diff --git a/CHANGELOG.md b/CHANGELOG.md index 232298e8f..4f28d138a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## master +- api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 11.1.1 - phishing 0.22.7 - api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 11.0.3 - api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 11.0.2 diff --git a/api-augment/packageInfo.ts b/api-augment/packageInfo.ts index 75be82e2c..0b44bbc1c 100644 --- a/api-augment/packageInfo.ts +++ b/api-augment/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/api-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/api-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/api-base/packageInfo.ts b/api-base/packageInfo.ts index 25326780e..d0b954922 100644 --- a/api-base/packageInfo.ts +++ b/api-base/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/api-base', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/api-base', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/api-base/types/submittable.ts b/api-base/types/submittable.ts index 85988ff14..978db1309 100644 --- a/api-base/types/submittable.ts +++ b/api-base/types/submittable.ts @@ -1,7 +1,7 @@ import type { Observable } from 'https://esm.sh/rxjs@7.8.1'; import type { AccountId, Address, ApplyExtrinsicResult, BlockNumber, Call, DispatchError, DispatchInfo, EventRecord, Extrinsic, ExtrinsicStatus, Hash, RuntimeDispatchInfo } from 'https://deno.land/x/polkadot/types/interfaces/index.ts'; -import type { AnyFunction, AnyNumber, AnyTuple, Callback, CallBase, Codec, IExtrinsicEra, IKeyringPair, ISubmittableResult, Signer } from 'https://deno.land/x/polkadot/types/types/index.ts'; +import type { AnyFunction, AnyNumber, AnyTuple, AnyU8a, Callback, CallBase, Codec, IExtrinsicEra, IKeyringPair, ISubmittableResult, Signer } from 'https://deno.land/x/polkadot/types/types/index.ts'; import type { ApiTypes, EmptyBase, PromiseOrObs } from './base.ts'; export type AugmentedSubmittable = T & CallBase; @@ -15,6 +15,8 @@ export interface SignerOptions { signer?: Signer; tip?: AnyNumber; assetId?: AnyNumber | object; + mode?: AnyNumber; + metadataHash?: AnyU8a; } export type SubmittableDryRunResult = diff --git a/api-contract/packageInfo.ts b/api-contract/packageInfo.ts index f65c0b081..6c89004d6 100644 --- a/api-contract/packageInfo.ts +++ b/api-contract/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/api-contract', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/api-contract', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/api-derive/accounts/identity.ts b/api-derive/accounts/identity.ts index 66202ed05..2a83c5d16 100644 --- a/api-derive/accounts/identity.ts +++ b/api-derive/accounts/identity.ts @@ -1,7 +1,7 @@ import type { Observable } from 'https://esm.sh/rxjs@7.8.1'; -import type { Bytes, Data } from 'https://deno.land/x/polkadot/types/mod.ts'; -import type { AccountId } from 'https://deno.land/x/polkadot/types/interfaces/index.ts'; +import type { Bytes, Data, Struct } from 'https://deno.land/x/polkadot/types/mod.ts'; +import type { AccountId, H160 } from 'https://deno.land/x/polkadot/types/interfaces/index.ts'; import type { PalletIdentityLegacyIdentityInfo, PalletIdentityRegistration } from 'https://deno.land/x/polkadot/types/lookup.ts'; import type { Option } from 'https://deno.land/x/polkadot/types-codec/mod.ts'; import type { ITuple } from 'https://deno.land/x/polkadot/types-codec/types/index.ts'; @@ -15,9 +15,26 @@ import { firstMemo, memo } from '../util/index.ts'; type IdentityInfoAdditional = PalletIdentityLegacyIdentityInfo['additional'][0]; +interface PeopleIdentityInfo extends Struct { + display: Data; + legal: Data; + web: Data; + matrix: Data; + email: Data; + pgpFingerprint: Option; + image: Data; + twitter: Data; + github: Data; + discord: Data; +} + const UNDEF_HEX = { toHex: () => undefined }; function dataAsString (data: Data): string | undefined { + if (!data) { + return data; + } + return data.isRaw ? u8aToString(data.asRaw.toU8a(true)) : data.isNone @@ -55,13 +72,16 @@ function extractIdentity (identityOfOpt?: Option; export interface DeriveAccountRegistration { + discord?: string | undefined; display?: string | undefined; displayParent?: string | undefined; email?: string | undefined; + github?: string | undefined; image?: string | undefined; legal?: string | undefined; + matrix?: string | undefined; other?: Record | undefined; parent?: AccountId | undefined; pgp?: string | undefined; diff --git a/api-derive/packageInfo.ts b/api-derive/packageInfo.ts index ce5b2623f..4e560c493 100644 --- a/api-derive/packageInfo.ts +++ b/api-derive/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/api-derive', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/api-derive', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/api-derive/staking/validators.ts b/api-derive/staking/validators.ts index 908309870..6ce927217 100644 --- a/api-derive/staking/validators.ts +++ b/api-derive/staking/validators.ts @@ -15,14 +15,16 @@ export function nextElected (instanceId: string, api: DeriveApi): () => Observab // only populate for next era in the last session, so track both here - entries are not // subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh switchMap(({ currentEra }) => api.query.staking.erasStakersPaged.keys(currentEra)), - map((keys) => keys.map(({ args: [, accountId] }) => accountId)) + // Dedupe any duplicates + map((keys) => [...new Set(keys.map(({ args: [, accountId] }) => accountId.toString()))].map((a) => api.registry.createType('AccountId', a))) ) : api.query.staking.erasStakers ? api.derive.session.indexes().pipe( // only populate for next era in the last session, so track both here - entries are not // subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)), - map((keys) => keys.map(({ args: [, accountId] }) => accountId)) + // Dedupe any duplicates + map((keys) => [...new Set(keys.map(({ args: [, accountId] }) => accountId.toString()))].map((a) => api.registry.createType('AccountId', a))) ) : api.query.staking['currentElected']() ); diff --git a/api/packageInfo.ts b/api/packageInfo.ts index b6ab8c7f6..d721534fe 100644 --- a/api/packageInfo.ts +++ b/api/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/api', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/api', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/rpc-augment/packageInfo.ts b/rpc-augment/packageInfo.ts index c5cd0b367..7de0c95ec 100644 --- a/rpc-augment/packageInfo.ts +++ b/rpc-augment/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/rpc-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/rpc-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/rpc-core/packageInfo.ts b/rpc-core/packageInfo.ts index b3f1ed8e9..cd86fa061 100644 --- a/rpc-core/packageInfo.ts +++ b/rpc-core/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/rpc-core', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/rpc-core', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/rpc-provider/packageInfo.ts b/rpc-provider/packageInfo.ts index b9e6ddde2..4347934a1 100644 --- a/rpc-provider/packageInfo.ts +++ b/rpc-provider/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/rpc-provider', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/rpc-provider', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/types-augment/packageInfo.ts b/types-augment/packageInfo.ts index 606b14891..16c79bc2d 100644 --- a/types-augment/packageInfo.ts +++ b/types-augment/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/types-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/types-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/types-codec/packageInfo.ts b/types-codec/packageInfo.ts index c2d9d8993..15f49f8a3 100644 --- a/types-codec/packageInfo.ts +++ b/types-codec/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/types-codec', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/types-codec', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/types-create/packageInfo.ts b/types-create/packageInfo.ts index c24f43cb9..bb1788f3c 100644 --- a/types-create/packageInfo.ts +++ b/types-create/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/types-create', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/types-create', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/types-known/packageInfo.ts b/types-known/packageInfo.ts index db77f9f6a..acea704d3 100644 --- a/types-known/packageInfo.ts +++ b/types-known/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/types-known', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/types-known', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/types/extrinsic/Extrinsic.ts b/types/extrinsic/Extrinsic.ts index d0a41dfe0..fe2c9d362 100644 --- a/types/extrinsic/Extrinsic.ts +++ b/types/extrinsic/Extrinsic.ts @@ -3,7 +3,7 @@ import type { AnyJson, AnyTuple, AnyU8a, ArgsDef, IMethod, Inspect, IOption } fr import type { HexString } from 'https://deno.land/x/polkadot/util/types.ts'; import type { EcdsaSignature, Ed25519Signature, ExtrinsicUnknown, ExtrinsicV4, Sr25519Signature } from '../interfaces/extrinsics/index.ts'; import type { FunctionMetadataLatest } from '../interfaces/metadata/index.ts'; -import type { Address, Call, CodecHash } from '../interfaces/runtime/index.ts'; +import type { Address, Call, CodecHash, Hash } from '../interfaces/runtime/index.ts'; import type { MultiLocation } from '../interfaces/types.ts'; import type { CallBase, ExtrinsicPayloadValue, ICompact, IExtrinsic, IKeyringPair, INumber, Registry, SignatureOptions } from '../types/index.ts'; import type { GenericExtrinsicEra } from './ExtrinsicEra.ts'; @@ -191,10 +191,17 @@ abstract class ExtrinsicBase extends AbstractBase | IOption { + public get assetId (): IOption { return this.inner.signature.assetId; } + /** + * @description Forward compat + */ + public get metadataHash (): IOption { + return this.inner.signature.metadataHash; + } + /** * @description Returns the raw transaction version (not flagged with signing information) */ @@ -320,8 +327,9 @@ export class GenericExtrinsic extends ExtrinsicBa }, this.isSigned ? { - assetId: this.assetId.toHuman(isExpanded, disableAscii), + assetId: this.assetId ? this.assetId.toHuman(isExpanded, disableAscii) : null, era: this.era.toHuman(isExpanded, disableAscii), + metadataHash: this.metadataHash ? this.metadataHash.toHex() : null, nonce: this.nonce.toHuman(isExpanded, disableAscii), signature: this.signature.toHex(), signer: this.signer.toHuman(isExpanded, disableAscii), diff --git a/types/extrinsic/ExtrinsicPayload.ts b/types/extrinsic/ExtrinsicPayload.ts index dce086185..9041a284d 100644 --- a/types/extrinsic/ExtrinsicPayload.ts +++ b/types/extrinsic/ExtrinsicPayload.ts @@ -4,7 +4,7 @@ import type { AnyJson, BareOpts, Registry } from 'https://deno.land/x/polkadot/t import type { HexString } from 'https://deno.land/x/polkadot/util/types.ts'; import type { BlockHash } from '../interfaces/chain/index.ts'; import type { ExtrinsicPayloadV4 } from '../interfaces/extrinsics/index.ts'; -import type { MultiLocation } from '../interfaces/types.ts'; +import type { Hash, MultiLocation } from '../interfaces/types.ts'; import type { ExtrinsicPayloadValue, ICompact, IKeyringPair, INumber, IOption } from '../types/index.ts'; import type { GenericExtrinsicEra } from './ExtrinsicEra.ts'; @@ -110,10 +110,17 @@ export class GenericExtrinsicPayload extends AbstractBase { /** * @description The (optional) asset id as a [[u32]] or [[MultiLocation]] for this payload */ - public get assetId (): IOption> { + public get assetId (): IOption { return this.inner.assetId; } + /** + * @description The (optional) [[Hash]] of the genesis metadata for this payload + */ + public get metadataHash (): IOption { + return this.inner.metadataHash; + } + /** * @description Compares the value of the input to see if there is a match */ diff --git a/types/extrinsic/SignerPayload.ts b/types/extrinsic/SignerPayload.ts index 3e8258428..d7978653e 100644 --- a/types/extrinsic/SignerPayload.ts +++ b/types/extrinsic/SignerPayload.ts @@ -10,11 +10,14 @@ import { objectProperty, objectSpread, u8aToHex } from 'https://deno.land/x/polk export interface SignerPayloadType extends Codec { address: Address; + assetId: IOption; blockHash: Hash; blockNumber: INumber; era: ExtrinsicEra; genesisHash: Hash; + metadataHash: IOption; method: Call; + mode: INumber; nonce: ICompact; runtimeVersion: IRuntimeVersion; signedExtensions: Vec; @@ -24,11 +27,14 @@ export interface SignerPayloadType extends Codec { const knownTypes: Record = { address: 'Address', + assetId: 'Option', blockHash: 'Hash', blockNumber: 'BlockNumber', era: 'ExtrinsicEra', genesisHash: 'Hash', + metadataHash: 'Option<[u8;32]>', method: 'Call', + mode: 'u8', nonce: 'Compact', runtimeVersion: 'RuntimeVersion', signedExtensions: 'Vec', @@ -102,7 +108,7 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign return this.getT('tip'); } - get assetId (): IOption | IOption { + get assetId (): IOption { return this.getT('assetId'); } @@ -110,6 +116,14 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign return this.getT('version'); } + get mode (): INumber { + return this.getT('mode'); + } + + get metadataHash (): IOption { + return this.getT('metadataHash'); + } + /** * @description Creates an representation of the structure as an ISignerPayload JSON */ @@ -137,11 +151,14 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign // the known defaults as managed explicitly and has different // formatting in cases, e.g. we mostly expose a hex format here address: this.address.toString(), + assetId: this.assetId ? this.assetId.toJSON() : null, blockHash: this.blockHash.toHex(), blockNumber: this.blockNumber.toHex(), era: this.era.toHex(), genesisHash: this.genesisHash.toHex(), + metadataHash: this.metadataHash.isSome ? this.metadataHash.toHex() : null, method: this.method.toHex(), + mode: this.mode.toNumber(), nonce: this.nonce.toHex(), signedExtensions: this.signedExtensions.map((e) => e.toString()), specVersion: this.runtimeVersion.specVersion.toHex(), diff --git a/types/extrinsic/signedExtensions/substrate.ts b/types/extrinsic/signedExtensions/substrate.ts index 4ed02ab18..c30318965 100644 --- a/types/extrinsic/signedExtensions/substrate.ts +++ b/types/extrinsic/signedExtensions/substrate.ts @@ -3,6 +3,15 @@ import type { ExtDef, ExtInfo } from './types.ts'; import { emptyCheck } from './emptyCheck.ts'; +const CheckMetadataHash: ExtInfo = { + extrinsic: { + mode: 'u8' + }, + payload: { + metadataHash: 'Option<[u8;32]>' + } +}; + const CheckMortality: ExtInfo = { extrinsic: { era: 'ExtrinsicEra' @@ -29,6 +38,7 @@ export const substrate: ExtDef = { genesisHash: 'Hash' } }, + CheckMetadataHash, CheckMortality, CheckNonZeroSender: emptyCheck, CheckNonce: { diff --git a/types/extrinsic/v4/ExtrinsicPayload.ts b/types/extrinsic/v4/ExtrinsicPayload.ts index 886391584..d1db16745 100644 --- a/types/extrinsic/v4/ExtrinsicPayload.ts +++ b/types/extrinsic/v4/ExtrinsicPayload.ts @@ -1,6 +1,6 @@ import type { SignOptions } from 'https://deno.land/x/polkadot/keyring/types.ts'; -import type { MultiLocation } from 'https://deno.land/x/polkadot/types/interfaces/index.ts'; +import type { Hash, MultiLocation } from 'https://deno.land/x/polkadot/types/interfaces/index.ts'; import type { Bytes } from 'https://deno.land/x/polkadot/types-codec/mod.ts'; import type { Inspect, Registry } from 'https://deno.land/x/polkadot/types-codec/types/index.ts'; import type { HexString } from 'https://deno.land/x/polkadot/util/types.ts'; @@ -103,10 +103,17 @@ export class GenericExtrinsicPayloadV4 extends Struct { /** * @description The (optional) asset id for this signature for chains that support transaction fees in assets */ - public get assetId (): IOption> { + public get assetId (): IOption { return this.getT('assetId'); } + /** + * @description The (optional) asset id for this signature for chains that support transaction fees in assets + */ + public get metadataHash (): IOption { + return this.getT('metadataHash'); + } + /** * @description Sign the payload with the keypair */ diff --git a/types/extrinsic/v4/ExtrinsicSignature.ts b/types/extrinsic/v4/ExtrinsicSignature.ts index 92c32b04f..61385fa21 100644 --- a/types/extrinsic/v4/ExtrinsicSignature.ts +++ b/types/extrinsic/v4/ExtrinsicSignature.ts @@ -2,7 +2,7 @@ import type { MultiLocation } from 'https://deno.land/x/polkadot/types/interfaces/index.ts'; import type { HexString } from 'https://deno.land/x/polkadot/util/types.ts'; import type { EcdsaSignature, Ed25519Signature, ExtrinsicEra, ExtrinsicSignature, Sr25519Signature } from '../../interfaces/extrinsics/index.ts'; -import type { Address, Call } from '../../interfaces/runtime/index.ts'; +import type { Address, Call, Hash } from '../../interfaces/runtime/index.ts'; import type { ExtrinsicPayloadValue, ICompact, IExtrinsicSignature, IKeyringPair, INumber, IOption, Registry, SignatureOptions } from '../../types/index.ts'; import type { ExtrinsicSignatureOptions } from '../types.ts'; @@ -119,10 +119,17 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig /** * @description The [[u32]] or [[MultiLocation]] assetId */ - public get assetId (): IOption | IOption { + public get assetId (): IOption { return this.getT('assetId'); } + /** + * @description The [[Hash]] for the metadata + */ + public get metadataHash (): IOption { + return this.getT('metadataHash'); + } + protected _injectSignature (signer: Address, signature: ExtrinsicSignature, payload: GenericExtrinsicPayloadV4): IExtrinsicSignature { // use the fields exposed to guide the getters for (let i = 0, count = this.#signKeys.length; i < count; i++) { diff --git a/types/packageInfo.ts b/types/packageInfo.ts index ea9bd8a35..489d037b7 100644 --- a/types/packageInfo.ts +++ b/types/packageInfo.ts @@ -1,3 +1,3 @@ -export const packageInfo = { name: '@polkadot/types', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.0.3' }; +export const packageInfo = { name: '@polkadot/types', path: new URL(import.meta.url).pathname, type: 'deno', version: '11.1.1' }; diff --git a/types/types/extrinsic.ts b/types/types/extrinsic.ts index 7f8f735ec..3b2005722 100644 --- a/types/types/extrinsic.ts +++ b/types/types/extrinsic.ts @@ -33,6 +33,11 @@ export interface SignerPayloadJSON { */ address: string; + /** + * @description The id of the asset used to pay fees, in hex + */ + assetId?: number | object; + /** * @description The checkpoint hash of the block, in hex */ @@ -53,11 +58,21 @@ export interface SignerPayloadJSON { */ genesisHash: HexString; + /** + * @description The metadataHash for the CheckMetadataHash SignedExtension, as hex + */ + metadataHash?: HexString; + /** * @description The encoded method (with arguments) in hex */ method: string; + /** + * @description The mode for the CheckMetadataHash SignedExtension, in hex + */ + mode?: number; + /** * @description The nonce for this transaction, in hex */ @@ -162,6 +177,8 @@ export interface SignatureOptions { signer?: Signer; tip?: AnyNumber; assetId?: AnyNumber | object; + mode?: AnyNumber; + metadataHash?: Uint8Array | string; } interface ExtrinsicSignatureBase { @@ -183,6 +200,8 @@ export interface ExtrinsicPayloadValue { tip: AnyNumber; transactionVersion: AnyNumber; assetId?: AnyNumber | object; + mode?: AnyNumber; + metadataHash?: AnyU8a; } export interface IExtrinsicSignature extends ExtrinsicSignatureBase, Codec {