1import { ITxData } from '@walletconnect/types';
2import { JsonTx, Transaction } from '@ethereumjs/tx';
3import { stripHexPrefix } from './utils/address';
4import { FakeSignableTx, FakeSignResult } from './txn';
5import Web3 from 'web3';
7type SignWalletConnectTransactionArgs = {
10 txnSigner: (txn: ITxData) => Promise<string>;
11 txnSender: (txn: ITxData) => Promise<string>;
14const walletConnectSignTransaction = async ({
19}: SignWalletConnectTransactionArgs) => {
20 // tsc complains about missing from and gas, which are populated in subsequent lines
22 let wcFormattedTx: JsonTx & {
26 wcFormattedTx.from = from;
27 wcFormattedTx.gas = txn.gasLimit.toString();
31 signature = await txnSigner(wcFormattedTx);
33 if (e.message === 'METHOD_NOT_SUPPORTED') {
34 console.log('connected wc wallet does not support tx signing.');
35 return FakeSignResult(
38 walletConnectSendTransaction(txnSender)
44 const serializedTx = Buffer.from(stripHexPrefix(signature), 'hex');
45 const signedTx = Transaction.fromSerializedTx(serializedTx);
50const walletConnectSendTransaction = (
51 txnSender: (tx: FakeSignableTx) => Promise<string>
52) => (txn: FakeSignableTx, _web3: Web3): Promise<string> => txnSender(txn);
54export { 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