diff --git a/packages/app-contracts/src/Contracts/Add.tsx b/packages/app-contracts/src/Contracts/Add.tsx index e19ac224f4..2ae6f8d84a 100644 --- a/packages/app-contracts/src/Contracts/Add.tsx +++ b/packages/app-contracts/src/Contracts/Add.tsx @@ -2,11 +2,12 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { ApiProps } from '@polkadot/ui-api/types'; import { I18nProps } from '@polkadot/ui-app/types'; import { ActionStatus } from '@polkadot/ui-app/Status/types'; import React from 'react'; -import { api } from '@polkadot/ui-api'; +import { withApi } from '@polkadot/ui-api'; import { AddressRow, Button, Input } from '@polkadot/ui-app'; import keyring from '@polkadot/ui-keyring'; @@ -15,7 +16,7 @@ import ValidateAddr from './ValidateAddr'; import translate from '../translate'; -type Props = ContractModalProps & I18nProps; +type Props = ContractModalProps & ApiProps & I18nProps; type State = ContractModalState & { address?: string | null, @@ -96,7 +97,7 @@ class Add extends ContractModal { } private onAdd = async () => { - await api.isReady; + const { api } = this.props; const status = { action: 'create' } as ActionStatus; const { address, abi, name, tags } = this.state; @@ -129,4 +130,4 @@ class Add extends ContractModal { } } -export default translate(Add); +export default translate(withApi(Add)); diff --git a/packages/app-contracts/src/Deploy.tsx b/packages/app-contracts/src/Deploy.tsx index e64c2b3b7a..1621576686 100644 --- a/packages/app-contracts/src/Deploy.tsx +++ b/packages/app-contracts/src/Deploy.tsx @@ -11,7 +11,7 @@ import React from 'react'; import { RouteComponentProps } from 'react-router'; import { withRouter } from 'react-router-dom'; import { Abi } from '@polkadot/api-contract'; -import { api as apiUi, withApi, withMulti } from '@polkadot/ui-api'; +import { withApi, withMulti } from '@polkadot/ui-api'; import keyring from '@polkadot/ui-keyring'; import { Button, Dropdown, InputBalance, TxButton } from '@polkadot/ui-app'; import { AccountId, getTypeDef } from '@polkadot/types'; @@ -255,8 +255,6 @@ class Deploy extends ContractModal { if (record) { const address = record.event.data[1] as any as AccountId; - await apiUi.isReady; - this.setState(({ abi, name, tags }) => { if (!abi || !name) { return; @@ -266,7 +264,7 @@ class Deploy extends ContractModal { name, contract: { abi, - genesisHash: apiUi.genesisHash.toHex() + genesisHash: api.genesisHash.toHex() }, tags }); @@ -274,6 +272,7 @@ class Deploy extends ContractModal { history.push(this.props.basePath); this.onClose(); + return { isBusy: false } as State; }); } diff --git a/packages/app-contracts/src/store.ts b/packages/app-contracts/src/store.ts index 47889f170d..60eec950bd 100644 --- a/packages/app-contracts/src/store.ts +++ b/packages/app-contracts/src/store.ts @@ -30,8 +30,6 @@ class Store extends EventEmitter { } async saveCode (codeHash: string | Hash, partial: Partial) { - await api.isReady; - const hex = (typeof codeHash === 'string' ? new Hash(codeHash) : codeHash).toHex(); const existing = this.getCode(hex);