Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^0.100.0-beta.7",
"@polkadot/api-contract": "^0.100.0-beta.7",
"@polkadot/api": "^0.100.0-beta.9",
"@polkadot/api-contract": "^0.100.0-beta.9",
"@polkadot/keyring": "^1.7.1",
"@polkadot/types": "^0.100.0-beta.7",
"@polkadot/types": "^0.100.0-beta.9",
"@polkadot/util": "^1.7.1",
"@polkadot/util-crypto": "^1.7.1",
"babel-core": "^7.0.0-bridge.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.7.5",
"@polkadot/api-contract": "^0.100.0-beta.7",
"@polkadot/api-contract": "^0.100.0-beta.9",
"@polkadot/react-components": "^0.39.0-beta.14"
}
}
27 changes: 15 additions & 12 deletions packages/app-contracts/src/Contracts/Call.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { ContractCallOutcome } from '@polkadot/api-contract/types';
import { ApiProps } from '@polkadot/react-api/types';
import { BareProps, I18nProps, StringOrNull } from '@polkadot/react-components/types';
import { ContractExecResult } from '@polkadot/types/interfaces/contracts';

Expand All @@ -12,7 +11,8 @@ import React, { useState, useEffect } from 'react';
import styled from 'styled-components';
import { Button, Dropdown, IconLink, InputAddress, InputBalance, InputNumber, Modal, Toggle, TxButton } from '@polkadot/react-components';
import { PromiseContract as ApiContract } from '@polkadot/api-contract';
import { withApi, withMulti } from '@polkadot/react-api/hoc';
import { withMulti } from '@polkadot/react-api/hoc';
import { useApi } from '@polkadot/react-hooks';
import { createValue } from '@polkadot/react-params/values';
import { isNull } from '@polkadot/util';

Expand All @@ -23,7 +23,7 @@ import translate from '../translate';
import { GAS_LIMIT } from '../constants';
import { getCallMessageOptions } from './util';

interface Props extends BareProps, I18nProps, ApiProps {
interface Props extends BareProps, I18nProps {
callContract: ApiContract | null;
callMessageIndex: number | null;
callResults: ContractExecResult[];
Expand All @@ -34,31 +34,35 @@ interface Props extends BareProps, I18nProps, ApiProps {
}

function Call (props: Props): React.ReactElement<Props> | null {
const { className, isOpen, callContract, callMessageIndex, onChangeCallContractAddress, onChangeCallMessageIndex, onClose, api, t } = props;
const { className, isOpen, callContract, callMessageIndex, onChangeCallContractAddress, onChangeCallMessageIndex, onClose, t } = props;

if (isNull(callContract) || isNull(callMessageIndex)) {
return null;
}

const hasRpc = api.rpc.contracts && api.rpc.contracts.call;
const hasRpc = callContract.hasRpcContractsCall;
let callMessage = callContract.getMessage(callMessageIndex);

const { api } = useApi();
const [accountId, setAccountId] = useState<StringOrNull>(null);
const [endowment, setEndowment] = useState<BN>(new BN(0));
const [gasLimit, setGasLimit] = useState<BN>(new BN(GAS_LIMIT));
const [isBusy, setIsBusy] = useState(false);
const [outcomes, setOutcomes] = useState<ContractCallOutcome[]>([]);
const [params, setParams] = useState<any[]>(callMessage ? callMessage.def.args.map(({ type }): any => createValue({ type })) : []);
const [useRpc, setUseRpc] = useState(callMessage && !callMessage.def.mutates);
const [useRpc, setUseRpc] = useState(hasRpc && callMessage && !callMessage.def.mutates);

useEffect((): void => {
callMessage = callContract.getMessage(callMessageIndex);

setParams(callMessage ? callMessage.def.args.map(({ type }): any => createValue({ type })) : []);
if (!callMessage || callMessage.def.mutates) {
setUseRpc(false);
} else {
setUseRpc(true);

if (hasRpc) {
if (!callMessage || callMessage.def.mutates) {
setUseRpc(false);
} else {
setUseRpc(true);
}
}
}, [callContract, callMessageIndex]);

Expand Down Expand Up @@ -266,6 +270,5 @@ export default withMulti(
float: right;
}
`,
translate,
withApi
translate
);
2 changes: 1 addition & 1 deletion packages/react-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.7.6",
"@polkadot/api": "^0.100.0-beta.7",
"@polkadot/api": "^0.100.0-beta.9",
"@polkadot/extension-dapp": "^0.14.1",
"edgeware-node-types": "^1.0.10",
"rxjs-compat": "^6.5.3"
Expand Down
Loading