Skip to content
Snippets Groups Projects
runtime-calls.md 57 KiB
Newer Older
Remove one certification given the issuer and the receiver.

- `origin`: Must be `Root`.

#### remove_all_certs_received_by - 2

<details><summary><code>remove_all_certs_received_by(idty_index)</code></summary>

Taking 6.846 % of a block.
Remove all certifications received by an identity.

- `origin`: Must be `Root`.

#### request_distance_evaluation - 0

<details><summary><code>request_distance_evaluation()</code></summary>

Taking 0.0389 % of a block.
Request evaluation of the caller's identity distance.

This function allows the caller to request an evaluation of their distance.
A positive evaluation will lead to claiming or renewing membership, while a negative
evaluation will result in slashing for the caller.

#### request_distance_evaluation_for - 4

<details><summary><code>request_distance_evaluation_for(target)</code></summary>

Taking 0.0399 % of a block.
Request evaluation of a target identity's distance.

This function allows the caller to request an evaluation of a specific target identity's distance.
This action is only permitted for unvalidated identities.

#### update_evaluation - 1

<details><summary><code>update_evaluation(computation_result)</code></summary>

Taking 0.0341 % of a block.
```rust
computation_result: ComputationResult
```
Push an evaluation result to the pool.

This inherent function is called internally by validators to push an evaluation result
to the evaluation pool.

#### force_update_evaluation - 2

<details><summary><code>force_update_evaluation(evaluator, computation_result)</code></summary>

Taking 0.0192 % of a block.
```rust
evaluator: <T as frame_system::Config>::AccountId
computation_result: ComputationResult
```
Force push an evaluation result to the pool.

It is primarily used for testing purposes.

- `origin`: Must be `Root`.
#### force_valid_distance_status - 3
<details><summary><code>force_valid_distance_status(identity)</code></summary>
Taking 0.027 % of a block.
```rust
identity: <T as pallet_identity::Config>::IdtyIndex
```
Force set the distance evaluation status of an identity.

It is primarily used for testing purposes.

- `origin`: Must be `Root`.

#### create_swap - 0

<details><summary><code>create_swap(target, hashed_proof, action, duration)</code></summary>

