From 39e68dfcd3e5e38acb8cd10e9266c633ffdb366e Mon Sep 17 00:00:00 2001 From: Ilja Date: Fri, 4 Mar 2022 14:08:20 +0200 Subject: [PATCH] Enable per chain account selection --- .../src/views/SessionProposalModal.tsx | 58 +++++++++---------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx b/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx index 872fca0..90efddd 100644 --- a/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx +++ b/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx @@ -3,6 +3,8 @@ import ProjectInfoCard from '@/components/ProjectInfoCard' import RequesDetailsCard from '@/components/RequestDetalilsCard' import RequestMethodCard from '@/components/RequestMethodCard' import RequestModalContainer from '@/components/RequestModalContainer' +import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData' +import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data' import ModalStore from '@/store/ModalStore' import { cosmosAddresses } from '@/utils/CosmosWalletUtil' import { eip155Addresses } from '@/utils/EIP155WalletUtil' @@ -51,19 +53,7 @@ export default function SessionProposalModal() { // Hanlde approve action async function onApprove() { if (proposal) { - const accounts: string[] = [] - chains.forEach(chain => { - if (isEIP155Chain(chain)) { - selectedEIP155.forEach(address => { - accounts.push(`${chain}:${address}`) - }) - } else if (isCosmosChain(chain)) { - selectedCosmos.forEach(address => { - accounts.push(`${chain}:${address}`) - }) - } - }) - + const accounts = [...selectedEIP155, ...selectedCosmos] const response = { state: { accounts @@ -95,25 +85,27 @@ export default function SessionProposalModal() { - - {chains.map(chain => { if (isEIP155Chain(chain)) { return ( - - - Select EIP155 Accounts - {eip155Addresses.map((address, index) => ( - onSelectEIP155(address)} - selected={selectedEIP155.includes(address)} - /> - ))} - - + + + + + + {`Select ${EIP155_CHAINS[chain as TEIP155Chain].name} Accounts`} + {eip155Addresses.map((address, index) => ( + onSelectEIP155(`${chain}:${address}`)} + selected={selectedEIP155.includes(`${chain}:${address}`)} + /> + ))} + + + ) } else if (isCosmosChain(chain)) { return ( @@ -122,14 +114,16 @@ export default function SessionProposalModal() { - Select Cosmos Accounts + + {`Select ${COSMOS_MAINNET_CHAINS[chain as TCosmosChain].name} Accounts`} + {cosmosAddresses.map((address, index) => ( onSelectCosmos(address)} - selected={selectedCosmos.includes(address)} + onSelect={() => onSelectCosmos(`${chain}:${address}`)} + selected={selectedCosmos.includes(`${chain}:${address}`)} /> ))}