diff --git a/docs/api/runtime-calls.md b/docs/api/runtime-calls.md index f6a2ddb8aa0aad99e8e3e4100924948699223373..39d58a35a791b50697c4845f3c0c9b9385214ea0 100644 --- a/docs/api/runtime-calls.md +++ b/docs/api/runtime-calls.md @@ -359,7 +359,7 @@ ask to join the set of validators two sessions after <details><summary><code>set_session_keys(keys)</code></summary> ```rust -keys: T::KeysWrapper +keys: T::Keys ``` </details> @@ -750,8 +750,11 @@ Link an account to an identity </details> -claim pending membership to become actual memberhip -the requested membership must fullfill requirements +claim membership +a pending membership should exist +it must fullfill the requirements (certs, distance) +for main wot claim_membership is called automatically when validating identity +for smith wot, it means joining the authority members #### renew_membership - 2 @@ -844,10 +847,9 @@ Removes the status if `status` is `None`. #### request_membership - 0 -<details><summary><code>request_membership(metadata)</code></summary> +<details><summary><code>request_membership()</code></summary> ```rust -metadata: T::MetaData ``` </details> @@ -864,8 +866,11 @@ submit a membership request (must have a declared identity) </details> -claim pending membership to become actual memberhip -the requested membership must fullfill requirements +claim membership +a pending membership should exist +it must fullfill the requirements (certs, distance) +for main wot claim_membership is called automatically when validating identity +for smith wot, it means joining the authority members #### renew_membership - 2 @@ -2003,10 +2008,9 @@ usually means being a stash account). #### request_membership - 0 -<details><summary><code>request_membership(metadata)</code></summary> +<details><summary><code>request_membership()</code></summary> ```rust -metadata: T::MetaData ``` </details> diff --git a/docs/api/runtime-events.md b/docs/api/runtime-events.md new file mode 100644 index 0000000000000000000000000000000000000000..82c4671400346474aa3fdbb47c4e6fba0044f207 --- /dev/null +++ b/docs/api/runtime-events.md @@ -0,0 +1,1493 @@ +# Runtime events + +There are xxx calls from **37** pallets. + +### System - 0 + +#### ExtrinsicSuccess - 0 + +<details><summary><code>ExtrinsicSuccess(dispatch_info)</code></summary> + +```rust +dispatch_info: DispatchInfo +``` +</details> + + +#### ExtrinsicFailed - 1 + +<details><summary><code>ExtrinsicFailed(dispatch_error, dispatch_info)</code></summary> + +```rust +dispatch_error: DispatchError +dispatch_info: DispatchInfo +``` +</details> + + +#### CodeUpdated - 2 + +<details><summary><code>CodeUpdated()</code></summary> + +```rust +``` +</details> + + +#### NewAccount - 3 + +<details><summary><code>NewAccount(account)</code></summary> + +```rust +account: T::AccountId +``` +</details> + + +#### KilledAccount - 4 + +<details><summary><code>KilledAccount(account)</code></summary> + +```rust +account: T::AccountId +``` +</details> + + +#### Remarked - 5 + +<details><summary><code>Remarked(sender, hash)</code></summary> + +```rust +sender: T::AccountId +hash: T::Hash +``` +</details> + + +### Account - 1 + +#### ForceDestroy - 0 + +<details><summary><code>ForceDestroy(who, balance)</code></summary> + +```rust +who: T::AccountId +balance: T::Balance +``` +</details> + + +#### RandomIdAssigned - 1 + +<details><summary><code>RandomIdAssigned(who, random_id)</code></summary> + +```rust +who: T::AccountId +random_id: H256 +``` +</details> + + +#### AccountLinked - 2 + +<details><summary><code>AccountLinked(who, identity)</code></summary> + +```rust +who: T::AccountId +identity: IdtyIdOf<T> +``` +</details> + + +#### AccountUnlinked - 3 + +<details><summary><code>AccountUnlinked()</code></summary> + +```rust +: T::AccountId +``` +</details> + + +### Scheduler - 2 + +#### Scheduled - 0 + +<details><summary><code>Scheduled(when, index)</code></summary> + +```rust +when: T::BlockNumber +index: u32 +``` +</details> + + +#### Canceled - 1 + +<details><summary><code>Canceled(when, index)</code></summary> + +```rust +when: T::BlockNumber +index: u32 +``` +</details> + + +#### Dispatched - 2 + +<details><summary><code>Dispatched(task, id, result)</code></summary> + +```rust +task: TaskAddress<T::BlockNumber> +id: Option<TaskName> +result: DispatchResult +``` +</details> + + +#### CallUnavailable - 3 + +<details><summary><code>CallUnavailable(task, id)</code></summary> + +```rust +task: TaskAddress<T::BlockNumber> +id: Option<TaskName> +``` +</details> + + +#### PeriodicFailed - 4 + +<details><summary><code>PeriodicFailed(task, id)</code></summary> + +```rust +task: TaskAddress<T::BlockNumber> +id: Option<TaskName> +``` +</details> + + +#### PermanentlyOverweight - 5 + +<details><summary><code>PermanentlyOverweight(task, id)</code></summary> + +```rust +task: TaskAddress<T::BlockNumber> +id: Option<TaskName> +``` +</details> + + +### Babe - 3 + +### Timestamp - 4 + +### Parameters - 5 + +### Balances - 6 + +#### Endowed - 0 + +<details><summary><code>Endowed(account, free_balance)</code></summary> + +```rust +account: T::AccountId +free_balance: T::Balance +``` +</details> + + +#### DustLost - 1 + +<details><summary><code>DustLost(account, amount)</code></summary> + +```rust +account: T::AccountId +amount: T::Balance +``` +</details> + + +#### Transfer - 2 + +<details><summary><code>Transfer(from, to, amount)</code></summary> + +```rust +from: T::AccountId +to: T::AccountId +amount: T::Balance +``` +</details> + + +#### BalanceSet - 3 + +<details><summary><code>BalanceSet(who, free)</code></summary> + +```rust +who: T::AccountId +free: T::Balance +``` +</details> + + +#### Reserved - 4 + +<details><summary><code>Reserved(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Unreserved - 5 + +<details><summary><code>Unreserved(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### ReserveRepatriated - 6 + +<details><summary><code>ReserveRepatriated(from, to, amount, destination_status)</code></summary> + +```rust +from: T::AccountId +to: T::AccountId +amount: T::Balance +destination_status: Status +``` +</details> + + +#### Deposit - 7 + +<details><summary><code>Deposit(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Withdraw - 8 + +<details><summary><code>Withdraw(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Slashed - 9 + +<details><summary><code>Slashed(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Minted - 10 + +<details><summary><code>Minted(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Burned - 11 + +<details><summary><code>Burned(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Suspended - 12 + +<details><summary><code>Suspended(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Restored - 13 + +<details><summary><code>Restored(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Upgraded - 14 + +<details><summary><code>Upgraded(who)</code></summary> + +```rust +who: T::AccountId +``` +</details> + + +#### Issued - 15 + +<details><summary><code>Issued(amount)</code></summary> + +```rust +amount: T::Balance +``` +</details> + + +#### Rescinded - 16 + +<details><summary><code>Rescinded(amount)</code></summary> + +```rust +amount: T::Balance +``` +</details> + + +#### Locked - 17 + +<details><summary><code>Locked(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Unlocked - 18 + +<details><summary><code>Unlocked(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Frozen - 19 + +<details><summary><code>Frozen(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +#### Thawed - 20 + +<details><summary><code>Thawed(who, amount)</code></summary> + +```rust +who: T::AccountId +amount: T::Balance +``` +</details> + + +### TransactionPayment - 32 + +#### TransactionFeePaid - 0 + +<details><summary><code>TransactionFeePaid(who, actual_fee, tip)</code></summary> + +```rust +who: T::AccountId +actual_fee: BalanceOf<T> +tip: BalanceOf<T> +``` +</details> + + +### OneshotAccount - 7 + +#### OneshotAccountCreated - 0 + +<details><summary><code>OneshotAccountCreated(account, balance, creator)</code></summary> + +```rust +account: T::AccountId +balance: <T::Currency as Currency<T::AccountId>>::Balance +creator: T::AccountId +``` +</details> + + +#### OneshotAccountConsumed - 1 + +<details><summary><code>OneshotAccountConsumed(account, dest1, dest2)</code></summary> + +```rust +account: T::AccountId +dest1: (T::AccountId,<T::Currency as Currency<T::AccountId>>::Balance,) +dest2: Option< +(T::AccountId,<T::Currency as Currency<T::AccountId>>::Balance,) +> +``` +</details> + + +#### Withdraw - 2 + +<details><summary><code>Withdraw(account, balance)</code></summary> + +```rust +account: T::AccountId +balance: <T::Currency as Currency<T::AccountId>>::Balance +``` +</details> + + +### Quota - 66 + +#### Refunded - 0 + +<details><summary><code>Refunded(who, identity, amount)</code></summary> + +```rust +who: T::AccountId +identity: IdtyId<T> +amount: BalanceOf<T> +``` +</details> + + +#### NoQuotaForIdty - 1 + +<details><summary><code>NoQuotaForIdty()</code></summary> + +```rust +: IdtyId<T> +``` +</details> + + +#### NoMoreCurrencyForRefund - 2 + +<details><summary><code>NoMoreCurrencyForRefund()</code></summary> + +```rust +``` +</details> + + +#### RefundFailed - 3 + +<details><summary><code>RefundFailed()</code></summary> + +```rust +: T::AccountId +``` +</details> + + +#### RefundQueueFull - 4 + +<details><summary><code>RefundQueueFull()</code></summary> + +```rust +``` +</details> + + +### AuthorityMembers - 10 + +#### IncomingAuthorities - 0 + +<details><summary><code>IncomingAuthorities()</code></summary> + +```rust +: Vec<T::MemberId> +``` +</details> + + +#### OutgoingAuthorities - 1 + +<details><summary><code>OutgoingAuthorities()</code></summary> + +```rust +: Vec<T::MemberId> +``` +</details> + + +#### MemberGoOffline - 2 + +<details><summary><code>MemberGoOffline()</code></summary> + +```rust +: T::MemberId +``` +</details> + + +#### MemberGoOnline - 3 + +<details><summary><code>MemberGoOnline()</code></summary> + +```rust +: T::MemberId +``` +</details> + + +#### MemberRemoved - 4 + +<details><summary><code>MemberRemoved()</code></summary> + +```rust +: T::MemberId +``` +</details> + + +#### MemberRemovedFromBlackList - 5 + +<details><summary><code>MemberRemovedFromBlackList()</code></summary> + +```rust +: T::MemberId +``` +</details> + + +### Authorship - 11 + +### Offences - 12 + +#### Offence - 0 + +<details><summary><code>Offence(kind, timeslot)</code></summary> + +```rust +kind: Kind +timeslot: OpaqueTimeSlot +``` +</details> + + +### Historical - 13 + +### Session - 14 + +#### NewSession - 0 + +<details><summary><code>NewSession(session_index)</code></summary> + +```rust +session_index: SessionIndex +``` +</details> + + +### Grandpa - 15 + +#### NewAuthorities - 0 + +<details><summary><code>NewAuthorities(authority_set)</code></summary> + +```rust +authority_set: AuthorityList +``` +</details> + + +#### Paused - 1 + +<details><summary><code>Paused()</code></summary> + +```rust +``` +</details> + + +#### Resumed - 2 + +<details><summary><code>Resumed()</code></summary> + +```rust +``` +</details> + + +### ImOnline - 16 + +#### HeartbeatReceived - 0 + +<details><summary><code>HeartbeatReceived(authority_id)</code></summary> + +```rust +authority_id: T::AuthorityId +``` +</details> + + +#### AllGood - 1 + +<details><summary><code>AllGood()</code></summary> + +```rust +``` +</details> + + +#### SomeOffline - 2 + +<details><summary><code>SomeOffline(offline)</code></summary> + +```rust +offline: Vec<IdentificationTuple<T>> +``` +</details> + + +### AuthorityDiscovery - 17 + +### Sudo - 20 + +#### Sudid - 0 + +<details><summary><code>Sudid(sudo_result)</code></summary> + +```rust +sudo_result: DispatchResult +``` +</details> + + +#### KeyChanged - 1 + +<details><summary><code>KeyChanged(old_sudoer)</code></summary> + +```rust +old_sudoer: Option<T::AccountId> +``` +</details> + + +#### SudoAsDone - 2 + +<details><summary><code>SudoAsDone(sudo_result)</code></summary> + +```rust +sudo_result: DispatchResult +``` +</details> + + +### UpgradeOrigin - 21 + +#### DispatchedAsRoot - 0 + +<details><summary><code>DispatchedAsRoot(result)</code></summary> + +```rust +result: DispatchResult +``` +</details> + + +### Preimage - 22 + +#### Noted - 0 + +<details><summary><code>Noted(hash)</code></summary> + +```rust +hash: T::Hash +``` +</details> + + +#### Requested - 1 + +<details><summary><code>Requested(hash)</code></summary> + +```rust +hash: T::Hash +``` +</details> + + +#### Cleared - 2 + +<details><summary><code>Cleared(hash)</code></summary> + +```rust +hash: T::Hash +``` +</details> + + +### TechnicalCommittee - 23 + +#### Proposed - 0 + +<details><summary><code>Proposed(account, proposal_index, proposal_hash, threshold)</code></summary> + +```rust +account: T::AccountId +proposal_index: ProposalIndex +proposal_hash: T::Hash +threshold: MemberCount +``` +</details> + + +#### Voted - 1 + +<details><summary><code>Voted(account, proposal_hash, voted, yes, no)</code></summary> + +```rust +account: T::AccountId +proposal_hash: T::Hash +voted: bool +yes: MemberCount +no: MemberCount +``` +</details> + + +#### Approved - 2 + +<details><summary><code>Approved(proposal_hash)</code></summary> + +```rust +proposal_hash: T::Hash +``` +</details> + + +#### Disapproved - 3 + +<details><summary><code>Disapproved(proposal_hash)</code></summary> + +```rust +proposal_hash: T::Hash +``` +</details> + + +#### Executed - 4 + +<details><summary><code>Executed(proposal_hash, result)</code></summary> + +```rust +proposal_hash: T::Hash +result: DispatchResult +``` +</details> + + +#### MemberExecuted - 5 + +<details><summary><code>MemberExecuted(proposal_hash, result)</code></summary> + +```rust +proposal_hash: T::Hash +result: DispatchResult +``` +</details> + + +#### Closed - 6 + +<details><summary><code>Closed(proposal_hash, yes, no)</code></summary> + +```rust +proposal_hash: T::Hash +yes: MemberCount +no: MemberCount +``` +</details> + + +### UniversalDividend - 30 + +#### NewUdCreated - 0 + +<details><summary><code>NewUdCreated(amount, index, monetary_mass, members_count)</code></summary> + +```rust +amount: BalanceOf<T> +index: UdIndex +monetary_mass: BalanceOf<T> +members_count: BalanceOf<T> +``` +</details> + + +#### UdReevalued - 1 + +<details><summary><code>UdReevalued(new_ud_amount, monetary_mass, members_count)</code></summary> + +```rust +new_ud_amount: BalanceOf<T> +monetary_mass: BalanceOf<T> +members_count: BalanceOf<T> +``` +</details> + + +#### UdsAutoPaidAtRemoval - 2 + +<details><summary><code>UdsAutoPaidAtRemoval(count, total, who)</code></summary> + +```rust +count: UdIndex +total: BalanceOf<T> +who: T::AccountId +``` +</details> + + +#### UdsClaimed - 3 + +<details><summary><code>UdsClaimed(count, total, who)</code></summary> + +```rust +count: UdIndex +total: BalanceOf<T> +who: T::AccountId +``` +</details> + + +### Wot - 40 + +### Identity - 41 + +#### IdtyCreated - 0 + +<details><summary><code>IdtyCreated(idty_index, owner_key)</code></summary> + +```rust +idty_index: T::IdtyIndex +owner_key: T::AccountId +``` +</details> + + +#### IdtyConfirmed - 1 + +<details><summary><code>IdtyConfirmed(idty_index, owner_key, name)</code></summary> + +```rust +idty_index: T::IdtyIndex +owner_key: T::AccountId +name: IdtyName +``` +</details> + + +#### IdtyValidated - 2 + +<details><summary><code>IdtyValidated(idty_index)</code></summary> + +```rust +idty_index: T::IdtyIndex +``` +</details> + + +#### IdtyChangedOwnerKey - 3 + +<details><summary><code>IdtyChangedOwnerKey(idty_index, new_owner_key)</code></summary> + +```rust +idty_index: T::IdtyIndex +new_owner_key: T::AccountId +``` +</details> + + +#### IdtyRemoved - 4 + +<details><summary><code>IdtyRemoved(idty_index, reason)</code></summary> + +```rust +idty_index: T::IdtyIndex +reason: IdtyRemovalReason<T::IdtyRemovalOtherReason> +``` +</details> + + +### Membership - 42 + +#### MembershipAcquired - 0 + +<details><summary><code>MembershipAcquired()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### MembershipExpired - 1 + +<details><summary><code>MembershipExpired()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### MembershipRenewed - 2 + +<details><summary><code>MembershipRenewed()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### MembershipRequested - 3 + +<details><summary><code>MembershipRequested()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### MembershipRevoked - 4 + +<details><summary><code>MembershipRevoked()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### PendingMembershipExpired - 5 + +<details><summary><code>PendingMembershipExpired()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +### Cert - 43 + +#### NewCert - 0 + +<details><summary><code>NewCert(issuer, issuer_issued_count, receiver, receiver_received_count)</code></summary> + +```rust +issuer: T::IdtyIndex +issuer_issued_count: u32 +receiver: T::IdtyIndex +receiver_received_count: u32 +``` +</details> + + +#### RemovedCert - 1 + +<details><summary><code>RemovedCert(issuer, issuer_issued_count, receiver, receiver_received_count, expiration)</code></summary> + +```rust +issuer: T::IdtyIndex +issuer_issued_count: u32 +receiver: T::IdtyIndex +receiver_received_count: u32 +expiration: bool +``` +</details> + + +#### RenewedCert - 2 + +<details><summary><code>RenewedCert(issuer, receiver)</code></summary> + +```rust +issuer: T::IdtyIndex +receiver: T::IdtyIndex +``` +</details> + + +### Distance - 44 + +### SmithSubWot - 50 + +### SmithMembership - 52 + +#### MembershipAcquired - 0 + +<details><summary><code>MembershipAcquired()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### MembershipExpired - 1 + +<details><summary><code>MembershipExpired()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### MembershipRenewed - 2 + +<details><summary><code>MembershipRenewed()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### MembershipRequested - 3 + +<details><summary><code>MembershipRequested()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### MembershipRevoked - 4 + +<details><summary><code>MembershipRevoked()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +#### PendingMembershipExpired - 5 + +<details><summary><code>PendingMembershipExpired()</code></summary> + +```rust +: T::IdtyId +``` +</details> + + +### SmithCert - 53 + +#### NewCert - 0 + +<details><summary><code>NewCert(issuer, issuer_issued_count, receiver, receiver_received_count)</code></summary> + +```rust +issuer: T::IdtyIndex +issuer_issued_count: u32 +receiver: T::IdtyIndex +receiver_received_count: u32 +``` +</details> + + +#### RemovedCert - 1 + +<details><summary><code>RemovedCert(issuer, issuer_issued_count, receiver, receiver_received_count, expiration)</code></summary> + +```rust +issuer: T::IdtyIndex +issuer_issued_count: u32 +receiver: T::IdtyIndex +receiver_received_count: u32 +expiration: bool +``` +</details> + + +#### RenewedCert - 2 + +<details><summary><code>RenewedCert(issuer, receiver)</code></summary> + +```rust +issuer: T::IdtyIndex +receiver: T::IdtyIndex +``` +</details> + + +### AtomicSwap - 60 + +#### NewSwap - 0 + +<details><summary><code>NewSwap(account, proof, swap)</code></summary> + +```rust +account: T::AccountId +proof: HashedProof +swap: PendingSwap<T> +``` +</details> + + +#### SwapClaimed - 1 + +<details><summary><code>SwapClaimed(account, proof, success)</code></summary> + +```rust +account: T::AccountId +proof: HashedProof +success: bool +``` +</details> + + +#### SwapCancelled - 2 + +<details><summary><code>SwapCancelled(account, proof)</code></summary> + +```rust +account: T::AccountId +proof: HashedProof +``` +</details> + + +### Multisig - 61 + +#### NewMultisig - 0 + +<details><summary><code>NewMultisig(approving, multisig, call_hash)</code></summary> + +```rust +approving: T::AccountId +multisig: T::AccountId +call_hash: CallHash +``` +</details> + + +#### MultisigApproval - 1 + +<details><summary><code>MultisigApproval(approving, timepoint, multisig, call_hash)</code></summary> + +```rust +approving: T::AccountId +timepoint: Timepoint<T::BlockNumber> +multisig: T::AccountId +call_hash: CallHash +``` +</details> + + +#### MultisigExecuted - 2 + +<details><summary><code>MultisigExecuted(approving, timepoint, multisig, call_hash, result)</code></summary> + +```rust +approving: T::AccountId +timepoint: Timepoint<T::BlockNumber> +multisig: T::AccountId +call_hash: CallHash +result: DispatchResult +``` +</details> + + +#### MultisigCancelled - 3 + +<details><summary><code>MultisigCancelled(cancelling, timepoint, multisig, call_hash)</code></summary> + +```rust +cancelling: T::AccountId +timepoint: Timepoint<T::BlockNumber> +multisig: T::AccountId +call_hash: CallHash +``` +</details> + + +### ProvideRandomness - 62 + +#### FilledRandomness - 0 + +<details><summary><code>FilledRandomness(request_id, randomness)</code></summary> + +```rust +request_id: RequestId +randomness: H256 +``` +</details> + + +#### RequestedRandomness - 1 + +<details><summary><code>RequestedRandomness(request_id, salt, r#type)</code></summary> + +```rust +request_id: RequestId +salt: H256 +r#type: RandomnessType +``` +</details> + + +### Proxy - 63 + +#### ProxyExecuted - 0 + +<details><summary><code>ProxyExecuted(result)</code></summary> + +```rust +result: DispatchResult +``` +</details> + + +#### PureCreated - 1 + +<details><summary><code>PureCreated(pure, who, proxy_type, disambiguation_index)</code></summary> + +```rust +pure: T::AccountId +who: T::AccountId +proxy_type: T::ProxyType +disambiguation_index: u16 +``` +</details> + + +#### Announced - 2 + +<details><summary><code>Announced(real, proxy, call_hash)</code></summary> + +```rust +real: T::AccountId +proxy: T::AccountId +call_hash: CallHashOf<T> +``` +</details> + + +#### ProxyAdded - 3 + +<details><summary><code>ProxyAdded(delegator, delegatee, proxy_type, delay)</code></summary> + +```rust +delegator: T::AccountId +delegatee: T::AccountId +proxy_type: T::ProxyType +delay: T::BlockNumber +``` +</details> + + +#### ProxyRemoved - 4 + +<details><summary><code>ProxyRemoved(delegator, delegatee, proxy_type, delay)</code></summary> + +```rust +delegator: T::AccountId +delegatee: T::AccountId +proxy_type: T::ProxyType +delay: T::BlockNumber +``` +</details> + + +### Utility - 64 + +#### BatchInterrupted - 0 + +<details><summary><code>BatchInterrupted(index, error)</code></summary> + +```rust +index: u32 +error: DispatchError +``` +</details> + + +#### BatchCompleted - 1 + +<details><summary><code>BatchCompleted()</code></summary> + +```rust +``` +</details> + + +#### BatchCompletedWithErrors - 2 + +<details><summary><code>BatchCompletedWithErrors()</code></summary> + +```rust +``` +</details> + + +#### ItemCompleted - 3 + +<details><summary><code>ItemCompleted()</code></summary> + +```rust +``` +</details> + + +#### ItemFailed - 4 + +<details><summary><code>ItemFailed(error)</code></summary> + +```rust +error: DispatchError +``` +</details> + + +#### DispatchedAs - 5 + +<details><summary><code>DispatchedAs(result)</code></summary> + +```rust +result: DispatchResult +``` +</details> + + +### Treasury - 65 + +#### Proposed - 0 + +<details><summary><code>Proposed(proposal_index)</code></summary> + +```rust +proposal_index: ProposalIndex +``` +</details> + + +#### Spending - 1 + +<details><summary><code>Spending(budget_remaining)</code></summary> + +```rust +budget_remaining: BalanceOf<T, I> +``` +</details> + + +#### Awarded - 2 + +<details><summary><code>Awarded(proposal_index, award, account)</code></summary> + +```rust +proposal_index: ProposalIndex +award: BalanceOf<T, I> +account: T::AccountId +``` +</details> + + +#### Rejected - 3 + +<details><summary><code>Rejected(proposal_index, slashed)</code></summary> + +```rust +proposal_index: ProposalIndex +slashed: BalanceOf<T, I> +``` +</details> + + +#### Burnt - 4 + +<details><summary><code>Burnt(burnt_funds)</code></summary> + +```rust +burnt_funds: BalanceOf<T, I> +``` +</details> + + +#### Rollover - 5 + +<details><summary><code>Rollover(rollover_balance)</code></summary> + +```rust +rollover_balance: BalanceOf<T, I> +``` +</details> + + +#### Deposit - 6 + +<details><summary><code>Deposit(value)</code></summary> + +```rust +value: BalanceOf<T, I> +``` +</details> + + +#### SpendApproved - 7 + +<details><summary><code>SpendApproved(proposal_index, amount, beneficiary)</code></summary> + +```rust +proposal_index: ProposalIndex +amount: BalanceOf<T, I> +beneficiary: T::AccountId +``` +</details> + + +#### UpdatedInactive - 8 + +<details><summary><code>UpdatedInactive(reactivated, deactivated)</code></summary> + +```rust +reactivated: BalanceOf<T, I> +deactivated: BalanceOf<T, I> +``` +</details> + + diff --git a/xtask/res/templates/runtime-events.md b/xtask/res/templates/runtime-events.md new file mode 100644 index 0000000000000000000000000000000000000000..f3888e3abd1e08c1b14f0b75778a262716920d0a --- /dev/null +++ b/xtask/res/templates/runtime-events.md @@ -0,0 +1,26 @@ +# Runtime events + +There are xxx calls from **{{ pallets | length }}** pallets. + +{% for pallet in pallets -%} +### {{ pallet.name }} - {{ pallet.index }} + +{% for event in pallet.events -%} +#### {{ event.name }} - {{ event.index }} + +<details><summary><code>{{ event.name }}( + {%- for param in event.params -%} + {{ param.name }}{% if loop.last != true %}, {% endif %} + {%- endfor -%} + )</code></summary> + +```rust +{% for param in event.params -%} +{{ param.name }}: {{ param.type_name }} +{% endfor -%} +``` +</details> + + +{% endfor -%} +{% endfor -%} diff --git a/xtask/src/gen_calls_doc.rs b/xtask/src/gen_doc.rs similarity index 65% rename from xtask/src/gen_calls_doc.rs rename to xtask/src/gen_doc.rs index c1c03b3c9c44cc3fd3f8f712c558ff4f4151d027..3ca8f27e0b9b642b53bdd075b454add716e7be72 100644 --- a/xtask/src/gen_calls_doc.rs +++ b/xtask/src/gen_doc.rs @@ -27,45 +27,79 @@ use tera::Tera; // consts const CALLS_DOC_FILEPATH: &str = "docs/api/runtime-calls.md"; +const EVENTS_DOC_FILEPATH: &str = "docs/api/runtime-events.md"; const TEMPLATES_GLOB: &str = "xtask/res/templates/*.md"; // define structs and implementations -type RuntimeCalls = Vec<Pallet>; +type RuntimePallets = Vec<Pallet>; #[derive(Clone, Serialize)] struct Pallet { index: u8, name: String, calls: Vec<Call>, + events: Vec<Event>, +} +#[derive(Clone, Serialize)] +struct Call { + documentation: String, + index: u8, + name: String, + params: Vec<CallParam>, +} +#[derive(Clone, Serialize)] +struct CallParam { + name: String, + type_name: String, +} +#[derive(Clone, Serialize)] +struct Event { + documentation: String, + index: u8, + name: String, + params: Vec<EventParam>, +} +#[derive(Clone, Serialize)] +struct EventParam { + name: String, + type_name: String, } impl Pallet { fn new( index: u8, name: String, - scale_type_def: &scale_info::TypeDef<PortableForm>, + call_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, + event_scale_type_def: &Option<scale_info::TypeDef<PortableForm>>, ) -> Result<Self> { - if let scale_info::TypeDef::Variant(calls_enum) = scale_type_def { - Ok(Self { - index, - name, - calls: calls_enum.variants.iter().map(Into::into).collect(), - }) + let calls = if let Some(call_scale_type_def) = call_scale_type_def { + if let scale_info::TypeDef::Variant(calls_enum) = call_scale_type_def { + calls_enum.variants.iter().map(Into::into).collect() + } else { + bail!("Invalid metadata") + } } else { - bail!("Invalid metadata") - } + vec![] + }; + let events = if let Some(event_scale_type_def) = event_scale_type_def { + if let scale_info::TypeDef::Variant(events_enum) = event_scale_type_def { + events_enum.variants.iter().map(Into::into).collect() + } else { + bail!("Invalid metadata") + } + } else { + vec![] + }; + Ok(Self { + index, + name, + calls, + events, + }) } } -#[derive(Clone, Serialize)] -struct Call { - documentation: String, - index: u8, - name: String, - params: Vec<CallParam>, -} - impl From<&scale_info::Variant<PortableForm>> for Call { fn from(variant: &scale_info::Variant<PortableForm>) -> Self { Self { @@ -83,13 +117,27 @@ impl From<&scale_info::Variant<PortableForm>> for Call { } } -#[derive(Clone, Serialize)] -struct CallParam { - name: String, - type_name: String, +impl From<&scale_info::Field<PortableForm>> for CallParam { + fn from(field: &scale_info::Field<PortableForm>) -> Self { + Self { + name: field.clone().name.unwrap_or_default(), + type_name: field.clone().type_name.unwrap_or_default(), + } + } } -impl From<&scale_info::Field<PortableForm>> for CallParam { +impl From<&scale_info::Variant<PortableForm>> for Event { + fn from(variant: &scale_info::Variant<PortableForm>) -> Self { + Self { + documentation: variant.docs.iter().cloned().collect::<Vec<_>>().join("\n"), + index: variant.index, + name: variant.name.to_owned(), + params: variant.fields.iter().map(Into::into).collect(), + } + } +} + +impl From<&scale_info::Field<PortableForm>> for EventParam { fn from(field: &scale_info::Field<PortableForm>) -> Self { Self { name: field.clone().name.unwrap_or_default(), @@ -149,7 +197,7 @@ impl CallCategory { } /// generate runtime calls documentation -pub(super) fn gen_calls_doc() -> Result<()> { +pub(super) fn gen_doc() -> Result<()> { // Read metadata let mut file = std::fs::File::open("resources/metadata.scale") .with_context(|| "Failed to open metadata file")?; @@ -163,49 +211,80 @@ pub(super) fn gen_calls_doc() -> Result<()> { println!("Metadata successfully loaded!"); - let runtime_calls = if let frame_metadata::RuntimeMetadata::V14(metadata_v14) = metadata.1 { - get_calls_from_metadata_v14(metadata_v14)? + let runtime = if let frame_metadata::RuntimeMetadata::V14(metadata_v14) = metadata.1 { + get_from_metadata_v14(metadata_v14)? } else { bail!("unsuported metadata version") }; - let output = print_runtime_calls(runtime_calls); + let (call_doc, event_doc) = print_runtime(runtime); let mut file = File::create(CALLS_DOC_FILEPATH) .with_context(|| format!("Failed to create file '{}'", CALLS_DOC_FILEPATH))?; - file.write_all(output.as_bytes()) + file.write_all(call_doc.as_bytes()) .with_context(|| format!("Failed to write to file '{}'", CALLS_DOC_FILEPATH))?; + let mut file = File::create(EVENTS_DOC_FILEPATH) + .with_context(|| format!("Failed to create file '{}'", EVENTS_DOC_FILEPATH))?; + file.write_all(event_doc.as_bytes()) + .with_context(|| format!("Failed to write to file '{}'", EVENTS_DOC_FILEPATH))?; Ok(()) } -fn get_calls_from_metadata_v14( +fn get_from_metadata_v14( metadata_v14: frame_metadata::v14::RuntimeMetadataV14, -) -> Result<RuntimeCalls> { +) -> Result<RuntimePallets> { println!("Number of pallets: {}", metadata_v14.pallets.len()); let mut pallets = Vec::new(); for pallet in metadata_v14.pallets { - if let Some(calls) = pallet.calls { - if let Some(calls_type) = metadata_v14.types.resolve(calls.ty.id) { - let pallet = Pallet::new(pallet.index, pallet.name.clone(), &calls_type.type_def)?; - let calls_len = pallet.calls.len(); - println!("{}: {} ({} calls)", pallet.index, pallet.name, calls_len); - pallets.push(pallet); - } else { + let calls_type_def = if let Some(calls) = pallet.calls { + let Some(calls_type) = metadata_v14.types.resolve(calls.ty.id) else { bail!("Invalid metadata") - } + }; + Some(calls_type.type_def.clone()) } else { println!("{}: {} (0 calls)", pallet.index, pallet.name); - } + None + }; + let events_type_def = if let Some(events) = pallet.event { + let Some(events_type) = metadata_v14.types.resolve(events.ty.id) else { + bail!("Invalid metadata") + }; + Some(events_type.type_def.clone()) + } else { + println!("{}: {} (0 events)", pallet.index, pallet.name); + None + }; + + let pallet = Pallet::new( + pallet.index, + pallet.name.clone(), + &calls_type_def, + &events_type_def, + )?; + + println!( + "{}: {} ({} calls)", + pallet.index, + pallet.name, + pallet.calls.len() + ); + println!( + "{}: {} ({} events)", + pallet.index, + pallet.name, + pallet.events.len() + ); + pallets.push(pallet); } Ok(pallets) } /// use template to render markdown file with runtime calls documentation -fn print_runtime_calls(pallets: RuntimeCalls) -> String { +fn print_runtime(pallets: RuntimePallets) -> (String, String) { // init variables let mut user_calls_counter = 0; - let user_calls_pallets: RuntimeCalls = pallets + let user_calls_pallets: RuntimePallets = pallets .iter() .cloned() .filter_map(|mut pallet| { @@ -222,7 +301,7 @@ fn print_runtime_calls(pallets: RuntimeCalls) -> String { }) .collect(); let mut root_calls_counter = 0; - let root_calls_pallets: RuntimeCalls = pallets + let root_calls_pallets: RuntimePallets = pallets .iter() .cloned() .filter_map(|mut pallet| { @@ -239,7 +318,7 @@ fn print_runtime_calls(pallets: RuntimeCalls) -> String { }) .collect(); let mut disabled_calls_counter = 0; - let disabled_calls_pallets: RuntimeCalls = pallets + let disabled_calls_pallets: RuntimePallets = pallets .iter() .cloned() .filter_map(|mut pallet| { @@ -265,7 +344,7 @@ fn print_runtime_calls(pallets: RuntimeCalls) -> String { } }; - // fills tera context for rendering + // fills tera context for rendering calls let mut context = tera::Context::new(); context.insert("user_calls_counter", &user_calls_counter); context.insert("user_calls_pallets", &user_calls_pallets); @@ -274,6 +353,16 @@ fn print_runtime_calls(pallets: RuntimeCalls) -> String { context.insert("disabled_calls_counter", &disabled_calls_counter); context.insert("disabled_calls_pallets", &disabled_calls_pallets); - tera.render("runtime-calls.md", &context) - .expect("template error") + let call_doc = tera + .render("runtime-calls.md", &context) + .expect("template error"); + + // render events + + context.insert("pallets", &pallets); + let event_doc = tera + .render("runtime-events.md", &context) + .expect("template error"); + + (call_doc, event_doc) } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index e29fbe9ae66604c62731d4ea12ce05e8c097e1c7..331bab7a9edb1333687885206eb2fd0d5ce34371 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -mod gen_calls_doc; +mod gen_doc; mod release_runtime; use anyhow::{Context, Result}; @@ -38,8 +38,8 @@ enum DuniterXTaskCommand { #[clap(long)] production: bool, }, - /// Generate calls documentation - GenCallsDoc, + /// Generate documentation (calls and events) + GenDoc, /// Inject runtime code in raw specs InjectRuntimeCode { #[clap(short, long)] @@ -82,7 +82,7 @@ async fn main() -> Result<()> { match args.command { DuniterXTaskCommand::Build { production } => build(production), - DuniterXTaskCommand::GenCallsDoc => gen_calls_doc::gen_calls_doc(), + DuniterXTaskCommand::GenDoc => gen_doc::gen_doc(), DuniterXTaskCommand::InjectRuntimeCode { runtime, raw_spec } => { inject_runtime_code(&raw_spec, &runtime) }