4 FeeMarketEIP1559Transaction as EIP1559Transaction,
5} from '@ethereumjs/tx';
6import { stripHexPrefix } from './utils/address';
7import { FakeSignableTx, FakeSignResult } from './txn';
8import Web3 from 'web3';
9import { EIP1559_TRANSACTION_TYPE } from './constants';
10import { ITxData } from './types/ITxData';
12type SignWalletConnectTransactionArgs = {
14 txn: Transaction | EIP1559Transaction;
15 txnSigner: (txn: ITxData) => Promise<string>;
16 txnSender: (txn: ITxData) => Promise<string>;
19const walletConnectSignTransaction = async ({
24}: SignWalletConnectTransactionArgs) => {
25 // tsc complains about missing from and gas, which are populated in subsequent lines
27 let wcFormattedTx: JsonTx & {
31 wcFormattedTx.from = from;
32 wcFormattedTx.type = `0x${EIP1559_TRANSACTION_TYPE}`;
36 signature = await txnSigner(wcFormattedTx);
39 e.message === 'METHOD_NOT_SUPPORTED' ||
40 e.message === '"eth_signTransaction" not implemented'
42 console.log('connected wc wallet does not support tx signing.');
43 return FakeSignResult(
47 walletConnectSendTransaction(txnSender)
53 const serializedTx = Buffer.from(stripHexPrefix(signature), 'hex');
54 const signedTx = EIP1559Transaction.fromSerializedTx(serializedTx);
59const walletConnectSendTransaction = (
60 txnSender: (tx: FakeSignableTx) => Promise<string>
61) => (txn: FakeSignableTx, _web3: Web3): Promise<string> => txnSender(txn);
63export { 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