Fix upload and deploy contract(s) after rename (#1346)

* Fix upload and deploy contract(s) after rename

* Fix api import name collision
This commit is contained in:
Andrew Jones 2019-06-25 11:52:09 +01:00 committed by Stefanie Doll
parent 3319633153
commit f9c779574d
2 changed files with 9 additions and 6 deletions

View File

@ -96,9 +96,11 @@ class Upload extends ContractModal<Props, State> {
}
private onSuccess = (result: SubmittableResult): void => {
const { api } = this.props;
this.setState(({ abi, name, tags }) => {
const record = result.findRecord('contract', 'CodeStored');
const section = api.tx.contracts ? 'contracts' : 'contract';
const record = result.findRecord(section, 'CodeStored');
if (record) {
const codeHash = record.event.data[0];

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, withApi, withMulti } from '@polkadot/ui-api';
import { api as apiUi, 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';
@ -248,14 +248,15 @@ class Deploy extends ContractModal<Props, State> {
}
private onSuccess = async (result: SubmittableResult) => {
const { history } = this.props;
const { api, history } = this.props;
const record = result.findRecord('contract', 'Instantiated');
const section = api.tx.contracts ? 'contracts' : 'contract';
const record = result.findRecord(section, 'Instantiated');
if (record) {
const address = record.event.data[1] as any as AccountId;
await api.isReady;
await apiUi.isReady;
this.setState(({ abi, name, tags }) => {
if (!abi || !name) {
@ -266,7 +267,7 @@ class Deploy extends ContractModal<Props, State> {
name,
contract: {
abi,
genesisHash: api.genesisHash.toHex()
genesisHash: apiUi.genesisHash.toHex()
},
tags
});