Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply AssetHub type gen to augmentations #6023

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
591 changes: 591 additions & 0 deletions packages/api-augment/src/assetHubKusama/consts.ts

Large diffs are not rendered by default.

1,236 changes: 1,236 additions & 0 deletions packages/api-augment/src/assetHubKusama/errors.ts

Large diffs are not rendered by default.

1,200 changes: 1,200 additions & 0 deletions packages/api-augment/src/assetHubKusama/events.ts

Large diffs are not rendered by default.

964 changes: 964 additions & 0 deletions packages/api-augment/src/assetHubKusama/query.ts

Large diffs are not rendered by default.

313 changes: 313 additions & 0 deletions packages/api-augment/src/assetHubKusama/runtime.ts

Large diffs are not rendered by default.

3,941 changes: 3,941 additions & 0 deletions packages/api-augment/src/assetHubKusama/tx.ts

Large diffs are not rendered by default.

564 changes: 564 additions & 0 deletions packages/api-augment/src/assetHubPolkadot/consts.ts

Large diffs are not rendered by default.

1,214 changes: 1,214 additions & 0 deletions packages/api-augment/src/assetHubPolkadot/errors.ts

Large diffs are not rendered by default.

1,186 changes: 1,186 additions & 0 deletions packages/api-augment/src/assetHubPolkadot/events.ts

Large diffs are not rendered by default.

954 changes: 954 additions & 0 deletions packages/api-augment/src/assetHubPolkadot/query.ts

Large diffs are not rendered by default.

313 changes: 313 additions & 0 deletions packages/api-augment/src/assetHubPolkadot/runtime.ts

Large diffs are not rendered by default.

3,896 changes: 3,896 additions & 0 deletions packages/api-augment/src/assetHubPolkadot/tx.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/api-derive/src/tx/signingInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ interface Aura {
function babeOrAuraPeriod (api: DeriveApi): BN | undefined {
const period = api.consts.babe?.expectedBlockTime ||
// this will be present ones https://github.com/paritytech/polkadot-sdk/pull/3732 is merged
(api.consts['aura'] as unknown as Aura)?.slotDuration ||
(api.consts.aura as unknown as Aura)?.slotDuration ||
api.consts.timestamp?.minimumPeriod.muln(2);

return period && period.isZero && !period.isZero() ? period : undefined;
Expand Down
6 changes: 5 additions & 1 deletion packages/typegen/src/generate/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Handlebars from 'handlebars';
import path from 'node:path';

import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import staticAssetHubKusama from '@polkadot/types-support/metadata/v15/asset-hub-kusama-hex';
import staticAssetHubPolkadot from '@polkadot/types-support/metadata/v15/asset-hub-polkadot-hex';
import staticKusama from '@polkadot/types-support/metadata/v15/kusama-hex';
import staticPolkadot from '@polkadot/types-support/metadata/v15/polkadot-hex';
import staticSubstrate from '@polkadot/types-support/metadata/v15/substrate-hex';
Expand Down Expand Up @@ -271,7 +273,9 @@ export function generateDefaultLookup (destDir = 'packages/types-augment/src/loo
: [
['substrate', staticSubstrate],
['polkadot', staticPolkadot],
['kusama', staticKusama]
['kusama', staticKusama],
['asset-hub-kusama', staticAssetHubKusama],
['asset-hub-polkadot', staticAssetHubPolkadot]
]
);
}
3 changes: 3 additions & 0 deletions packages/typegen/src/generate/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const generateCallsTypesTemplate = Handlebars.compile(readTemplate('calls'));

// This works similar to the PATHS_ALIAS set from the PortableRegistry
const aliases: Record<string, string> = {
AssetHubKusamaRuntimeRuntimeCall: 'RuntimeCall',
AssetHubPolkadotRuntimeRuntimeCall: 'RuntimeCall',
KitchensinkRuntimeRuntimeCall: 'RuntimeCall',
OpaqueValue: 'Bytes',
PolkadotParachainPrimitivesPrimitivesId: 'ParaId',
Expand All @@ -32,6 +34,7 @@ const aliases: Record<string, string> = {
PrimitiveTypesH256: 'H256',
SpConsensusBabeOpaqueKeyOwnershipProof: 'OpaqueKeyOwnershipProof',
SpConsensusSlotsSlot: 'Slot',
SpConsensusSlotsSlotDuration: 'SlotDuration',
SpCoreCryptoAccountId32: 'AccountId32',
SpCoreOpaqueMetadata: 'OpaqueMetadata',
SpRuntimeOpaqueValue: 'Bytes',
Expand Down
4 changes: 3 additions & 1 deletion packages/typegen/src/interfacesTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

import type { HexString } from '@polkadot/util/types';

import assetHubKusama from '@polkadot/types-support/metadata/v15/asset-hub-kusama-hex';
import assetHubPolkadot from '@polkadot/types-support/metadata/v15/asset-hub-polkadot-hex';
import kusama from '@polkadot/types-support/metadata/v15/kusama-hex';
import polkadot from '@polkadot/types-support/metadata/v15/polkadot-hex';
import substrate from '@polkadot/types-support/metadata/v15/substrate-hex';

import { generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultInterface, generateDefaultLookup, generateDefaultQuery, generateDefaultRpc, generateDefaultRuntime, generateDefaultTsDef, generateDefaultTx } from './generate/index.js';

const BASE = 'packages/api-augment/src';
const METAS = Object.entries<HexString>({ kusama, polkadot, substrate });
const METAS = Object.entries<HexString>({ assetHubKusama, assetHubPolkadot, kusama, polkadot, substrate });

export function main (): void {
generateDefaultInterface();
Expand Down
12 changes: 12 additions & 0 deletions packages/typegen/src/metadataMd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { Metadata, TypeRegistry, Vec } from '@polkadot/types';
import * as definitions from '@polkadot/types/interfaces/definitions';
import { getStorage as getSubstrateStorage } from '@polkadot/types/metadata/decorate/storage/getStorage';
import { unwrapStorageType } from '@polkadot/types/util';
import assetHubKusamaMeta, { rpc as assetHubKusamaRpc, version as assetHubKusamaVer } from '@polkadot/types-support/metadata/static-asset-hub-kusama';
import assetHubPolkadotMeta, { rpc as assetHubPolkadotRpc, version as assetHubPolkadotVer } from '@polkadot/types-support/metadata/static-asset-hub-polkadot';
import kusamaMeta, { rpc as kusamaRpc, version as kusamaVer } from '@polkadot/types-support/metadata/static-kusama';
import polkadotMeta, { rpc as polkadotRpc, version as polkadotVer } from '@polkadot/types-support/metadata/static-polkadot';
import substrateMeta from '@polkadot/types-support/metadata/static-substrate';
Expand Down Expand Up @@ -55,6 +57,16 @@ interface StaticDef {
const headerFn = (runtimeDesc: string) => `\n\n(NOTE: These were generated from a static/snapshot view of a recent ${runtimeDesc}. Some items may not be available in older nodes, or in any customized implementations.)`;

const ALL_STATIC: Record<string, StaticDef> = {
'asset-hub-kusama': {
meta: assetHubKusamaMeta,
rpc: assetHubKusamaRpc,
ver: assetHubKusamaVer as unknown as { apis: ApiDef[] }
},
'asset-hub-polkadot': {
meta: assetHubPolkadotMeta,
rpc: assetHubPolkadotRpc,
ver: assetHubPolkadotVer as unknown as { apis: ApiDef[] }
},
kusama: {
meta: kusamaMeta,
rpc: kusamaRpc,
Expand Down
Loading