feat: adds sig verification for eth_signTransaction

This commit is contained in:
Ben Kremer
2022-03-21 13:20:53 +01:00
parent 5097f42b7f
commit 80e97e5163
9 changed files with 102 additions and 18 deletions
+7 -5
View File
@@ -1,6 +1,9 @@
import React, { useState } from "react";
import { version } from "@walletconnect/client/package.json";
import * as encoding from "@walletconnect/encoding";
import { BigNumber, utils } from "ethers";
import { TypedDataField } from "@ethersproject/abstract-signer";
import { Transaction } from "@ethereumjs/tx";
import Banner from "./components/Banner";
import Blockchain from "./components/Blockchain";
@@ -28,8 +31,6 @@ import {
SToggleContainer,
} from "./components/app";
import { useWalletConnectClient } from "./contexts/ClientContext";
import { BigNumber, utils } from "ethers";
import { TypedDataField } from "@ethersproject/abstract-signer";
interface IFormattedRpcResponse {
method: string;
@@ -130,13 +131,14 @@ export default function App() {
const [address] = await web3Provider.listAccounts();
const tx = await formatTestTransaction("eip155:" + chainId + ":" + address);
const signedTx = await web3Provider.send("eth_signTransaction", [tx]);
const valid = Transaction.fromSerializedTx(signedTx as any).verifySignature();
const signature = await web3Provider.send("eth_signTransaction", [tx]);
return {
method: "eth_signTransaction",
address,
valid: true,
result: signature,
valid,
result: signedTx,
};
};