Skip to content

Commit

Permalink
feat: generate node-api for polkadot-v1.10.0 and fee payer selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitdevos committed Jun 6, 2024
1 parent cd3558f commit 7b30a3b
Show file tree
Hide file tree
Showing 12 changed files with 1,452 additions and 364 deletions.
2 changes: 1 addition & 1 deletion packages/client-node/integration/Balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function checkCoinBalanceDelta(current: TypesAccountData, expectedDelta:

export function checkCoinBalance(balance: TypesAccountData, expectedValue: string) {
const formatted = formatBalance(balance);
expect(expectedValue).toEqual(formatted)
expect(formatted).toEqual(expectedValue)
}

export function formatBalance(balance: TypesAccountData): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export function buildSimpleNodeApi(): LogionNodeApiClass {
const api = {
runtimeVersion: {
specName: { toString: () => "logion" },
specVersion: { toBigInt: () => 3000n },
specVersion: { toBigInt: () => 4000n },
},
consts: {
system: {
Expand Down
2 changes: 1 addition & 1 deletion packages/node-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@logion/node-api",
"version": "0.31.0-1",
"version": "0.31.0-2",
"description": "logion API",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/node-api/src/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const EXPECTED_SPEC_NAME = "logion";

export const EXPECTED_SOLO_VERSION = 164n;

export const EXPECTED_PARA_VERSION = 3000n;
export const EXPECTED_PARA_VERSION = 4000n;

/**
* A Logion chain client. An instance of this class provides
Expand Down
42 changes: 39 additions & 3 deletions packages/node-api/src/interfaces/augment-api-consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>

declare module '@polkadot/api-base/types/consts' {
interface AugmentedConsts<ApiType extends ApiTypes> {
aura: {
/**
* The slot duration Aura should run with, expressed in milliseconds.
* The effective value of this type should not change while the chain is running.
*
* For backwards compatibility either use [`MinimumPeriodTimesTwo`] or a const.
**/
slotDuration: u64 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
balances: {
/**
* The minimum amount required to keep an account open. MUST BE GREATER THAN ZERO!
Expand All @@ -34,10 +47,14 @@ declare module '@polkadot/api-base/types/consts' {
/**
* The maximum number of locks that should exist on an account.
* Not strictly enforced, but used for weight estimation.
*
* Use of locks is deprecated in favour of freezes. See `https://github.com/paritytech/substrate/pull/12951/`
**/
maxLocks: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of named reserves that can exist on an account.
*
* Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/`
**/
maxReserves: u32 & AugmentedConst<ApiType>;
/**
Expand Down Expand Up @@ -146,6 +163,14 @@ declare module '@polkadot/api-base/types/consts' {
* size is slightly lower than this as defined by [`MaxMessageLenOf`].
**/
heapSize: u32 & AugmentedConst<ApiType>;
/**
* The maximum amount of weight (if any) to be used from remaining weight `on_idle` which
* should be provided to the message queue for servicing enqueued items `on_idle`.
* Useful for parachains to process messages at the same block they are received.
*
* If `None`, it will not call `ServiceQueues::service_queues` in `on_idle`.
**/
idleMaxServiceWeight: Option<SpWeightsWeightV2Weight> & AugmentedConst<ApiType>;
/**
* The maximum number of stale pages (i.e. of overweight messages) allowed before culling
* can happen. Once there are more stale pages than this, then historical pages may be
Expand All @@ -154,10 +179,11 @@ declare module '@polkadot/api-base/types/consts' {
maxStale: u32 & AugmentedConst<ApiType>;
/**
* The amount of weight (if any) which should be provided to the message queue for
* servicing enqueued items.
* servicing enqueued items `on_initialize`.
*
* This may be legitimately `None` in the case that you will call
* `ServiceQueues::service_queues` manually.
* `ServiceQueues::service_queues` manually or set [`Self::IdleMaxServiceWeight`] to have
* it run in `on_idle`.
**/
serviceWeight: Option<SpWeightsWeightV2Weight> & AugmentedConst<ApiType>;
/**
Expand Down Expand Up @@ -190,6 +216,16 @@ declare module '@polkadot/api-base/types/consts' {
**/
[key: string]: Codec;
};
parachainSystem: {
/**
* Returns the parachain ID we are running with.
**/
selfParaId: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
recovery: {
/**
* The base amount of currency needed to reserve for creating a recovery configuration.
Expand Down Expand Up @@ -256,7 +292,7 @@ declare module '@polkadot/api-base/types/consts' {
**/
ss58Prefix: u16 & AugmentedConst<ApiType>;
/**
* Get the chain's current version.
* Get the chain's in-code version.
**/
version: SpVersionRuntimeVersion & AugmentedConst<ApiType>;
/**
Expand Down
13 changes: 13 additions & 0 deletions packages/node-api/src/interfaces/augment-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,10 @@ declare module '@polkadot/api-base/types/errors' {
* Too many assets with different reserve locations have been attempted for transfer.
**/
TooManyReserves: AugmentedError<ApiType>;
/**
* Could not decode XCM.
**/
UnableToDecode: AugmentedError<ApiType>;
/**
* The desired destination was unreachable, generally because there is a no way of routing
* to it.
Expand All @@ -783,6 +787,11 @@ declare module '@polkadot/api-base/types/errors' {
* The message's weight could not be determined.
**/
UnweighableMessage: AugmentedError<ApiType>;
/**
* XCM encoded length is too large.
* Returned when an XCM encoded length is larger than `MaxXcmEncodedSize`.
**/
XcmTooLarge: AugmentedError<ApiType>;
/**
* Generic error
**/
Expand Down Expand Up @@ -910,6 +919,10 @@ declare module '@polkadot/api-base/types/errors' {
* and the new runtime.
**/
InvalidSpecName: AugmentedError<ApiType>;
/**
* A multi-block migration is ongoing and prevents the current code from being replaced.
**/
MultiBlockMigrationsOngoing: AugmentedError<ApiType>;
/**
* Suicide called when the account has non-default composite data.
**/
Expand Down
18 changes: 13 additions & 5 deletions packages/node-api/src/interfaces/augment-api-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { ApiTypes, AugmentedQuery, QueryableStorageEntry } from '@polkadot/
import type { BTreeMap, BTreeSet, Bytes, Null, Option, Struct, U8aFixed, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types-codec';
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, H256 } from '@polkadot/types/interfaces/runtime';
import type { CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletParachainSystemUnincludedSegmentAncestor, CumulusPalletParachainSystemUnincludedSegmentSegmentTracker, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesCoreAggregateMessageOrigin, FrameSupportDispatchPerDispatchClassWeight, FrameSystemAccountInfo, FrameSystemCodeUpgradeAuthorization, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, LogionRuntimeRuntimeHoldReason, LogionRuntimeSessionKeys, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesIdAmount, PalletBalancesReserveData, PalletCollatorSelectionCandidateInfo, PalletLoAuthorityListLegalOfficerData, PalletLoAuthorityListStorageVersion, PalletLogionLocCollectionItem, PalletLogionLocLegalOfficerCase, PalletLogionLocSponsorship, PalletLogionLocStorageVersion, PalletLogionLocTokensRecord, PalletLogionLocVerifiedIssuer, PalletLogionVoteVote, PalletMessageQueueBookState, PalletMessageQueuePage, PalletMultisigMultisig, PalletRecoveryActiveRecovery, PalletRecoveryRecoveryConfig, PalletTransactionPaymentReleases, PalletTreasuryProposal, PalletTreasurySpendStatus, PalletVestingReleases, PalletVestingVestingInfo, PalletXcmQueryStatus, PalletXcmRemoteLockedFungibleRecord, PalletXcmVersionMigrationStage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV6AbridgedHostConfiguration, PolkadotPrimitivesV6PersistedValidationData, PolkadotPrimitivesV6UpgradeGoAhead, PolkadotPrimitivesV6UpgradeRestriction, SpConsensusAuraSr25519AppSr25519Public, SpCoreCryptoKeyTypeId, SpRuntimeDigest, SpTrieStorageProof, SpWeightsWeightV2Weight, XcmVersionedAssetId, XcmVersionedLocation } from '@polkadot/types/lookup';
import type { CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletParachainSystemUnincludedSegmentAncestor, CumulusPalletParachainSystemUnincludedSegmentSegmentTracker, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesCoreAggregateMessageOrigin, FrameSupportDispatchPerDispatchClassWeight, FrameSystemAccountInfo, FrameSystemCodeUpgradeAuthorization, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, LogionRuntimeRuntimeHoldReason, LogionRuntimeSessionKeys, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesIdAmount, PalletBalancesReserveData, PalletCollatorSelectionCandidateInfo, PalletLoAuthorityListLegalOfficerData, PalletLoAuthorityListStorageVersion, PalletLogionLocCollectionItem, PalletLogionLocLegalOfficerCase, PalletLogionLocSponsorship, PalletLogionLocStorageVersion, PalletLogionLocTokensRecord, PalletLogionLocVerifiedIssuer, PalletLogionVoteVote, PalletMessageQueueBookState, PalletMessageQueuePage, PalletMultisigMultisig, PalletRecoveryActiveRecovery, PalletRecoveryRecoveryConfig, PalletTransactionPaymentReleases, PalletTreasuryProposal, PalletTreasurySpendStatus, PalletVestingReleases, PalletVestingVestingInfo, PalletXcmQueryStatus, PalletXcmRemoteLockedFungibleRecord, PalletXcmVersionMigrationStage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV7AbridgedHostConfiguration, PolkadotPrimitivesV7PersistedValidationData, PolkadotPrimitivesV7UpgradeGoAhead, PolkadotPrimitivesV7UpgradeRestriction, SpConsensusAuraSr25519AppSr25519Public, SpCoreCryptoKeyTypeId, SpRuntimeDigest, SpTrieStorageProof, SpWeightsWeightV2Weight, XcmVersionedAssetId, XcmVersionedLocation } from '@polkadot/types/lookup';
import type { Observable } from '@polkadot/types/types';

export type __AugmentedQuery<ApiType extends ApiTypes> = AugmentedQuery<ApiType, () => unknown>;
Expand Down Expand Up @@ -109,10 +109,14 @@ declare module '@polkadot/api-base/types/storage' {
/**
* Any liquidity locks on some account balances.
* NOTE: Should only be accessed when setting, changing and freeing a lock.
*
* Use of locks is deprecated in favour of freezes. See `https://github.com/paritytech/substrate/pull/12951/`
**/
locks: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Vec<PalletBalancesBalanceLock>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
/**
* Named reserves on some account balances.
*
* Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/`
**/
reserves: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Vec<PalletBalancesReserveData>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
/**
Expand Down Expand Up @@ -351,7 +355,7 @@ declare module '@polkadot/api-base/types/storage' {
*
* This data is also absent from the genesis.
**/
hostConfiguration: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV6AbridgedHostConfiguration>>, []> & QueryableStorageEntry<ApiType, []>;
hostConfiguration: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV7AbridgedHostConfiguration>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* HRMP messages that were sent in a block.
*
Expand Down Expand Up @@ -456,7 +460,7 @@ declare module '@polkadot/api-base/types/storage' {
* relay-chain. This value is ephemeral which means it doesn't hit the storage. This value is
* set after the inherent.
**/
upgradeGoAhead: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV6UpgradeGoAhead>>, []> & QueryableStorageEntry<ApiType, []>;
upgradeGoAhead: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV7UpgradeGoAhead>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* An option which indicates if the relay-chain restricts signalling a validation code upgrade.
* In other words, if this is `Some` and [`NewValidationCode`] is `Some` then the produced
Expand All @@ -466,7 +470,7 @@ declare module '@polkadot/api-base/types/storage' {
* relay-chain. This value is ephemeral which means it doesn't hit the storage. This value is
* set after the inherent.
**/
upgradeRestrictionSignal: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV6UpgradeRestriction>>, []> & QueryableStorageEntry<ApiType, []>;
upgradeRestrictionSignal: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV7UpgradeRestriction>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The factor to multiply the base delivery fee by for UMP.
**/
Expand All @@ -482,7 +486,7 @@ declare module '@polkadot/api-base/types/storage' {
* This value is expected to be set only once per block and it's never stored
* in the trie.
**/
validationData: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV6PersistedValidationData>>, []> & QueryableStorageEntry<ApiType, []>;
validationData: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV7PersistedValidationData>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
**/
Expand Down Expand Up @@ -686,6 +690,10 @@ declare module '@polkadot/api-base/types/storage' {
* Extrinsics data for the current block (maps an extrinsic's index to its data).
**/
extrinsicData: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Bytes>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
/**
* Whether all inherents have been applied.
**/
inherentsApplied: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened.
**/
Expand Down
6 changes: 3 additions & 3 deletions packages/node-api/src/interfaces/augment-api-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
import type { GenesisBuildErr } from '@polkadot/types/interfaces/genesisBuilder';
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { AccountId, Balance, Block, Call, Header, Index, KeyTypeId, SlotDuration, Weight } from '@polkadot/types/interfaces/runtime';
import type { AccountId, Balance, Block, Call, ExtrinsicInclusionMode, Header, Index, KeyTypeId, SlotDuration, Weight } 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 @@ -88,7 +88,7 @@ declare module '@polkadot/api-base/types/calls' {
**/
[key: string]: DecoratedCallBase<ApiType>;
};
/** 0xdf6acb689907609b/4 */
/** 0xdf6acb689907609b/5 */
core: {
/**
* Execute the given block.
Expand All @@ -97,7 +97,7 @@ declare module '@polkadot/api-base/types/calls' {
/**
* Initialize a block with the given header.
**/
initializeBlock: AugmentedCall<ApiType, (header: Header | { parentHash?: any; number?: any; stateRoot?: any; extrinsicsRoot?: any; digest?: any } | string | Uint8Array) => Observable<Null>>;
initializeBlock: AugmentedCall<ApiType, (header: Header | { parentHash?: any; number?: any; stateRoot?: any; extrinsicsRoot?: any; digest?: any } | string | Uint8Array) => Observable<ExtrinsicInclusionMode>>;
/**
* Returns the version of the runtime.
**/
Expand Down
Loading

0 comments on commit 7b30a3b

Please sign in to comment.