1import { ITxData } from '@walletconnect/types';
2import { JsonTx, Transaction, FeeMarketEIP1559Transaction as EIP1559Transaction } from '@ethereumjs/tx';
3import { stripHexPrefix } from './utils/address';
4import { FakeSignableTx, FakeSignResult } from './txn';
5import Web3 from 'web3';
6import { EIP1559_TRANSACTION_TYPE } from './constants';
8type SignWalletConnectTransactionArgs = {
10 txn: Transaction | EIP1559Transaction;
11 txnSigner: (txn: ITxData) => Promise<string>;
12 txnSender: (txn: ITxData) => Promise<string>;
15const walletConnectSignTransaction = async ({
20}: SignWalletConnectTransactionArgs) => {
21 // tsc complains about missing from and gas, which are populated in subsequent lines
23 let wcFormattedTx: JsonTx & {
27 wcFormattedTx.from = from;
28 wcFormattedTx.type = `0x${EIP1559_TRANSACTION_TYPE}`;
32 signature = await txnSigner(wcFormattedTx);
34 if (e.message === 'METHOD_NOT_SUPPORTED' || e.message === '"eth_signTransaction" not implemented') {
35 console.log('connected wc wallet does not support tx signing.');
36 return FakeSignResult(
39 walletConnectSendTransaction(txnSender)
45 const serializedTx = Buffer.from(stripHexPrefix(signature), 'hex');
46 const signedTx = EIP1559Transaction.fromSerializedTx(serializedTx);
51const walletConnectSendTransaction = (
52 txnSender: (tx: FakeSignableTx) => Promise<string>
53) => (txn: FakeSignableTx, _web3: Web3): Promise<string> => txnSender(txn);
55export { walletConnectSignTransaction };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list