From 534097a56f3888bf3dabb076027ea27174877563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Mas=C5=82owski?= Date: Tue, 26 Nov 2024 14:01:21 +0100 Subject: [PATCH] fixup! feat: add ledger support for VP delegation --- source/renderer/app/utils/dataSerialization.ts | 7 +++++-- source/renderer/app/utils/shelleyLedger.ts | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source/renderer/app/utils/dataSerialization.ts b/source/renderer/app/utils/dataSerialization.ts index 2c9fd47263..7479b2f196 100644 --- a/source/renderer/app/utils/dataSerialization.ts +++ b/source/renderer/app/utils/dataSerialization.ts @@ -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]; }; diff --git a/source/renderer/app/utils/shelleyLedger.ts b/source/renderer/app/utils/shelleyLedger.ts index af87c3eea8..0b80074c5f 100644 --- a/source/renderer/app/utils/shelleyLedger.ts +++ b/source/renderer/app/utils/shelleyLedger.ts @@ -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, }; };