diff --git a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx index 0262dee15..f7d8e3409 100644 --- a/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/components/MultibridgeRequestModal.tsx @@ -6,7 +6,11 @@ import RequestModal from './RequestModal' import ModalStore from '@/store/ModalStore' import { styledToast } from '@/utils/HelperUtil' import { approveEIP155Request } from '@/utils/EIP155RequestHandlerUtil' -import { convertTokenBalance, decodeErc20Transaction, getAssetByContractAddress } from '@/utils/MultibridgeUtil' +import { + convertTokenBalance, + decodeErc20Transaction, + getAssetByContractAddress +} from '@/utils/MultibridgeUtil' import { getWallet } from '@/utils/EIP155WalletUtil' import { walletkit } from '@/utils/WalletConnectUtil' import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data' @@ -65,30 +69,30 @@ export default function MultibridgeRequestModal({ 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 chainProvider = new providers.JsonRpcProvider( + EIP155_CHAINS[chainId as TEIP155Chain].rpc + ) const chainConnectedWallet = await wallet.connect(chainProvider) const walletAddress = wallet.getAddress() - const hash = await chainConnectedWallet.sendTransaction({ + const txResponse = await chainConnectedWallet.sendTransaction({ from: walletAddress, to: transaction.to, value: transaction.value, data: transaction.data, - nonce:transaction.nonce, + nonce: transaction.nonce, gasPrice: transaction.gasPrice, gasLimit: transaction.gas }) - const receipt = typeof hash === 'string' ? hash : hash?.hash - console.log(`Transaction broadcasted on chain ${chainId} , ${{ receipt }}`) + const txHash = typeof txResponse === 'string' ? txResponse : txResponse?.hash + const txReceipt = await txResponse.wait() + const txStatus = txReceipt.status + console.log( + `Transaction broadcasted on chain ${chainId} , ${{ txHash }}, status: ${txStatus}` + ) } - - try { - await pollOrchestrationStatus(orchestrationId) - } catch (e) { - console.error(e) - onReject() - } - }, [ bridgingTransactions, orchestrationId, onReject, params]) + await pollOrchestrationStatus(orchestrationId) + }, [bridgingTransactions, orchestrationId, onReject, params]) async function pollOrchestrationStatus( orchestrationId: string, @@ -172,7 +176,11 @@ export default function MultibridgeRequestModal({ Transaction details - + Sending {amount} {asset} to: @@ -186,13 +194,17 @@ export default function MultibridgeRequestModal({ Chain details Target chain: - + + + {targetChain.name} Sourcing funds from: - + + + {sourceChain.name} diff --git a/advanced/wallets/react-wallet-v2/src/lib/smart-accounts/builders/UserOpBuilder.ts b/advanced/wallets/react-wallet-v2/src/lib/smart-accounts/builders/UserOpBuilder.ts index 31149746b..321342dba 100644 --- a/advanced/wallets/react-wallet-v2/src/lib/smart-accounts/builders/UserOpBuilder.ts +++ b/advanced/wallets/react-wallet-v2/src/lib/smart-accounts/builders/UserOpBuilder.ts @@ -59,7 +59,7 @@ export type SendPreparedCallsParams = { export type SendPreparedCallsReturnValue = string -export type GetCallsStatusParams = string; +export type GetCallsStatusParams = string export type GetCallsStatusReturnValue = { status: 'PENDING' | 'CONFIRMED' receipts?: { diff --git a/advanced/wallets/react-wallet-v2/src/pages/api/wallet.ts b/advanced/wallets/react-wallet-v2/src/pages/api/wallet.ts index a45cf5e76..b2e39271f 100644 --- a/advanced/wallets/react-wallet-v2/src/pages/api/wallet.ts +++ b/advanced/wallets/react-wallet-v2/src/pages/api/wallet.ts @@ -89,7 +89,8 @@ async function handleGetCallsStatus( const pimlicoChainName = PIMLICO_NETWORK_NAMES[chain.name] const apiKey = process.env.NEXT_PUBLIC_PIMLICO_KEY const localBundlerUrl = process.env.NEXT_PUBLIC_LOCAL_BUNDLER_URL - const bundlerUrl = localBundlerUrl || `https://api.pimlico.io/v1/${pimlicoChainName}/rpc?apikey=${apiKey}` + const bundlerUrl = + localBundlerUrl || `https://api.pimlico.io/v1/${pimlicoChainName}/rpc?apikey=${apiKey}` const bundlerClient = createPimlicoBundlerClient({ entryPoint: ENTRYPOINT_ADDRESS_V07, transport: http(bundlerUrl) @@ -117,13 +118,17 @@ async function handleGetCallsStatus( : undefined } return receipt - } export default async function handler( req: NextApiRequest, res: NextApiResponse< - JsonRpcResponse + JsonRpcResponse< + | PrepareCallsReturnValue[] + | SendPreparedCallsReturnValue[] + | GetCallsStatusReturnValue[] + | ErrorResponse + > > ) { if (req.method === 'OPTIONS') { @@ -138,7 +143,9 @@ export default async function handler( const jsonRpcRequest: JsonRpcRequest = req.body const { id, method, params } = jsonRpcRequest - if (!['wallet_prepareCalls', 'wallet_sendPreparedCalls', 'wallet_getCallsStatus'].includes(method)) { + if ( + !['wallet_prepareCalls', 'wallet_sendPreparedCalls', 'wallet_getCallsStatus'].includes(method) + ) { return res .status(200) .json(createErrorResponse(id, ERROR_CODES.METHOD_NOT_FOUND, `${method} method not found`)) diff --git a/advanced/wallets/react-wallet-v2/src/utils/EIP155RequestHandlerUtil.ts b/advanced/wallets/react-wallet-v2/src/utils/EIP155RequestHandlerUtil.ts index 68e552d71..a61af4a22 100644 --- a/advanced/wallets/react-wallet-v2/src/utils/EIP155RequestHandlerUtil.ts +++ b/advanced/wallets/react-wallet-v2/src/utils/EIP155RequestHandlerUtil.ts @@ -66,12 +66,15 @@ export async function approveEIP155Request(requestEvent: RequestEventArgs) { const provider = new providers.JsonRpcProvider(EIP155_CHAINS[chainId as TEIP155Chain].rpc) const sendTransaction = request.params[0] const connectedWallet = await wallet.connect(provider) - const hash = await connectedWallet.sendTransaction(sendTransaction) - const receipt = typeof hash === 'string' ? hash : hash?.hash // TODO improve interface - return formatJsonRpcResult(id, receipt) + const txResponse = await connectedWallet.sendTransaction(sendTransaction) + const txHash = typeof txResponse === 'string' ? txResponse : txResponse?.hash + const txReceipt = await txResponse.wait() + console.log( + `Transaction broadcasted on chain ${chainId} , ${{ txHash }}, status: ${txReceipt.status}` + ) + return formatJsonRpcResult(id, txHash) } catch (error: any) { console.error(error) - alert(error.message) return formatJsonRpcError(id, error.message) }