Enter your password to confirm this transaction.
@@ -99,7 +99,7 @@ class Signer extends Component {
diff --git a/packages/fether-react/src/stores/parityStore.js b/packages/fether-react/src/stores/parityStore.js
index 365267ab5badce8b56fc56f8c707b9d3684151cd..0c026a06d1330a4150c6c8438daa58f91fe6fdc6 100644
--- a/packages/fether-react/src/stores/parityStore.js
+++ b/packages/fether-react/src/stores/parityStore.js
@@ -27,6 +27,7 @@ export class ParityStore {
// Retrieve token from localStorage
const token = store.get(LS_KEY);
if (token) {
+ debug('Got token from localStorage.');
this.setToken(token);
}
@@ -99,6 +100,7 @@ export class ParityStore {
}
// If `parity signer new-token` has successfully given us a token back,
// then we submit it
+ debug('Successfully received new token.');
this.setToken(token);
});
};
@@ -137,7 +139,6 @@ export class ParityStore {
return;
}
- debug(`Setting token in localStorage.`);
this.token = token;
// If we receive a new token, then we try to connect to the Api with this
diff --git a/packages/fether-react/src/stores/sendStore.js b/packages/fether-react/src/stores/sendStore.js
index 8103f6750839a1752388df2e3e9f3b9395aef70c..f20c83ef109bd40ea31feffc9572787ce68fd8f6 100644
--- a/packages/fether-react/src/stores/sendStore.js
+++ b/packages/fether-react/src/stores/sendStore.js
@@ -7,12 +7,9 @@ import abi from '@parity/shared/lib/contracts/abi/eip20';
import { action, computed, observable } from 'mobx';
import { BigNumber } from 'bignumber.js';
import { blockNumber$, makeContract$, post$ } from '@parity/light.js';
-import memoize from 'lodash/memoize';
-import noop from 'lodash/noop';
import Debug from '../utils/debug';
import parityStore from './parityStore';
-import tokensStore from './tokensStore';
import { txForErc20, txForEth } from '../utils/estimateGas';
const debug = Debug('sendStore');
@@ -22,7 +19,6 @@ const DEFAULT_GAS = new BigNumber(21000 * GAS_MULT_FACTOR); // Default gas amoun
export class SendStore {
@observable blockNumber; // Current block number, used to calculate tx confirmations.
@observable estimated = DEFAULT_GAS; // Estimated gas amount for this transaction.
- @observable tokenAddress; // 'ETH', or the token contract address
tx = {}; // The actual tx we are sending. No need to be observable.
@observable txStatus; // Status of the tx, see wiki for details.
@@ -66,64 +62,21 @@ export class SendStore {
return makeContract$(this.tokenAddress, abi);
}
- /**
- * Estimate the amount of gas for our transaction.
- */
- estimateGas = () => {
- if (!this.tx || !Object.keys(this.tx).length) {
- return Promise.reject(new Error('Tx not set in sendStore.'));
- }
-
- if (this.tokenAddress === 'ETH') {
- return this.estimateGasForEth(txForEth(this.tx));
- } else {
- return this.estimateGasForErc20(
- txForErc20(this.tx, tokensStore.tokens[this.tokenAddress])
- );
- }
- };
-
- /**
- * Estimate gas to transfer in ERC20 contract. Expensive function, so we
- * memoize it.
- */
- estimateGasForErc20 = memoize(
- txForErc20 =>
- this.contract.contractObject.instance.transfer
- .estimateGas(txForErc20.options, txForErc20.args)
- .then(this.setEstimated)
- .catch(noop),
- JSON.stringify
- );
-
- /**
- * Estimate gas to transfer to an ETH address. Expensive function, so we
- * memoize it.
- */
- estimateGasForEth = memoize(
- txForEth =>
- parityStore.api.eth
- .estimateGas(txForEth)
- .then(this.setEstimated)
- .catch(noop),
- JSON.stringify
- );
-
/**
* Create a transaction.
*/
- send = password => {
+ send = (token, password) => {
const send$ =
- this.tokenAddress === 'ETH'
+ token.address === 'ETH'
? post$(txForEth(this.tx))
: this.contract.transfer$(
- ...txForErc20(this.tx).args,
- txForErc20(this.tx).options
+ ...txForErc20(this.tx, token).args,
+ txForErc20(this.tx, token).options
);
debug(
'Sending tx.',
- this.tokenAddress === 'ETH' ? this.txForEth : this.txForErc20
+ token.address === 'ETH' ? this.txForEth : this.txForErc20
);
return new Promise((resolve, reject) => {
@@ -151,11 +104,6 @@ export class SendStore {
debug('Estimated gas,', +estimated, ', with buffer,', +this.estimated);
};
- @action
- setTokenAddress = tokenAddress => {
- this.tokenAddress = tokenAddress;
- };
-
@action
setTx = tx => {
this.tx = tx;
diff --git a/packages/fether-ui/src/Form/Field/Field.js b/packages/fether-ui/src/Form/Field/Field.js
index 907801668fbceb05370bd9d50e481e25a18f9f02..b16817143ae3869523f324dee0c96c81aa8b545c 100644
--- a/packages/fether-ui/src/Form/Field/Field.js
+++ b/packages/fether-ui/src/Form/Field/Field.js
@@ -18,10 +18,10 @@ export const Field = ({