on master help sign in
Don't use Maybes for signTransaction
1caf845Fang
src/components/old/StatelessTransaction.js+7−1
@@ -494,7 +494,13 @@ class StatelessTransaction extends React.Component {
494 prop-size={'lg wide'}
494 prop-size={'lg wide'}
495 prop-color={signerButtonColor}
495 prop-color={signerButtonColor}
496 onClick={() =>
496 onClick={() =>
497+ signTransaction({
498+ ...this.props,
499+ ...this.state,
497− signTransaction({ ...this.props, ...this.state, setStx: this.setStx })
500+ setStx: this.setStx,
501+ wallet: this.props.wallet.value,
502+ txn: txn.value,
503+ })
498 }>
504 }>
499 {'Sign Transaction'}
505 {'Sign Transaction'}
500 </Button>
506 </Button>
src/lib/txn.js+2−17
@@ -4,7 +4,6 @@ import Tx from 'ethereumjs-tx';
4import { toWei, fromWei, toHex } from 'web3-utils';
4import { toWei, fromWei, toHex } from 'web3-utils';
5import * as retry from 'async-retry';
5import * as retry from 'async-retry';
6
6
7−import { BRIDGE_ERROR } from './error';
8import { NETWORK_TYPES } from './network';
7import { NETWORK_TYPES } from './network';
9import { ledgerSignTransaction } from './ledger';
8import { ledgerSignTransaction } from './ledger';
10import { trezorSignTransaction } from './trezor';
9import { trezorSignTransaction } from './trezor';
@@ -114,21 +113,7 @@ const signTransaction = async config => {
114 ? Object.assign(txParams, eip155Params)
113 ? Object.assign(txParams, eip155Params)
115 : txParams;
114 : txParams;
116
115
117− const wal = wallet.matchWith({
118− Just: w => w.value,
119− Nothing: () => {
120− throw BRIDGE_ERROR.MISSING_WALLET;
121− },
122− });
123−
124− const sec = wal.privateKey;
125−
126− const utx = txn.matchWith({
127− Just: tx => Object.assign(tx.value, signingParams),
116+ const utx = Object.assign(txn, signingParams);
128− Nothing: () => {
129− throw BRIDGE_ERROR.MISSING_TXN;
130− },
131− });
132
117
133 const stx = new Tx(utx);
118 const stx = new Tx(utx);
134
119
@@ -137,7 +122,7 @@ const signTransaction = async config => {
137 } else if (walletType === WALLET_TYPES.TREZOR) {
122 } else if (walletType === WALLET_TYPES.TREZOR) {
138 await trezorSignTransaction(stx, walletHdPath);
123 await trezorSignTransaction(stx, walletHdPath);
139 } else {
124 } else {
140− stx.sign(sec);
125+ stx.sign(wallet.privateKey);
141 }
126 }
142
127
143 setStx(Just(stx));
128 setStx(Just(stx));
src/views/Invite/InviteEmail.js+2−3
@@ -1,6 +1,5 @@
1import React, { useCallback, useEffect, useMemo, useState } from 'react';
1import React, { useCallback, useEffect, useMemo, useState } from 'react';
2import cn from 'classnames';
2import cn from 'classnames';
3−import { Just } from 'folktale/maybe';
4import * as azimuth from 'azimuth-js';
3import * as azimuth from 'azimuth-js';
5import {
4import {
6 Grid,
5 Grid,
@@ -247,12 +246,12 @@ export default function InviteEmail() {
247 owner.keys.address
246 owner.keys.address
248 );
247 );
249 const signedTx = await signTransaction({
248 const signedTx = await signTransaction({
250− wallet,
249+ wallet: _wallet,
251 walletType,
250 walletType,
252 walletHdPath,
251 walletHdPath,
253 networkType,
252 networkType,
254 // TODO: ^ make a useTransactionSigner to encapsulate this logic
253 // TODO: ^ make a useTransactionSigner to encapsulate this logic
255− txn: Just(inviteTx),
254+ txn: inviteTx,
256 gasPrice: GAS_PRICE_GWEI.toString(),
255 gasPrice: GAS_PRICE_GWEI.toString(),
257 gasLimit: GAS_LIMIT.toString(),
256 gasLimit: GAS_LIMIT.toString(),
258 nonce: nonce + i,
257 nonce: nonce + i,