From fa91a6c926bbe2f6a2e22b002003e5826ab0ee03 Mon Sep 17 00:00:00 2001 From: yushi Date: Tue, 26 Sep 2023 02:53:45 +0800 Subject: [PATCH 1/9] show vote delegation certificate on UI --- .../components/signin/CardanoSignTxPage.js | 1 + .../components/signin/cardano/SignTx.js | 22 ++++++- .../app/connector/stores/ConnectorStore.js | 64 +++++++++++++++++- .../yoroi-extension/app/connector/types.js | 66 +++++++++++++++++++ 4 files changed, 150 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/connector/components/signin/CardanoSignTxPage.js b/packages/yoroi-extension/app/connector/components/signin/CardanoSignTxPage.js index 242eda283a..06aa33414d 100644 --- a/packages/yoroi-extension/app/connector/components/signin/CardanoSignTxPage.js +++ b/packages/yoroi-extension/app/connector/components/signin/CardanoSignTxPage.js @@ -395,6 +395,7 @@ class SignTxPage extends Component { id="walletPassword" /> } + cip95Info={txData.cip95Info} /> ); diff --git a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js index d612cb6081..7c4b38c532 100644 --- a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js +++ b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js @@ -1,6 +1,6 @@ // @flow import type { Node, ComponentType } from 'react'; -import type { ConnectorIntl } from '../../../types'; +import type { ConnectorIntl, Cip95Info } from '../../../types'; import type { SummaryAssetsData } from '../CardanoSignTxPage'; import BigNumber from 'bignumber.js'; import { injectIntl } from 'react-intl'; @@ -37,6 +37,7 @@ type Props = {| passwordFormField: Node, hwWalletError: ?LocalizableError, walletType: string, + cip95Info: Array, |}; function CardanoSignTx({ @@ -46,6 +47,7 @@ function CardanoSignTx({ passwordFormField, hwWalletError, walletType, + cip95Info, }: Props & ConnectorIntl): Node { const { total, isOnlyTxFee, sent, received } = txAssetsData; const isSendingNativeToken = Number(total.amount) < 0; @@ -53,6 +55,9 @@ function CardanoSignTx({ return ( + + + ( {children} ); + +const RenderCip95Info = ({ + cip95Info +}): Node => { + return [ + ...cip95Info.filter(c => c.type === 'VoteDelegCert').map((c, i) => { + if (c.type !== 'VoteDelegCert') { + throw new Error('unexpected type'); + } + return ( + Vote delegation to DRep: {c.drep} + ); + }) + ]; +} diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index c0f8339082..9fa22c460c 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -758,9 +758,68 @@ export default class ConnectorStore extends Store { } } + const cip95Info = []; + const certs = txBody.certs(); + if (certs) { + for (let i = 0; i < certs.len(); i++) { + const cert = certs.get(i); + if (!cert) { + throw new Error('unexpectedly missing certificate'); + } + const stakeRegistration = cert.as_stake_registration(); + if (stakeRegistration) { + const coin = stakeRegistration.coin()?.toString() ?? null; + cip95Info.push({ + type: 'StakeRegistrationCert', + coin, + }); + continue; + } + const stakeDeregistration = cert.as_stake_deregistration(); + if (stakeDeregistration) { + const coin = stakeDeregistration.coin()?.toString() ?? null; + cip95Info.push({ + type: 'StakeDeregistrationCert', + coin, + }); + continue; + } + const stakeDelegation = cert.as_stake_delegation(); + if (stakeDelegation) { + const keyHash = stakeDelegation.stake_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'StakeDelegationCert', + poolKeyHash: keyHash.to_hex(), + }); + } + continue; + } + const voteDelegation = cert.as_vote_delegation(); + if (voteDelegation) { + const keyHash = voteDelegation.stake_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'VoteDelegCert', + drep: voteDelegation.drep().to_hex(), + }); + } + continue; + } + // ... + } + } runInAction(() => { - // $FlowFixMe[prop-missing] - this.adaTransaction = { inputs, foreignInputs, outputs, fee, total, amount }; + this.adaTransaction = { + inputs, + // $FlowFixMe[prop-missing] + foreignInputs, + outputs, + fee, + total, + amount, + cip95Info, + }; }); }; @@ -849,6 +908,7 @@ export default class ConnectorStore extends Store { fee, amount, total, + cip95Info: [], }; }); }; diff --git a/packages/yoroi-extension/app/connector/types.js b/packages/yoroi-extension/app/connector/types.js index 5c94444425..e91038ac92 100644 --- a/packages/yoroi-extension/app/connector/types.js +++ b/packages/yoroi-extension/app/connector/types.js @@ -23,6 +23,71 @@ export type TxDataFee = {| amount: string, |}; +export type Anchor = {| + url: string, + dataHash: string, +|}; + +export type Cip95Info = {| + type: 'StakeRegistrationCert', + coin: string | null, +|} | {| + type: 'StakeDeregistrationCert', + coin: string | null, +|} | {| + type: 'StakeDelegationCert', + poolKeyHash: string, +|} | {| + type: 'VoteDelegCert', + drep: string, +|} | {| + type: 'StakeVoteDelegCert', + poolKeyHash: string, + drep: string, +|} | {| + type: 'StakeRegDelegCert', + poolKeyHash: string, + coin: string, +|} | {| + type: 'VoteRegDelegCert', + drep: string, + coin: string, +|} | {| + type: 'StakeVoteRegDelegCert', + poolKeyHash: string, + drep: string, + coin: string, +|} | {| + type: 'RegDrepCert', + coin: string, + anchor: Anchor | null, +|} | {| + type: 'UnregDrepCert', + coin: string, +|} | {| + type: 'UpdateDrepCert', + anchor: Anchor | null, +|} | {| + type: 'VotingProcedure', + voterType: number, + voterHash: string, + govActionTxId: string, + govActionIndex: string, + vote: 0 | 1 | 2, + anchor: Anchor, +|} | {| + type: 'ProposalProcedure', + deposit: string, + reward_account: string, + govAction: any, // todo + anchor: Anchor, +|} | {| + type: 'TresuryValue', + coin: string, +|} | {| + type: 'TresuryDonation', + positiveCoin: string, +|} export type CardanoConnectorSignRequest = {| inputs: Array, foreignInputs: Array, @@ -30,6 +95,7 @@ export type CardanoConnectorSignRequest = {| fee: TxDataFee, amount: MultiToken, total: MultiToken, + cip95Info: Array, |}; export type SignSubmissionErrorType = 'WRONG_PASSWORD' | 'SEND_TX_ERROR'; From eb1e65bc32f85c6b1f36c00394d730958a0a5ba0 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 28 Sep 2023 02:04:27 +0800 Subject: [PATCH 2/9] deserialize more cip95 data --- .../app/connector/stores/ConnectorStore.js | 163 +++++++++++++++++- .../yoroi-extension/app/connector/types.js | 10 +- 2 files changed, 166 insertions(+), 7 deletions(-) diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index 9fa22c460c..0f8eaf6b13 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -19,8 +19,14 @@ import type { } from '../../../chrome/extension/connector/types'; import type { ActionsMap } from '../actions/index'; import type { StoresMap } from './index'; -import type { CardanoConnectorSignRequest, SignSubmissionErrorType, TxDataInput, TxDataOutput, } from '../types'; import { LoadingWalletStates } from '../types'; +import type { + CardanoConnectorSignRequest, + SignSubmissionErrorType, + TxDataInput, + TxDataOutput, + Anchor, +} from '../types'; import type { ISignRequest } from '../../api/common/lib/transactions/ISignRequest'; import type { GetUtxoDataResponse, RemoteUnspentOutput, UtxoData, } from '../../api/ada/lib/state-fetch/types'; import { WrongPassphraseError } from '../../api/ada/lib/cardanoCrypto/cryptoErrors'; @@ -806,9 +812,149 @@ export default class ConnectorStore extends Store { } continue; } - // ... + const stakeVoteDelegation = cert.as_stake_and_vote_delegation(); + if (stakeVoteDelegation) { + const keyHash = stakeVoteDelegation.stake_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'StakeVoteDelegCert', + drep: stakeVoteDelegation.drep().to_hex(), + poolKeyHash: stakeVoteDelegation.pool_keyhash().to_hex(), + }); + } + continue; + } + const stakeRegDelegation = cert.as_stake_registration_and_delegation(); + if (stakeRegDelegation) { + const keyHash = stakeRegDelegation.stake_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'StakeRegDelegCert', + poolKeyHash: stakeRegDelegation.pool_keyhash().to_hex(), + coin: stakeRegDelegation.coin().to_str(), + }); + } + continue; + } + const voteRegDelegation = cert.as_vote_registration_and_delegation(); + if (voteRegDelegation) { + const keyHash = voteRegDelegation.stake_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'VoteRegDelegCert', + drep: voteRegDelegation.drep().to_hex(), + coin: voteRegDelegation.coin().to_str(), + }); + } + continue; + } + const stakeRegVoteDeletion = cert.as_stake_vote_registration_and_delegation(); + if (stakeRegVoteDeletion) { + const keyHash = stakeRegVoteDeletion.stake_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'StakeVoteRegDelegCert', + poolKeyHash: stakeRegVoteDeletion.pool_keyhash().to_hex(), + drep: stakeRegVoteDeletion.drep().to_hex(), + coin: stakeRegVoteDeletion.coin().to_str(), + }); + } + continue; + } + const regDrep = cert.as_drep_registration(); + if (regDrep) { + const keyHash = regDrep.voting_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'RegDrepCert', + coin: regDrep.coin().to_str(), + anchor: deserializeAnchor(regDrep.anchor()), + }); + } + continue; + } + const unregDrep = cert.as_drep_deregistration(); + if (unregDrep) { + const keyHash = unregDrep.voting_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'UnregDrepCert', + coin: unregDrep.coin().to_str(), + }); + } + continue; + } + const updateDrep = cert.as_drep_update(); + if (updateDrep) { + const keyHash = updateDrep.voting_credential().to_keyhash(); + if (keyHash) { + cip95Info.push({ + type: 'UpdateDrepCert', + anchor: deserializeAnchor(updateDrep.anchor()), + }); + } + continue; + } + } + } + const votingProcedures = txBody.voting_procedures(); + if (votingProcedures) { + const voters = votingProcedures.get_voters(); + for (let i = 0; i < voters.len(); i++) { + const voter = voters.get(i); + if (!voter) { + throw new Error('unexpectedly missing voter'); + } + const govActionIds = votingProcedures.get_governance_action_ids_by_voter( + voter + ); + for (let j = 0; i < govActionIds.len(); j++) { + const govActionId = govActionIds.get(j); + if (!govActionId) { + throw new Error('unexpectedly missing governance action id'); + } + const votingProcedure = votingProcedures.get(voter, govActionId); + if (!votingProcedure) { + throw new Error('unexpectedly missing voting procedure'); + } + cip95Info.push({ + type: 'VotingProcedure', + voterType: voter.kind(), + voterHash: voter.to_constitutional_committee_hot_cred()?.to_scripthash()?.to_hex() || + voter.to_constitutional_committee_hot_cred()?.to_keyhash()?.to_hex() || + voter.to_drep_cred()?.to_scripthash()?.to_hex() || + voter.to_drep_cred()?.to_keyhash()?.to_hex() || + voter.to_staking_pool_key_hash()?.to_hex() || + (() => { throw new Error('unexpected voter'); })(), + govActionTxId: govActionId.transaction_id().to_hex(), + govActionIndex: govActionId.index(), + vote: votingProcedure.vote_kind(), + anchor: deserializeAnchor(votingProcedure.anchor()), + }); + } + } + } + const votingProposals = txBody.voting_proposals(); + if (votingProposals) { + for (let i = 0; i < votingProposals.len(); i++) { + const votingProposal = votingProposals.get(i); + // wait for CSL update } } + const currentTreasuryValue = txBody.current_treasury_value(); + if (currentTreasuryValue) { + cip95Info.push({ + type: 'TreasuryValue', + coin: currentTreasuryValue.to_str(), + }); + } + const donation = txBody.donation(); + if (donation) { + cip95Info.push({ + type: 'TreasuryDonation', + positiveCoin: donation.to_str(), + }); + } runInAction(() => { this.adaTransaction = { inputs, @@ -1337,3 +1483,16 @@ export default class ConnectorStore extends Store { } } } + +function deserializeAnchor(anchor: ?RustModule.WalletV4.Anchor): Anchor | null { + if (!anchor) { + return null; + } + return { + url: anchor.url().url(), + dataHash: anchor.anchor_data_hash().to_hex(), + }; +} + + + diff --git a/packages/yoroi-extension/app/connector/types.js b/packages/yoroi-extension/app/connector/types.js index e91038ac92..124c2918ff 100644 --- a/packages/yoroi-extension/app/connector/types.js +++ b/packages/yoroi-extension/app/connector/types.js @@ -72,9 +72,9 @@ export type Cip95Info = {| voterType: number, voterHash: string, govActionTxId: string, - govActionIndex: string, - vote: 0 | 1 | 2, - anchor: Anchor, + govActionIndex: number, + vote: number, // 0 | 1 | 2, + anchor: Anchor | null, |} | {| type: 'ProposalProcedure', deposit: string, @@ -82,10 +82,10 @@ export type Cip95Info = {| govAction: any, // todo anchor: Anchor, |} | {| - type: 'TresuryValue', + type: 'TreasuryValue', coin: string, |} | {| - type: 'TresuryDonation', + type: 'TreasuryDonation', positiveCoin: string, |} export type CardanoConnectorSignRequest = {| From a74c965fdd93ac955b76fe84519264d526479669 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 28 Sep 2023 17:41:54 +0800 Subject: [PATCH 3/9] add more certificate UI --- .../components/signin/cardano/SignTx.js | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js index 7c4b38c532..121b7e35d3 100644 --- a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js +++ b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js @@ -203,6 +203,59 @@ const RenderCip95Info = ({ return ( Vote delegation to DRep: {c.drep} ); - }) + }), + ...cip95Info.filter(c => c.type === 'StakeVoteDelegCert').map((c, i) => { + if (c.type !== 'StakeVoteDelegCert') { + throw new Error('unexpected type'); + } + return ( +
+