```rust
target: T::AccountId
hashed_proof: HashedProof
action: T::SwapAction
Register a new atomic swap, declaring an intention to send funds from origin to target
on the current blockchain. The target can claim the fund using the revealed proof. If
the fund is not claimed after `duration` blocks, then the sender can cancel the swap.

The dispatch origin for this call must be _Signed_.

- `target`: Receiver of the atomic swap.
- `hashed_proof`: The blake2_256 hash of the secret proof.
- `balance`: Funds to be sent from origin.
- `duration`: Locked duration of the atomic swap. For safety reasons, it is recommended
  that the revealer uses a shorter duration than the counterparty, to prevent the
  situation where the revealer reveals the proof too late around the end block.
#### claim_swap - 1

<details><summary><code>claim_swap(proof, action)</code></summary>
proof: Vec<u8>
action: T::SwapAction
Claim an atomic swap.

The dispatch origin for this call must be _Signed_.

- `proof`: Revealed proof of the claim.
- `action`: Action defined in the swap, it must match the entry in blockchain. Otherwise
  the operation fails. This is used for weight calculation.
#### cancel_swap - 2

<details><summary><code>cancel_swap(target, hashed_proof)</code></summary>
target: T::AccountId
hashed_proof: HashedProof
Cancel an atomic swap. Only possible after the originally set duration has passed.

The dispatch origin for this call must be _Signed_.

- `target`: Target of the original atomic swap.
- `hashed_proof`: Hashed proof of the original atomic swap.

#### as_multi_threshold_1 - 0

<details><summary><code>as_multi_threshold_1(other_signatories, call)</code></summary>
Taking 0.005 % of a block.
other_signatories: Vec<T::AccountId>
call: Box<<T as Config>::RuntimeCall>
Immediately dispatch a multi-signature call using a single approval from the caller.

The dispatch origin for this call must be _Signed_.

- `other_signatories`: The accounts (other than the sender) who are part of the
multi-signature, but do not participate in the approval process.
- `call`: The call to be executed.

Result is equivalent to the dispatched result.

**Complexity**
O(Z + C) where Z is the length of the call and C its execution weight.
<details><summary><code>as_multi(threshold, other_signatories, maybe_timepoint, call, max_weight)</code></summary>
threshold: u16
other_signatories: Vec<T::AccountId>
maybe_timepoint: Option<Timepoint<BlockNumberFor<T>>>
call: Box<<T as Config>::RuntimeCall>
Register approval for a dispatch to be made from a deterministic composite account if
approved by a total of `threshold - 1` of `other_signatories`.

If there are enough, then dispatch the call.

Payment: `DepositBase` will be reserved if this is the first approval, plus
`threshold` times `DepositFactor`. It is returned once this dispatch happens or
is cancelled.

The dispatch origin for this call must be _Signed_.

- `threshold`: The total number of approvals for this dispatch before it is executed.
- `other_signatories`: The accounts (other than the sender) who can approve this
dispatch. May not be empty.
- `maybe_timepoint`: If this is the first approval, then this must be `None`. If it is
not the first approval, then it must be `Some`, with the timepoint (block number and
transaction index) of the first approval transaction.
- `call`: The call to be executed.

NOTE: Unless this is the final approval, you will generally want to use
`approve_as_multi` instead, since it only requires a hash of the call.

Result is equivalent to the dispatched result if `threshold` is exactly `1`. Otherwise
on success, result is `Ok` and the result from the interior call, if it was executed,
may be found in the deposited `MultisigExecuted` event.

**Complexity**
- `O(S + Z + Call)`.
- Up to one balance-reserve or unreserve operation.
- One passthrough operation, one insert, both `O(S)` where `S` is the number of
  signatories. `S` is capped by `MaxSignatories`, with weight being proportional.
- One call encode & hash, both of complexity `O(Z)` where `Z` is tx-len.
- One encode & hash, both of complexity `O(S)`.
- Up to one binary search and insert (`O(logS + S)`).
- I/O: 1 read `O(S)`, up to 1 mutate `O(S)`. Up to one remove.
- One event.
- The weight of the `call`.
- Storage: inserts one item, value size bounded by `MaxSignatories`, with a deposit
  taken for its lifetime of `DepositBase + threshold * DepositFactor`.
#### approve_as_multi - 2

<details><summary><code>approve_as_multi(threshold, other_signatories, maybe_timepoint, call_hash, max_weight)</code></summary>
threshold: u16
other_signatories: Vec<T::AccountId>
maybe_timepoint: Option<Timepoint<BlockNumberFor<T>>>
Register approval for a dispatch to be made from a deterministic composite account if
approved by a total of `threshold - 1` of `other_signatories`.

Payment: `DepositBase` will be reserved if this is the first approval, plus
`threshold` times `DepositFactor`. It is returned once this dispatch happens or
is cancelled.

The dispatch origin for this call must be _Signed_.

- `threshold`: The total number of approvals for this dispatch before it is executed.
- `other_signatories`: The accounts (other than the sender) who can approve this
dispatch. May not be empty.
- `maybe_timepoint`: If this is the first approval, then this must be `None`. If it is
not the first approval, then it must be `Some`, with the timepoint (block number and
transaction index) of the first approval transaction.
- `call_hash`: The hash of the call to be executed.

NOTE: If this is the final approval, you will want to use `as_multi` instead.

**Complexity**
- `O(S)`.
- Up to one balance-reserve or unreserve operation.
- One passthrough operation, one insert, both `O(S)` where `S` is the number of
  signatories. `S` is capped by `MaxSignatories`, with weight being proportional.
- One encode & hash, both of complexity `O(S)`.
- Up to one binary search and insert (`O(logS + S)`).
- I/O: 1 read `O(S)`, up to 1 mutate `O(S)`. Up to one remove.
- One event.
- Storage: inserts one item, value size bounded by `MaxSignatories`, with a deposit
  taken for its lifetime of `DepositBase + threshold * DepositFactor`.
#### cancel_as_multi - 3

<details><summary><code>cancel_as_multi(threshold, other_signatories, timepoint, call_hash)</code></summary>
Taking 0.0123 % of a block.
threshold: u16
other_signatories: Vec<T::AccountId>
timepoint: Timepoint<BlockNumberFor<T>>
Cancel a pre-existing, on-going multisig transaction. Any deposit reserved previously
for this operation will be unreserved on success.

The dispatch origin for this call must be _Signed_.

- `threshold`: The total number of approvals for this dispatch before it is executed.
- `other_signatories`: The accounts (other than the sender) who can approve this
dispatch. May not be empty.
- `timepoint`: The timepoint (block number and transaction index) of the first approval
transaction for this dispatch.
- `call_hash`: The hash of the call to be executed.

**Complexity**
- `O(S)`.
- Up to one balance-reserve or unreserve operation.
- One passthrough operation, one insert, both `O(S)` where `S` is the number of
  signatories. `S` is capped by `MaxSignatories`, with weight being proportional.
- One encode & hash, both of complexity `O(S)`.
- One event.
- I/O: 1 read `O(S)`, one remove.
- Storage: removes one item.
### ProvideRandomness - 52

#### request - 0

<details><summary><code>request(randomness_type, salt)</code></summary>
Taking 0.0404 % of a block.
randomness_type: RandomnessType
salt: H256
<details><summary><code>proxy(real, force_proxy_type, call)</code></summary>
Taking 0.0062 % of a block.
real: AccountIdLookupOf<T>
force_proxy_type: Option<T::ProxyType>
call: Box<<T as Config>::RuntimeCall>
Dispatch the given `call` from an account that the sender is authorised for through
`add_proxy`.

The dispatch origin for this call must be _Signed_.

Parameters:
- `real`: The account that the proxy will make a call on behalf of.
- `force_proxy_type`: Specify the exact proxy type to be used and checked for this call.
- `call`: The call to be made by the `real` account.
#### add_proxy - 1

<details><summary><code>add_proxy(delegate, proxy_type, delay)</code></summary>
Taking 0.0121 % of a block.
delegate: AccountIdLookupOf<T>
Register a proxy account for the sender that is able to make calls on its behalf.

The dispatch origin for this call must be _Signed_.

Parameters:
- `proxy`: The account that the `caller` would like to make a proxy.
- `proxy_type`: The permissions allowed for this proxy account.
- `delay`: The announcement period required of the initial proxy. Will generally be
zero.
#### remove_proxy - 2

<details><summary><code>remove_proxy(delegate, proxy_type, delay)</code></summary>
Taking 0.0121 % of a block.
delegate: AccountIdLookupOf<T>
Unregister a proxy account for the sender.

The dispatch origin for this call must be _Signed_.

Parameters:
- `proxy`: The account that the `caller` would like to remove as a proxy.
- `proxy_type`: The permissions currently enabled for the removed proxy account.
#### remove_proxies - 3

<details><summary><code>remove_proxies()</code></summary>
Taking 0.012 % of a block.
Unregister all proxy accounts for the sender.

The dispatch origin for this call must be _Signed_.

WARNING: This may be called on accounts created by `pure`, however if done, then
the unreserved fees will be inaccessible. **All access to this account will be lost.**
<details><summary><code>create_pure(proxy_type, delay, index)</code></summary>
Taking 0.0121 % of a block.
Spawn a fresh new account that is guaranteed to be otherwise inaccessible, and
initialize it with a proxy of `proxy_type` for `origin` sender.

Requires a `Signed` origin.

- `proxy_type`: The type of the proxy that the sender will be registered as over the
new account. This will almost always be the most permissive `ProxyType` possible to
allow for maximum flexibility.
- `index`: A disambiguation index, in case this is called multiple times in the same
transaction (e.g. with `utility::batch`). Unless you're using `batch` you probably just
want to use `0`.
- `delay`: The announcement period required of the initial proxy. Will generally be
zero.

Fails with `Duplicate` if this has already been called in this transaction, from the
same sender, with the same parameters.

Fails if there are insufficient funds to pay for deposit.
<details><summary><code>kill_pure(spawner, proxy_type, index, height, ext_index)</code></summary>
Taking 0.012 % of a block.
spawner: AccountIdLookupOf<T>
Removes a previously spawned pure proxy.

WARNING: **All access to this account will be lost.** Any funds held in it will be
inaccessible.

Requires a `Signed` origin, and the sender account must have been created by a call to
`pure` with corresponding parameters.

- `spawner`: The account that originally called `pure` to create this account.
- `index`: The disambiguation index originally passed to `pure`. Probably `0`.
- `proxy_type`: The proxy type originally passed to `pure`.
- `height`: The height of the chain when the call to `pure` was processed.
- `ext_index`: The extrinsic index in which the call to `pure` was processed.

Fails with `NoPermission` in case the caller is not a previously created pure
account whose `pure` call has corresponding parameters.
#### announce - 6

<details><summary><code>announce(real, call_hash)</code></summary>
Taking 0.0199 % of a block.
real: AccountIdLookupOf<T>
Publish the hash of a proxy-call that will be made in the future.

This must be called some number of blocks before the corresponding `proxy` is attempted
if the delay associated with the proxy relationship is greater than zero.

No more than `MaxPending` announcements may be made at any one time.

This will take a deposit of `AnnouncementDepositFactor` as well as
`AnnouncementDepositBase` if there are no other pending announcements.

The dispatch origin for this call must be _Signed_ and a proxy of `real`.

Parameters:
- `real`: The account that the proxy will make a call on behalf of.
- `call_hash`: The hash of the call to be made by the `real` account.
#### remove_announcement - 7

<details><summary><code>remove_announcement(real, call_hash)</code></summary>
Taking 0.0186 % of a block.
real: AccountIdLookupOf<T>
call_hash: CallHashOf<T>
```
Remove a given announcement.

