on c19b2a8 help sign in
bridge/src/lib/metamask.js
27 lines 729 B history raw
1export function MetamaskWallet(address) {
2 this.address = address;
3}
5export function FakeMetamaskTransaction(txnData) {
6 this.txnData = txnData;
8 this.serialize = function() {
9 return '0';
10 };
13// Cheat a bit and pretend to sign transaction
14// Sign it actually when sending
15export const metamaskSignTransaction = async (txn, from) => {
16 const metamaskFormattedTxn = {
17 to: txn.to.toString('hex'),
18 value: txn.value.toString('hex'),
19 data: txn.data.toString('hex'),
20 gasLimit: txn.gasLimit.toString('hex'),
21 gasPrice: txn.gasPrice.toString('hex'),
22 nonce: txn.nonce.length === 0 ? '00' : txn.nonce.toString('hex'),
23 from: from,
24 };
26 return new FakeMetamaskTransaction(metamaskFormattedTxn);
27};