diff --git a/advanced/wallets/react-wallet-v2/src/pages/settings.tsx b/advanced/wallets/react-wallet-v2/src/pages/settings.tsx index 2ade434..062cab7 100644 --- a/advanced/wallets/react-wallet-v2/src/pages/settings.tsx +++ b/advanced/wallets/react-wallet-v2/src/pages/settings.tsx @@ -23,7 +23,8 @@ export default function SettingsPage() { multiversxAddress, tronAddress, tezosAddress, - kadenaAddress + kadenaAddress, + smartAccountEnabled } = useSnapshot(SettingsStore.state) return ( @@ -68,6 +69,20 @@ export default function SettingsPage() { + + Smart Account Enabled + + + + {smartAccountEnabled ? 'Enabled' : 'Disabled'} + + + + Relayer Region diff --git a/advanced/wallets/react-wallet-v2/src/store/SettingsStore.ts b/advanced/wallets/react-wallet-v2/src/store/SettingsStore.ts index 264654a..649fad4 100644 --- a/advanced/wallets/react-wallet-v2/src/store/SettingsStore.ts +++ b/advanced/wallets/react-wallet-v2/src/store/SettingsStore.ts @@ -20,7 +20,8 @@ interface State { activeChainId: string currentRequestVerifyContext?: Verify.Context sessions: SessionTypes.Struct[] - smartAccountSponsorshipEnabled: boolean + smartAccountSponsorshipEnabled: boolean, + smartAccountEnabled: boolean, } /** @@ -42,6 +43,7 @@ const state = proxy({ relayerRegionURL: '', sessions: [], smartAccountSponsorshipEnabled: false, + smartAccountEnabled: false, }) /** @@ -116,6 +118,10 @@ const SettingsStore = { toggleSmartAccountSponsorship() { if (!state.testNets) return state.smartAccountSponsorshipEnabled = !state.smartAccountSponsorshipEnabled + }, + + toggleSmartAccountEnabled() { + state.smartAccountEnabled = !state.smartAccountEnabled } } diff --git a/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx b/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx index 020201e..0099334 100644 --- a/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx @@ -48,7 +48,7 @@ const StyledSpan = styled('span', { } as any) export default function SessionProposalModal() { - const { smartAccountSponsorshipEnabled } = useSnapshot(SettingsStore.state) + const { smartAccountSponsorshipEnabled, smartAccountEnabled } = useSnapshot(SettingsStore.state) // Get proposal data and wallet address from store const data = useSnapshot(ModalStore.state) const proposal = data?.data?.proposal as SignClientTypes.EventArguments['session_proposal'] @@ -262,7 +262,7 @@ export default function SessionProposalModal() { if (allowedChainIds.length) { const chainIdParsed = allowedChainIds[0].replace(`${nameSpaceKey}:`, '') - if (namespaces[nameSpaceKey].accounts) { + if (namespaces[nameSpaceKey].accounts && smartAccountEnabled) { const signerAddress = namespaces[nameSpaceKey].accounts[0].split(':')[2] const wallet = eip155Wallets[signerAddress] const chain = allowedChains.find(chain => chain.id.toString() === chainIdParsed)! @@ -280,12 +280,10 @@ export default function SessionProposalModal() { const accountIsAllowed = namespaces.eip155.accounts.findIndex(account => account.includes(id)) return namespaces.eip155.accounts[accountIsAllowed] - }) - - // when SA available, make it 1st on dApp + }) + // when SA available, make it first on dApp namespaces.eip155.accounts = [`${nameSpaceKey}:${chain.id}:${smartAccountAddress.address}`, ...allowedAccounts] } - console.log('approving namespaces:', namespaces.eip155.accounts) } } @@ -304,7 +302,7 @@ export default function SessionProposalModal() { } setIsLoadingApprove(false) ModalStore.close() - }, [namespaces, proposal, smartAccountSponsorshipEnabled]) + }, [namespaces, proposal, smartAccountSponsorshipEnabled, smartAccountEnabled]) // Hanlde reject action // eslint-disable-next-line react-hooks/rules-of-hooks