Substrate contracts, basics (#928)

* Substrate contracts, basics

* Expand Create & Deploy with placeholder inputs

* Add ABI parsing & validation (re-usable)

* Expand ABI parsing

* WIP, putCode works, deploy in-progress

* Updates for Params & Instantiate (untested)

* Up to call...

* Linting

* Updated

* InputFile & ABI adjustments

* Add ability to attch existing (code & deployed)

* Small cleanups

* Very basic intro

* Hide contracts sidebar entry

* Update README.md
This commit is contained in:
Jaco Greeff 2019-04-10 11:52:34 +02:00 committed by GitHub
parent bb42748a2d
commit 1a103e9812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 1532 additions and 63 deletions

View File

@ -1,7 +1,7 @@
{
"name": "@polkadot/app-123code",
"version": "0.31.0-beta.21",
"description": "A baasic app that shows the ropes on customisation",
"description": "A basic app that shows the ropes on customisation",
"main": "index.js",
"scripts": {},
"author": "Jaco Greeff <jacogr@gmail.com>",

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,3 @@
# @polkadot/app-contracts
Substrate contracts - code deployment, instance creation and messages.

View File

@ -0,0 +1,16 @@
{
"name": "@polkadot/app-contracts",
"version": "0.31.0-beta.17",
"description": "Deployment and management of substrate contracts",
"main": "index.js",
"scripts": {},
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [
"Jaco Greeff <jacogr@gmail.com>"
],
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.4.3",
"@polkadot/ui-app": "^0.31.0-beta.17"
}
}

View File

@ -0,0 +1,69 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { I18nProps } from '@polkadot/ui-app/types';
import React from 'react';
import { InputFile } from '@polkadot/ui-app';
import { ContractAbi } from '@polkadot/types';
import { u8aToString } from '@polkadot/util';
import translate from './translate';
type Props = I18nProps & {
help: React.ReactNode,
isError?: boolean,
label: React.ReactNode,
onChange: (json: string | null, contractAbi: ContractAbi | null) => void
};
type State = {
abi?: Uint8Array | null,
isAbiValid: boolean,
name?: string,
placeholder?: React.ReactNode | null
};
class ABI extends React.PureComponent<Props, State> {
state: State = {
isAbiValid: true
};
render () {
const { help, isError, label } = this.props;
const { isAbiValid, placeholder } = this.state;
return (
<InputFile
help={help}
isError={!isAbiValid || isError}
label={label}
onChange={this.onChange}
placeholder={placeholder}
/>
);
}
private onChange = (u8a: Uint8Array, name: string): void => {
const { onChange } = this.props;
const json = u8aToString(u8a);
try {
const abi = new ContractAbi(JSON.parse(json));
this.setState({
isAbiValid: true,
name,
placeholder: `${name} (${Object.keys(abi.messages).join(', ')})`
}, () => onChange(json, abi));
} catch (error) {
this.setState({
isAbiValid: false,
placeholder: error.message
}, () => onChange(null, null));
}
}
}
export default translate(ABI);

View File

@ -0,0 +1,183 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { I18nProps } from '@polkadot/ui-app/types';
import { ComponentProps } from './types';
import BN from 'bn.js';
import React from 'react';
import { Button, Dropdown, InputAddress, InputBalance, InputNumber, TxButton } from '@polkadot/ui-app';
import { ContractAbi } from '@polkadot/types';
import store from './store';
import translate from './translate';
import Params from './Params';
type Props = ComponentProps & I18nProps;
type State = {
accountId: string | null,
address?: string,
contractAbi?: ContractAbi | null,
endowment: BN,
gasLimit: BN,
isAddressValid: boolean,
isBusy: boolean,
method?: string | null,
params: Array<any>
};
class Call extends React.PureComponent<Props, State> {
state: State = {
accountId: null,
endowment: new BN(0),
gasLimit: new BN(0),
isAddressValid: false,
isBusy: false,
params: []
};
render () {
const { t } = this.props;
const { accountId, address, contractAbi, endowment, gasLimit, isAddressValid, method } = this.state;
const contractOptions = store.getAllContracts().map(({ json: { address, name } }) => ({
text: `${name} (${address})`,
value: address
}));
const methodOptions = contractAbi
? Object.keys(contractAbi.messages).map((key) => {
const fn = contractAbi.messages[key];
const type = fn.type ? `: ${fn.type}` : '';
const args = fn.args.map(({ name, type }) => `${name}: ${type}`);
const text = `${key}(${args.join(', ')})${type}`;
return {
key,
text,
value: key
};
})
: [];
const defaultContract = contractOptions.length
? contractOptions[contractOptions.length - 1].value
: undefined;
const isEndowValid = !endowment.isZero();
const isGasValid = !gasLimit.isZero();
const isValid = !!accountId && isEndowValid && isGasValid;
return (
<div className='contracts--Call'>
<InputAddress
help={t('Specify the user account to use for this contract call. And fees will be deducted from this account.')}
label={t('call from account')}
onChange={this.onChangeAccount}
type='account'
/>
<Dropdown
defaultValue={defaultContract}
help={t('A deployed contract that has either been deployed or attached. The address and ABI are used to construct the parameters.')}
isError={!isAddressValid}
label={t('contract to use')}
onChange={this.onChangeAddress}
options={contractOptions}
value={address}
/>
<Dropdown
defaultValue={method}
help={t('The message to send to this contract. Parameters are adjusted based on the ABI provided.')}
isError={!method}
label={t('message to send')}
onChange={this.onChangeMethod}
options={methodOptions}
value={method}
/>
<Params
onChange={this.onChangeParams}
params={
method && contractAbi && contractAbi.messages[method]
? contractAbi.messages[method].args
: undefined
}
/>
<InputBalance
help={t('The allotted value for this contract, i.e. the amount transferred to the contract as part of this call.')}
isError={!isEndowValid}
label={t('value')}
onChange={this.onChangeEndowment}
/>
<InputNumber
help={t('The maximum amount of gas that can be used by this deployment, if the code requires more, the deployment will fail.')}
isError={!isGasValid}
label={t('maximum gas allowed')}
onChange={this.onChangeGas}
/>
<Button.Group>
<TxButton
accountId={accountId}
isDisabled={!isValid}
isPrimary
label={t('Call')}
onClick={this.toggleBusy}
onFailed={this.toggleBusy}
onSuccess={this.toggleBusy}
params={this.constructCall}
tx='contract.call'
/>
</Button.Group>
</div>
);
}
private constructCall = (): Array<any> => {
const { contractAbi, endowment, gasLimit, method, params } = this.state;
if (!contractAbi || !method) {
return [];
}
return [endowment, gasLimit, contractAbi.messages[method](...params)];
}
private onChangeAccount = (accountId: string | null): void => {
this.setState({ accountId });
}
private onChangeAddress = (address: string): void => {
const contract = store.getContract(address);
const contractAbi = contract
? contract.contractAbi
: null;
this.setState({ address, contractAbi, isAddressValid: !!contractAbi });
this.onChangeMethod(
contractAbi
? Object.keys(contractAbi.messages)[0]
: null
);
}
private onChangeEndowment = (endowment?: BN | null): void => {
this.setState({ endowment: endowment || new BN(0) });
}
private onChangeGas = (gasLimit: BN | undefined): void => {
this.setState({ gasLimit: gasLimit || new BN(0) });
}
private onChangeMethod = (method: string | null): void => {
this.setState({ method });
}
private onChangeParams = (params: Array<any>): void => {
this.setState({ params });
}
private toggleBusy = (): void => {
this.setState(({ isBusy }) => ({
isBusy: !isBusy
}));
}
}
export default translate(Call);

View File

@ -0,0 +1,256 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic';
import { I18nProps } from '@polkadot/ui-app/types';
import { ComponentProps } from './types';
import BN from 'bn.js';
import React from 'react';
import { Button, Input, InputAddress, InputFile, InputNumber, TxButton } from '@polkadot/ui-app';
import { compactAddLength, isHex } from '@polkadot/util';
import { Hash } from '@polkadot/types';
import ABI from './ABI';
import store from './store';
import translate from './translate';
type Props = ComponentProps & I18nProps;
type State = {
abi?: string | null,
accountId?: string | null,
codeHash?: string | null,
gasLimit: BN,
isAbiValid: boolean,
isBusy: boolean,
isHashValid: boolean,
isNameValid: boolean,
isNew: boolean,
isWasmValid: boolean,
name?: string | null,
wasm?: Uint8Array | null
};
class Deploy extends React.PureComponent<Props, State> {
state: State = {
accountId: null,
gasLimit: new BN(0),
isAbiValid: true,
isBusy: false,
isHashValid: false,
isNew: true,
isNameValid: false,
isWasmValid: false
};
render () {
const { t } = this.props;
const { isNew } = this.state;
return (
<div className='contracts--Code'>
<Button.Group isBasic isCentered>
<Button
isBasic
isNegative={isNew}
label={t('deploy new')}
onClick={this.toggleNew}
/>
<Button
isBasic
isNegative={!isNew}
label={t('attach existing')}
onClick={this.toggleNew}
/>
</Button.Group>
{
isNew
? this.renderDeploy()
: this.renderExisting()
}
</div>
);
}
private renderDeploy () {
const { t } = this.props;
const { accountId, gasLimit, isAbiValid, isBusy, isNameValid, isWasmValid, wasm } = this.state;
const isValid = !isBusy && isAbiValid && isNameValid && isWasmValid && !gasLimit.isZero() && !!accountId;
return (
<>
<InputAddress
help={t('Specify the user account to use for this deployment. And fees will be deducted from this account.')}
label={t('deployment account')}
onChange={this.onChangeAccount}
type='account'
/>
<InputFile
help={t('The compiled WASM for the contract that you wish to deploy. Ecah unique code blob will be attached with a code hash that can be used to create new instances.')}
isError={!isWasmValid}
label={t('compiled contract WASM')}
onChange={this.onAddWasm}
/>
{this.renderInputName()}
{this.renderInputAbi()}
<InputNumber
help={t('The maximum amount of gas that can be used by this deployment, if the code requires more, the deployment will fail.')}
label={t('maximum gas allowed')}
onChange={this.onChangeGas}
/>
<Button.Group>
<TxButton
accountId={accountId}
isDisabled={!isValid}
isPrimary
label={t('Deploy')}
onClick={this.toggleBusy}
onFailed={this.toggleBusy}
onSuccess={this.onSuccess}
params={[gasLimit, wasm]}
tx='contract.putCode'
/>
</Button.Group>
</>
);
}
private renderExisting () {
const { t } = this.props;
const { codeHash, isAbiValid, isHashValid, isNameValid } = this.state;
const isValid = isAbiValid && isHashValid && isNameValid;
return (
<>
<Input
autoFocus
help={t('The code hash for the on-chain deployed code.')}
isError={!isHashValid}
label={t('code hash')}
onChange={this.onChangeHash}
value={codeHash}
/>
{this.renderInputName()}
{this.renderInputAbi()}
<Button.Group>
<Button
isDisabled={!isValid}
isPrimary
label={t('Save')}
onClick={this.onSave}
/>
</Button.Group>
</>
);
}
private renderInputAbi () {
const { t } = this.props;
const { isAbiValid } = this.state;
return (
<ABI
help={t('The ABI for the WASM code. In this step it is optional, but setting it here simplifies the setup of contract instances.')}
isError={!isAbiValid}
label={t('contract ABI (optional)')}
onChange={this.onAddAbi}
/>
);
}
private renderInputName () {
const { t } = this.props;
const { isNameValid, name } = this.state;
return (
<Input
help={t('A name for this WASM code that helps to user distinguish. Only used for display purposes.')}
isError={!isNameValid}
label={t('code bundle name')}
onChange={this.onChangeName}
value={name}
/>
);
}
private onAddAbi = (abi: string | null): void => {
this.setState({ abi, isAbiValid: !!abi });
}
private onAddWasm = (wasm: Uint8Array, name: string): void => {
this.setState({ wasm: compactAddLength(wasm), isWasmValid: true });
this.onChangeName(name);
}
private onChangeAccount = (accountId: string | null): void => {
this.setState({ accountId });
}
private onChangeGas = (gasLimit: BN | undefined): void => {
this.setState({ gasLimit: gasLimit || new BN(0) });
}
private onChangeHash = (codeHash: string): void => {
this.setState({ codeHash, isHashValid: isHex(codeHash) && codeHash.length === 66 });
}
private onChangeName = (name: string): void => {
this.setState({ name, isNameValid: name.length !== 0 });
}
private toggleBusy = (): void => {
this.setState(({ isBusy }) => ({
isBusy: !isBusy
}));
}
private toggleNew = (): void => {
this.setState(({ isNew }) => ({
abi: null,
codeHash: null,
isAbiValid: true,
isHashValid: false,
isNameValid: false,
name: null,
isNew: !isNew
}));
}
private onSave = (): void => {
const { abi, codeHash, name } = this.state;
if (!codeHash || !name) {
return;
}
store.saveCode(new Hash(codeHash), { abi, name });
this.redirect();
}
private onSuccess = (result: SubmittableResult): void => {
const record = result.findRecord('contract', 'CodeStored');
if (record) {
const codeHash = record.event.data[0];
this.setState(({ abi, name }) => {
if (!codeHash || !name) {
return;
}
store.saveCode(codeHash as Hash, { abi, name });
this.redirect();
});
}
this.toggleBusy();
}
private redirect () {
window.location.hash = this.props.basePath;
}
}
export default translate(Deploy);

View File

@ -0,0 +1,360 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { SubmittableResult } from '@polkadot/api/SubmittableExtrinsic';
import { I18nProps } from '@polkadot/ui-app/types';
import { ComponentProps } from './types';
import BN from 'bn.js';
import React from 'react';
import { Button, Dropdown, Input, InputAddress, InputBalance, InputNumber, TxButton } from '@polkadot/ui-app';
import { AccountId, ContractAbi } from '@polkadot/types';
import ABI from './ABI';
import Params from './Params';
import store from './store';
import translate from './translate';
import keyring from '@polkadot/ui-keyring';
type Props = ComponentProps & I18nProps;
type State = {
abi?: string | null,
accountId: string | null,
address?: string | null,
codeHash?: string,
contractAbi?: ContractAbi | null,
endowment: BN,
gasLimit: BN,
isAbiValid: boolean,
isAbiSupplied: boolean,
isAddressValid: boolean,
isBusy: boolean,
isHashValid: boolean,
isNameValid: boolean,
isNew?: boolean,
name?: string | null,
params: Array<any>
};
class Create extends React.PureComponent<Props, State> {
state: State = {
accountId: null,
endowment: new BN(0),
gasLimit: new BN(0),
isAbiValid: false,
isAbiSupplied: false,
isAddressValid: false,
isBusy: false,
isHashValid: false,
isNameValid: false,
isNew: true,
params: []
};
render () {
const { t } = this.props;
const { isNew } = this.state;
return (
<div className='contracts--Instantiate'>
<Button.Group isBasic isCentered>
<Button
isBasic
isNegative={isNew}
label={t('deploy new')}
onClick={this.toggleNew}
/>
<Button
isBasic
isNegative={!isNew}
label={t('attach existing')}
onClick={this.toggleNew}
/>
</Button.Group>
{
isNew
? this.renderDeploy()
: this.renderExisting()
}
</div>
);
}
private renderDeploy () {
const { t } = this.props;
const { accountId, codeHash, contractAbi, endowment, gasLimit, isAbiSupplied, isAbiValid, isHashValid, isNameValid } = this.state;
const isEndowValid = !endowment.isZero();
const isGasValid = !gasLimit.isZero();
const isValid = isAbiValid && isHashValid && isEndowValid && isGasValid && !!accountId && isNameValid;
const codeOptions = store.getAllCode().map(({ json: { codeHash, name } }) => ({
text: `${name} (${codeHash})`,
value: codeHash
}));
const defaultCode = codeOptions.length
? codeOptions[codeOptions.length - 1].value
: undefined;
const constructOptions = contractAbi
? (() => {
const args = contractAbi.deploy.args.map(({ name, type }) => name + ': ' + type);
const text = `deploy(${args.join(', ')})`;
return [{
key: 'deploy',
text,
value: 'deploy'
}];
})()
: [];
return (
<>
<InputAddress
help={t('Specify the user account to use for this contract creation. And fees will be deducted from this account.')}
label={t('deployment account')}
onChange={this.onChangeAccount}
type='account'
/>
<Dropdown
defaultValue={defaultCode}
help={t('The contract WASM previously deployed. Internally this is identified by the hash of the code, as either created or attached.')}
isError={!isHashValid}
label={t('code for this contract')}
onChange={this.onChangeCode}
options={codeOptions}
value={codeHash}
/>
{this.renderInputName()}
{
isAbiSupplied
? null
: this.renderInputAbi()
}
{
contractAbi
? (
<Dropdown
defaultValue='deploy'
help={t('The deployment constructor information for this contract, as provided by the ABI.')}
isDisabled
label={t('constructor')}
options={constructOptions}
value='deploy'
/>
)
: null
}
<Params
onChange={this.onChangeParams}
params={
contractAbi
? contractAbi.deploy.args
: undefined
}
/>
<InputBalance
help={t('The allotted endownment for this contract, i.e. the amount transferred to the contract upon instantiation.')}
isError={!isEndowValid}
label={t('endowment')}
onChange={this.onChangeEndowment}
/>
<InputNumber
help={t('The maximum amount of gas that can be used by this deployment, if the code requires more, the deployment will fail.')}
isError={!isGasValid}
label={t('maximum gas allowed')}
onChange={this.onChangeGas}
/>
<Button.Group>
<TxButton
accountId={accountId}
isDisabled={!isValid}
isPrimary
label={t('Instantiate')}
onClick={this.toggleBusy}
onFailed={this.toggleBusy}
onSuccess={this.onSuccess}
params={this.constructCall}
tx='contract.create'
/>
</Button.Group>
</>
);
}
private renderExisting () {
const { t } = this.props;
const { address, isAddressValid, isAbiValid, isNameValid } = this.state;
const isValid = isNameValid && isAddressValid && isAbiValid;
return (
<>
<Input
autoFocus
help={t('The address for the deployed contract instance.')}
isError={!isAddressValid}
label={t('contract address')}
onChange={this.onChangeAddress}
value={address}
/>
{this.renderInputName()}
{this.renderInputAbi()}
<Button.Group>
<Button
isDisabled={!isValid}
isPrimary
label={t('Save')}
onClick={this.onSave}
/>
</Button.Group>
</>
);
}
private renderInputAbi () {
const { t } = this.props;
const { isAbiValid } = this.state;
return (
<ABI
help={t('The ABI for the WASM code. Since we will be making a call into the code, the ABI is required and stored for future operations such as sending messages.')}
isError={!isAbiValid}
label={t('Contract ABI')}
onChange={this.onAddAbi}
/>
);
}
private renderInputName () {
const { t } = this.props;
const { isNameValid, name } = this.state;
return (
<Input
help={t('A name for the deployed contract to help you distinguish. Only used for display purposes.')}
isError={!isNameValid}
label={t('contract name')}
onChange={this.onChangeName}
value={name}
/>
);
}
private constructCall = (): Array<any> => {
const { codeHash, contractAbi, endowment, gasLimit, params } = this.state;
if (!contractAbi) {
return [];
}
return [endowment, gasLimit, codeHash, contractAbi.deploy(...params)];
}
private onAddAbi = (abi: string | null | undefined, contractAbi: ContractAbi | null, isAbiSupplied: boolean = false): void => {
this.setState({ abi, contractAbi, isAbiSupplied, isAbiValid: !!abi });
}
private onChangeAccount = (accountId: string | null): void => {
this.setState({ accountId });
}
private onChangeAddress = (address: string): void => {
let isAddressValid = false;
try {
keyring.decodeAddress(address);
isAddressValid = true;
} catch (error) {
// ignore
}
this.setState({ address, isAddressValid });
}
private onChangeCode = (codeHash: string): void => {
const code = store.getCode(codeHash);
this.setState({ codeHash, isHashValid: !!code });
if (code) {
if (code.contractAbi) {
this.onAddAbi(code.json.abi, code.contractAbi, true);
} else {
this.onAddAbi(null, null, false);
}
this.onChangeName(`${code.json.name} (instance)`);
}
}
private onChangeEndowment = (endowment?: BN | null): void => {
this.setState({ endowment: endowment || new BN(0) });
}
private onChangeGas = (gasLimit: BN | undefined): void => {
this.setState({ gasLimit: gasLimit || new BN(0) });
}
private onChangeName = (name: string): void => {
this.setState({ name, isNameValid: name.length !== 0 });
}
private onChangeParams = (params: Array<any>): void => {
this.setState({ params });
}
private toggleBusy = (): void => {
this.setState(({ isBusy }) => ({
isBusy: !isBusy
}));
}
private toggleNew = (): void => {
this.setState(({ isNew }) => ({
address: null,
abi: null,
isAddressValid: false,
isAbiValid: false,
isNameValid: false,
isNew: !isNew,
name: null
}));
}
private onSave = (): void => {
const { address, abi, name } = this.state;
if (!address || !abi || !name) {
return;
}
store.saveContract(new AccountId(address), { abi, name });
this.redirect();
}
private onSuccess = (result: SubmittableResult): void => {
const record = result.findRecord('contract', 'Instantiated');
if (record) {
const address = record.event.data[1];
this.setState(({ abi, name }) => {
if (!abi || !name) {
return;
}
store.saveContract(address as AccountId, { abi, name });
this.redirect();
});
}
this.toggleBusy();
}
private redirect () {
window.location.hash = this.props.basePath;
}
}
export default translate(Create);

View File

@ -0,0 +1,57 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { ContractABIArgs } from '@polkadot/types/ContractAbi';
import { RawParams } from '@polkadot/ui-params/types';
import React from 'react';
import UIParams from '@polkadot/ui-params';
import { getTypeDef, TypeDef } from '@polkadot/types';
type Props = {
params?: ContractABIArgs,
onChange: (values: Array<any>) => void
};
type State = {
params: Array<{ name: string, type: TypeDef }>
};
export default class Params extends React.PureComponent<Props, State> {
state: State = { params: [] };
static getDerivedStateFromProps ({ params }: Props): State | null {
if (!params) {
return { params: [] };
}
return {
params: params.map(({ name, type }) => ({
name,
type: getTypeDef(type, name)
}))
} as State;
}
render () {
const { params } = this.state;
if (!params.length) {
return null;
}
return (
<UIParams
onChange={this.onChange}
params={params}
/>
);
}
private onChange = (values: RawParams): void => {
const { onChange } = this.props;
onChange(values.map(({ value }) => value));
}
}

View File

@ -0,0 +1,116 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AppProps, I18nProps } from '@polkadot/ui-app/types';
import { TabItem } from '@polkadot/ui-app/Tabs';
import { ComponentProps, LocationProps } from './types';
import React from 'react';
import { Route, Switch } from 'react-router';
import { HelpOverlay, Tabs } from '@polkadot/ui-app';
import introMd from './md/intro.md';
import store from './store';
import translate from './translate';
import Call from './Call';
import Code from './Code';
import Instantiate from './Instantiate';
type Props = AppProps & I18nProps;
type State = {
tabs: Array<TabItem>,
updated: number
};
class App extends React.PureComponent<Props, State> {
state: State;
constructor (props: Props) {
super(props);
const { t } = props;
store.on('new-code', this.triggerUpdate);
store.on('new-contract', this.triggerUpdate);
this.state = {
tabs: [
{
name: 'call',
text: t('Call')
},
{
name: 'instantiate',
text: t('Instance')
},
{
name: 'code',
text: t('Code')
}
],
updated: 0
};
}
render () {
const { basePath } = this.props;
const { tabs } = this.state;
const hidden = store.hasContracts
? []
: ['call'];
if (!store.hasCode) {
hidden.push('instantiate');
}
return (
<main className='contracts--App'>
<HelpOverlay md={introMd} />
<header>
<Tabs
basePath={basePath}
hidden={hidden}
items={tabs}
/>
</header>
<Switch>
<Route path={`${basePath}/instantiate`} render={this.renderComponent(Instantiate)} />
<Route path={`${basePath}/code`} render={this.renderComponent(Code)} />
<Route
render={
hidden.includes('call')
? (
hidden.includes('instantiate')
? this.renderComponent(Code)
: this.renderComponent(Instantiate)
)
: this.renderComponent(Call)
}
/>
</Switch>
</main>
);
}
private renderComponent (Component: React.ComponentType<ComponentProps>) {
return ({ match }: LocationProps) => {
const { basePath, location, onStatusChange } = this.props;
return (
<Component
basePath={basePath}
location={location}
match={match}
onStatusChange={onStatusChange}
/>
);
};
}
private triggerUpdate = (): void => {
this.setState({ updated: Date.now() });
}
}
export default translate(App);

