diff --git a/src/App.tsx b/src/App.tsx index 9cbe0bf..52b76ac 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -146,6 +146,23 @@ const App = (): React.JSX.Element => { requestSessionData, }); break; + + case EIP155_SIGNING_METHODS.WALLET_GET_CAPABILITIES: + const supportedNetworks = networksData + .filter(network => network.namespace === EIP155) + .map(network => `${network.namespace}:${network.chainId}`); + const capabilitiesResponse = formatJsonRpcResult(id, { + accountManagement: true, + sessionManagement: true, + supportedAuthMethods: ['personal_sign', 'eth_sendTransaction'], + supportedNetworks: supportedNetworks, + }); + + await web3wallet!.respondSessionRequest({ + topic, + response: capabilitiesResponse, + }); + break; case COSMOS_METHODS.COSMOS_SIGN_DIRECT: const message = { @@ -347,6 +364,7 @@ const App = (): React.JSX.Element => { // eslint-disable-next-line react/no-unstable-nested-components headerRight: () => ( )} diff --git a/src/components/PairingModal.tsx b/src/components/PairingModal.tsx index 5fbec48..b8249d7 100644 --- a/src/components/PairingModal.tsx +++ b/src/components/PairingModal.tsx @@ -282,20 +282,24 @@ const PairingModal = ({ )} - - - - - - + + {currentProposal && namespaces && ( + + + + + + )} + diff --git a/src/screens/AddSession.tsx b/src/screens/AddSession.tsx index 430cccb..5beaa8a 100644 --- a/src/screens/AddSession.tsx +++ b/src/screens/AddSession.tsx @@ -44,7 +44,7 @@ const AddSession = () => { /> - diff --git a/src/screens/ApproveTransfer.tsx b/src/screens/ApproveTransfer.tsx index f32e2a3..8a5c54a 100644 --- a/src/screens/ApproveTransfer.tsx +++ b/src/screens/ApproveTransfer.tsx @@ -82,23 +82,27 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => { useState(); const isSufficientFunds = useMemo(() => { - if (!transaction.value) { - return; - } - if (!balance) { return; } - const amountBigNum = BigNumber.from(String(transaction.value)); - const balanceBigNum = BigNumber.from(balance); - - if (amountBigNum.gte(balanceBigNum)) { - return false; - } else { - return true; + if (!fees) { + return; } - }, [balance, transaction]); + + const balanceBigNum = BigNumber.from(balance); + const feesBigNum = BigNumber.from(fees); + let totalRequiredBigNum = feesBigNum; + + if (transaction.value) { + const amountBigNum = BigNumber.from(String(transaction.value)); + totalRequiredBigNum = amountBigNum.add(feesBigNum); + } + + // Compare the user's balance with the total required amount + const isSufficient = balanceBigNum.gte(totalRequiredBigNum); + return isSufficient; + }, [balance, transaction.value, fees]); const requestedNetwork = networksData.find( networkData => @@ -273,8 +277,12 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => { useEffect(() => { if (namespace === EIP155) { - const ethFees = BigNumber.from(ethGasLimit ?? 0) - .mul(BigNumber.from(ethMaxFee ?? ethGasPrice ?? 0)) + if (!ethGasLimit || !(ethMaxFee || ethGasPrice)){ + return; + } + + const ethFees = BigNumber.from(ethGasLimit) + .mul(BigNumber.from(ethMaxFee ?? ethGasPrice)) .toString(); setFees(ethFees); } else { @@ -495,7 +503,7 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => { useEffect(() => { const getEthGas = async () => { try { - if (!isSufficientFunds || !provider) { + if (!provider) { return; } @@ -568,11 +576,11 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => { }, [cosmosStargateClient, isSufficientFunds, sendMsg, transaction,txMemo]); useEffect(() => { - if (balance && !isSufficientFunds) { + if (balance && !isSufficientFunds && !fees) { setTxError('Insufficient funds'); setIsTxErrorDialogOpen(true); } - }, [isSufficientFunds, balance]); + }, [isSufficientFunds, balance, fees]); return ( <> @@ -614,14 +622,16 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => { {transaction && ( - + {transaction.value !== undefined && transaction.value !== null && ( + + )} {namespace === COSMOS && ( { ); useEffect(() => { - if (route.path) { + const requestEvent = route.params.requestEvent; + if (route.path && !requestEvent) { const sanitizedRoute = sanitizePath(route.path); sanitizedRoute && retrieveData( @@ -127,7 +128,6 @@ const SignRequest = ({ route }: SignRequestProps) => { ); return; } - const requestEvent = route.params.requestEvent; const requestChainId = requestEvent?.params.chainId; const requestedChain = networksData.find( @@ -310,6 +310,7 @@ const SignRequest = ({ route }: SignRequestProps) => {