Delegate to the stake pool ${c.poolKeyHash}

+

and DRep ${c.drep}

+
+ ); + }), + ...cip95Info.filter(c => c.type === 'StakeRegDelegCert').map((c, i) => { + if (c.type !== 'StakeRegDelegCert') { + throw new Error('unexpected type'); + } + return ( +
+

Register your stake credential with deposit of ${c.coin} ADA and delegate to stake pool

+

${c.poolKeyHash}

+
+ ); + }), + ...cip95Info.filter(c => c.type === 'VoteRegDelegCert').map((c, i) => { + if (c.type !== 'VoteRegDelegCert') { + throw new Error('unexpected type'); + } + return ( +
+

Register your stake credential with deposit of ${c.coin} ADA and delegate to the DRep

+

${c.drep}

+
+ ); + }), + ...cip95Info.filter(c => c.type === 'StakeVoteRegDelegCert').map((c, i) => { + if (c.type !== 'StakeVoteRegDelegCert') { + throw new Error('unexpected type'); + } + return ( +
+

Register your stake credential with deposit of ${c.coin} ADA and delegate to the DRep

+

${c.drep} and the stake pool

+

${c.poolKeyHash}

+
+ ); + }), + ...cip95Info.filter(c => c.type === 'TreasuryDonation').map((c, i) => { + if (c.type !== 'TreasuryDonation') { + throw new Error('unexpected type'); + } + return ( + Treasury donation: {c.positiveCoin} ADA + ); + }), ]; } From b6cfc26c25fe8e98f5bcfebe8d4fc58c153c2f14 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 28 Sep 2023 17:53:40 +0800 Subject: [PATCH 4/9] add more certificate UI --- .../components/signin/cardano/SignTx.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js index 121b7e35d3..06eb4d09d4 100644 --- a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js +++ b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js @@ -257,5 +257,47 @@ const RenderCip95Info = ({ Treasury donation: {c.positiveCoin} ADA ); }), + ...cip95Info.filter(c => c.type === 'RegDrepCert').map((c, i) => { + if (c.type !== 'RegDrepCert') { + throw new Error('unexpected type'); + } + return ( +
+

Register DRep credential with deposit ${c.coin} ADA

+ {c.anchor && ( + <> +

URL: {c.anchor.url}

+

Hash: {c.anchor.dataHash}

+ + )} +
+ ); + }), + ...cip95Info.filter(c => c.type === 'UnregDrepCert').map((c, i) => { + if (c.type !== 'UnregDrepCert') { + throw new Error('unexpected type'); + } + return ( + + Unregister DRep credential and return ${c.coin} ADA deposit + + ); + }), + ...cip95Info.filter(c => c.type === 'UpdateDrepCert').map((c, i) => { + if (c.type !== 'UpdateDrepCert') { + throw new Error('unexpected type'); + } + return ( +
+

Update DRep credential

+ {c.anchor && ( + <> +

URL: {c.anchor.url}

+

Hash: {c.anchor.dataHash}

+ + )} +
+ ); + }), ]; } From de8e6aa6bdcb1762cdcf568ccbe6375051bf1c42 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 28 Sep 2023 18:28:24 +0800 Subject: [PATCH 5/9] add more certificate UI --- .../components/signin/cardano/SignTx.js | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js index 06eb4d09d4..85382d0dd0 100644 --- a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js +++ b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js @@ -196,6 +196,32 @@ const RenderCip95Info = ({ cip95Info }): Node => { return [ + ...cip95Info.filter(c => c.type === 'StakeRegistrationCert').map((c, i) => { + if (c.type !== 'StakeRegistrationCert') { + throw new Error('unexpected type'); + } + return ( +
+ Register stake credential + {c.coin && ( + with {c.coin} ADA deposit + )} +
+ ); + }), + ...cip95Info.filter(c => c.type === 'StakeDeregistrationCert').map((c, i) => { + if (c.type !== 'StakeDeregistrationCert') { + throw new Error('unexpected type'); + } + return ( +
+ Deregister stake credential + {c.coin && ( + and return {c.coin} ADA deposit + )} +
+ ); + }), ...cip95Info.filter(c => c.type === 'VoteDelegCert').map((c, i) => { if (c.type !== 'VoteDelegCert') { throw new Error('unexpected type'); @@ -221,7 +247,7 @@ const RenderCip95Info = ({ } return (
-

Register your stake credential with deposit of ${c.coin} ADA and delegate to stake pool

+

Register your stake credential with deposit of {c.coin} ADA and delegate to stake pool

${c.poolKeyHash}

); @@ -232,7 +258,7 @@ const RenderCip95Info = ({ } return (
-

Register your stake credential with deposit of ${c.coin} ADA and delegate to the DRep

+

Register your stake credential with deposit of {c.coin} ADA and delegate to the DRep

${c.drep}

); @@ -243,7 +269,7 @@ const RenderCip95Info = ({ } return (
-

Register your stake credential with deposit of ${c.coin} ADA and delegate to the DRep

+

Register your stake credential with deposit of {c.coin} ADA and delegate to the DRep

${c.drep} and the stake pool

${c.poolKeyHash}

@@ -263,7 +289,7 @@ const RenderCip95Info = ({ } return (
-

Register DRep credential with deposit ${c.coin} ADA

+

Register DRep credential with deposit {c.coin} ADA

{c.anchor && ( <>

URL: {c.anchor.url}

@@ -279,7 +305,7 @@ const RenderCip95Info = ({ } return ( - Unregister DRep credential and return ${c.coin} ADA deposit + Unregister DRep credential and return {c.coin} ADA deposit ); }), From cb4a8a26d589dae0f0600cfd32fe590e682f40fe Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 28 Sep 2023 18:57:48 +0800 Subject: [PATCH 6/9] add more certificate UI --- .../components/signin/cardano/SignTx.js | 89 +++++++++++++------ 1 file changed, 62 insertions(+), 27 deletions(-) diff --git a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js index 85382d0dd0..463257ae6f 100644 --- a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js +++ b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js @@ -222,12 +222,20 @@ const RenderCip95Info = ({
); }), + ...cip95Info.filter(c => c.type === 'StakeDelegationCert').map((c, i) => { + if (c.type !== 'StakeDelegationCert') { + throw new Error('unexpected type'); + } + return ( +
Stake delegation to the pool: {c.poolKeyHash}
+ ); + }), ...cip95Info.filter(c => c.type === 'VoteDelegCert').map((c, i) => { if (c.type !== 'VoteDelegCert') { throw new Error('unexpected type'); } return ( - Vote delegation to DRep: {c.drep} +
Vote delegation to DRep: {c.drep}
); }), ...cip95Info.filter(c => c.type === 'StakeVoteDelegCert').map((c, i) => { @@ -236,8 +244,8 @@ const RenderCip95Info = ({ } return (
-

Delegate to the stake pool ${c.poolKeyHash}

-

and DRep ${c.drep}

+
Delegate to the stake pool ${c.poolKeyHash}
+
and DRep ${c.drep}
); }), @@ -247,8 +255,8 @@ const RenderCip95Info = ({ } return (
-

Register your stake credential with deposit of {c.coin} ADA and delegate to stake pool

-

${c.poolKeyHash}

+
Register your stake credential with deposit of {c.coin} ADA and delegate to stake pool
+
${c.poolKeyHash}
); }), @@ -258,8 +266,8 @@ const RenderCip95Info = ({ } return (
-

Register your stake credential with deposit of {c.coin} ADA and delegate to the DRep

-

${c.drep}

+
Register your stake credential with deposit of {c.coin} ADA and delegate to the DRep
+
${c.drep}
); }), @@ -269,31 +277,23 @@ const RenderCip95Info = ({ } return (
-

Register your stake credential with deposit of {c.coin} ADA and delegate to the DRep

-

${c.drep} and the stake pool

-

${c.poolKeyHash}

+
Register your stake credential with deposit of {c.coin} ADA and delegate to the DRep
+
${c.drep} and the stake pool
+
${c.poolKeyHash}
); }), - ...cip95Info.filter(c => c.type === 'TreasuryDonation').map((c, i) => { - if (c.type !== 'TreasuryDonation') { - throw new Error('unexpected type'); - } - return ( - Treasury donation: {c.positiveCoin} ADA - ); - }), ...cip95Info.filter(c => c.type === 'RegDrepCert').map((c, i) => { if (c.type !== 'RegDrepCert') { throw new Error('unexpected type'); } return (
-

Register DRep credential with deposit {c.coin} ADA

+
Register DRep credential with deposit {c.coin} ADA
{c.anchor && ( <> -

URL: {c.anchor.url}

-

Hash: {c.anchor.dataHash}

+
URL: {c.anchor.url}
+
Hash: {c.anchor.dataHash}
)}
@@ -304,9 +304,9 @@ const RenderCip95Info = ({ throw new Error('unexpected type'); } return ( - +
Unregister DRep credential and return {c.coin} ADA deposit - +
); }), ...cip95Info.filter(c => c.type === 'UpdateDrepCert').map((c, i) => { @@ -315,15 +315,50 @@ const RenderCip95Info = ({ } return (
-

Update DRep credential

+
Update DRep credential
{c.anchor && ( <> -

URL: {c.anchor.url}

-

Hash: {c.anchor.dataHash}

+
URL: {c.anchor.url}
+
Hash: {c.anchor.dataHash}
)}
); }), - ]; + ...cip95Info.filter(c => c.type === 'TreasuryValue').map((c, i) => { + if (c.type !== 'TreasuryValue') { + throw new Error('unexpected type'); + } + return ( +
Treasury value: {c.coin} ADA
+ ); + }), + ...cip95Info.filter(c => c.type === 'TreasuryDonation').map((c, i) => { + if (c.type !== 'TreasuryDonation') { + throw new Error('unexpected type'); + } + return ( +
Treasury donation: {c.positiveCoin} ADA
+ ); + }), + ...cip95Info.filter(c => c.type === 'VotingProcedure').map((c, i) => { + if (c.type !== 'VotingProcedure') { + throw new Error('unexpected type'); + } + return ( +
+
Voter: {c.voterHash}
+
Governance action transaction: {c.govActionTxId}
+
Governance action index: {c.govActionIndex}
+
Vote: {['no', 'yes', 'abstain'][c.vote]}
+ {c.anchor && ( +
+
URL: {c.anchor.url}
+
Hash: {c.anchor.dataHash}
+
+ )} +
+ ); + }), + ]; } From bfc8ccb8f3cb5ed3188a464c9bb0ba2f6e2970aa Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 3 Nov 2023 00:51:53 +0800 Subject: [PATCH 7/9] lint --- packages/yoroi-extension/app/connector/stores/ConnectorStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index 0f8eaf6b13..1ef0ddca07 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -937,7 +937,7 @@ export default class ConnectorStore extends Store { const votingProposals = txBody.voting_proposals(); if (votingProposals) { for (let i = 0; i < votingProposals.len(); i++) { - const votingProposal = votingProposals.get(i); + const _votingProposal = votingProposals.get(i); // wait for CSL update } } From d6410faf89b82dfd3646f177b0cd3d0be4a7fd85 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Wed, 15 Nov 2023 15:46:26 +0300 Subject: [PATCH 8/9] added br --- .../components/signin/cardano/SignTx.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js index 463257ae6f..987401a62a 100644 --- a/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js +++ b/packages/yoroi-extension/app/connector/components/signin/cardano/SignTx.js @@ -57,6 +57,7 @@ function CardanoSignTx({ +
( const RenderCip95Info = ({ cip95Info }): Node => { + function renderCoin(c) { + try { + return new BigNumber(c).div(1_000_000).toString(); + } catch (e) { + console.error(e); + return String(c); + } + } return [ ...cip95Info.filter(c => c.type === 'StakeRegistrationCert').map((c, i) => { if (c.type !== 'StakeRegistrationCert') { @@ -204,7 +213,7 @@ const RenderCip95Info = ({
Register stake credential {c.coin && ( - with {c.coin} ADA deposit + with {renderCoin(c.coin)} ADA deposit )}
); @@ -217,7 +226,7 @@ const RenderCip95Info = ({
Deregister stake credential {c.coin && ( - and return {c.coin} ADA deposit + and return {renderCoin(c.coin)} ADA deposit )}
); @@ -255,7 +264,7 @@ const RenderCip95Info = ({ } return (
-
Register your stake credential with deposit of {c.coin} ADA and delegate to stake pool
+
Register your stake credential with deposit of {renderCoin(c.coin)} ADA and delegate to stake pool
${c.poolKeyHash}
); @@ -266,7 +275,7 @@ const RenderCip95Info = ({ } return (
-
Register your stake credential with deposit of {c.coin} ADA and delegate to the DRep
+
Register your stake credential with deposit of {renderCoin(c.coin)} ADA and delegate to the DRep
${c.drep}
); @@ -277,7 +286,7 @@ const RenderCip95Info = ({ } return (
-
Register your stake credential with deposit of {c.coin} ADA and delegate to the DRep
+
Register your stake credential with deposit of {renderCoin(c.coin)} ADA and delegate to the DRep
${c.drep} and the stake pool
${c.poolKeyHash}
@@ -289,7 +298,7 @@ const RenderCip95Info = ({ } return (
-
Register DRep credential with deposit {c.coin} ADA
+
Register DRep credential with deposit {renderCoin(c.coin)} ADA
{c.anchor && ( <>
URL: {c.anchor.url}
@@ -305,7 +314,7 @@ const RenderCip95Info = ({ } return (
- Unregister DRep credential and return {c.coin} ADA deposit + Unregister DRep credential and return {renderCoin(c.coin)} ADA deposit
); }), @@ -330,7 +339,7 @@ const RenderCip95Info = ({ throw new Error('unexpected type'); } return ( -
Treasury value: {c.coin} ADA
+
Treasury value: {renderCoin(c.coin)} ADA
); }), ...cip95Info.filter(c => c.type === 'TreasuryDonation').map((c, i) => { @@ -338,7 +347,7 @@ const RenderCip95Info = ({ throw new Error('unexpected type'); } return ( -
Treasury donation: {c.positiveCoin} ADA
+
Treasury donation: {renderCoin(c.positiveCoin)} ADA
); }), ...cip95Info.filter(c => c.type === 'VotingProcedure').map((c, i) => { From d64dbf82645849fc77a1b3fdcc24eb6878383492 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Wed, 15 Nov 2023 18:19:48 +0300 Subject: [PATCH 9/9] lint fixes --- packages/yoroi-extension/app/connector/stores/ConnectorStore.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index 1ef0ddca07..bb156a6db0 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -937,6 +937,7 @@ export default class ConnectorStore extends Store { const votingProposals = txBody.voting_proposals(); if (votingProposals) { for (let i = 0; i < votingProposals.len(); i++) { + // eslint-disable-next-line no-unused-vars const _votingProposal = votingProposals.get(i); // wait for CSL update }