Fix transaction sending, implement signTransaction

This commit is contained in:
Ilja 2022-02-18 13:55:17 +02:00
parent 287664ac87
commit 32c7949c16
5 changed files with 13 additions and 12 deletions

View File

@ -30,13 +30,6 @@ export const EIP155_MAINNET_CHAINS = {
logo: LOGO_BASE_URL + 'eip155:137.png', logo: LOGO_BASE_URL + 'eip155:137.png',
rgb: '130, 71, 229', rgb: '130, 71, 229',
rpc: 'https://polygon-rpc.com/' 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/'
} }
} }

View File

@ -26,6 +26,8 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
const { method } = request const { method } = request
const requestSession = await walletConnectClient.session.get(topic) const requestSession = await walletConnectClient.session.get(topic)
console.log({ requestEvent, requestSession })
switch (method) { switch (method) {
case EIP155_SIGNING_METHODS.ETH_SIGN: case EIP155_SIGNING_METHODS.ETH_SIGN:
case EIP155_SIGNING_METHODS.PERSONAL_SIGN: case EIP155_SIGNING_METHODS.PERSONAL_SIGN:
@ -37,6 +39,7 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
return ModalStore.open('SessionSignTypedDataModal', { requestEvent, requestSession }) return ModalStore.open('SessionSignTypedDataModal', { requestEvent, requestSession })
case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION: case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION:
case EIP155_SIGNING_METHODS.ETH_SIGN_TRANSACTION:
return ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession }) return ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession })
default: default:

View File

@ -11,7 +11,7 @@ interface State {
* State * State
*/ */
const state = proxy<State>({ const state = proxy<State>({
testNets: typeof localStorage !== 'undefined' ? Boolean(localStorage.getItem('TEST_NETS')) : false testNets: typeof localStorage !== 'undefined' ? Boolean(localStorage.getItem('TEST_NETS')) : true
}) })
/** /**

View File

@ -25,9 +25,14 @@ export async function approveEIP155Request(request: RequestEvent['request'], wal
return formatJsonRpcResult(id, signedData) return formatJsonRpcResult(id, signedData)
case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION: case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION:
const transaction = params[0] const sendTransaction = params[0]
const { hash } = await wallet.sendTransaction(transaction) const { hash } = await wallet.sendTransaction(sendTransaction)
return formatJsonRpcError(id, hash) 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: default:
throw new Error(ERROR.UNKNOWN_JSONRPC_METHOD.format().message) throw new Error(ERROR.UNKNOWN_JSONRPC_METHOD.format().message)

View File

@ -68,7 +68,7 @@ export default function SessionSendTransactionModal() {
return ( return (
<Fragment> <Fragment>
<Modal.Header> <Modal.Header>
<Text h3>Send Transaction</Text> <Text h3>Send / Sign Transaction</Text>
</Modal.Header> </Modal.Header>
<Modal.Body> <Modal.Body>