View File

@ -0,0 +1,17 @@
# contracts
This contract management interface allows you to deploy WASM code for contracts, deploy contracts based on on-chain code and allows you to interact with contracts by sending messages.
## warning
Please be aware that this interface is very new and has not been thoroughly tested against all kinds of combinations of inputs - there are no doubt bugs lurking inside these sections. Additionally, the substrate contracts ABI is a very recent addition, and while stabilizing there may be changes and or-breakages while using this UI to interact.
With all that said - if you do find issues, please log them.
## basic operations
The interface has 3 main areas -
- **Code** This allows you to deploy WASM code on-chain or attach on-chain code into your local registry. Each code blob is identified by a unique hash, when deploying this will be saved, when attaching you would need to know the unique hash. From these bundles you can then move to the next step,
- **Instance** This allows you to create contract instances using on-chain WASM code. Select the code to use, attach the ABI, specify the contract values and the contract can be deployed. As with the Code section, you can also attach on-chain instances when you know the address.
- **Call** This allows you to send messages to contracts, via the address and attached ABIs.

View File

@ -0,0 +1,105 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { CodeJson, ContractJson } from './types';
import EventEmitter from 'eventemitter3';
import store from 'store';
import { AccountId, ContractAbi, Hash } from '@polkadot/types';
const KEY_CODE = 'contract:code:';
const KEY_CONTRACT = 'contract:contract:';
const codeRegex = new RegExp(`^${KEY_CODE}`, '');
const contractRegex = new RegExp(`^${KEY_CONTRACT}`, '');
type CodeStored = { json: CodeJson , contractAbi?: ContractAbi };
type ContractStored = { json: ContractJson , contractAbi: ContractAbi };
class Store extends EventEmitter {
private allCode: { [index: string]: CodeStored } = {};
private allContracts: { [index: string]: ContractStored } = {};
constructor () {
super();
store.each((json: CodeJson | ContractJson, key: string) => {
if (codeRegex.test(key)) {
this.addCode(json as CodeJson);
} else if (contractRegex.test(key)) {
this.addContract(json as ContractJson);
}
});
}
get hasCode (): boolean {
return Object.keys(this.allCode).length !== 0;
}
get hasContracts (): boolean {
return Object.keys(this.allContracts).length !== 0;
}
getAllCode (): Array<CodeStored> {
return Object.values(this.allCode);
}
getAllContracts (): Array<ContractStored> {
return Object.values(this.allContracts);
}
getCode (codeHash: string): CodeStored {
return this.allCode[codeHash];
}
getContract (address: string): ContractStored {
return this.allContracts[address];
}
saveCode (codeHash: Hash, partial: Partial<CodeJson>) {
const json = { ...partial, codeHash: codeHash.toHex() } as CodeJson;
store.set(`${KEY_CODE}${json.codeHash}`, json);
this.addCode(json);
}
saveContract (address: AccountId, partial: Partial<ContractJson>) {
const json = { ...partial, address: address.toString() } as ContractJson;
store.set(`${KEY_CONTRACT}${address}`, json);
this.addContract(json);
}
private addCode (json: CodeJson) {
try {
this.allCode[json.codeHash] = {
json,
contractAbi: json.abi
? new ContractAbi(JSON.parse(json.abi))
: undefined
};
this.emit('new-code');
} catch (error) {
console.error(error);
}
}
private addContract (json: ContractJson) {
try {
this.allContracts[json.address] = {
json,
contractAbi: new ContractAbi(JSON.parse(json.abi))
};
this.emit('new-contract');
} catch (error) {
console.error(error);
}
}
}
export default new Store();

