From 32c7949c168282fd4e1acbecc97dd1ef1ea0824d Mon Sep 17 00:00:00 2001 From: Ilja Date: Fri, 18 Feb 2022 13:55:17 +0200 Subject: [PATCH] Fix transaction sending, implement signTransaction --- wallets/react-wallet-v2/src/data/EIP155Data.ts | 7 ------- .../src/hooks/useWalletConnectEventsManager.ts | 3 +++ wallets/react-wallet-v2/src/store/SettingsStore.ts | 2 +- .../react-wallet-v2/src/utils/RequestHandlerUtil.ts | 11 ++++++++--- .../src/views/SessionSendTransactionModal.tsx | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/wallets/react-wallet-v2/src/data/EIP155Data.ts b/wallets/react-wallet-v2/src/data/EIP155Data.ts index d44c514..48f6cc6 100644 --- a/wallets/react-wallet-v2/src/data/EIP155Data.ts +++ b/wallets/react-wallet-v2/src/data/EIP155Data.ts @@ -30,13 +30,6 @@ export const EIP155_MAINNET_CHAINS = { logo: LOGO_BASE_URL + 'eip155:137.png', rgb: '130, 71, 229', rpc: 'https://polygon-rpc.com/' - }, - 'eip155:42161': { - chainId: 42161, - name: 'Arbitrum', - logo: LOGO_BASE_URL + 'eip155:42161.png', - rgb: '44, 55, 75', - rpc: 'https://arb1.arbitrum.io/rpc/' } } diff --git a/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts b/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts index afb0d35..ba36219 100644 --- a/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts +++ b/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts @@ -26,6 +26,8 @@ export default function useWalletConnectEventsManager(initialized: boolean) { const { method } = request const requestSession = await walletConnectClient.session.get(topic) + console.log({ requestEvent, requestSession }) + switch (method) { case EIP155_SIGNING_METHODS.ETH_SIGN: case EIP155_SIGNING_METHODS.PERSONAL_SIGN: @@ -37,6 +39,7 @@ export default function useWalletConnectEventsManager(initialized: boolean) { return ModalStore.open('SessionSignTypedDataModal', { requestEvent, requestSession }) case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION: + case EIP155_SIGNING_METHODS.ETH_SIGN_TRANSACTION: return ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession }) default: diff --git a/wallets/react-wallet-v2/src/store/SettingsStore.ts b/wallets/react-wallet-v2/src/store/SettingsStore.ts index 667825f..6d9d508 100644 --- a/wallets/react-wallet-v2/src/store/SettingsStore.ts +++ b/wallets/react-wallet-v2/src/store/SettingsStore.ts @@ -11,7 +11,7 @@ interface State { * State */ const state = proxy({ - testNets: typeof localStorage !== 'undefined' ? Boolean(localStorage.getItem('TEST_NETS')) : false + testNets: typeof localStorage !== 'undefined' ? Boolean(localStorage.getItem('TEST_NETS')) : true }) /** diff --git a/wallets/react-wallet-v2/src/utils/RequestHandlerUtil.ts b/wallets/react-wallet-v2/src/utils/RequestHandlerUtil.ts index e428427..e140a85 100644 --- a/wallets/react-wallet-v2/src/utils/RequestHandlerUtil.ts +++ b/wallets/react-wallet-v2/src/utils/RequestHandlerUtil.ts @@ -25,9 +25,14 @@ export async function approveEIP155Request(request: RequestEvent['request'], wal return formatJsonRpcResult(id, signedData) case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION: - const transaction = params[0] - const { hash } = await wallet.sendTransaction(transaction) - return formatJsonRpcError(id, hash) + const sendTransaction = params[0] + const { hash } = await wallet.sendTransaction(sendTransaction) + return formatJsonRpcResult(id, hash) + + case EIP155_SIGNING_METHODS.ETH_SIGN_TRANSACTION: + const signTransaction = params[0] + const signature = await wallet.signTransaction(signTransaction) + return formatJsonRpcResult(id, signature) default: throw new Error(ERROR.UNKNOWN_JSONRPC_METHOD.format().message) diff --git a/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx b/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx index 7b024a4..42e736f 100644 --- a/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx +++ b/wallets/react-wallet-v2/src/views/SessionSendTransactionModal.tsx @@ -68,7 +68,7 @@ export default function SessionSendTransactionModal() { return ( - Send Transaction + Send / Sign Transaction