Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typos #449

Merged
merged 5 commits into from
Aug 20, 2023
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
4 changes: 2 additions & 2 deletions docs/api-contract/start/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Code
The `CodePromise` class allows the developer to manage calls to the `instantiate_with_code` dispatchable in the contracts pallet.
It is useful in cases where an existing `codeHash` is not available, meaning that the code has never been deployed to the blockchain in its current form.

The `instantiate_with_code` dispatchable uploads the wasm code the blockchain and creates a new instance in one go. Learn how it works under the hood in the [Substrate Metadata](../../substrate/extrinsics.md#instantiatewithcodevalue-compactu128-gas_limit-compactu64-storage_deposit_limit-optioncompactu128-code-bytes-data-bytes-salt-bytes) section
The `instantiate_with_code` dispatchable uploads the wasm code to the blockchain and creates a new instance in one go. Learn how it works under the hood in the [Substrate Metadata](../../substrate/extrinsics.md#instantiatewithcodevalue-compactu128-gas_limit-compactu64-storage_deposit_limit-optioncompactu128-code-bytes-data-bytes-salt-bytes) section

The `CodePromise` constructor takes 3 arguments: an API instance, the contract metadata, and the contract code. Only the wasm code will end up on-chain; the metadata is only used in the JavaScript world. See [Prerequisites](./basics.md) to find out how to obtain them.

Expand All @@ -29,7 +29,7 @@ const storageDepositLimit = null
// used to derive contract address,
// use null to prevent duplicate contracts
const salt = new Uint8Array()
// balance to transfer to the contract account, formerly know as "endowment".
// balance to transfer to the contract account, formerly known as "endowment".
// use only with payable constructors, will fail otherwise.
const value = api.registry.createType('Balance', 1000)
const initValue = 1;
Expand Down
2 changes: 1 addition & 1 deletion docs/api-contract/start/contract.read.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ const callValue = await contract.query.balanceOf(from, { gasLimit: -1 }, target)
In this example we have specified a `gasLimit` of `-1`, in a subsequent section we will expand on this. for now, just remember that is indicated to use max available, i.e. we don't explicitly want to specify a value.


Now that we understand the underlying call/read interfaces where a message is executed, but not part of a block, we will loo into [sending transaction messages](contract.tx.md) in our next section.
Now that we understand the underlying call/read interfaces where a message is executed, but not part of a block, we will look into [sending transaction messages](contract.tx.md) in our next section.

2 changes: 1 addition & 1 deletion docs/api-contract/start/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Generally you would want to keep the versions of the 2 in lock-step, which mean

## Notes on use

Be aware that Substrate chains are different, which means that some chains will not have the [FRAME contracts pallet](https://docs.substrate.io/v3/runtime/frame) installed. For instance, relay chains such as Polkadot does not have this functionality; however, many have parachains that do.
Be aware that Substrate chains are different, which means that some chains will not have the [FRAME contracts pallet](https://docs.substrate.io/v3/runtime/frame) installed. For instance, relay chains such as Polkadot do not have this functionality; however, many have parachains that do.

Additionally the contracts pallet and [ink!](https://github.com/paritytech/ink) are still evolving. With the upgrade from ink! v2 to v3 the ABI structure has changed completely. As of the [polkadot-js API v2.2.1](https://github.com/polkadot-js/api/releases/tag/v2.2.1) only ink! v3.0-rc1 and later is supported. If you are using an earlier version, this guide will not be useful since the wrapper interfaces have changed in a major way to support the new formats.

Expand Down
2 changes: 1 addition & 1 deletion docs/api-contract/start/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ For development purposes it's generally preferred to use a local development net
You will need a Substrate account to sign messages. Check the [docs section on Keyring](../../api/start/keyring.md) in order to get access to dev accounts (Alice, Bob, Charlie, ..etc.) or create new ones. Alternatively, check out the [Extension package docs](../../extension/intro.md) in order to retrieve all injected accounts.

## Contract build artifacts
The contract metadata and the wasm code are generated by building the contract with a tool like [cargo-contract](https://github.com/paritytech/cargo-contract) or [solang](https://github.com/hyperledger-labs/solang#build-for-substrate). These tools also generate a `<name>.contract` file which contains the metadata and includes the the wasm code under `metadata.source.wasm`.
The contract metadata and the wasm code are generated by building the contract with a tool like [cargo-contract](https://github.com/paritytech/cargo-contract) or [solang](https://github.com/hyperledger-labs/solang#build-for-substrate). These tools also generate a `<name>.contract` file which contains the metadata and includes the wasm code under `metadata.source.wasm`.

As metadata, all `api-contract` helpers accept either a JSON string, a parsed JSON or an `Abi` instance.

Expand Down
12 changes: 6 additions & 6 deletions docs/api/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,26 @@ There are 3 `Address` types that are generally configured in different chains, a
- `type Address = AccountId` (Rust), this is used in a number of chains such as Kusama/Polkadot (prior to the 28 runtime) and a previous default for the node-template chain as well. To override to this type of Address, use the API types `{ "Address": "AccountId", "LookupSource": "AccountId" }`


The above may also apply when when you use [polkadot-js/apps](https://github.com/polkadot-js/apps) to connect to your node. Known chains are correctly configured, however any custom chain may need additional types.
The above may also apply when you use [polkadot-js/apps](https://github.com/polkadot-js/apps) to connect to your node. Known chains are correctly configured, however any custom chain may need additional types.


## I would like to sign transactions offline

The API itself is independent on where the signature comes from and how it is injected. Additionally it implements a signer interface, that can be used for external signing - an example of this is the [polkadot-js/apps](https://github.com/polkadot-js/apps) support for signing via extensions and even the [polkadot-js/extension](https://github.com/polkadot-js/extension) support for tools such as the [Parity Signer](https://github.com/paritytech/parity-signer).
The API itself is independent of where the signature comes from and how it is injected. Additionally it implements a signer interface, that can be used for external signing - an example of this is the [polkadot-js/apps](https://github.com/polkadot-js/apps) support for signing via extensions and even the [polkadot-js/extension](https://github.com/polkadot-js/extension) support for tools such as the [Parity Signer](https://github.com/paritytech/parity-signer).

As of this writing we don't have an explicit example of implementing the signer interface in these docs, although we do use one in [our tests](https://github.com/polkadot-js/api/blob/master/packages/api/src/test/SingleAccountSigner.ts). Additionally, the [polkadot-js/tools](https://github.com/polkadot-js/tools) has an implementation of [a very basic offline signer](https://github.com/polkadot-js/tools/tree/master/packages/signer-cli) where transactions are generated in one process and signatures in another non-connected process.


## I would like to send a root transaction

Some calls in Polkadot/Substrate can only be submitted as root, these are indicated by `ensure_root(origin)` in the Rust codebase. Root here does not refer to the actual account, i.e. `//Alice` on a `--dev` chain, but rather that it cannot be submitted as a bare user transaction. This restriction applies to chain upgrades, changing balances or anything that modifies the state and/or chain operation.
Some calls in Polkadot/Substrate can only be submitted as root, these are indicated by `ensure_root(origin)` in the Rust codebase. Root here does not refer to the actual account, i.e. `//Alice` on a `--dev` chain, but rather that it cannot be submitted as a bare user transaction. This restriction applies to chain upgrades, changing balances or anything that modifies the state and/or chain operation.

To submit these transactions, it needs to be send as a [wrapped transaction](start/api.tx.wrap.md#sudo-use) via either `sudo.sudo` (assuming you have access on your chain) or `democracy.proposal` (which would allow users of the chain to vote on it).
To submit these transactions, it needs to be sent as a [wrapped transaction](start/api.tx.wrap.md#sudo-use) via either `sudo.sudo` (assuming you have access on your chain) or `democracy.proposal` (which would allow users of the chain to vote on it).


## How do I call a function with a Tuple input

Tuples, as defined in the Polkadot/Substrate types appear as `(TypeA, TypeB)`. For instance we may have an `(AccountId, u64)` input as defined in the metadata or as part of the user types. To specify a Tuple as an input, wrap it in an array format, for instance to call `query.module.get((u32, u64))` where a `(u32, u64)` Tuple input is expected, you would do `query.module.get([123, 456])`
Tuples, as defined in the Polkadot/Substrate types appear as `(TypeA, TypeB)`. For instance we may have an `(AccountId, u64)` input as defined in the metadata or as part of the user types. To specify a Tuple as an input, wrap it in an array format, for instance to call `query.module.get((u32, u64))` where a `(u32, u64)` Tuple input is expected, you would do `query.module.get([123, 456])`


## How long do transactions live
Expand Down Expand Up @@ -95,7 +95,7 @@ If you are on a chain that has not been upgraded yet, you need to add `Weight: '

## On a non-current, non Substrate 2.0 branch, my balances are wrong

As part of the Substrate 2.0 release, the `RefCount` type has been changed from ` u8` to a `u32`. Since the API always track latest Substrate, this change has been applied by default. The impact of this type is that it is used in the `AccountInfo` type which is returned from `system.account`, which, in turn, tracks balances.
As part of the Substrate 2.0 release, the `RefCount` type has been changed from ` u8` to a `u32`. Since the API always tracks latest Substrate, this change has been applied by default. The impact of this type is that it is used in the `AccountInfo` type which is returned from `system.account`, which, in turn, tracks balances.

If on an older version of the chain, apply the older type via `RefCount: 'u8'` to your types.

Expand Down