Remove api imports (only on store, non-context) (#1347)

This commit is contained in:
Jaco Greeff 2019-06-25 16:20:03 +02:00 committed by kwingram25
parent f9a28fc6ea
commit a33292803a
3 changed files with 8 additions and 10 deletions

View File

@ -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<Props, State> {
}
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<Props, State> {
}
}
export default translate(Add);
export default translate(withApi(Add));

View File

@ -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<Props, State> {
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<Props, State> {
name,
contract: {
abi,
genesisHash: apiUi.genesisHash.toHex()
genesisHash: api.genesisHash.toHex()
},
tags
});
@ -274,6 +272,7 @@ class Deploy extends ContractModal<Props, State> {
history.push(this.props.basePath);
this.onClose();
return { isBusy: false } as State;
});
}

View File

@ -30,8 +30,6 @@ class Store extends EventEmitter {
}
async saveCode (codeHash: string | Hash, partial: Partial<CodeJson>) {
await api.isReady;
const hex = (typeof codeHash === 'string' ? new Hash(codeHash) : codeHash).toHex();
const existing = this.getCode(hex);