1import Web3 from 'web3';
2import { toHex } from 'web3-utils';
3import { FakeSignableTx, FakeSignResult } from './txn';
5export function MetamaskWallet(address) {
6 this.address = address;
9// Cheat a bit and pretend to sign transaction
10// Sign it actually when sending
11export const metamaskSignTransaction = async (
16 return FakeSignResult(txn, metamaskSendTransaction);
19const metamaskSendTransaction = async (txn: FakeSignableTx, web3: Web3) => {
20 const metamaskFormattedTxn = {
22 gasLimit: txn.gasLimit,
23 gasPrice: txn.gasPrice,
26 from: toHex(txn.from),
30 if (window.ethereum) {
31 //NOTE see also #596, #630, #646
32 // no idea what's going on, we should figure it out,
33 // but we apply this bandaid to hopefully stop the bleeding.
34 // at least it also helps with the NOTE of the other branch.
35 txHash = await window.ethereum.request({
36 method: 'eth_sendTransaction',
37 params: [metamaskFormattedTxn],
41 //NOTE since this gives us a receipt instead of just the hash of the
42 // signed tx, it makes us wait for confirmation outside of our own
43 // waitForTransactionConfirm. because of this the progress bar loses
44 // its progressiveness for metamask users.
45 let receipt = await await web3.eth.sendTransaction(metamaskFormattedTxn);
46 txHash = receipt.transactionHash;
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