Skip to content

Commit cf26e34

Browse files
authored
Support for BeefyApi v4 (#5950)
1 parent 15c440d commit cf26e34

File tree

2 files changed

+57
-7
lines changed

2 files changed

+57
-7
lines changed

packages/api-augment/src/substrate/runtime.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { Bytes, Null, Option, Result, U64, Vec, bool, u128, u32 } from '@po
1010
import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types';
1111
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
1212
import type { BabeEquivocationProof, BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe';
13+
import type { ValidatorSet, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
1314
import type { CheckInherentsResult, InherentData } from '@polkadot/types/interfaces/blockbuilder';
1415
import type { BlockHash } from '@polkadot/types/interfaces/chain';
1516
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
@@ -28,7 +29,7 @@ import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
2829
import type { StatementStoreInvalidStatement, StatementStoreStatementSource, StatementStoreValidStatement } from '@polkadot/types/interfaces/statement';
2930
import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces/system';
3031
import type { TransactionSource, TransactionValidity } from '@polkadot/types/interfaces/txqueue';
31-
import type { SpStatementStoreStatement, StagingXcmV3MultiLocation } from '@polkadot/types/lookup';
32+
import type { SpConsensusBeefyDoubleVotingProof, SpStatementStoreStatement, StagingXcmV3MultiLocation } from '@polkadot/types/lookup';
3233
import type { IExtrinsic, Observable } from '@polkadot/types/types';
3334

3435
export type __AugmentedCall<ApiType extends ApiTypes> = AugmentedCall<ApiType>;
@@ -119,6 +120,29 @@ declare module '@polkadot/api-base/types/calls' {
119120
**/
120121
[key: string]: DecoratedCallBase<ApiType>;
121122
};
123+
/** 0x49eaaf1b548a0cb0/4 */
124+
beefyApi: {
125+
/**
126+
* Return the block number where BEEFY consensus is enabled/started
127+
**/
128+
beefyGenesis: AugmentedCall<ApiType, () => Observable<Option<BlockNumber>>>;
129+
/**
130+
* Generates a proof of key ownership for the given authority in the given set.
131+
**/
132+
generateKeyOwnershipProof: AugmentedCall<ApiType, (setId: ValidatorSetId | AnyNumber | Uint8Array, authorityId: AuthorityId | string | Uint8Array) => Observable<Option<OpaqueKeyOwnershipProof>>>;
133+
/**
134+
* Submits an unsigned extrinsic to report a double voting equivocation.
135+
**/
136+
submitReportDoubleVotingUnsignedExtrinsic: AugmentedCall<ApiType, (equivocationProof: SpConsensusBeefyDoubleVotingProof | { first?: any; second?: any } | string | Uint8Array, keyOwnerProof: OpaqueKeyOwnershipProof | string | Uint8Array) => Observable<Option<Null>>>;
137+
/**
138+
* Return the current active BEEFY validator set
139+
**/
140+
validatorSet: AugmentedCall<ApiType, () => Observable<Option<ValidatorSet>>>;
141+
/**
142+
* Generic call
143+
**/
144+
[key: string]: DecoratedCallBase<ApiType>;
145+
};
122146
/** 0x40fe3ad401f8959a/6 */
123147
blockBuilder: {
124148
/**

packages/types/src/interfaces/beefy/runtime.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

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

6-
const BEEFY_V1_V3: Record<string, DefinitionCall> = {
6+
const BEEFY_V3: Record<string, DefinitionCall> = {
77
beefy_genesis: {
88
description: 'Return the block number where BEEFY consensus is enabled/started',
99
params: [],
@@ -23,6 +23,15 @@ const BEEFY_V1_V3: Record<string, DefinitionCall> = {
2323
],
2424
type: 'Option<OpaqueKeyOwnershipProof>'
2525
},
26+
validator_set: {
27+
description: 'Return the current active BEEFY validator set',
28+
params: [],
29+
type: 'Option<ValidatorSet>'
30+
}
31+
};
32+
33+
const BEEFY_V1_V3: Record<string, DefinitionCall> = {
34+
...BEEFY_V3,
2635
submit_report_equivocation_unsigned_extrinsic: {
2736
description: 'Submits an unsigned extrinsic to report an equivocation.',
2837
params: [
@@ -36,11 +45,24 @@ const BEEFY_V1_V3: Record<string, DefinitionCall> = {
3645
}
3746
],
3847
type: 'Option<Null>'
39-
},
40-
validator_set: {
41-
description: 'Return the current active BEEFY validator set',
42-
params: [],
43-
type: 'Option<ValidatorSet>'
48+
}
49+
};
50+
51+
const BEEFY_V4: Record<string, DefinitionCall> = {
52+
...BEEFY_V3,
53+
submit_report_double_voting_unsigned_extrinsic: {
54+
description: 'Submits an unsigned extrinsic to report a double voting equivocation.',
55+
params: [
56+
{
57+
name: 'equivocationProof',
58+
type: 'SpConsensusBeefyDoubleVotingProof'
59+
},
60+
{
61+
name: 'keyOwnerProof',
62+
type: 'OpaqueKeyOwnershipProof'
63+
}
64+
],
65+
type: 'Option<Null>'
4466
}
4567
};
4668

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

6082
export const runtime: DefinitionsCall = {
6183
BeefyApi: [
84+
{
85+
methods: BEEFY_V4,
86+
version: 4
87+
},
6288
{
6389
methods: BEEFY_V1_V3,
6490
version: 3

0 commit comments

Comments
 (0)