From 2593b8a7650559e763d5dc99ae7c4768321e021c Mon Sep 17 00:00:00 2001 From: mmv Date: Tue, 12 Mar 2019 16:35:25 +0400 Subject: [PATCH] fix safe loading by awaiting .at function --- src/logic/contracts/safeContracts.js | 2 +- src/logic/safe/safeFrontendOperations.js | 3 ++- src/routes/load/components/DetailsForm/index.jsx | 4 ++-- src/routes/load/components/ReviewInformation/index.jsx | 6 +++--- src/routes/load/components/fields.js | 1 - 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/logic/contracts/safeContracts.js b/src/logic/contracts/safeContracts.js index f0362b8b..b58d905b 100644 --- a/src/logic/contracts/safeContracts.js +++ b/src/logic/contracts/safeContracts.js @@ -76,7 +76,7 @@ export const deploySafeContract = async (safeAccounts: string[], numConfirmation export const getGnosisSafeInstanceAt = async (safeAddress: string) => { const web3 = getWeb3() const GnosisSafe = await getGnosisSafeContract(web3) - const gnosisSafe = GnosisSafe.at(safeAddress) + const gnosisSafe = await GnosisSafe.at(safeAddress) return gnosisSafe } diff --git a/src/logic/safe/safeFrontendOperations.js b/src/logic/safe/safeFrontendOperations.js index 361ca457..f1a4a50c 100644 --- a/src/logic/safe/safeFrontendOperations.js +++ b/src/logic/safe/safeFrontendOperations.js @@ -26,7 +26,8 @@ const hasOneOwner = (safe: Safe) => { export const getSafeEthereumInstance = async (safeAddress: string) => { const web3 = getWeb3() const GnosisSafe = await getGnosisSafeContract(web3) - return GnosisSafe.at(safeAddress) + const safeInstance = await GnosisSafe.at(safeAddress) + return safeInstance } export const createTransaction = async ( diff --git a/src/routes/load/components/DetailsForm/index.jsx b/src/routes/load/components/DetailsForm/index.jsx index a8f849d3..f8e5a886 100644 --- a/src/routes/load/components/DetailsForm/index.jsx +++ b/src/routes/load/components/DetailsForm/index.jsx @@ -47,7 +47,7 @@ export const safeFieldsValidation = async (values: Object) => { // https://solidity.readthedocs.io/en/latest/metadata.html#usage-for-source-code-verification const metaData = 'a165' - const code = await promisify(cb => web3.eth.getCode(safeAddress, cb)) + const code = await web3.eth.getCode(safeAddress) const codeWithoutMetadata = code.substring(0, code.lastIndexOf(metaData)) const proxyCode = SafeProxy.deployedBytecode @@ -63,7 +63,7 @@ export const safeFieldsValidation = async (values: Object) => { // check mastercopy const proxy = contract(SafeProxy) proxy.setProvider(web3.currentProvider) - const proxyInstance = proxy.at(safeAddress) + const proxyInstance = await proxy.at(safeAddress) const proxyImplementation = await proxyInstance.implementation() const safeMaster = await getSafeMasterContract() diff --git a/src/routes/load/components/ReviewInformation/index.jsx b/src/routes/load/components/ReviewInformation/index.jsx index 1790e910..7a472d02 100644 --- a/src/routes/load/components/ReviewInformation/index.jsx +++ b/src/routes/load/components/ReviewInformation/index.jsx @@ -62,6 +62,8 @@ class ReviewComponent extends React.PureComponent { isOwner: false, } + mounted = false + componentDidMount = async () => { this.mounted = true @@ -70,7 +72,7 @@ class ReviewComponent extends React.PureComponent { const web3 = getWeb3() const GnosisSafe = getGnosisSafeContract(web3) - const gnosisSafe = GnosisSafe.at(safeAddress) + const gnosisSafe = await GnosisSafe.at(safeAddress) const owners = await gnosisSafe.getOwners() if (!owners) { return @@ -86,8 +88,6 @@ class ReviewComponent extends React.PureComponent { this.mounted = false } - mounted = false - render() { const { values, classes, network } = this.props const { isOwner } = this.state diff --git a/src/routes/load/components/fields.js b/src/routes/load/components/fields.js index 9e2693a5..1d615a41 100644 --- a/src/routes/load/components/fields.js +++ b/src/routes/load/components/fields.js @@ -1,4 +1,3 @@ // @flow export const FIELD_LOAD_NAME: string = 'name' export const FIELD_LOAD_ADDRESS: string = 'address' -