Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c054f96c80 | ||
|
|
11c1b998be | ||
|
|
fdebf8b74b | ||
|
|
7c91ee5ccc | ||
|
|
c146727510 | ||
|
|
096da21c76 | ||
|
|
d3c16b5cb4 | ||
|
|
87b4cecc1b | ||
|
|
d79a5301fb | ||
|
|
7481983e44 | ||
|
|
47291533e6 | ||
|
|
a15d0dd0df | ||
|
|
1dca21d607 |
@@ -1,5 +1,26 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 14.0.1 Oct 2, 2024
|
||||
|
||||
Changes:
|
||||
|
||||
- TransactionExtension, ExtrinsicV5
|
||||
- This is a very large feature that gives support for Extrinsic V5. This is not a breaking change, but because of the impact it has it is a Major bump.
|
||||
- This PR acts as a forward compatible feature that still focuses on v4, but allows for the use of v5 when:
|
||||
a: The metadata extrinsic version is set to 5
|
||||
b: The extrinsic version is set to 5 when manually constructing transactions.
|
||||
- The PR allows the decoding of all v4, and v5 extrinsics including {bare, signed, general} transactions.
|
||||
- Address parsing issues for H160 accounts in api.derive.accounts.{*} ([#5991](https://github.com/polkadot-js/api/pull/5991))
|
||||
|
||||
|
||||
## 13.2.1 Sep 23, 2024
|
||||
|
||||
Changes:
|
||||
|
||||
- Generate Runtime Apis Dynamically ([#5986](https://github.com/polkadot-js/api/pull/5986))
|
||||
- Fix logging for older runtimes for runtime-api decoration ([#5988](https://github.com/polkadot-js/api/pull/5988))
|
||||
|
||||
|
||||
## 13.1.1 Sep 17, 2024
|
||||
|
||||
Changes:
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
3512 Jaco Bump deps (#5785)
|
||||
103 Tarik Gul 13.1.1 (#5985)
|
||||
109 Tarik Gul 14.0.1 (#5995)
|
||||
83 Amaury Martiny StatementKind: Regular and Saft (#2303)
|
||||
37 Keith Ingram Update contract types and rpc (#4541)
|
||||
35 Stefanie Doll Updated child storage parameters (#1709)
|
||||
@@ -66,6 +66,7 @@
|
||||
1 Dan Forbes Add WeightToFeeCoefficient type (#2296)
|
||||
1 Daniel Maricic Fixed typo in README (#2402)
|
||||
1 Daniel Savu fix: Generate custom type definitions (#4224)
|
||||
1 Daria choosing AccountId20 type if the address is 20 bytes (#5991)
|
||||
1 David Don't log full error (#2952)
|
||||
1 David Duong Avoid reserved words during named enum fields augmentation (#5203)
|
||||
1 Denis Tsai realign AccountKey20Junction to polkadot xcm's Junction enum (#3770)
|
||||
|
||||
+3
-3
@@ -14,10 +14,10 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"versions": {
|
||||
"git": "13.1.1",
|
||||
"npm": "13.1.1"
|
||||
"git": "14.0.1",
|
||||
"npm": "14.0.1"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/api-base": "13.1.1",
|
||||
"@polkadot/rpc-augment": "13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-augment": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/api-base": "14.0.1",
|
||||
"@polkadot/rpc-augment": "14.0.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-augment": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"tslib": "^2.7.0"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-augment', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-augment', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/rpc-core": "13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/rpc-core": "14.0.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"rxjs": "^7.8.1",
|
||||
"tslib": "^2.7.0"
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-base', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-base', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,22 +18,22 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/api": "13.1.1",
|
||||
"@polkadot/api-augment": "13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/types-create": "13.1.1",
|
||||
"@polkadot/api": "14.0.1",
|
||||
"@polkadot/api-augment": "14.0.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/types-create": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"@polkadot/util-crypto": "^13.1.1",
|
||||
"rxjs": "^7.8.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api-augment": "13.1.1",
|
||||
"@polkadot/api-augment": "14.0.1",
|
||||
"@polkadot/keyring": "^13.1.1",
|
||||
"@polkadot/types-support": "13.1.1"
|
||||
"@polkadot/types-support": "14.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,25 +18,25 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/api": "13.1.1",
|
||||
"@polkadot/api-augment": "13.1.1",
|
||||
"@polkadot/api-base": "13.1.1",
|
||||
"@polkadot/rpc-core": "13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/api": "14.0.1",
|
||||
"@polkadot/api-augment": "14.0.1",
|
||||
"@polkadot/api-base": "14.0.1",
|
||||
"@polkadot/rpc-core": "14.0.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"@polkadot/util-crypto": "^13.1.1",
|
||||
"rxjs": "^7.8.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api": "13.1.1",
|
||||
"@polkadot/api-augment": "13.1.1",
|
||||
"@polkadot/rpc-augment": "13.1.1",
|
||||
"@polkadot/rpc-provider": "13.1.1",
|
||||
"@polkadot/types-support": "13.1.1"
|
||||
"@polkadot/api": "14.0.1",
|
||||
"@polkadot/api-augment": "14.0.1",
|
||||
"@polkadot/rpc-augment": "14.0.1",
|
||||
"@polkadot/rpc-provider": "14.0.1",
|
||||
"@polkadot/types-support": "14.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export function accountId (instanceId: string, api: DeriveApi): (address?: Addre
|
||||
: decodeAddress((address || '').toString());
|
||||
|
||||
if (decoded.length > 8) {
|
||||
return of(api.registry.createType('AccountId', decoded));
|
||||
return of(api.registry.createType(decoded.length === 20 ? 'AccountId20' : 'AccountId', decoded));
|
||||
}
|
||||
|
||||
const accountIndex = api.registry.createType('AccountIndex', decoded);
|
||||
|
||||
@@ -34,7 +34,7 @@ export function idAndIndex (instanceId: string, api: DeriveApi): (address?: Addr
|
||||
: decodeAddress((address || '').toString());
|
||||
|
||||
if (decoded.length > 8) {
|
||||
const accountId = api.registry.createType('AccountId', decoded);
|
||||
const accountId = api.registry.createType(decoded.length === 20 ? 'AccountId20' : 'AccountId', decoded);
|
||||
|
||||
return api.derive.accounts.idToIndex(accountId).pipe(
|
||||
map((accountIndex): AccountIdAndIndex => [accountId, accountIndex])
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-derive', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
+14
-14
@@ -18,21 +18,21 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/api-augment": "13.1.1",
|
||||
"@polkadot/api-base": "13.1.1",
|
||||
"@polkadot/api-derive": "13.1.1",
|
||||
"@polkadot/api-augment": "14.0.1",
|
||||
"@polkadot/api-base": "14.0.1",
|
||||
"@polkadot/api-derive": "14.0.1",
|
||||
"@polkadot/keyring": "^13.1.1",
|
||||
"@polkadot/rpc-augment": "13.1.1",
|
||||
"@polkadot/rpc-core": "13.1.1",
|
||||
"@polkadot/rpc-provider": "13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-augment": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/types-create": "13.1.1",
|
||||
"@polkadot/types-known": "13.1.1",
|
||||
"@polkadot/rpc-augment": "14.0.1",
|
||||
"@polkadot/rpc-core": "14.0.1",
|
||||
"@polkadot/rpc-provider": "14.0.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-augment": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/types-create": "14.0.1",
|
||||
"@polkadot/types-known": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"@polkadot/util-crypto": "^13.1.1",
|
||||
"eventemitter3": "^5.0.1",
|
||||
@@ -40,7 +40,7 @@
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api-augment": "13.1.1",
|
||||
"@polkadot/types-support": "13.1.1"
|
||||
"@polkadot/api-augment": "14.0.1",
|
||||
"@polkadot/types-support": "14.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AugmentedCall, DeriveCustom, QueryableCalls } from '@polkadot/api-base/types';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Metadata, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { Metadata, StorageKey, Text, u64, Vec } from '@polkadot/types';
|
||||
import type { Call, Hash, RuntimeApiMethodMetadataV15, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { AnyFunction, AnyJson, AnyTuple, CallFunction, Codec, DefinitionCallNamed, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, DefinitionsCallEntry, DetectCodec, IMethod, IStorageKey, Registry, RegistryError, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { AnyFunction, AnyJson, AnyTuple, CallFunction, Codec, DefinitionCall, DefinitionCallNamed, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, DefinitionsCallEntry, DetectCodec, IMethod, IStorageKey, Registry, RegistryError, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { SubmittableExtrinsic } from '../submittable/types.js';
|
||||
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, AugmentedQuery, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecorateMethod, GenericStorageEntryFunction, PaginationOptions, QueryableConsts, QueryableStorage, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics } from '../types/index.js';
|
||||
@@ -492,64 +492,126 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
return Object.entries(result);
|
||||
}
|
||||
|
||||
// pre-metadata decoration
|
||||
// Helper for _getRuntimeDefsViaMetadata
|
||||
protected _getMethods (registry: Registry, methods: Vec<RuntimeApiMethodMetadataV15>) {
|
||||
const result: Record<string, DefinitionCall> = {};
|
||||
|
||||
methods.forEach((m) => {
|
||||
const { docs, inputs, name, output } = m;
|
||||
|
||||
result[name.toString()] = {
|
||||
description: docs.map((d) => d.toString()).join(),
|
||||
params: inputs.map(({ name, type }) => {
|
||||
return { name: name.toString(), type: registry.lookup.getName(type) || registry.lookup.getTypeDef(type).type };
|
||||
}),
|
||||
type: registry.lookup.getName(output) || registry.lookup.getTypeDef(output).type
|
||||
};
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Maintains the same structure as `_getRuntimeDefs` in order to make conversion easier.
|
||||
protected _getRuntimeDefsViaMetadata (registry: Registry): [string, DefinitionsCallEntry[]][] {
|
||||
const result: DefinitionsCall = {};
|
||||
const { apis } = registry.metadata;
|
||||
|
||||
for (let i = 0, count = apis.length; i < count; i++) {
|
||||
const { methods, name } = apis[i];
|
||||
|
||||
result[name.toString()] = [{
|
||||
methods: this._getMethods(registry, methods),
|
||||
// We set the version to 0 here since it will not be relevant when we are grabbing the runtime apis
|
||||
// from the Metadata.
|
||||
version: 0
|
||||
}];
|
||||
}
|
||||
|
||||
return Object.entries(result);
|
||||
}
|
||||
|
||||
// When the calls are available in the metadata, it will generate them based off of the metadata.
|
||||
// When they are not available it will use the hardcoded calls generated in the static types.
|
||||
protected _decorateCalls<ApiType extends ApiTypes> ({ registry, runtimeVersion: { apis, specName, specVersion } }: VersionedRegistry<any>, decorateMethod: DecorateMethod<ApiType>, blockHash?: Uint8Array | string | null): QueryableCalls<ApiType> {
|
||||
const result = {} as QueryableCalls<ApiType>;
|
||||
const named: Record<string, Record<string, DefinitionCallNamed>> = {};
|
||||
const hashes: Record<HexString, boolean> = {};
|
||||
const sections = this._getRuntimeDefs(registry, specName, this._runtimeChain);
|
||||
const isApiInMetadata = registry.metadata.apis.length > 0;
|
||||
const sections = isApiInMetadata ? this._getRuntimeDefsViaMetadata(registry) : this._getRuntimeDefs(registry, specName, this._runtimeChain);
|
||||
const older: string[] = [];
|
||||
const implName = `${specName.toString()}/${specVersion.toString()}`;
|
||||
const hasLogged = this.#runtimeLog[implName] || false;
|
||||
|
||||
this.#runtimeLog[implName] = true;
|
||||
|
||||
for (let i = 0, scount = sections.length; i < scount; i++) {
|
||||
const [_section, secs] = sections[i];
|
||||
const sectionHash = blake2AsHex(_section, 64);
|
||||
const rtApi = apis.find(([a]) => a.eq(sectionHash));
|
||||
if (isApiInMetadata) {
|
||||
for (let i = 0, scount = sections.length; i < scount; i++) {
|
||||
const [_section, secs] = sections[i];
|
||||
const sec = secs[0];
|
||||
const sectionHash = blake2AsHex(_section, 64);
|
||||
|
||||
hashes[sectionHash] = true;
|
||||
const section = stringCamelCase(_section);
|
||||
const methods = Object.entries(sec.methods);
|
||||
|
||||
if (rtApi) {
|
||||
const all = secs.map(({ version }) => version).sort();
|
||||
const sec = secs.find(({ version }) => rtApi[1].eq(version));
|
||||
if (!named[section]) {
|
||||
named[section] = {};
|
||||
}
|
||||
|
||||
if (sec) {
|
||||
const section = stringCamelCase(_section);
|
||||
const methods = Object.entries(sec.methods);
|
||||
for (let m = 0, mcount = methods.length; m < mcount; m++) {
|
||||
const [_method, def] = methods[m];
|
||||
const method = stringCamelCase(_method);
|
||||
|
||||
if (methods.length) {
|
||||
if (!named[section]) {
|
||||
named[section] = {};
|
||||
}
|
||||
|
||||
for (let m = 0, mcount = methods.length; m < mcount; m++) {
|
||||
const [_method, def] = methods[m];
|
||||
const method = stringCamelCase(_method);
|
||||
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
older.push(`${_section}/${rtApi[1].toString()} (${all.join('/')} known)`);
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0, scount = sections.length; i < scount; i++) {
|
||||
const [_section, secs] = sections[i];
|
||||
const sectionHash = blake2AsHex(_section, 64);
|
||||
const rtApi = apis.find(([a]) => a.eq(sectionHash));
|
||||
|
||||
// find the runtimes that we don't have hashes for
|
||||
const notFound = apis
|
||||
.map(([a, v]): [HexString, string] => [a.toHex(), v.toString()])
|
||||
.filter(([a]) => !hashes[a])
|
||||
.map(([a, v]) => `${this._runtimeMap[a] || a}/${v}`);
|
||||
hashes[sectionHash] = true;
|
||||
|
||||
if (!this._options.noInitWarn && !hasLogged) {
|
||||
if (older.length) {
|
||||
l.warn(`${implName}: Not decorating runtime apis without matching versions: ${older.join(', ')}`);
|
||||
if (rtApi) {
|
||||
const all = secs.map(({ version }) => version).sort();
|
||||
const sec = secs.find(({ version }) => rtApi[1].eq(version));
|
||||
|
||||
if (sec) {
|
||||
const section = stringCamelCase(_section);
|
||||
const methods = Object.entries(sec.methods);
|
||||
|
||||
if (methods.length) {
|
||||
if (!named[section]) {
|
||||
named[section] = {};
|
||||
}
|
||||
|
||||
for (let m = 0, mcount = methods.length; m < mcount; m++) {
|
||||
const [_method, def] = methods[m];
|
||||
const method = stringCamelCase(_method);
|
||||
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
older.push(`${_section}/${rtApi[1].toString()} (${all.join('/')} known)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (notFound.length) {
|
||||
l.warn(`${implName}: Not decorating unknown runtime apis: ${notFound.join(', ')}`);
|
||||
// find the runtimes that we don't have hashes for
|
||||
const notFound = apis
|
||||
.map(([a, v]): [HexString, string] => [a.toHex(), v.toString()])
|
||||
.filter(([a]) => !hashes[a])
|
||||
.map(([a, v]) => `${this._runtimeMap[a] || a}/${v}`);
|
||||
|
||||
if (!this._options.noInitWarn && !hasLogged) {
|
||||
if (older.length) {
|
||||
l.warn(`${implName}: Not decorating runtime apis without matching versions: ${older.join(', ')}`);
|
||||
}
|
||||
|
||||
if (notFound.length) {
|
||||
l.warn(`${implName}: Not decorating unknown runtime apis: ${notFound.join(', ')}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/rpc-core": "13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/rpc-core": "14.0.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"tslib": "^2.7.0"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-augment', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-augment', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,18 +18,18 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/rpc-augment": "13.1.1",
|
||||
"@polkadot/rpc-provider": "13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/rpc-augment": "14.0.1",
|
||||
"@polkadot/rpc-provider": "14.0.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"rxjs": "^7.8.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^13.1.1",
|
||||
"@polkadot/rpc-augment": "13.1.1"
|
||||
"@polkadot/rpc-augment": "14.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/keyring": "^13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-support": "13.1.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-support": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"@polkadot/util-crypto": "^13.1.1",
|
||||
"@polkadot/x-fetch": "^13.1.1",
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.mjs",
|
||||
@@ -28,15 +28,15 @@
|
||||
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "13.1.1",
|
||||
"@polkadot/api-augment": "13.1.1",
|
||||
"@polkadot/rpc-augment": "13.1.1",
|
||||
"@polkadot/rpc-provider": "13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-augment": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/types-create": "13.1.1",
|
||||
"@polkadot/types-support": "13.1.1",
|
||||
"@polkadot/api": "14.0.1",
|
||||
"@polkadot/api-augment": "14.0.1",
|
||||
"@polkadot/rpc-augment": "14.0.1",
|
||||
"@polkadot/rpc-provider": "14.0.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-augment": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/types-create": "14.0.1",
|
||||
"@polkadot/types-support": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"@polkadot/util-crypto": "^13.1.1",
|
||||
"@polkadot/x-ws": "^13.1.1",
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/typegen', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"tslib": "^2.7.0"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-augment', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-augment', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -35,7 +35,7 @@ import type { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex,
|
||||
import type { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
|
||||
import type { BlockV0, BlockV1, BlockV2, EIP1559Transaction, EIP2930Transaction, EthAccessList, EthAccessListItem, EthAccount, EthAddress, EthBlock, EthBloom, EthCallRequest, EthFeeHistory, EthFilter, EthFilterAddress, EthFilterChanges, EthFilterTopic, EthFilterTopicEntry, EthFilterTopicInner, EthHeader, EthLog, EthReceipt, EthReceiptV0, EthReceiptV3, EthRichBlock, EthRichHeader, EthStorageProof, EthSubKind, EthSubParams, EthSubResult, EthSyncInfo, EthSyncStatus, EthTransaction, EthTransactionAction, EthTransactionCondition, EthTransactionRequest, EthTransactionSignature, EthTransactionStatus, EthWork, EthereumAccountId, EthereumAddress, EthereumLookupSource, EthereumSignature, LegacyTransaction, TransactionV0, TransactionV1, TransactionV2 } from '@polkadot/types/interfaces/eth';
|
||||
import type { EvmAccount, EvmCallInfo, EvmCallInfoV2, EvmCreateInfo, EvmCreateInfoV2, EvmLog, EvmVicinity, EvmWeightInfo, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed } from '@polkadot/types/interfaces/evm';
|
||||
import type { AnySignature, EcdsaSignature, Ed25519Signature, Era, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { AnySignature, EcdsaSignature, Ed25519Signature, Era, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicPayloadV5, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicSignatureV5, ExtrinsicUnknown, ExtrinsicV4, ExtrinsicV5, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { FungiblesAccessError } from '@polkadot/types/interfaces/fungibles';
|
||||
import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
|
||||
import type { GenesisBuildErr } from '@polkadot/types/interfaces/genesisBuilder';
|
||||
@@ -504,12 +504,15 @@ declare module '@polkadot/types/types/registry' {
|
||||
ExtrinsicPayload: ExtrinsicPayload;
|
||||
ExtrinsicPayloadUnknown: ExtrinsicPayloadUnknown;
|
||||
ExtrinsicPayloadV4: ExtrinsicPayloadV4;
|
||||
ExtrinsicPayloadV5: ExtrinsicPayloadV5;
|
||||
ExtrinsicSignature: ExtrinsicSignature;
|
||||
ExtrinsicSignatureV4: ExtrinsicSignatureV4;
|
||||
ExtrinsicSignatureV5: ExtrinsicSignatureV5;
|
||||
ExtrinsicStatus: ExtrinsicStatus;
|
||||
ExtrinsicsWeight: ExtrinsicsWeight;
|
||||
ExtrinsicUnknown: ExtrinsicUnknown;
|
||||
ExtrinsicV4: ExtrinsicV4;
|
||||
ExtrinsicV5: ExtrinsicV5;
|
||||
f32: f32;
|
||||
F32: F32;
|
||||
f64: f64;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/util": "^13.1.1",
|
||||
@@ -26,9 +26,9 @@
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-augment": "13.1.1",
|
||||
"@polkadot/types-support": "13.1.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-augment": "14.0.1",
|
||||
"@polkadot/types-support": "14.0.1",
|
||||
"@polkadot/util-crypto": "^13.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-codec', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-codec', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -71,6 +71,7 @@ export interface Registry {
|
||||
getClassName (clazz: CodecClass): string | undefined;
|
||||
getOrThrow <T extends Codec = Codec, K extends string = string> (name: K, msg?: string): CodecClass<T>;
|
||||
getOrUnknown <T extends Codec = Codec, K extends string = string> (name: K): CodecClass<T>;
|
||||
getTransactionExtensionVersion (): number;
|
||||
getSignedExtensionExtra (): Record<string, string>;
|
||||
getSignedExtensionTypes (): Record<string, string>;
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "13.1.1"
|
||||
"@polkadot/types": "14.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-create', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-create', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/networks": "^13.1.1",
|
||||
"@polkadot/types": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/types-create": "13.1.1",
|
||||
"@polkadot/types": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/types-create": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api": "13.1.1"
|
||||
"@polkadot/api": "14.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-known', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/util": "^13.1.1",
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-support', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-support', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "13.1.1",
|
||||
"version": "14.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/keyring": "^13.1.1",
|
||||
"@polkadot/types-augment": "13.1.1",
|
||||
"@polkadot/types-codec": "13.1.1",
|
||||
"@polkadot/types-create": "13.1.1",
|
||||
"@polkadot/types-augment": "14.0.1",
|
||||
"@polkadot/types-codec": "14.0.1",
|
||||
"@polkadot/types-create": "14.0.1",
|
||||
"@polkadot/util": "^13.1.1",
|
||||
"@polkadot/util-crypto": "^13.1.1",
|
||||
"rxjs": "^7.8.1",
|
||||
@@ -32,6 +32,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^13.1.1",
|
||||
"@polkadot/types-support": "13.1.1"
|
||||
"@polkadot/types-support": "14.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,6 +441,11 @@ export class TypeRegistry implements Registry {
|
||||
return this.get<T, K>(name, true) as unknown as CodecClass<R>;
|
||||
}
|
||||
|
||||
// Only used in extrinsic version 5
|
||||
public getTransactionExtensionVersion (): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public getSignedExtensionExtra (): Record<string, string> {
|
||||
return expandExtensionTypes(this.#signedExtensions, 'payload', this.#userExtensions);
|
||||
}
|
||||
|
||||
@@ -48,4 +48,81 @@ describe('Extrinsic', (): void => {
|
||||
expect(extrinsic.toPrimitive()).toEqual({ method: { args: { dest: { id: '5DiuK2zR4asj2CEh77SKtUgTswTLkD8eiAKrByg5G3wL5w9b' }, value: 104560923320000 }, callIndex: '0x0600' }, signature: { era: { mortalEra: [1024, 186] }, nonce: 68, signature: { ed25519: '0xd99ffe3e610ad234e1414bda5831395a6df9098bf80b01561ce89a5065ae89d5c10e1619c6c99131b0bea4fb73ef04d07c07770e2ae9df5c325c331769ccb300' }, signer: { id: '5Hn8KKEp8qruCGWaN9MEsjTs4FXB4wv9xn7g1RWkNeKKNXCr' }, tip: 30000000000 } });
|
||||
});
|
||||
});
|
||||
|
||||
describe('V5', () => {
|
||||
// Ensure it does not have its registry modified by the fallback extensions.
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
describe('SignedExtrinsic', () => {
|
||||
it('Should work when the version and preamble is passed in', () => {
|
||||
const extrinsic = new Extrinsic(
|
||||
registry,
|
||||
'0x51028500d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d011e0b7d9438899333c50121f8e10144952d51c3bb8d0ea11dd1f24940d8ff615ad351d95ed9f41f078748ed7cf182864a20b38eebfaef6629433365eb90c0148c007502000000000603008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a480b00a0724e1809',
|
||||
{ preamble: 'signed', version: 5 }
|
||||
);
|
||||
|
||||
expect(extrinsic.signer.toString()).toEqual('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
|
||||
expect(extrinsic.era.toHuman()).toEqual({ MortalEra: { period: '64', phase: '39' } });
|
||||
expect(extrinsic.nonce.toNumber()).toEqual(0);
|
||||
expect(extrinsic.tip.toHuman()).toEqual('0');
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 3]));
|
||||
expect(extrinsic.args[0].toHex()).toEqual('0x008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48');
|
||||
expect(extrinsic.args[1].toHuman()).toEqual('10,000,000,000,000');
|
||||
});
|
||||
|
||||
it('Should work when the version and preamble is not passed in', () => {
|
||||
const extrinsic = new Extrinsic(
|
||||
registry,
|
||||
'0x51028500d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d011e0b7d9438899333c50121f8e10144952d51c3bb8d0ea11dd1f24940d8ff615ad351d95ed9f41f078748ed7cf182864a20b38eebfaef6629433365eb90c0148c007502000000000603008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a480b00a0724e1809'
|
||||
);
|
||||
|
||||
expect(extrinsic.version).toEqual(133);
|
||||
expect(extrinsic.signer.toString()).toEqual('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
|
||||
expect(extrinsic.era.toHuman()).toEqual({ MortalEra: { period: '64', phase: '39' } });
|
||||
expect(extrinsic.nonce.toNumber()).toEqual(0);
|
||||
expect(extrinsic.tip.toHuman()).toEqual('0');
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 3]));
|
||||
expect(extrinsic.args[0].toHex()).toEqual('0x008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48');
|
||||
expect(extrinsic.args[1].toHuman()).toEqual('10,000,000,000,000');
|
||||
});
|
||||
});
|
||||
|
||||
describe('GeneralExtrinsic', () => {
|
||||
it('Should work when the version and preamble is passed in', () => {
|
||||
const extrinsic = new Extrinsic(
|
||||
registry,
|
||||
'0xc44500650000000000060000d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0700e40b5402',
|
||||
{ preamble: 'general', version: 5 }
|
||||
);
|
||||
|
||||
expect(extrinsic.version).toEqual(69);
|
||||
// expect(extrinsic.transactionExtensionVersion.toNumber()).toEqual(0);
|
||||
expect(extrinsic.method.toHuman()).toEqual({ args: { dest: { Id: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY' }, value: '10,000,000,000' }, method: 'transferAllowDeath', section: 'balances' });
|
||||
expect(extrinsic.era.toHuman()).toEqual({ MortalEra: { period: '64', phase: '6' } });
|
||||
expect(extrinsic.tip.toNumber()).toEqual(0);
|
||||
expect(extrinsic.mode.toNumber()).toEqual(0);
|
||||
expect(extrinsic.assetId.toHuman()).toEqual(null);
|
||||
expect(extrinsic.nonce.toNumber()).toEqual(0);
|
||||
});
|
||||
|
||||
it('Should work when there is no version and preamble is passed in', () => {
|
||||
const extrinsic = new Extrinsic(
|
||||
registry,
|
||||
'0xc44500650000000000060000d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0700e40b5402'
|
||||
);
|
||||
|
||||
expect(extrinsic.version).toEqual(69);
|
||||
// expect(extrinsic.transactionExtensionVersion.toNumber()).toEqual(0);
|
||||
expect(extrinsic.method.toHuman()).toEqual({ args: { dest: { Id: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY' }, value: '10,000,000,000' }, method: 'transferAllowDeath', section: 'balances' });
|
||||
expect(extrinsic.era.toHuman()).toEqual({ MortalEra: { period: '64', phase: '6' } });
|
||||
expect(extrinsic.tip.toNumber()).toEqual(0);
|
||||
expect(extrinsic.mode.toNumber()).toEqual(0);
|
||||
expect(extrinsic.assetId.toHuman()).toEqual(null);
|
||||
expect(extrinsic.nonce.toNumber()).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,48 +3,71 @@
|
||||
|
||||
import type { AnyJson, AnyTuple, AnyU8a, ArgsDef, IMethod, Inspect, IOption } from '@polkadot/types-codec/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { EcdsaSignature, Ed25519Signature, ExtrinsicUnknown, ExtrinsicV4, Sr25519Signature } from '../interfaces/extrinsics/index.js';
|
||||
import type { GeneralExtrinsic } from '../index.types.js';
|
||||
import type { EcdsaSignature, Ed25519Signature, ExtrinsicSignatureV5, ExtrinsicUnknown, ExtrinsicV5, Sr25519Signature } from '../interfaces/extrinsics/index.js';
|
||||
import type { FunctionMetadataLatest } from '../interfaces/metadata/index.js';
|
||||
import type { Address, Call, CodecHash, Hash } from '../interfaces/runtime/index.js';
|
||||
import type { MultiLocation } from '../interfaces/types.js';
|
||||
import type { CallBase, ExtrinsicPayloadValue, ICompact, IExtrinsic, IKeyringPair, INumber, Registry, SignatureOptions } from '../types/index.js';
|
||||
import type { GenericExtrinsicEra } from './ExtrinsicEra.js';
|
||||
import type { ExtrinsicValueV4 } from './v4/Extrinsic.js';
|
||||
import type { Preamble } from './types.js';
|
||||
import type { ExtrinsicValueV5 } from './v5/Extrinsic.js';
|
||||
|
||||
import { AbstractBase } from '@polkadot/types-codec';
|
||||
import { compactAddLength, compactFromU8a, compactToU8a, isHex, isU8a, objectProperty, objectSpread, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { EXTRINSIC_VERSION as LATEST_EXTRINSIC_VERSION } from './v4/Extrinsic.js';
|
||||
import { BIT_SIGNED, BIT_UNSIGNED, DEFAULT_VERSION, UNMASK_VERSION } from './constants.js';
|
||||
import { BARE_EXTRINSIC, BIT_SIGNED, BIT_UNSIGNED, DEFAULT_PREAMBLE, GENERAL_EXTRINSIC, LATEST_EXTRINSIC_VERSION, LOWEST_SUPPORTED_EXTRINSIC_FORMAT_VERSION, SIGNED_EXTRINSIC, TYPE_MASK, VERSION_MASK } from './constants.js';
|
||||
|
||||
interface CreateOptions {
|
||||
version?: number;
|
||||
preamble?: Preamble;
|
||||
}
|
||||
|
||||
// NOTE The following 2 types, as well as the VERSION structure and the latest export
|
||||
// is to be changed with the addition of a new extrinsic version
|
||||
|
||||
type ExtrinsicVx = ExtrinsicV4;
|
||||
type ExtrinsicValue = ExtrinsicValueV4;
|
||||
type ExtrinsicVx = ExtrinsicV5 | GeneralExtrinsic;
|
||||
type ExtrinsicValue = ExtrinsicValueV5;
|
||||
|
||||
const VERSIONS = [
|
||||
'ExtrinsicUnknown', // v0 is unknown
|
||||
'ExtrinsicUnknown',
|
||||
'ExtrinsicUnknown',
|
||||
'ExtrinsicUnknown',
|
||||
'ExtrinsicV4'
|
||||
'ExtrinsicV4',
|
||||
'ExtrinsicV5'
|
||||
];
|
||||
|
||||
const PREAMBLE = {
|
||||
bare: 'ExtrinsicV5',
|
||||
general: 'GeneralExtrinsic',
|
||||
signed: 'ExtrinsicV5'
|
||||
};
|
||||
|
||||
const PreambleMask = {
|
||||
bare: BARE_EXTRINSIC,
|
||||
general: GENERAL_EXTRINSIC,
|
||||
signed: SIGNED_EXTRINSIC
|
||||
};
|
||||
|
||||
const preambleUnMask: Record<string, Preamble> = {
|
||||
0: 'bare',
|
||||
// eslint-disable-next-line sort-keys
|
||||
64: 'general',
|
||||
// eslint-disable-next-line sort-keys
|
||||
128: 'signed'
|
||||
};
|
||||
|
||||
export { LATEST_EXTRINSIC_VERSION };
|
||||
|
||||
/** @internal */
|
||||
function newFromValue (registry: Registry, value: any, version: number): ExtrinsicVx | ExtrinsicUnknown {
|
||||
function newFromValue (registry: Registry, value: any, version: number, preamble: Preamble): ExtrinsicVx | ExtrinsicUnknown {
|
||||
if (value instanceof GenericExtrinsic) {
|
||||
return value.unwrap();
|
||||
}
|
||||
|
||||
const isSigned = (version & BIT_SIGNED) === BIT_SIGNED;
|
||||
const type = VERSIONS[version & UNMASK_VERSION] || VERSIONS[0];
|
||||
const type = (version & VERSION_MASK) === 5 ? PREAMBLE[preamble] : VERSIONS[version & VERSION_MASK] || VERSIONS[0];
|
||||
|
||||
// we cast here since the VERSION definition is incredibly broad - we don't have a
|
||||
// slice for "only add extrinsic types", and more string definitions become unwieldy
|
||||
@@ -52,20 +75,20 @@ function newFromValue (registry: Registry, value: any, version: number): Extrins
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeExtrinsic (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, version: number = DEFAULT_VERSION): ExtrinsicVx | ExtrinsicUnknown {
|
||||
function decodeExtrinsic (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, version: number = LOWEST_SUPPORTED_EXTRINSIC_FORMAT_VERSION, preamble: Preamble = DEFAULT_PREAMBLE): ExtrinsicVx | ExtrinsicUnknown {
|
||||
if (isU8a(value) || Array.isArray(value) || isHex(value)) {
|
||||
return decodeU8a(registry, u8aToU8a(value), version);
|
||||
return decodeU8a(registry, u8aToU8a(value), version, preamble);
|
||||
} else if (value instanceof registry.createClassUnsafe('Call')) {
|
||||
return newFromValue(registry, { method: value }, version);
|
||||
return newFromValue(registry, { method: value }, version, preamble);
|
||||
}
|
||||
|
||||
return newFromValue(registry, value, version);
|
||||
return newFromValue(registry, value, version, preamble);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeU8a (registry: Registry, value: Uint8Array, version: number): ExtrinsicVx | ExtrinsicUnknown {
|
||||
function decodeU8a (registry: Registry, value: Uint8Array, version: number, preamble: Preamble): ExtrinsicVx | ExtrinsicUnknown {
|
||||
if (!value.length) {
|
||||
return newFromValue(registry, new Uint8Array(), version);
|
||||
return newFromValue(registry, new Uint8Array(), version, preamble);
|
||||
}
|
||||
|
||||
const [offset, length] = compactFromU8a(value);
|
||||
@@ -76,22 +99,41 @@ function decodeU8a (registry: Registry, value: Uint8Array, version: number): Ext
|
||||
}
|
||||
|
||||
const data = value.subarray(offset, total);
|
||||
const unmaskedPreamble = data[0] & TYPE_MASK;
|
||||
|
||||
return newFromValue(registry, data.subarray(1), data[0]);
|
||||
if (preambleUnMask[`${unmaskedPreamble}`] === 'general') {
|
||||
// NOTE: GeneralExtrinsic needs to have the full data to validate the preamble and version
|
||||
return newFromValue(registry, value, data[0], preambleUnMask[`${unmaskedPreamble}`] || preamble);
|
||||
} else {
|
||||
return newFromValue(registry, data.subarray(1), data[0], preambleUnMask[`${unmaskedPreamble}`] || preamble);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicVx | ExtrinsicUnknown> {
|
||||
constructor (registry: Registry, value: ExtrinsicV4 | ExtrinsicUnknown, initialU8aLength?: number) {
|
||||
readonly #preamble: Preamble;
|
||||
|
||||
constructor (registry: Registry, value: ExtrinsicVx | ExtrinsicUnknown, initialU8aLength?: number, preamble?: Preamble) {
|
||||
super(registry, value, initialU8aLength);
|
||||
|
||||
const signKeys = Object.keys(registry.getSignedExtensionTypes());
|
||||
const getter = (key: string) => this.inner.signature[key as 'signer'];
|
||||
|
||||
// This is on the abstract class, ensuring that hasOwnProperty operates
|
||||
// correctly, i.e. it needs to be on the base class exposing it
|
||||
for (let i = 0, count = signKeys.length; i < count; i++) {
|
||||
objectProperty(this, signKeys[i], getter);
|
||||
if (this.version === 5 && preamble !== 'general') {
|
||||
const getter = (key: string) => (this.inner.signature as unknown as ExtrinsicSignatureV5)[key as 'signer'];
|
||||
|
||||
// This is on the abstract class, ensuring that hasOwnProperty operates
|
||||
// correctly, i.e. it needs to be on the base class exposing it
|
||||
for (let i = 0, count = signKeys.length; i < count; i++) {
|
||||
objectProperty(this, signKeys[i], getter);
|
||||
}
|
||||
}
|
||||
|
||||
const unmaskedPreamble = this.type & TYPE_MASK;
|
||||
|
||||
this.#preamble = preamble || preambleUnMask[`${unmaskedPreamble}`];
|
||||
}
|
||||
|
||||
public isGeneral () {
|
||||
return this.#preamble === 'general';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +168,9 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicV
|
||||
* @description The era for this extrinsic
|
||||
*/
|
||||
public get era (): GenericExtrinsicEra {
|
||||
return this.inner.signature.era;
|
||||
return this.isGeneral()
|
||||
? (this.inner as unknown as GeneralExtrinsic).era
|
||||
: (this.inner.signature as unknown as ExtrinsicSignatureV5).era;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +184,9 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicV
|
||||
* @description `true` id the extrinsic is signed
|
||||
*/
|
||||
public get isSigned (): boolean {
|
||||
return this.inner.signature.isSigned;
|
||||
return this.isGeneral()
|
||||
? false
|
||||
: (this.inner.signature as unknown as ExtrinsicSignatureV5).isSigned;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,49 +214,67 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicV
|
||||
* @description The nonce for this extrinsic
|
||||
*/
|
||||
public get nonce (): ICompact<INumber> {
|
||||
return this.inner.signature.nonce;
|
||||
return this.isGeneral()
|
||||
? (this.inner as unknown as GeneralExtrinsic).nonce
|
||||
: (this.inner.signature as unknown as ExtrinsicSignatureV5).nonce;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The actual [[EcdsaSignature]], [[Ed25519Signature]] or [[Sr25519Signature]]
|
||||
*/
|
||||
public get signature (): EcdsaSignature | Ed25519Signature | Sr25519Signature {
|
||||
return this.inner.signature.signature;
|
||||
if (this.isGeneral()) {
|
||||
throw new Error('Extrinsic: GeneralExtrinsic does not have signature implemented');
|
||||
}
|
||||
|
||||
return (this.inner.signature as unknown as ExtrinsicSignatureV5).signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Address]] that signed
|
||||
*/
|
||||
public get signer (): Address {
|
||||
return this.inner.signature.signer;
|
||||
if (this.isGeneral()) {
|
||||
throw new Error('Extrinsic: GeneralExtrinsic does not have signer implemented');
|
||||
}
|
||||
|
||||
return (this.inner.signature as unknown as ExtrinsicSignatureV5).signer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Forwards compat
|
||||
*/
|
||||
public get tip (): ICompact<INumber> {
|
||||
return this.inner.signature.tip;
|
||||
return this.isGeneral()
|
||||
? (this.inner as unknown as GeneralExtrinsic).tip
|
||||
: (this.inner.signature as unknown as ExtrinsicSignatureV5).tip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Forward compat
|
||||
*/
|
||||
public get assetId (): IOption<INumber | MultiLocation> {
|
||||
return this.inner.signature.assetId;
|
||||
return this.isGeneral()
|
||||
? (this.inner as unknown as GeneralExtrinsic).assetId
|
||||
: (this.inner.signature as unknown as ExtrinsicSignatureV5).assetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Forward compat
|
||||
*/
|
||||
public get metadataHash (): IOption<Hash> {
|
||||
return this.inner.signature.metadataHash;
|
||||
return this.isGeneral()
|
||||
? (this.inner as unknown as GeneralExtrinsic).metadataHash
|
||||
: (this.inner.signature as unknown as ExtrinsicSignatureV5).metadataHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Forward compat
|
||||
*/
|
||||
public get mode (): INumber {
|
||||
return this.inner.signature.mode;
|
||||
return this.isGeneral()
|
||||
? (this.inner as unknown as GeneralExtrinsic).mode
|
||||
: (this.inner.signature as unknown as ExtrinsicSignatureV5).mode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +292,11 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends AbstractBase<ExtrinsicV
|
||||
* @description Returns the encoded version flag
|
||||
*/
|
||||
public get version (): number {
|
||||
return this.type | (this.isSigned ? BIT_SIGNED : BIT_UNSIGNED);
|
||||
if (this.type <= LOWEST_SUPPORTED_EXTRINSIC_FORMAT_VERSION) {
|
||||
return this.type | (this.isSigned ? BIT_SIGNED : BIT_UNSIGNED);
|
||||
} else {
|
||||
return this.type | (this.isSigned ? PreambleMask.signed : this.isGeneral() ? PreambleMask.general : PreambleMask.bare);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,8 +328,8 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
|
||||
|
||||
static LATEST_EXTRINSIC_VERSION = LATEST_EXTRINSIC_VERSION;
|
||||
|
||||
constructor (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, { version }: CreateOptions = {}) {
|
||||
super(registry, decodeExtrinsic(registry, value, version));
|
||||
constructor (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, { preamble, version }: CreateOptions = {}) {
|
||||
super(registry, decodeExtrinsic(registry, value, version || registry.metadata.extrinsic.version?.toNumber(), preamble), undefined, preamble);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,37 +5,49 @@ import type { Bytes } from '@polkadot/types-codec';
|
||||
import type { AnyJson, BareOpts, Registry } from '@polkadot/types-codec/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { BlockHash } from '../interfaces/chain/index.js';
|
||||
import type { ExtrinsicPayloadV4 } from '../interfaces/extrinsics/index.js';
|
||||
import type { ExtrinsicPayloadV5 } from '../interfaces/extrinsics/index.js';
|
||||
import type { Hash, MultiLocation } from '../interfaces/types.js';
|
||||
import type { ExtrinsicPayloadValue, ICompact, IKeyringPair, INumber, IOption } from '../types/index.js';
|
||||
import type { GenericExtrinsicEra } from './ExtrinsicEra.js';
|
||||
import type { Preamble } from './types.js';
|
||||
|
||||
import { AbstractBase } from '@polkadot/types-codec';
|
||||
import { hexToU8a, isHex, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { DEFAULT_VERSION } from './constants.js';
|
||||
import { DEFAULT_PREAMBLE, LATEST_EXTRINSIC_VERSION } from './constants.js';
|
||||
|
||||
interface ExtrinsicPayloadOptions {
|
||||
version?: number;
|
||||
preamble?: Preamble;
|
||||
}
|
||||
|
||||
// all our known types that can be returned
|
||||
type ExtrinsicPayloadVx = ExtrinsicPayloadV4;
|
||||
type ExtrinsicPayloadVx = ExtrinsicPayloadV5;
|
||||
|
||||
const VERSIONS = [
|
||||
'ExtrinsicPayloadUnknown', // v0 is unknown
|
||||
'ExtrinsicPayloadUnknown',
|
||||
'ExtrinsicPayloadUnknown',
|
||||
'ExtrinsicPayloadUnknown',
|
||||
'ExtrinsicPayloadV4'
|
||||
'ExtrinsicPayloadV4',
|
||||
'ExtrinsicPayloadV5'
|
||||
];
|
||||
|
||||
const PREAMBLES = {
|
||||
bare: 'ExtrinsicPayloadV5',
|
||||
// Not supported yet
|
||||
general: 'ExtrinsicPayloadV5',
|
||||
signed: 'ExtrinsicPayloadV5'
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
function decodeExtrinsicPayload (registry: Registry, value?: GenericExtrinsicPayload | ExtrinsicPayloadValue | Uint8Array | string, version: number = DEFAULT_VERSION): ExtrinsicPayloadVx {
|
||||
function decodeExtrinsicPayload (registry: Registry, value?: GenericExtrinsicPayload | ExtrinsicPayloadValue | Uint8Array | string, version = LATEST_EXTRINSIC_VERSION, preamble: Preamble = DEFAULT_PREAMBLE): ExtrinsicPayloadVx {
|
||||
if (value instanceof GenericExtrinsicPayload) {
|
||||
return value.unwrap();
|
||||
}
|
||||
|
||||
const extVersion = version === 5 ? PREAMBLES[preamble] : VERSIONS[version] || VERSIONS[0];
|
||||
|
||||
/**
|
||||
* HACK: In order to change the assetId from `number | object` to HexString (While maintaining the true type ie Option<TAssetConversion>),
|
||||
* to allow for easier generalization of the SignerPayloadJSON interface the below check is necessary. The ExtrinsicPayloadV4 class does not like
|
||||
@@ -51,10 +63,10 @@ function decodeExtrinsicPayload (registry: Registry, value?: GenericExtrinsicPay
|
||||
assetId: registry.createType('TAssetConversion', hexToU8a((value as ExtrinsicPayloadValue).assetId)).toJSON()
|
||||
};
|
||||
|
||||
return registry.createTypeUnsafe(VERSIONS[version] || VERSIONS[0], [adjustedPayload, { version }]);
|
||||
return registry.createTypeUnsafe(extVersion, [adjustedPayload, { version }]);
|
||||
}
|
||||
|
||||
return registry.createTypeUnsafe(VERSIONS[version] || VERSIONS[0], [value, { version }]);
|
||||
return registry.createTypeUnsafe(extVersion, [value, { version }]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,8 +76,8 @@ function decodeExtrinsicPayload (registry: Registry, value?: GenericExtrinsicPay
|
||||
* on the contents included
|
||||
*/
|
||||
export class GenericExtrinsicPayload extends AbstractBase<ExtrinsicPayloadVx> {
|
||||
constructor (registry: Registry, value?: Partial<ExtrinsicPayloadValue> | Uint8Array | string, { version }: ExtrinsicPayloadOptions = {}) {
|
||||
super(registry, decodeExtrinsicPayload(registry, value as ExtrinsicPayloadValue, version));
|
||||
constructor (registry: Registry, value?: Partial<ExtrinsicPayloadValue> | Uint8Array | string, { preamble, version }: ExtrinsicPayloadOptions = {}) {
|
||||
super(registry, decodeExtrinsicPayload(registry, value as ExtrinsicPayloadValue, version, preamble));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,23 @@ export const BIT_UNSIGNED = 0;
|
||||
|
||||
export const EMPTY_U8A = new Uint8Array();
|
||||
|
||||
export const DEFAULT_VERSION = 4;
|
||||
|
||||
export const IMMORTAL_ERA = new Uint8Array([0]);
|
||||
|
||||
export const UNMASK_VERSION = 0b01111111;
|
||||
|
||||
export const DEFAULT_PREAMBLE = 'bare';
|
||||
|
||||
// Latest extrinsic version is v5, which has backwards compatibility for v4 signed extrinsics
|
||||
export const LATEST_EXTRINSIC_VERSION = 5;
|
||||
|
||||
export const VERSION_MASK = 0b00111111;
|
||||
|
||||
export const TYPE_MASK = 0b11000000;
|
||||
|
||||
export const BARE_EXTRINSIC = 0b00000000;
|
||||
|
||||
export const SIGNED_EXTRINSIC = 0b10000000;
|
||||
|
||||
export const GENERAL_EXTRINSIC = 0b01000000;
|
||||
|
||||
export const LOWEST_SUPPORTED_EXTRINSIC_FORMAT_VERSION = 4;
|
||||
|
||||
@@ -11,3 +11,4 @@ export { GenericSignerPayload } from './SignerPayload.js';
|
||||
|
||||
// all starred
|
||||
export * from './v4/index.js';
|
||||
export * from './v5/index.js';
|
||||
|
||||
@@ -21,3 +21,5 @@ export interface ExtrinsicExtraValue {
|
||||
nonce?: AnyNumber;
|
||||
tip?: AnyNumber;
|
||||
}
|
||||
|
||||
export type Preamble = 'signed' | 'bare' | 'general';
|
||||
|
||||
@@ -13,3 +13,16 @@ export function sign (registry: Registry, signerPair: IKeyringPair, u8a: Uint8Ar
|
||||
|
||||
return signerPair.sign(encoded, options);
|
||||
}
|
||||
|
||||
// a helper function for both types of payloads, Raw and metadata-known
|
||||
export function signV5 (registry: Registry, signerPair: IKeyringPair, u8a: Uint8Array, options?: SignOptions): Uint8Array {
|
||||
const encoded = registry.hash(u8a);
|
||||
|
||||
return signerPair.sign(encoded, options);
|
||||
}
|
||||
|
||||
export function signGeneral (registry: Registry, u8a: Uint8Array): Uint8Array {
|
||||
const encoded = registry.hash(u8a);
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
|
||||
import { BN } from '@polkadot/util';
|
||||
|
||||
import { TypeRegistry } from '../../create/index.js';
|
||||
import { decorateExtrinsics, Metadata } from '../../metadata/index.js';
|
||||
import { GenericExtrinsicV5 as Extrinsic } from './index.js';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const tx = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
describe('ExtrinsicV5', (): void => {
|
||||
it('constructs a sane Uint8Array (default)', (): void => {
|
||||
const xt = new Extrinsic(registry);
|
||||
|
||||
// expect(`${xt.method.section}${xt.method.method}`).toEqual('system.fillBlock');
|
||||
expect(`${xt.method.section}.${xt.method.method}`).toEqual('system.remark');
|
||||
|
||||
expect(xt.toU8a()).toEqual(new Uint8Array([
|
||||
0, 0, // index
|
||||
// 0, 0, 0, 0 // fillBlock, Perbill
|
||||
0 // remark, Vec<u8>
|
||||
]));
|
||||
});
|
||||
|
||||
it('creates a unsigned extrinsic', (): void => {
|
||||
expect(
|
||||
new Extrinsic(
|
||||
registry,
|
||||
tx['balances']['transferAllowDeath'](keyring.bob.publicKey, 6969n)
|
||||
).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'0600' + // balance.transferAllowDeath
|
||||
'00' +
|
||||
'd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' +
|
||||
'e56c'
|
||||
);
|
||||
});
|
||||
|
||||
it('creates a signed extrinsic', (): void => {
|
||||
expect(
|
||||
new Extrinsic(
|
||||
registry,
|
||||
tx['balances']['transferAllowDeath'](keyring.bob.publicKey, 6969n)
|
||||
).sign(keyring.alice, {
|
||||
blockHash: '0xec7afaf1cca720ce88c1d1b689d81f0583cc15a97d621cf046dd9abf605ef22f',
|
||||
genesisHash: '0xdcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b',
|
||||
mode: 0,
|
||||
nonce: 1,
|
||||
runtimeVersion: {
|
||||
apis: [],
|
||||
authoringVersion: new BN(123),
|
||||
implName: 'test',
|
||||
implVersion: new BN(123),
|
||||
specName: 'test',
|
||||
specVersion: new BN(123),
|
||||
transactionVersion: new BN(123)
|
||||
},
|
||||
tip: 2
|
||||
}).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'00' +
|
||||
'd172a74cda4c865912c32ba0a80a57ae69abae410e5ccb59dee84e2f4432db4f' +
|
||||
'00' + // ed25519
|
||||
'84181ebef350cc212e70e042b6ebcd33ca955bf9497711a64aa7c64e2b8c2732' +
|
||||
'ab837715364eab7be5cc76f74eefa36d3ba9ee698264ed28a286c8360fc9aa0c' +
|
||||
'00' + // TransactionExtension version
|
||||
'0004080000' + // era. nonce, tip, mode
|
||||
'0600' +
|
||||
'00' +
|
||||
'd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' +
|
||||
'e56c'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,116 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { ExtrinsicSignatureV5 } from '../../interfaces/extrinsics/index.js';
|
||||
import type { Address, Call } from '../../interfaces/runtime/index.js';
|
||||
import type { ExtrinsicPayloadValue, IExtrinsicV5Impl, IKeyringPair, Registry, SignatureOptions } from '../../types/index.js';
|
||||
import type { ExtrinsicOptions, Preamble } from '../types.js';
|
||||
|
||||
import { Struct } from '@polkadot/types-codec';
|
||||
import { isU8a } from '@polkadot/util';
|
||||
|
||||
export const EXTRINSIC_VERSION = 5;
|
||||
|
||||
export interface ExtrinsicValueV5 {
|
||||
method?: Call;
|
||||
signature?: ExtrinsicSignatureV5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name GenericExtrinsicV5
|
||||
* @description
|
||||
* The fourth generation of compact extrinsics
|
||||
*/
|
||||
export class GenericExtrinsicV5 extends Struct implements IExtrinsicV5Impl {
|
||||
constructor (registry: Registry, value?: Uint8Array | ExtrinsicValueV5 | Call, { isSigned }: Partial<ExtrinsicOptions> = {}) {
|
||||
super(registry, {
|
||||
signature: 'ExtrinsicSignatureV5',
|
||||
// eslint-disable-next-line sort-keys
|
||||
method: 'Call'
|
||||
}, GenericExtrinsicV5.decodeExtrinsic(registry, value, isSigned));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeExtrinsic (registry: Registry, value?: Call | Uint8Array | ExtrinsicValueV5, isSigned = false): ExtrinsicValueV5 {
|
||||
if (value instanceof GenericExtrinsicV5) {
|
||||
return value;
|
||||
} else if (value instanceof registry.createClassUnsafe<Call>('Call')) {
|
||||
return { method: value };
|
||||
} else if (isU8a(value)) {
|
||||
// here we decode manually since we need to pull through the version information
|
||||
const signature = registry.createTypeUnsafe<ExtrinsicSignatureV5>('ExtrinsicSignatureV5', [value, { isSigned }]);
|
||||
// We add 2 here since the length of the TransactionExtension Version needs to be accounted for
|
||||
const method = registry.createTypeUnsafe<Call>('Call', [value.subarray(signature.encodedLength)]);
|
||||
|
||||
return {
|
||||
method,
|
||||
signature
|
||||
};
|
||||
}
|
||||
|
||||
return value || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public override get encodedLength (): number {
|
||||
return this.toU8a().length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Call]] this extrinsic wraps
|
||||
*/
|
||||
public get method (): Call {
|
||||
return this.getT('method');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicSignatureV5]]
|
||||
*/
|
||||
public get signature (): ExtrinsicSignatureV5 {
|
||||
return this.getT('signature');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The version for the signature
|
||||
*/
|
||||
public get version (): number {
|
||||
return EXTRINSIC_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Preamble]] for the extrinsic
|
||||
*/
|
||||
public get preamble (): Preamble {
|
||||
return this.getT('preamble');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Add an [[ExtrinsicSignatureV5]] to the extrinsic (already generated)
|
||||
*/
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | HexString, payload: ExtrinsicPayloadValue | Uint8Array | HexString): GenericExtrinsicV5 {
|
||||
this.signature.addSignature(signer, signature, payload);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sign the extrinsic with a specific keypair
|
||||
*/
|
||||
public sign (account: IKeyringPair, options: SignatureOptions): GenericExtrinsicV5 {
|
||||
this.signature.sign(this.method, account, options);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @describe Adds a fake signature to the extrinsic
|
||||
*/
|
||||
public signFake (signer: Address | Uint8Array | string, options: SignatureOptions): GenericExtrinsicV5 {
|
||||
this.signature.signFake(this.method, signer, options);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
import { TypeRegistry } from '../../create/index.js';
|
||||
import { decorateExtrinsics, Metadata } from '../../metadata/index.js';
|
||||
import { GenericExtrinsicPayloadV5 as ExtrinsicPayload } from './index.js';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const tx = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
describe('ExtrinsicPayload', (): void => {
|
||||
it('has a sane inspect', (): void => {
|
||||
// we don't expect this to fail, however it is actually a good
|
||||
// reference for the ordering in base Substrate
|
||||
expect(new ExtrinsicPayload(registry, { method: tx['timestamp']['set'](0).toHex() } as never).inspect()).toEqual({
|
||||
inner: [
|
||||
{ name: 'method', outer: [new Uint8Array([3, 0, 0])] },
|
||||
{ inner: undefined, name: 'era', outer: [new Uint8Array([0]), new Uint8Array([0])] },
|
||||
{ name: 'nonce', outer: [new Uint8Array([0])] },
|
||||
{ name: 'tip', outer: [new Uint8Array([0])] },
|
||||
{ name: 'assetId', outer: [new Uint8Array([0])] },
|
||||
{ name: 'mode', outer: [new Uint8Array([0])] },
|
||||
{ name: 'specVersion', outer: [new Uint8Array([0, 0, 0, 0])] },
|
||||
{ name: 'transactionVersion', outer: [new Uint8Array([0, 0, 0, 0])] },
|
||||
{ name: 'genesisHash', outer: [new Uint8Array(32)] },
|
||||
{ name: 'blockHash', outer: [new Uint8Array(32)] },
|
||||
{ name: 'metadataHash', outer: [new Uint8Array([0])] }
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,130 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { SignOptions } from '@polkadot/keyring/types';
|
||||
import type { Hash, MultiLocation } from '@polkadot/types/interfaces';
|
||||
import type { Bytes } from '@polkadot/types-codec';
|
||||
import type { Inspect, Registry } from '@polkadot/types-codec/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { BlockHash } from '../../interfaces/chain/index.js';
|
||||
import type { ExtrinsicEra } from '../../interfaces/extrinsics/index.js';
|
||||
import type { ExtrinsicPayloadValue, ICompact, IKeyringPair, INumber, IOption } from '../../types/index.js';
|
||||
|
||||
import { Enum, Struct } from '@polkadot/types-codec';
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { signV5 } from '../util.js';
|
||||
|
||||
/**
|
||||
* @name GenericExtrinsicPayloadV5
|
||||
* @description
|
||||
* A signing payload for an [[Extrinsic]]. For the final encoding, it is
|
||||
* variable length based on the contents included
|
||||
*/
|
||||
export class GenericExtrinsicPayloadV5 extends Struct {
|
||||
#signOptions: SignOptions;
|
||||
|
||||
constructor (registry: Registry, value?: ExtrinsicPayloadValue | Uint8Array | HexString) {
|
||||
super(registry, objectSpread(
|
||||
{ method: 'Bytes' },
|
||||
registry.getSignedExtensionTypes(),
|
||||
registry.getSignedExtensionExtra()
|
||||
), value);
|
||||
|
||||
// Do detection for the type of extrinsic, in the case of MultiSignature
|
||||
// this is an enum, in the case of AnySignature, this is a Hash only
|
||||
// (which may be 64 or 65 bytes)
|
||||
this.#signOptions = {
|
||||
withType: registry.createTypeUnsafe('ExtrinsicSignature', []) instanceof Enum
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a breakdown of the hex encoding for this Codec
|
||||
*/
|
||||
public override inspect (): Inspect {
|
||||
return super.inspect({ method: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The block [[BlockHash]] the signature applies to (mortal/immortal)
|
||||
*/
|
||||
public get blockHash (): BlockHash {
|
||||
return this.getT('blockHash');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicEra]]
|
||||
*/
|
||||
public get era (): ExtrinsicEra {
|
||||
return this.getT('era');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The genesis [[BlockHash]] the signature applies to (mortal/immortal)
|
||||
*/
|
||||
public get genesisHash (): BlockHash {
|
||||
return this.getT('genesisHash');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Bytes]] contained in the payload
|
||||
*/
|
||||
public get method (): Bytes {
|
||||
return this.getT('method');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Index]]
|
||||
*/
|
||||
public get nonce (): ICompact<INumber> {
|
||||
return this.getT('nonce');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The specVersion for this signature
|
||||
*/
|
||||
public get specVersion (): INumber {
|
||||
return this.getT('specVersion');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The tip [[Balance]]
|
||||
*/
|
||||
public get tip (): ICompact<INumber> {
|
||||
return this.getT('tip');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The transactionVersion for this signature
|
||||
*/
|
||||
public get transactionVersion (): INumber {
|
||||
return this.getT('transactionVersion');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The (optional) asset id for this signature for chains that support transaction fees in assets
|
||||
*/
|
||||
public get assetId (): IOption<INumber | MultiLocation> {
|
||||
return this.getT('assetId');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The (optional) metadataHash proof for the CheckMetadataHash TransactionExtension
|
||||
*/
|
||||
public get metadataHash (): IOption<Hash> {
|
||||
return this.getT('metadataHash');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
// NOTE The `toU8a({ method: true })` argument is absolutely critical, we
|
||||
// don't want the method (Bytes) to have the length prefix included. This
|
||||
// means that the data-as-signed is un-decodable, but is also doesn't need
|
||||
// the extra information, only the pure data (and is not decoded) ...
|
||||
// The same applies to V1..V3, if we have a V6, carry this comment
|
||||
return signV5(this.registry, signerPair, this.toU8a({ method: true }), this.#signOptions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import metadataStatic from '@polkadot/types-support/metadata/static-substrate';
|
||||
import { BN_ZERO } from '@polkadot/util';
|
||||
|
||||
import { TypeRegistry } from '../../create/index.js';
|
||||
import { Metadata } from '../../metadata/index.js';
|
||||
import { GenericExtrinsicSignatureV5 as ExtrinsicSignature } from './index.js';
|
||||
|
||||
const signOptions = {
|
||||
blockHash: '0x1234567890123456789012345678901234567890123456789012345678901234',
|
||||
genesisHash: '0x1234567890123456789012345678901234567890123456789012345678901234',
|
||||
nonce: '0x69',
|
||||
runtimeVersion: {
|
||||
apis: [],
|
||||
authoringVersion: BN_ZERO,
|
||||
implName: String('test'),
|
||||
implVersion: BN_ZERO,
|
||||
specName: String('test'),
|
||||
specVersion: BN_ZERO,
|
||||
transactionVersion: BN_ZERO
|
||||
}
|
||||
};
|
||||
|
||||
describe('ExtrinsicSignatureV4', (): void => {
|
||||
const pairs = createTestPairs({ type: 'ed25519' });
|
||||
|
||||
it('encodes to a sane Uint8Array (default)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
const u8a = new Uint8Array([
|
||||
// signer as an AccountIndex
|
||||
0x01, 0x08, // 4 << 2
|
||||
// signature type
|
||||
0x01,
|
||||
// signature
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x00, // TransactionExtension version
|
||||
// extra stuff
|
||||
0x00, // immortal,
|
||||
0x04, // nonce, compact
|
||||
0x08 // tip, compact
|
||||
]);
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry, u8a, { isSigned: true }).toU8a()
|
||||
).toEqual(u8a);
|
||||
});
|
||||
|
||||
it('fake signs default', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry).signFake(
|
||||
registry.createType('Call'),
|
||||
pairs.alice.publicKey,
|
||||
signOptions
|
||||
).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'00' + // MultiAddress
|
||||
'd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' +
|
||||
'01' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'00' + // TransactionExtension version
|
||||
'00a5010000' +
|
||||
'00' // Mode
|
||||
);
|
||||
});
|
||||
|
||||
it('fake signs default (AccountId address)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
registry.register({
|
||||
Address: 'AccountId',
|
||||
ExtrinsicSignature: 'AnySignature'
|
||||
});
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry).signFake(
|
||||
registry.createType('Call'),
|
||||
pairs.alice.address,
|
||||
signOptions
|
||||
).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
// Address = AccountId, no prefix
|
||||
'd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' +
|
||||
// This is a prefix-less signature, anySignture as opposed to Multi above
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'00' + // TransactionExtension version
|
||||
'00a5010000' +
|
||||
'00' // mode
|
||||
);
|
||||
});
|
||||
|
||||
it('fake signs with non-enum signature', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
registry.register({
|
||||
Address: 'AccountId',
|
||||
ExtrinsicSignature: '[u8;65]'
|
||||
});
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry).signFake(
|
||||
registry.createType('Call'),
|
||||
pairs.alice.address,
|
||||
signOptions
|
||||
).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
// Address = AccountId, no prefix
|
||||
'd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' +
|
||||
// 65 bytes here
|
||||
'01' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'00' + // TransactionExtension version
|
||||
'00a5010000' +
|
||||
'00' // mode
|
||||
);
|
||||
});
|
||||
|
||||
it('injects a signature', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry).addSignature(
|
||||
pairs.alice.publicKey,
|
||||
new Uint8Array(65).fill(1),
|
||||
new Uint8Array(0)
|
||||
).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'00' + // MultiAddress
|
||||
'd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' +
|
||||
'01' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'00' + // TransactionExtension version
|
||||
'00000000' +
|
||||
'00' // mode
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,241 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MultiLocation } from '@polkadot/types/interfaces';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { EcdsaSignature, Ed25519Signature, ExtrinsicEra, ExtrinsicSignature, Sr25519Signature } from '../../interfaces/extrinsics/index.js';
|
||||
import type { Address, Call, Hash } from '../../interfaces/runtime/index.js';
|
||||
import type { ExtrinsicPayloadValue, ICompact, IExtrinsicSignature, IKeyringPair, INumber, IOption, Registry, SignatureOptions } from '../../types/index.js';
|
||||
import type { ExtrinsicSignatureOptions } from '../types.js';
|
||||
|
||||
import { Struct } from '@polkadot/types-codec';
|
||||
import { isU8a, isUndefined, objectProperties, objectSpread, stringify, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { EMPTY_U8A, IMMORTAL_ERA } from '../constants.js';
|
||||
import { GenericExtrinsicPayloadV5 } from './ExtrinsicPayload.js';
|
||||
|
||||
// Ensure we have enough data for all types of signatures
|
||||
const FAKE_SIGNATURE = new Uint8Array(256).fill(1);
|
||||
|
||||
function toAddress (registry: Registry, address: Address | Uint8Array | string): Address {
|
||||
return registry.createTypeUnsafe('Address', [isU8a(address) ? u8aToHex(address) : address]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name GenericExtrinsicSignatureV5
|
||||
* @description
|
||||
* A container for the [[Signature]] associated with a specific [[Extrinsic]]
|
||||
*/
|
||||
export class GenericExtrinsicSignatureV5 extends Struct implements IExtrinsicSignature {
|
||||
#signKeys: string[];
|
||||
#transactionExtensionVersion: number;
|
||||
|
||||
constructor (registry: Registry, value?: GenericExtrinsicSignatureV5 | Uint8Array, { isSigned }: ExtrinsicSignatureOptions = {}) {
|
||||
const signTypes = registry.getSignedExtensionTypes();
|
||||
const signedVersion = registry.getTransactionExtensionVersion();
|
||||
|
||||
super(
|
||||
registry,
|
||||
objectSpread(
|
||||
// eslint-disable-next-line sort-keys
|
||||
{ signer: 'Address', signature: 'ExtrinsicSignature', transactionExtensionVersion: 'u8' },
|
||||
signTypes
|
||||
),
|
||||
GenericExtrinsicSignatureV5.decodeExtrinsicSignature(value, isSigned)
|
||||
);
|
||||
|
||||
this.#transactionExtensionVersion = signedVersion;
|
||||
this.#signKeys = Object.keys(signTypes);
|
||||
|
||||
objectProperties(this, this.#signKeys, (k) => this.get(k));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeExtrinsicSignature (value?: GenericExtrinsicSignatureV5 | Uint8Array, isSigned = false): GenericExtrinsicSignatureV5 | Uint8Array {
|
||||
if (!value) {
|
||||
return EMPTY_U8A;
|
||||
} else if (value instanceof GenericExtrinsicSignatureV5) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return isSigned
|
||||
? value
|
||||
: EMPTY_U8A;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public override get encodedLength (): number {
|
||||
return this.isSigned
|
||||
? super.encodedLength
|
||||
: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` if the signature is valid
|
||||
*/
|
||||
public get isSigned (): boolean {
|
||||
return !this.signature.isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicEra]] (mortal or immortal) this signature applies to
|
||||
*/
|
||||
public get era (): ExtrinsicEra {
|
||||
return this.getT('era');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Index]] for the signature
|
||||
*/
|
||||
public get nonce (): ICompact<INumber> {
|
||||
return this.getT('nonce');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The actual [[EcdsaSignature]], [[Ed25519Signature]] or [[Sr25519Signature]]
|
||||
*/
|
||||
public get signature (): EcdsaSignature | Ed25519Signature | Sr25519Signature {
|
||||
// the second case here is when we don't have an enum signature, treat as raw
|
||||
return (this.multiSignature.value || this.multiSignature) as Sr25519Signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The raw [[ExtrinsicSignature]]
|
||||
*/
|
||||
public get multiSignature (): ExtrinsicSignature {
|
||||
return this.getT('signature');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Address]] that signed
|
||||
*/
|
||||
public get signer (): Address {
|
||||
return this.getT('signer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Balance]] tip
|
||||
*/
|
||||
public get tip (): ICompact<INumber> {
|
||||
return this.getT('tip');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[u32]] or [[MultiLocation]] assetId
|
||||
*/
|
||||
public get assetId (): IOption<INumber | MultiLocation> {
|
||||
return this.getT('assetId');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description the [[u32]] mode
|
||||
*/
|
||||
public get mode (): INumber {
|
||||
return this.getT('mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The (optional) [[Hash]] for the metadata proof
|
||||
*/
|
||||
public get metadataHash (): IOption<Hash> {
|
||||
return this.getT('metadataHash');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[u8]] for the TransactionExtension version
|
||||
*/
|
||||
public get transactionExtensionVersion (): INumber {
|
||||
return this.getT('transactionExtensionVersion');
|
||||
}
|
||||
|
||||
protected _injectSignature (signer: Address, signature: ExtrinsicSignature, payload: GenericExtrinsicPayloadV5): IExtrinsicSignature {
|
||||
// use the fields exposed to guide the getters
|
||||
for (let i = 0, count = this.#signKeys.length; i < count; i++) {
|
||||
const k = this.#signKeys[i];
|
||||
const v = payload.get(k);
|
||||
|
||||
if (k === 'transactionExtensionVersion') {
|
||||
this.set(k, this.registry.createType('u8', this.#transactionExtensionVersion));
|
||||
} else if (!isUndefined(v)) {
|
||||
this.set(k, v);
|
||||
}
|
||||
}
|
||||
|
||||
// additional fields (exposed in struct itself)
|
||||
this.set('signer', signer);
|
||||
this.set('signature', signature);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Adds a raw signature
|
||||
*/
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | HexString, payload: ExtrinsicPayloadValue | Uint8Array | HexString): IExtrinsicSignature {
|
||||
return this._injectSignature(
|
||||
toAddress(this.registry, signer),
|
||||
this.registry.createTypeUnsafe('ExtrinsicSignature', [signature]),
|
||||
new GenericExtrinsicPayloadV5(this.registry, payload)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Creates a payload from the supplied options
|
||||
*/
|
||||
public createPayload (method: Call, options: SignatureOptions): GenericExtrinsicPayloadV5 {
|
||||
const { era, runtimeVersion: { specVersion, transactionVersion } } = options;
|
||||
|
||||
return new GenericExtrinsicPayloadV5(this.registry, objectSpread<ExtrinsicPayloadValue>({}, options, {
|
||||
era: era || IMMORTAL_ERA,
|
||||
method: method.toHex(),
|
||||
specVersion,
|
||||
transactionVersion
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
if (!account?.addressRaw) {
|
||||
throw new Error(`Expected a valid keypair for signing, found ${stringify(account)}`);
|
||||
}
|
||||
|
||||
const payload = this.createPayload(method, options);
|
||||
|
||||
return this._injectSignature(
|
||||
toAddress(this.registry, account.addressRaw),
|
||||
this.registry.createTypeUnsafe('ExtrinsicSignature', [payload.sign(account)]),
|
||||
payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Generate a payload and applies a fake signature
|
||||
*/
|
||||
public signFake (method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature {
|
||||
if (!address) {
|
||||
throw new Error(`Expected a valid address for signing, found ${stringify(address)}`);
|
||||
}
|
||||
|
||||
const payload = this.createPayload(method, options);
|
||||
|
||||
return this._injectSignature(
|
||||
toAddress(this.registry, address),
|
||||
this.registry.createTypeUnsafe('ExtrinsicSignature', [FAKE_SIGNATURE]),
|
||||
payload
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
||||
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
||||
*/
|
||||
public override toU8a (isBare?: boolean): Uint8Array {
|
||||
return this.isSigned
|
||||
? super.toU8a(isBare)
|
||||
: EMPTY_U8A;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
import { TypeRegistry } from '../../create/index.js';
|
||||
import { Metadata } from '../../metadata/index.js';
|
||||
import { GeneralExtrinsic } from './GeneralExtrinsic.js';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
describe('GeneralExt', (): void => {
|
||||
const extrinsic = '0xc44500650000000000060000d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0700e40b5402';
|
||||
|
||||
it('Can decode a general extrinsic', (): void => {
|
||||
const genExt = new GeneralExtrinsic(registry, extrinsic);
|
||||
|
||||
expect(genExt.version).toEqual(5);
|
||||
expect(genExt.transactionExtensionVersion.toNumber()).toEqual(0);
|
||||
expect(genExt.method.toHuman()).toEqual({ args: { dest: { Id: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY' }, value: '10,000,000,000' }, method: 'transferAllowDeath', section: 'balances' });
|
||||
expect(genExt.era.toHuman()).toEqual({ MortalEra: { period: '64', phase: '6' } });
|
||||
expect(genExt.tip.toNumber()).toEqual(0);
|
||||
expect(genExt.mode.toNumber()).toEqual(0);
|
||||
expect(genExt.assetId.toHuman()).toEqual(null);
|
||||
expect(genExt.nonce.toNumber()).toEqual(0);
|
||||
});
|
||||
|
||||
it('Can encode a general extrinsic', (): void => {
|
||||
const payload = {
|
||||
era: '0x6500',
|
||||
method: '0x060000d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0700e40b5402',
|
||||
nonce: '0x00000000',
|
||||
tip: '0x00000000000000000000000000000000',
|
||||
transactionVersion: '0x00000002'
|
||||
};
|
||||
const genExt = new GeneralExtrinsic(registry, {
|
||||
payload
|
||||
});
|
||||
|
||||
expect(genExt.toHex()).toEqual(extrinsic);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,208 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Call, ExtrinsicEra, Hash, MultiLocation } from '@polkadot/types/interfaces';
|
||||
import type { AnyNumber, AnyU8a, ICompact, IExtrinsicEra, INumber, IOption, Registry } from '@polkadot/types/types';
|
||||
import type { AnyTuple, IMethod } from '@polkadot/types-codec/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
import { Struct } from '@polkadot/types-codec';
|
||||
import { compactAddLength, compactFromU8a, isHex, isObject, isU8a, objectSpread, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { EMPTY_U8A, UNMASK_VERSION } from '../constants.js';
|
||||
|
||||
interface TransactionExtensionValues {
|
||||
era: AnyU8a | IExtrinsicEra;
|
||||
nonce: AnyNumber;
|
||||
tip: AnyNumber;
|
||||
transactionVersion: AnyNumber;
|
||||
assetId?: HexString;
|
||||
mode?: AnyNumber;
|
||||
metadataHash?: AnyU8a;
|
||||
}
|
||||
|
||||
interface GeneralExtrinsicPayloadValues extends TransactionExtensionValues {
|
||||
method: AnyU8a | IMethod<AnyTuple>;
|
||||
}
|
||||
|
||||
interface GeneralExtrinsicValue {
|
||||
payload?: GeneralExtrinsicPayloadValues;
|
||||
transactionExtensionVersion?: number;
|
||||
}
|
||||
|
||||
function decodeU8a (u8a: Uint8Array) {
|
||||
if (!u8a.length) {
|
||||
return new Uint8Array();
|
||||
}
|
||||
|
||||
const [offset, length] = compactFromU8a(u8a);
|
||||
const total = offset + length.toNumber();
|
||||
|
||||
if (total > u8a.length) {
|
||||
throw new Error(`Extrinsic: length less than remainder, expected at least ${total}, found ${u8a.length}`);
|
||||
}
|
||||
|
||||
const data = u8a.subarray(offset, total);
|
||||
|
||||
// 69 denotes 0b01000101 which is the version and preamble for this Extrinsic
|
||||
if (data[0] !== 69) {
|
||||
throw new Error(`Extrinsic: incorrect version for General Transactions, expected 5, found ${data[0] & UNMASK_VERSION}`);
|
||||
}
|
||||
|
||||
return data.subarray(1);
|
||||
}
|
||||
|
||||
export class GeneralExtrinsic extends Struct {
|
||||
#version: number;
|
||||
#preamble: number;
|
||||
|
||||
constructor (registry: Registry, value?: GeneralExtrinsicValue | Uint8Array | HexString, opt?: { version: number }) {
|
||||
const extTypes = registry.getSignedExtensionTypes();
|
||||
|
||||
super(registry, objectSpread(
|
||||
{
|
||||
transactionExtensionVersion: 'u8'
|
||||
},
|
||||
extTypes,
|
||||
{
|
||||
method: 'Call'
|
||||
}
|
||||
), GeneralExtrinsic.decodeExtrinsic(registry, value));
|
||||
|
||||
this.#version = opt?.version || 0b00000101;
|
||||
this.#preamble = 0b01000000;
|
||||
}
|
||||
|
||||
public static decodeExtrinsic (registry: Registry, value?: GeneralExtrinsicValue | Uint8Array | HexString) {
|
||||
if (!value) {
|
||||
return EMPTY_U8A;
|
||||
} else if (value instanceof GeneralExtrinsic) {
|
||||
return value;
|
||||
} else if (isU8a(value) || Array.isArray(value) || isHex(value)) {
|
||||
return decodeU8a(u8aToU8a(value));
|
||||
} else if (isObject(value)) {
|
||||
const { payload, transactionExtensionVersion } = value;
|
||||
|
||||
return objectSpread(payload || {}, {
|
||||
transactionExtensionVersion: transactionExtensionVersion || registry.getTransactionExtensionVersion()
|
||||
});
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public override get encodedLength (): number {
|
||||
return super.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[ExtrinsicEra]]
|
||||
*/
|
||||
public get era (): ExtrinsicEra {
|
||||
return this.getT('era');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Index]]
|
||||
*/
|
||||
public get nonce (): ICompact<INumber> {
|
||||
return this.getT('nonce');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The tip [[Balance]]
|
||||
*/
|
||||
public get tip (): ICompact<INumber> {
|
||||
return this.getT('tip');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The (optional) asset id for this signature for chains that support transaction fees in assets
|
||||
*/
|
||||
public get assetId (): IOption<INumber | MultiLocation> {
|
||||
return this.getT('assetId');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The mode used for the CheckMetadataHash TransactionExtension
|
||||
*/
|
||||
public get mode (): INumber {
|
||||
return this.getT('mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The (optional) [[Hash]] for the metadata proof
|
||||
*/
|
||||
public get metadataHash (): IOption<Hash> {
|
||||
return this.getT('metadataHash');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The version of the TransactionExtensions used in this extrinsic
|
||||
*/
|
||||
public get transactionExtensionVersion (): INumber {
|
||||
return this.getT('transactionExtensionVersion');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Call]] this extrinsic wraps
|
||||
*/
|
||||
public get method (): Call {
|
||||
return this.getT('method');
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The extrinsic's version
|
||||
*/
|
||||
public get version () {
|
||||
return this.#version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[Preamble]] for the extrinsic
|
||||
*/
|
||||
public get preamble () {
|
||||
return this.#preamble;
|
||||
}
|
||||
|
||||
public override toHex (isBare?: boolean): HexString {
|
||||
return u8aToHex(this.toU8a(isBare));
|
||||
}
|
||||
|
||||
public override toU8a (isBare?: boolean): Uint8Array {
|
||||
return isBare
|
||||
? this.encode()
|
||||
: compactAddLength(this.encode());
|
||||
}
|
||||
|
||||
public override toRawType () {
|
||||
return 'GeneralExt';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @description Returns an encoded GeneralExtrinsic
|
||||
*/
|
||||
public encode () {
|
||||
return u8aConcat(new Uint8Array([this.version | this.preamble]), super.toU8a());
|
||||
}
|
||||
|
||||
public signFake () {
|
||||
throw new Error('Extrinsic: Type GeneralExtrinsic does not have signFake implemented');
|
||||
}
|
||||
|
||||
public addSignature () {
|
||||
throw new Error('Extrinsic: Type GeneralExtrinsic does not have addSignature implemented');
|
||||
}
|
||||
|
||||
public sign () {
|
||||
throw new Error('Extrinsic: Type GeneralExtrinsic does not have sign implemented');
|
||||
}
|
||||
|
||||
public signature () {
|
||||
throw new Error('Extrinsic: Type GeneralExtrinsic does not have the signature getter');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2024 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { GenericExtrinsicV5 } from './Extrinsic.js';
|
||||
export { GenericExtrinsicPayloadV5 } from './ExtrinsicPayload.js';
|
||||
export { GenericExtrinsicSignatureV5 } from './ExtrinsicSignature.js';
|
||||
export { GeneralExtrinsic } from './GeneralExtrinsic.js';
|
||||
@@ -18,6 +18,9 @@ export default {
|
||||
ExtrinsicSignatureV4: 'GenericExtrinsicSignatureV4',
|
||||
ExtrinsicUnknown: 'GenericExtrinsicUnknown',
|
||||
ExtrinsicPayloadUnknown: 'GenericExtrinsicPayloadUnknown',
|
||||
ExtrinsicV5: 'GenericExtrinsicV5',
|
||||
ExtrinsicPayloadV5: 'GenericExtrinsicPayloadV5',
|
||||
ExtrinsicSignatureV5: 'GenericExtrinsicSignatureV5',
|
||||
|
||||
// eras
|
||||
Era: 'ExtrinsicEra',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
import type { GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericExtrinsicPayloadUnknown, GenericExtrinsicPayloadV4, GenericExtrinsicSignatureV4, GenericExtrinsicUnknown, GenericExtrinsicV4, GenericImmortalEra, GenericMortalEra, GenericSignerPayload } from '@polkadot/types';
|
||||
import type { GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericExtrinsicPayloadUnknown, GenericExtrinsicPayloadV4, GenericExtrinsicPayloadV5, GenericExtrinsicSignatureV4, GenericExtrinsicSignatureV5, GenericExtrinsicUnknown, GenericExtrinsicV4, GenericExtrinsicV5, GenericImmortalEra, GenericMortalEra, GenericSignerPayload } from '@polkadot/types';
|
||||
import type { Enum, U8aFixed } from '@polkadot/types-codec';
|
||||
import type { H512 } from '@polkadot/types/interfaces/runtime';
|
||||
|
||||
@@ -32,18 +32,27 @@ export interface ExtrinsicPayloadUnknown extends GenericExtrinsicPayloadUnknown
|
||||
/** @name ExtrinsicPayloadV4 */
|
||||
export interface ExtrinsicPayloadV4 extends GenericExtrinsicPayloadV4 {}
|
||||
|
||||
/** @name ExtrinsicPayloadV5 */
|
||||
export interface ExtrinsicPayloadV5 extends GenericExtrinsicPayloadV5 {}
|
||||
|
||||
/** @name ExtrinsicSignature */
|
||||
export interface ExtrinsicSignature extends MultiSignature {}
|
||||
|
||||
/** @name ExtrinsicSignatureV4 */
|
||||
export interface ExtrinsicSignatureV4 extends GenericExtrinsicSignatureV4 {}
|
||||
|
||||
/** @name ExtrinsicSignatureV5 */
|
||||
export interface ExtrinsicSignatureV5 extends GenericExtrinsicSignatureV5 {}
|
||||
|
||||
/** @name ExtrinsicUnknown */
|
||||
export interface ExtrinsicUnknown extends GenericExtrinsicUnknown {}
|
||||
|
||||
/** @name ExtrinsicV4 */
|
||||
export interface ExtrinsicV4 extends GenericExtrinsicV4 {}
|
||||
|
||||
/** @name ExtrinsicV5 */
|
||||
export interface ExtrinsicV5 extends GenericExtrinsicV5 {}
|
||||
|
||||
/** @name ImmortalEra */
|
||||
export interface ImmortalEra extends GenericImmortalEra {}
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types', path: 'auto', type: 'auto', version: '13.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/types', path: 'auto', type: 'auto', version: '14.0.1' };
|
||||
|
||||
@@ -247,6 +247,12 @@ export interface IExtrinsicImpl extends IExtrinsicSignable<IExtrinsicImpl> {
|
||||
readonly version: number;
|
||||
}
|
||||
|
||||
export interface IExtrinsicV5Impl extends IExtrinsicSignable<IExtrinsicV5Impl> {
|
||||
readonly method: Call;
|
||||
readonly signature: IExtrinsicSignature;
|
||||
readonly version: number;
|
||||
}
|
||||
|
||||
export interface IExtrinsic<A extends AnyTuple = AnyTuple> extends IExtrinsicSignable<IExtrinsic<A>>, ExtrinsicSignatureBase, IMethod<A> {
|
||||
readonly length: number;
|
||||
readonly method: IMethod<A>;
|
||||
|
||||
@@ -447,26 +447,26 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/api-augment@npm:13.1.1, @polkadot/api-augment@workspace:packages/api-augment":
|
||||
"@polkadot/api-augment@npm:14.0.1, @polkadot/api-augment@workspace:packages/api-augment":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/api-augment@workspace:packages/api-augment"
|
||||
dependencies:
|
||||
"@polkadot/api-base": "npm:13.1.1"
|
||||
"@polkadot/rpc-augment": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-augment": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/api-base": "npm:14.0.1"
|
||||
"@polkadot/rpc-augment": "npm:14.0.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-augment": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
tslib: "npm:^2.7.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/api-base@npm:13.1.1, @polkadot/api-base@workspace:packages/api-base":
|
||||
"@polkadot/api-base@npm:14.0.1, @polkadot/api-base@workspace:packages/api-base":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/api-base@workspace:packages/api-base"
|
||||
dependencies:
|
||||
"@polkadot/rpc-core": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/rpc-core": "npm:14.0.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
rxjs: "npm:^7.8.1"
|
||||
tslib: "npm:^2.7.0"
|
||||
@@ -477,13 +477,13 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/api-contract@workspace:packages/api-contract"
|
||||
dependencies:
|
||||
"@polkadot/api": "npm:13.1.1"
|
||||
"@polkadot/api-augment": "npm:13.1.1"
|
||||
"@polkadot/api": "npm:14.0.1"
|
||||
"@polkadot/api-augment": "npm:14.0.1"
|
||||
"@polkadot/keyring": "npm:^13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/types-create": "npm:13.1.1"
|
||||
"@polkadot/types-support": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/types-create": "npm:14.0.1"
|
||||
"@polkadot/types-support": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
"@polkadot/util-crypto": "npm:^13.1.1"
|
||||
rxjs: "npm:^7.8.1"
|
||||
@@ -491,19 +491,19 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/api-derive@npm:13.1.1, @polkadot/api-derive@workspace:packages/api-derive":
|
||||
"@polkadot/api-derive@npm:14.0.1, @polkadot/api-derive@workspace:packages/api-derive":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/api-derive@workspace:packages/api-derive"
|
||||
dependencies:
|
||||
"@polkadot/api": "npm:13.1.1"
|
||||
"@polkadot/api-augment": "npm:13.1.1"
|
||||
"@polkadot/api-base": "npm:13.1.1"
|
||||
"@polkadot/rpc-augment": "npm:13.1.1"
|
||||
"@polkadot/rpc-core": "npm:13.1.1"
|
||||
"@polkadot/rpc-provider": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/types-support": "npm:13.1.1"
|
||||
"@polkadot/api": "npm:14.0.1"
|
||||
"@polkadot/api-augment": "npm:14.0.1"
|
||||
"@polkadot/api-base": "npm:14.0.1"
|
||||
"@polkadot/rpc-augment": "npm:14.0.1"
|
||||
"@polkadot/rpc-core": "npm:14.0.1"
|
||||
"@polkadot/rpc-provider": "npm:14.0.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/types-support": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
"@polkadot/util-crypto": "npm:^13.1.1"
|
||||
rxjs: "npm:^7.8.1"
|
||||
@@ -511,23 +511,23 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/api@npm:13.1.1, @polkadot/api@workspace:packages/api":
|
||||
"@polkadot/api@npm:14.0.1, @polkadot/api@workspace:packages/api":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/api@workspace:packages/api"
|
||||
dependencies:
|
||||
"@polkadot/api-augment": "npm:13.1.1"
|
||||
"@polkadot/api-base": "npm:13.1.1"
|
||||
"@polkadot/api-derive": "npm:13.1.1"
|
||||
"@polkadot/api-augment": "npm:14.0.1"
|
||||
"@polkadot/api-base": "npm:14.0.1"
|
||||
"@polkadot/api-derive": "npm:14.0.1"
|
||||
"@polkadot/keyring": "npm:^13.1.1"
|
||||
"@polkadot/rpc-augment": "npm:13.1.1"
|
||||
"@polkadot/rpc-core": "npm:13.1.1"
|
||||
"@polkadot/rpc-provider": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-augment": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/types-create": "npm:13.1.1"
|
||||
"@polkadot/types-known": "npm:13.1.1"
|
||||
"@polkadot/types-support": "npm:13.1.1"
|
||||
"@polkadot/rpc-augment": "npm:14.0.1"
|
||||
"@polkadot/rpc-core": "npm:14.0.1"
|
||||
"@polkadot/rpc-provider": "npm:14.0.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-augment": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/types-create": "npm:14.0.1"
|
||||
"@polkadot/types-known": "npm:14.0.1"
|
||||
"@polkadot/types-support": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
"@polkadot/util-crypto": "npm:^13.1.1"
|
||||
eventemitter3: "npm:^5.0.1"
|
||||
@@ -657,39 +657,39 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/rpc-augment@npm:13.1.1, @polkadot/rpc-augment@workspace:packages/rpc-augment":
|
||||
"@polkadot/rpc-augment@npm:14.0.1, @polkadot/rpc-augment@workspace:packages/rpc-augment":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/rpc-augment@workspace:packages/rpc-augment"
|
||||
dependencies:
|
||||
"@polkadot/rpc-core": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/rpc-core": "npm:14.0.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
tslib: "npm:^2.7.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/rpc-core@npm:13.1.1, @polkadot/rpc-core@workspace:packages/rpc-core":
|
||||
"@polkadot/rpc-core@npm:14.0.1, @polkadot/rpc-core@workspace:packages/rpc-core":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/rpc-core@workspace:packages/rpc-core"
|
||||
dependencies:
|
||||
"@polkadot/keyring": "npm:^13.1.1"
|
||||
"@polkadot/rpc-augment": "npm:13.1.1"
|
||||
"@polkadot/rpc-provider": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/rpc-augment": "npm:14.0.1"
|
||||
"@polkadot/rpc-provider": "npm:14.0.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
rxjs: "npm:^7.8.1"
|
||||
tslib: "npm:^2.7.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/rpc-provider@npm:13.1.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
|
||||
"@polkadot/rpc-provider@npm:14.0.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/rpc-provider@workspace:packages/rpc-provider"
|
||||
dependencies:
|
||||
"@polkadot/keyring": "npm:^13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-support": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-support": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
"@polkadot/util-crypto": "npm:^13.1.1"
|
||||
"@polkadot/x-fetch": "npm:^13.1.1"
|
||||
@@ -710,15 +710,15 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/typegen@workspace:packages/typegen"
|
||||
dependencies:
|
||||
"@polkadot/api": "npm:13.1.1"
|
||||
"@polkadot/api-augment": "npm:13.1.1"
|
||||
"@polkadot/rpc-augment": "npm:13.1.1"
|
||||
"@polkadot/rpc-provider": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-augment": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/types-create": "npm:13.1.1"
|
||||
"@polkadot/types-support": "npm:13.1.1"
|
||||
"@polkadot/api": "npm:14.0.1"
|
||||
"@polkadot/api-augment": "npm:14.0.1"
|
||||
"@polkadot/rpc-augment": "npm:14.0.1"
|
||||
"@polkadot/rpc-provider": "npm:14.0.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-augment": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/types-create": "npm:14.0.1"
|
||||
"@polkadot/types-support": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
"@polkadot/util-crypto": "npm:^13.1.1"
|
||||
"@polkadot/x-ws": "npm:^13.1.1"
|
||||
@@ -735,24 +735,24 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/types-augment@npm:13.1.1, @polkadot/types-augment@workspace:packages/types-augment":
|
||||
"@polkadot/types-augment@npm:14.0.1, @polkadot/types-augment@workspace:packages/types-augment":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/types-augment@workspace:packages/types-augment"
|
||||
dependencies:
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
tslib: "npm:^2.7.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/types-codec@npm:13.1.1, @polkadot/types-codec@workspace:packages/types-codec":
|
||||
"@polkadot/types-codec@npm:14.0.1, @polkadot/types-codec@workspace:packages/types-codec":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/types-codec@workspace:packages/types-codec"
|
||||
dependencies:
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-augment": "npm:13.1.1"
|
||||
"@polkadot/types-support": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-augment": "npm:14.0.1"
|
||||
"@polkadot/types-support": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
"@polkadot/util-crypto": "npm:^13.1.1"
|
||||
"@polkadot/x-bigint": "npm:^13.1.1"
|
||||
@@ -760,32 +760,32 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/types-create@npm:13.1.1, @polkadot/types-create@workspace:packages/types-create":
|
||||
"@polkadot/types-create@npm:14.0.1, @polkadot/types-create@workspace:packages/types-create":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/types-create@workspace:packages/types-create"
|
||||
dependencies:
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
tslib: "npm:^2.7.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/types-known@npm:13.1.1, @polkadot/types-known@workspace:packages/types-known":
|
||||
"@polkadot/types-known@npm:14.0.1, @polkadot/types-known@workspace:packages/types-known":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/types-known@workspace:packages/types-known"
|
||||
dependencies:
|
||||
"@polkadot/api": "npm:13.1.1"
|
||||
"@polkadot/api": "npm:14.0.1"
|
||||
"@polkadot/networks": "npm:^13.1.1"
|
||||
"@polkadot/types": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/types-create": "npm:13.1.1"
|
||||
"@polkadot/types": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/types-create": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
tslib: "npm:^2.7.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/types-support@npm:13.1.1, @polkadot/types-support@workspace:packages/types-support":
|
||||
"@polkadot/types-support@npm:14.0.1, @polkadot/types-support@workspace:packages/types-support":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/types-support@workspace:packages/types-support"
|
||||
dependencies:
|
||||
@@ -794,15 +794,15 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/types@npm:13.1.1, @polkadot/types@workspace:packages/types":
|
||||
"@polkadot/types@npm:14.0.1, @polkadot/types@workspace:packages/types":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/types@workspace:packages/types"
|
||||
dependencies:
|
||||
"@polkadot/keyring": "npm:^13.1.1"
|
||||
"@polkadot/types-augment": "npm:13.1.1"
|
||||
"@polkadot/types-codec": "npm:13.1.1"
|
||||
"@polkadot/types-create": "npm:13.1.1"
|
||||
"@polkadot/types-support": "npm:13.1.1"
|
||||
"@polkadot/types-augment": "npm:14.0.1"
|
||||
"@polkadot/types-codec": "npm:14.0.1"
|
||||
"@polkadot/types-create": "npm:14.0.1"
|
||||
"@polkadot/types-support": "npm:14.0.1"
|
||||
"@polkadot/util": "npm:^13.1.1"
|
||||
"@polkadot/util-crypto": "npm:^13.1.1"
|
||||
rxjs: "npm:^7.8.1"
|
||||
|
||||
Reference in New Issue
Block a user