1import { ITxData } from '@walletconnect/types';
2import { 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: FakeSignableTx) => Promise<string>;
14const walletConnectSignTransaction = async ({
19}: SignWalletConnectTransactionArgs) => {
20 // TS compiler complains next line about missing from and gas, which we set on the following lines
21 let wcFormattedTx: FakeSignableTx = txn.toJSON();
22 wcFormattedTx.from = from;
23 wcFormattedTx.gas = wcFormattedTx.gasLimit;
27 signature = await txnSigner(wcFormattedTx);
29 if (e.message === 'METHOD_NOT_SUPPORTED') {
30 console.log('connected wc wallet does not support tx signing.');
31 return FakeSignResult(
33 walletConnectSendTransaction(txnSender)
39 const serializedTx = Buffer.from(stripHexPrefix(signature), 'hex');
40 const signedTx = Transaction.fromSerializedTx(serializedTx);
45const walletConnectSendTransaction = (
46 txnSender: (tx: FakeSignableTx) => Promise<string>
47) => (txn: FakeSignableTx, _web3: Web3): Promise<string> => txnSender(txn);
49export { 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