From e86a8bad47b1ead6df2e886d7e5cd52ae4bee79f Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 21 Jun 2018 18:11:50 +0200 Subject: [PATCH] Fix bug this.api undefined (#66) --- .../light-react/src/stores/createAccountStore.js | 16 +++++++--------- packages/light-react/src/stores/sendStore.js | 14 +++++++------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/light-react/src/stores/createAccountStore.js b/packages/light-react/src/stores/createAccountStore.js index 1ea1fd96..f92f09e7 100644 --- a/packages/light-react/src/stores/createAccountStore.js +++ b/packages/light-react/src/stores/createAccountStore.js @@ -14,10 +14,6 @@ class CreateAccountStore { @observable password = ''; @observable phrase = null; // The 12-word seed phrase - constructor () { - this.api = parityStore.api; - } - /** * Reinitialize everything */ @@ -28,15 +24,17 @@ class CreateAccountStore { } generateNewAccount = () => { - return this.api.parity.generateSecretPhrase().then(this.setPhrase); + return parityStore.api.parity.generateSecretPhrase().then(this.setPhrase); }; saveAccountToParity = () => { - return this.api.parity + return parityStore.api.parity .newAccountFromPhrase(this.phrase, this.password) - .then(() => this.api.parity.setAccountName(this.address, this.name)) .then(() => - this.api.parity.setAccountMeta(this.address, { + parityStore.api.parity.setAccountName(this.address, this.name) + ) + .then(() => + parityStore.api.parity.setAccountMeta(this.address, { timestamp: Date.now() }) ); @@ -69,7 +67,7 @@ class CreateAccountStore { @action setPhrase = phrase => { this.phrase = phrase; - return this.api.parity + return parityStore.api.parity .phraseToAddress(phrase) .then(address => this.setAddress(address)); }; diff --git a/packages/light-react/src/stores/sendStore.js b/packages/light-react/src/stores/sendStore.js index da4d4527..187f893a 100644 --- a/packages/light-react/src/stores/sendStore.js +++ b/packages/light-react/src/stores/sendStore.js @@ -24,10 +24,6 @@ class SendStore { tx = {}; // The actual tx we are sending. No need to be observable. @observable txStatus; // Status of the tx, see wiki for details. - constructor () { - this.api = parityStore.api; - } - acceptRequest = password => { // Avoid calling this method from a random place if (!this.requestId) { @@ -40,7 +36,11 @@ class SendStore { // to calculate the number of confirmations this.subscription = blockNumber$().subscribe(this.setBlockNumber); - return this.api.signer.confirmRequest(this.requestId, null, password); + return parityStore.api.signer.confirmRequest( + this.requestId, + null, + password + ); }; /** @@ -103,7 +103,7 @@ class SendStore { * memoize it. */ estimateGasForEth = memoize(txForEth => { - return this.api.eth + return parityStore.api.eth .estimateGas(txForEth) .then(this.setEstimated) .catch(noop); @@ -136,7 +136,7 @@ class SendStore { new Error('The requestId has not been generated yet.') ); } - return this.api.signer.rejectRequest(this.requestId); + return parityStore.api.signer.rejectRequest(this.requestId); }; @computed -- GitLab