Skip to content

Commit

Permalink
Support for BeefyApi v4
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Aug 5, 2024
1 parent 15c440d commit a24af20
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
26 changes: 25 additions & 1 deletion packages/api-augment/src/substrate/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { Bytes, Null, Option, Result, U64, Vec, bool, u128, u32 } from '@po
import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types';
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
import type { BabeEquivocationProof, BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe';
import type { ValidatorSet, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
import type { CheckInherentsResult, InherentData } from '@polkadot/types/interfaces/blockbuilder';
import type { BlockHash } from '@polkadot/types/interfaces/chain';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
Expand All @@ -28,7 +29,7 @@ import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
import type { StatementStoreInvalidStatement, StatementStoreStatementSource, StatementStoreValidStatement } from '@polkadot/types/interfaces/statement';
import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces/system';
import type { TransactionSource, TransactionValidity } from '@polkadot/types/interfaces/txqueue';
import type { SpStatementStoreStatement, StagingXcmV3MultiLocation } from '@polkadot/types/lookup';
import type { SpConsensusBeefyDoubleVotingProof, SpStatementStoreStatement, StagingXcmV3MultiLocation } from '@polkadot/types/lookup';
import type { IExtrinsic, Observable } from '@polkadot/types/types';

export type __AugmentedCall<ApiType extends ApiTypes> = AugmentedCall<ApiType>;
Expand Down Expand Up @@ -119,6 +120,29 @@ declare module '@polkadot/api-base/types/calls' {
**/
[key: string]: DecoratedCallBase<ApiType>;
};
/** 0x49eaaf1b548a0cb0/4 */
beefyApi: {
/**
* Return the block number where BEEFY consensus is enabled/started
**/
beefyGenesis: AugmentedCall<ApiType, () => Observable<Option<BlockNumber>>>;
/**
* Generates a proof of key ownership for the given authority in the given set.
**/
generateKeyOwnershipProof: AugmentedCall<ApiType, (setId: ValidatorSetId | AnyNumber | Uint8Array, authorityId: AuthorityId | string | Uint8Array) => Observable<Option<OpaqueKeyOwnershipProof>>>;
/**
* Submits an unsigned extrinsic to report a double voting equivocation.
**/
submitReportDoubleVotingUnsignedExtrinsic: AugmentedCall<ApiType, (equivocationProof: SpConsensusBeefyDoubleVotingProof | { first?: any; second?: any } | string | Uint8Array, keyOwnerProof: OpaqueKeyOwnershipProof | string | Uint8Array) => Observable<Option<Null>>>;
/**
* Return the current active BEEFY validator set
**/
validatorSet: AugmentedCall<ApiType, () => Observable<Option<ValidatorSet>>>;
/**
* Generic call
**/
[key: string]: DecoratedCallBase<ApiType>;
};
/** 0x40fe3ad401f8959a/6 */
blockBuilder: {
/**
Expand Down
38 changes: 32 additions & 6 deletions packages/types/src/interfaces/beefy/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import type { DefinitionCall, DefinitionsCall } from '../../types/index.js';

const BEEFY_V1_V3: Record<string, DefinitionCall> = {
const BEEFY_V3: Record<string, DefinitionCall> = {
beefy_genesis: {
description: 'Return the block number where BEEFY consensus is enabled/started',
params: [],
Expand All @@ -23,6 +23,15 @@ const BEEFY_V1_V3: Record<string, DefinitionCall> = {
],
type: 'Option<OpaqueKeyOwnershipProof>'
},
validator_set: {
description: 'Return the current active BEEFY validator set',
params: [],
type: 'Option<ValidatorSet>'
}
};

const BEEFY_V1_V3: Record<string, DefinitionCall> = {
...BEEFY_V3,
submit_report_equivocation_unsigned_extrinsic: {
description: 'Submits an unsigned extrinsic to report an equivocation.',
params: [
Expand All @@ -36,11 +45,24 @@ const BEEFY_V1_V3: Record<string, DefinitionCall> = {
}
],
type: 'Option<Null>'
},
validator_set: {
description: 'Return the current active BEEFY validator set',
params: [],
type: 'Option<ValidatorSet>'
}
};

const BEEFY_V4: Record<string, DefinitionCall> = {
...BEEFY_V3,
submit_report_double_voting_unsigned_extrinsic: {
description: 'Submits an unsigned extrinsic to report a double voting equivocation.',
params: [
{
name: 'equivocationProof',
type: 'SpConsensusBeefyDoubleVotingProof'
},
{
name: 'keyOwnerProof',
type: 'OpaqueKeyOwnershipProof'
}
],
type: 'Option<Null>'
}
};

Expand All @@ -59,6 +81,10 @@ const BEEFY_MMR_V1: Record<string, DefinitionCall> = {

export const runtime: DefinitionsCall = {
BeefyApi: [
{
methods: BEEFY_V4,
version: 4
},
{
methods: BEEFY_V1_V3,
version: 3
Expand Down

0 comments on commit a24af20

Please sign in to comment.