From 5e37453ac6e0ce4cda68f3d9ca57e3aac185216e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Mon, 20 May 2019 18:21:56 +0200 Subject: [PATCH] Refactor get Safe instance --- src/routes/load/components/OwnerList/index.jsx | 10 +++------- src/routes/load/container/Load.jsx | 7 ++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/routes/load/components/OwnerList/index.jsx b/src/routes/load/components/OwnerList/index.jsx index 9022fa86..8cd07851 100644 --- a/src/routes/load/components/OwnerList/index.jsx +++ b/src/routes/load/components/OwnerList/index.jsx @@ -17,10 +17,9 @@ import { sm, md, lg, border, secondary, } from '~/theme/variables' import { getOwnerNameBy, getOwnerAddressBy } from '~/routes/open/components/fields' -import { getEtherScanLink, getWeb3 } from '~/logic/wallets/getWeb3' +import { getEtherScanLink } from '~/logic/wallets/getWeb3' import { FIELD_LOAD_ADDRESS, THRESHOLD } from '~/routes/load/components/fields' -import { getGnosisSafeContract } from '~/logic/contracts/safeContracts' - +import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' const openIconStyle = { height: '16px', @@ -102,12 +101,9 @@ class OwnerListComponent extends React.PureComponent { componentDidMount = async () => { this.mounted = true const { values, updateInitialProps } = this.props - const safeAddress = values[FIELD_LOAD_ADDRESS] - const web3 = getWeb3() - const GnosisSafe = getGnosisSafeContract(web3) - const gnosisSafe = await GnosisSafe.at(safeAddress) + const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) const owners = await gnosisSafe.getOwners() const threshold = await gnosisSafe.getThreshold() diff --git a/src/routes/load/container/Load.jsx b/src/routes/load/container/Load.jsx index b8fefa28..9c45952d 100644 --- a/src/routes/load/container/Load.jsx +++ b/src/routes/load/container/Load.jsx @@ -11,9 +11,8 @@ import selector, { type SelectorProps } from './selector' import actions, { type Actions } from './actions' import Layout from '../components/Layout' import { getNamesFrom, getOwnersFrom } from '~/routes/open/utils/safeDataExtractor' -import { getWeb3 } from '~/logic/wallets/getWeb3' -import { getGnosisSafeContract } from '~/logic/contracts/safeContracts' import { FIELD_LOAD_NAME, FIELD_LOAD_ADDRESS } from '../components/fields' +import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' type Props = SelectorProps & Actions @@ -41,9 +40,7 @@ class Load extends React.Component { const safeAddress = values[FIELD_LOAD_ADDRESS] const ownerNames = getNamesFrom(values) - const web3 = getWeb3() - const GnosisSafe = getGnosisSafeContract(web3) - const gnosisSafe = await GnosisSafe.at(safeAddress) + const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) const ownerAddresses = await gnosisSafe.getOwners() const owners = getOwnersFrom(ownerNames, ownerAddresses.sort())