From c2f2a9b3a2ecbc0111ea8a40852536a3a7ed759d Mon Sep 17 00:00:00 2001 From: Gancho Radkov Date: Tue, 28 Jan 2025 13:30:48 +0200 Subject: [PATCH 1/8] wip: feat: yttrium --- advanced/wallets/react-wallet-v2/package.json | 2 +- .../components/MultibridgeRequestModal.tsx | 35 +++-- .../src/lib/smart-accounts/SmartAccountLib.ts | 1 + .../src/utils/ChainAbstractionService.ts | 3 +- .../src/utils/WalletConnectUtil.ts | 2 +- .../src/views/SessionSendTransactionModal.tsx | 83 +++++----- advanced/wallets/react-wallet-v2/yarn.lock | 146 +++++++++++------- 7 files changed, 161 insertions(+), 111 deletions(-) diff --git a/advanced/wallets/react-wallet-v2/package.json b/advanced/wallets/react-wallet-v2/package.json index bd77bd224..7fb9376c8 100644 --- a/advanced/wallets/react-wallet-v2/package.json +++ b/advanced/wallets/react-wallet-v2/package.json @@ -29,7 +29,7 @@ "@noble/curves": "^1.6.0", "@polkadot/keyring": "^10.1.2", "@polkadot/types": "^9.3.3", - "@reown/walletkit": "1.0.0", + "@reown/walletkit": "1.1.2-canary-wasm-3", "@reown/appkit-experimental": "1.1.5", "@rhinestone/module-sdk": "0.1.25", "@solana/web3.js": "1.89.2", diff --git a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx index f7d8e3409..6593b77a2 100644 --- a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx @@ -21,22 +21,27 @@ import { formatJsonRpcError } from '@json-rpc-tools/utils' interface IProps { onReject: () => void transactions?: Transaction[] + initialTransaction?: Transaction orchestrationId: string rejectLoader?: LoaderProps } export default function MultibridgeRequestModal({ transactions, + initialTransaction, orchestrationId, onReject, rejectLoader }: IProps) { const [isLoadingApprove, setIsLoadingApprove] = useState(false) - const bridgingTransactions = transactions?.slice(0, transactions.length - 1) || [] - const initialTransaction = transactions?.[transactions.length - 1] + if (!transactions || transactions?.length === 0) { + return null + } + console.log('transactions', transactions) + const bridgingTransactions = transactions - const eip155ChainsFundsSourcedFrom = transactions + const eip155ChainsFundsSourcedFrom = bridgingTransactions ? new Set(bridgingTransactions.map(transaction => transaction.chainId)) : new Set() @@ -74,15 +79,16 @@ export default function MultibridgeRequestModal({ ) const chainConnectedWallet = await wallet.connect(chainProvider) const walletAddress = wallet.getAddress() - + console.log('Connected wallet address', chainConnectedWallet) const txResponse = await chainConnectedWallet.sendTransaction({ from: walletAddress, to: transaction.to, value: transaction.value, data: transaction.data, nonce: transaction.nonce, - gasPrice: transaction.gasPrice, - gasLimit: transaction.gas + maxFeePerGas: transaction.maxFeePerGas, + maxPriorityFeePerGas: transaction.maxPriorityFeePerGas, + gasLimit: transaction.gasLimit }) const txHash = typeof txResponse === 'string' ? txResponse : txResponse?.hash const txReceipt = await txResponse.wait() @@ -102,7 +108,7 @@ export default function MultibridgeRequestModal({ for (let attempt = 0; attempt < maxAttempts; attempt++) { const { status } = await caService.getOrchestrationStatus(orchestrationId) console.log(attempt, '- Orchestration status:', status) - if (status === 'completed') { + if (status.toLowerCase() === 'completed') { console.log('Bridging completed') return } @@ -118,7 +124,18 @@ export default function MultibridgeRequestModal({ try { performance.mark('startInititalTransactionSend') await bridgeFunds() - const response = await approveEIP155Request(requestEvent) + const response = await approveEIP155Request({ + ...requestEvent, + params: { + ...requestEvent.params, + request: { + ...requestEvent.params.request, + params: { + ...initialTransaction + } + } + } + }) performance.mark('endInititalTransactionSend') console.log( `Initial transaction send: ${ @@ -160,7 +177,7 @@ export default function MultibridgeRequestModal({ const asset = getAssetByContractAddress(transfer.contract) const amount = convertTokenBalance(asset, transfer.amount) const destination = transfer.to - const sourceChain = EIP155_CHAINS[Array.from(eip155ChainsFundsSourcedFrom)[0] as TEIP155Chain] + const sourceChain = EIP155_CHAINS[transactions[0].chainId as TEIP155Chain] const targetChain = EIP155_CHAINS[eip155ChainFundsDestination as TEIP155Chain] return ( diff --git a/advanced/wallets/react-wallet-v2/src/lib/smart-accounts/SmartAccountLib.ts b/advanced/wallets/react-wallet-v2/src/lib/smart-accounts/SmartAccountLib.ts index df9d7964b..8830439f0 100644 --- a/advanced/wallets/react-wallet-v2/src/lib/smart-accounts/SmartAccountLib.ts +++ b/advanced/wallets/react-wallet-v2/src/lib/smart-accounts/SmartAccountLib.ts @@ -211,6 +211,7 @@ export abstract class SmartAccountLib implements EIP155Wallet { if (!this.client?.account) { throw new Error('Client not initialized') } + console.log('Sending transaction from smart account', { type: this.type, to, value, data }) const txResult = await this.client.sendTransaction({ to, value: BigInt(value), diff --git a/advanced/wallets/react-wallet-v2/src/utils/ChainAbstractionService.ts b/advanced/wallets/react-wallet-v2/src/utils/ChainAbstractionService.ts index 54e7a0403..6e037c0f9 100644 --- a/advanced/wallets/react-wallet-v2/src/utils/ChainAbstractionService.ts +++ b/advanced/wallets/react-wallet-v2/src/utils/ChainAbstractionService.ts @@ -5,12 +5,11 @@ export interface Transaction { from: string to: string value: string - gas: string - gasPrice: string data: string nonce: string maxFeePerGas: string maxPriorityFeePerGas: string + gasLimit: string chainId: string } diff --git a/advanced/wallets/react-wallet-v2/src/utils/WalletConnectUtil.ts b/advanced/wallets/react-wallet-v2/src/utils/WalletConnectUtil.ts index b3a59dc86..fba139657 100644 --- a/advanced/wallets/react-wallet-v2/src/utils/WalletConnectUtil.ts +++ b/advanced/wallets/react-wallet-v2/src/utils/WalletConnectUtil.ts @@ -6,7 +6,7 @@ export async function createWalletKit(relayerRegionURL: string) { const core = new Core({ projectId: process.env.NEXT_PUBLIC_PROJECT_ID, relayUrl: relayerRegionURL ?? process.env.NEXT_PUBLIC_RELAY_URL, - logger: 'trace' + logger: 'debug' }) walletkit = await WalletKit.init({ core, diff --git a/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx b/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx index cac73e433..400c521c9 100644 --- a/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx @@ -28,14 +28,13 @@ export default function SessionSendTransactionModal() { const [requiresMultiChain, setRequiresMultiChain] = useState(false) const [routeTransactions, setRouteTransactions] = useState([]) const [orchestrationId, setOrchestrationId] = useState(null) - + const [initialTransaction, setInitialTransaction] = useState() // Extract request and wallet data from store const requestEvent = ModalStore.state.data?.requestEvent const requestSession = ModalStore.state.data?.requestSession const { topic, params } = requestEvent || {} const { chainId, request } = params || {} const transaction = request?.params[0] - // Check for multi-chain requirement and handle routing useEffect(() => { const initializeMultiChainCheck = async (): Promise => { @@ -53,11 +52,11 @@ export default function SessionSendTransactionModal() { } try { - const caService = new ChainAbstractionService() - const isMultiChain = await checkMultiChainRequirement(caService, request, chainId) - if (isMultiChain) { - await setupRouteTransactions(caService, request, chainId) - } + // const caService = new ChainAbstractionService() + // const isMultiChain = await checkMultiChainRequirement(caService, request, chainId) + // if (isMultiChain) { + await setupRouteTransactions(request, chainId) + // } } catch (error) { console.error('Error during multi-chain check:', error) styledToast('Unable to check multibridge availability', 'error') @@ -69,48 +68,42 @@ export default function SessionSendTransactionModal() { initializeMultiChainCheck() }, [request, chainId]) - const checkMultiChainRequirement = async ( - caService: ChainAbstractionService, - request: { params: [{ from: string; to: string; data: string }] }, - chainId: string - ): Promise => { - const { data, from, to } = request.params[0] - const isMultiChain = await caService.checkTransaction({ - from, - to, - value: '0', - gas: '0', - gasPrice: '0', - data, - nonce: '0', - maxFeePerGas: '0', - maxPriorityFeePerGas: '0', - chainId - }) - setRequiresMultiChain(isMultiChain) - return isMultiChain - } - const setupRouteTransactions = async ( - caService: ChainAbstractionService, + // caService: ChainAbstractionService, request: { params: [{ from: string; to: string; data: string }] }, chainId: string ): Promise => { const { data, from, to } = request.params[0] - const routeResult = await caService.routeTransaction({ - from, - to, - value: '0', - gas: '0', - gasPrice: '0', - data, - nonce: '0', - maxFeePerGas: '0', - maxPriorityFeePerGas: '0', - chainId + + const result = await walletkit.prepareFulfilment({ + transaction: { + to, + from, + data, + chainId + } }) - setRouteTransactions(routeResult.transactions) - setOrchestrationId(routeResult.orchestrationId) + console.log('Fulfilment result:', result) + if (result.status === 'available') { + const routes = result.data.transactions.map(tx => ({ + ...tx, + data: tx.input + })) + setRouteTransactions(routes) + setOrchestrationId(result.data.fulfilmentId) + setRequiresMultiChain(true) + setInitialTransaction({ + to: result.data.initialTransaction.to, + from: result.data.initialTransaction.from, + value: result.data.initialTransaction.value, + data: result.data.initialTransaction.input, + nonce: result.data.initialTransaction.nonce, + maxFeePerGas: result.data.initialTransaction.maxFeePerGas, + maxPriorityFeePerGas: result.data.initialTransaction.maxPriorityFeePerGas, + chainId: result.data.initialTransaction.chainId, + gasLimit: result.data.initialTransaction.gasLimit + }) + } } const handleApproval = useCallback(async (): Promise => { @@ -159,6 +152,7 @@ export default function SessionSendTransactionModal() { @@ -214,6 +208,7 @@ const SingleChainModal = ({ type MultiChainModalProps = { transactions: Transaction[] + initialTransaction?: Transaction orchestrationId: string onReject: () => Promise loadingReject: boolean @@ -221,12 +216,14 @@ type MultiChainModalProps = { const MultiChainModal = ({ transactions, + initialTransaction, orchestrationId, onReject, loadingReject }: MultiChainModalProps): JSX.Element => ( Date: Fri, 31 Jan 2025 10:33:54 +0200 Subject: [PATCH 2/8] wip: feat: uses yttrium via walletkit for chain abstraction --- advanced/wallets/react-wallet-v2/package.json | 2 +- .../wallets/react-wallet-v2/public/bridge.png | Bin 0 -> 700 bytes .../src/components/BridgeBadge.tsx | 26 ++ .../ChainAbstractionBalanceCard.tsx | 6 +- .../components/MultibridgeRequestModal.tsx | 366 +++++++++++++++--- .../hooks/useWalletConnectEventsManager.ts | 28 ++ .../src/utils/MultibridgeUtil.ts | 9 +- .../src/views/SessionSendTransactionModal.tsx | 80 +++- advanced/wallets/react-wallet-v2/yarn.lock | 8 +- 9 files changed, 444 insertions(+), 81 deletions(-) create mode 100644 advanced/wallets/react-wallet-v2/public/bridge.png create mode 100644 advanced/wallets/react-wallet-v2/src/components/BridgeBadge.tsx diff --git a/advanced/wallets/react-wallet-v2/package.json b/advanced/wallets/react-wallet-v2/package.json index 7fb9376c8..98b2a0231 100644 --- a/advanced/wallets/react-wallet-v2/package.json +++ b/advanced/wallets/react-wallet-v2/package.json @@ -29,8 +29,8 @@ "@noble/curves": "^1.6.0", "@polkadot/keyring": "^10.1.2", "@polkadot/types": "^9.3.3", - "@reown/walletkit": "1.1.2-canary-wasm-3", "@reown/appkit-experimental": "1.1.5", + "@reown/walletkit": "1.1.2-canary-wasm-5", "@rhinestone/module-sdk": "0.1.25", "@solana/web3.js": "1.89.2", "@taquito/signer": "^15.1.0", diff --git a/advanced/wallets/react-wallet-v2/public/bridge.png b/advanced/wallets/react-wallet-v2/public/bridge.png new file mode 100644 index 0000000000000000000000000000000000000000..218ea79bb29eebc617679847e6751d42ba37cd45 GIT binary patch literal 700 zcmV;t0z>_YP)@~0drDELIAGL9O(c600d`2O+f$vv5yPnj7U=#3o`lUu(tqN4YdNJt3%ZwSvE zc{y4?gcD5B0%<8m@}q=sLOGI;h6;%I_|j>A2TMf$iFA~i^&2OwXqY5%A(Z~fBY}kq zzAP-ow}?z`{mzKLWalaNXvnSKd<8A!;vSLE`eQ`X@0O^0^5ZuGlUu(tVnzO_(GqmZ zu-YUYw^m`>7LpEWtOWp zOGle~Ut@CXD+8{{&aUfd$O!%XmfTd@plfaTLf@-)D{{|1s_lG&{+@iMP_hrJe@4A( z$Ov6lkbfliWf@5S5HMXU#s?$6<#ail&AfvQ*R47I;M+f(o-vKB)?fNI=;_~as(VGX zk+(zb@LZDP=*smaM(Q1lZ@;#B^WOUu{jv) + + + ) +} diff --git a/advanced/wallets/react-wallet-v2/src/components/ChainAbstractionBalanceCard.tsx b/advanced/wallets/react-wallet-v2/src/components/ChainAbstractionBalanceCard.tsx index 96f274e7c..e282dd50b 100644 --- a/advanced/wallets/react-wallet-v2/src/components/ChainAbstractionBalanceCard.tsx +++ b/advanced/wallets/react-wallet-v2/src/components/ChainAbstractionBalanceCard.tsx @@ -11,7 +11,7 @@ import { Hex } from 'viem' export default function ChainAbstractionBalanceCard() { const { eip155Address } = useSnapshot(SettingsStore.state) - const [balances, setBalances] = useState>>({}) + const [balances, setBalances] = useState>>({}) const [totalBalance, setTotalBalance] = useState>({}) const [loading, setLoading] = useState(true) useEffect(() => { @@ -20,7 +20,7 @@ export default function ChainAbstractionBalanceCard() { const fetchedBalances: Record = {} for (const asset of Object.keys(multibridgeSupportedAssets)) { - const assetBalances: Record = {} + const assetBalances: Record = {} for (const chainId of Object.keys(multibridgeSupportedAssets[asset])) { const tokenAddress = multibridgeSupportedAssets[asset][Number(chainId)] const balance = await getErc20TokenBalance( @@ -43,7 +43,7 @@ export default function ChainAbstractionBalanceCard() { for (const asset of Object.keys(balances)) { let total = 0 for (const chainBalance of Object.values(balances[asset])) { - total += chainBalance + total += parseFloat(chainBalance) } totalBalances[asset] = total } diff --git a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx index 6593b77a2..cb99a83cb 100644 --- a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx @@ -1,7 +1,6 @@ -import { useCallback, useState } from 'react' -import { Avatar, Col, Divider, Row, Text } from '@nextui-org/react' +import { useCallback, useEffect, useMemo, useState } from 'react' +import { Avatar, Col, Row, Text } from '@nextui-org/react' import { LoaderProps } from '@/components/ModalFooter' -import RequestMethodCard from '@/components/RequestMethodCard' import RequestModal from './RequestModal' import ModalStore from '@/store/ModalStore' import { styledToast } from '@/utils/HelperUtil' @@ -9,7 +8,8 @@ import { approveEIP155Request } from '@/utils/EIP155RequestHandlerUtil' import { convertTokenBalance, decodeErc20Transaction, - getAssetByContractAddress + getAssetByContractAddress, + getErc20TokenBalance } from '@/utils/MultibridgeUtil' import { getWallet } from '@/utils/EIP155WalletUtil' import { walletkit } from '@/utils/WalletConnectUtil' @@ -17,13 +17,18 @@ import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data' import { ChainAbstractionService, Transaction } from '@/utils/ChainAbstractionService' import { providers } from 'ethers' import { formatJsonRpcError } from '@json-rpc-tools/utils' +import { ChainAbstractionTypes } from '@reown/walletkit' +import { Hex } from 'viem' +import BridgeBadge from './BridgeBadge' interface IProps { onReject: () => void transactions?: Transaction[] - initialTransaction?: Transaction + initialTransaction: Transaction orchestrationId: string rejectLoader?: LoaderProps + fundings: ChainAbstractionTypes.FundingFrom[] + initialTransactionMetadata: ChainAbstractionTypes.InitialTransactionMetadata } export default function MultibridgeRequestModal({ @@ -31,15 +36,18 @@ export default function MultibridgeRequestModal({ initialTransaction, orchestrationId, onReject, - rejectLoader + rejectLoader, + fundings, + initialTransactionMetadata }: IProps) { const [isLoadingApprove, setIsLoadingApprove] = useState(false) - if (!transactions || transactions?.length === 0) { - return null - } + const [bridgingTransactions, setBridgingTransactions] = useState([]) + const [tokenBalances, setTokenBalances] = useState>({}) + const [totalFee, setTotalFee] = useState('') + const [transaction, setTransaction] = useState(initialTransaction) console.log('transactions', transactions) - const bridgingTransactions = transactions + // const bridgingTransactions = transactions const eip155ChainsFundsSourcedFrom = bridgingTransactions ? new Set(bridgingTransactions.map(transaction => transaction.chainId)) @@ -54,9 +62,145 @@ export default function MultibridgeRequestModal({ const topic = requestEvent?.topic const params = requestEvent?.params - const chainId = params?.chainId const request = params?.request - const caService = new ChainAbstractionService() + + useMemo(async () => { + if (!orchestrationId) { + return null + } + const details = await walletkit.getFulfilmentDetails({ fulfilmentId: orchestrationId }) + // const details = { + // routeDetails: [ + // { + // transaction: { + // chainId: 'eip155:8453', + // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', + // to: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', + // value: '0x0', + // input: + // '0x095ea7b30000000000000000000000003a23f943181408eac424116af7b7790c94cb97a50000000000000000000000000000000000000000000000000000000000225928', + // gasLimit: '0x1b760', + // nonce: '0x17', + // maxFeePerGas: '0xd5d732', + // maxPriorityFeePerGas: '0xf4240' + // }, + // transactionFee: { + // fee: { + // symbol: 'ETH', + // amount: '0x171c8892672', + // unit: 18, + // formatted: '0.000001588207363698 ETH', + // formatted_alt: '<$0.01' + // }, + // localFee: { + // symbol: 'USD', + // amount: '0x6b62af154a82c7301f20', + // unit: 26, + // formatted: '0.00507113610658132270260000 USD', + // formatted_alt: '$0.01' + // } + // } + // }, + // { + // transaction: { + // chainId: 'eip155:8453', + // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', + // to: '0x3a23f943181408eac424116af7b7790c94cb97a5', + // value: '0x0', + // input: + // '0x0000019b792ebcb90000000000000000000000000000000000000000000000000000000000225928000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000001c2f0000000000000000000000000000000000000000000000000000000000001b3b000000000000000000000000000000000000000000000000000000000000000200000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c520000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000223cf9000000000000000000000000000000000000000000000000000000000000a4b1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000679b390b00000000000000000000000000000000000000000000000000000000679b8d11d00dfeeddeadbeef765753be7f7a64d5509974b0d678e1e3149b02f4', + // gasLimit: '0x1a584', + // nonce: '0x18', + // maxFeePerGas: '0xd5d732', + // maxPriorityFeePerGas: '0xf4240' + // }, + // transactionFee: { + // fee: { + // symbol: 'ETH', + // amount: '0x166e7abc8ce', + // unit: 18, + // formatted: '0.000001541485086926 ETH', + // formatted_alt: '<$0.01' + // }, + // localFee: { + // symbol: 'USD', + // amount: '0x6839f4c8807ec111d4e0', + // unit: 26, + // formatted: '0.00492195217119867036620000 USD', + // formatted_alt: '<$0.01' + // } + // } + // } + // ], + // initialTransactionDetails: { + // transaction: { + // chainId: 'eip155:42161', + // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', + // to: '0xaf88d065e77c8cc2239327c5edb3a432268e5831', + // value: '0x0', + // input: + // '0xa9059cbb00000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000000000000000000000000000000000000003d0900', + // gasLimit: '0x1913a', + // nonce: '0x4b', + // maxFeePerGas: '0x1312d01', + // maxPriorityFeePerGas: '0x1' + // }, + // transactionFee: { + // fee: { + // symbol: 'ETH', + // amount: '0x1de4ca2c33a', + // unit: 18, + // formatted: '0.000002054280102714 ETH', + // formatted_alt: '<$0.01' + // }, + // localFee: { + // symbol: 'USD', + // amount: '0x8ad02fd36877a3207d80', + // unit: 26, + // formatted: '0.00655526943616345542000000 USD', + // formatted_alt: '$0.01' + // } + // } + // }, + // bridgeDetails: [ + // { + // fee: { + // symbol: 'USDC', + // amount: '0xb729d', + // unit: 6, + // formatted: '0.750237 USDC', + // formatted_alt: '$0.75' + // }, + // localFee: { + // symbol: 'USD', + // amount: '0x444cf6c826fb', + // unit: 14, + // formatted: '0.75097348515579 USD', + // formattedAlt: '$0.75' + // } + // } + // ], + // totalFee: { + // symbol: 'USD', + // amount: '0x3f7ce83f5225a6a9992180', + // unit: 26, + // formatted: '0.76752184286973344848880000 USD', + // formattedAlt: '$0.77' + // } + // } + console.log('details', details) + setTotalFee(details.totalFee.formattedAlt) + setTransaction({ + ...details.initialTransactionDetails.transaction, + data: details.initialTransactionDetails.transaction.input + }) + setBridgingTransactions( + details.routeDetails.map(route => ({ + ...route.transaction, + data: route.transaction.input + })) + ) + }, [orchestrationId]) const bridgeFunds = useCallback(async (): Promise => { if (!bridgingTransactions) { @@ -92,32 +236,35 @@ export default function MultibridgeRequestModal({ }) const txHash = typeof txResponse === 'string' ? txResponse : txResponse?.hash const txReceipt = await txResponse.wait() + console.log('Transaction receipt', txReceipt) const txStatus = txReceipt.status console.log( `Transaction broadcasted on chain ${chainId} , ${{ txHash }}, status: ${txStatus}` ) } - await pollOrchestrationStatus(orchestrationId) }, [bridgingTransactions, orchestrationId, onReject, params]) - async function pollOrchestrationStatus( - orchestrationId: string, - maxAttempts = 100, - interval = 1500 - ): Promise { - for (let attempt = 0; attempt < maxAttempts; attempt++) { - const { status } = await caService.getOrchestrationStatus(orchestrationId) - console.log(attempt, '- Orchestration status:', status) - if (status.toLowerCase() === 'completed') { - console.log('Bridging completed') - return - } - await new Promise(resolve => setTimeout(resolve, interval)) - } - console.log('Max attempts reached. Orchestration not completed.') - throw new Error('Max attempts reached. Orchestration not completed.') + const fetchTokenBalance = async (chainId: string, tokenAddress: string) => { + const tokenBalance = await getErc20TokenBalance( + tokenAddress as Hex, + Number(chainId.split(':')[1]), + initialTransaction?.from as Hex + ) + console.log('Token balance', tokenBalance) + setTokenBalances(prevState => ({ + ...prevState, + [tokenAddress]: tokenBalance + })) } + useEffect(() => { + console.log('Initial transaction', initialTransaction?.chainId) + if (initialTransactionMetadata) { + console.log('Fetching token balance for', initialTransaction.to) + fetchTokenBalance(initialTransaction.chainId, initialTransactionMetadata.tokenContract) + } + }, [initialTransactionMetadata]) + const onApprove = useCallback(async (): Promise => { if (requestEvent && topic) { setIsLoadingApprove(true) @@ -131,7 +278,7 @@ export default function MultibridgeRequestModal({ request: { ...requestEvent.params.request, params: { - ...initialTransaction + ...transaction } } } @@ -177,9 +324,20 @@ export default function MultibridgeRequestModal({ const asset = getAssetByContractAddress(transfer.contract) const amount = convertTokenBalance(asset, transfer.amount) const destination = transfer.to - const sourceChain = EIP155_CHAINS[transactions[0].chainId as TEIP155Chain] const targetChain = EIP155_CHAINS[eip155ChainFundsDestination as TEIP155Chain] + const formatAddress = (address: string) => { + return `${address.slice(0, 6)}...${address.slice(-4)}` + } + + function hexToDecimal(hex: string, decimals: number, toFixed?: number): string { + // Convert hex to decimal + const decimalValue = parseInt(hex, 16) + + // Apply decimal places + return (decimalValue / Math.pow(10, decimals)).toFixed(toFixed || decimals) + } + return ( - - - Transaction details - - Sending {amount} {asset} to: - - - {destination} - - - - - - - Chain details - Target chain: - - - +
+
+ + Sending + + {/* */} + {amount} {asset} + {/* */} + {/* + {destination} + */} - {targetChain.name} - - Sourcing funds from: - + + To + {formatAddress(destination)} + + - + + Source of funds + + + + + + + Balance + + + + ~{tokenBalances[initialTransactionMetadata.tokenContract]}{' '} + {initialTransactionMetadata.symbol} + + + {fundings?.map((funding, i) => { + return ( + + + + Bridging + + + + ~{hexToDecimal(funding.amount, funding.decimals, 2)} {funding.symbol} + + from {EIP155_CHAINS[funding.chainId as TEIP155Chain]?.name} + + + + + ) + })} - {sourceChain.name} - - - - +
+
+
+
+ + + App + + + {requestSession.peer.metadata.url} + + + + + + + Network + + + {' '} + {targetChain.name} + + + + + + + Estimated Fees + ~{totalFee} + + +
+
) } diff --git a/advanced/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts b/advanced/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts index c7b5821f6..1dfe5d8a0 100644 --- a/advanced/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts +++ b/advanced/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts @@ -41,6 +41,7 @@ export default function useWalletConnectEventsManager(initialized: boolean) { *****************************************************************************/ const onSessionRequest = useCallback( async (requestEvent: SignClientTypes.EventArguments['session_request']) => { + console.log('session_request', JSON.parse(JSON.stringify(requestEvent))) const { topic, params, verifyContext, id } = requestEvent const { request } = params const requestSession = walletkit.engine.signClient.session.get(topic) @@ -181,6 +182,33 @@ export default function useWalletConnectEventsManager(initialized: boolean) { refreshSessionsList() }) walletkit.on('session_authenticate', onSessionAuthenticate) + + onSessionRequest({ + id: 1738225968028357, + topic: '67132090c8b0fd3c2362b7dea4be21ebc6b0b14b6b27e82eb358bfc6f96c4533', + params: { + request: { + method: 'eth_sendTransaction', + params: [ + { + data: '0xa9059cbb00000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000000000000000000000000000000000000003d0900', + from: '0x13A2Ff792037AA2cd77fE1f4B522921ac59a9C52', + to: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' + } + ], + expiryTimestamp: 1738226268 + }, + chainId: 'eip155:42161' + }, + verifyContext: { + verified: { + verifyUrl: 'https://verify.walletconnect.org', + validation: 'VALID', + origin: 'https://appkit-lab.reown.com', + isScam: false + } + } + }) // load sessions on init refreshSessionsList() } diff --git a/advanced/wallets/react-wallet-v2/src/utils/MultibridgeUtil.ts b/advanced/wallets/react-wallet-v2/src/utils/MultibridgeUtil.ts index 1fc7e03be..03740cb83 100644 --- a/advanced/wallets/react-wallet-v2/src/utils/MultibridgeUtil.ts +++ b/advanced/wallets/react-wallet-v2/src/utils/MultibridgeUtil.ts @@ -61,7 +61,7 @@ export async function getErc20TokenBalance( chainId: number, account: Hex, convert: boolean = true -): Promise { +): Promise { const publicClient = createPublicClient({ chain: getChainById(chainId), transport: http() @@ -73,11 +73,12 @@ export async function getErc20TokenBalance( }) const result = await contract.read.balanceOf([account]) if (!convert) { - return Number(result) + return result.toString() } const decimals = await contract.read.decimals() - const balance = BigInt(result) / BigInt(10 ** decimals) - return Number(balance) + console.log('result', result, decimals) + const balance = Number(result) / Number(10 ** decimals) + return balance.toFixed(2) } type Erc20Transfer = { diff --git a/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx b/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx index 400c521c9..58b3c8952 100644 --- a/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx @@ -12,6 +12,7 @@ import RequestDetailsCard from '@/components/RequestDetalilsCard' import RequestMethodCard from '@/components/RequestMethodCard' import RequestModal from '@/components/RequestModal' import MultibridgeRequestModal from '@/components/MultibridgeRequestModal' +import { ChainAbstractionTypes, WalletKitTypes } from '@reown/walletkit' // Types for props used in individual components type Session = { @@ -29,6 +30,9 @@ export default function SessionSendTransactionModal() { const [routeTransactions, setRouteTransactions] = useState([]) const [orchestrationId, setOrchestrationId] = useState(null) const [initialTransaction, setInitialTransaction] = useState() + const [fundings, setFundings] = useState() + const [initialTransactionMetadata, setInitialTransactionMetadata] = + useState() // Extract request and wallet data from store const requestEvent = ModalStore.state.data?.requestEvent const requestSession = ModalStore.state.data?.requestSession @@ -83,12 +87,69 @@ export default function SessionSendTransactionModal() { chainId } }) + + // const result = { + // status: 'available', + // data: { + // fulfilmentId: 'e20881f7-df15-4b99-9d72-8456dc0f4662', + // transactions: [ + // { + // chainId: 'eip155:8453', + // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', + // to: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', + // value: '0x0', + // input: + // '0x095ea7b30000000000000000000000003a23f943181408eac424116af7b7790c94cb97a50000000000000000000000000000000000000000000000000000000000225928', + // gasLimit: '0x1b760', + // nonce: '0x17' + // }, + // { + // chainId: 'eip155:8453', + // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', + // to: '0x3a23f943181408eac424116af7b7790c94cb97a5', + // value: '0x0', + // input: + // '0x0000019b792ebcb90000000000000000000000000000000000000000000000000000000000225928000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000001c2f0000000000000000000000000000000000000000000000000000000000001b3b000000000000000000000000000000000000000000000000000000000000000200000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c520000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000223cf9000000000000000000000000000000000000000000000000000000000000a4b1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000679b390b00000000000000000000000000000000000000000000000000000000679b8d11d00dfeeddeadbeef765753be7f7a64d5509974b0d678e1e3149b02f4', + // gasLimit: '0x1a584', + // nonce: '0x18' + // } + // ], + // funding: [ + // { + // chainId: 'eip155:8453', + // tokenContract: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', + // symbol: 'USDC', + // amount: '0x223cf9', + // bridgingFee: '0xb729d', + // decimals: 6 + // } + // ], + // initialTransaction: { + // chainId: 'eip155:42161', + // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', + // to: '0xaf88d065e77c8cc2239327c5edb3a432268e5831', + // value: '0x0', + // input: + // '0xa9059cbb00000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000000000000000000000000000000000000003d0900', + // gasLimit: '0x1913a', + // nonce: '0x4b' + // }, + // initialTransactionMetadata: { + // transferTo: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', + // amount: '0x3d0900', + // tokenContract: '0xaf88d065e77c8cc2239327c5edb3a432268e5831', + // symbol: 'USDC', + // decimals: 6 + // } + // } + // } console.log('Fulfilment result:', result) if (result.status === 'available') { const routes = result.data.transactions.map(tx => ({ ...tx, data: tx.input })) + setFundings(result.data.funding) setRouteTransactions(routes) setOrchestrationId(result.data.fulfilmentId) setRequiresMultiChain(true) @@ -103,6 +164,7 @@ export default function SessionSendTransactionModal() { chainId: result.data.initialTransaction.chainId, gasLimit: result.data.initialTransaction.gasLimit }) + setInitialTransactionMetadata(result.data.initialTransactionMetadata) } } @@ -134,12 +196,12 @@ export default function SessionSendTransactionModal() { } }, [requestEvent, topic]) - if (!request || !requestSession) return Request not found + if (!requestEvent) return Request not found if (!isReadyForRender) return return !requiresMultiChain || orchestrationId == null ? ( ) } @@ -208,10 +272,12 @@ const SingleChainModal = ({ type MultiChainModalProps = { transactions: Transaction[] - initialTransaction?: Transaction + initialTransaction: Transaction orchestrationId: string onReject: () => Promise loadingReject: boolean + fundings: ChainAbstractionTypes.FundingFrom[] + initialTransactionMetadata: ChainAbstractionTypes.InitialTransactionMetadata } const MultiChainModal = ({ @@ -219,7 +285,9 @@ const MultiChainModal = ({ initialTransaction, orchestrationId, onReject, - loadingReject + loadingReject, + fundings, + initialTransactionMetadata }: MultiChainModalProps): JSX.Element => ( ) diff --git a/advanced/wallets/react-wallet-v2/yarn.lock b/advanced/wallets/react-wallet-v2/yarn.lock index 3a9a650d8..218ed0335 100644 --- a/advanced/wallets/react-wallet-v2/yarn.lock +++ b/advanced/wallets/react-wallet-v2/yarn.lock @@ -2231,10 +2231,10 @@ valtio "1.11.2" viem "2.x" -"@reown/walletkit@1.1.2-canary-wasm-3": - version "1.1.2-canary-wasm-3" - resolved "https://registry.yarnpkg.com/@reown/walletkit/-/walletkit-1.1.2-canary-wasm-3.tgz#4373ca64d487d481a778bdc29a7c3ace0f6c0477" - integrity sha512-7n0WdudqSQqvUThxbq1tdfYmBhJXP0nr/8dynIgeNS01cPiiSSvOvuekhU2FuqLYBT4lW4u6IZ9eo3hWE1iWLg== +"@reown/walletkit@1.1.2-canary-wasm-5": + version "1.1.2-canary-wasm-5" + resolved "https://registry.yarnpkg.com/@reown/walletkit/-/walletkit-1.1.2-canary-wasm-5.tgz#168a95d95c77f6bdd2c7d62c0b64b46c42dbd9d2" + integrity sha512-8pR4Sg7L8gT/gsPGgv0FygSNu7ZXu6Rb8AgjcazNcEb4ml8RhYPpXmX/GGI/iz6zXB9jxDYERCmAQDFfzpkm9w== dependencies: "@walletconnect/core" "2.17.3" "@walletconnect/jsonrpc-provider" "1.0.14" From 045b1bf383d708677fb7dc3f196c6f7e27408435 Mon Sep 17 00:00:00 2001 From: Gancho Radkov Date: Fri, 31 Jan 2025 11:32:59 +0200 Subject: [PATCH 3/8] feat: implements import of private key or mnemonic for eip155 --- .../react-wallet-v2/src/lib/EIP155Lib.ts | 14 +++++++++--- .../react-wallet-v2/src/pages/settings.tsx | 18 ++++++++++++--- .../src/utils/EIP155WalletUtil.ts | 22 ++++++++++++++++++- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/advanced/wallets/react-wallet-v2/src/lib/EIP155Lib.ts b/advanced/wallets/react-wallet-v2/src/lib/EIP155Lib.ts index b4e7488df..09210a05b 100644 --- a/advanced/wallets/react-wallet-v2/src/lib/EIP155Lib.ts +++ b/advanced/wallets/react-wallet-v2/src/lib/EIP155Lib.ts @@ -5,6 +5,7 @@ import { providers, Wallet } from 'ethers' */ interface IInitArgs { mnemonic?: string + privateKey?: string } export interface EIP155Wallet { getMnemonic(): string @@ -26,14 +27,21 @@ export default class EIP155Lib implements EIP155Wallet { this.wallet = wallet } - static init({ mnemonic }: IInitArgs) { - const wallet = mnemonic ? Wallet.fromMnemonic(mnemonic) : Wallet.createRandom() + static init({ mnemonic, privateKey }: IInitArgs) { + let wallet + if (privateKey) { + wallet = new Wallet(privateKey) + } else if (mnemonic) { + wallet = Wallet.fromMnemonic(mnemonic) + } else { + wallet = Wallet.createRandom() + } return new EIP155Lib(wallet) } getMnemonic() { - return this.wallet.mnemonic.phrase + return this.wallet.mnemonic?.phrase || this.getPrivateKey() } getPrivateKey() { diff --git a/advanced/wallets/react-wallet-v2/src/pages/settings.tsx b/advanced/wallets/react-wallet-v2/src/pages/settings.tsx index cbe3efd8d..41416acd5 100644 --- a/advanced/wallets/react-wallet-v2/src/pages/settings.tsx +++ b/advanced/wallets/react-wallet-v2/src/pages/settings.tsx @@ -2,12 +2,12 @@ import PageHeader from '@/components/PageHeader' import RelayRegionPicker from '@/components/RelayRegionPicker' import SettingsStore from '@/store/SettingsStore' import { cosmosWallets } from '@/utils/CosmosWalletUtil' -import { eip155Wallets } from '@/utils/EIP155WalletUtil' +import { eip155Wallets, replaceEip155Mnemonic } from '@/utils/EIP155WalletUtil' import { solanaWallets } from '@/utils/SolanaWalletUtil' import { multiversxWallets } from '@/utils/MultiversxWalletUtil' import { tronWallets } from '@/utils/TronWalletUtil' import { kadenaWallets } from '@/utils/KadenaWalletUtil' -import { Card, Col, Divider, Row, Switch, Text } from '@nextui-org/react' +import { Button, Card, Col, Divider, Row, Switch, Text } from '@nextui-org/react' import { Fragment } from 'react' import { useSnapshot } from 'valtio' import packageJSON from '../../package.json' @@ -32,6 +32,12 @@ export default function SettingsPage() { chainAbstractionEnabled } = useSnapshot(SettingsStore.state) + const onImportEip155Mnemonic = (value: string | null) => { + console.log('Importing EIP155 Mnemonic: ', value) + if (!value) throw new Error('No value provided') + replaceEip155Mnemonic(value.trim()) + } + return ( @@ -191,8 +197,14 @@ export default function SettingsPage() { be used elsewhere! - + EIP155 Mnemonic + {eip155Wallets[eip155Address].getMnemonic()} diff --git a/advanced/wallets/react-wallet-v2/src/utils/EIP155WalletUtil.ts b/advanced/wallets/react-wallet-v2/src/utils/EIP155WalletUtil.ts index 247c0ec84..de475da86 100644 --- a/advanced/wallets/react-wallet-v2/src/utils/EIP155WalletUtil.ts +++ b/advanced/wallets/react-wallet-v2/src/utils/EIP155WalletUtil.ts @@ -18,7 +18,11 @@ export function createOrRestoreEIP155Wallet() { const mnemonic2 = localStorage.getItem('EIP155_MNEMONIC_2') if (mnemonic1 && mnemonic2) { - wallet1 = EIP155Lib.init({ mnemonic: mnemonic1 }) + if (mnemonic1.includes(' ')) { + wallet1 = EIP155Lib.init({ mnemonic: mnemonic1 }) + } else { + wallet1 = EIP155Lib.init({ privateKey: mnemonic1 }) + } wallet2 = EIP155Lib.init({ mnemonic: mnemonic2 }) } else { wallet1 = EIP155Lib.init({}) @@ -44,6 +48,22 @@ export function createOrRestoreEIP155Wallet() { } } +export async function replaceEip155Mnemonic(mnemonicOrPrivateKey: string) { + try { + let wallet + if (mnemonicOrPrivateKey.includes(' ')) { + wallet = EIP155Lib.init({ mnemonic: mnemonicOrPrivateKey }) + } else { + wallet = EIP155Lib.init({ privateKey: mnemonicOrPrivateKey }) + } + localStorage.setItem('EIP155_MNEMONIC_1', wallet.getMnemonic()) + location.reload() + } catch (error) { + console.error('Failed to replace mnemonic: ', error) + throw new Error('Invalid mnemonic or private key') + } +} + /** * Get wallet for the address in params */ From 61e0c4e64fda328bf1cfb8959b09cc61f7e6771d Mon Sep 17 00:00:00 2001 From: Gancho Radkov Date: Thu, 6 Feb 2025 13:11:53 +0200 Subject: [PATCH 4/8] chore: updates tvf canary --- advanced/wallets/react-wallet-v2/package.json | 2 +- advanced/wallets/react-wallet-v2/yarn.lock | 113 ++++++++++++------ 2 files changed, 76 insertions(+), 39 deletions(-) diff --git a/advanced/wallets/react-wallet-v2/package.json b/advanced/wallets/react-wallet-v2/package.json index 98b2a0231..dd7b83d0d 100644 --- a/advanced/wallets/react-wallet-v2/package.json +++ b/advanced/wallets/react-wallet-v2/package.json @@ -30,7 +30,7 @@ "@polkadot/keyring": "^10.1.2", "@polkadot/types": "^9.3.3", "@reown/appkit-experimental": "1.1.5", - "@reown/walletkit": "1.1.2-canary-wasm-5", + "@reown/walletkit": "1.1.2-canary-tvf-1", "@rhinestone/module-sdk": "0.1.25", "@solana/web3.js": "1.89.2", "@taquito/signer": "^15.1.0", diff --git a/advanced/wallets/react-wallet-v2/yarn.lock b/advanced/wallets/react-wallet-v2/yarn.lock index 218ed0335..92c9ad443 100644 --- a/advanced/wallets/react-wallet-v2/yarn.lock +++ b/advanced/wallets/react-wallet-v2/yarn.lock @@ -1259,6 +1259,11 @@ "@react-types/shared" "3.11.0" "@stitches/react" "1.2.7" +"@noble/ciphers@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@noble/ciphers/-/ciphers-1.2.1.tgz#3812b72c057a28b44ff0ad4aff5ca846e5b9cdc9" + integrity sha512-rONPWMC7PeExE077uLE4oqWrZ1IvAfz3oH9LibVAcVCopJiA9R62uavnbEzdkVmJYI6M6Zgkbeb07+tWjlq2XA== + "@noble/curves@1.3.0", "@noble/curves@^1.2.0", "@noble/curves@~1.3.0": version "1.3.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.3.0.tgz#01be46da4fd195822dab821e72f71bf4aeec635e" @@ -1280,6 +1285,20 @@ dependencies: "@noble/hashes" "1.5.0" +"@noble/curves@1.8.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.0.tgz#fe035a23959e6aeadf695851b51a87465b5ba8f7" + integrity sha512-j84kjAbzEnQHaSIhRPUmB3/eVXu2k3dKPl2LOrR8fSOIL+89U+7lV117EWHtq/GHM3ReGHM46iRBdZfpc4HRUQ== + dependencies: + "@noble/hashes" "1.7.0" + +"@noble/curves@1.8.1": + version "1.8.1" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.1.tgz#19bc3970e205c99e4bdb1c64a4785706bce497ff" + integrity sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ== + dependencies: + "@noble/hashes" "1.7.1" + "@noble/curves@^1.4.0", "@noble/curves@~1.4.0": version "1.4.2" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.2.tgz#40309198c76ed71bc6dbf7ba24e81ceb4d0d1fe9" @@ -1317,6 +1336,16 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.5.0.tgz#abadc5ca20332db2b1b2aa3e496e9af1213570b0" integrity sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA== +"@noble/hashes@1.7.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.0.tgz#5d9e33af2c7d04fee35de1519b80c958b2e35e39" + integrity sha512-HXydb0DgzTpDPwbVeDGCG1gIu7X6+AuU6Zl6av/E/KG8LMsvPntvq+w17CHRpKBmN6Ybdrt1eP3k4cj8DJa78w== + +"@noble/hashes@1.7.1": + version "1.7.1" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.1.tgz#5738f6d765710921e7a751e00c20ae091ed8db0f" + integrity sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ== + "@noble/secp256k1@1.7.1": version "1.7.1" resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c" @@ -2231,18 +2260,18 @@ valtio "1.11.2" viem "2.x" -"@reown/walletkit@1.1.2-canary-wasm-5": - version "1.1.2-canary-wasm-5" - resolved "https://registry.yarnpkg.com/@reown/walletkit/-/walletkit-1.1.2-canary-wasm-5.tgz#168a95d95c77f6bdd2c7d62c0b64b46c42dbd9d2" - integrity sha512-8pR4Sg7L8gT/gsPGgv0FygSNu7ZXu6Rb8AgjcazNcEb4ml8RhYPpXmX/GGI/iz6zXB9jxDYERCmAQDFfzpkm9w== +"@reown/walletkit@1.1.2-canary-tvf-1": + version "1.1.2-canary-tvf-1" + resolved "https://registry.yarnpkg.com/@reown/walletkit/-/walletkit-1.1.2-canary-tvf-1.tgz#ddc35cd825f5b8df27ac13dc9ac3a349e922f0da" + integrity sha512-Hj0SrNReFeIOGu2SdZAvRXol77sValoJUs43xZZnh5MV5WLjoWeJglKkkLnK1yfAE64zc/0rBB5aMYYPemfetw== dependencies: - "@walletconnect/core" "2.17.3" + "@walletconnect/core" "2.18.0-canary-tvf-1" "@walletconnect/jsonrpc-provider" "1.0.14" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "2.1.2" - "@walletconnect/sign-client" "2.17.3" - "@walletconnect/types" "2.17.3" - "@walletconnect/utils" "2.17.3" + "@walletconnect/sign-client" "2.18.0-canary-tvf-1" + "@walletconnect/types" "2.18.0-canary-tvf-1" + "@walletconnect/utils" "2.18.0-canary-tvf-1" brotli "^1.3.3" "@rhinestone/module-sdk@0.1.25": @@ -2898,10 +2927,10 @@ lodash.isequal "4.5.0" uint8arrays "3.1.0" -"@walletconnect/core@2.17.3": - version "2.17.3" - resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.17.3.tgz#e59045a666951e9fc2e8420130c4f93221bd2492" - integrity sha512-57uv0FW4L6H/tmkb1kS2nG41MDguyDgZbGR58nkDUd1TO/HydyiTByVOhFzIxgN331cnY/1G1rMaKqncgdnOFA== +"@walletconnect/core@2.18.0-canary-tvf-1": + version "2.18.0-canary-tvf-1" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.18.0-canary-tvf-1.tgz#c05e39440670e5e8d4e60f4576f9f80e6bf0d7c4" + integrity sha512-Te1W2OBNHdpBWDkEHhzCgZeX0DRWaxh3lysRkfsyVSP90OEKqhk2c/hT3IrNxHE3NR9w0XeBMdV/Ecvmj16Tlw== dependencies: "@walletconnect/heartbeat" "1.2.2" "@walletconnect/jsonrpc-provider" "1.0.14" @@ -2911,11 +2940,11 @@ "@walletconnect/keyvaluestorage" "1.1.1" "@walletconnect/logger" "2.1.2" "@walletconnect/relay-api" "1.0.11" - "@walletconnect/relay-auth" "1.0.4" + "@walletconnect/relay-auth" "1.1.0" "@walletconnect/safe-json" "1.0.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.17.3" - "@walletconnect/utils" "2.17.3" + "@walletconnect/types" "2.18.0-canary-tvf-1" + "@walletconnect/utils" "2.18.0-canary-tvf-1" "@walletconnect/window-getters" "1.0.1" events "3.3.0" lodash.isequal "4.5.0" @@ -3045,6 +3074,17 @@ tslib "1.14.1" uint8arrays "^3.0.0" +"@walletconnect/relay-auth@1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@walletconnect/relay-auth/-/relay-auth-1.1.0.tgz#c3c5f54abd44a5138ea7d4fe77970597ba66c077" + integrity sha512-qFw+a9uRz26jRCDgL7Q5TA9qYIgcNY8jpJzI1zAWNZ8i7mQjaijRnWFKsCHAU9CyGjvt6RKrRXyFtFOpWTVmCQ== + dependencies: + "@noble/curves" "1.8.0" + "@noble/hashes" "1.7.0" + "@walletconnect/safe-json" "^1.0.1" + "@walletconnect/time" "^1.0.2" + uint8arrays "^3.0.0" + "@walletconnect/safe-json@1.0.2", "@walletconnect/safe-json@^1.0.1", "@walletconnect/safe-json@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@walletconnect/safe-json/-/safe-json-1.0.2.tgz#7237e5ca48046e4476154e503c6d3c914126fa77" @@ -3067,19 +3107,19 @@ "@walletconnect/utils" "2.17.0" events "3.3.0" -"@walletconnect/sign-client@2.17.3": - version "2.17.3" - resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.17.3.tgz#86c116bc927946bffa8415ca8d92d3ef412082e1" - integrity sha512-OzOWxRTfVGCHU3OOF6ibPkgPfDpivFJjuknfcOUt9PYWpTAv6YKOmT4cyfBPhc7llruyHpV44fYbykMcLIvEcg== +"@walletconnect/sign-client@2.18.0-canary-tvf-1": + version "2.18.0-canary-tvf-1" + resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.18.0-canary-tvf-1.tgz#30ea47b437deef1796872440ca1d5d852e6e3ee7" + integrity sha512-J3TlAh9zbyhnRvAQy4YegLEvIEypGCUL7mPexcJA9mZ+jzv0f7AtK6OEE1kM2pc5nS/XdSRplbYoHTmk0lNXZw== dependencies: - "@walletconnect/core" "2.17.3" + "@walletconnect/core" "2.18.0-canary-tvf-1" "@walletconnect/events" "1.0.1" "@walletconnect/heartbeat" "1.2.2" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "2.1.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.17.3" - "@walletconnect/utils" "2.17.3" + "@walletconnect/types" "2.18.0-canary-tvf-1" + "@walletconnect/utils" "2.18.0-canary-tvf-1" events "3.3.0" "@walletconnect/time@1.0.2", "@walletconnect/time@^1.0.2": @@ -3101,10 +3141,10 @@ "@walletconnect/logger" "2.1.2" events "3.3.0" -"@walletconnect/types@2.17.3": - version "2.17.3" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.17.3.tgz#906f25cf0c9691704b9161eaa305262b0e7626d0" - integrity sha512-5eFxnbZGJJx0IQyCS99qz+OvozpLJJYfVG96dEHGgbzZMd+C9V1eitYqVClx26uX6V+WQVqVwjpD2Dyzie++Wg== +"@walletconnect/types@2.18.0-canary-tvf-1": + version "2.18.0-canary-tvf-1" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.18.0-canary-tvf-1.tgz#142874526362b2f96dec67d75944b0a7930d84df" + integrity sha512-a7sg0qP3T6MtRwQLqLG/xbnReCRFfMpcaUF/PQqznmN5XDSEx2jPnwkwWIWYwFhsQSQfiMhW6HR0+h1j0w8DvQ== dependencies: "@walletconnect/events" "1.0.1" "@walletconnect/heartbeat" "1.2.2" @@ -3150,25 +3190,22 @@ query-string "7.1.3" uint8arrays "3.1.0" -"@walletconnect/utils@2.17.3": - version "2.17.3" - resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.17.3.tgz#a22938567febc3e3771efae8eb351adf3d499a8d" - integrity sha512-tG77UpZNeLYgeOwViwWnifpyBatkPlpKSSayhN0gcjY1lZAUNqtYslpm4AdTxlrA3pL61MnyybXgWYT5eZjarw== +"@walletconnect/utils@2.18.0-canary-tvf-1": + version "2.18.0-canary-tvf-1" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.18.0-canary-tvf-1.tgz#c2ce9e88b1440a34767b2699756532d4b85e4a77" + integrity sha512-CoOU5TFzd0iK4VeEAImTnmc30DeJPgCyoQLq9nOjnjlDChUVGcmi8OdCjwrEhokcCfzPMuFEbpNjewg9+mUnLw== dependencies: - "@ethersproject/hash" "5.7.0" "@ethersproject/transactions" "5.7.0" - "@stablelib/chacha20poly1305" "1.0.1" - "@stablelib/hkdf" "1.0.1" - "@stablelib/random" "1.0.2" - "@stablelib/sha256" "1.0.1" - "@stablelib/x25519" "1.0.3" + "@noble/ciphers" "1.2.1" + "@noble/curves" "1.8.1" + "@noble/hashes" "1.7.1" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/keyvaluestorage" "1.1.1" "@walletconnect/relay-api" "1.0.11" - "@walletconnect/relay-auth" "1.0.4" + "@walletconnect/relay-auth" "1.1.0" "@walletconnect/safe-json" "1.0.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.17.3" + "@walletconnect/types" "2.18.0-canary-tvf-1" "@walletconnect/window-getters" "1.0.1" "@walletconnect/window-metadata" "1.0.1" detect-browser "5.3.0" From a5266f072839fe58d22e5614f9575f368846340b Mon Sep 17 00:00:00 2001 From: Gancho Radkov Date: Mon, 17 Feb 2025 13:18:38 +0200 Subject: [PATCH 5/8] feat: execute method --- advanced/wallets/react-wallet-v2/package.json | 4 +- .../components/MultibridgeRequestModal.tsx | 332 ++++-------------- .../src/utils/EIP155WalletUtil.ts | 8 + .../src/views/SessionSendTransactionModal.tsx | 174 +++------ advanced/wallets/react-wallet-v2/yarn.lock | 139 ++++---- 5 files changed, 209 insertions(+), 448 deletions(-) diff --git a/advanced/wallets/react-wallet-v2/package.json b/advanced/wallets/react-wallet-v2/package.json index dd7b83d0d..97088752d 100644 --- a/advanced/wallets/react-wallet-v2/package.json +++ b/advanced/wallets/react-wallet-v2/package.json @@ -30,7 +30,7 @@ "@polkadot/keyring": "^10.1.2", "@polkadot/types": "^9.3.3", "@reown/appkit-experimental": "1.1.5", - "@reown/walletkit": "1.1.2-canary-tvf-1", + "@reown/walletkit": "1.1.2-canary-wasm-9", "@rhinestone/module-sdk": "0.1.25", "@solana/web3.js": "1.89.2", "@taquito/signer": "^15.1.0", @@ -63,7 +63,7 @@ "tiny-secp256k1": "^2.2.3", "tronweb": "^4.4.0", "valtio": "1.13.2", - "viem": "2.17.8", + "viem": "2.23.2", "webauthn-p256": "0.0.2" }, "devDependencies": { diff --git a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx index cb99a83cb..5268e282a 100644 --- a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx @@ -11,290 +11,115 @@ import { getAssetByContractAddress, getErc20TokenBalance } from '@/utils/MultibridgeUtil' -import { getWallet } from '@/utils/EIP155WalletUtil' +import { getWallet, getWalletByAddress } from '@/utils/EIP155WalletUtil' import { walletkit } from '@/utils/WalletConnectUtil' import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data' -import { ChainAbstractionService, Transaction } from '@/utils/ChainAbstractionService' -import { providers } from 'ethers' -import { formatJsonRpcError } from '@json-rpc-tools/utils' +import { ChainAbstractionService } from '@/utils/ChainAbstractionService' +import { ethers, providers } from 'ethers' +import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils' import { ChainAbstractionTypes } from '@reown/walletkit' -import { Hex } from 'viem' +import { createWalletClient, Hex, http, recoverAddress, recoverMessageAddress } from 'viem' import BridgeBadge from './BridgeBadge' +import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts' +import { mainnet } from 'viem/chains' interface IProps { onReject: () => void - transactions?: Transaction[] - initialTransaction: Transaction - orchestrationId: string rejectLoader?: LoaderProps - fundings: ChainAbstractionTypes.FundingFrom[] - initialTransactionMetadata: ChainAbstractionTypes.InitialTransactionMetadata + bridgeDetails: ChainAbstractionTypes.UiFields } -export default function MultibridgeRequestModal({ - transactions, - initialTransaction, - orchestrationId, - onReject, - rejectLoader, - fundings, - initialTransactionMetadata -}: IProps) { +export default function MultibridgeRequestModal({ onReject, rejectLoader, bridgeDetails }: IProps) { const [isLoadingApprove, setIsLoadingApprove] = useState(false) - - const [bridgingTransactions, setBridgingTransactions] = useState([]) const [tokenBalances, setTokenBalances] = useState>({}) - const [totalFee, setTotalFee] = useState('') - const [transaction, setTransaction] = useState(initialTransaction) - console.log('transactions', transactions) - // const bridgingTransactions = transactions - - const eip155ChainsFundsSourcedFrom = bridgingTransactions - ? new Set(bridgingTransactions.map(transaction => transaction.chainId)) - : new Set() + const transaction = bridgeDetails.initial.transaction + console.log('bridgeDetails', bridgeDetails) + const bridgingTransactions = bridgeDetails.route.map(route => route) + const orchestrationId = bridgeDetails.routeResponse.orchestrationId + const totalFee = bridgeDetails.localTotal.formattedAlt + const initialTransactionMetadata = bridgeDetails.routeResponse.metadata.initialTransaction + const fundingFrom = bridgeDetails.routeResponse.metadata.fundingFrom + console.log('transactions', bridgingTransactions) - const eip155ChainFundsDestination = initialTransaction?.chainId + const eip155ChainFundsDestination = transaction?.chainId // Get request and wallet data from store const requestEvent = ModalStore.state.data?.requestEvent const requestSession = ModalStore.state.data?.requestSession - const topic = requestEvent?.topic const params = requestEvent?.params const request = params?.request - useMemo(async () => { - if (!orchestrationId) { - return null - } - const details = await walletkit.getFulfilmentDetails({ fulfilmentId: orchestrationId }) - // const details = { - // routeDetails: [ - // { - // transaction: { - // chainId: 'eip155:8453', - // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', - // to: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', - // value: '0x0', - // input: - // '0x095ea7b30000000000000000000000003a23f943181408eac424116af7b7790c94cb97a50000000000000000000000000000000000000000000000000000000000225928', - // gasLimit: '0x1b760', - // nonce: '0x17', - // maxFeePerGas: '0xd5d732', - // maxPriorityFeePerGas: '0xf4240' - // }, - // transactionFee: { - // fee: { - // symbol: 'ETH', - // amount: '0x171c8892672', - // unit: 18, - // formatted: '0.000001588207363698 ETH', - // formatted_alt: '<$0.01' - // }, - // localFee: { - // symbol: 'USD', - // amount: '0x6b62af154a82c7301f20', - // unit: 26, - // formatted: '0.00507113610658132270260000 USD', - // formatted_alt: '$0.01' - // } - // } - // }, - // { - // transaction: { - // chainId: 'eip155:8453', - // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', - // to: '0x3a23f943181408eac424116af7b7790c94cb97a5', - // value: '0x0', - // input: - // '0x0000019b792ebcb90000000000000000000000000000000000000000000000000000000000225928000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000001c2f0000000000000000000000000000000000000000000000000000000000001b3b000000000000000000000000000000000000000000000000000000000000000200000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c520000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000223cf9000000000000000000000000000000000000000000000000000000000000a4b1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000679b390b00000000000000000000000000000000000000000000000000000000679b8d11d00dfeeddeadbeef765753be7f7a64d5509974b0d678e1e3149b02f4', - // gasLimit: '0x1a584', - // nonce: '0x18', - // maxFeePerGas: '0xd5d732', - // maxPriorityFeePerGas: '0xf4240' - // }, - // transactionFee: { - // fee: { - // symbol: 'ETH', - // amount: '0x166e7abc8ce', - // unit: 18, - // formatted: '0.000001541485086926 ETH', - // formatted_alt: '<$0.01' - // }, - // localFee: { - // symbol: 'USD', - // amount: '0x6839f4c8807ec111d4e0', - // unit: 26, - // formatted: '0.00492195217119867036620000 USD', - // formatted_alt: '<$0.01' - // } - // } - // } - // ], - // initialTransactionDetails: { - // transaction: { - // chainId: 'eip155:42161', - // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', - // to: '0xaf88d065e77c8cc2239327c5edb3a432268e5831', - // value: '0x0', - // input: - // '0xa9059cbb00000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000000000000000000000000000000000000003d0900', - // gasLimit: '0x1913a', - // nonce: '0x4b', - // maxFeePerGas: '0x1312d01', - // maxPriorityFeePerGas: '0x1' - // }, - // transactionFee: { - // fee: { - // symbol: 'ETH', - // amount: '0x1de4ca2c33a', - // unit: 18, - // formatted: '0.000002054280102714 ETH', - // formatted_alt: '<$0.01' - // }, - // localFee: { - // symbol: 'USD', - // amount: '0x8ad02fd36877a3207d80', - // unit: 26, - // formatted: '0.00655526943616345542000000 USD', - // formatted_alt: '$0.01' - // } - // } - // }, - // bridgeDetails: [ - // { - // fee: { - // symbol: 'USDC', - // amount: '0xb729d', - // unit: 6, - // formatted: '0.750237 USDC', - // formatted_alt: '$0.75' - // }, - // localFee: { - // symbol: 'USD', - // amount: '0x444cf6c826fb', - // unit: 14, - // formatted: '0.75097348515579 USD', - // formattedAlt: '$0.75' - // } - // } - // ], - // totalFee: { - // symbol: 'USD', - // amount: '0x3f7ce83f5225a6a9992180', - // unit: 26, - // formatted: '0.76752184286973344848880000 USD', - // formattedAlt: '$0.77' - // } - // } - console.log('details', details) - setTotalFee(details.totalFee.formattedAlt) - setTransaction({ - ...details.initialTransactionDetails.transaction, - data: details.initialTransactionDetails.transaction.input + const bridgeFunds = async ( + bridgeSignedTransactions: string[], + initialSignedTransaction: string + ) => { + return await walletkit.chainAbstraction.execute({ + orchestrationId, + bridgeSignedTransactions, + initialSignedTransaction }) - setBridgingTransactions( - details.routeDetails.map(route => ({ - ...route.transaction, - data: route.transaction.input - })) - ) - }, [orchestrationId]) - - const bridgeFunds = useCallback(async (): Promise => { - if (!bridgingTransactions) { - throw new Error('bridgingTransactions are unavailable') - } - - const wallet = await getWallet(params) - console.log( - 'Bridge funds from', - eip155ChainsFundsSourcedFrom, - 'to', - eip155ChainFundsDestination - ) - - for (const transaction of bridgingTransactions) { - console.log('Bridging transaction', transaction) - const chainId = transaction.chainId - const chainProvider = new providers.JsonRpcProvider( - EIP155_CHAINS[chainId as TEIP155Chain].rpc - ) - const chainConnectedWallet = await wallet.connect(chainProvider) - const walletAddress = wallet.getAddress() - console.log('Connected wallet address', chainConnectedWallet) - const txResponse = await chainConnectedWallet.sendTransaction({ - from: walletAddress, - to: transaction.to, - value: transaction.value, - data: transaction.data, - nonce: transaction.nonce, - maxFeePerGas: transaction.maxFeePerGas, - maxPriorityFeePerGas: transaction.maxPriorityFeePerGas, - gasLimit: transaction.gasLimit - }) - const txHash = typeof txResponse === 'string' ? txResponse : txResponse?.hash - const txReceipt = await txResponse.wait() - console.log('Transaction receipt', txReceipt) - const txStatus = txReceipt.status - console.log( - `Transaction broadcasted on chain ${chainId} , ${{ txHash }}, status: ${txStatus}` - ) - } - }, [bridgingTransactions, orchestrationId, onReject, params]) - - const fetchTokenBalance = async (chainId: string, tokenAddress: string) => { - const tokenBalance = await getErc20TokenBalance( - tokenAddress as Hex, - Number(chainId.split(':')[1]), - initialTransaction?.from as Hex - ) - console.log('Token balance', tokenBalance) - setTokenBalances(prevState => ({ - ...prevState, - [tokenAddress]: tokenBalance - })) } useEffect(() => { - console.log('Initial transaction', initialTransaction?.chainId) - if (initialTransactionMetadata) { - console.log('Fetching token balance for', initialTransaction.to) - fetchTokenBalance(initialTransaction.chainId, initialTransactionMetadata.tokenContract) + console.log('Initial transaction', initialTransactionMetadata) + const fetchTokenBalance = async (tokenAddress: string) => { + const tokenBalance = await getErc20TokenBalance( + tokenAddress as Hex, + Number(transaction.chainId.split(':')[1]), + transaction?.from as Hex + ) + console.log('Token balance', tokenBalance) + setTokenBalances(prevState => ({ + ...prevState, + [tokenAddress]: tokenBalance + })) } - }, [initialTransactionMetadata]) + fetchTokenBalance(initialTransactionMetadata.tokenContract) + }, []) const onApprove = useCallback(async (): Promise => { - if (requestEvent && topic) { + if (requestEvent) { + const topic = requestEvent.topic + const id = requestEvent.id setIsLoadingApprove(true) try { - performance.mark('startInititalTransactionSend') - await bridgeFunds() - const response = await approveEIP155Request({ - ...requestEvent, - params: { - ...requestEvent.params, - request: { - ...requestEvent.params.request, - params: { - ...transaction - } - } - } + console.log('Approving request', transaction) + const loadedWallet = getWalletByAddress(transaction.from) + const account = mnemonicToAccount(loadedWallet.getMnemonic()) + console.log('Account', account) + + console.log('Connected wallet', account) + const bridgeSignedTransactions = [] + for (const route of bridgeDetails.route) { + const message = route.transactionHashToSign + const signature = await account.sign({ hash: message }) + bridgeSignedTransactions.push(signature) + console.log('Signed bridge transaction', { + message, + signature, + address: account.address + }) + } + + const message = bridgeDetails.initial.transactionHashToSign + const initialSignedTransaction = await account.sign({ + hash: message }) - performance.mark('endInititalTransactionSend') - console.log( - `Initial transaction send: ${ - performance.measure( - 'initial-tx-send', - 'startInititalTransactionSend', - 'endInititalTransactionSend' - ).duration - } ms` - ) - await walletkit.respondSessionRequest({ topic, response }) + console.log('Signed initial transaction', { + message, + signature: initialSignedTransaction, + address: account.address + }) + const result = await bridgeFunds(bridgeSignedTransactions, initialSignedTransaction) + + await walletkit.respondSessionRequest({ + topic, + response: formatJsonRpcResult(id, result.initialTxnHash) + }) + ModalStore.close() } catch (e) { const { id } = requestEvent const errorMessage = (e as Error).message || 'Error bridging funds' @@ -308,9 +133,8 @@ export default function MultibridgeRequestModal({ } finally { setIsLoadingApprove(false) } - ModalStore.close() } - }, [bridgeFunds, requestEvent, topic]) + }, [bridgeDetails, bridgeFunds]) if (!request || !requestSession || !bridgingTransactions || bridgingTransactions.length === 0) { return Request not found @@ -401,7 +225,7 @@ export default function MultibridgeRequestModal({ {initialTransactionMetadata.symbol} - {fundings?.map((funding, i) => { + {fundingFrom?.map((funding, i) => { return ( diff --git a/advanced/wallets/react-wallet-v2/src/utils/EIP155WalletUtil.ts b/advanced/wallets/react-wallet-v2/src/utils/EIP155WalletUtil.ts index de475da86..9fbc871aa 100644 --- a/advanced/wallets/react-wallet-v2/src/utils/EIP155WalletUtil.ts +++ b/advanced/wallets/react-wallet-v2/src/utils/EIP155WalletUtil.ts @@ -1,6 +1,7 @@ import EIP155Lib from '@/lib/EIP155Lib' import { smartAccountWallets } from './SmartAccountUtil' import { getWalletAddressFromParams } from './HelperUtil' +import { ethers } from 'ethers' export let wallet1: EIP155Lib export let wallet2: EIP155Lib @@ -64,6 +65,13 @@ export async function replaceEip155Mnemonic(mnemonicOrPrivateKey: string) { } } +export const getWalletByAddress = (address: string) => { + const checksumAddress = ethers.utils.getAddress(address) + const wallet = eip155Wallets[checksumAddress] + console.log('getWalletByAddress', { checksumAddress, wallet, eip155Wallets }) + return wallet +} + /** * Get wallet for the address in params */ diff --git a/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx b/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx index 58b3c8952..baf307a4e 100644 --- a/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx @@ -1,9 +1,8 @@ import { useCallback, useEffect, useState } from 'react' -import { Card, Divider, Loading, Text } from '@nextui-org/react' +import { Card, Col, Divider, Loading, Row, Text } from '@nextui-org/react' import { approveEIP155Request, rejectEIP155Request } from '@/utils/EIP155RequestHandlerUtil' import { styledToast } from '@/utils/HelperUtil' import { walletkit } from '@/utils/WalletConnectUtil' -import { ChainAbstractionService, Transaction } from '@/utils/ChainAbstractionService' import ModalStore from '@/store/ModalStore' import SettingsStore from '@/store/SettingsStore' @@ -12,7 +11,7 @@ import RequestDetailsCard from '@/components/RequestDetalilsCard' import RequestMethodCard from '@/components/RequestMethodCard' import RequestModal from '@/components/RequestModal' import MultibridgeRequestModal from '@/components/MultibridgeRequestModal' -import { ChainAbstractionTypes, WalletKitTypes } from '@reown/walletkit' +import { ChainAbstractionTypes } from '@reown/walletkit' // Types for props used in individual components type Session = { @@ -26,13 +25,9 @@ export default function SessionSendTransactionModal() { const [isLoadingApprove, setIsLoadingApprove] = useState(false) const [isLoadingReject, setIsLoadingReject] = useState(false) const [isReadyForRender, setIsReadyForRender] = useState(false) - const [requiresMultiChain, setRequiresMultiChain] = useState(false) - const [routeTransactions, setRouteTransactions] = useState([]) - const [orchestrationId, setOrchestrationId] = useState(null) - const [initialTransaction, setInitialTransaction] = useState() - const [fundings, setFundings] = useState() - const [initialTransactionMetadata, setInitialTransactionMetadata] = - useState() + useState() + const [bridgeDetails, setBridgeDetails] = useState() + const [chainAbstractionStatus, setChainAbstractionStatus] = useState('') // Extract request and wallet data from store const requestEvent = ModalStore.state.data?.requestEvent const requestSession = ModalStore.state.data?.requestSession @@ -74,97 +69,44 @@ export default function SessionSendTransactionModal() { const setupRouteTransactions = async ( // caService: ChainAbstractionService, - request: { params: [{ from: string; to: string; data: string }] }, + request: { + params: [ + { + from: ChainAbstractionTypes.Hex + to: ChainAbstractionTypes.Hex + data: ChainAbstractionTypes.Hex + } + ] + }, chainId: string ): Promise => { const { data, from, to } = request.params[0] - const result = await walletkit.prepareFulfilment({ + const result = await walletkit.chainAbstraction.prepareDetailed({ transaction: { - to, from, - data, + to, + input: data, chainId } }) - // const result = { - // status: 'available', - // data: { - // fulfilmentId: 'e20881f7-df15-4b99-9d72-8456dc0f4662', - // transactions: [ - // { - // chainId: 'eip155:8453', - // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', - // to: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', - // value: '0x0', - // input: - // '0x095ea7b30000000000000000000000003a23f943181408eac424116af7b7790c94cb97a50000000000000000000000000000000000000000000000000000000000225928', - // gasLimit: '0x1b760', - // nonce: '0x17' - // }, - // { - // chainId: 'eip155:8453', - // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', - // to: '0x3a23f943181408eac424116af7b7790c94cb97a5', - // value: '0x0', - // input: - // '0x0000019b792ebcb90000000000000000000000000000000000000000000000000000000000225928000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000001c2f0000000000000000000000000000000000000000000000000000000000001b3b000000000000000000000000000000000000000000000000000000000000000200000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c520000000000000000000000000000000000000000000000000000000000000002000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000223cf9000000000000000000000000000000000000000000000000000000000000a4b1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000679b390b00000000000000000000000000000000000000000000000000000000679b8d11d00dfeeddeadbeef765753be7f7a64d5509974b0d678e1e3149b02f4', - // gasLimit: '0x1a584', - // nonce: '0x18' - // } - // ], - // funding: [ - // { - // chainId: 'eip155:8453', - // tokenContract: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', - // symbol: 'USDC', - // amount: '0x223cf9', - // bridgingFee: '0xb729d', - // decimals: 6 - // } - // ], - // initialTransaction: { - // chainId: 'eip155:42161', - // from: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', - // to: '0xaf88d065e77c8cc2239327c5edb3a432268e5831', - // value: '0x0', - // input: - // '0xa9059cbb00000000000000000000000013a2ff792037aa2cd77fe1f4b522921ac59a9c5200000000000000000000000000000000000000000000000000000000003d0900', - // gasLimit: '0x1913a', - // nonce: '0x4b' - // }, - // initialTransactionMetadata: { - // transferTo: '0x13a2ff792037aa2cd77fe1f4b522921ac59a9c52', - // amount: '0x3d0900', - // tokenContract: '0xaf88d065e77c8cc2239327c5edb3a432268e5831', - // symbol: 'USDC', - // decimals: 6 - // } - // } - // } - console.log('Fulfilment result:', result) - if (result.status === 'available') { - const routes = result.data.transactions.map(tx => ({ - ...tx, - data: tx.input - })) - setFundings(result.data.funding) - setRouteTransactions(routes) - setOrchestrationId(result.data.fulfilmentId) - setRequiresMultiChain(true) - setInitialTransaction({ - to: result.data.initialTransaction.to, - from: result.data.initialTransaction.from, - value: result.data.initialTransaction.value, - data: result.data.initialTransaction.input, - nonce: result.data.initialTransaction.nonce, - maxFeePerGas: result.data.initialTransaction.maxFeePerGas, - maxPriorityFeePerGas: result.data.initialTransaction.maxPriorityFeePerGas, - chainId: result.data.initialTransaction.chainId, - gasLimit: result.data.initialTransaction.gasLimit - }) - setInitialTransactionMetadata(result.data.initialTransactionMetadata) + console.log('prepare detaield result:', result) + if ('error' in result) { + setChainAbstractionStatus(result.error.error) + } + + if (!('success' in result)) { + return + } + + if ('notRequired' in result.success) { + setChainAbstractionStatus('not required') + } + + if ('available' in result.success) { + setChainAbstractionStatus('available') + setBridgeDetails(result.success.available) } } @@ -199,7 +141,13 @@ export default function SessionSendTransactionModal() { if (!requestEvent) return Request not found if (!isReadyForRender) return - return !requiresMultiChain || orchestrationId == null ? ( + return bridgeDetails ? ( + + ) : ( - ) : ( - ) } @@ -242,6 +181,7 @@ type SingleChainModalProps = { onReject: () => Promise loadingApprove: boolean loadingReject: boolean + chainAbstractionStatus: string } const SingleChainModal = ({ @@ -252,7 +192,8 @@ const SingleChainModal = ({ onApprove, onReject, loadingApprove, - loadingReject + loadingReject, + chainAbstractionStatus }: SingleChainModalProps): JSX.Element => ( + + + + Chain Abstraction Status + + {chainAbstractionStatus} + + + @@ -271,31 +221,19 @@ const SingleChainModal = ({ ) type MultiChainModalProps = { - transactions: Transaction[] - initialTransaction: Transaction - orchestrationId: string onReject: () => Promise loadingReject: boolean - fundings: ChainAbstractionTypes.FundingFrom[] - initialTransactionMetadata: ChainAbstractionTypes.InitialTransactionMetadata + bridgeDetails: ChainAbstractionTypes.UiFields } const MultiChainModal = ({ - transactions, - initialTransaction, - orchestrationId, onReject, loadingReject, - fundings, - initialTransactionMetadata + bridgeDetails }: MultiChainModalProps): JSX.Element => ( ) diff --git a/advanced/wallets/react-wallet-v2/yarn.lock b/advanced/wallets/react-wallet-v2/yarn.lock index 92c9ad443..82f42579d 100644 --- a/advanced/wallets/react-wallet-v2/yarn.lock +++ b/advanced/wallets/react-wallet-v2/yarn.lock @@ -7,12 +7,7 @@ resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== -"@adraffy/ens-normalize@1.10.0": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" - integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== - -"@adraffy/ens-normalize@1.11.0": +"@adraffy/ens-normalize@1.11.0", "@adraffy/ens-normalize@^1.10.1": version "1.11.0" resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz#42cc67c5baa407ac25059fcd7d405cc5ecdb0c33" integrity sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg== @@ -1271,13 +1266,6 @@ dependencies: "@noble/hashes" "1.3.3" -"@noble/curves@1.4.0": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.0.tgz#f05771ef64da724997f69ee1261b2417a49522d6" - integrity sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg== - dependencies: - "@noble/hashes" "1.4.0" - "@noble/curves@1.6.0", "@noble/curves@^1.4.2", "@noble/curves@^1.6.0", "@noble/curves@~1.6.0": version "1.6.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.6.0.tgz#be5296ebcd5a1730fccea4786d420f87abfeb40b" @@ -1292,14 +1280,14 @@ dependencies: "@noble/hashes" "1.7.0" -"@noble/curves@1.8.1": +"@noble/curves@1.8.1", "@noble/curves@~1.8.1": version "1.8.1" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.1.tgz#19bc3970e205c99e4bdb1c64a4785706bce497ff" integrity sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ== dependencies: "@noble/hashes" "1.7.1" -"@noble/curves@^1.4.0", "@noble/curves@~1.4.0": +"@noble/curves@^1.4.0": version "1.4.2" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.2.tgz#40309198c76ed71bc6dbf7ba24e81ceb4d0d1fe9" integrity sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw== @@ -1326,7 +1314,7 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== -"@noble/hashes@1.4.0", "@noble/hashes@^1.4.0", "@noble/hashes@~1.4.0": +"@noble/hashes@1.4.0", "@noble/hashes@^1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== @@ -1341,7 +1329,7 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.0.tgz#5d9e33af2c7d04fee35de1519b80c958b2e35e39" integrity sha512-HXydb0DgzTpDPwbVeDGCG1gIu7X6+AuU6Zl6av/E/KG8LMsvPntvq+w17CHRpKBmN6Ybdrt1eP3k4cj8DJa78w== -"@noble/hashes@1.7.1": +"@noble/hashes@1.7.1", "@noble/hashes@^1.5.0", "@noble/hashes@~1.7.1": version "1.7.1" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.1.tgz#5738f6d765710921e7a751e00c20ae091ed8db0f" integrity sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ== @@ -2260,10 +2248,10 @@ valtio "1.11.2" viem "2.x" -"@reown/walletkit@1.1.2-canary-tvf-1": - version "1.1.2-canary-tvf-1" - resolved "https://registry.yarnpkg.com/@reown/walletkit/-/walletkit-1.1.2-canary-tvf-1.tgz#ddc35cd825f5b8df27ac13dc9ac3a349e922f0da" - integrity sha512-Hj0SrNReFeIOGu2SdZAvRXol77sValoJUs43xZZnh5MV5WLjoWeJglKkkLnK1yfAE64zc/0rBB5aMYYPemfetw== +"@reown/walletkit@1.1.2-canary-wasm-9": + version "1.1.2-canary-wasm-9" + resolved "https://registry.yarnpkg.com/@reown/walletkit/-/walletkit-1.1.2-canary-wasm-9.tgz#9a09a7fd8b4122d7a6b737931205185d3ddb2be8" + integrity sha512-ftVD0pDoMS6tH8YiZ9sqkjeeSme4KWg2Md5zE1e84q9nAiNxT4nEBVeZ4vG/dREOEb7/xwgfPS17epT0/FIJzw== dependencies: "@walletconnect/core" "2.18.0-canary-tvf-1" "@walletconnect/jsonrpc-provider" "1.0.14" @@ -2302,10 +2290,10 @@ resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.5.tgz#1d85d17269fe97694b9c592552dd9e5e33552157" integrity sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ== -"@scure/base@~1.1.6": - version "1.1.7" - resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.7.tgz#fe973311a5c6267846aa131bc72e96c5d40d2b30" - integrity sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g== +"@scure/base@~1.2.2", "@scure/base@~1.2.4": + version "1.2.4" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.4.tgz#002eb571a35d69bdb4c214d0995dff76a8dcd2a9" + integrity sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ== "@scure/bip32@1.3.3": version "1.3.3" @@ -2316,15 +2304,6 @@ "@noble/hashes" "~1.3.2" "@scure/base" "~1.1.4" -"@scure/bip32@1.4.0": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.4.0.tgz#4e1f1e196abedcef395b33b9674a042524e20d67" - integrity sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg== - dependencies: - "@noble/curves" "~1.4.0" - "@noble/hashes" "~1.4.0" - "@scure/base" "~1.1.6" - "@scure/bip32@1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.5.0.tgz#dd4a2e1b8a9da60e012e776d954c4186db6328e6" @@ -2334,6 +2313,15 @@ "@noble/hashes" "~1.5.0" "@scure/base" "~1.1.7" +"@scure/bip32@1.6.2", "@scure/bip32@^1.5.0": + version "1.6.2" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.6.2.tgz#093caa94961619927659ed0e711a6e4bf35bffd0" + integrity sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw== + dependencies: + "@noble/curves" "~1.8.1" + "@noble/hashes" "~1.7.1" + "@scure/base" "~1.2.2" + "@scure/bip39@1.2.2": version "1.2.2" resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.2.tgz#f3426813f4ced11a47489cbcf7294aa963966527" @@ -2342,14 +2330,6 @@ "@noble/hashes" "~1.3.2" "@scure/base" "~1.1.4" -"@scure/bip39@1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.3.0.tgz#0f258c16823ddd00739461ac31398b4e7d6a18c3" - integrity sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ== - dependencies: - "@noble/hashes" "~1.4.0" - "@scure/base" "~1.1.6" - "@scure/bip39@1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.4.0.tgz#664d4f851564e2e1d4bffa0339f9546ea55960a6" @@ -2358,6 +2338,14 @@ "@noble/hashes" "~1.5.0" "@scure/base" "~1.1.8" +"@scure/bip39@1.5.4", "@scure/bip39@^1.4.0": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.5.4.tgz#07fd920423aa671be4540d59bdd344cc1461db51" + integrity sha512-TFM4ni0vKvCfBpohoh+/lY05i9gRbSwXWngAsF4CABQxoaOHijxuaZ2R6cStDQ5CHtHO9aGJTr4ksVJASRRyMA== + dependencies: + "@noble/hashes" "~1.7.1" + "@scure/base" "~1.2.4" + "@solana/buffer-layout@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" @@ -3265,16 +3253,16 @@ JSONStream@^1.3.5: jsonparse "^1.2.0" through ">=2.2.7 <3" -abitype@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.5.tgz#29d0daa3eea867ca90f7e4123144c1d1270774b6" - integrity sha512-YzDhti7cjlfaBhHutMaboYB21Ha3rXR9QTkNJFzYC4kC8YclaiwPBBBJY8ejFdu2wnJeZCVZSMlQJ7fi8S6hsw== - abitype@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.6.tgz#76410903e1d88e34f1362746e2d407513c38565b" integrity sha512-MMSqYh4+C/aVqI2RQaWqbvI4Kxo5cQV40WQ4QFtDnNzCkqChm8MuENhElmynZlO0qUy/ObkEUaXtKqYnx1Kp3A== +abitype@1.0.8, abitype@^1.0.6: + version "1.0.8" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.8.tgz#3554f28b2e9d6e9f35eb59878193eabd1b9f46ba" + integrity sha512-ZeiI6h3GnW06uYDLx0etQtX/p8E24UaHHBj57RSjK7YBFe7iuVn07EDpOeP451D06sF27VOz9JJPlIKJmXgkEg== + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" @@ -4775,6 +4763,11 @@ ethjs-unit@0.1.6: bn.js "4.11.6" number-to-bn "1.7.0" +eventemitter3@5.0.1, eventemitter3@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" + integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== + eventemitter3@^3.1.0: version "3.1.2" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7" @@ -4785,11 +4778,6 @@ eventemitter3@^4.0.7: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== -eventemitter3@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" - integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== - events@3.3.0, events@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" @@ -5632,11 +5620,6 @@ isomorphic-ws@^4.0.1: resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== -isows@1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.4.tgz#810cd0d90cc4995c26395d2aa4cfa4037ebdf061" - integrity sha512-hEzjY+x9u9hPmBom9IIAqdJCwNLax+xrPb51vEPpERoFlIxgmZcHzsT5jKG06nvInKOBGvReAVz80Umed5CczQ== - isows@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.6.tgz#0da29d706fa51551c663c627ace42769850f86e7" @@ -6424,6 +6407,19 @@ optionator@^0.9.1: prelude-ls "^1.2.1" type-check "^0.4.0" +ox@0.6.7: + version "0.6.7" + resolved "https://registry.yarnpkg.com/ox/-/ox-0.6.7.tgz#afd53f2ecef68b8526660e9d29dee6e6b599a832" + integrity sha512-17Gk/eFsFRAZ80p5eKqv89a57uXjd3NgIf1CaXojATPBuujVc/fQSVhBeAU9JCRB+k7J50WQAyWTxK19T9GgbA== + dependencies: + "@adraffy/ens-normalize" "^1.10.1" + "@noble/curves" "^1.6.0" + "@noble/hashes" "^1.5.0" + "@scure/bip32" "^1.5.0" + "@scure/bip39" "^1.4.0" + abitype "^1.0.6" + eventemitter3 "5.0.1" + p-limit@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" @@ -7780,19 +7776,19 @@ varuint-bitcoin@^1.0.1, varuint-bitcoin@^1.1.2: dependencies: safe-buffer "^5.1.1" -viem@2.17.8: - version "2.17.8" - resolved "https://registry.yarnpkg.com/viem/-/viem-2.17.8.tgz#79da50ef86fb429d3b36d4ef2f49be5b2999420f" - integrity sha512-AnLX26/8UAVguXvTc+o5jvehAUfoujomH+WLPNCo0Y0ukb9Z4qWpunkHvPyazeExP2V7EevVJB79mstZh0fLsQ== +viem@2.23.2: + version "2.23.2" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.23.2.tgz#db395c8cf5f4fb5572914b962fb8ce5db09f681c" + integrity sha512-NVmW/E0c5crMOtbEAqMF0e3NmvQykFXhLOc/CkLIXOlzHSA6KXVz3CYVmaKqBF8/xtjsjHAGjdJN3Ru1kFJLaA== dependencies: - "@adraffy/ens-normalize" "1.10.0" - "@noble/curves" "1.4.0" - "@noble/hashes" "1.4.0" - "@scure/bip32" "1.4.0" - "@scure/bip39" "1.3.0" - abitype "1.0.5" - isows "1.0.4" - ws "8.17.1" + "@noble/curves" "1.8.1" + "@noble/hashes" "1.7.1" + "@scure/bip32" "1.6.2" + "@scure/bip39" "1.5.4" + abitype "1.0.8" + isows "1.0.6" + ox "0.6.7" + ws "8.18.0" viem@2.x: version "2.21.28" @@ -7945,11 +7941,6 @@ ws@7.4.6: resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== -ws@8.17.1: - version "8.17.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" - integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== - ws@8.18.0: version "8.18.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" From 9f705de3ec96e429211e960c96563021307349f4 Mon Sep 17 00:00:00 2001 From: Gancho Radkov Date: Thu, 20 Feb 2025 12:37:19 +0200 Subject: [PATCH 6/8] chore; updates wk --- advanced/wallets/react-wallet-v2/package.json | 2 +- advanced/wallets/react-wallet-v2/yarn.lock | 178 ++++++++++++------ 2 files changed, 119 insertions(+), 61 deletions(-) diff --git a/advanced/wallets/react-wallet-v2/package.json b/advanced/wallets/react-wallet-v2/package.json index 8f10a90a0..3d8770dc7 100644 --- a/advanced/wallets/react-wallet-v2/package.json +++ b/advanced/wallets/react-wallet-v2/package.json @@ -30,7 +30,7 @@ "@polkadot/keyring": "^10.1.2", "@polkadot/types": "^9.3.3", "@reown/appkit-experimental": "1.6.8", - "@reown/walletkit": "1.1.2-canary-wasm-9", + "@reown/walletkit": "1.1.2-canary-ca-1", "@rhinestone/module-sdk": "0.1.25", "@solana/web3.js": "1.89.2", "@taquito/signer": "^15.1.0", diff --git a/advanced/wallets/react-wallet-v2/yarn.lock b/advanced/wallets/react-wallet-v2/yarn.lock index b54c4159c..515c548e1 100644 --- a/advanced/wallets/react-wallet-v2/yarn.lock +++ b/advanced/wallets/react-wallet-v2/yarn.lock @@ -2233,18 +2233,18 @@ valtio "1.13.2" viem ">=2.23.0" -"@reown/walletkit@1.1.2-canary-wasm-9": - version "1.1.2-canary-wasm-9" - resolved "https://registry.yarnpkg.com/@reown/walletkit/-/walletkit-1.1.2-canary-wasm-9.tgz#9a09a7fd8b4122d7a6b737931205185d3ddb2be8" - integrity sha512-ftVD0pDoMS6tH8YiZ9sqkjeeSme4KWg2Md5zE1e84q9nAiNxT4nEBVeZ4vG/dREOEb7/xwgfPS17epT0/FIJzw== +"@reown/walletkit@1.1.2-canary-ca-1": + version "1.1.2-canary-ca-1" + resolved "https://registry.yarnpkg.com/@reown/walletkit/-/walletkit-1.1.2-canary-ca-1.tgz#12179dd1ad38085acbb705d208a6acd5c10ad596" + integrity sha512-hzUqikXlAt4kULYNDWNxPP0+0NWKDzGeSMUlnNFgXTniLmzb/eAnUJQ6WgWIJ2UDf86KQF40iZ0MBbu/SWs4ZA== dependencies: - "@walletconnect/core" "2.18.0-canary-tvf-1" + "@walletconnect/core" "2.17.3" "@walletconnect/jsonrpc-provider" "1.0.14" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "2.1.2" - "@walletconnect/sign-client" "2.18.0-canary-tvf-1" - "@walletconnect/types" "2.18.0-canary-tvf-1" - "@walletconnect/utils" "2.18.0-canary-tvf-1" + "@walletconnect/sign-client" "2.17.3" + "@walletconnect/types" "2.17.3" + "@walletconnect/utils" "2.17.3" brotli "^1.3.3" "@rhinestone/module-sdk@0.1.25": @@ -2363,6 +2363,11 @@ rpc-websockets "^9.0.2" superstruct "^2.0.2" +"@stablelib/aead@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@stablelib/aead/-/aead-1.0.1.tgz#c4b1106df9c23d1b867eb9b276d8f42d5fc4c0c3" + integrity sha512-q39ik6sxGHewqtO0nP4BuSe3db5G1fEJE8ukvngS2gLkBXyy6E7pLubhbYgnkDFv6V8cWaxcE4Xn0t6LWcJkyg== + "@stablelib/binary@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@stablelib/binary/-/binary-1.0.1.tgz#c5900b94368baf00f811da5bdb1610963dfddf7f" @@ -2384,12 +2389,32 @@ resolved "https://registry.yarnpkg.com/@stablelib/bytes/-/bytes-1.0.1.tgz#0f4aa7b03df3080b878c7dea927d01f42d6a20d8" integrity sha512-Kre4Y4kdwuqL8BR2E9hV/R5sOrUj6NanZaZis0V6lX5yzqC3hBuVSDXUIBqQv/sCpmuWRiHLwqiT1pqqjuBXoQ== +"@stablelib/chacha20poly1305@1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@stablelib/chacha20poly1305/-/chacha20poly1305-1.0.1.tgz#de6b18e283a9cb9b7530d8767f99cde1fec4c2ee" + integrity sha512-MmViqnqHd1ymwjOQfghRKw2R/jMIGT3wySN7cthjXCBdO+qErNPUBnRzqNpnvIwg7JBCg3LdeCZZO4de/yEhVA== + dependencies: + "@stablelib/aead" "^1.0.1" + "@stablelib/binary" "^1.0.1" + "@stablelib/chacha" "^1.0.1" + "@stablelib/constant-time" "^1.0.1" + "@stablelib/poly1305" "^1.0.1" + "@stablelib/wipe" "^1.0.1" + +"@stablelib/chacha@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@stablelib/chacha/-/chacha-1.0.1.tgz#deccfac95083e30600c3f92803a3a1a4fa761371" + integrity sha512-Pmlrswzr0pBzDofdFuVe1q7KdsHKhhU24e8gkEwnTGOmlC7PADzLVxGdn2PoNVBBabdg0l/IfLKg6sHAbTQugg== + dependencies: + "@stablelib/binary" "^1.0.1" + "@stablelib/wipe" "^1.0.1" + "@stablelib/constant-time@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@stablelib/constant-time/-/constant-time-1.0.1.tgz#bde361465e1cf7b9753061b77e376b0ca4c77e35" integrity sha512-tNOs3uD0vSJcK6z1fvef4Y+buN7DXhzHDPqRLSXUel1UfqMB1PWNsnnAezrKfEwTLpN0cGH2p9NNjs6IqeD0eg== -"@stablelib/ed25519@^1.0.3": +"@stablelib/ed25519@^1.0.2", "@stablelib/ed25519@^1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@stablelib/ed25519/-/ed25519-1.0.3.tgz#f8fdeb6f77114897c887bb6a3138d659d3f35996" integrity sha512-puIMWaX9QlRsbhxfDc5i+mNPMY+0TmQEskunY1rZEBPi1acBCVQAhnsk/1Hk50DGPtVsZtAWQg4NHGlVaO9Hqg== @@ -2403,6 +2428,15 @@ resolved "https://registry.yarnpkg.com/@stablelib/hash/-/hash-1.0.1.tgz#3c944403ff2239fad8ebb9015e33e98444058bc5" integrity sha512-eTPJc/stDkdtOcrNMZ6mcMK1e6yBbqRBaNW55XA1jU8w/7QdnCF0CmMmOD1m7VSkBR44PWrMHU2l6r8YEQHMgg== +"@stablelib/hkdf@1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@stablelib/hkdf/-/hkdf-1.0.1.tgz#b4efd47fd56fb43c6a13e8775a54b354f028d98d" + integrity sha512-SBEHYE16ZXlHuaW5RcGk533YlBj4grMeg5TooN80W3NpcHRtLZLLXvKyX0qcRFxf+BGDobJLnwkvgEwHIDBR6g== + dependencies: + "@stablelib/hash" "^1.0.1" + "@stablelib/hmac" "^1.0.1" + "@stablelib/wipe" "^1.0.1" + "@stablelib/hmac@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@stablelib/hmac/-/hmac-1.0.1.tgz#3d4c1b8cf194cb05d28155f0eed8a299620a07ec" @@ -2453,7 +2487,7 @@ "@stablelib/constant-time" "^1.0.1" "@stablelib/wipe" "^1.0.1" -"@stablelib/random@^1.0.2": +"@stablelib/random@1.0.2", "@stablelib/random@^1.0.1", "@stablelib/random@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@stablelib/random/-/random-1.0.2.tgz#2dece393636489bf7e19c51229dd7900eddf742c" integrity sha512-rIsE83Xpb7clHPVRlBj8qNe5L8ISQOzjghYQm/dZ7VaM2KHYwMW5adjQjrzTZCchFnNCNhkwtnOBa9HTMJCI8w== @@ -2470,6 +2504,15 @@ "@stablelib/constant-time" "^1.0.1" "@stablelib/wipe" "^1.0.1" +"@stablelib/sha256@1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@stablelib/sha256/-/sha256-1.0.1.tgz#77b6675b67f9b0ea081d2e31bda4866297a3ae4f" + integrity sha512-GIIH3e6KH+91FqGV42Kcj71Uefd/QEe7Dy42sBTeqppXV95ggCcxLTk39bEr+lZfJmp+ghsR07J++ORkRELsBQ== + dependencies: + "@stablelib/binary" "^1.0.1" + "@stablelib/hash" "^1.0.1" + "@stablelib/wipe" "^1.0.1" + "@stablelib/sha512@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@stablelib/sha512/-/sha512-1.0.1.tgz#6da700c901c2c0ceacbd3ae122a38ac57c72145f" @@ -2484,7 +2527,7 @@ resolved "https://registry.yarnpkg.com/@stablelib/wipe/-/wipe-1.0.1.tgz#d21401f1d59ade56a62e139462a97f104ed19a36" integrity sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg== -"@stablelib/x25519@^1.0.3": +"@stablelib/x25519@1.0.3", "@stablelib/x25519@^1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@stablelib/x25519/-/x25519-1.0.3.tgz#13c8174f774ea9f3e5e42213cbf9fc68a3c7b7fd" integrity sha512-KnTbKmUhPhHavzobclVJQG5kuivH+qDLpe84iRqX3CLrKp881cF160JvXJ+hjn1aMyCwYOKeIZefIH/P5cJoRw== @@ -2818,10 +2861,10 @@ version "0.3.1" resolved "https://codeload.github.com/ecadlabs/axios-fetch-adapter/tar.gz/167684f522e90343b9f3439d9a43ac571e2396f6" -"@walletconnect/core@2.18.0": - version "2.18.0" - resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.18.0.tgz#749b57000823eceb1c667d38531e7eae206df349" - integrity sha512-i/olu/IwYtBiWYqyfNUMxq4b6QS5dv+ZVVGmLT2buRwdH6MGETN0Bx3/z6rXJzd1sNd+QL07fxhSFxCekL57tA== +"@walletconnect/core@2.17.3": + version "2.17.3" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.17.3.tgz#e59045a666951e9fc2e8420130c4f93221bd2492" + integrity sha512-57uv0FW4L6H/tmkb1kS2nG41MDguyDgZbGR58nkDUd1TO/HydyiTByVOhFzIxgN331cnY/1G1rMaKqncgdnOFA== dependencies: "@walletconnect/heartbeat" "1.2.2" "@walletconnect/jsonrpc-provider" "1.0.14" @@ -2831,20 +2874,20 @@ "@walletconnect/keyvaluestorage" "1.1.1" "@walletconnect/logger" "2.1.2" "@walletconnect/relay-api" "1.0.11" - "@walletconnect/relay-auth" "1.1.0" + "@walletconnect/relay-auth" "1.0.4" "@walletconnect/safe-json" "1.0.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.18.0" - "@walletconnect/utils" "2.18.0" + "@walletconnect/types" "2.17.3" + "@walletconnect/utils" "2.17.3" "@walletconnect/window-getters" "1.0.1" events "3.3.0" lodash.isequal "4.5.0" uint8arrays "3.1.0" -"@walletconnect/core@2.18.0-canary-tvf-1": - version "2.18.0-canary-tvf-1" - resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.18.0-canary-tvf-1.tgz#c05e39440670e5e8d4e60f4576f9f80e6bf0d7c4" - integrity sha512-Te1W2OBNHdpBWDkEHhzCgZeX0DRWaxh3lysRkfsyVSP90OEKqhk2c/hT3IrNxHE3NR9w0XeBMdV/Ecvmj16Tlw== +"@walletconnect/core@2.18.0": + version "2.18.0" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.18.0.tgz#749b57000823eceb1c667d38531e7eae206df349" + integrity sha512-i/olu/IwYtBiWYqyfNUMxq4b6QS5dv+ZVVGmLT2buRwdH6MGETN0Bx3/z6rXJzd1sNd+QL07fxhSFxCekL57tA== dependencies: "@walletconnect/heartbeat" "1.2.2" "@walletconnect/jsonrpc-provider" "1.0.14" @@ -2857,8 +2900,8 @@ "@walletconnect/relay-auth" "1.1.0" "@walletconnect/safe-json" "1.0.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.18.0-canary-tvf-1" - "@walletconnect/utils" "2.18.0-canary-tvf-1" + "@walletconnect/types" "2.18.0" + "@walletconnect/utils" "2.18.0" "@walletconnect/window-getters" "1.0.1" events "3.3.0" lodash.isequal "4.5.0" @@ -2966,6 +3009,18 @@ dependencies: "@walletconnect/jsonrpc-types" "^1.0.2" +"@walletconnect/relay-auth@1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@walletconnect/relay-auth/-/relay-auth-1.0.4.tgz#0b5c55c9aa3b0ef61f526ce679f3ff8a5c4c2c7c" + integrity sha512-kKJcS6+WxYq5kshpPaxGHdwf5y98ZwbfuS4EE/NkQzqrDFm5Cj+dP8LofzWvjrrLkZq7Afy7WrQMXdLy8Sx7HQ== + dependencies: + "@stablelib/ed25519" "^1.0.2" + "@stablelib/random" "^1.0.1" + "@walletconnect/safe-json" "^1.0.1" + "@walletconnect/time" "^1.0.2" + tslib "1.14.1" + uint8arrays "^3.0.0" + "@walletconnect/relay-auth@1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@walletconnect/relay-auth/-/relay-auth-1.1.0.tgz#c3c5f54abd44a5138ea7d4fe77970597ba66c077" @@ -2984,34 +3039,34 @@ dependencies: tslib "1.14.1" -"@walletconnect/sign-client@2.18.0": - version "2.18.0" - resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.18.0.tgz#33480ee3e711d31c947860125ac26cf31bb9bcb5" - integrity sha512-oUjlRIsbHxMSRif2WvMRdvm6tMsQjMj07rl7YVcKVvZ1gF1/9GcbJPjzL/U87fv8qAQkVhIlbEg2vHaVYf6J/g== +"@walletconnect/sign-client@2.17.3": + version "2.17.3" + resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.17.3.tgz#86c116bc927946bffa8415ca8d92d3ef412082e1" + integrity sha512-OzOWxRTfVGCHU3OOF6ibPkgPfDpivFJjuknfcOUt9PYWpTAv6YKOmT4cyfBPhc7llruyHpV44fYbykMcLIvEcg== dependencies: - "@walletconnect/core" "2.18.0" + "@walletconnect/core" "2.17.3" "@walletconnect/events" "1.0.1" "@walletconnect/heartbeat" "1.2.2" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "2.1.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.18.0" - "@walletconnect/utils" "2.18.0" + "@walletconnect/types" "2.17.3" + "@walletconnect/utils" "2.17.3" events "3.3.0" -"@walletconnect/sign-client@2.18.0-canary-tvf-1": - version "2.18.0-canary-tvf-1" - resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.18.0-canary-tvf-1.tgz#30ea47b437deef1796872440ca1d5d852e6e3ee7" - integrity sha512-J3TlAh9zbyhnRvAQy4YegLEvIEypGCUL7mPexcJA9mZ+jzv0f7AtK6OEE1kM2pc5nS/XdSRplbYoHTmk0lNXZw== +"@walletconnect/sign-client@2.18.0": + version "2.18.0" + resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.18.0.tgz#33480ee3e711d31c947860125ac26cf31bb9bcb5" + integrity sha512-oUjlRIsbHxMSRif2WvMRdvm6tMsQjMj07rl7YVcKVvZ1gF1/9GcbJPjzL/U87fv8qAQkVhIlbEg2vHaVYf6J/g== dependencies: - "@walletconnect/core" "2.18.0-canary-tvf-1" + "@walletconnect/core" "2.18.0" "@walletconnect/events" "1.0.1" "@walletconnect/heartbeat" "1.2.2" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "2.1.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.18.0-canary-tvf-1" - "@walletconnect/utils" "2.18.0-canary-tvf-1" + "@walletconnect/types" "2.18.0" + "@walletconnect/utils" "2.18.0" events "3.3.0" "@walletconnect/time@1.0.2", "@walletconnect/time@^1.0.2": @@ -3021,10 +3076,10 @@ dependencies: tslib "1.14.1" -"@walletconnect/types@2.18.0": - version "2.18.0" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.18.0.tgz#dda74a0aeb5a4790a860a1d8eba439f19a07cb54" - integrity sha512-g0jU+6LUuw3E/EPAQfHNK2xK/95IpRfz68tdNAFckLmefZU6kzoE1mIM1SrPJq8rT9kUPp6/APMQE+ReH2OdBA== +"@walletconnect/types@2.17.3": + version "2.17.3" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.17.3.tgz#906f25cf0c9691704b9161eaa305262b0e7626d0" + integrity sha512-5eFxnbZGJJx0IQyCS99qz+OvozpLJJYfVG96dEHGgbzZMd+C9V1eitYqVClx26uX6V+WQVqVwjpD2Dyzie++Wg== dependencies: "@walletconnect/events" "1.0.1" "@walletconnect/heartbeat" "1.2.2" @@ -3033,10 +3088,10 @@ "@walletconnect/logger" "2.1.2" events "3.3.0" -"@walletconnect/types@2.18.0-canary-tvf-1": - version "2.18.0-canary-tvf-1" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.18.0-canary-tvf-1.tgz#142874526362b2f96dec67d75944b0a7930d84df" - integrity sha512-a7sg0qP3T6MtRwQLqLG/xbnReCRFfMpcaUF/PQqznmN5XDSEx2jPnwkwWIWYwFhsQSQfiMhW6HR0+h1j0w8DvQ== +"@walletconnect/types@2.18.0": + version "2.18.0" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.18.0.tgz#dda74a0aeb5a4790a860a1d8eba439f19a07cb54" + integrity sha512-g0jU+6LUuw3E/EPAQfHNK2xK/95IpRfz68tdNAFckLmefZU6kzoE1mIM1SrPJq8rT9kUPp6/APMQE+ReH2OdBA== dependencies: "@walletconnect/events" "1.0.1" "@walletconnect/heartbeat" "1.2.2" @@ -3063,22 +3118,25 @@ events "3.3.0" lodash "4.17.21" -"@walletconnect/utils@2.18.0": - version "2.18.0" - resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.18.0.tgz#1caa15eb6704dcfce03b58d96d44a58ef7b103ec" - integrity sha512-6AUXIcjSxTHGRsTtmUP/oqudtwRILrQqrJsH3jS5T28FFDzZt7+On6fR4mXzi64k4nNYeWg1wMCGLEdtxmGbZQ== +"@walletconnect/utils@2.17.3": + version "2.17.3" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.17.3.tgz#a22938567febc3e3771efae8eb351adf3d499a8d" + integrity sha512-tG77UpZNeLYgeOwViwWnifpyBatkPlpKSSayhN0gcjY1lZAUNqtYslpm4AdTxlrA3pL61MnyybXgWYT5eZjarw== dependencies: + "@ethersproject/hash" "5.7.0" "@ethersproject/transactions" "5.7.0" - "@noble/ciphers" "1.2.1" - "@noble/curves" "1.8.1" - "@noble/hashes" "1.7.1" + "@stablelib/chacha20poly1305" "1.0.1" + "@stablelib/hkdf" "1.0.1" + "@stablelib/random" "1.0.2" + "@stablelib/sha256" "1.0.1" + "@stablelib/x25519" "1.0.3" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/keyvaluestorage" "1.1.1" "@walletconnect/relay-api" "1.0.11" - "@walletconnect/relay-auth" "1.1.0" + "@walletconnect/relay-auth" "1.0.4" "@walletconnect/safe-json" "1.0.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.18.0" + "@walletconnect/types" "2.17.3" "@walletconnect/window-getters" "1.0.1" "@walletconnect/window-metadata" "1.0.1" detect-browser "5.3.0" @@ -3086,10 +3144,10 @@ query-string "7.1.3" uint8arrays "3.1.0" -"@walletconnect/utils@2.18.0-canary-tvf-1": - version "2.18.0-canary-tvf-1" - resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.18.0-canary-tvf-1.tgz#c2ce9e88b1440a34767b2699756532d4b85e4a77" - integrity sha512-CoOU5TFzd0iK4VeEAImTnmc30DeJPgCyoQLq9nOjnjlDChUVGcmi8OdCjwrEhokcCfzPMuFEbpNjewg9+mUnLw== +"@walletconnect/utils@2.18.0": + version "2.18.0" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.18.0.tgz#1caa15eb6704dcfce03b58d96d44a58ef7b103ec" + integrity sha512-6AUXIcjSxTHGRsTtmUP/oqudtwRILrQqrJsH3jS5T28FFDzZt7+On6fR4mXzi64k4nNYeWg1wMCGLEdtxmGbZQ== dependencies: "@ethersproject/transactions" "5.7.0" "@noble/ciphers" "1.2.1" @@ -3101,7 +3159,7 @@ "@walletconnect/relay-auth" "1.1.0" "@walletconnect/safe-json" "1.0.2" "@walletconnect/time" "1.0.2" - "@walletconnect/types" "2.18.0-canary-tvf-1" + "@walletconnect/types" "2.18.0" "@walletconnect/window-getters" "1.0.1" "@walletconnect/window-metadata" "1.0.1" detect-browser "5.3.0" From a19a15f84c323124cebeac7cb281b8f79d2cf0ec Mon Sep 17 00:00:00 2001 From: Gancho Radkov Date: Thu, 20 Feb 2025 12:53:14 +0200 Subject: [PATCH 7/8] refactor: use mnemonic --- .../react-wallet-v2/src/components/MultibridgeRequestModal.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx index 5268e282a..13d8b293f 100644 --- a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx @@ -87,7 +87,8 @@ export default function MultibridgeRequestModal({ onReject, rejectLoader, bridge try { console.log('Approving request', transaction) const loadedWallet = getWalletByAddress(transaction.from) - const account = mnemonicToAccount(loadedWallet.getMnemonic()) + const account = privateKeyToAccount(loadedWallet.getPrivateKey() as Hex) + // const account = mnemonicToAccount(loadedWallet.getMnemonic()) console.log('Account', account) console.log('Connected wallet', account) From ef1521205001d736d1184bcdf0bf3cd1a6ca25f3 Mon Sep 17 00:00:00 2001 From: Gancho Radkov Date: Thu, 20 Feb 2025 14:33:24 +0200 Subject: [PATCH 8/8] fix: adds usdt and removes throw --- .../src/components/MultibridgeRequestModal.tsx | 10 +++------- .../src/utils/MultibridgeUtil.ts | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx index 13d8b293f..e5c90d907 100644 --- a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx @@ -4,24 +4,20 @@ import { LoaderProps } from '@/components/ModalFooter' import RequestModal from './RequestModal' import ModalStore from '@/store/ModalStore' import { styledToast } from '@/utils/HelperUtil' -import { approveEIP155Request } from '@/utils/EIP155RequestHandlerUtil' import { convertTokenBalance, decodeErc20Transaction, getAssetByContractAddress, getErc20TokenBalance } from '@/utils/MultibridgeUtil' -import { getWallet, getWalletByAddress } from '@/utils/EIP155WalletUtil' +import { getWalletByAddress } from '@/utils/EIP155WalletUtil' import { walletkit } from '@/utils/WalletConnectUtil' import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data' -import { ChainAbstractionService } from '@/utils/ChainAbstractionService' -import { ethers, providers } from 'ethers' import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils' import { ChainAbstractionTypes } from '@reown/walletkit' -import { createWalletClient, Hex, http, recoverAddress, recoverMessageAddress } from 'viem' +import { Hex } from 'viem' import BridgeBadge from './BridgeBadge' -import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts' -import { mainnet } from 'viem/chains' +import { privateKeyToAccount } from 'viem/accounts' interface IProps { onReject: () => void diff --git a/advanced/wallets/react-wallet-v2/src/utils/MultibridgeUtil.ts b/advanced/wallets/react-wallet-v2/src/utils/MultibridgeUtil.ts index 03740cb83..422384457 100644 --- a/advanced/wallets/react-wallet-v2/src/utils/MultibridgeUtil.ts +++ b/advanced/wallets/react-wallet-v2/src/utils/MultibridgeUtil.ts @@ -1,7 +1,7 @@ import { createPublicClient, decodeFunctionData, erc20Abi, getContract, Hex, http } from 'viem' import { arbitrum, base, optimism } from 'viem/chains' import { getChainById } from './ChainUtil' -import { providers } from 'ethers' +import { ethers, providers } from 'ethers' import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data' const BASE_URL = 'https://api.socket.tech/v2' @@ -13,11 +13,17 @@ export const supportedAssets: Record> = { [base.id]: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', [optimism.id]: '0x0b2c639c533813f4aa9d7837caf62653d097ff85', [arbitrum.id]: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' + }, + USDT: { + [base.id]: '0xfde4c96c8593536e31f229ea8f37b2ada2699bb2', + [optimism.id]: '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58', + [arbitrum.id]: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9' } } as const const assetDecimals: Record = { - USDC: 6 + USDC: 6, + USDT: 6 } export const supportedChains = [base, optimism, arbitrum] as const @@ -44,13 +50,15 @@ export function getAssetByContractAddress(address: Hex): string { } } } - throw new Error('Asset not found for the given contract address') + console.error('Asset not found for the given contract address') + return '' } -export function convertTokenBalance(asset: string, amount: number): number { +export function convertTokenBalance(asset: string, amount: number): number | undefined { const decimals = assetDecimals[asset] if (!decimals) { - throw new Error('Asset not supported') + console.error('Asset not supported') + return } const balance = amount / 10 ** decimals return balance