Skip to content

Commit

Permalink
add back v1 of MmrApi
Browse files Browse the repository at this point in the history
  • Loading branch information
Lederstrumpf committed Mar 19, 2023
1 parent 239c6f8 commit ef96d1f
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 22 deletions.
26 changes: 19 additions & 7 deletions packages/api-augment/src/kusama/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
import type { AuthorityList, GrandpaEquivocationProof, SetId } from '@polkadot/types/interfaces/grandpa';
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError } from '@polkadot/types/interfaces/mmr';
import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError, MmrLeafIndex, MmrProof } from '@polkadot/types/interfaces/mmr';
import type { CandidateCommitments, CandidateEvent, CommittedCandidateReceipt, CoreState, GroupRotationInfo, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, ParaId, ParaValidatorIndex, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorSignature } from '@polkadot/types/interfaces/parachains';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { AccountId, Balance, Block, BlockNumber, Call, Hash, Header, Index, KeyTypeId, Slot, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
import type { AccountId, Balance, Block, Call, Hash, Header, Index, KeyTypeId, Slot, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
import type { SessionIndex } from '@polkadot/types/interfaces/session';
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces/system';
Expand Down Expand Up @@ -174,21 +174,33 @@ declare module '@polkadot/api-base/types/calls' {
/** 0x91d5df18b0d2cf58/1 */
mmrApi: {
/**
* Generate MMR proof for the given block numbers.
* Generate MMR proof for a series of leaves under given indices.
**/
generateProof: AugmentedCall<ApiType, (blockNumbers: Vec<BlockNumber> | (BlockNumber | AnyNumber | Uint8Array)[], bestKnownBlockNumber: Option<BlockNumber> | null | Uint8Array | BlockNumber | AnyNumber) => Observable<Result<ITuple<[Vec<MmrEncodableOpaqueLeaf>, MmrBatchProof]>, MmrError>>>;
generateBatchProof: AugmentedCall<ApiType, (leafIndices: Vec<MmrLeafIndex> | (MmrLeafIndex | AnyNumber | Uint8Array)[]) => Observable<Result<ITuple<[Vec<MmrEncodableOpaqueLeaf>, MmrBatchProof]>, MmrError>>>;
/**
* Generate MMR proof for a leaf under given index.
**/
generateProof: AugmentedCall<ApiType, (leafIndex: MmrLeafIndex | AnyNumber | Uint8Array) => Observable<Result<ITuple<[MmrEncodableOpaqueLeaf, MmrProof]>, MmrError>>>;
/**
* Return the on-chain MMR root hash.
**/
root: AugmentedCall<ApiType, () => Observable<Result<Hash, MmrError>>>;
mmrRoot: AugmentedCall<ApiType, () => Observable<Result<Hash, MmrError>>>;
/**
* Verify MMR proof against on-chain MMR for a batch of leaves.
**/
verifyBatchProof: AugmentedCall<ApiType, (leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against given root hash or a batch of leaves.
**/
verifyBatchProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against on-chain MMR.
**/
verifyProof: AugmentedCall<ApiType, (leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
verifyProof: AugmentedCall<ApiType, (leaf: MmrEncodableOpaqueLeaf | string | Uint8Array, proof: MmrProof | { leafIndex?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against given root hash.
**/
verifyProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
verifyProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaf: MmrEncodableOpaqueLeaf | string | Uint8Array, proof: MmrProof | { leafIndex?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Generic call
**/
Expand Down
26 changes: 19 additions & 7 deletions packages/api-augment/src/polkadot/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
import type { AuthorityList, GrandpaEquivocationProof, SetId } from '@polkadot/types/interfaces/grandpa';
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError } from '@polkadot/types/interfaces/mmr';
import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError, MmrLeafIndex, MmrProof } from '@polkadot/types/interfaces/mmr';
import type { CandidateCommitments, CandidateEvent, CommittedCandidateReceipt, CoreState, GroupRotationInfo, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, ParaId, ParaValidatorIndex, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorSignature } from '@polkadot/types/interfaces/parachains';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { AccountId, Balance, Block, BlockNumber, Call, Hash, Header, Index, KeyTypeId, Slot, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
import type { AccountId, Balance, Block, Call, Hash, Header, Index, KeyTypeId, Slot, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
import type { SessionIndex } from '@polkadot/types/interfaces/session';
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces/system';
Expand Down Expand Up @@ -174,21 +174,33 @@ declare module '@polkadot/api-base/types/calls' {
/** 0x91d5df18b0d2cf58/1 */
mmrApi: {
/**
* Generate MMR proof for the given block numbers.
* Generate MMR proof for a series of leaves under given indices.
**/
generateProof: AugmentedCall<ApiType, (blockNumbers: Vec<BlockNumber> | (BlockNumber | AnyNumber | Uint8Array)[], bestKnownBlockNumber: Option<BlockNumber> | null | Uint8Array | BlockNumber | AnyNumber) => Observable<Result<ITuple<[Vec<MmrEncodableOpaqueLeaf>, MmrBatchProof]>, MmrError>>>;
generateBatchProof: AugmentedCall<ApiType, (leafIndices: Vec<MmrLeafIndex> | (MmrLeafIndex | AnyNumber | Uint8Array)[]) => Observable<Result<ITuple<[Vec<MmrEncodableOpaqueLeaf>, MmrBatchProof]>, MmrError>>>;
/**
* Generate MMR proof for a leaf under given index.
**/
generateProof: AugmentedCall<ApiType, (leafIndex: MmrLeafIndex | AnyNumber | Uint8Array) => Observable<Result<ITuple<[MmrEncodableOpaqueLeaf, MmrProof]>, MmrError>>>;
/**
* Return the on-chain MMR root hash.
**/
root: AugmentedCall<ApiType, () => Observable<Result<Hash, MmrError>>>;
mmrRoot: AugmentedCall<ApiType, () => Observable<Result<Hash, MmrError>>>;
/**
* Verify MMR proof against on-chain MMR for a batch of leaves.
**/
verifyBatchProof: AugmentedCall<ApiType, (leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against given root hash or a batch of leaves.
**/
verifyBatchProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against on-chain MMR.
**/
verifyProof: AugmentedCall<ApiType, (leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
verifyProof: AugmentedCall<ApiType, (leaf: MmrEncodableOpaqueLeaf | string | Uint8Array, proof: MmrProof | { leafIndex?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against given root hash.
**/
verifyProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
verifyProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaf: MmrEncodableOpaqueLeaf | string | Uint8Array, proof: MmrProof | { leafIndex?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Generic call
**/
Expand Down
26 changes: 19 additions & 7 deletions packages/api-augment/src/substrate/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import type { CodeSource, CodeUploadResult, ContractExecResult, ContractInstanti
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
import type { AuthorityList, GrandpaEquivocationProof, SetId } from '@polkadot/types/interfaces/grandpa';
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError } from '@polkadot/types/interfaces/mmr';
import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError, MmrLeafIndex, MmrProof } from '@polkadot/types/interfaces/mmr';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { AccountId, Balance, Block, BlockNumber, Call, Hash, Header, Index, KeyTypeId, Slot, Weight, WeightV2 } from '@polkadot/types/interfaces/runtime';
import type { AccountId, Balance, Block, Call, Hash, Header, Index, KeyTypeId, Slot, Weight, WeightV2 } from '@polkadot/types/interfaces/runtime';
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces/system';
import type { TransactionSource, TransactionValidity } from '@polkadot/types/interfaces/txqueue';
Expand Down Expand Up @@ -184,21 +184,33 @@ declare module '@polkadot/api-base/types/calls' {
/** 0x91d5df18b0d2cf58/1 */
mmrApi: {
/**
* Generate MMR proof for the given block numbers.
* Generate MMR proof for a series of leaves under given indices.
**/
generateProof: AugmentedCall<ApiType, (blockNumbers: Vec<BlockNumber> | (BlockNumber | AnyNumber | Uint8Array)[], bestKnownBlockNumber: Option<BlockNumber> | null | Uint8Array | BlockNumber | AnyNumber) => Observable<Result<ITuple<[Vec<MmrEncodableOpaqueLeaf>, MmrBatchProof]>, MmrError>>>;
generateBatchProof: AugmentedCall<ApiType, (leafIndices: Vec<MmrLeafIndex> | (MmrLeafIndex | AnyNumber | Uint8Array)[]) => Observable<Result<ITuple<[Vec<MmrEncodableOpaqueLeaf>, MmrBatchProof]>, MmrError>>>;
/**
* Generate MMR proof for a leaf under given index.
**/
generateProof: AugmentedCall<ApiType, (leafIndex: MmrLeafIndex | AnyNumber | Uint8Array) => Observable<Result<ITuple<[MmrEncodableOpaqueLeaf, MmrProof]>, MmrError>>>;
/**
* Return the on-chain MMR root hash.
**/
root: AugmentedCall<ApiType, () => Observable<Result<Hash, MmrError>>>;
mmrRoot: AugmentedCall<ApiType, () => Observable<Result<Hash, MmrError>>>;
/**
* Verify MMR proof against on-chain MMR for a batch of leaves.
**/
verifyBatchProof: AugmentedCall<ApiType, (leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against given root hash or a batch of leaves.
**/
verifyBatchProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against on-chain MMR.
**/
verifyProof: AugmentedCall<ApiType, (leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
verifyProof: AugmentedCall<ApiType, (leaf: MmrEncodableOpaqueLeaf | string | Uint8Array, proof: MmrProof | { leafIndex?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Verify MMR proof against given root hash.
**/
verifyProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaves: Vec<MmrEncodableOpaqueLeaf> | (MmrEncodableOpaqueLeaf | string | Uint8Array)[], proof: MmrBatchProof | { leafIndices?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
verifyProofStateless: AugmentedCall<ApiType, (root: Hash | string | Uint8Array, leaf: MmrEncodableOpaqueLeaf | string | Uint8Array, proof: MmrProof | { leafIndex?: any; leafCount?: any; items?: any } | string | Uint8Array) => Observable<Result<ITuple<[]>, MmrError>>>;
/**
* Generic call
**/
Expand Down
96 changes: 95 additions & 1 deletion packages/types/src/interfaces/mmr/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,100 @@ import type { DefinitionsCall } from '../../types';

export const runtime: DefinitionsCall = {
MmrApi: [
{
methods: {
generate_batch_proof: {
description: 'Generate MMR proof for a series of leaves under given indices.',
params: [
{
name: 'leafIndices',
type: 'Vec<MmrLeafIndex>'
}
],
type: 'Result<(Vec<MmrEncodableOpaqueLeaf>, MmrBatchProof), MmrError>'
},
generate_proof: {
description: 'Generate MMR proof for a leaf under given index.',
params: [
{
name: 'leafIndex',
type: 'MmrLeafIndex'
}
],
type: 'Result<(MmrEncodableOpaqueLeaf, MmrProof), MmrError>'
},
mmr_root: {
description: 'Return the on-chain MMR root hash.',
params: [],
type: 'Result<Hash, MmrError>'
},
verify_batch_proof: {
description: 'Verify MMR proof against on-chain MMR for a batch of leaves.',
params: [
{
name: 'leaves',
type: 'Vec<MmrEncodableOpaqueLeaf>'
},
{
name: 'proof',
type: 'MmrBatchProof'
}
],
type: 'Result<(), MmrError>'
},
verify_batch_proof_stateless: {
description: 'Verify MMR proof against given root hash or a batch of leaves.',
params: [
{
name: 'root',
type: 'Hash'
},
{
name: 'leaves',
type: 'Vec<MmrEncodableOpaqueLeaf>'
},
{
name: 'proof',
type: 'MmrBatchProof'
}
],
type: 'Result<(), MmrError>'
},
verify_proof: {
description: 'Verify MMR proof against on-chain MMR.',
params: [
{
name: 'leaf',
type: 'MmrEncodableOpaqueLeaf'
},
{
name: 'proof',
type: 'MmrProof'
}
],
type: 'Result<(), MmrError>'
},
verify_proof_stateless: {
description: 'Verify MMR proof against given root hash.',
params: [
{
name: 'root',
type: 'Hash'
},
{
name: 'leaf',
type: 'MmrEncodableOpaqueLeaf'
},
{
name: 'proof',
type: 'MmrProof'
}
],
type: 'Result<(), MmrError>'
}
},
version: 1
},
{
methods: {
generate_proof: {
Expand Down Expand Up @@ -59,7 +153,7 @@ export const runtime: DefinitionsCall = {
type: 'Result<(), MmrError>'
},
},
version: 1
version: 2
}
]
};

0 comments on commit ef96d1f

Please sign in to comment.