fix: smart account feature flag (#481)
* fix: smart account namespace ordering * feat: add feature flag for smart accounts
This commit is contained in:
parent
8a8fe68c3e
commit
fce1d3be56
@ -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() {
|
||||
|
||||
<Divider y={2} />
|
||||
|
||||
<Text h4 css={{ marginBottom: '$5' }}>
|
||||
Smart Account Enabled
|
||||
</Text>
|
||||
<Row justify="space-between" align="center">
|
||||
<Switch
|
||||
checked={smartAccountEnabled}
|
||||
onChange={SettingsStore.toggleSmartAccountEnabled}
|
||||
data-testid="settings-toggle-smart-account-enabled"
|
||||
/>
|
||||
<Text>{smartAccountEnabled ? 'Enabled' : 'Disabled'}</Text>
|
||||
</Row>
|
||||
|
||||
<Divider y={2} />
|
||||
|
||||
<Row justify="space-between" align="center">
|
||||
<Text h4 css={{ marginBottom: '$5' }}>
|
||||
Relayer Region
|
||||
|
@ -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<State>({
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user