diff --git a/packages/app-extrinsics/src/Params/Call.tsx b/packages/app-extrinsics/src/Params/Call.tsx index f7f4ef1966..e6bb292890 100644 --- a/packages/app-extrinsics/src/Params/Call.tsx +++ b/packages/app-extrinsics/src/Params/Call.tsx @@ -14,12 +14,19 @@ type Props = ApiProps & BaseProps; class Call extends React.PureComponent { render () { - const { apiPromise, className, isDisabled, isError, label, onChange, style, withLabel } = this.props; + const { apiDefaultTx, apiPromise, className, isDisabled, isError, label, onChange, style, withLabel } = this.props; + const defaultValue = (() => { + try { + return apiPromise.tx.balances.transfer; + } catch (error) { + return apiDefaultTx; + } + })(); return ( { label } })} - labelSection={t('proposal.method', { + labelSection={t('proposal.section', { defaultValue: '{{label}} (section)', replace: { label diff --git a/packages/app-extrinsics/src/Params/Proposal.tsx b/packages/app-extrinsics/src/Params/Proposal.tsx index b18ccb029f..50d45bacf8 100644 --- a/packages/app-extrinsics/src/Params/Proposal.tsx +++ b/packages/app-extrinsics/src/Params/Proposal.tsx @@ -15,12 +15,19 @@ type Props = ApiProps & BaseProps; class ProposalDisplay extends React.PureComponent { render () { - const { apiPromise, className, isDisabled, isError, label, style, withLabel } = this.props; + const { apiDefaultTx, apiPromise, className, isDisabled, isError, label, style, withLabel } = this.props; + const defaultValue = (() => { + try { + return apiPromise.tx.consensus.setCode; + } catch (error) { + return apiDefaultTx; + } + })(); return ( { } as State; render () { - const { apiPromise, t } = this.props; + const { apiDefaultTx, apiPromise, t } = this.props; const { isValid, accountId } = this.state; + const defaultExtrinsic = (() => { + try { + return apiPromise.tx.balances.transfer; + } catch (error) { + return apiDefaultTx; + } + })(); return (
@@ -50,7 +57,7 @@ class Selection extends React.PureComponent { type='account' /> { isApiReady: false, apiPromise: new ApiPromise(provider), setApiUrl - }; + } as State; } componentDidMount () { @@ -116,16 +116,23 @@ export default class ApiWrapper extends React.PureComponent { private subscribeIsReady = (api: ApiPromise) => { api.on('ready', () => { - this.setState({ isApiReady: true }); + const section = Object.keys(api.tx)[0]; + const method = Object.keys(api.tx[section])[0]; + + this.setState({ + isApiReady: true, + apiDefaultTx: api.tx[section][method] + }); }); } render () { - const { apiPromise, chain, isApiConnected, isApiReady, setApiUrl } = this.state; + const { apiDefaultTx, apiPromise, chain, isApiConnected, isApiReady, setApiUrl } = this.state; return ( void };