Check against runtime for calls generation (#4990)

* Check against runtime for calls generation

* No default augmentation
This commit is contained in:
Jaco
2022-06-29 17:34:11 +03:00
committed by GitHub
parent 74e1442343
commit 9ea866815b
22 changed files with 603 additions and 78 deletions
@@ -2,8 +2,11 @@
/* eslint-disable */
import type { ApiTypes } from '@polkadot/api-base/types';
import type { Bytes, u32 } from '@polkadot/types-codec';
import type { AnyNumber } from '@polkadot/types-codec/types';
import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa';
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { AccountId, Index } from '@polkadot/types/interfaces/runtime';
import type { Observable } from '@polkadot/types/types';
@@ -43,5 +46,19 @@ declare module '@polkadot/api-base/types/calls' {
**/
[key: string]: DecoratedCallBase<ApiType>;
};
transactionPaymentApi: {
/**
* The transaction fee details
**/
queryFeeDetails: AugmentedCall<ApiType, (uxt: Bytes | string | Uint8Array, len: u32 | AnyNumber | Uint8Array) => Observable<FeeDetails>>;
/**
* The transaction info
**/
queryInfo: AugmentedCall<ApiType, (uxt: Bytes | string | Uint8Array, len: u32 | AnyNumber | Uint8Array) => Observable<RuntimeDispatchInfo>>;
/**
* Generic call
**/
[key: string]: DecoratedCallBase<ApiType>;
};
} // AugmentedCalls
} // declare module
@@ -2,8 +2,11 @@
/* eslint-disable */
import type { ApiTypes } from '@polkadot/api-base/types';
import type { Bytes, u32 } from '@polkadot/types-codec';
import type { AnyNumber } from '@polkadot/types-codec/types';
import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa';
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { AccountId, Index } from '@polkadot/types/interfaces/runtime';
import type { Observable } from '@polkadot/types/types';
@@ -43,5 +46,19 @@ declare module '@polkadot/api-base/types/calls' {
**/
[key: string]: DecoratedCallBase<ApiType>;
};
transactionPaymentApi: {
/**
* The transaction fee details
**/
queryFeeDetails: AugmentedCall<ApiType, (uxt: Bytes | string | Uint8Array, len: u32 | AnyNumber | Uint8Array) => Observable<FeeDetails>>;
/**
* The transaction info
**/
queryInfo: AugmentedCall<ApiType, (uxt: Bytes | string | Uint8Array, len: u32 | AnyNumber | Uint8Array) => Observable<RuntimeDispatchInfo>>;
/**
* Generic call
**/
[key: string]: DecoratedCallBase<ApiType>;
};
} // AugmentedCalls
} // declare module
+41 -1
View File
@@ -2,9 +2,13 @@
/* eslint-disable */
import type { ApiTypes } from '@polkadot/api-base/types';
import type { Bytes, Option, u32, u64 } from '@polkadot/types-codec';
import type { AnyNumber } from '@polkadot/types-codec/types';
import type { CodeUploadResult, ContractExecResult, ContractInstantiateResult } from '@polkadot/types/interfaces/contracts';
import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa';
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
import type { AccountId, Index } from '@polkadot/types/interfaces/runtime';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { AccountId, Balance, Index } from '@polkadot/types/interfaces/runtime';
import type { Observable } from '@polkadot/types/types';
declare module '@polkadot/api-base/types/calls' {
@@ -19,6 +23,28 @@ declare module '@polkadot/api-base/types/calls' {
**/
[key: string]: DecoratedCallBase<ApiType>;
};
contractsApi: {
/**
* Perform a call from a specified account to a given contract.
**/
call: AugmentedCall<ApiType, (origin: AccountId | string | Uint8Array, dest: AccountId | string | Uint8Array, value: Balance | AnyNumber | Uint8Array, gasLimit: u64 | AnyNumber | Uint8Array, storageDepositLimit: Option<Balance> | null | object | string | Uint8Array, inputData: Bytes | string | Uint8Array) => Observable<ContractExecResult>>;
/**
* Query a given storage key in a given contract.
**/
getStorage: AugmentedCall<ApiType, (address: AccountId | string | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
/**
* Instantiate a new contract.
**/
instantiate: AugmentedCall<ApiType, (origin: AccountId | string | Uint8Array, value: Balance | AnyNumber | Uint8Array, gasLimit: u64 | AnyNumber | Uint8Array, storageDepositLimit: Option<Balance> | null | object | string | Uint8Array, code: Bytes | string | Uint8Array, data: Bytes | string | Uint8Array, salt: Bytes | string | Uint8Array) => Observable<ContractInstantiateResult>>;
/**
* Upload new code without instantiating a contract from it.
**/
uploadCode: AugmentedCall<ApiType, (origin: AccountId | string | Uint8Array, code: Bytes | string | Uint8Array, storageDepositLimit: Option<Balance> | null | object | string | Uint8Array) => Observable<CodeUploadResult>>;
/**
* Generic call
**/
[key: string]: DecoratedCallBase<ApiType>;
};
grandpaApi: {
/**
* Get current GRANDPA authority set id.
@@ -43,5 +69,19 @@ declare module '@polkadot/api-base/types/calls' {
**/
[key: string]: DecoratedCallBase<ApiType>;
};
transactionPaymentApi: {
/**
* The transaction fee details
**/
queryFeeDetails: AugmentedCall<ApiType, (uxt: Bytes | string | Uint8Array, len: u32 | AnyNumber | Uint8Array) => Observable<FeeDetails>>;
/**
* The transaction info
**/
queryInfo: AugmentedCall<ApiType, (uxt: Bytes | string | Uint8Array, len: u32 | AnyNumber | Uint8Array) => Observable<RuntimeDispatchInfo>>;
/**
* Generic call
**/
[key: string]: DecoratedCallBase<ApiType>;
};
} // AugmentedCalls
} // declare module
+1
View File
@@ -44,6 +44,7 @@
"@polkadot/types-create": "8.10.2-1-x",
"@polkadot/types-support": "8.10.2-1-x",
"@polkadot/util": "^9.6.2",
"@polkadot/util-crypto": "^9.6.2",
"@polkadot/x-ws": "^9.6.2",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
+21 -6
View File
@@ -12,7 +12,9 @@ import { formatNumber } from '@polkadot/util';
import { generateDefaultCalls, generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultQuery, generateDefaultRpc, generateDefaultTx } from './generate';
import { assertDir, assertFile, getMetadataViaWs, HEADER, writeFile } from './util';
function generate (metaHex: HexString, pkg: string | undefined, output: string, isStrict?: boolean): void {
type Version = { apis: [HexString, number][] };
function generate (metaHex: HexString, version: Version | null, pkg: string | undefined, output: string, isStrict?: boolean): void {
console.log(`Generating from metadata, ${formatNumber((metaHex.length - 2) / 2)} bytes`);
const outputPath = assertDir(path.join(process.cwd(), output));
@@ -46,7 +48,7 @@ function generate (metaHex: HexString, pkg: string | undefined, output: string,
generateDefaultQuery(path.join(outputPath, 'augment-api-query.ts'), metaHex, extraTypes, isStrict, customLookupDefinitions);
generateDefaultRpc(path.join(outputPath, 'augment-api-rpc.ts'), extraTypes);
generateDefaultTx(path.join(outputPath, 'augment-api-tx.ts'), metaHex, extraTypes, isStrict, customLookupDefinitions);
generateDefaultCalls(path.join(outputPath, 'augment-api-runtime.ts'), metaHex, extraTypes, isStrict, customLookupDefinitions);
generateDefaultCalls(path.join(outputPath, 'augment-api-runtime.ts'), metaHex, version, extraTypes, isStrict, customLookupDefinitions);
writeFile(path.join(outputPath, 'augment-api.ts'), (): string =>
[
@@ -62,10 +64,10 @@ function generate (metaHex: HexString, pkg: string | undefined, output: string,
process.exit(0);
}
type ArgV = { endpoint: string; output: string; package?: string; strict?: boolean };
type ArgV = { endpoint: string; output: string; package?: string; strict?: boolean, version?: string };
export function main (): void {
const { endpoint, output, package: pkg, strict: isStrict } = yargs.strict().options({
const { endpoint, output, package: pkg, strict: isStrict, version } = yargs.strict().options({
endpoint: {
description: 'The endpoint to connect to (e.g. wss://kusama-rpc.polkadot.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call',
required: true,
@@ -83,15 +85,28 @@ export function main (): void {
strict: {
description: 'Turns on strict mode, no output of catch-all generic versions',
type: 'boolean'
},
version: {
description: 'Pass through a version JSON (if endpoint is non-wss)',
type: 'string'
}
}).argv as ArgV;
if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) {
getMetadataViaWs(endpoint)
.then((metadata) => generate(metadata, pkg, output, isStrict))
.then(({ metadata, version }) => generate(metadata, version, pkg, output, isStrict))
.catch(() => process.exit(1));
} else {
let rtv: Version | null = null;
if (version) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
rtv = (require(assertFile(path.join(process.cwd(), version))) as Record<string, Version>).result;
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
generate((require(assertFile(path.join(process.cwd(), endpoint))) as Record<string, HexString>).result, pkg, output, isStrict);
const metadata = (require(assertFile(path.join(process.cwd(), endpoint))) as Record<string, HexString>).result;
generate(metadata, rtv, pkg, output, isStrict);
}
}
+1 -1
View File
@@ -72,7 +72,7 @@ export function main (): void {
if (endpoint) {
if (endpoint.startsWith('wss://') || endpoint.startsWith('ws://')) {
getMetadataViaWs(endpoint)
.then((metadata) => generateDefaultLookup(inputPath, metadata))
.then(({ metadata }) => generateDefaultLookup(inputPath, metadata))
.catch(() => process.exit(1));
} else {
// eslint-disable-next-line @typescript-eslint/no-var-requires
+32 -15
View File
@@ -12,13 +12,16 @@ import Handlebars from 'handlebars';
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import lookupDefinitions from '@polkadot/types-augment/lookup/definitions';
import { objectSpread, stringCamelCase } from '@polkadot/util';
import { blake2AsHex } from '@polkadot/util-crypto';
import { createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util';
type Apis = [HexString, number][];
const generateCallsTypesTemplate = Handlebars.compile(readTemplate('calls'));
/** @internal */
function getDefs (defs: Record<string, Definitions>): Record<string, Record<string, DefinitionCallNamed>> {
function getDefs (apis: Apis | null, defs: Record<string, Definitions>): Record<string, Record<string, DefinitionCallNamed>> {
const named: Record<string, Record<string, DefinitionCallNamed>> = {};
const all = Object.values(defs);
@@ -30,20 +33,31 @@ function getDefs (defs: Record<string, Definitions>): Record<string, Record<stri
for (let i = 0; i < sections.length; i++) {
const [_section, sec] = sections[i];
const methods = Object.entries(sec[0].methods);
const apiHash = blake2AsHex(_section, 64);
const api = apis && apis.find(([h]) => h === apiHash);
if (methods.length) {
const section = stringCamelCase(_section);
if (api) {
const ver = sec.find(({ version = 1 }) => version === api[1]);
if (!named[section]) {
named[section] = {};
}
if (ver) {
const methods = Object.entries(ver.methods);
for (let m = 0; m < methods.length; m++) {
const [_method, def] = methods[m];
const method = stringCamelCase(_method);
if (methods.length) {
const section = stringCamelCase(_section);
named[section][method] = objectSpread({ method, name: `${_section}_${method}`, section }, def);
if (!named[section]) {
named[section] = {};
}
for (let m = 0; m < methods.length; m++) {
const [_method, def] = methods[m];
const method = stringCamelCase(_method);
named[section][method] = objectSpread({ method, name: `${_section}_${method}`, section }, def);
}
}
} else {
console.warn(`Unable to find matching version for runtime ${_section}, expected ${api[1]}`);
}
}
}
@@ -54,7 +68,7 @@ function getDefs (defs: Record<string, Definitions>): Record<string, Record<stri
}
/** @internal */
export function generateCallTypes (registry: TypeRegistry, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
export function generateCallTypes (registry: TypeRegistry, dest: string, apis: Apis | null, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
writeFile(dest, (): string => {
const allTypes: ExtraTypes = {
'@polkadot/types-augment': {
@@ -70,7 +84,7 @@ export function generateCallTypes (registry: TypeRegistry, dest: string, extraTy
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
}, {});
const definitions = getDefs(imports.definitions as Record<string, Definitions>);
const definitions = getDefs(apis, imports.definitions as Record<string, Definitions>);
const callKeys = Object.keys(definitions);
const modules = callKeys.map((section) => {
@@ -103,7 +117,9 @@ export function generateCallTypes (registry: TypeRegistry, dest: string, extraTy
};
}).sort((a, b) => a.name.localeCompare(b.name));
imports.typesTypes.Observable = true;
if (modules.length) {
imports.typesTypes.Observable = true;
}
return generateCallsTypesTemplate({
headerType: 'chain',
@@ -124,12 +140,13 @@ export function generateCallTypes (registry: TypeRegistry, dest: string, extraTy
});
}
export function generateDefaultCalls (dest: string, data: HexString, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void {
export function generateDefaultCalls (dest: string, data: HexString, rtVersion: { apis: Apis } | null = null, extraTypes: ExtraTypes = {}, isStrict = false, customLookupDefinitions?: Definitions): void {
const { registry } = initMeta(data, extraTypes);
generateCallTypes(
registry,
dest,
rtVersion && rtVersion.apis,
extraTypes,
isStrict,
customLookupDefinitions
+5 -1
View File
@@ -6,11 +6,15 @@ import type { HexString } from '@polkadot/util/types';
import kusama from '@polkadot/types-support/metadata/static-kusama';
import polkadot from '@polkadot/types-support/metadata/static-polkadot';
import substrate from '@polkadot/types-support/metadata/static-substrate';
import kusamaVer from '@polkadot/types-support/versions/kusama';
import polkadotVer from '@polkadot/types-support/versions/polkadot';
import substrateVer from '@polkadot/types-support/versions/substrate';
import { generateDefaultCalls, generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultInterface, generateDefaultLookup, generateDefaultQuery, generateDefaultRpc, generateDefaultTsDef, generateDefaultTx } from './generate';
const BASE = 'packages/api-augment/src';
const METAS = Object.entries({ kusama, polkadot, substrate }) as [string, HexString][];
const VERS = { kusama: kusamaVer, polkadot: polkadotVer, substrate: substrateVer };
export function main (): void {
generateDefaultInterface();
@@ -27,6 +31,6 @@ export function main (): void {
generateDefaultEvents(`${BASE}/${name}/events.ts`, staticMeta);
generateDefaultQuery(`${BASE}/${name}/query.ts`, staticMeta);
generateDefaultTx(`${BASE}/${name}/tx.ts`, staticMeta);
generateDefaultCalls(`${BASE}/${name}/runtime.ts`, staticMeta);
generateDefaultCalls(`${BASE}/${name}/runtime.ts`, staticMeta, VERS[name as keyof typeof VERS] as unknown as { apis: [HexString, number][] });
}
}
+15 -3
View File
@@ -5,7 +5,7 @@ import type { HexString } from '@polkadot/util/types';
import { WebSocket } from '@polkadot/x-ws';
export async function getMetadataViaWs (endpoint: string): Promise<HexString> {
async function getWsData <T> (endpoint: string, method: 'state_getMetadata' | 'state_getRuntimeVersion'): Promise<T> {
return new Promise((resolve): void => {
try {
const websocket = new WebSocket(endpoint);
@@ -28,11 +28,11 @@ export async function getMetadataViaWs (endpoint: string): Promise<HexString> {
websocket.onopen = (): void => {
console.log('connected');
websocket.send('{"id":"1","jsonrpc":"2.0","method":"state_getMetadata","params":[]}');
websocket.send(`{"id":"1","jsonrpc":"2.0","method":"${method}","params":[]}`);
};
websocket.onmessage = (message: { data: string }): void => {
resolve((JSON.parse(message.data) as { result: HexString }).result);
resolve((JSON.parse(message.data) as { result: T }).result);
websocket.close();
};
} catch (error) {
@@ -40,3 +40,15 @@ export async function getMetadataViaWs (endpoint: string): Promise<HexString> {
}
});
}
export async function getMetadataViaWs (endpoint: string): Promise<{ metadata: HexString, version: { apis: [HexString, number][] } }> {
return Promise
.all([
getWsData<HexString>(endpoint, 'state_getMetadata'),
getWsData<{ apis: [HexString, number][] }>(endpoint, 'state_getRuntimeVersion')
])
.then(([metadata, version]) => ({
metadata,
version
}));
}
@@ -10,7 +10,7 @@ import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interface
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
import type { BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefyPayloadId, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
import type { BeefyAuthoritySet, BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefyPayloadId, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
import type { BridgeMessageId, BridgedBlockHash, BridgedBlockNumber, BridgedHeader, CallOrigin, ChainId, DeliveredMessages, DispatchFeePayment, InboundLaneData, InboundRelayer, InitializationData, LaneId, MessageData, MessageKey, MessageNonce, MessagesDeliveryProofOf, MessagesProofOf, OperatingMode, OutboundLaneData, OutboundMessageFee, OutboundPayload, Parameter, RelayerId, UnrewardedRelayer, UnrewardedRelayersState } from '@polkadot/types/interfaces/bridges';
import type { BlockHash } from '@polkadot/types/interfaces/chain';
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
@@ -136,6 +136,7 @@ declare module '@polkadot/types/types/registry' {
BalanceLockTo212: BalanceLockTo212;
BalanceOf: BalanceOf;
BalanceStatus: BalanceStatus;
BeefyAuthoritySet: BeefyAuthoritySet;
BeefyCommitment: BeefyCommitment;
BeefyId: BeefyId;
BeefyKey: BeefyKey;
@@ -0,0 +1,72 @@
// Copyright 2017-2022 @polkadot/types-support authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable sort-keys */
export default {
specName: 'kusama',
implName: 'parity-kusama',
authoringVersion: 2,
specVersion: 9230,
implVersion: 0,
apis: [
[
'0xdf6acb689907609b',
4
],
[
'0x37e397fc7c91f5e4',
1
],
[
'0x40fe3ad401f8959a',
6
],
[
'0xd2bc9897eed08f15',
3
],
[
'0xf78b278be53f454c',
2
],
[
'0xaf2c0297a23e6d3d',
2
],
[
'0x49eaaf1b548a0cb0',
1
],
[
'0x91d5df18b0d2cf58',
1
],
[
'0xed99c5acb25eedf5',
3
],
[
'0xcbca25e39f142387',
2
],
[
'0x687ad44ad37f03c2',
1
],
[
'0xab3c0572291feb8b',
1
],
[
'0xbc9d89904f5b923f',
1
],
[
'0x37c8bb1350a9a2a8',
1
]
],
transactionVersion: 11,
stateVersion: 0
};
@@ -0,0 +1,72 @@
// Copyright 2017-2022 @polkadot/types-support authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable sort-keys */
export default {
specName: 'polkadot',
implName: 'parity-polkadot',
authoringVersion: 0,
specVersion: 9230,
implVersion: 0,
apis: [
[
'0xdf6acb689907609b',
4
],
[
'0x37e397fc7c91f5e4',
1
],
[
'0x40fe3ad401f8959a',
6
],
[
'0xd2bc9897eed08f15',
3
],
[
'0xf78b278be53f454c',
2
],
[
'0xaf2c0297a23e6d3d',
2
],
[
'0x49eaaf1b548a0cb0',
1
],
[
'0x91d5df18b0d2cf58',
1
],
[
'0xed99c5acb25eedf5',
3
],
[
'0xcbca25e39f142387',
2
],
[
'0x687ad44ad37f03c2',
1
],
[
'0xab3c0572291feb8b',
1
],
[
'0xbc9d89904f5b923f',
1
],
[
'0x37c8bb1350a9a2a8',
1
]
],
transactionVersion: 12,
stateVersion: 0
};
@@ -0,0 +1,68 @@
// Copyright 2017-2022 @polkadot/types-support authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable sort-keys */
export default {
specName: 'node',
implName: 'substrate-node',
authoringVersion: 10,
specVersion: 268,
implVersion: 0,
apis: [
[
'0xdf6acb689907609b',
4
],
[
'0x37e397fc7c91f5e4',
1
],
[
'0x40fe3ad401f8959a',
6
],
[
'0xd2bc9897eed08f15',
3
],
[
'0xf78b278be53f454c',
2
],
[
'0xed99c5acb25eedf5',
3
],
[
'0xcbca25e39f142387',
2
],
[
'0x687ad44ad37f03c2',
1
],
[
'0xbc9d89904f5b923f',
1
],
[
'0x68b66ba122c93fa7',
1
],
[
'0x37c8bb1350a9a2a8',
1
],
[
'0x91d5df18b0d2cf58',
1
],
[
'0xab3c0572291feb8b',
1
]
],
transactionVersion: 2,
stateVersion: 1
};
@@ -7,10 +7,17 @@
import type { Definitions } from '../../types';
import { rpc } from './rpc';
import { runtime } from './runtime';
export default {
rpc,
runtime,
types: {
BeefyAuthoritySet: {
id: 'u64',
len: 'u32',
root: 'H256'
},
BeefyCommitment: {
payload: 'BeefyPayload',
blockNumber: 'BlockNumber',
@@ -0,0 +1,23 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall } from '../../types';
export const runtime: DefinitionsCall = {
BeefyMmrApi: [
{
methods: {
authority_set_proof: {
description: 'Return the currently active BEEFY authority set proof.',
params: [],
type: 'BeefyAuthoritySet'
},
next_authority_set_proof: {
description: 'Return the next/queued BEEFY authority set proof.',
params: [],
type: 'BeefyNextAuthoritySet'
}
}
}
]
};
@@ -6,6 +6,13 @@ import type { ITuple } from '@polkadot/types-codec/types';
import type { EcdsaSignature } from '@polkadot/types/interfaces/extrinsics';
import type { BlockNumber, H256 } from '@polkadot/types/interfaces/runtime';
/** @name BeefyAuthoritySet */
export interface BeefyAuthoritySet extends Struct {
readonly id: u64;
readonly len: u32;
readonly root: H256;
}
/** @name BeefyCommitment */
export interface BeefyCommitment extends Struct {
readonly payload: BeefyPayload;
@@ -6,10 +6,12 @@
import type { Definitions } from '../../types';
import rpc from './rpc';
import { rpc } from './rpc';
import { runtime } from './runtime';
export default {
rpc,
runtime,
types: {
AliveContractInfo: {
trieId: 'TrieId',
+46 -49
View File
@@ -1,12 +1,9 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { DefinitionsRpc } from '../../types';
export default {
export const rpc: DefinitionsRpc = {
call: {
description: 'Executes a call to a contract',
params: [
@@ -15,49 +12,14 @@ export default {
type: 'ContractCallRequest'
},
{
name: 'at',
type: 'BlockHash',
isHistoric: true,
isOptional: true
isOptional: true,
name: 'at',
type: 'BlockHash'
}
],
type: 'ContractExecResult'
},
instantiate: {
description: 'Instantiate a new contract',
params: [
{
name: 'request',
type: 'InstantiateRequest'
},
{
name: 'at',
type: 'BlockHash',
isHstoric: true,
isOptional: true
}
],
type: 'ContractInstantiateResult'
},
uploadCode: {
// The RPC here is terribly misnamed - somebody forgot how the RPCs
// are actually done, ie. <module>_<camelCasedMethod>
endpoint: 'contracts_upload_code',
description: 'Upload new code without instantiating a contract from it',
params: [
{
name: 'uploadRequest',
type: 'CodeUploadRequest'
},
{
name: 'at',
type: 'BlockHash',
isHstoric: true,
isOptional: true
}
],
type: 'CodeUploadResult'
},
getStorage: {
description: 'Returns the value under a specified storage key in a contract',
params: [
@@ -70,14 +32,30 @@ export default {
type: 'H256'
},
{
name: 'at',
type: 'BlockHash',
isHistoric: true,
isOptional: true
isOptional: true,
name: 'at',
type: 'BlockHash'
}
],
type: 'Option<Bytes>'
},
instantiate: {
description: 'Instantiate a new contract',
params: [
{
name: 'request',
type: 'InstantiateRequest'
},
{
isHistoric: true,
isOptional: true,
name: 'at',
type: 'BlockHash'
}
],
type: 'ContractInstantiateResult'
},
rentProjection: {
description: 'Returns the projected time a given contract will be able to sustain paying its rent',
params: [
@@ -86,12 +64,31 @@ export default {
type: 'AccountId'
},
{
name: 'at',
type: 'BlockHash',
isHistoric: true,
isOptional: true
isOptional: true,
name: 'at',
type: 'BlockHash'
}
],
type: 'Option<BlockNumber>'
},
uploadCode: {
description: 'Upload new code without instantiating a contract from it',
// The RPC here is terribly misnamed - somebody forgot how the RPCs
// are actually done, ie. <module>_<camelCasedMethod>
endpoint: 'contracts_upload_code',
params: [
{
name: 'uploadRequest',
type: 'CodeUploadRequest'
},
{
isHistoric: true,
isOptional: true,
name: 'at',
type: 'BlockHash'
}
],
type: 'CodeUploadResult'
}
} as DefinitionsRpc;
};
@@ -0,0 +1,109 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall } from '../../types';
export const runtime: DefinitionsCall = {
ContractsApi: [
{
methods: {
call: {
description: 'Perform a call from a specified account to a given contract.',
params: [
{
name: 'origin',
type: 'AccountId'
},
{
name: 'dest',
type: 'AccountId'
},
{
name: 'value',
type: 'Balance'
},
{
name: 'gasLimit',
type: 'u64'
},
{
name: 'storageDepositLimit',
type: 'Option<Balance>'
},
{
name: 'inputData',
type: 'Vec<u8>'
}
],
type: 'ContractExecResult'
},
get_storage: {
description: 'Query a given storage key in a given contract.',
params: [
{
name: 'address',
type: 'AccountId'
},
{
name: 'key',
type: 'Bytes'
}
],
type: 'Option<Bytes>'
},
instantiate: {
description: 'Instantiate a new contract.',
params: [
{
name: 'origin',
type: 'AccountId'
},
{
name: 'value',
type: 'Balance'
},
{
name: 'gasLimit',
type: 'u64'
},
{
name: 'storageDepositLimit',
type: 'Option<Balance>'
},
{
name: 'code',
type: 'Bytes'
},
{
name: 'data',
type: 'Bytes'
},
{
name: 'salt',
type: 'Bytes'
}
],
type: 'ContractInstantiateResult'
},
upload_code: {
description: 'Upload new code without instantiating a contract from it.',
params: [
{
name: 'origin',
type: 'AccountId'
},
{
name: 'code',
type: 'Bytes'
},
{
name: 'storageDepositLimit',
type: 'Option<Balance>'
}
],
type: 'CodeUploadResult'
}
}
}
]
};
@@ -7,9 +7,11 @@
import type { Definitions } from '../../types';
import { rpc } from './rpc';
import { runtime } from './runtime';
export default {
rpc,
runtime,
types: {
FeeDetails: {
inclusionFee: 'Option<InclusionFee>'
@@ -0,0 +1,41 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall } from '../../types';
export const runtime: DefinitionsCall = {
TransactionPaymentApi: [
{
methods: {
query_fee_details: {
description: 'The transaction fee details',
params: [
{
name: 'uxt',
type: 'Bytes'
},
{
name: 'len',
type: 'u32'
}
],
type: 'FeeDetails'
},
query_info: {
description: 'The transaction info',
params: [
{
name: 'uxt',
type: 'Bytes'
},
{
name: 'len',
type: 'u32'
}
],
type: 'RuntimeDispatchInfo'
}
}
}
]
};
+1
View File
@@ -2222,6 +2222,7 @@ __metadata:
"@polkadot/types-create": 8.10.2-1-x
"@polkadot/types-support": 8.10.2-1-x
"@polkadot/util": ^9.6.2
"@polkadot/util-crypto": ^9.6.2
"@polkadot/x-ws": ^9.6.2
"@types/websocket": ^1.0.5
"@types/yargs": ^17.0.10