From 44cd8a4fbebc5cdf46aabca34dce404eab1e2a17 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Wed, 16 Mar 2022 13:12:00 -0400 Subject: [PATCH] feat(price): Get price from minimal-slp-wallet and not bch-js --- src/components/admin-lte/configure/servers.js | 15 +++----------- src/components/admin-lte/send-receive/send.js | 20 ++----------------- src/components/admin-lte/wallet/create.js | 11 +--------- src/components/admin-lte/wallet/import.js | 10 +--------- 4 files changed, 7 insertions(+), 49 deletions(-) diff --git a/src/components/admin-lte/configure/servers.js b/src/components/admin-lte/configure/servers.js index 80af45b..ed04074 100644 --- a/src/components/admin-lte/configure/servers.js +++ b/src/components/admin-lte/configure/servers.js @@ -64,7 +64,7 @@ class Servers extends React.Component { type='primary' onClick={_this.handleNewServerUrl} /> - } + } /> ) : ( @@ -80,7 +80,7 @@ class Servers extends React.Component { icon='fa-plus' onClick={_this.handleTextField} /> - } + } /> )} @@ -303,16 +303,7 @@ class Servers extends React.Component { await bchWalletLib.walletInfoPromise const myBalance = await bchWalletLib.getBalance() - const bchjs = bchWalletLib.bchjs - - let currentRate - - if (bchjs.restURL.includes('abc.fullstack')) { - currentRate = (await bchjs.Price.getBchaUsd()) * 100 - } else { - // BCHN price. - currentRate = (await bchjs.Price.getUsd()) * 100 - } + const currentRate = (await bchWalletLib.getUsd()) * 100 _this.setState({ currentRate: currentRate diff --git a/src/components/admin-lte/send-receive/send.js b/src/components/admin-lte/send-receive/send.js index db50b9f..a8af769 100644 --- a/src/components/admin-lte/send-receive/send.js +++ b/src/components/admin-lte/send-receive/send.js @@ -284,16 +284,8 @@ class Send extends React.Component { // update balance setTimeout(async () => { const myBalance = await bchWalletLib.getBalance() - const bchjs = bchWalletLib.bchjs - let currentRate - - if (bchjs.restURL.includes('abc.fullstack')) { - currentRate = (await bchjs.Price.getBchaUsd()) * 100 - } else { - // BCHN price. - currentRate = (await bchjs.Price.getUsd()) * 100 - } + const currentRate = (await bchWalletLib.getUsd()) * 100 _this.props.updateBalance({ myBalance, currentRate }) }, 1000) @@ -365,16 +357,8 @@ class Send extends React.Component { // update balance setTimeout(async () => { const myBalance = await bchWalletLib.getBalance() - const bchjs = bchWalletLib.bchjs - let currentRate - - if (bchjs.restURL.includes('abc.fullstack')) { - currentRate = (await bchjs.Price.getBchaUsd()) * 100 - } else { - // BCHN price. - currentRate = (await bchjs.Price.getUsd()) * 100 - } + const currentRate = (await bchWalletLib.getUsd()) * 100 _this.props.updateBalance({ myBalance, currentRate }) }, 1000) diff --git a/src/components/admin-lte/wallet/create.js b/src/components/admin-lte/wallet/create.js index 56f695c..c3e63fc 100644 --- a/src/components/admin-lte/wallet/create.js +++ b/src/components/admin-lte/wallet/create.js @@ -97,16 +97,7 @@ class NewWallet extends React.Component { const myBalance = await bchWalletLib.getBalance() - const bchjs = bchWalletLib.bchjs - - let currentRate - - if (bchjs.restURL.includes('abc.fullstack')) { - currentRate = (await bchjs.Price.getBchaUsd()) * 100 - } else { - // BCHN price. - currentRate = (await bchjs.Price.getUsd()) * 100 - } + const currentRate = (await bchWalletLib.getUsd()) * 100 // console.log("myBalance", myBalance) // Update redux state diff --git a/src/components/admin-lte/wallet/import.js b/src/components/admin-lte/wallet/import.js index b0666fa..3815401 100644 --- a/src/components/admin-lte/wallet/import.js +++ b/src/components/admin-lte/wallet/import.js @@ -135,15 +135,7 @@ class ImportWallet extends React.Component { Object.assign(currentWallet, walletInfo) const myBalance = await bchWalletLib.getBalance() - const bchjs = bchWalletLib.bchjs - let currentRate - - if (bchjs.restURL.includes('abc.fullstack')) { - currentRate = (await bchjs.Price.getBchaUsd()) * 100 - } else { - // BCHN price. - currentRate = (await bchjs.Price.getUsd()) * 100 - } + const currentRate = (await bchWalletLib.getUsd()) * 100 _this.setState({ currentRate: currentRate