diff --git a/apps/browser-extension-wallet/.env.defaults b/apps/browser-extension-wallet/.env.defaults index 5925a8b29c..0ef5c78c06 100644 --- a/apps/browser-extension-wallet/.env.defaults +++ b/apps/browser-extension-wallet/.env.defaults @@ -4,7 +4,7 @@ DEFAULT_CHAIN=Mainnet WALLET_SYNC_TIMEOUT_IN_SEC=60 WALLET_INTERVAL_IN_SEC=30 DROP_CONSOLE_IN_PRODUCTION=false -AVAILABLE_CHAINS=Preprod,Preview,Mainnet,Sanchonet +AVAILABLE_CHAINS=Preprod,Preview,Mainnet ADA_PRICE_POLLING_IN_SEC=60 TOKEN_PRICE_POLLING_IN_SEC=300 SAVED_PRICE_DURATION_IN_MINUTES=720 @@ -75,7 +75,7 @@ ADA_HANDLE_URL_MAINNET=https://api.handle.me ADA_HANDLE_URL_PREVIEW=https://preview.api.handle.me ADA_HANDLE_URL_PREPROD=https://preprod.api.handle.me # TODO: update this with a valid sanchonet url -ADA_HANDLE_URL_SANCHONET=https://preprod.api.handle.me +ADA_HANDLE_URL_SANCHONET= # Manifest.json LACE_EXTENSION_KEY=gafhhkghbfjjkeiendhlofajokpaflmk diff --git a/apps/browser-extension-wallet/src/features/ada-handle/config.ts b/apps/browser-extension-wallet/src/features/ada-handle/config.ts index 0cfabe0985..17b0d4af28 100644 --- a/apps/browser-extension-wallet/src/features/ada-handle/config.ts +++ b/apps/browser-extension-wallet/src/features/ada-handle/config.ts @@ -3,10 +3,8 @@ import { Wallet } from '@lace/cardano'; export const ADA_HANDLE_POLICY_ID = Wallet.ADA_HANDLE_POLICY_ID; export const isAdaHandleEnabled = process.env.USE_ADA_HANDLE === 'true'; -export const HANDLE_SERVER_URLS: Record = { +export const HANDLE_SERVER_URLS: Record, string> = { [Cardano.NetworkMagics.Mainnet]: 'https://api.handle.me', [Cardano.NetworkMagics.Preprod]: 'https://preprod.api.handle.me', - [Cardano.NetworkMagics.Preview]: 'https://preview.api.handle.me', - // TODO: update once there's a valid sanchonet version available - [Cardano.NetworkMagics.Sanchonet]: 'https://sanchonet.api.handle.me' + [Cardano.NetworkMagics.Preview]: 'https://preview.api.handle.me' }; diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmVoteDelegationContainer.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmVoteDelegationContainer.tsx index bbd58e6461..52f08895b3 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmVoteDelegationContainer.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmVoteDelegationContainer.tsx @@ -14,10 +14,9 @@ interface Props { export const ConfirmVoteDelegationContainer = ({ signTxData, errorMessage }: Props): React.ReactElement => { const { t } = useTranslation(); - const certificate = certificateInspectorFactory( + const { dRep } = certificateInspectorFactory( CertificateType.VoteDelegation )(signTxData.tx); - const dRep = certificate.dRep; return ( { +export enum VoterType { + CONSTITUTIONAL_COMMITTEE = 'constitutionalCommittee', + SPO = 'spo', + DREP = 'drep' +} + +export const getVoterType = (voterType: Wallet.Cardano.VoterType): VoterType => { switch (voterType) { case Wallet.Cardano.VoterType.ccHotKeyHash: case Wallet.Cardano.VoterType.ccHotScriptHash: - return 'Constitutional Committee'; + return VoterType.CONSTITUTIONAL_COMMITTEE; case Wallet.Cardano.VoterType.stakePoolKeyHash: - return 'SPO'; + return VoterType.SPO; case Wallet.Cardano.VoterType.dRepKeyHash: case Wallet.Cardano.VoterType.dRepScriptHash: default: - return 'DRep'; + return VoterType.DREP; } }; -export const getVote = (vote: Wallet.Cardano.Vote): string => { +export enum Votes { + YES = 'yes', + NO = 'no', + ABSTAIN = 'abstain' +} + +export const getVote = (vote: Wallet.Cardano.Vote): Votes => { switch (vote) { case Wallet.Cardano.Vote.yes: - return 'Yes'; + return Votes.YES; case Wallet.Cardano.Vote.no: - return 'No'; + return Votes.NO; case Wallet.Cardano.Vote.abstain: default: - return 'Abstain'; + return Votes.ABSTAIN; } }; @@ -56,12 +68,12 @@ export const VotingProceduresContainer = ({ signTxData, errorMessage }: Props): const voterType = getVoterType(votingProcedure.voter.__typename); const drepId = - voterType === 'DRep' + voterType === VoterType.DREP ? drepIDasBech32FromHash(votingProcedure.voter.credential.hash) : votingProcedure.voter.credential.hash.toString(); return { voter: { - type: voterType, + type: t(`core.votingProcedures.voterType.${voterType}`), dRepId: drepId }, votes: votingProcedure.votes.map((vote) => ({ @@ -71,7 +83,7 @@ export const VotingProceduresContainer = ({ signTxData, errorMessage }: Props): ...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${vote.actionId.id}` }) }, votingProcedure: { - vote: getVote(vote.votingProcedure.vote), + vote: t(`core.votingProcedures.votes.${getVote(vote.votingProcedure.vote)}`), anchor: !!vote.votingProcedure.anchor?.url && { url: vote.votingProcedure.anchor?.url, hash: vote.votingProcedure.anchor?.dataHash.toString() diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/__tests__/VotingProceduresContainer.test.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/__tests__/VotingProceduresContainer.test.tsx index 984806f75a..c02aa5f70c 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/__tests__/VotingProceduresContainer.test.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/__tests__/VotingProceduresContainer.test.tsx @@ -11,7 +11,7 @@ const mockPreprodCexplorerBaseUrl = 'PREPROD_CEXPLORER_BASE_URL'; const mockCexplorerUrlPathsTx = 'CEXPLORER_URL_PATHS.TX'; import * as React from 'react'; import { cleanup, render } from '@testing-library/react'; -import { VotingProceduresContainer, getVote, getVoterType } from '../VotingProceduresContainer'; +import { VoterType, Votes, VotingProceduresContainer, getVote, getVoterType } from '../VotingProceduresContainer'; import '@testing-library/jest-dom'; import { I18nextProvider } from 'react-i18next'; import { StoreProvider } from '@src/stores'; @@ -203,7 +203,7 @@ describe('Testing VotingProceduresContainer component', () => { expect(queryByTestId('VotingProcedures')).toBeInTheDocument(); // eslint-disable-next-line unicorn/consistent-function-scoping const getExpectedDrepId = (type: string) => (hash: Wallet.Crypto.Hash28ByteBase16) => - type === 'DRep' + type === VoterType.DREP ? Wallet.Cardano.DRepID(Wallet.HexBlob.toTypedBech32('drep', Wallet.HexBlob(hash))) : hash.toString(); expect(mockVotingProcedures).toHaveBeenLastCalledWith( @@ -211,7 +211,7 @@ describe('Testing VotingProceduresContainer component', () => { dappInfo, data: voters.map(({ __typename }, index) => ({ voter: { - type: getVoterType(__typename), + type: t(`core.votingProcedures.voterType.${getVoterType(__typename)}`), dRepId: getExpectedDrepId(getVoterType(__typename))(voters[index].credential.hash) }, votes: votingProcedures[index].votes.map((vote) => ({ @@ -221,7 +221,7 @@ describe('Testing VotingProceduresContainer component', () => { txHashUrl: `${mockPreprodCexplorerBaseUrl}/${mockCexplorerUrlPathsTx}/${vote.actionId.id}` }, votingProcedure: { - vote: getVote(vote.votingProcedure.vote), + vote: t(`core.votingProcedures.votes.${getVote(vote.votingProcedure.vote)}`), anchor: !!vote.votingProcedure.anchor?.url && { url: vote.votingProcedure.anchor?.url, hash: vote.votingProcedure.anchor?.dataHash.toString() @@ -279,16 +279,16 @@ describe('Testing VotingProceduresContainer component', () => { }); test('testing getVoterType', () => { - expect(getVoterType(constitutionalCommitteeKeyHashVoter.__typename)).toEqual('Constitutional Committee'); - expect(getVoterType(constitutionalCommitteeScriptHashVoter.__typename)).toEqual('Constitutional Committee'); - expect(getVoterType(drepKeyHashVoter.__typename)).toEqual('DRep'); - expect(getVoterType(drepScriptHashVoter.__typename)).toEqual('DRep'); - expect(getVoterType(stakePoolKeyHashVoter.__typename)).toEqual('SPO'); + expect(getVoterType(constitutionalCommitteeKeyHashVoter.__typename)).toEqual(VoterType.CONSTITUTIONAL_COMMITTEE); + expect(getVoterType(constitutionalCommitteeScriptHashVoter.__typename)).toEqual(VoterType.CONSTITUTIONAL_COMMITTEE); + expect(getVoterType(drepKeyHashVoter.__typename)).toEqual(VoterType.DREP); + expect(getVoterType(drepScriptHashVoter.__typename)).toEqual(VoterType.DREP); + expect(getVoterType(stakePoolKeyHashVoter.__typename)).toEqual(VoterType.SPO); }); test('testing getVote', () => { - expect(getVote(Wallet.Cardano.Vote.yes)).toEqual('Yes'); - expect(getVote(Wallet.Cardano.Vote.no)).toEqual('No'); - expect(getVote(Wallet.Cardano.Vote.abstain)).toEqual('Abstain'); + expect(getVote(Wallet.Cardano.Vote.yes)).toEqual(Votes.YES); + expect(getVote(Wallet.Cardano.Vote.no)).toEqual(Votes.NO); + expect(getVote(Wallet.Cardano.Vote.abstain)).toEqual(Votes.ABSTAIN); }); }); diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/hooks.ts b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/hooks.ts index 9d532f06f3..b79f5452c3 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/hooks.ts +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/hooks.ts @@ -121,23 +121,22 @@ export const useTxSummary = ({ if (txType === TxType.Send) { return walletInfo.addresses.every((addr) => output.address !== addr.address); } - return true; + // Don't show withdrawl tx's etc + return output.address.toString() !== walletInfo.addresses[0].address.toString(); }); // eslint-disable-next-line unicorn/no-array-reduce - const txSummaryOutputs: Wallet.Cip30SignTxSummary['outputs'] = externalOutputs.reduce((acc, txOut) => { - // Don't show withdrawl tx's etc - if (txOut.address.toString() === walletInfo.addresses[0].address.toString()) return acc; - - return [ + const txSummaryOutputs: Wallet.Cip30SignTxSummary['outputs'] = externalOutputs.reduce( + (acc, txOut) => [ ...acc, { coins: Wallet.util.lovelacesToAdaString(txOut.value.coins.toString()), recipient: addressToNameMap?.get(txOut.address.toString()) || txOut.address.toString(), ...(txOut.value.assets?.size > 0 && { assets: createAssetList(txOut.value.assets) }) } - ]; - }, []); + ], + [] + ); return { fee: Wallet.util.lovelacesToAdaString(tx.body.fee.toString()), diff --git a/apps/browser-extension-wallet/src/lib/translations/en.json b/apps/browser-extension-wallet/src/lib/translations/en.json index cf27811238..91cafdca4a 100644 --- a/apps/browser-extension-wallet/src/lib/translations/en.json +++ b/apps/browser-extension-wallet/src/lib/translations/en.json @@ -1127,7 +1127,17 @@ "hash": "Anchor Hash", "url": "Anchor URL" }, - "dRepId": "DRep ID" + "dRepId": "DRep ID", + "voterTypes": { + "constitutionalCommittee": "Constitutional Committee", + "spo": "SPO", + "drep": "DRep" + }, + "votes": { + "yes": "Yes", + "no": "No", + "abstain": "Abstain" + } }, "drepRegistration": { "title": "Confirm DRep Registration", diff --git a/packages/core/src/ui/components/ActivityDetail/TransactionDetails.tsx b/packages/core/src/ui/components/ActivityDetail/TransactionDetails.tsx index 4c18e38c9c..f7324cbbd7 100644 --- a/packages/core/src/ui/components/ActivityDetail/TransactionDetails.tsx +++ b/packages/core/src/ui/components/ActivityDetail/TransactionDetails.tsx @@ -141,7 +141,8 @@ export const TransactionDetails = ({