Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft changes needed for sript dreps #1956

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions govtool/backend/sql/get-drep-info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ WITH DRepId AS (
SELECT
decode(?, 'hex') AS raw
),
IsScriptHash AS (
SELECT
drep_hash.has_script AS value
FROM
drep_hash
WHERE
drep_hash.raw = DRepId.raw
),
AllRegistrationEntries AS (
SELECT
drep_registration.voting_anchor_id AS voting_anchor_id,
Expand Down Expand Up @@ -165,6 +173,7 @@ SoleVoterRetire AS (
LIMIT 1
)
SELECT
IsScriptHash.value,
IsRegisteredAsDRep.value,
WasRegisteredAsDRep.value,
IsRegisteredAsSoleVoter.value,
Expand All @@ -185,6 +194,7 @@ SELECT
off_chain_vote_drep_data.image_url,
off_chain_vote_drep_data.image_hash
FROM
IsScriptHash
IsRegisteredAsDRep
CROSS JOIN IsRegisteredAsSoleVoter
CROSS JOIN WasRegisteredAsDRep
Expand Down
2 changes: 2 additions & 0 deletions govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ DRepActivity AS (
SELECT
encode(dh.raw, 'hex'),
dh.view,
dh.has_script,
va.url,
encode(va.data_hash, 'hex'),
dr_deposit.deposit,
Expand Down Expand Up @@ -128,6 +129,7 @@ GROUP BY
dh.raw,
second_to_newest_drep_registration.voting_anchor_id,
dh.view,
dh.has_script,
va.url,
va.data_hash,
dr_deposit.deposit,
Expand Down
3 changes: 2 additions & 1 deletion govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ listDReps = withPool $ \conn -> do
results <- liftIO $ SQL.query_ conn listDRepsSql
timeZone <- liftIO getCurrentTimeZone
return
[ DRepRegistration drepHash drepView url dataHash (floor @Scientific deposit) votingPower status drepType txHash (localTimeToUTC timeZone date) paymentAddress givenName objectives motivations qualifications imageUrl imageHash
[ DRepRegistration drepHash drepView hashScript url dataHash (floor @Scientific deposit) votingPower status drepType txHash (localTimeToUTC timeZone date) paymentAddress givenName objectives motivations qualifications imageUrl imageHash
| ( drepHash
, drepView
, hashScript
, url
, dataHash
, deposit
Expand Down
4 changes: 3 additions & 1 deletion govtool/frontend/src/context/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,10 @@ const CardanoProvider = (props: Props) => {
targetDRep = DRep.new_always_abstain();
} else if (target === AutomatedVotingOptionDelegationId.no_confidence) {
targetDRep = DRep.new_always_no_confidence();
} else if (target.includes("drep")) {
} else if (target.includes("drep1")) {
targetDRep = DRep.new_key_hash(Ed25519KeyHash.from_bech32(target));
} else if (target.includes("drep_script1")) {
targetDRep = DRep.new_script_hash(Ed25519KeyHash.from_bech32(target));
} else {
targetDRep = DRep.new_key_hash(Ed25519KeyHash.from_hex(target));
}
Expand Down
9 changes: 7 additions & 2 deletions govtool/frontend/src/utils/getDRepID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

import { CardanoApiWallet } from "@models";

export const formHexToBech32 = (dRepID?: string) => {
export const formHexToBech32 = (dRepID?: string, isScript?: boolean) => {
if (!dRepID) return;
const words = bech32.toWords(Buffer.from(dRepID, "hex"));
const dRepIDBech32 = bech32.encode("drep", words);
let dRepIDBech32;
if (isScript){

Check failure on line 11 in govtool/frontend/src/utils/getDRepID.ts

View workflow job for this annotation

GitHub Actions / lint

Missing space before opening brace
dRepIDBech32 = bech32.encode("drep_script", words);
} else {
dRepIDBech32 = bech32.encode("drep", words);
}
return dRepIDBech32;
};

Expand Down
Loading