May be called by a proxy account to remove a call they previously announced and return
the deposit.

The dispatch origin for this call must be _Signed_.

Parameters:
- `real`: The account that the proxy will make a call on behalf of.
- `call_hash`: The hash of the call to be made by the `real` account.
#### reject_announcement - 8

<details><summary><code>reject_announcement(delegate, call_hash)</code></summary>
Taking 0.0186 % of a block.
delegate: AccountIdLookupOf<T>
call_hash: CallHashOf<T>
```
Remove the given announcement of a delegate.

May be called by a target (proxied) account to remove a call that one of their delegates
(`delegate`) has announced they want to execute. The deposit is returned.

The dispatch origin for this call must be _Signed_.

Parameters:
- `delegate`: The account that previously announced the call.
- `call_hash`: The hash of the call to be made.
#### proxy_announced - 9

<details><summary><code>proxy_announced(delegate, real, force_proxy_type, call)</code></summary>
Taking 0.02 % of a block.
delegate: AccountIdLookupOf<T>
real: AccountIdLookupOf<T>
force_proxy_type: Option<T::ProxyType>
call: Box<<T as Config>::RuntimeCall>
Dispatch the given `call` from an account that the sender is authorized for through
`add_proxy`.

Removes any corresponding announcement(s).

The dispatch origin for this call must be _Signed_.

Parameters:
- `real`: The account that the proxy will make a call on behalf of.
- `force_proxy_type`: Specify the exact proxy type to be used and checked for this call.
- `call`: The call to be made by the `real` account.

#### batch - 0

<details><summary><code>batch(calls)</code></summary>
Taking 0.1149 % of a block.
calls: Vec<<T as Config>::RuntimeCall>
Send a batch of dispatch calls.

May be called from any origin except `None`.

- `calls`: The calls to be dispatched from the same origin. The number of call must not
  exceed the constant: `batched_calls_limit` (available in constant metadata).

If origin is root then the calls are dispatched without checking origin filter. (This
includes bypassing `frame_system::Config::BaseCallFilter`).

**Complexity**
- O(C) where C is the number of calls to be batched.

This will return `Ok` in all circumstances. To determine the success of the batch, an
event is deposited. If a call failed and the batch was interrupted, then the
`BatchInterrupted` event is deposited, along with the number of successful calls made
and the error of the failed call. If all were successful, then the `BatchCompleted`
event is deposited.
#### as_derivative - 1

<details><summary><code>as_derivative(index, call)</code></summary>
Taking 0.0047 % of a block.
call: Box<<T as Config>::RuntimeCall>
Send a call through an indexed pseudonym of the sender.

Filter from origin are passed along. The call will be dispatched with an origin which
use the same filter as the origin of this call.

NOTE: If you need to ensure that any account-based filtering is not honored (i.e.
because you expect `proxy` to have been used prior in the call stack and you do not want
the call restrictions to apply to any sub-accounts), then use `as_multi_threshold_1`
in the Multisig pallet instead.

NOTE: Prior to version *12, this was called `as_limited_sub`.

The dispatch origin for this call must be _Signed_.
#### batch_all - 2

<details><summary><code>batch_all(calls)</code></summary>
Taking 0.1241 % of a block.
calls: Vec<<T as Config>::RuntimeCall>
Send a batch of dispatch calls and atomically execute them.
The whole transaction will rollback and fail if any of the calls failed.

May be called from any origin except `None`.

- `calls`: The calls to be dispatched from the same origin. The number of call must not
  exceed the constant: `batched_calls_limit` (available in constant metadata).

If origin is root then the calls are dispatched without checking origin filter. (This
includes bypassing `frame_system::Config::BaseCallFilter`).

**Complexity**
- O(C) where C is the number of calls to be batched.
#### force_batch - 4

<details><summary><code>force_batch(calls)</code></summary>
Taking 0.1155 % of a block.
calls: Vec<<T as Config>::RuntimeCall>
Send a batch of dispatch calls.
Unlike `batch`, it allows errors and won't interrupt.

May be called from any origin except `None`.

- `calls`: The calls to be dispatched from the same origin. The number of call must not
  exceed the constant: `batched_calls_limit` (available in constant metadata).

If origin is root then the calls are dispatch without checking origin filter. (This
includes bypassing `frame_system::Config::BaseCallFilter`).

**Complexity**
- O(C) where C is the number of calls to be batched.

#### with_weight - 5

<details><summary><code>with_weight(call, weight)</code></summary>
```rust
call: Box<<T as Config>::RuntimeCall>
weight: Weight
```
Dispatch a function call with a specified weight.

This function does not check the weight of the call, and instead allows the
Root origin to specify the weight of the call.

The dispatch origin for this call must be _Root_.
<details><summary><code>spend_local(amount, beneficiary)</code></summary>
Taking 0.0045 % of a block.
beneficiary: AccountIdLookupOf<T>
Propose and approve a spend of treasury funds.

## Dispatch Origin

Must be [`Config::SpendOrigin`] with the `Success` value being at least `amount`.

### Details
NOTE: For record-keeping purposes, the proposer is deemed to be equivalent to the
beneficiary.

### Parameters
- `amount`: The amount to be transferred from the treasury to the `beneficiary`.
- `beneficiary`: The destination account for the transfer.

## Events

Emits [`Event::SpendApproved`] if successful.
<details><summary><code>remove_approval(proposal_id)</code></summary>
Taking 0.0056 % of a block.
Éloïs's avatar
Éloïs committed
```rust
Éloïs's avatar
Éloïs committed
```
Force a previously approved proposal to be removed from the approval queue.

## Dispatch Origin

Must be [`Config::RejectOrigin`].

## Details

The original deposit will no longer be returned.

### Parameters
- `proposal_id`: The index of a proposal

#**Complexity**
- O(A) where `A` is the number of approvals

### Errors
- [`Error::ProposalNotApproved`]: The `proposal_id` supplied was not found in the
  approval queue, i.e., the proposal has not been approved. This could also mean the
  proposal does not exist altogether, thus there is no way it would have been approved
  in the first place.

#### spend - 5

<details><summary><code>spend(asset_kind, amount, beneficiary, valid_from)</code></summary>

Taking 0.0045 % of a block.

```rust
asset_kind: Box<T::AssetKind>
amount: AssetBalanceOf<T, I>
beneficiary: Box<BeneficiaryLookupOf<T, I>>
valid_from: Option<BlockNumberFor<T>>
```
</details>

Propose and approve a spend of treasury funds.

## Dispatch Origin

Must be [`Config::SpendOrigin`] with the `Success` value being at least
`amount` of `asset_kind` in the native asset. The amount of `asset_kind` is converted
for assertion using the [`Config::BalanceConverter`].

## Details

Create an approved spend for transferring a specific `amount` of `asset_kind` to a
designated beneficiary. The spend must be claimed using the `payout` dispatchable within
the [`Config::PayoutPeriod`].

### Parameters
- `asset_kind`: An indicator of the specific asset class to be spent.
- `amount`: The amount to be transferred from the treasury to the `beneficiary`.
- `beneficiary`: The beneficiary of the spend.
- `valid_from`: The block number from which the spend can be claimed. It can refer to
  the past if the resulting spend has not yet expired according to the
  [`Config::PayoutPeriod`]. If `None`, the spend can be claimed immediately after
  approval.

## Events

Emits [`Event::AssetSpendApproved`] if successful.

#### payout - 6

<details><summary><code>payout(index)</code></summary>

Taking 0.0057 % of a block.

## Details

Spends must be claimed within some temporal bounds. A spend may be claimed within one
[`Config::PayoutPeriod`] from the `valid_from` block.
In case of a payout failure, the spend status must be updated with the `check_status`
dispatchable before retrying with the current function.

### Parameters
- `index`: The spend index.

## Events

Emits [`Event::Paid`] if successful.

#### check_status - 7

<details><summary><code>check_status(index)</code></summary>

Taking 0.0057 % of a block.
Éloïs's avatar
Éloïs committed
</details>

Check the status of the spend and remove it from the storage if processed.

## Dispatch Origin

Must be signed.

## Details

The status check is a prerequisite for retrying a failed payout.
If a spend has either succeeded or expired, it is removed from the storage by this
function. In such instances, transaction fees are refunded.

### Parameters
- `index`: The spend index.

## Events

Emits [`Event::PaymentFailed`] if the spend payout has failed.
Emits [`Event::SpendProcessed`] if the spend payout has succeed.
<details><summary><code>void_spend(index)</code></summary>
Taking 0.0057 % of a block.
Void previously approved spend.

## Dispatch Origin

Must be [`Config::RejectOrigin`].

## Details

A spend void is only possible if the payout has not been attempted yet.

### Parameters
- `index`: The spend index.

## Events

Emits [`Event::AssetSpendVoided`] if successful.
There are **18** root calls from **8** pallets.
<details><summary><code>set_heap_pages(pages)</code></summary>
Taking 0.0165 % of a block.
Set the number of pages in the WebAssembly environment's heap.
<details><summary><code>set_code(code)</code></summary>
Taking 3.9234 % of a block.
<details><summary><code>set_code_without_checks(code)</code></summary>