Skip to content

Commit

Permalink
fixup! feat: add ledger support for VP delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonmaslowski committed Nov 27, 2024
1 parent e1de569 commit 534097a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions source/renderer/app/utils/dataSerialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,15 @@ export const toTxOutputAssets = (assets: CoinSelectionAssetsType) => {
return policyIdMap;
};

const parseVoteDelegation = (vote: string): [number] | [number, string] => {
const parseVoteDelegation = (vote: string): [number] | [number, Buffer] => {
if (!vote) throw new Error('Invalid voting power option');
if (vote === 'abstain') return [2];
if (vote === 'no_confidence') return [3];

const voteHash = utils.buf_to_hex(utils.bech32_decodeAddress(vote));
const voteHash = Buffer.from(
utils.buf_to_hex(utils.bech32_decodeAddress(vote)),
'hex'
);
return [vote.includes('_script') ? 1 : 0, voteHash];
};

Expand Down
6 changes: 4 additions & 2 deletions source/renderer/app/utils/shelleyLedger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ const parseVoteDelegation = (
};
}

const votHash = utils.buf_to_hex(utils.bech32_decodeAddress(cert.vote));

if (cert.vote.includes('_script')) {
return {
type: DRepParamsType.SCRIPT_HASH,
scriptHashHex: cert.vote,
scriptHashHex: votHash,
};
}

return {
type: DRepParamsType.KEY_HASH,
keyHashHex: cert.vote,
keyHashHex: votHash,
};
};

Expand Down

0 comments on commit 534097a

Please sign in to comment.