@polkadot-api/substrate-bindings
Advanced tools
Comparing version 0.0.1-09799e72004d94fd5719dea88928b301c7b9c84d.1.0 to 0.0.1-097dae903cc84c0d8a6c93f39fef5e4724660825.1.0
@@ -6,3 +6,3 @@ import * as scale_ts from 'scale-ts'; | ||
type SS58String = string & { | ||
__SS58String: unknown; | ||
__SS58String?: unknown; | ||
}; | ||
@@ -14,11 +14,5 @@ declare const AccountId: (ss58Format?: number, nBytes?: 32 | 33) => scale_ts.Codec<SS58String>; | ||
declare const selfEncoder: <T>(value: () => Encoder<T>) => Encoder<{ | ||
self: T; | ||
}>; | ||
declare const selfDecoder: <T>(value: () => Decoder<T>) => Decoder<{ | ||
self: T; | ||
}>; | ||
declare const Self: <T>(value: () => Codec<T>) => Codec<{ | ||
self: T; | ||
}>; | ||
declare const selfEncoder: <T>(value: () => Encoder<T>) => Encoder<T>; | ||
declare const selfDecoder: <T>(value: () => Decoder<T>) => Decoder<T>; | ||
declare const Self: <T>(value: () => Codec<T>) => Codec<T>; | ||
@@ -141,3 +135,3 @@ type OpaqueValue<T> = { | ||
type HexString = string & { | ||
__hexString: unknown; | ||
__hexString?: unknown; | ||
}; | ||
@@ -189,3 +183,3 @@ declare const Hex: { | ||
}; | ||
fallback: number[]; | ||
fallback: HexString; | ||
docs: string[]; | ||
@@ -360,3 +354,3 @@ }[]; | ||
}; | ||
fallback: number[]; | ||
fallback: HexString; | ||
docs: string[]; | ||
@@ -578,3 +572,3 @@ }[]; | ||
}; | ||
fallback: number[]; | ||
fallback: HexString; | ||
docs: string[]; | ||
@@ -618,2 +612,61 @@ }[]; | ||
declare const blockHeader: scale_ts.Codec<{ | ||
parentHash: HexString; | ||
number: number; | ||
stateRoot: HexString; | ||
extrinsicRoot: HexString; | ||
digests: ({ | ||
tag: "consensus"; | ||
value: { | ||
engine: string; | ||
payload: HexString; | ||
}; | ||
} | { | ||
tag: "seal"; | ||
value: { | ||
engine: string; | ||
payload: HexString; | ||
}; | ||
} | { | ||
tag: "preRuntime"; | ||
value: { | ||
engine: string; | ||
payload: HexString; | ||
}; | ||
} | { | ||
tag: "runtimeUpdated"; | ||
value: undefined; | ||
})[]; | ||
}>; | ||
type BlockHeader = CodecType<typeof blockHeader>; | ||
interface IBinary { | ||
asText: () => string; | ||
asHex: () => HexString; | ||
asBytes: () => Uint8Array; | ||
} | ||
declare class Binary implements IBinary { | ||
private bytes; | ||
private hex; | ||
private str; | ||
constructor(bytes: Uint8Array); | ||
constructor(hex: HexString); | ||
constructor(text: string); | ||
asText(): string; | ||
asHex(): string; | ||
asBytes(): Uint8Array; | ||
} | ||
declare const Bin: { | ||
(nBytes?: number): Codec<Binary>; | ||
enc: (nBytes?: number) => Encoder<Binary>; | ||
dec: (nBytes?: number) => Decoder<Binary>; | ||
}; | ||
declare const option: <T extends { | ||
tag: string; | ||
value: any; | ||
}, K extends T["tag"]>(tag: K, value: (T & { | ||
tag: K; | ||
})["value"]) => T; | ||
declare const Blake2256: (encoded: Uint8Array) => Uint8Array; | ||
@@ -638,74 +691,51 @@ declare const Blake2128: (encoded: Uint8Array) => Uint8Array; | ||
type Tuple<T> = readonly [T, ...T[]]; | ||
interface DescriptorCommon<Pallet extends string, Name extends string> { | ||
checksum: bigint; | ||
pallet: Pallet; | ||
name: Name; | ||
} | ||
interface ArgsWithPayloadCodec<Args extends Array<any>, O> { | ||
len: Args["length"]; | ||
} | ||
interface ArgsWithoutPayloadCodec<Args extends Array<any>> { | ||
len: Args["length"]; | ||
} | ||
interface StorageDescriptor<Common extends DescriptorCommon<string, string>, Codecs extends ArgsWithPayloadCodec<any, any>> { | ||
type: "storage"; | ||
props: Common; | ||
codecs: Codecs; | ||
} | ||
interface ConstantDescriptor<Common extends DescriptorCommon<string, string>, Codecs> { | ||
type: "const"; | ||
props: Common; | ||
codecs: Codecs; | ||
} | ||
interface EventDescriptor<Common extends DescriptorCommon<string, string>, Codecs> { | ||
type: "event"; | ||
props: Common; | ||
codecs: Codecs; | ||
} | ||
interface ErrorDescriptor<Common extends DescriptorCommon<string, string>, Codecs> { | ||
type: "error"; | ||
props: Common; | ||
codecs: Codecs; | ||
} | ||
interface TxDescriptor<Common extends DescriptorCommon<string, string>, Codecs extends ArgsWithoutPayloadCodec<any>, Events extends Array<EventDescriptor<any, any>>, Errors extends Array<ErrorDescriptor<any, any>>> { | ||
type: "tx"; | ||
props: Common; | ||
codecs: Codecs; | ||
events: Events; | ||
errors: Errors; | ||
} | ||
type Descriptor = ConstantDescriptor<any, any> | EventDescriptor<any, any> | StorageDescriptor<any, any> | ErrorDescriptor<any, any> | TxDescriptor<any, any, any, any>; | ||
declare const createCommonDescriptor: <Pallet extends string, Name extends string>(checksum: bigint, pallet: Pallet, name: Name) => DescriptorCommon<Pallet, Name>; | ||
declare const getDescriptorCreator: <Type extends "const" | "event" | "error", Pallet extends string, Name extends string, Codecs>(type: Type, checksum: bigint, pallet: Pallet, name: Name, codecs: Codecs) => Type extends "const" ? ConstantDescriptor<DescriptorCommon<Pallet, Name>, Codecs> : Type extends "event" ? EventDescriptor<DescriptorCommon<Pallet, Name>, Codecs> : ErrorDescriptor<DescriptorCommon<Pallet, Name>, Codecs>; | ||
declare const getPalletCreator: <Pallet extends string>(pallet: Pallet) => { | ||
getPayloadDescriptor: <Type extends "const" | "event" | "error", Name extends string, Codecs>(type: Type, checksum: bigint, name: Name, codecs: Codecs) => Type extends "const" ? ConstantDescriptor<DescriptorCommon<Pallet, Name>, Codecs> : Type extends "event" ? EventDescriptor<DescriptorCommon<Pallet, Name>, Codecs> : ErrorDescriptor<DescriptorCommon<Pallet, Name>, Codecs>; | ||
getStorageDescriptor: <Name_1 extends string, Codecs_1 extends ArgsWithPayloadCodec<any[], any>>(checksum: bigint, name: Name_1, codecs: Codecs_1) => StorageDescriptor<DescriptorCommon<Pallet, Name_1>, Codecs_1>; | ||
getTxDescriptor: <Name_2 extends string, Codecs_2 extends ArgsWithoutPayloadCodec<any>, Events extends EventDescriptor<any, any>[], Errors extends ErrorDescriptor<any, any>[]>(checksum: bigint, name: Name_2, events: Events, errors: Errors, codecs: Codecs_2) => TxDescriptor<DescriptorCommon<Pallet, Name_2>, Codecs_2, Events, Errors>; | ||
type PlainDescriptor<T> = string & { | ||
_type?: T; | ||
}; | ||
type EventToObject<E extends EventDescriptor<DescriptorCommon<any, string>, any>> = E extends EventDescriptor<DescriptorCommon<any, infer K>, infer V> ? { | ||
type: K; | ||
value: V; | ||
} : unknown; | ||
type UnionizeTupleEvents<E extends Array<EventDescriptor<any, any>>> = E extends Array<infer Ev> ? Ev extends EventDescriptor<any, any> ? EventToObject<Ev> : unknown : unknown; | ||
type TxDescriptorArgs<D extends TxDescriptor<any, any, any, any>> = D extends TxDescriptor<any, ArgsWithoutPayloadCodec<infer A>, any, any> ? A : []; | ||
type TxDescriptorEvents<D extends TxDescriptor<any, any, any, any>> = D extends TxDescriptor<any, any, infer E, any> ? E : []; | ||
type TxDescriptorErrors<D extends TxDescriptor<any, any, any, any>> = D extends TxDescriptor<any, any, any, infer Errors> ? Errors extends Tuple<ErrorDescriptor<any, any>> ? { | ||
[K in keyof Errors]: Errors[K] extends ErrorDescriptor<DescriptorCommon<any, infer Type>, infer Value> ? { | ||
type: Type; | ||
value: Value; | ||
} : unknown; | ||
}[keyof Errors extends number ? keyof Errors : never] : [] : []; | ||
type TxFunction<D extends TxDescriptor<any, any, any, any>> = (...args: TxDescriptorArgs<D>) => Promise<{ | ||
ok: true; | ||
events: Array<UnionizeTupleEvents<TxDescriptorEvents<D>>>; | ||
} | { | ||
ok: false; | ||
error: TxDescriptorErrors<D>; | ||
}>; | ||
type StorageType<T extends StorageDescriptor<any, ArgsWithPayloadCodec<any, any>>> = T extends StorageDescriptor<any, ArgsWithPayloadCodec<infer Args, infer Payload>> ? { | ||
keyArgs: Args; | ||
value: Payload; | ||
} : unknown; | ||
type StorageDescriptor<Args extends Array<any>, T, Optional extends true | false> = string & { | ||
_type: T; | ||
_args: Args; | ||
_optional: Optional; | ||
}; | ||
type TxDescriptor<Args extends Array<any>> = string & { | ||
_args: Args; | ||
}; | ||
type Descriptors = Record<string, [ | ||
Record<string, StorageDescriptor<any, any, any>>, | ||
Record<string, TxDescriptor<any>>, | ||
Record<string, PlainDescriptor<any>>, | ||
Record<string, PlainDescriptor<any>>, | ||
Record<string, PlainDescriptor<any>> | ||
]>; | ||
type PickDescriptors<Idx extends 0 | 1 | 2 | 3 | 4, T extends Descriptors> = { | ||
[K in keyof T]: T[K][Idx]; | ||
}; | ||
type Anonymize<T> = T extends string | number | bigint | boolean | void | undefined | null | symbol | Binary ? T : T extends (...args: infer Args) => infer R ? (...args: Anonymize<Args>) => Anonymize<R> : { | ||
[K in keyof T]: Anonymize<T[K]>; | ||
}; | ||
type ExtractStorage<T extends Record<string, Record<string, StorageDescriptor<any, any, any>>>> = { | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends StorageDescriptor<infer Key, infer Value, infer Optional> ? { | ||
KeyArgs: Anonymize<Key>; | ||
Value: Anonymize<Value>; | ||
IsOptional: Optional; | ||
} : unknown; | ||
}; | ||
}; | ||
type ExtractTx<T extends Record<string, Record<string, TxDescriptor<any>>>> = { | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends TxDescriptor<infer Args> ? Anonymize<Args> : unknown; | ||
}; | ||
}; | ||
type ExtractPlain<T extends Record<string, Record<string, PlainDescriptor<any>>>> = { | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends PlainDescriptor<infer Value> ? Anonymize<Value> : unknown; | ||
}; | ||
}; | ||
type QueryFromDescriptors<T extends Descriptors> = ExtractStorage<PickDescriptors<0, T>>; | ||
type TxFromDescriptors<T extends Descriptors> = ExtractTx<PickDescriptors<1, T>>; | ||
type EventsFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<2, T>>; | ||
type ErrorsFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<3, T>>; | ||
type ConstFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<4, T>>; | ||
export { AccountId, ArgsWithPayloadCodec, ArgsWithoutPayloadCodec, BitSequence, Blake2128, Blake2128Concat, Blake2256, ConstantDescriptor, Descriptor, DescriptorCommon, EncoderWithHash, ErrorDescriptor, EventDescriptor, EventToObject, Hex, HexString, Identity, OpaqueCodec, OpaqueValue, SS58String, Self, Storage, StorageDescriptor, StorageType, Twox128, Twox256, Twox64Concat, TxDescriptor, TxDescriptorArgs, TxDescriptorErrors, TxDescriptorEvents, TxFunction, UnionizeTupleEvents, V14, V14Extrinsic, V14Lookup, V14Pallets, bitSequence, char, compactBn, compactNumber, createCommonDescriptor, fixedStr, getDescriptorCreator, getPalletCreator, h64, metadata, selfDecoder, selfEncoder, v14 }; | ||
export { AccountId, Bin, Binary, type BitSequence, Blake2128, Blake2128Concat, Blake2256, type BlockHeader, type ConstFromDescriptors, type Descriptors, type EncoderWithHash, type ErrorsFromDescriptors, type EventsFromDescriptors, Hex, type HexString, Identity, OpaqueCodec, type OpaqueValue, type PlainDescriptor, type QueryFromDescriptors, type SS58String, Self, Storage, type StorageDescriptor, Twox128, Twox256, Twox64Concat, type TxDescriptor, type TxFromDescriptors, type V14, type V14Extrinsic, type V14Lookup, type V14Pallets, bitSequence, blockHeader, char, compactBn, compactNumber, fixedStr, h64, metadata, option, selfDecoder, selfEncoder, v14 }; |
@@ -6,2 +6,3 @@ "use strict"; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __export = (target, all) => { | ||
@@ -21,2 +22,6 @@ for (var name in all) | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
@@ -27,2 +32,4 @@ // src/index.ts | ||
AccountId: () => AccountId, | ||
Bin: () => Bin, | ||
Binary: () => Binary, | ||
Blake2128: () => Blake2128, | ||
@@ -40,11 +47,10 @@ Blake2128Concat: () => Blake2128Concat, | ||
bitSequence: () => bitSequence2, | ||
blockHeader: () => blockHeader, | ||
char: () => char, | ||
compactBn: () => compactBn, | ||
compactNumber: () => compactNumber, | ||
createCommonDescriptor: () => createCommonDescriptor, | ||
fixedStr: () => fixedStr, | ||
getDescriptorCreator: () => getDescriptorCreator, | ||
getPalletCreator: () => getPalletCreator, | ||
h64: () => h64, | ||
metadata: () => metadata, | ||
option: () => option, | ||
selfDecoder: () => selfDecoder, | ||
@@ -61,2 +67,4 @@ selfEncoder: () => selfEncoder, | ||
AccountId: () => AccountId, | ||
Bin: () => Bin, | ||
Binary: () => Binary, | ||
Hex: () => Hex, | ||
@@ -66,2 +74,3 @@ OpaqueCodec: () => OpaqueCodec, | ||
bitSequence: () => bitSequence2, | ||
blockHeader: () => blockHeader, | ||
char: () => char, | ||
@@ -72,2 +81,3 @@ compactBn: () => compactBn, | ||
metadata: () => metadata, | ||
option: () => option, | ||
selfDecoder: () => selfDecoder, | ||
@@ -145,3 +155,3 @@ selfEncoder: () => selfEncoder, | ||
let cache = (x) => { | ||
const encoder = import_scale_ts3.Struct.enc({ self: value() }); | ||
const encoder = value(); | ||
cache = encoder; | ||
@@ -154,3 +164,3 @@ return encoder(x); | ||
let cache = (x) => { | ||
const decoder = import_scale_ts3.Struct.dec({ self: value() }); | ||
const decoder = value(); | ||
const result = decoder; | ||
@@ -304,3 +314,3 @@ cache = decoder; | ||
}), | ||
fallback: (0, import_scale_ts7.Vector)(import_scale_ts7.u8), | ||
fallback: Hex(), | ||
docs: (0, import_scale_ts7.Vector)(import_scale_ts7.str) | ||
@@ -421,2 +431,78 @@ }); | ||
// src/codecs/blockHeader.ts | ||
var import_scale_ts13 = require("scale-ts"); | ||
var textEncoder2 = new TextEncoder(); | ||
var textDecoder2 = new TextDecoder(); | ||
var fourChars = (0, import_scale_ts13.enhanceCodec)( | ||
(0, import_scale_ts13.Bytes)(4), | ||
textEncoder2.encode.bind(textEncoder2), | ||
textDecoder2.decode.bind(textDecoder2) | ||
); | ||
var diggestVal = (0, import_scale_ts13.Struct)({ | ||
engine: fourChars, | ||
payload: Hex() | ||
}); | ||
var diggest = (0, import_scale_ts13.Enum)( | ||
{ | ||
consensus: diggestVal, | ||
seal: diggestVal, | ||
preRuntime: diggestVal, | ||
runtimeUpdated: import_scale_ts13._void | ||
}, | ||
[4, 5, 6, 8] | ||
); | ||
var hex32 = Hex(32); | ||
var blockHeader = (0, import_scale_ts13.Struct)({ | ||
parentHash: hex32, | ||
number: compactNumber, | ||
stateRoot: hex32, | ||
extrinsicRoot: hex32, | ||
digests: (0, import_scale_ts13.Vector)(diggest) | ||
}); | ||
// src/codecs/Binary.ts | ||
var import_utils2 = require("@polkadot-api/utils"); | ||
var import_scale_ts14 = require("scale-ts"); | ||
var textEncoder3 = new TextEncoder(); | ||
var textDecoder3 = new TextDecoder(); | ||
var Binary = class { | ||
constructor(data) { | ||
__publicField(this, "bytes"); | ||
__publicField(this, "hex", null); | ||
__publicField(this, "str", null); | ||
if (data instanceof Uint8Array) { | ||
this.bytes = data; | ||
} else if (data.match(/0[xX][0-9a-fA-F]+/)) { | ||
this.bytes = (0, import_utils2.fromHex)(data); | ||
this.hex = data; | ||
} else { | ||
this.bytes = textEncoder3.encode(data); | ||
this.str = data; | ||
} | ||
} | ||
asText() { | ||
return this.str === null ? this.str = textDecoder3.decode(this.bytes) : this.str; | ||
} | ||
asHex() { | ||
return this.hex === null ? this.hex = (0, import_utils2.toHex)(this.bytes) : this.hex; | ||
} | ||
asBytes() { | ||
return this.bytes; | ||
} | ||
}; | ||
var enc2 = (nBytes) => { | ||
const _enc = import_scale_ts14.Bytes.enc(nBytes); | ||
return (value) => _enc(value.asBytes()); | ||
}; | ||
var dec2 = (nBytes) => { | ||
const _dec = import_scale_ts14.Bytes.dec(nBytes); | ||
return (value) => new Binary(_dec(value)); | ||
}; | ||
var Bin = (nBytes) => (0, import_scale_ts14.createCodec)(enc2(nBytes), dec2(nBytes)); | ||
Bin.enc = enc2; | ||
Bin.dec = dec2; | ||
// src/codecs/helpers.ts | ||
var option = (tag, value) => ({ tag, value }); | ||
// src/index.ts | ||
@@ -426,3 +512,3 @@ __reExport(src_exports, codecs_exports, module.exports); | ||
// src/hashes/blake2.ts | ||
var import_utils2 = require("@polkadot-api/utils"); | ||
var import_utils3 = require("@polkadot-api/utils"); | ||
var import_blake2b2 = require("@noble/hashes/blake2b"); | ||
@@ -433,3 +519,3 @@ var len32 = { dkLen: 32 }; | ||
var Blake2128 = (encoded) => (0, import_blake2b2.blake2b)(encoded, len16); | ||
var Blake2128Concat = (encoded) => (0, import_utils2.mergeUint8)(Blake2128(encoded), encoded); | ||
var Blake2128Concat = (encoded) => (0, import_utils3.mergeUint8)(Blake2128(encoded), encoded); | ||
@@ -440,4 +526,4 @@ // src/hashes/identity.ts | ||
// src/hashes/twoX.ts | ||
var import_utils3 = require("@polkadot-api/utils"); | ||
var import_scale_ts13 = require("scale-ts"); | ||
var import_utils4 = require("@polkadot-api/utils"); | ||
var import_scale_ts15 = require("scale-ts"); | ||
@@ -595,15 +681,15 @@ // src/hashes/h64.ts | ||
}; | ||
var Twox64Concat = (encoded) => (0, import_utils3.mergeUint8)(import_scale_ts13.u64.enc(h64(encoded)), encoded); | ||
var Twox64Concat = (encoded) => (0, import_utils4.mergeUint8)(import_scale_ts15.u64.enc(h64(encoded)), encoded); | ||
// src/storage.ts | ||
var import_utils4 = require("@polkadot-api/utils"); | ||
var textEncoder2 = new TextEncoder(); | ||
var import_utils5 = require("@polkadot-api/utils"); | ||
var textEncoder4 = new TextEncoder(); | ||
var Storage = (pallet) => { | ||
const palledEncoded = Twox128(textEncoder2.encode(pallet)); | ||
return (name, dec2, ...encoders) => { | ||
const palletItemEncoded = (0, import_utils4.mergeUint8)( | ||
const palledEncoded = Twox128(textEncoder4.encode(pallet)); | ||
return (name, dec3, ...encoders) => { | ||
const palletItemEncoded = (0, import_utils5.mergeUint8)( | ||
palledEncoded, | ||
Twox128(textEncoder2.encode(name)) | ||
Twox128(textEncoder4.encode(name)) | ||
); | ||
const palletItemEncodedHex = (0, import_utils4.toHex)(palletItemEncoded); | ||
const palletItemEncodedHex = (0, import_utils5.toHex)(palletItemEncoded); | ||
const bytesToSkip = encoders.map((e) => e[1]).map((x) => { | ||
@@ -636,10 +722,10 @@ if (x === Identity) | ||
const fns = encoders.map( | ||
([{ enc: enc3 }, hash]) => (val) => hash(enc3(val)) | ||
([{ enc: enc4 }, hash]) => (val) => hash(enc4(val)) | ||
); | ||
const enc2 = (...args) => (0, import_utils4.toHex)( | ||
(0, import_utils4.mergeUint8)(palletItemEncoded, ...args.map((val, idx) => fns[idx](val))) | ||
const enc3 = (...args) => (0, import_utils5.toHex)( | ||
(0, import_utils5.mergeUint8)(palletItemEncoded, ...args.map((val, idx) => fns[idx](val))) | ||
); | ||
return { | ||
enc: enc2, | ||
dec: dec2, | ||
enc: enc3, | ||
dec: dec3, | ||
keyDecoder | ||
@@ -649,38 +735,2 @@ }; | ||
}; | ||
// src/descriptors.ts | ||
var createCommonDescriptor = (checksum, pallet, name) => ({ | ||
checksum, | ||
pallet, | ||
name | ||
}); | ||
var getDescriptorCreator = (type, checksum, pallet, name, codecs) => ({ | ||
type, | ||
props: { checksum, pallet, name }, | ||
codecs | ||
}); | ||
var getPalletCreator = (pallet) => { | ||
const getPayloadDescriptor = (type, checksum, name, codecs) => ({ | ||
type, | ||
props: { checksum, pallet, name }, | ||
codecs | ||
}); | ||
const getStorageDescriptor = (checksum, name, codecs) => ({ | ||
type: "storage", | ||
props: { checksum, pallet, name }, | ||
codecs | ||
}); | ||
const getTxDescriptor = (checksum, name, events, errors, codecs) => ({ | ||
type: "tx", | ||
props: { checksum, pallet, name }, | ||
codecs, | ||
events, | ||
errors | ||
}); | ||
return { | ||
getPayloadDescriptor, | ||
getStorageDescriptor, | ||
getTxDescriptor | ||
}; | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,3 @@ import * as scale_ts from 'scale-ts'; | ||
type SS58String = string & { | ||
__SS58String: unknown; | ||
__SS58String?: unknown; | ||
}; | ||
@@ -14,11 +14,5 @@ declare const AccountId: (ss58Format?: number, nBytes?: 32 | 33) => scale_ts.Codec<SS58String>; | ||
declare const selfEncoder: <T>(value: () => Encoder<T>) => Encoder<{ | ||
self: T; | ||
}>; | ||
declare const selfDecoder: <T>(value: () => Decoder<T>) => Decoder<{ | ||
self: T; | ||
}>; | ||
declare const Self: <T>(value: () => Codec<T>) => Codec<{ | ||
self: T; | ||
}>; | ||
declare const selfEncoder: <T>(value: () => Encoder<T>) => Encoder<T>; | ||
declare const selfDecoder: <T>(value: () => Decoder<T>) => Decoder<T>; | ||
declare const Self: <T>(value: () => Codec<T>) => Codec<T>; | ||
@@ -141,3 +135,3 @@ type OpaqueValue<T> = { | ||
type HexString = string & { | ||
__hexString: unknown; | ||
__hexString?: unknown; | ||
}; | ||
@@ -189,3 +183,3 @@ declare const Hex: { | ||
}; | ||
fallback: number[]; | ||
fallback: HexString; | ||
docs: string[]; | ||
@@ -360,3 +354,3 @@ }[]; | ||
}; | ||
fallback: number[]; | ||
fallback: HexString; | ||
docs: string[]; | ||
@@ -578,3 +572,3 @@ }[]; | ||
}; | ||
fallback: number[]; | ||
fallback: HexString; | ||
docs: string[]; | ||
@@ -618,2 +612,61 @@ }[]; | ||
declare const blockHeader: scale_ts.Codec<{ | ||
parentHash: HexString; | ||
number: number; | ||
stateRoot: HexString; | ||
extrinsicRoot: HexString; | ||
digests: ({ | ||
tag: "consensus"; | ||
value: { | ||
engine: string; | ||
payload: HexString; | ||
}; | ||
} | { | ||
tag: "seal"; | ||
value: { | ||
engine: string; | ||
payload: HexString; | ||
}; | ||
} | { | ||
tag: "preRuntime"; | ||
value: { | ||
engine: string; | ||
payload: HexString; | ||
}; | ||
} | { | ||
tag: "runtimeUpdated"; | ||
value: undefined; | ||
})[]; | ||
}>; | ||
type BlockHeader = CodecType<typeof blockHeader>; | ||
interface IBinary { | ||
asText: () => string; | ||
asHex: () => HexString; | ||
asBytes: () => Uint8Array; | ||
} | ||
declare class Binary implements IBinary { | ||
private bytes; | ||
private hex; | ||
private str; | ||
constructor(bytes: Uint8Array); | ||
constructor(hex: HexString); | ||
constructor(text: string); | ||
asText(): string; | ||
asHex(): string; | ||
asBytes(): Uint8Array; | ||
} | ||
declare const Bin: { | ||
(nBytes?: number): Codec<Binary>; | ||
enc: (nBytes?: number) => Encoder<Binary>; | ||
dec: (nBytes?: number) => Decoder<Binary>; | ||
}; | ||
declare const option: <T extends { | ||
tag: string; | ||
value: any; | ||
}, K extends T["tag"]>(tag: K, value: (T & { | ||
tag: K; | ||
})["value"]) => T; | ||
declare const Blake2256: (encoded: Uint8Array) => Uint8Array; | ||
@@ -638,74 +691,51 @@ declare const Blake2128: (encoded: Uint8Array) => Uint8Array; | ||
type Tuple<T> = readonly [T, ...T[]]; | ||
interface DescriptorCommon<Pallet extends string, Name extends string> { | ||
checksum: bigint; | ||
pallet: Pallet; | ||
name: Name; | ||
} | ||
interface ArgsWithPayloadCodec<Args extends Array<any>, O> { | ||
len: Args["length"]; | ||
} | ||
interface ArgsWithoutPayloadCodec<Args extends Array<any>> { | ||
len: Args["length"]; | ||
} | ||
interface StorageDescriptor<Common extends DescriptorCommon<string, string>, Codecs extends ArgsWithPayloadCodec<any, any>> { | ||
type: "storage"; | ||
props: Common; | ||
codecs: Codecs; | ||
} | ||
interface ConstantDescriptor<Common extends DescriptorCommon<string, string>, Codecs> { | ||
type: "const"; | ||
props: Common; | ||
codecs: Codecs; | ||
} | ||
interface EventDescriptor<Common extends DescriptorCommon<string, string>, Codecs> { | ||
type: "event"; | ||
props: Common; | ||
codecs: Codecs; | ||
} | ||
interface ErrorDescriptor<Common extends DescriptorCommon<string, string>, Codecs> { | ||
type: "error"; | ||
props: Common; | ||
codecs: Codecs; | ||
} | ||
interface TxDescriptor<Common extends DescriptorCommon<string, string>, Codecs extends ArgsWithoutPayloadCodec<any>, Events extends Array<EventDescriptor<any, any>>, Errors extends Array<ErrorDescriptor<any, any>>> { | ||
type: "tx"; | ||
props: Common; | ||
codecs: Codecs; | ||
events: Events; | ||
errors: Errors; | ||
} | ||
type Descriptor = ConstantDescriptor<any, any> | EventDescriptor<any, any> | StorageDescriptor<any, any> | ErrorDescriptor<any, any> | TxDescriptor<any, any, any, any>; | ||
declare const createCommonDescriptor: <Pallet extends string, Name extends string>(checksum: bigint, pallet: Pallet, name: Name) => DescriptorCommon<Pallet, Name>; | ||
declare const getDescriptorCreator: <Type extends "const" | "event" | "error", Pallet extends string, Name extends string, Codecs>(type: Type, checksum: bigint, pallet: Pallet, name: Name, codecs: Codecs) => Type extends "const" ? ConstantDescriptor<DescriptorCommon<Pallet, Name>, Codecs> : Type extends "event" ? EventDescriptor<DescriptorCommon<Pallet, Name>, Codecs> : ErrorDescriptor<DescriptorCommon<Pallet, Name>, Codecs>; | ||
declare const getPalletCreator: <Pallet extends string>(pallet: Pallet) => { | ||
getPayloadDescriptor: <Type extends "const" | "event" | "error", Name extends string, Codecs>(type: Type, checksum: bigint, name: Name, codecs: Codecs) => Type extends "const" ? ConstantDescriptor<DescriptorCommon<Pallet, Name>, Codecs> : Type extends "event" ? EventDescriptor<DescriptorCommon<Pallet, Name>, Codecs> : ErrorDescriptor<DescriptorCommon<Pallet, Name>, Codecs>; | ||
getStorageDescriptor: <Name_1 extends string, Codecs_1 extends ArgsWithPayloadCodec<any[], any>>(checksum: bigint, name: Name_1, codecs: Codecs_1) => StorageDescriptor<DescriptorCommon<Pallet, Name_1>, Codecs_1>; | ||
getTxDescriptor: <Name_2 extends string, Codecs_2 extends ArgsWithoutPayloadCodec<any>, Events extends EventDescriptor<any, any>[], Errors extends ErrorDescriptor<any, any>[]>(checksum: bigint, name: Name_2, events: Events, errors: Errors, codecs: Codecs_2) => TxDescriptor<DescriptorCommon<Pallet, Name_2>, Codecs_2, Events, Errors>; | ||
type PlainDescriptor<T> = string & { | ||
_type?: T; | ||
}; | ||
type EventToObject<E extends EventDescriptor<DescriptorCommon<any, string>, any>> = E extends EventDescriptor<DescriptorCommon<any, infer K>, infer V> ? { | ||
type: K; | ||
value: V; | ||
} : unknown; | ||
type UnionizeTupleEvents<E extends Array<EventDescriptor<any, any>>> = E extends Array<infer Ev> ? Ev extends EventDescriptor<any, any> ? EventToObject<Ev> : unknown : unknown; | ||
type TxDescriptorArgs<D extends TxDescriptor<any, any, any, any>> = D extends TxDescriptor<any, ArgsWithoutPayloadCodec<infer A>, any, any> ? A : []; | ||
type TxDescriptorEvents<D extends TxDescriptor<any, any, any, any>> = D extends TxDescriptor<any, any, infer E, any> ? E : []; | ||
type TxDescriptorErrors<D extends TxDescriptor<any, any, any, any>> = D extends TxDescriptor<any, any, any, infer Errors> ? Errors extends Tuple<ErrorDescriptor<any, any>> ? { | ||
[K in keyof Errors]: Errors[K] extends ErrorDescriptor<DescriptorCommon<any, infer Type>, infer Value> ? { | ||
type: Type; | ||
value: Value; | ||
} : unknown; | ||
}[keyof Errors extends number ? keyof Errors : never] : [] : []; | ||
type TxFunction<D extends TxDescriptor<any, any, any, any>> = (...args: TxDescriptorArgs<D>) => Promise<{ | ||
ok: true; | ||
events: Array<UnionizeTupleEvents<TxDescriptorEvents<D>>>; | ||
} | { | ||
ok: false; | ||
error: TxDescriptorErrors<D>; | ||
}>; | ||
type StorageType<T extends StorageDescriptor<any, ArgsWithPayloadCodec<any, any>>> = T extends StorageDescriptor<any, ArgsWithPayloadCodec<infer Args, infer Payload>> ? { | ||
keyArgs: Args; | ||
value: Payload; | ||
} : unknown; | ||
type StorageDescriptor<Args extends Array<any>, T, Optional extends true | false> = string & { | ||
_type: T; | ||
_args: Args; | ||
_optional: Optional; | ||
}; | ||
type TxDescriptor<Args extends Array<any>> = string & { | ||
_args: Args; | ||
}; | ||
type Descriptors = Record<string, [ | ||
Record<string, StorageDescriptor<any, any, any>>, | ||
Record<string, TxDescriptor<any>>, | ||
Record<string, PlainDescriptor<any>>, | ||
Record<string, PlainDescriptor<any>>, | ||
Record<string, PlainDescriptor<any>> | ||
]>; | ||
type PickDescriptors<Idx extends 0 | 1 | 2 | 3 | 4, T extends Descriptors> = { | ||
[K in keyof T]: T[K][Idx]; | ||
}; | ||
type Anonymize<T> = T extends string | number | bigint | boolean | void | undefined | null | symbol | Binary ? T : T extends (...args: infer Args) => infer R ? (...args: Anonymize<Args>) => Anonymize<R> : { | ||
[K in keyof T]: Anonymize<T[K]>; | ||
}; | ||
type ExtractStorage<T extends Record<string, Record<string, StorageDescriptor<any, any, any>>>> = { | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends StorageDescriptor<infer Key, infer Value, infer Optional> ? { | ||
KeyArgs: Anonymize<Key>; | ||
Value: Anonymize<Value>; | ||
IsOptional: Optional; | ||
} : unknown; | ||
}; | ||
}; | ||
type ExtractTx<T extends Record<string, Record<string, TxDescriptor<any>>>> = { | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends TxDescriptor<infer Args> ? Anonymize<Args> : unknown; | ||
}; | ||
}; | ||
type ExtractPlain<T extends Record<string, Record<string, PlainDescriptor<any>>>> = { | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends PlainDescriptor<infer Value> ? Anonymize<Value> : unknown; | ||
}; | ||
}; | ||
type QueryFromDescriptors<T extends Descriptors> = ExtractStorage<PickDescriptors<0, T>>; | ||
type TxFromDescriptors<T extends Descriptors> = ExtractTx<PickDescriptors<1, T>>; | ||
type EventsFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<2, T>>; | ||
type ErrorsFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<3, T>>; | ||
type ConstFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<4, T>>; | ||
export { AccountId, ArgsWithPayloadCodec, ArgsWithoutPayloadCodec, BitSequence, Blake2128, Blake2128Concat, Blake2256, ConstantDescriptor, Descriptor, DescriptorCommon, EncoderWithHash, ErrorDescriptor, EventDescriptor, EventToObject, Hex, HexString, Identity, OpaqueCodec, OpaqueValue, SS58String, Self, Storage, StorageDescriptor, StorageType, Twox128, Twox256, Twox64Concat, TxDescriptor, TxDescriptorArgs, TxDescriptorErrors, TxDescriptorEvents, TxFunction, UnionizeTupleEvents, V14, V14Extrinsic, V14Lookup, V14Pallets, bitSequence, char, compactBn, compactNumber, createCommonDescriptor, fixedStr, getDescriptorCreator, getPalletCreator, h64, metadata, selfDecoder, selfEncoder, v14 }; | ||
export { AccountId, Bin, Binary, type BitSequence, Blake2128, Blake2128Concat, Blake2256, type BlockHeader, type ConstFromDescriptors, type Descriptors, type EncoderWithHash, type ErrorsFromDescriptors, type EventsFromDescriptors, Hex, type HexString, Identity, OpaqueCodec, type OpaqueValue, type PlainDescriptor, type QueryFromDescriptors, type SS58String, Self, Storage, type StorageDescriptor, Twox128, Twox256, Twox64Concat, type TxDescriptor, type TxFromDescriptors, type V14, type V14Extrinsic, type V14Lookup, type V14Pallets, bitSequence, blockHeader, char, compactBn, compactNumber, fixedStr, h64, metadata, option, selfDecoder, selfEncoder, v14 }; |
@@ -1,2 +0,2 @@ | ||
"use strict";var J=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var ae=(e,r)=>{for(var t in r)J(e,t,{get:r[t],enumerable:!0})},X=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ve(r))!_e.call(e,a)&&a!==t&&J(e,a,{get:()=>r[a],enumerable:!(i=Be(r,a))||i.enumerable});return e},m=(e,r,t)=>(X(e,r,"default"),t&&X(t,r,"default"));var He=e=>X(J({},"__esModule",{value:!0}),e);var T={};ae(T,{AccountId:()=>de,Blake2128:()=>we,Blake2128Concat:()=>oe,Blake2256:()=>nr,Hex:()=>V,Identity:()=>ne,OpaqueCodec:()=>O,Self:()=>me,Storage:()=>ar,Twox128:()=>G,Twox256:()=>cr,Twox64Concat:()=>ce,bitSequence:()=>be,char:()=>he,compactBn:()=>pe,compactNumber:()=>d,createCommonDescriptor:()=>ir,fixedStr:()=>Ae,getDescriptorCreator:()=>dr,getPalletCreator:()=>pr,h64:()=>k,metadata:()=>Te,selfDecoder:()=>re,selfEncoder:()=>ee,v14:()=>$});module.exports=He(T);m(T,require("scale-ts"),module.exports);var l={};ae(l,{AccountId:()=>de,Hex:()=>V,OpaqueCodec:()=>O,Self:()=>me,bitSequence:()=>be,char:()=>he,compactBn:()=>pe,compactNumber:()=>d,fixedStr:()=>Ae,metadata:()=>Te,selfDecoder:()=>re,selfEncoder:()=>ee,v14:()=>$});m(l,require("scale-ts"));var K=require("scale-ts"),Y=require("@noble/hashes/blake2b"),Z=require("@scure/base"),ie=new TextEncoder().encode("SS58PRE"),Q=2,Ie=e=>{let r=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return t=>{let i=(0,Y.blake2b)(Uint8Array.of(...ie,...r,...t),{dkLen:64}).subarray(0,Q);return Z.base58.encode(Uint8Array.of(...r,...t,...i))}};function Le(e,r){return t=>{let i=Z.base58.decode(t),a=i.subarray(0,i[0]&64?2:1),y=i.subarray(a.length,i.length-Q);if(y.length!==e)throw new Error("Invalid public key length");let x=i.subarray(a.length+y.length),f=(0,Y.blake2b)(Uint8Array.of(...ie,...a,...y),{dkLen:64}).subarray(0,Q);if(x[0]!==f[0]||x[1]!==f[1])throw new Error("Invalid checksum");if(We(a)!=r)throw new Error("Invalid SS58 prefix");return y.slice()}}var de=(e=42,r=32)=>(0,K.enhanceCodec)((0,K.Bytes)(r),Le(r,e),Ie(e)),We=e=>{let r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.byteLength===1?r.getUint8(0):r.getUint16(0)};var F=require("scale-ts"),d=F.compact,pe=F.compact;var L=require("scale-ts"),ee=e=>{let r=t=>{let i=L.Struct.enc({self:e()});return r=i,i(t)};return t=>r(t)},re=e=>{let r=t=>{let i=L.Struct.dec({self:e()}),a=i;return r=i,a(t)};return t=>r(t)},me=e=>(0,L.createCodec)(ee(()=>e().enc),re(()=>e().dec));var B=require("scale-ts");var ye=(e,r=d.dec)=>(0,B.createDecoder)(t=>{let i=r(t),a=(0,B.Bytes)(i).dec(t),y;return{length:i,inner:()=>y=y||e(a)}}),le=(e,r=d.enc)=>t=>{let i=r(t.length),a=new Uint8Array(i.length+t.length);return a.set(i,0),a.set(e(t.inner()),i.length),a},O=(e,r=d)=>(0,B.createCodec)(le(e.enc,r.enc),ye(e.dec,r.dec));O.enc=le;O.dec=ye;var S=require("scale-ts");var n=require("scale-ts"),xe=(0,n.Option)(n.str),M=(0,n.Vector)(n.str),qe=(0,n.Enum)({bool:n._void,char:n._void,str:n._void,u8:n._void,u16:n._void,u32:n._void,u64:n._void,u128:n._void,u256:n._void,i8:n._void,i16:n._void,i32:n._void,i64:n._void,i128:n._void,i256:n._void}),ge=(0,n.Vector)((0,n.Struct)({name:xe,type:d,typeName:xe,docs:M})),Ke=(0,n.Struct)({len:n.u32,type:d}),Oe=(0,n.Struct)({bitStoreType:d,bitOrderType:d}),Me=(0,n.Vector)((0,n.Struct)({name:n.str,fields:ge,index:n.u8,docs:M})),Re=(0,n.Enum)({composite:ge,variant:Me,sequence:d,array:Ke,tuple:(0,n.Vector)(d),primitive:qe,compact:d,bitSequence:Oe,historicMetaCompat:n.str}),$e=(0,n.Struct)({name:n.str,type:(0,n.Option)(d)}),ze=(0,n.Vector)($e),je=(0,n.Struct)({id:d,path:M,params:ze,def:Re,docs:M}),fe=(0,n.Vector)(je);var R=require("@polkadot-api/utils"),W=require("scale-ts"),ue=e=>{let r=W.Bytes.enc(e);return t=>r((0,R.fromHex)(t))},Ce=e=>{let r=W.Bytes.dec(e);return t=>(0,R.toHex)(r(t))},V=e=>(0,W.createCodec)(ue(e),Ce(e));V.enc=ue;V.dec=Ce;var c=require("scale-ts"),Ge=(0,c.Enum)({Blake2128:c._void,Blake2256:c._void,Blake2128Concat:c._void,Twox128:c._void,Twox256:c._void,Twox64Concat:c._void,Identity:c._void}),Xe=(0,c.Vector)(Ge),Je=(0,c.Struct)({hashers:Xe,key:d,value:d}),Qe=(0,c.Struct)({name:c.str,modifier:c.u8,type:(0,c.Enum)({plain:d,map:Je}),fallback:(0,c.Vector)(c.u8),docs:(0,c.Vector)(c.str)}),Ye=(0,c.Option)((0,c.Struct)({prefix:c.str,items:(0,c.Vector)(Qe)})),De=(0,c.Vector)((0,c.Struct)({name:c.str,storage:Ye,calls:(0,c.Option)(d),events:(0,c.Option)(d),constants:(0,c.Vector)((0,c.Struct)({name:c.str,type:d,value:V(),docs:(0,c.Vector)(c.str)})),errors:(0,c.Option)(d),index:c.u8}));var Ze=(0,S.Struct)({type:d,version:S.u8,signedExtensions:(0,S.Vector)((0,S.Struct)({identifier:S.str,type:d,additionalSigned:d}))}),$=(0,S.Struct)({lookup:fe,pallets:De,extrinsic:Ze,type:d});var P=require("scale-ts");var Ee=()=>{throw new Error("Unsupported metadata version!")},h=(0,P.createCodec)(Ee,Ee),Te=(0,P.Struct)({magicNumber:P.u32,metadata:(0,P.Enum)({v0:h,v1:h,v2:h,v3:h,v4:h,v5:h,v6:h,v7:h,v8:h,v9:h,v10:h,v11:h,v12:h,v13:h,v14:$})});var _=require("scale-ts");var Fe=(0,_.createDecoder)(e=>{let r=d.dec(e),t=Math.ceil(r/8);return{bytes:(0,_.Bytes)(t).dec(e),bitsLen:r}}),er=e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);let r=d.enc(e.bitsLen),t=new Uint8Array(e.bytes.length+r.length);return t.set(r,0),t.set(e.bytes,r.length),t},be=(0,_.createCodec)(er,Fe);var z=require("scale-ts"),he=(0,z.enhanceCodec)(z.u8,e=>e.charCodeAt(0),String.fromCharCode);var j=require("scale-ts"),rr=new TextEncoder,tr=new TextDecoder,Ae=e=>(0,j.enhanceCodec)((0,j.Bytes)(e),r=>rr.encode(r),r=>tr.decode(r));m(T,l,module.exports);var ve=require("@polkadot-api/utils"),te=require("@noble/hashes/blake2b"),or={dkLen:32},nr=e=>(0,te.blake2b)(e,or),sr={dkLen:16},we=e=>(0,te.blake2b)(e,sr),oe=e=>(0,ve.mergeUint8)(we(e),e);var ne=e=>e;var Ue=require("@polkadot-api/utils"),Pe=require("scale-ts");var N=(e,r,t,i)=>new DataView(new Uint16Array([e,r,t,i]).buffer).getBigUint64(0,!0),se=2n**64n-1n,E=(e,r)=>e<<r&se|e>>64n-r,p=(e,r)=>e*r&se,C=(e,r)=>e+r&se,D=11400714785074694791n,A=14029467366897019727n,Se=1609587929392839161n,q=9650029242287828579n,ke=2870177450012600261n;function k(e,r=0n){let t=C(C(r,D),A),i=C(r,A),a=r,y=r-D,x=e.length,f=0,U=null;(function(){let o=0,v=o+x;if(x){if(U=new Uint8Array(32),x<32){U.set(e.subarray(0,x),f),f+=x;return}if(o<=v-32){let I=v-32;do{let w;w=N(e[o+1]<<8|e[o],e[o+3]<<8|e[o+2],e[o+5]<<8|e[o+4],e[o+7]<<8|e[o+6]),t=p(E(C(t,p(w,A)),31n),D),o+=8,w=N(e[o+1]<<8|e[o],e[o+3]<<8|e[o+2],e[o+5]<<8|e[o+4],e[o+7]<<8|e[o+6]),i=p(E(C(i,p(w,A)),31n),D),o+=8,w=N(e[o+1]<<8|e[o],e[o+3]<<8|e[o+2],e[o+5]<<8|e[o+4],e[o+7]<<8|e[o+6]),a=p(E(C(a,p(w,A)),31n),D),o+=8,w=N(e[o+1]<<8|e[o],e[o+3]<<8|e[o+2],e[o+5]<<8|e[o+4],e[o+7]<<8|e[o+6]),y=p(E(C(y,p(w,A)),31n),D),o+=8}while(o<=I)}o<v&&(U.set(e.subarray(o,v),f),f=v-o)}})(),e=U||e;let s,g=0;for(x>=32?(s=E(t,1n),s=C(s,E(i,7n)),s=C(s,E(a,12n)),s=C(s,E(y,18n)),t=p(E(p(t,A),31n),D),s=s^t,s=C(p(s,D),q),i=p(E(p(i,A),31n),D),s=s^i,s=C(p(s,D),q),a=p(E(p(a,A),31n),D),s=s^a,s=C(p(s,D),q),y=p(E(p(y,A),31n),D),s=s^y,s=C(p(s,D),q)):s=C(r,ke),s=C(s,BigInt(x));g<=f-8;){let b=N(e[g+1]<<8|e[g],e[g+3]<<8|e[g+2],e[g+5]<<8|e[g+4],e[g+7]<<8|e[g+6]);b=p(E(p(b,A),31n),D),s=C(p(E(s^b,27n),D),q),g+=8}if(g+4<=f){let b=p(N(e[g+1]<<8|e[g],e[g+3]<<8|e[g+2],0,0),D);s=C(p(E(s^b,23n),A),Se),g+=4}for(;g<f;){let b=p(N(e[g++],0,0,0),ke);s=p(E(s^b,11n),D)}let u=s>>33n;return s=p(s^u,A),u=s>>29n,s=p(s^u,Se),u=s>>32n,s^=u,s}var G=e=>{let r=new Uint8Array(16),t=new DataView(r.buffer);return t.setBigUint64(0,k(e),!0),t.setBigUint64(8,k(e,1n),!0),r},cr=e=>{let r=new Uint8Array(32),t=new DataView(r.buffer);return t.setBigUint64(0,k(e),!0),t.setBigUint64(8,k(e,1n),!0),t.setBigUint64(16,k(e,2n),!0),t.setBigUint64(24,k(e,3n),!0),r},ce=e=>(0,Ue.mergeUint8)(Pe.u64.enc(k(e)),e);var H=require("@polkadot-api/utils");var Ne=new TextEncoder,ar=e=>{let r=G(Ne.encode(e));return(t,i,...a)=>{let y=(0,H.mergeUint8)(r,G(Ne.encode(t))),x=(0,H.toHex)(y),f=a.map(u=>u[1]).map(u=>u===ne?0:u===ce?8:u===oe?16:null).filter(Boolean),U=u=>{if(!u.startsWith(x))throw new Error(`key does not match this storage (${e}.${t})`);if(f.length!==a.length)throw new Error("Impossible to decode this key");if(a.length===0)return[];let b=u.slice(x.length),o=new Array(a.length);for(let v=0,I=0;v<f.length;v++){let w=a[v][0];I+=f[v],o[v]=w.dec(b.slice(I*2)),I+=w.enc(o[v]).length}return o},s=a.map(([{enc:u},b])=>o=>b(u(o)));return{enc:(...u)=>(0,H.toHex)((0,H.mergeUint8)(y,...u.map((b,o)=>s[o](b)))),dec:i,keyDecoder:U}}};var ir=(e,r,t)=>({checksum:e,pallet:r,name:t}),dr=(e,r,t,i,a)=>({type:e,props:{checksum:r,pallet:t,name:i},codecs:a}),pr=e=>({getPayloadDescriptor:(a,y,x,f)=>({type:a,props:{checksum:y,pallet:e,name:x},codecs:f}),getStorageDescriptor:(a,y,x)=>({type:"storage",props:{checksum:a,pallet:e,name:y},codecs:x}),getTxDescriptor:(a,y,x,f,U)=>({type:"tx",props:{checksum:a,pallet:e,name:y},codecs:U,events:x,errors:f})}); | ||
"use strict";var P=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var je=Object.prototype.hasOwnProperty;var Je=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var fe=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},ee=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of Ge(t))!je.call(e,d)&&d!==r&&P(e,d,{get:()=>t[d],enumerable:!(i=ze(t,d))||i.enumerable});return e},l=(e,t,r)=>(ee(e,t,"default"),r&&ee(r,t,"default"));var Qe=e=>ee(P({},"__esModule",{value:!0}),e);var W=(e,t,r)=>(Je(e,typeof t!="symbol"?t+"":t,r),r);var h={};fe(h,{AccountId:()=>ue,Bin:()=>Z,Binary:()=>O,Blake2128:()=>Me,Blake2128Concat:()=>me,Blake2256:()=>Ct,Hex:()=>v,Identity:()=>le,OpaqueCodec:()=>X,Self:()=>he,Storage:()=>Ut,Twox128:()=>F,Twox256:()=>St,Twox64Concat:()=>ye,bitSequence:()=>De,blockHeader:()=>Le,char:()=>He,compactBn:()=>be,compactNumber:()=>a,fixedStr:()=>_e,h64:()=>D,metadata:()=>Be,option:()=>Ne,selfDecoder:()=>se,selfEncoder:()=>ce,v14:()=>j});module.exports=Qe(h);l(h,require("scale-ts"),module.exports);var p={};fe(p,{AccountId:()=>ue,Bin:()=>Z,Binary:()=>O,Hex:()=>v,OpaqueCodec:()=>X,Self:()=>he,bitSequence:()=>De,blockHeader:()=>Le,char:()=>He,compactBn:()=>be,compactNumber:()=>a,fixedStr:()=>_e,metadata:()=>Be,option:()=>Ne,selfDecoder:()=>se,selfEncoder:()=>ce,v14:()=>j});l(p,require("scale-ts"));var $=require("scale-ts"),re=require("@noble/hashes/blake2b"),oe=require("@scure/base"),xe=new TextEncoder().encode("SS58PRE"),te=2,Ye=e=>{let t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return r=>{let i=(0,re.blake2b)(Uint8Array.of(...xe,...t,...r),{dkLen:64}).subarray(0,te);return oe.base58.encode(Uint8Array.of(...t,...r,...i))}};function Ze(e,t){return r=>{let i=oe.base58.decode(r),d=i.subarray(0,i[0]&64?2:1),b=i.subarray(d.length,i.length-te);if(b.length!==e)throw new Error("Invalid public key length");let C=i.subarray(d.length+b.length),T=(0,re.blake2b)(Uint8Array.of(...xe,...d,...b),{dkLen:64}).subarray(0,te);if(C[0]!==T[0]||C[1]!==T[1])throw new Error("Invalid checksum");if(Fe(d)!=t)throw new Error("Invalid SS58 prefix");return b.slice()}}var ue=(e=42,t=32)=>(0,$.enhanceCodec)((0,$.Bytes)(t),Ze(t,e),Ye(e)),Fe=e=>{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)};var ne=require("scale-ts"),a=ne.compact,be=ne.compact;var ge=require("scale-ts"),ce=e=>{let t=r=>{let i=e();return t=i,i(r)};return r=>t(r)},se=e=>{let t=r=>{let i=e(),d=i;return t=i,d(r)};return r=>t(r)},he=e=>(0,ge.createCodec)(ce(()=>e().enc),se(()=>e().dec));var I=require("scale-ts");var Te=(e,t=a.dec)=>(0,I.createDecoder)(r=>{let i=t(r),d=(0,I.Bytes)(i).dec(r),b;return{length:i,inner:()=>b=b||e(d)}}),Ee=(e,t=a.enc)=>r=>{let i=t(r.length),d=new Uint8Array(i.length+r.length);return d.set(i,0),d.set(e(r.inner()),i.length),d},X=(e,t=a)=>(0,I.createCodec)(Ee(e.enc,t.enc),Te(e.dec,t.dec));X.enc=Ee;X.dec=Te;var B=require("scale-ts");var n=require("scale-ts"),we=(0,n.Option)(n.str),z=(0,n.Vector)(n.str),et=(0,n.Enum)({bool:n._void,char:n._void,str:n._void,u8:n._void,u16:n._void,u32:n._void,u64:n._void,u128:n._void,u256:n._void,i8:n._void,i16:n._void,i32:n._void,i64:n._void,i128:n._void,i256:n._void}),Ce=(0,n.Vector)((0,n.Struct)({name:we,type:a,typeName:we,docs:z})),tt=(0,n.Struct)({len:n.u32,type:a}),rt=(0,n.Struct)({bitStoreType:a,bitOrderType:a}),ot=(0,n.Vector)((0,n.Struct)({name:n.str,fields:Ce,index:n.u8,docs:z})),nt=(0,n.Enum)({composite:Ce,variant:ot,sequence:a,array:tt,tuple:(0,n.Vector)(a),primitive:et,compact:a,bitSequence:rt,historicMetaCompat:n.str}),ct=(0,n.Struct)({name:n.str,type:(0,n.Option)(a)}),st=(0,n.Vector)(ct),it=(0,n.Struct)({id:a,path:z,params:st,def:nt,docs:z}),Ae=(0,n.Vector)(it);var G=require("@polkadot-api/utils"),N=require("scale-ts"),Se=e=>{let t=N.Bytes.enc(e);return r=>t((0,G.fromHex)(r))},Ue=e=>{let t=N.Bytes.dec(e);return r=>(0,G.toHex)(t(r))},v=e=>(0,N.createCodec)(Se(e),Ue(e));v.enc=Se;v.dec=Ue;var s=require("scale-ts"),at=(0,s.Enum)({Blake2128:s._void,Blake2256:s._void,Blake2128Concat:s._void,Twox128:s._void,Twox256:s._void,Twox64Concat:s._void,Identity:s._void}),dt=(0,s.Vector)(at),mt=(0,s.Struct)({hashers:dt,key:a,value:a}),lt=(0,s.Struct)({name:s.str,modifier:s.u8,type:(0,s.Enum)({plain:a,map:mt}),fallback:v(),docs:(0,s.Vector)(s.str)}),pt=(0,s.Option)((0,s.Struct)({prefix:s.str,items:(0,s.Vector)(lt)})),ke=(0,s.Vector)((0,s.Struct)({name:s.str,storage:pt,calls:(0,s.Option)(a),events:(0,s.Option)(a),constants:(0,s.Vector)((0,s.Struct)({name:s.str,type:a,value:v(),docs:(0,s.Vector)(s.str)})),errors:(0,s.Option)(a),index:s.u8}));var yt=(0,B.Struct)({type:a,version:B.u8,signedExtensions:(0,B.Vector)((0,B.Struct)({identifier:B.str,type:a,additionalSigned:a}))}),j=(0,B.Struct)({lookup:Ae,pallets:ke,extrinsic:yt,type:a});var H=require("scale-ts");var ve=()=>{throw new Error("Unsupported metadata version!")},w=(0,H.createCodec)(ve,ve),Be=(0,H.Struct)({magicNumber:H.u32,metadata:(0,H.Enum)({v0:w,v1:w,v2:w,v3:w,v4:w,v5:w,v6:w,v7:w,v8:w,v9:w,v10:w,v11:w,v12:w,v13:w,v14:j})});var L=require("scale-ts");var ft=(0,L.createDecoder)(e=>{let t=a.dec(e),r=Math.ceil(t/8);return{bytes:(0,L.Bytes)(r).dec(e),bitsLen:t}}),xt=e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);let t=a.enc(e.bitsLen),r=new Uint8Array(e.bytes.length+t.length);return r.set(t,0),r.set(e.bytes,t.length),r},De=(0,L.createCodec)(xt,ft);var J=require("scale-ts"),He=(0,J.enhanceCodec)(J.u8,e=>e.charCodeAt(0),String.fromCharCode);var Q=require("scale-ts"),ut=new TextEncoder,bt=new TextDecoder,_e=e=>(0,Q.enhanceCodec)((0,Q.Bytes)(e),t=>ut.encode(t),t=>bt.decode(t));var A=require("scale-ts");var Ve=new TextEncoder,Ie=new TextDecoder,gt=(0,A.enhanceCodec)((0,A.Bytes)(4),Ve.encode.bind(Ve),Ie.decode.bind(Ie)),ie=(0,A.Struct)({engine:gt,payload:v()}),ht=(0,A.Enum)({consensus:ie,seal:ie,preRuntime:ie,runtimeUpdated:A._void},[4,5,6,8]),ae=v(32),Le=(0,A.Struct)({parentHash:ae,number:a,stateRoot:ae,extrinsicRoot:ae,digests:(0,A.Vector)(ht)});var Y=require("@polkadot-api/utils"),M=require("scale-ts");var Tt=new TextEncoder,Et=new TextDecoder,O=class{constructor(t){W(this,"bytes");W(this,"hex",null);W(this,"str",null);t instanceof Uint8Array?this.bytes=t:t.match(/0[xX][0-9a-fA-F]+/)?(this.bytes=(0,Y.fromHex)(t),this.hex=t):(this.bytes=Tt.encode(t),this.str=t)}asText(){return this.str===null?this.str=Et.decode(this.bytes):this.str}asHex(){return this.hex===null?this.hex=(0,Y.toHex)(this.bytes):this.hex}asBytes(){return this.bytes}},qe=e=>{let t=M.Bytes.enc(e);return r=>t(r.asBytes())},Ke=e=>{let t=M.Bytes.dec(e);return r=>new O(t(r))},Z=e=>(0,M.createCodec)(qe(e),Ke(e));Z.enc=qe;Z.dec=Ke;var Ne=(e,t)=>({tag:e,value:t});l(h,p,module.exports);var Oe=require("@polkadot-api/utils"),de=require("@noble/hashes/blake2b"),wt={dkLen:32},Ct=e=>(0,de.blake2b)(e,wt),At={dkLen:16},Me=e=>(0,de.blake2b)(e,At),me=e=>(0,Oe.mergeUint8)(Me(e),e);var le=e=>e;var We=require("@polkadot-api/utils"),$e=require("scale-ts");var _=(e,t,r,i)=>new DataView(new Uint16Array([e,t,r,i]).buffer).getBigUint64(0,!0),pe=2n**64n-1n,g=(e,t)=>e<<t&pe|e>>64n-t,m=(e,t)=>e*t&pe,x=(e,t)=>e+t&pe,u=11400714785074694791n,S=14029467366897019727n,Re=1609587929392839161n,R=9650029242287828579n,Pe=2870177450012600261n;function D(e,t=0n){let r=x(x(t,u),S),i=x(t,S),d=t,b=t-u,C=e.length,T=0,V=null;(function(){let o=0,U=o+C;if(C){if(V=new Uint8Array(32),C<32){V.set(e.subarray(0,C),T),T+=C;return}if(o<=U-32){let K=U-32;do{let k;k=_(e[o+1]<<8|e[o],e[o+3]<<8|e[o+2],e[o+5]<<8|e[o+4],e[o+7]<<8|e[o+6]),r=m(g(x(r,m(k,S)),31n),u),o+=8,k=_(e[o+1]<<8|e[o],e[o+3]<<8|e[o+2],e[o+5]<<8|e[o+4],e[o+7]<<8|e[o+6]),i=m(g(x(i,m(k,S)),31n),u),o+=8,k=_(e[o+1]<<8|e[o],e[o+3]<<8|e[o+2],e[o+5]<<8|e[o+4],e[o+7]<<8|e[o+6]),d=m(g(x(d,m(k,S)),31n),u),o+=8,k=_(e[o+1]<<8|e[o],e[o+3]<<8|e[o+2],e[o+5]<<8|e[o+4],e[o+7]<<8|e[o+6]),b=m(g(x(b,m(k,S)),31n),u),o+=8}while(o<=K)}o<U&&(V.set(e.subarray(o,U),T),T=U-o)}})(),e=V||e;let c,y=0;for(C>=32?(c=g(r,1n),c=x(c,g(i,7n)),c=x(c,g(d,12n)),c=x(c,g(b,18n)),r=m(g(m(r,S),31n),u),c=c^r,c=x(m(c,u),R),i=m(g(m(i,S),31n),u),c=c^i,c=x(m(c,u),R),d=m(g(m(d,S),31n),u),c=c^d,c=x(m(c,u),R),b=m(g(m(b,S),31n),u),c=c^b,c=x(m(c,u),R)):c=x(t,Pe),c=x(c,BigInt(C));y<=T-8;){let E=_(e[y+1]<<8|e[y],e[y+3]<<8|e[y+2],e[y+5]<<8|e[y+4],e[y+7]<<8|e[y+6]);E=m(g(m(E,S),31n),u),c=x(m(g(c^E,27n),u),R),y+=8}if(y+4<=T){let E=m(_(e[y+1]<<8|e[y],e[y+3]<<8|e[y+2],0,0),u);c=x(m(g(c^E,23n),S),Re),y+=4}for(;y<T;){let E=m(_(e[y++],0,0,0),Pe);c=m(g(c^E,11n),u)}let f=c>>33n;return c=m(c^f,S),f=c>>29n,c=m(c^f,Re),f=c>>32n,c^=f,c}var F=e=>{let t=new Uint8Array(16),r=new DataView(t.buffer);return r.setBigUint64(0,D(e),!0),r.setBigUint64(8,D(e,1n),!0),t},St=e=>{let t=new Uint8Array(32),r=new DataView(t.buffer);return r.setBigUint64(0,D(e),!0),r.setBigUint64(8,D(e,1n),!0),r.setBigUint64(16,D(e,2n),!0),r.setBigUint64(24,D(e,3n),!0),t},ye=e=>(0,We.mergeUint8)($e.u64.enc(D(e)),e);var q=require("@polkadot-api/utils");var Xe=new TextEncoder,Ut=e=>{let t=F(Xe.encode(e));return(r,i,...d)=>{let b=(0,q.mergeUint8)(t,F(Xe.encode(r))),C=(0,q.toHex)(b),T=d.map(f=>f[1]).map(f=>f===le?0:f===ye?8:f===me?16:null).filter(Boolean),V=f=>{if(!f.startsWith(C))throw new Error(`key does not match this storage (${e}.${r})`);if(T.length!==d.length)throw new Error("Impossible to decode this key");if(d.length===0)return[];let E=f.slice(C.length),o=new Array(d.length);for(let U=0,K=0;U<T.length;U++){let k=d[U][0];K+=T[U],o[U]=k.dec(E.slice(K*2)),K+=k.enc(o[U]).length}return o},c=d.map(([{enc:f},E])=>o=>E(f(o)));return{enc:(...f)=>(0,q.toHex)((0,q.mergeUint8)(b,...f.map((E,o)=>c[o](E)))),dec:i,keyDecoder:V}}}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@polkadot-api/substrate-bindings", | ||
"version": "0.0.1-09799e72004d94fd5719dea88928b301c7b9c84d.1.0", | ||
"version": "0.0.1-097dae903cc84c0d8a6c93f39fef5e4724660825.1.0", | ||
"author": "Josep M Sobrepere (https://github.com/josepot)", | ||
@@ -45,4 +45,4 @@ "repository": { | ||
"@scure/base": "^1.1.1", | ||
"scale-ts": "^1.4.2", | ||
"@polkadot-api/utils": "0.0.1-09799e72004d94fd5719dea88928b301c7b9c84d.1.0" | ||
"scale-ts": "^1.4.3", | ||
"@polkadot-api/utils": "0.0.1-097dae903cc84c0d8a6c93f39fef5e4724660825.1.0" | ||
}, | ||
@@ -49,0 +49,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2904
241077