View File

@ -0,0 +1,7 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { withTranslation } from 'react-i18next';
export default withTranslation(['contracts', 'ui']);

View File

@ -0,0 +1,25 @@
// Copyright 2017-2019 @polkadot/app-contracts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AppProps } from '@polkadot/ui-app/types';
export type LocationProps = {
match: {
params: { [index: string]: any }
}
};
export type ComponentProps = AppProps & LocationProps;
export type CodeJson = {
abi?: string | null,
codeHash: string,
name: string
};
export type ContractJson = {
abi: string,
address: string,
name: string
};

View File

@ -105,11 +105,10 @@ class Developer extends React.PureComponent<Props, State> {
}
private onChangeTypes = (data: Uint8Array) => {
const dataToString = u8aToString(data);
const code = u8aToString(data);
try {
const types = JSON.parse(dataToString);
const types = JSON.parse(code);
const typesPlaceholder = Object.keys(types).join(', ');
console.log('Registering types:', typesPlaceholder);
@ -117,7 +116,7 @@ class Developer extends React.PureComponent<Props, State> {
getTypeRegistry().register(types);
this.setState({
code: dataToString,
code,
isJsonValid: true,
isTypesValid: true,
types,
@ -125,11 +124,10 @@ class Developer extends React.PureComponent<Props, State> {
});
} catch (error) {
console.error('Error registering types:', error);
this.setState({
code: dataToString,
code,
isJsonValid: false,
isTypesValid: false,
types: null,

View File

@ -6,7 +6,6 @@ import { AppProps, I18nProps } from '@polkadot/ui-app/types';
import { SettingsStruct } from '@polkadot/ui-settings/types';
import React from 'react';
import { Tab } from 'semantic-ui-react';
import { Button, Dropdown, Input } from '@polkadot/ui-app';
import { ActionStatus } from '@polkadot/ui-app/Status/types';
import uiSettings from '@polkadot/ui-settings';
@ -53,9 +52,7 @@ class General extends React.PureComponent<Props, State> {
return (
<div className='settings-General'>
<div className='ui--row'>
{this.renderEndpoint()}
</div>
{this.renderEndpoint()}
<div className='ui--row'>
<div className='medium'>
<Dropdown
@ -99,38 +96,45 @@ class General extends React.PureComponent<Props, State> {
private renderEndpoint = () => {
const { t } = this.props;
const { isCustomNode, isUrlValid, settings: { apiUrl } } = this.state;
const activeIndex = isCustomNode ? 1 : 0;
const preset = (
<Dropdown
defaultValue={apiUrl}
label={t('remote node/endpoint to connect to')}
onChange={this.onChangeApiUrl}
options={uiSettings.availableNodes}
/>
);
const custom = (
<Input
defaultValue={apiUrl}
isError={!isUrlValid}
label={t('remote node/endpoint to connect to')}
onChange={this.onChangeApiUrl}
/>
);
const panes = [
{ menuItem: t('pre-set'), render: () => <Tab.Pane attached={true}>{preset}</Tab.Pane> },
{ menuItem: t('custom'), render: () => <Tab.Pane attached={true}>{custom}</Tab.Pane> }
];
return (
<Tab
activeIndex={activeIndex}
menu={{ secondary: true }}
onTabChange={this.toggleCustomNode}
panes={panes}
/>
<>
<Button.Group isBasic>
<Button
isBasic
isNegative={!isCustomNode}
label={t('preset')}
onClick={this.toggleCustomNode}
/>
<Button
isBasic
isNegative={isCustomNode}
label={t('custom')}
onClick={this.toggleCustomNode}
/>
</Button.Group>
<div className='ui--row'>
{
isCustomNode
? (
<Input
defaultValue={apiUrl}
isError={!isUrlValid}
label={t('remote node/endpoint to connect to')}
onChange={this.onChangeApiUrl}
/>
)
: (
<Dropdown
defaultValue={apiUrl}
label={t('remote node/endpoint to connect to')}
onChange={this.onChangeApiUrl}
options={uiSettings.availableNodes}
/>
)
}
</div>
</>
);
}

View File

@ -80,16 +80,16 @@
.apps--SideBar-Item {
align-self: flex-end;
flex-grow: 0;
padding: 0 !important;
width: inherit;
padding: 0 !important;
.text {
padding-left: 0.5rem;
}
}
.apps--SideBar-logo {
margin: 0.5rem 1.5rem 1rem 0.75rem;
margin: 0.5rem 1.5rem 1.5rem 0.75rem;
padding-top: 0.75em;
width: 9rem;
}

View File

@ -0,0 +1,25 @@
// Copyright 2017-2019 @polkadot/apps authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Routes } from '../types';
import Contracts from '@polkadot/app-contracts';
export default ([
{
Component: Contracts,
display: {
isHidden: true,
needsAccounts: true,
needsApi: [
'tx.contract.call'
]
},
i18n: {
defaultValue: 'Contracts'
},
icon: 'compress',
name: 'contracts'
}
] as Routes);

View File

@ -9,6 +9,7 @@ import appSettings from '@polkadot/ui-settings';
import template from './123code';
import accounts from './accounts';
import addresses from './addresses';
import contracts from './contracts';
import democracy from './democracy';
import explorer from './explorer';
import extrinsics from './extrinsics';
@ -40,6 +41,7 @@ const routes: Routes = appSettings.uiMode === 'light'
accounts,
addresses,
null,
contracts,
storage,
extrinsics,
null,

View File

@ -4,6 +4,11 @@
.ui--Button-Group {
text-align: right;
&.centered {
margin-bottom: 0.5rem;
text-align: center;
}
}
.ui--Button-Group:not(:first-child) {

View File

@ -14,7 +14,7 @@ export default class Button extends React.PureComponent<ButtonProps> {
const { children, className, floated, icon, isBasic = false, isCircular = false, isDisabled = false, isNegative = false, isPositive = false, isPrimary = false, label, onClick, size, style, tabIndex } = this.props;
const props = {
basic: isBasic || false,
basic: isBasic,
circular: isCircular,
className,
disabled: isDisabled,
@ -25,7 +25,7 @@ export default class Button extends React.PureComponent<ButtonProps> {
positive: isPositive,
primary: isPrimary,
size,
secondary: isBasic && !(isPositive || isPrimary || isNegative || false),
secondary: !isBasic && !(isPositive || isPrimary || isNegative),
style,
tabIndex
};

View File

@ -12,15 +12,19 @@ import Divider from './Divider';
class ButtonGroup extends React.PureComponent<GroupProps> {
render () {
const { children, className, style } = this.props;
const { children, className, isBasic = false, isCentered = false, style } = this.props;
return (
<div
className={classes('ui--Button-Group', className)}
className={classes('ui--Button-Group', isCentered ? 'centered' : '', className)}
style={style}
>
<SUIButton.Group>
<Divider style={{ padding: '0em' }} />
<SUIButton.Group basic={isBasic}>
{
isBasic
? null
: <Divider style={{ padding: '0em' }} />
}
{children}
</SUIButton.Group>
</div>

View File

@ -25,7 +25,9 @@ export type ButtonProps = BareProps & {
export type DividerProps = BareProps;
export type GroupProps = BareProps & {
children?: React.ReactNode
children?: React.ReactNode,
isBasic?: boolean,
isCentered?: boolean
};
export type GroupType = React.ComponentType<GroupProps> & {

View File

@ -20,9 +20,9 @@ type Props = BareProps & WithTranslation & {
help?: React.ReactNode,
isDisabled?: boolean,
isError?: boolean,
label: string,
onChange?: (contents: Uint8Array) => void,
placeholder?: string,
label: React.ReactNode,
onChange?: (contents: Uint8Array, name: string) => void,
placeholder?: React.ReactNode | null,
withLabel?: boolean
};
@ -90,12 +90,13 @@ class InputFile extends React.PureComponent<Props, State> {
// @ts-ignore ummm... events are not properly specified here?
reader.onload = ({ target: { result } }: LoadEvent) => {
const data = new Uint8Array(result);
const name = file.name;
onChange && onChange(data);
onChange && onChange(data, name);
this.setState({
file: {
name: file.name,
name,
size: data.length
}
});

View File

@ -84,7 +84,7 @@ class InputNumber extends React.PureComponent<Props, State> {
}
render () {
const { bitLength = DEFAULT_BITLENGTH, className, help, isSi, isDisabled, maxLength, style, t } = this.props;
const { bitLength = DEFAULT_BITLENGTH, className, help, isSi, isDisabled, isError = false, maxLength, style, t } = this.props;
const { isValid, value } = this.state;
const maxValueLength = this.maxValue(bitLength).toString().length - 1;
@ -95,7 +95,7 @@ class InputNumber extends React.PureComponent<Props, State> {
help={help}
isAction={isSi}
isDisabled={isDisabled}
isError={!isValid}
isError={!isValid || isError}
maxLength={maxLength || maxValueLength}
onChange={this.onChange}
onKeyDown={this.onKeyDown}

View File

@ -7,11 +7,13 @@ import { QueueTx$ExtrinsicAdd, TxCallback } from './Status/types';
import React from 'react';
import { withApi } from '@polkadot/ui-api';
import { assert, isUndefined } from '@polkadot/util';
import { assert, isFunction, isUndefined } from '@polkadot/util';
import { QueueConsumer } from './Status/Context';
import Button from './Button';
type ConstructFn = () => Array<any>;
type InjectedProps = {
queueExtrinsic: QueueTx$ExtrinsicAdd;
};
@ -26,7 +28,7 @@ type Props = ApiProps & {
onFailed?: TxCallback,
onSuccess?: TxCallback,
onUpdate?: TxCallback,
params?: Array<any>,
params?: Array<any> | ConstructFn,
tx: string
};
@ -54,9 +56,13 @@ class TxButtonInner extends React.PureComponent<Props & InjectedProps> {
assert(api.tx[section] && api.tx[section][method], `Unable to find api.tx.${section}.${method}`);
const extrinsic: any = api.tx[section][method](
...(isFunction(params) ? params() : params)
);
queueExtrinsic({
accountId,
extrinsic: api.tx[section][method](...params) as any, // ???
extrinsic,
txFailedCb: onFailed,
txSuccessCb: onSuccess,
txUpdateCb: onUpdate

View File

@ -240,10 +240,10 @@ header .ui--Button-Group {
border: 1px dashed rgba(34, 36, 38, 0.15);
border-radius: $small-corner;
display: flex;
font-size: 1.2em;
height: 5em;
font-size: 1rem;
height: 3.5rem;
justify-content: center;
margin-bottom: 0.5rem;
margin: 0.25rem 0;
width: 100% !important;
&.error {

View File

@ -19,6 +19,11 @@
background-color: $button-primary-color-hover;
}
.ui.basic.negative.button {
box-shadow: 0 0 0 1px rgba(215, 94, 161, 1) inset !important;
color: rgba(215, 94, 161, 1) !important;
}
.ui.button,
.ui.buttons .button,
.ui.button:active,

View File

@ -9,6 +9,8 @@
"@polkadot/app-accounts/*": [ "packages/app-accounts/src/*" ],
"@polkadot/app-addresses": [ "packages/app-addresses/src" ],
"@polkadot/app-addresses/*": [ "packages/app-addresses/src/*" ],
"@polkadot/app-contracts": [ "packages/app-contracts/src" ],
"@polkadot/app-contracts/*": [ "packages/app-contracts/src/*" ],
"@polkadot/app-democracy": [ "packages/app-democracy/src" ],
"@polkadot/app-democracy/*": [ "packages/app-democracy/src/*" ],
"@polkadot/app-extrinsics": [ "packages/app-extrinsics/src" ],