Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@polkadot-api/substrate-bindings

Package Overview
Dependencies
Maintainers
2
Versions
604
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polkadot-api/substrate-bindings - npm Package Compare versions

Comparing version 0.0.1-fc2d544220690af6fb53e6837b4498eaf27ec832.1.0 to 0.0.1-fc842ef2a18284b688469fbeed66fcaef82e0b3c.1.0

383

dist/index.d.ts
import * as scale_ts from 'scale-ts';
import { Codec, Encoder, Decoder, CodecType } from 'scale-ts';
export * from 'scale-ts';
import { Codec, Encoder, Decoder, StringRecord, CodecType, EncoderType, DecoderType } from 'scale-ts';
export { Bytes, Codec, CodecType, Decoder, DecoderType, Encoder, EncoderType, Option, Result, ResultPayload, StringRecord, Struct, Tuple, Vector, _void, bool, compact, createCodec, createDecoder, enhanceCodec, enhanceDecoder, enhanceEncoder, i128, i16, i256, i32, i64, i8, str, u128, u16, u256, u32, u64, u8 } from 'scale-ts';
import * as scale_ts_dist_types from 'scale-ts/dist/types';

@@ -10,5 +11,40 @@ type SS58String = string & {

type HexString = string & {
__hexString?: unknown;
};
declare const Hex: {
(nBytes?: number): Codec<HexString>;
enc: (nBytes?: number) => Encoder<HexString>;
dec: (nBytes?: number) => Decoder<HexString>;
};
declare class Binary {
#private;
constructor(data: Uint8Array);
asText: () => string;
asHex: () => string;
asBytes: () => Uint8Array;
static fromText(input: string): Binary;
static fromHex(input: HexString): Binary;
static fromBytes(input: Uint8Array): Binary;
}
declare const Bin: {
(nBytes?: number): Codec<Binary>;
enc: (nBytes?: number) => Encoder<Binary>;
dec: (nBytes?: number) => Decoder<Binary>;
};
interface BitSequence {
bitsLen: number;
bytes: Uint8Array;
}
declare const bitSequence: scale_ts.Codec<BitSequence>;
declare const char: scale_ts.Codec<string>;
declare const compactNumber: Codec<number>;
declare const compactBn: Codec<bigint>;
declare const fixedStr: (nBytes: number) => scale_ts.Codec<string>;
declare const selfEncoder: <T>(value: () => Encoder<T>) => Encoder<T>;

@@ -18,12 +54,107 @@ declare const selfDecoder: <T>(value: () => Decoder<T>) => Decoder<T>;

type OpaqueValue<T> = {
length: number;
inner: () => T;
type Tuple<T, N extends number> = readonly [T, ...T[]] & {
length: N;
};
declare const OpaqueCodec: {
<T>(inner: Codec<T>, len?: Codec<number>): Codec<OpaqueValue<T>>;
enc: <T_1>(inner: Encoder<T_1>, len?: Encoder<number>) => Encoder<OpaqueValue<T_1>>;
dec: <T_2>(inner: Decoder<T_2>, len?: Decoder<number>) => Decoder<OpaqueValue<T_2>>;
type Push<T extends any[], V> = [...T, V];
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
type TuplifyUnion<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>;
type RestrictedLenTuple<T, O extends StringRecord<any>> = Tuple<T, TuplifyUnion<keyof O> extends Tuple<any, infer V> ? V : 0>;
type ExtractValue<T extends {
type: string;
value?: any;
}, K extends string> = T extends {
type: K;
value: infer R;
} ? R : never;
interface Discriminant<T extends {
type: string;
value?: any;
}> {
is<K extends T["type"]>(this: Enum<T>, type: K): this is Enum<{
type: K;
value: ExtractValue<T, K>;
}>;
as<K extends T["type"]>(type: K): ExtractValue<T, K>;
}
type MyTuple<T> = [T, ...T[]];
type List<T> = Array<T>;
type SeparateUndefined<T> = undefined extends T ? undefined | Exclude<T, undefined> : T;
type Anonymize<T> = SeparateUndefined<T extends string | number | bigint | boolean | void | undefined | null | symbol | Binary | Enum<{
type: string;
value: any;
}> | Uint8Array ? T : T extends (...args: infer Args) => infer R ? (...args: {
[K in keyof Args]: Anonymize<Args[K]>;
}) => Anonymize<R> : T extends MyTuple<any> ? {
[K in keyof T]: Anonymize<T[K]>;
} : [] extends T ? [] : T extends Array<infer A> ? List<Anonymize<A>> : {
[K in keyof T]: Anonymize<T[K]>;
}>;
declare const _Enum: {};
type EnumOption<T extends {
type: string;
value?: any;
}, Key extends T["type"]> = Anonymize<ExtractValue<T, Key>>;
type GetEnum<T extends Enum<{
type: string;
value: any;
}>> = {
[K in T["type"]]: (...args: ExtractValue<T, K> extends undefined ? [] : [value: Anonymize<ExtractValue<T, K>>]) => T;
};
type Enum<T extends {
type: string;
value?: any;
}> = T & Discriminant<T>;
declare const Enum: <T extends {
type: string;
value?: any;
}, Key extends T["type"]>(type: Key, ...args: ExtractValue<T, Key> extends undefined ? [] : [value: Anonymize<ExtractValue<T, Key>>]) => Enum<ExtractValue<T, Key> extends undefined ? T : ExtractValue<T, Key> extends never ? T : {
type: Key;
value: ExtractValue<T, Key>;
}>;
declare const Variant: {
<O extends StringRecord<Codec<any>>>(inner: O, indexes?: RestrictedLenTuple<number, O> | undefined): Codec<Enum<{ [K in keyof O]: K extends string ? {
type: K;
value: CodecType<O[K]>;
} : never; }[keyof O]>>;
enc: <O_1 extends StringRecord<Encoder<any>>>(inner: O_1, x?: RestrictedLenTuple<number, O_1> | undefined) => Encoder<Enum<{ [K_1 in keyof O_1]: K_1 extends string ? {
type: K_1;
value: EncoderType<O_1[K_1]>;
} : never; }[keyof O_1]>>;
dec: <O_2 extends StringRecord<Decoder<any>>>(inner: O_2, x?: RestrictedLenTuple<number, O_2> | undefined) => Decoder<Enum<{ [K_2 in keyof O_2]: K_2 extends string ? {
type: K_2;
value: DecoderType<O_2[K_2]>;
} : never; }[keyof O_2]>>;
};
declare const blockHeader: scale_ts_dist_types.Codec<{
parentHash: HexString;
number: number;
stateRoot: HexString;
extrinsicRoot: HexString;
digests: Enum<{
type: "consensus";
value: {
engine: string;
payload: HexString;
};
} | {
type: "seal";
value: {
engine: string;
payload: HexString;
};
} | {
type: "preRuntime";
value: {
engine: string;
payload: HexString;
};
} | {
type: "runtimeUpdated";
value: undefined;
}>[];
}>;
type BlockHeader = CodecType<typeof blockHeader>;
declare const lookup: scale_ts.Codec<{

@@ -34,3 +165,3 @@ id: number;

name: string;
type: number | void | undefined;
type: number | undefined;
}[];

@@ -40,5 +171,5 @@ def: {

value: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -51,5 +182,5 @@ }[];

fields: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -137,70 +268,8 @@ }[];

type HexString = string & {
__hexString?: unknown;
};
declare const Hex: {
(nBytes?: number): Codec<HexString>;
enc: (nBytes?: number) => Encoder<HexString>;
dec: (nBytes?: number) => Decoder<HexString>;
};
declare const pallets: scale_ts.Codec<{
name: string;
storage: void | {
prefix: string;
items: {
name: string;
modifier: number;
type: {
tag: "map";
value: {
hashers: ({
tag: "Blake2128";
value: undefined;
} | {
tag: "Blake2256";
value: undefined;
} | {
tag: "Blake2128Concat";
value: undefined;
} | {
tag: "Twox128";
value: undefined;
} | {
tag: "Twox256";
value: undefined;
} | {
tag: "Twox64Concat";
value: undefined;
} | {
tag: "Identity";
value: undefined;
})[];
key: number;
value: number;
};
} | {
tag: "plain";
value: number;
};
fallback: HexString;
docs: string[];
}[];
} | undefined;
calls: number | void | undefined;
events: number | void | undefined;
constants: {
name: string;
type: number;
value: HexString;
docs: string[];
}[];
errors: number | void | undefined;
index: number;
}[]>;
type V14Pallets = CodecType<typeof pallets>;
declare const extrinsic: scale_ts.Codec<{
type: number;
version: number;
address: number;
call: number;
signature: number;
extra: number;
signedExtensions: {

@@ -212,4 +281,4 @@ identifier: string;

}>;
type V14Extrinsic = CodecType<typeof extrinsic>;
declare const v14: scale_ts.Codec<{
type V15Extrinsic = CodecType<typeof extrinsic>;
declare const v15: scale_ts.Codec<{
lookup: {

@@ -220,3 +289,3 @@ id: number;

name: string;
type: number | void | undefined;
type: number | undefined;
}[];

@@ -226,5 +295,5 @@ def: {

value: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -237,5 +306,5 @@ }[];

fields: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -323,3 +392,3 @@ }[];

name: string;
storage: void | {
storage: {
prefix: string;

@@ -365,4 +434,4 @@ items: {

} | undefined;
calls: number | void | undefined;
events: number | void | undefined;
calls: number | undefined;
events: number | undefined;
constants: {

@@ -374,8 +443,12 @@ name: string;

}[];
errors: number | void | undefined;
errors: number | undefined;
index: number;
docs: string[];
}[];
extrinsic: {
type: number;
version: number;
address: number;
call: number;
signature: number;
extra: number;
signedExtensions: {

@@ -388,4 +461,26 @@ identifier: string;

type: number;
apis: {
name: string;
methods: {
name: string;
inputs: {
name: string;
type: number;
}[];
output: number;
docs: string[];
}[];
docs: string[];
}[];
outerEnums: {
call: number;
event: number;
error: number;
};
custom: [string, {
type: number;
value: HexString;
}][];
}>;
type V14 = CodecType<typeof v14>;
type V15 = CodecType<typeof v15>;

@@ -438,2 +533,5 @@ declare const metadata: Codec<{

tag: "v14";
value: unknown;
} | {
tag: "v15";
value: {

@@ -445,3 +543,3 @@ lookup: {

name: string;
type: number | void | undefined;
type: number | undefined;
}[];

@@ -451,5 +549,5 @@ def: {

value: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -462,5 +560,5 @@ }[];

fields: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -548,3 +646,3 @@ }[];

name: string;
storage: void | {
storage: {
prefix: string;

@@ -590,4 +688,4 @@ items: {

} | undefined;
calls: number | void | undefined;
events: number | void | undefined;
calls: number | undefined;
events: number | undefined;
constants: {

@@ -599,8 +697,12 @@ name: string;

}[];
errors: number | void | undefined;
errors: number | undefined;
index: number;
docs: string[];
}[];
extrinsic: {
type: number;
version: number;
address: number;
call: number;
signature: number;
extra: number;
signedExtensions: {

@@ -613,2 +715,24 @@ identifier: string;

type: number;
apis: {
name: string;
methods: {
name: string;
inputs: {
name: string;
type: number;
}[];
output: number;
docs: string[];
}[];
docs: string[];
}[];
outerEnums: {
call: number;
event: number;
error: number;
};
custom: [string, {
type: number;
value: HexString;
}][];
};

@@ -618,12 +742,2 @@ };

interface BitSequence {
bitsLen: number;
bytes: Uint8Array;
}
declare const bitSequence: scale_ts.Codec<BitSequence>;
declare const char: scale_ts.Codec<string>;
declare const fixedStr: (nBytes: number) => scale_ts.Codec<string>;
declare const Blake2256: (encoded: Uint8Array) => Uint8Array;

@@ -656,18 +770,21 @@ declare const Blake2128: (encoded: Uint8Array) => Uint8Array;

};
type TxDescriptor<Args extends Array<any>> = string & {
_args: Args;
type TxDescriptor<Args extends {} | undefined> = string & {
___: 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> = {
type RuntimeDescriptor<Args extends Array<any>, T> = string & {
__: [Args, T];
};
type Descriptors = {
pallets: Record<string, [
Record<string, StorageDescriptor<any, any, any>>,
Record<string, TxDescriptor<any>>,
Record<string, PlainDescriptor<any>>,
Record<string, PlainDescriptor<any>>,
Record<string, PlainDescriptor<any>>
]>;
apis: Record<string, Record<string, RuntimeDescriptor<any, any>>>;
};
type PickDescriptors<Idx extends 0 | 1 | 2 | 3 | 4, T extends Descriptors["pallets"]> = {
[K in keyof T]: T[K][Idx];
};
type Anonymize<T> = T extends string | number | bigint | boolean | void | undefined | null | symbol ? 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>>>> = {

@@ -678,3 +795,3 @@ [K in keyof T]: {

Value: Anonymize<Value>;
IsOptional: Optional extends 1 ? false : true;
IsOptional: Optional;
} : unknown;

@@ -693,8 +810,8 @@ };

};
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>>;
type QueryFromDescriptors<T extends Descriptors> = ExtractStorage<PickDescriptors<0, T["pallets"]>>;
type TxFromDescriptors<T extends Descriptors> = ExtractTx<PickDescriptors<1, T["pallets"]>>;
type EventsFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<2, T["pallets"]>>;
type ErrorsFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<3, T["pallets"]>>;
type ConstFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<4, T["pallets"]>>;
export { AccountId, BitSequence, Blake2128, Blake2128Concat, Blake2256, ConstFromDescriptors, Descriptors, EncoderWithHash, ErrorsFromDescriptors, EventsFromDescriptors, Hex, HexString, Identity, OpaqueCodec, OpaqueValue, PlainDescriptor, QueryFromDescriptors, SS58String, Self, Storage, StorageDescriptor, Twox128, Twox256, Twox64Concat, TxDescriptor, TxFromDescriptors, V14, V14Extrinsic, V14Lookup, V14Pallets, bitSequence, char, compactBn, compactNumber, fixedStr, h64, metadata, selfDecoder, selfEncoder, v14 };
export { AccountId, type Anonymize, Bin, Binary, type BitSequence, Blake2128, Blake2128Concat, Blake2256, type BlockHeader, type ConstFromDescriptors, type Descriptors, type Discriminant, type EncoderWithHash, Enum, type EnumOption, type ErrorsFromDescriptors, type EventsFromDescriptors, type GetEnum, Hex, type HexString, Identity, type PlainDescriptor, type QueryFromDescriptors, type RuntimeDescriptor, type SS58String, Self, Storage, type StorageDescriptor, Twox128, Twox256, Twox64Concat, type TxDescriptor, type TxFromDescriptors, type V14Lookup, type V15, type V15Extrinsic, Variant, _Enum, bitSequence, blockHeader, char, compactBn, compactNumber, fixedStr, h64, metadata, selfDecoder, selfEncoder, v15 };

@@ -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) => {

@@ -19,4 +20,25 @@ for (var name in all)

};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};

@@ -27,47 +49,59 @@ // src/index.ts

AccountId: () => AccountId,
Bin: () => Bin,
Binary: () => Binary,
Blake2128: () => Blake2128,
Blake2128Concat: () => Blake2128Concat,
Blake2256: () => Blake2256,
Bytes: () => import_scale_ts8.Bytes,
Enum: () => Enum,
Hex: () => Hex,
Identity: () => Identity,
OpaqueCodec: () => OpaqueCodec,
Option: () => import_scale_ts8.Option,
Result: () => import_scale_ts8.Result,
Self: () => Self,
Storage: () => Storage,
Struct: () => import_scale_ts8.Struct,
Tuple: () => import_scale_ts8.Tuple,
Twox128: () => Twox128,
Twox256: () => Twox256,
Twox64Concat: () => Twox64Concat,
bitSequence: () => bitSequence2,
Variant: () => Variant,
Vector: () => import_scale_ts8.Vector,
_Enum: () => _Enum,
_void: () => import_scale_ts8._void,
bitSequence: () => bitSequence,
blockHeader: () => blockHeader,
bool: () => import_scale_ts8.bool,
char: () => char,
compact: () => import_scale_ts8.compact,
compactBn: () => compactBn,
compactNumber: () => compactNumber,
createCodec: () => import_scale_ts8.createCodec,
createDecoder: () => import_scale_ts8.createDecoder,
enhanceCodec: () => import_scale_ts8.enhanceCodec,
enhanceDecoder: () => import_scale_ts8.enhanceDecoder,
enhanceEncoder: () => import_scale_ts8.enhanceEncoder,
fixedStr: () => fixedStr,
h64: () => h64,
i128: () => import_scale_ts8.i128,
i16: () => import_scale_ts8.i16,
i256: () => import_scale_ts8.i256,
i32: () => import_scale_ts8.i32,
i64: () => import_scale_ts8.i64,
i8: () => import_scale_ts8.i8,
metadata: () => metadata,
selfDecoder: () => selfDecoder,
selfEncoder: () => selfEncoder,
v14: () => v14
str: () => import_scale_ts8.str,
u128: () => import_scale_ts8.u128,
u16: () => import_scale_ts8.u16,
u256: () => import_scale_ts8.u256,
u32: () => import_scale_ts8.u32,
u64: () => import_scale_ts8.u64,
u8: () => import_scale_ts8.u8,
v15: () => v15
});
module.exports = __toCommonJS(src_exports);
__reExport(src_exports, require("scale-ts"), module.exports);
// src/codecs/index.ts
var codecs_exports = {};
__export(codecs_exports, {
AccountId: () => AccountId,
Hex: () => Hex,
OpaqueCodec: () => OpaqueCodec,
Self: () => Self,
bitSequence: () => bitSequence2,
char: () => char,
compactBn: () => compactBn,
compactNumber: () => compactNumber,
fixedStr: () => fixedStr,
metadata: () => metadata,
selfDecoder: () => selfDecoder,
selfEncoder: () => selfEncoder,
v14: () => v14
});
__reExport(codecs_exports, require("scale-ts"));
// src/codecs/AccountId.ts
// src/codecs/scale/AccountId.ts
var import_scale_ts = require("scale-ts");

@@ -129,9 +163,110 @@ var import_blake2b = require("@noble/hashes/blake2b");

// src/codecs/compact.ts
// src/codecs/scale/Binary.ts
var import_scale_ts2 = require("scale-ts");
var compactNumber = import_scale_ts2.compact;
var compactBn = import_scale_ts2.compact;
var import_utils = require("@polkadot-api/utils");
var textEncoder = new TextEncoder();
var textDecoder = new TextDecoder();
var _bytes, _hex, _str;
var _Binary = class _Binary {
constructor(data) {
__privateAdd(this, _bytes, void 0);
__privateAdd(this, _hex, null);
__privateAdd(this, _str, null);
__publicField(this, "asText", () => __privateGet(this, _str) === null ? __privateSet(this, _str, textDecoder.decode(__privateGet(this, _bytes))) : __privateGet(this, _str));
__publicField(this, "asHex", () => __privateGet(this, _hex) === null ? __privateSet(this, _hex, (0, import_utils.toHex)(__privateGet(this, _bytes))) : __privateGet(this, _hex));
__publicField(this, "asBytes", () => __privateGet(this, _bytes));
__privateSet(this, _bytes, data);
}
static fromText(input) {
return new _Binary(textEncoder.encode(input));
}
static fromHex(input) {
return new _Binary((0, import_utils.fromHex)(input));
}
static fromBytes(input) {
return new _Binary(input);
}
};
_bytes = new WeakMap();
_hex = new WeakMap();
_str = new WeakMap();
var Binary = _Binary;
var enc = (nBytes) => {
const _enc = import_scale_ts2.Bytes.enc(nBytes);
return (value) => _enc(value.asBytes());
};
var dec = (nBytes) => {
const _dec = import_scale_ts2.Bytes.dec(nBytes);
return (value) => Binary.fromBytes(_dec(value));
};
var Bin = (nBytes) => (0, import_scale_ts2.createCodec)(enc(nBytes), dec(nBytes));
Bin.enc = enc;
Bin.dec = dec;
// src/codecs/Self.ts
// src/codecs/scale/bitSequence.ts
var import_scale_ts4 = require("scale-ts");
// src/codecs/scale/compact.ts
var import_scale_ts3 = require("scale-ts");
var compactNumber = import_scale_ts3.compact;
var compactBn = import_scale_ts3.compact;
// src/codecs/scale/bitSequence.ts
var bitSequenceDecoder = (0, import_scale_ts4.createDecoder)((data) => {
const bitsLen = compactNumber.dec(data);
const bytesLen = Math.ceil(bitsLen / 8);
const bytes = (0, import_scale_ts4.Bytes)(bytesLen).dec(data);
return { bytes, bitsLen };
});
var bitSequenceEncoder = (input) => {
if (input.bitsLen > input.bytes.length * 8)
throw new Error(
`Not enough bytes. (bitsLen:${input.bitsLen}, bytesLen:${input.bytes.length})`
);
const lenEncoded = compactNumber.enc(input.bitsLen);
const result = new Uint8Array(input.bytes.length + lenEncoded.length);
result.set(lenEncoded, 0);
result.set(input.bytes, lenEncoded.length);
return result;
};
var bitSequence = (0, import_scale_ts4.createCodec)(bitSequenceEncoder, bitSequenceDecoder);
// src/codecs/scale/char.ts
var import_scale_ts5 = require("scale-ts");
var char = (0, import_scale_ts5.enhanceCodec)(
import_scale_ts5.u8,
(str5) => str5.charCodeAt(0),
String.fromCharCode
);
// src/codecs/scale/Hex.ts
var import_utils2 = require("@polkadot-api/utils");
var import_scale_ts6 = require("scale-ts");
var enc2 = (nBytes) => {
const _enc = import_scale_ts6.Bytes.enc(nBytes);
return (value) => _enc((0, import_utils2.fromHex)(value));
};
var dec2 = (nBytes) => {
const _dec = import_scale_ts6.Bytes.dec(nBytes);
return (value) => (0, import_utils2.toHex)(_dec(value));
};
var Hex = (nBytes) => (0, import_scale_ts6.createCodec)(enc2(nBytes), dec2(nBytes));
Hex.enc = enc2;
Hex.dec = dec2;
// src/codecs/scale/fixed-str.ts
var import_scale_ts7 = require("scale-ts");
var textEncoder2 = new TextEncoder();
var textDecoder2 = new TextDecoder();
var fixedStr = (nBytes) => (0, import_scale_ts7.enhanceCodec)(
(0, import_scale_ts7.Bytes)(nBytes),
(str5) => textEncoder2.encode(str5),
(bytes) => textDecoder2.decode(bytes)
);
// src/codecs/scale/re-exported.ts
var import_scale_ts8 = require("scale-ts");
// src/codecs/scale/Self.ts
var import_scale_ts9 = require("scale-ts");
var selfEncoder = (value) => {

@@ -154,3 +289,3 @@ let cache = (x) => {

};
var Self = (value) => (0, import_scale_ts3.createCodec)(
var Self = (value) => (0, import_scale_ts9.createCodec)(
selfEncoder(() => value().enc),

@@ -160,53 +295,103 @@ selfDecoder(() => value().dec)

// src/codecs/Opaque.ts
var import_scale_ts4 = require("scale-ts");
var OpaqueDecoder = (inner, len = compactNumber.dec) => (0, import_scale_ts4.createDecoder)((bytes) => {
const length = len(bytes);
const innerBytes = (0, import_scale_ts4.Bytes)(length).dec(bytes);
let _cachedValue;
return {
length,
inner: () => _cachedValue = _cachedValue || inner(innerBytes)
};
// src/codecs/scale/Variant.ts
var import_scale_ts10 = require("scale-ts");
var import_utils3 = require("@polkadot-api/utils");
var _Enum = new Proxy(
{},
{
get(_, prop) {
return (value) => Enum(prop, value);
}
}
);
var Enum = (_type, _value) => ({
as: (type) => {
if (type !== _type)
throw new Error(`Enum.as(${type}) used with actual type ${_type}`);
return _value;
},
is: (type) => type === _type,
type: _type,
value: _value
});
var OpaqueEncoder = (inner, len = compactNumber.enc) => (input) => {
const lenBytes = len(input.length);
const result = new Uint8Array(lenBytes.length + input.length);
result.set(lenBytes, 0);
result.set(inner(input.inner()), lenBytes.length);
return result;
var VariantEnc = (...args) => {
const enc3 = import_scale_ts10.Enum.enc(...args);
return (v) => enc3({ tag: v.type, value: v.value });
};
var OpaqueCodec = (inner, len = compactNumber) => (0, import_scale_ts4.createCodec)(
OpaqueEncoder(inner.enc, len.enc),
OpaqueDecoder(inner.dec, len.dec)
var VariantDec = (...args) => {
const dec3 = import_scale_ts10.Enum.dec(...args);
return (v) => {
const { tag, value } = dec3(v);
return Enum(tag, value);
};
};
var Variant = (inner, ...args) => (0, import_scale_ts10.createCodec)(
VariantEnc(
(0, import_utils3.mapObject)(inner, ([encoder]) => encoder),
...args
),
VariantDec(
(0, import_utils3.mapObject)(inner, ([, decoder]) => decoder),
...args
)
);
OpaqueCodec.enc = OpaqueEncoder;
OpaqueCodec.dec = OpaqueDecoder;
Variant.enc = VariantEnc;
Variant.dec = VariantDec;
// src/codecs/metadata/v14/v14.ts
var import_scale_ts8 = require("scale-ts");
// src/codecs/blockHeader.ts
var textEncoder3 = new TextEncoder();
var textDecoder3 = new TextDecoder();
var fourChars = (0, import_scale_ts8.enhanceCodec)(
(0, import_scale_ts8.Bytes)(4),
textEncoder3.encode.bind(textEncoder3),
textDecoder3.decode.bind(textDecoder3)
);
var diggestVal = (0, import_scale_ts8.Struct)({
engine: fourChars,
payload: Hex()
});
var diggest = Variant(
{
consensus: diggestVal,
seal: diggestVal,
preRuntime: diggestVal,
runtimeUpdated: import_scale_ts8._void
},
[4, 5, 6, 8]
);
var hex32 = Hex(32);
var blockHeader = (0, import_scale_ts8.Struct)({
parentHash: hex32,
number: compactNumber,
stateRoot: hex32,
extrinsicRoot: hex32,
digests: (0, import_scale_ts8.Vector)(diggest)
});
// src/codecs/metadata/v14/lookup.ts
var import_scale_ts5 = require("scale-ts");
var oStr = (0, import_scale_ts5.Option)(import_scale_ts5.str);
var strs = (0, import_scale_ts5.Vector)(import_scale_ts5.str);
var primitive = (0, import_scale_ts5.Enum)({
bool: import_scale_ts5._void,
char: import_scale_ts5._void,
str: import_scale_ts5._void,
u8: import_scale_ts5._void,
u16: import_scale_ts5._void,
u32: import_scale_ts5._void,
u64: import_scale_ts5._void,
u128: import_scale_ts5._void,
u256: import_scale_ts5._void,
i8: import_scale_ts5._void,
i16: import_scale_ts5._void,
i32: import_scale_ts5._void,
i64: import_scale_ts5._void,
i128: import_scale_ts5._void,
i256: import_scale_ts5._void
// src/codecs/metadata/v15/v15.ts
var import_scale_ts13 = require("scale-ts");
// src/codecs/metadata/v15/lookup.ts
var import_scale_ts11 = require("scale-ts");
var oStr = (0, import_scale_ts11.Option)(import_scale_ts11.str);
var strs = (0, import_scale_ts11.Vector)(import_scale_ts11.str);
var primitive = (0, import_scale_ts11.Enum)({
bool: import_scale_ts11._void,
char: import_scale_ts11._void,
str: import_scale_ts11._void,
u8: import_scale_ts11._void,
u16: import_scale_ts11._void,
u32: import_scale_ts11._void,
u64: import_scale_ts11._void,
u128: import_scale_ts11._void,
u256: import_scale_ts11._void,
i8: import_scale_ts11._void,
i16: import_scale_ts11._void,
i32: import_scale_ts11._void,
i64: import_scale_ts11._void,
i128: import_scale_ts11._void,
i256: import_scale_ts11._void
});
var fields = (0, import_scale_ts5.Vector)(
(0, import_scale_ts5.Struct)({
var fields = (0, import_scale_ts11.Vector)(
(0, import_scale_ts11.Struct)({
name: oStr,

@@ -218,19 +403,19 @@ type: compactNumber,

);
var arr = (0, import_scale_ts5.Struct)({
len: import_scale_ts5.u32,
var arr = (0, import_scale_ts11.Struct)({
len: import_scale_ts11.u32,
type: compactNumber
});
var bitSequence = (0, import_scale_ts5.Struct)({
var bitSequence2 = (0, import_scale_ts11.Struct)({
bitStoreType: compactNumber,
bitOrderType: compactNumber
});
var variant = (0, import_scale_ts5.Vector)(
(0, import_scale_ts5.Struct)({
name: import_scale_ts5.str,
var variant = (0, import_scale_ts11.Vector)(
(0, import_scale_ts11.Struct)({
name: import_scale_ts11.str,
fields,
index: import_scale_ts5.u8,
index: import_scale_ts11.u8,
docs: strs
})
);
var def = (0, import_scale_ts5.Enum)({
var def = (0, import_scale_ts11.Enum)({
composite: fields,

@@ -240,14 +425,14 @@ variant,

array: arr,
tuple: (0, import_scale_ts5.Vector)(compactNumber),
tuple: (0, import_scale_ts11.Vector)(compactNumber),
primitive,
compact: compactNumber,
bitSequence,
historicMetaCompat: import_scale_ts5.str
bitSequence: bitSequence2,
historicMetaCompat: import_scale_ts11.str
});
var param = (0, import_scale_ts5.Struct)({
name: import_scale_ts5.str,
type: (0, import_scale_ts5.Option)(compactNumber)
var param = (0, import_scale_ts11.Struct)({
name: import_scale_ts11.str,
type: (0, import_scale_ts11.Option)(compactNumber)
});
var params = (0, import_scale_ts5.Vector)(param);
var entry = (0, import_scale_ts5.Struct)({
var params = (0, import_scale_ts11.Vector)(param);
var entry = (0, import_scale_ts11.Struct)({
id: compactNumber,

@@ -259,32 +444,17 @@ path: strs,

});
var lookup = (0, import_scale_ts5.Vector)(entry);
var lookup = (0, import_scale_ts11.Vector)(entry);
// src/codecs/Hex.ts
var import_utils = require("@polkadot-api/utils");
var import_scale_ts6 = require("scale-ts");
var enc = (nBytes) => {
const _enc = import_scale_ts6.Bytes.enc(nBytes);
return (value) => _enc((0, import_utils.fromHex)(value));
};
var dec = (nBytes) => {
const _dec = import_scale_ts6.Bytes.dec(nBytes);
return (value) => (0, import_utils.toHex)(_dec(value));
};
var Hex = (nBytes) => (0, import_scale_ts6.createCodec)(enc(nBytes), dec(nBytes));
Hex.enc = enc;
Hex.dec = dec;
// src/codecs/metadata/v14/pallets.ts
var import_scale_ts7 = require("scale-ts");
var hashType = (0, import_scale_ts7.Enum)({
Blake2128: import_scale_ts7._void,
Blake2256: import_scale_ts7._void,
Blake2128Concat: import_scale_ts7._void,
Twox128: import_scale_ts7._void,
Twox256: import_scale_ts7._void,
Twox64Concat: import_scale_ts7._void,
Identity: import_scale_ts7._void
// src/codecs/metadata/v15/pallets.ts
var import_scale_ts12 = require("scale-ts");
var hashType = (0, import_scale_ts12.Enum)({
Blake2128: import_scale_ts12._void,
Blake2256: import_scale_ts12._void,
Blake2128Concat: import_scale_ts12._void,
Twox128: import_scale_ts12._void,
Twox256: import_scale_ts12._void,
Twox64Concat: import_scale_ts12._void,
Identity: import_scale_ts12._void
});
var hashers = (0, import_scale_ts7.Vector)(hashType);
var storageMap = (0, import_scale_ts7.Struct)({
var hashers = (0, import_scale_ts12.Vector)(hashType);
var storageMap = (0, import_scale_ts12.Struct)({
hashers,

@@ -294,6 +464,6 @@ key: compactNumber,

});
var storageItem = (0, import_scale_ts7.Struct)({
name: import_scale_ts7.str,
modifier: import_scale_ts7.u8,
type: (0, import_scale_ts7.Enum)({
var storageItem = (0, import_scale_ts12.Struct)({
name: import_scale_ts12.str,
modifier: import_scale_ts12.u8,
type: (0, import_scale_ts12.Enum)({
plain: compactNumber,

@@ -303,36 +473,58 @@ map: storageMap

fallback: Hex(),
docs: (0, import_scale_ts7.Vector)(import_scale_ts7.str)
docs: (0, import_scale_ts12.Vector)(import_scale_ts12.str)
});
var storage = (0, import_scale_ts7.Option)(
(0, import_scale_ts7.Struct)({
prefix: import_scale_ts7.str,
items: (0, import_scale_ts7.Vector)(storageItem)
var storage = (0, import_scale_ts12.Option)(
(0, import_scale_ts12.Struct)({
prefix: import_scale_ts12.str,
items: (0, import_scale_ts12.Vector)(storageItem)
})
);
var pallets = (0, import_scale_ts7.Vector)(
(0, import_scale_ts7.Struct)({
name: import_scale_ts7.str,
var pallets = (0, import_scale_ts12.Vector)(
(0, import_scale_ts12.Struct)({
name: import_scale_ts12.str,
storage,
calls: (0, import_scale_ts7.Option)(compactNumber),
events: (0, import_scale_ts7.Option)(compactNumber),
constants: (0, import_scale_ts7.Vector)(
(0, import_scale_ts7.Struct)({
name: import_scale_ts7.str,
calls: (0, import_scale_ts12.Option)(compactNumber),
events: (0, import_scale_ts12.Option)(compactNumber),
constants: (0, import_scale_ts12.Vector)(
(0, import_scale_ts12.Struct)({
name: import_scale_ts12.str,
type: compactNumber,
value: Hex(),
docs: (0, import_scale_ts7.Vector)(import_scale_ts7.str)
docs: (0, import_scale_ts12.Vector)(import_scale_ts12.str)
})
),
errors: (0, import_scale_ts7.Option)(compactNumber),
index: import_scale_ts7.u8
errors: (0, import_scale_ts12.Option)(compactNumber),
index: import_scale_ts12.u8,
docs: (0, import_scale_ts12.Vector)(import_scale_ts12.str)
})
);
// src/codecs/metadata/v14/v14.ts
var extrinsic = (0, import_scale_ts8.Struct)({
type: compactNumber,
version: import_scale_ts8.u8,
signedExtensions: (0, import_scale_ts8.Vector)(
(0, import_scale_ts8.Struct)({
identifier: import_scale_ts8.str,
// src/codecs/metadata/v15/v15.ts
var docs = (0, import_scale_ts13.Vector)(import_scale_ts13.str);
var runtimeApi = (0, import_scale_ts13.Struct)({
name: import_scale_ts13.str,
methods: (0, import_scale_ts13.Vector)(
(0, import_scale_ts13.Struct)({
name: import_scale_ts13.str,
inputs: (0, import_scale_ts13.Vector)(
(0, import_scale_ts13.Struct)({
name: import_scale_ts13.str,
type: compactNumber
})
),
output: compactNumber,
docs
})
),
docs
});
var extrinsic = (0, import_scale_ts13.Struct)({
version: import_scale_ts13.u8,
address: compactNumber,
call: compactNumber,
signature: compactNumber,
extra: compactNumber,
signedExtensions: (0, import_scale_ts13.Vector)(
(0, import_scale_ts13.Struct)({
identifier: import_scale_ts13.str,
type: compactNumber,

@@ -343,21 +535,28 @@ additionalSigned: compactNumber

});
var v14 = (0, import_scale_ts8.Struct)({
var v15 = (0, import_scale_ts13.Struct)({
lookup,
pallets,
extrinsic,
type: compactNumber
type: compactNumber,
apis: (0, import_scale_ts13.Vector)(runtimeApi),
outerEnums: (0, import_scale_ts13.Struct)({
call: compactNumber,
event: compactNumber,
error: compactNumber
}),
custom: (0, import_scale_ts13.Vector)((0, import_scale_ts13.Tuple)(import_scale_ts13.str, (0, import_scale_ts13.Struct)({ type: compactNumber, value: Hex() })))
});
// src/codecs/metadata/metadata.ts
var import_scale_ts9 = require("scale-ts");
var import_scale_ts14 = require("scale-ts");
var unsupportedFn = () => {
throw new Error("Unsupported metadata version!");
};
var unsupported = (0, import_scale_ts9.createCodec)(
var unsupported = (0, import_scale_ts14.createCodec)(
unsupportedFn,
unsupportedFn
);
var metadata = (0, import_scale_ts9.Struct)({
magicNumber: import_scale_ts9.u32,
metadata: (0, import_scale_ts9.Enum)({
var metadata = (0, import_scale_ts14.Struct)({
magicNumber: import_scale_ts14.u32,
metadata: (0, import_scale_ts14.Enum)({
v0: unsupported,

@@ -377,50 +576,9 @@ v1: unsupported,

v13: unsupported,
v14
v14: unsupported,
v15
})
});
// src/codecs/bitSequence.ts
var import_scale_ts10 = require("scale-ts");
var bitSequenceDecoder = (0, import_scale_ts10.createDecoder)((data) => {
const bitsLen = compactNumber.dec(data);
const bytesLen = Math.ceil(bitsLen / 8);
const bytes = (0, import_scale_ts10.Bytes)(bytesLen).dec(data);
return { bytes, bitsLen };
});
var bitSequenceEncoder = (input) => {
if (input.bitsLen > input.bytes.length * 8)
throw new Error(
`Not enough bytes. (bitsLen:${input.bitsLen}, bytesLen:${input.bytes.length})`
);
const lenEncoded = compactNumber.enc(input.bitsLen);
const result = new Uint8Array(input.bytes.length + lenEncoded.length);
result.set(lenEncoded, 0);
result.set(input.bytes, lenEncoded.length);
return result;
};
var bitSequence2 = (0, import_scale_ts10.createCodec)(bitSequenceEncoder, bitSequenceDecoder);
// src/codecs/char.ts
var import_scale_ts11 = require("scale-ts");
var char = (0, import_scale_ts11.enhanceCodec)(
import_scale_ts11.u8,
(str4) => str4.charCodeAt(0),
String.fromCharCode
);
// src/codecs/fixed-str.ts
var import_scale_ts12 = require("scale-ts");
var textEncoder = new TextEncoder();
var textDecoder = new TextDecoder();
var fixedStr = (nBytes) => (0, import_scale_ts12.enhanceCodec)(
(0, import_scale_ts12.Bytes)(nBytes),
(str4) => textEncoder.encode(str4),
(bytes) => textDecoder.decode(bytes)
);
// src/index.ts
__reExport(src_exports, codecs_exports, module.exports);
// src/hashes/blake2.ts
var import_utils2 = require("@polkadot-api/utils");
var import_utils4 = require("@polkadot-api/utils");
var import_blake2b2 = require("@noble/hashes/blake2b");

@@ -431,3 +589,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_utils4.mergeUint8)(Blake2128(encoded), encoded);

@@ -438,4 +596,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_utils5 = require("@polkadot-api/utils");
var import_scale_ts15 = require("scale-ts");

@@ -593,15 +751,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_utils5.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_utils6 = 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_utils6.mergeUint8)(
palledEncoded,
Twox128(textEncoder2.encode(name))
Twox128(textEncoder4.encode(name))
);
const palletItemEncodedHex = (0, import_utils4.toHex)(palletItemEncoded);
const palletItemEncodedHex = (0, import_utils6.toHex)(palletItemEncoded);
const bytesToSkip = encoders.map((e) => e[1]).map((x) => {

@@ -634,10 +792,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_utils6.toHex)(
(0, import_utils6.mergeUint8)(palletItemEncoded, ...args.map((val, idx) => fns[idx](val)))
);
return {
enc: enc2,
dec: dec2,
enc: enc3,
dec: dec3,
keyDecoder

@@ -644,0 +802,0 @@ };

import * as scale_ts from 'scale-ts';
import { Codec, Encoder, Decoder, CodecType } from 'scale-ts';
export * from 'scale-ts';
import { Codec, Encoder, Decoder, StringRecord, CodecType, EncoderType, DecoderType } from 'scale-ts';
export { Bytes, Codec, CodecType, Decoder, DecoderType, Encoder, EncoderType, Option, Result, ResultPayload, StringRecord, Struct, Tuple, Vector, _void, bool, compact, createCodec, createDecoder, enhanceCodec, enhanceDecoder, enhanceEncoder, i128, i16, i256, i32, i64, i8, str, u128, u16, u256, u32, u64, u8 } from 'scale-ts';
import * as scale_ts_dist_types from 'scale-ts/dist/types';

@@ -10,5 +11,40 @@ type SS58String = string & {

type HexString = string & {
__hexString?: unknown;
};
declare const Hex: {
(nBytes?: number): Codec<HexString>;
enc: (nBytes?: number) => Encoder<HexString>;
dec: (nBytes?: number) => Decoder<HexString>;
};
declare class Binary {
#private;
constructor(data: Uint8Array);
asText: () => string;
asHex: () => string;
asBytes: () => Uint8Array;
static fromText(input: string): Binary;
static fromHex(input: HexString): Binary;
static fromBytes(input: Uint8Array): Binary;
}
declare const Bin: {
(nBytes?: number): Codec<Binary>;
enc: (nBytes?: number) => Encoder<Binary>;
dec: (nBytes?: number) => Decoder<Binary>;
};
interface BitSequence {
bitsLen: number;
bytes: Uint8Array;
}
declare const bitSequence: scale_ts.Codec<BitSequence>;
declare const char: scale_ts.Codec<string>;
declare const compactNumber: Codec<number>;
declare const compactBn: Codec<bigint>;
declare const fixedStr: (nBytes: number) => scale_ts.Codec<string>;
declare const selfEncoder: <T>(value: () => Encoder<T>) => Encoder<T>;

@@ -18,12 +54,107 @@ declare const selfDecoder: <T>(value: () => Decoder<T>) => Decoder<T>;

type OpaqueValue<T> = {
length: number;
inner: () => T;
type Tuple<T, N extends number> = readonly [T, ...T[]] & {
length: N;
};
declare const OpaqueCodec: {
<T>(inner: Codec<T>, len?: Codec<number>): Codec<OpaqueValue<T>>;
enc: <T_1>(inner: Encoder<T_1>, len?: Encoder<number>) => Encoder<OpaqueValue<T_1>>;
dec: <T_2>(inner: Decoder<T_2>, len?: Decoder<number>) => Decoder<OpaqueValue<T_2>>;
type Push<T extends any[], V> = [...T, V];
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
type TuplifyUnion<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>;
type RestrictedLenTuple<T, O extends StringRecord<any>> = Tuple<T, TuplifyUnion<keyof O> extends Tuple<any, infer V> ? V : 0>;
type ExtractValue<T extends {
type: string;
value?: any;
}, K extends string> = T extends {
type: K;
value: infer R;
} ? R : never;
interface Discriminant<T extends {
type: string;
value?: any;
}> {
is<K extends T["type"]>(this: Enum<T>, type: K): this is Enum<{
type: K;
value: ExtractValue<T, K>;
}>;
as<K extends T["type"]>(type: K): ExtractValue<T, K>;
}
type MyTuple<T> = [T, ...T[]];
type List<T> = Array<T>;
type SeparateUndefined<T> = undefined extends T ? undefined | Exclude<T, undefined> : T;
type Anonymize<T> = SeparateUndefined<T extends string | number | bigint | boolean | void | undefined | null | symbol | Binary | Enum<{
type: string;
value: any;
}> | Uint8Array ? T : T extends (...args: infer Args) => infer R ? (...args: {
[K in keyof Args]: Anonymize<Args[K]>;
}) => Anonymize<R> : T extends MyTuple<any> ? {
[K in keyof T]: Anonymize<T[K]>;
} : [] extends T ? [] : T extends Array<infer A> ? List<Anonymize<A>> : {
[K in keyof T]: Anonymize<T[K]>;
}>;
declare const _Enum: {};
type EnumOption<T extends {
type: string;
value?: any;
}, Key extends T["type"]> = Anonymize<ExtractValue<T, Key>>;
type GetEnum<T extends Enum<{
type: string;
value: any;
}>> = {
[K in T["type"]]: (...args: ExtractValue<T, K> extends undefined ? [] : [value: Anonymize<ExtractValue<T, K>>]) => T;
};
type Enum<T extends {
type: string;
value?: any;
}> = T & Discriminant<T>;
declare const Enum: <T extends {
type: string;
value?: any;
}, Key extends T["type"]>(type: Key, ...args: ExtractValue<T, Key> extends undefined ? [] : [value: Anonymize<ExtractValue<T, Key>>]) => Enum<ExtractValue<T, Key> extends undefined ? T : ExtractValue<T, Key> extends never ? T : {
type: Key;
value: ExtractValue<T, Key>;
}>;
declare const Variant: {
<O extends StringRecord<Codec<any>>>(inner: O, indexes?: RestrictedLenTuple<number, O> | undefined): Codec<Enum<{ [K in keyof O]: K extends string ? {
type: K;
value: CodecType<O[K]>;
} : never; }[keyof O]>>;
enc: <O_1 extends StringRecord<Encoder<any>>>(inner: O_1, x?: RestrictedLenTuple<number, O_1> | undefined) => Encoder<Enum<{ [K_1 in keyof O_1]: K_1 extends string ? {
type: K_1;
value: EncoderType<O_1[K_1]>;
} : never; }[keyof O_1]>>;
dec: <O_2 extends StringRecord<Decoder<any>>>(inner: O_2, x?: RestrictedLenTuple<number, O_2> | undefined) => Decoder<Enum<{ [K_2 in keyof O_2]: K_2 extends string ? {
type: K_2;
value: DecoderType<O_2[K_2]>;
} : never; }[keyof O_2]>>;
};
declare const blockHeader: scale_ts_dist_types.Codec<{
parentHash: HexString;
number: number;
stateRoot: HexString;
extrinsicRoot: HexString;
digests: Enum<{
type: "consensus";
value: {
engine: string;
payload: HexString;
};
} | {
type: "seal";
value: {
engine: string;
payload: HexString;
};
} | {
type: "preRuntime";
value: {
engine: string;
payload: HexString;
};
} | {
type: "runtimeUpdated";
value: undefined;
}>[];
}>;
type BlockHeader = CodecType<typeof blockHeader>;
declare const lookup: scale_ts.Codec<{

@@ -34,3 +165,3 @@ id: number;

name: string;
type: number | void | undefined;
type: number | undefined;
}[];

@@ -40,5 +171,5 @@ def: {

value: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -51,5 +182,5 @@ }[];

fields: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -137,70 +268,8 @@ }[];

type HexString = string & {
__hexString?: unknown;
};
declare const Hex: {
(nBytes?: number): Codec<HexString>;
enc: (nBytes?: number) => Encoder<HexString>;
dec: (nBytes?: number) => Decoder<HexString>;
};
declare const pallets: scale_ts.Codec<{
name: string;
storage: void | {
prefix: string;
items: {
name: string;
modifier: number;
type: {
tag: "map";
value: {
hashers: ({
tag: "Blake2128";
value: undefined;
} | {
tag: "Blake2256";
value: undefined;
} | {
tag: "Blake2128Concat";
value: undefined;
} | {
tag: "Twox128";
value: undefined;
} | {
tag: "Twox256";
value: undefined;
} | {
tag: "Twox64Concat";
value: undefined;
} | {
tag: "Identity";
value: undefined;
})[];
key: number;
value: number;
};
} | {
tag: "plain";
value: number;
};
fallback: HexString;
docs: string[];
}[];
} | undefined;
calls: number | void | undefined;
events: number | void | undefined;
constants: {
name: string;
type: number;
value: HexString;
docs: string[];
}[];
errors: number | void | undefined;
index: number;
}[]>;
type V14Pallets = CodecType<typeof pallets>;
declare const extrinsic: scale_ts.Codec<{
type: number;
version: number;
address: number;
call: number;
signature: number;
extra: number;
signedExtensions: {

@@ -212,4 +281,4 @@ identifier: string;

}>;
type V14Extrinsic = CodecType<typeof extrinsic>;
declare const v14: scale_ts.Codec<{
type V15Extrinsic = CodecType<typeof extrinsic>;
declare const v15: scale_ts.Codec<{
lookup: {

@@ -220,3 +289,3 @@ id: number;

name: string;
type: number | void | undefined;
type: number | undefined;
}[];

@@ -226,5 +295,5 @@ def: {

value: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -237,5 +306,5 @@ }[];

fields: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -323,3 +392,3 @@ }[];

name: string;
storage: void | {
storage: {
prefix: string;

@@ -365,4 +434,4 @@ items: {

} | undefined;
calls: number | void | undefined;
events: number | void | undefined;
calls: number | undefined;
events: number | undefined;
constants: {

@@ -374,8 +443,12 @@ name: string;

}[];
errors: number | void | undefined;
errors: number | undefined;
index: number;
docs: string[];
}[];
extrinsic: {
type: number;
version: number;
address: number;
call: number;
signature: number;
extra: number;
signedExtensions: {

@@ -388,4 +461,26 @@ identifier: string;

type: number;
apis: {
name: string;
methods: {
name: string;
inputs: {
name: string;
type: number;
}[];
output: number;
docs: string[];
}[];
docs: string[];
}[];
outerEnums: {
call: number;
event: number;
error: number;
};
custom: [string, {
type: number;
value: HexString;
}][];
}>;
type V14 = CodecType<typeof v14>;
type V15 = CodecType<typeof v15>;

@@ -438,2 +533,5 @@ declare const metadata: Codec<{

tag: "v14";
value: unknown;
} | {
tag: "v15";
value: {

@@ -445,3 +543,3 @@ lookup: {

name: string;
type: number | void | undefined;
type: number | undefined;
}[];

@@ -451,5 +549,5 @@ def: {

value: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -462,5 +560,5 @@ }[];

fields: {
name: string | void | undefined;
name: string | undefined;
type: number;
typeName: string | void | undefined;
typeName: string | undefined;
docs: string[];

@@ -548,3 +646,3 @@ }[];

name: string;
storage: void | {
storage: {
prefix: string;

@@ -590,4 +688,4 @@ items: {

} | undefined;
calls: number | void | undefined;
events: number | void | undefined;
calls: number | undefined;
events: number | undefined;
constants: {

@@ -599,8 +697,12 @@ name: string;

}[];
errors: number | void | undefined;
errors: number | undefined;
index: number;
docs: string[];
}[];
extrinsic: {
type: number;
version: number;
address: number;
call: number;
signature: number;
extra: number;
signedExtensions: {

@@ -613,2 +715,24 @@ identifier: string;

type: number;
apis: {
name: string;
methods: {
name: string;
inputs: {
name: string;
type: number;
}[];
output: number;
docs: string[];
}[];
docs: string[];
}[];
outerEnums: {
call: number;
event: number;
error: number;
};
custom: [string, {
type: number;
value: HexString;
}][];
};

@@ -618,12 +742,2 @@ };

interface BitSequence {
bitsLen: number;
bytes: Uint8Array;
}
declare const bitSequence: scale_ts.Codec<BitSequence>;
declare const char: scale_ts.Codec<string>;
declare const fixedStr: (nBytes: number) => scale_ts.Codec<string>;
declare const Blake2256: (encoded: Uint8Array) => Uint8Array;

@@ -656,18 +770,21 @@ declare const Blake2128: (encoded: Uint8Array) => Uint8Array;

};
type TxDescriptor<Args extends Array<any>> = string & {
_args: Args;
type TxDescriptor<Args extends {} | undefined> = string & {
___: 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> = {
type RuntimeDescriptor<Args extends Array<any>, T> = string & {
__: [Args, T];
};
type Descriptors = {
pallets: Record<string, [
Record<string, StorageDescriptor<any, any, any>>,
Record<string, TxDescriptor<any>>,
Record<string, PlainDescriptor<any>>,
Record<string, PlainDescriptor<any>>,
Record<string, PlainDescriptor<any>>
]>;
apis: Record<string, Record<string, RuntimeDescriptor<any, any>>>;
};
type PickDescriptors<Idx extends 0 | 1 | 2 | 3 | 4, T extends Descriptors["pallets"]> = {
[K in keyof T]: T[K][Idx];
};
type Anonymize<T> = T extends string | number | bigint | boolean | void | undefined | null | symbol ? 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>>>> = {

@@ -678,3 +795,3 @@ [K in keyof T]: {

Value: Anonymize<Value>;
IsOptional: Optional extends 1 ? false : true;
IsOptional: Optional;
} : unknown;

@@ -693,8 +810,8 @@ };

};
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>>;
type QueryFromDescriptors<T extends Descriptors> = ExtractStorage<PickDescriptors<0, T["pallets"]>>;
type TxFromDescriptors<T extends Descriptors> = ExtractTx<PickDescriptors<1, T["pallets"]>>;
type EventsFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<2, T["pallets"]>>;
type ErrorsFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<3, T["pallets"]>>;
type ConstFromDescriptors<T extends Descriptors> = ExtractPlain<PickDescriptors<4, T["pallets"]>>;
export { AccountId, BitSequence, Blake2128, Blake2128Concat, Blake2256, ConstFromDescriptors, Descriptors, EncoderWithHash, ErrorsFromDescriptors, EventsFromDescriptors, Hex, HexString, Identity, OpaqueCodec, OpaqueValue, PlainDescriptor, QueryFromDescriptors, SS58String, Self, Storage, StorageDescriptor, Twox128, Twox256, Twox64Concat, TxDescriptor, TxFromDescriptors, V14, V14Extrinsic, V14Lookup, V14Pallets, bitSequence, char, compactBn, compactNumber, fixedStr, h64, metadata, selfDecoder, selfEncoder, v14 };
export { AccountId, type Anonymize, Bin, Binary, type BitSequence, Blake2128, Blake2128Concat, Blake2256, type BlockHeader, type ConstFromDescriptors, type Descriptors, type Discriminant, type EncoderWithHash, Enum, type EnumOption, type ErrorsFromDescriptors, type EventsFromDescriptors, type GetEnum, Hex, type HexString, Identity, type PlainDescriptor, type QueryFromDescriptors, type RuntimeDescriptor, type SS58String, Self, Storage, type StorageDescriptor, Twox128, Twox256, Twox64Concat, type TxDescriptor, type TxFromDescriptors, type V14Lookup, type V15, type V15Extrinsic, Variant, _Enum, bitSequence, blockHeader, char, compactBn, compactNumber, fixedStr, h64, metadata, selfDecoder, selfEncoder, v15 };

@@ -1,2 +0,2 @@

"use strict";var j=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var se=(e,t)=>{for(var r in t)j(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of He(t))!Ie.call(e,a)&&a!==r&&j(e,a,{get:()=>t[a],enumerable:!(i=_e(t,a))||i.enumerable});return e},l=(e,t,r)=>(X(e,t,"default"),r&&X(r,t,"default"));var Le=e=>X(j({},"__esModule",{value:!0}),e);var h={};se(h,{AccountId:()=>ae,Blake2128:()=>Ue,Blake2128Concat:()=>re,Blake2256:()=>nt,Hex:()=>D,Identity:()=>oe,OpaqueCodec:()=>M,Self:()=>le,Storage:()=>it,Twox128:()=>G,Twox256:()=>st,Twox64Concat:()=>ce,bitSequence:()=>Ee,char:()=>Ae,compactBn:()=>de,compactNumber:()=>d,fixedStr:()=>Ce,h64:()=>v,metadata:()=>we,selfDecoder:()=>ee,selfEncoder:()=>F,v14:()=>W});module.exports=Le(h);l(h,require("scale-ts"),module.exports);var f={};se(f,{AccountId:()=>ae,Hex:()=>D,OpaqueCodec:()=>M,Self:()=>le,bitSequence:()=>Ee,char:()=>Ae,compactBn:()=>de,compactNumber:()=>d,fixedStr:()=>Ce,metadata:()=>we,selfDecoder:()=>ee,selfEncoder:()=>F,v14:()=>W});l(f,require("scale-ts"));var O=require("scale-ts"),Q=require("@noble/hashes/blake2b"),Y=require("@scure/base"),ie=new TextEncoder().encode("SS58PRE"),J=2,qe=e=>{let t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return r=>{let i=(0,Q.blake2b)(Uint8Array.of(...ie,...t,...r),{dkLen:64}).subarray(0,J);return Y.base58.encode(Uint8Array.of(...t,...r,...i))}};function Ke(e,t){return r=>{let i=Y.base58.decode(r),a=i.subarray(0,i[0]&64?2:1),b=i.subarray(a.length,i.length-J);if(b.length!==e)throw new Error("Invalid public key length");let A=i.subarray(a.length+b.length),T=(0,Q.blake2b)(Uint8Array.of(...ie,...a,...b),{dkLen:64}).subarray(0,J);if(A[0]!==T[0]||A[1]!==T[1])throw new Error("Invalid checksum");if(Ne(a)!=t)throw new Error("Invalid SS58 prefix");return b.slice()}}var ae=(e=42,t=32)=>(0,O.enhanceCodec)((0,O.Bytes)(t),Ke(t,e),qe(e)),Ne=e=>{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)};var Z=require("scale-ts"),d=Z.compact,de=Z.compact;var me=require("scale-ts"),F=e=>{let t=r=>{let i=e();return t=i,i(r)};return r=>t(r)},ee=e=>{let t=r=>{let i=e(),a=i;return t=i,a(r)};return r=>t(r)},le=e=>(0,me.createCodec)(F(()=>e().enc),ee(()=>e().dec));var H=require("scale-ts");var fe=(e,t=d.dec)=>(0,H.createDecoder)(r=>{let i=t(r),a=(0,H.Bytes)(i).dec(r),b;return{length:i,inner:()=>b=b||e(a)}}),pe=(e,t=d.enc)=>r=>{let i=t(r.length),a=new Uint8Array(i.length+r.length);return a.set(i,0),a.set(e(r.inner()),i.length),a},M=(e,t=d)=>(0,H.createCodec)(pe(e.enc,t.enc),fe(e.dec,t.dec));M.enc=pe;M.dec=fe;var k=require("scale-ts");var n=require("scale-ts"),ye=(0,n.Option)(n.str),P=(0,n.Vector)(n.str),Oe=(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}),ue=(0,n.Vector)((0,n.Struct)({name:ye,type:d,typeName:ye,docs:P})),Me=(0,n.Struct)({len:n.u32,type:d}),Pe=(0,n.Struct)({bitStoreType:d,bitOrderType:d}),Re=(0,n.Vector)((0,n.Struct)({name:n.str,fields:ue,index:n.u8,docs:P})),We=(0,n.Enum)({composite:ue,variant:Re,sequence:d,array:Me,tuple:(0,n.Vector)(d),primitive:Oe,compact:d,bitSequence:Pe,historicMetaCompat:n.str}),$e=(0,n.Struct)({name:n.str,type:(0,n.Option)(d)}),ze=(0,n.Vector)($e),Ge=(0,n.Struct)({id:d,path:P,params:ze,def:We,docs:P}),xe=(0,n.Vector)(Ge);var R=require("@polkadot-api/utils"),K=require("scale-ts"),be=e=>{let t=K.Bytes.enc(e);return r=>t((0,R.fromHex)(r))},ge=e=>{let t=K.Bytes.dec(e);return r=>(0,R.toHex)(t(r))},D=e=>(0,K.createCodec)(be(e),ge(e));D.enc=be;D.dec=ge;var s=require("scale-ts"),Xe=(0,s.Enum)({Blake2128:s._void,Blake2256:s._void,Blake2128Concat:s._void,Twox128:s._void,Twox256:s._void,Twox64Concat:s._void,Identity:s._void}),je=(0,s.Vector)(Xe),Je=(0,s.Struct)({hashers:je,key:d,value:d}),Qe=(0,s.Struct)({name:s.str,modifier:s.u8,type:(0,s.Enum)({plain:d,map:Je}),fallback:D(),docs:(0,s.Vector)(s.str)}),Ye=(0,s.Option)((0,s.Struct)({prefix:s.str,items:(0,s.Vector)(Qe)})),he=(0,s.Vector)((0,s.Struct)({name:s.str,storage:Ye,calls:(0,s.Option)(d),events:(0,s.Option)(d),constants:(0,s.Vector)((0,s.Struct)({name:s.str,type:d,value:D(),docs:(0,s.Vector)(s.str)})),errors:(0,s.Option)(d),index:s.u8}));var Ze=(0,k.Struct)({type:d,version:k.u8,signedExtensions:(0,k.Vector)((0,k.Struct)({identifier:k.str,type:d,additionalSigned:d}))}),W=(0,k.Struct)({lookup:xe,pallets:he,extrinsic:Ze,type:d});var B=require("scale-ts");var Te=()=>{throw new Error("Unsupported metadata version!")},E=(0,B.createCodec)(Te,Te),we=(0,B.Struct)({magicNumber:B.u32,metadata:(0,B.Enum)({v0:E,v1:E,v2:E,v3:E,v4:E,v5:E,v6:E,v7:E,v8:E,v9:E,v10:E,v11:E,v12:E,v13:E,v14:W})});var I=require("scale-ts");var Fe=(0,I.createDecoder)(e=>{let t=d.dec(e),r=Math.ceil(t/8);return{bytes:(0,I.Bytes)(r).dec(e),bitsLen:t}}),et=e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);let t=d.enc(e.bitsLen),r=new Uint8Array(e.bytes.length+t.length);return r.set(t,0),r.set(e.bytes,t.length),r},Ee=(0,I.createCodec)(et,Fe);var $=require("scale-ts"),Ae=(0,$.enhanceCodec)($.u8,e=>e.charCodeAt(0),String.fromCharCode);var z=require("scale-ts"),tt=new TextEncoder,rt=new TextDecoder,Ce=e=>(0,z.enhanceCodec)((0,z.Bytes)(e),t=>tt.encode(t),t=>rt.decode(t));l(h,f,module.exports);var Se=require("@polkadot-api/utils"),te=require("@noble/hashes/blake2b"),ot={dkLen:32},nt=e=>(0,te.blake2b)(e,ot),ct={dkLen:16},Ue=e=>(0,te.blake2b)(e,ct),re=e=>(0,Se.mergeUint8)(Ue(e),e);var oe=e=>e;var Be=require("@polkadot-api/utils"),De=require("scale-ts");var V=(e,t,r,i)=>new DataView(new Uint16Array([e,t,r,i]).buffer).getBigUint64(0,!0),ne=2n**64n-1n,g=(e,t)=>e<<t&ne|e>>64n-t,m=(e,t)=>e*t&ne,u=(e,t)=>e+t&ne,x=11400714785074694791n,C=14029467366897019727n,ke=1609587929392839161n,N=9650029242287828579n,ve=2870177450012600261n;function v(e,t=0n){let r=u(u(t,x),C),i=u(t,C),a=t,b=t-x,A=e.length,T=0,_=null;(function(){let o=0,S=o+A;if(A){if(_=new Uint8Array(32),A<32){_.set(e.subarray(0,A),T),T+=A;return}if(o<=S-32){let q=S-32;do{let U;U=V(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(u(r,m(U,C)),31n),x),o+=8,U=V(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(u(i,m(U,C)),31n),x),o+=8,U=V(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=m(g(u(a,m(U,C)),31n),x),o+=8,U=V(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(u(b,m(U,C)),31n),x),o+=8}while(o<=q)}o<S&&(_.set(e.subarray(o,S),T),T=S-o)}})(),e=_||e;let c,p=0;for(A>=32?(c=g(r,1n),c=u(c,g(i,7n)),c=u(c,g(a,12n)),c=u(c,g(b,18n)),r=m(g(m(r,C),31n),x),c=c^r,c=u(m(c,x),N),i=m(g(m(i,C),31n),x),c=c^i,c=u(m(c,x),N),a=m(g(m(a,C),31n),x),c=c^a,c=u(m(c,x),N),b=m(g(m(b,C),31n),x),c=c^b,c=u(m(c,x),N)):c=u(t,ve),c=u(c,BigInt(A));p<=T-8;){let w=V(e[p+1]<<8|e[p],e[p+3]<<8|e[p+2],e[p+5]<<8|e[p+4],e[p+7]<<8|e[p+6]);w=m(g(m(w,C),31n),x),c=u(m(g(c^w,27n),x),N),p+=8}if(p+4<=T){let w=m(V(e[p+1]<<8|e[p],e[p+3]<<8|e[p+2],0,0),x);c=u(m(g(c^w,23n),C),ke),p+=4}for(;p<T;){let w=m(V(e[p++],0,0,0),ve);c=m(g(c^w,11n),x)}let y=c>>33n;return c=m(c^y,C),y=c>>29n,c=m(c^y,ke),y=c>>32n,c^=y,c}var G=e=>{let t=new Uint8Array(16),r=new DataView(t.buffer);return r.setBigUint64(0,v(e),!0),r.setBigUint64(8,v(e,1n),!0),t},st=e=>{let t=new Uint8Array(32),r=new DataView(t.buffer);return r.setBigUint64(0,v(e),!0),r.setBigUint64(8,v(e,1n),!0),r.setBigUint64(16,v(e,2n),!0),r.setBigUint64(24,v(e,3n),!0),t},ce=e=>(0,Be.mergeUint8)(De.u64.enc(v(e)),e);var L=require("@polkadot-api/utils");var Ve=new TextEncoder,it=e=>{let t=G(Ve.encode(e));return(r,i,...a)=>{let b=(0,L.mergeUint8)(t,G(Ve.encode(r))),A=(0,L.toHex)(b),T=a.map(y=>y[1]).map(y=>y===oe?0:y===ce?8:y===re?16:null).filter(Boolean),_=y=>{if(!y.startsWith(A))throw new Error(`key does not match this storage (${e}.${r})`);if(T.length!==a.length)throw new Error("Impossible to decode this key");if(a.length===0)return[];let w=y.slice(A.length),o=new Array(a.length);for(let S=0,q=0;S<T.length;S++){let U=a[S][0];q+=T[S],o[S]=U.dec(w.slice(q*2)),q+=U.enc(o[S]).length}return o},c=a.map(([{enc:y},w])=>o=>w(y(o)));return{enc:(...y)=>(0,L.toHex)((0,L.mergeUint8)(b,...y.map((w,o)=>c[o](w)))),dec:i,keyDecoder:_}}};
"use strict";var W=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Ge=(e,t,n)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var je=(e,t)=>{for(var n in t)W(e,n,{get:t[n],enumerable:!0})},Xe=(e,t,n,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of We(t))!$e.call(e,m)&&m!==n&&W(e,m,{get:()=>t[m],enumerable:!(d=qe(t,m))||d.enumerable});return e};var Je=e=>Xe(W({},"__esModule",{value:!0}),e);var $=(e,t,n)=>(Ge(e,typeof t!="symbol"?t+"":t,n),n),Te=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var C=(e,t,n)=>(Te(e,t,"read from private field"),n?n.call(e):t.get(e)),G=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},j=(e,t,n,d)=>(Te(e,t,"write to private field"),d?d.call(e,n):t.set(e,n),n);var Lt={};je(Lt,{AccountId:()=>Ze,Bin:()=>ce,Binary:()=>J,Blake2128:()=>_e,Blake2128Concat:()=>pe,Blake2256:()=>Dt,Bytes:()=>r.Bytes,Enum:()=>ae,Hex:()=>S,Identity:()=>le,Option:()=>r.Option,Result:()=>r.Result,Self:()=>yt,Storage:()=>Rt,Struct:()=>r.Struct,Tuple:()=>r.Tuple,Twox128:()=>te,Twox256:()=>Ht,Twox64Concat:()=>fe,Variant:()=>z,Vector:()=>r.Vector,_Enum:()=>mt,_void:()=>r._void,bitSequence:()=>ct,blockHeader:()=>lt,bool:()=>r.bool,char:()=>st,compact:()=>r.compact,compactBn:()=>nt,compactNumber:()=>a,createCodec:()=>r.createCodec,createDecoder:()=>r.createDecoder,enhanceCodec:()=>r.enhanceCodec,enhanceDecoder:()=>r.enhanceDecoder,enhanceEncoder:()=>r.enhanceEncoder,fixedStr:()=>dt,h64:()=>K,i128:()=>r.i128,i16:()=>r.i16,i256:()=>r.i256,i32:()=>r.i32,i64:()=>r.i64,i8:()=>r.i8,metadata:()=>Bt,selfDecoder:()=>we,selfEncoder:()=>ke,str:()=>r.str,u128:()=>r.u128,u16:()=>r.u16,u256:()=>r.u256,u32:()=>r.u32,u64:()=>r.u64,u8:()=>r.u8,v15:()=>me});module.exports=Je(Lt);var X=require("scale-ts"),re=require("@noble/hashes/blake2b"),oe=require("@scure/base"),ge=new TextEncoder().encode("SS58PRE"),ne=2,Qe=e=>{let t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{let d=(0,re.blake2b)(Uint8Array.of(...ge,...t,...n),{dkLen:64}).subarray(0,ne);return oe.base58.encode(Uint8Array.of(...t,...n,...d))}};function Ye(e,t){return n=>{let d=oe.base58.decode(n),m=d.subarray(0,d[0]&64?2:1),b=d.subarray(m.length,d.length-ne);if(b.length!==e)throw new Error("Invalid public key length");let v=d.subarray(m.length+b.length),h=(0,re.blake2b)(Uint8Array.of(...ge,...m,...b),{dkLen:64}).subarray(0,ne);if(v[0]!==h[0]||v[1]!==h[1])throw new Error("Invalid checksum");if(Fe(m)!=t)throw new Error("Invalid SS58 prefix");return b.slice()}}var Ze=(e=42,t=32)=>(0,X.enhanceCodec)((0,X.Bytes)(t),Ye(t,e),Qe(e)),Fe=e=>{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)};var N=require("scale-ts"),Q=require("@polkadot-api/utils");var et=new TextEncoder,tt=new TextDecoder,B,O,H,I=class I{constructor(t){G(this,B,void 0);G(this,O,null);G(this,H,null);$(this,"asText",()=>C(this,H)===null?j(this,H,tt.decode(C(this,B))):C(this,H));$(this,"asHex",()=>C(this,O)===null?j(this,O,(0,Q.toHex)(C(this,B))):C(this,O));$(this,"asBytes",()=>C(this,B));j(this,B,t)}static fromText(t){return new I(et.encode(t))}static fromHex(t){return new I((0,Q.fromHex)(t))}static fromBytes(t){return new I(t)}};B=new WeakMap,O=new WeakMap,H=new WeakMap;var J=I,be=e=>{let t=N.Bytes.enc(e);return n=>t(n.asBytes())},he=e=>{let t=N.Bytes.dec(e);return n=>J.fromBytes(t(n))},ce=e=>(0,N.createCodec)(be(e),he(e));ce.enc=be;ce.dec=he;var R=require("scale-ts");var se=require("scale-ts"),a=se.compact,nt=se.compact;var rt=(0,R.createDecoder)(e=>{let t=a.dec(e),n=Math.ceil(t/8);return{bytes:(0,R.Bytes)(n).dec(e),bitsLen:t}}),ot=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),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ct=(0,R.createCodec)(ot,rt);var Y=require("scale-ts"),st=(0,Y.enhanceCodec)(Y.u8,e=>e.charCodeAt(0),String.fromCharCode);var Z=require("@polkadot-api/utils"),M=require("scale-ts"),Ee=e=>{let t=M.Bytes.enc(e);return n=>t((0,Z.fromHex)(n))},ve=e=>{let t=M.Bytes.dec(e);return n=>(0,Z.toHex)(t(n))},S=e=>(0,M.createCodec)(Ee(e),ve(e));S.enc=Ee;S.dec=ve;var F=require("scale-ts"),it=new TextEncoder,at=new TextDecoder,dt=e=>(0,F.enhanceCodec)((0,F.Bytes)(e),t=>it.encode(t),t=>at.decode(t));var r=require("scale-ts");var Ae=require("scale-ts"),ke=e=>{let t=n=>{let d=e();return t=d,d(n)};return n=>t(n)},we=e=>{let t=n=>{let d=e(),m=d;return t=d,m(n)};return n=>t(n)},yt=e=>(0,Ae.createCodec)(ke(()=>e().enc),we(()=>e().dec));var P=require("scale-ts"),ie=require("@polkadot-api/utils"),mt=new Proxy({},{get(e,t){return n=>ae(t,n)}}),ae=(e,t)=>({as:n=>{if(n!==e)throw new Error(`Enum.as(${n}) used with actual type ${e}`);return t},is:n=>n===e,type:e,value:t}),Se=(...e)=>{let t=P.Enum.enc(...e);return n=>t({tag:n.type,value:n.value})},Ke=(...e)=>{let t=P.Enum.dec(...e);return n=>{let{tag:d,value:m}=t(n);return ae(d,m)}},z=(e,...t)=>(0,P.createCodec)(Se((0,ie.mapObject)(e,([n])=>n),...t),Ke((0,ie.mapObject)(e,([,n])=>n),...t));z.enc=Se;z.dec=Ke;var Ce=new TextEncoder,Ue=new TextDecoder,ut=(0,r.enhanceCodec)((0,r.Bytes)(4),Ce.encode.bind(Ce),Ue.decode.bind(Ue)),de=(0,r.Struct)({engine:ut,payload:S()}),pt=z({consensus:de,seal:de,preRuntime:de,runtimeUpdated:r._void},[4,5,6,8]),ye=S(32),lt=(0,r.Struct)({parentHash:ye,number:a,stateRoot:ye,extrinsicRoot:ye,digests:(0,r.Vector)(pt)});var u=require("scale-ts");var c=require("scale-ts"),Be=(0,c.Option)(c.str),ee=(0,c.Vector)(c.str),xt=(0,c.Enum)({bool:c._void,char:c._void,str:c._void,u8:c._void,u16:c._void,u32:c._void,u64:c._void,u128:c._void,u256:c._void,i8:c._void,i16:c._void,i32:c._void,i64:c._void,i128:c._void,i256:c._void}),Ve=(0,c.Vector)((0,c.Struct)({name:Be,type:a,typeName:Be,docs:ee})),ft=(0,c.Struct)({len:c.u32,type:a}),Tt=(0,c.Struct)({bitStoreType:a,bitOrderType:a}),gt=(0,c.Vector)((0,c.Struct)({name:c.str,fields:Ve,index:c.u8,docs:ee})),bt=(0,c.Enum)({composite:Ve,variant:gt,sequence:a,array:ft,tuple:(0,c.Vector)(a),primitive:xt,compact:a,bitSequence:Tt,historicMetaCompat:c.str}),ht=(0,c.Struct)({name:c.str,type:(0,c.Option)(a)}),Et=(0,c.Vector)(ht),vt=(0,c.Struct)({id:a,path:ee,params:Et,def:bt,docs:ee}),De=(0,c.Vector)(vt);var i=require("scale-ts"),At=(0,i.Enum)({Blake2128:i._void,Blake2256:i._void,Blake2128Concat:i._void,Twox128:i._void,Twox256:i._void,Twox64Concat:i._void,Identity:i._void}),kt=(0,i.Vector)(At),wt=(0,i.Struct)({hashers:kt,key:a,value:a}),St=(0,i.Struct)({name:i.str,modifier:i.u8,type:(0,i.Enum)({plain:a,map:wt}),fallback:S(),docs:(0,i.Vector)(i.str)}),Kt=(0,i.Option)((0,i.Struct)({prefix:i.str,items:(0,i.Vector)(St)})),Oe=(0,i.Vector)((0,i.Struct)({name:i.str,storage:Kt,calls:(0,i.Option)(a),events:(0,i.Option)(a),constants:(0,i.Vector)((0,i.Struct)({name:i.str,type:a,value:S(),docs:(0,i.Vector)(i.str)})),errors:(0,i.Option)(a),index:i.u8,docs:(0,i.Vector)(i.str)}));var He=(0,u.Vector)(u.str),Ct=(0,u.Struct)({name:u.str,methods:(0,u.Vector)((0,u.Struct)({name:u.str,inputs:(0,u.Vector)((0,u.Struct)({name:u.str,type:a})),output:a,docs:He})),docs:He}),Ut=(0,u.Struct)({version:u.u8,address:a,call:a,signature:a,extra:a,signedExtensions:(0,u.Vector)((0,u.Struct)({identifier:u.str,type:a,additionalSigned:a}))}),me=(0,u.Struct)({lookup:De,pallets:Oe,extrinsic:Ut,type:a,apis:(0,u.Vector)(Ct),outerEnums:(0,u.Struct)({call:a,event:a,error:a}),custom:(0,u.Vector)((0,u.Tuple)(u.str,(0,u.Struct)({type:a,value:S()})))});var U=require("scale-ts");var Re=()=>{throw new Error("Unsupported metadata version!")},g=(0,U.createCodec)(Re,Re),Bt=(0,U.Struct)({magicNumber:U.u32,metadata:(0,U.Enum)({v0:g,v1:g,v2:g,v3:g,v4:g,v5:g,v6:g,v7:g,v8:g,v9:g,v10:g,v11:g,v12:g,v13:g,v14:g,v15:me})});var Le=require("@polkadot-api/utils"),ue=require("@noble/hashes/blake2b"),Vt={dkLen:32},Dt=e=>(0,ue.blake2b)(e,Vt),Ot={dkLen:16},_e=e=>(0,ue.blake2b)(e,Ot),pe=e=>(0,Le.mergeUint8)(_e(e),e);var le=e=>e;var Me=require("@polkadot-api/utils"),Pe=require("scale-ts");var V=(e,t,n,d)=>new DataView(new Uint16Array([e,t,n,d]).buffer).getBigUint64(0,!0),xe=2n**64n-1n,T=(e,t)=>e<<t&xe|e>>64n-t,y=(e,t)=>e*t&xe,x=(e,t)=>e+t&xe,f=11400714785074694791n,A=14029467366897019727n,Ie=1609587929392839161n,q=9650029242287828579n,Ne=2870177450012600261n;function K(e,t=0n){let n=x(x(t,f),A),d=x(t,A),m=t,b=t-f,v=e.length,h=0,D=null;(function(){let o=0,k=o+v;if(v){if(D=new Uint8Array(32),v<32){D.set(e.subarray(0,v),h),h+=v;return}if(o<=k-32){let _=k-32;do{let w;w=V(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]),n=y(T(x(n,y(w,A)),31n),f),o+=8,w=V(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=y(T(x(d,y(w,A)),31n),f),o+=8,w=V(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]),m=y(T(x(m,y(w,A)),31n),f),o+=8,w=V(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=y(T(x(b,y(w,A)),31n),f),o+=8}while(o<=_)}o<k&&(D.set(e.subarray(o,k),h),h=k-o)}})(),e=D||e;let s,p=0;for(v>=32?(s=T(n,1n),s=x(s,T(d,7n)),s=x(s,T(m,12n)),s=x(s,T(b,18n)),n=y(T(y(n,A),31n),f),s=s^n,s=x(y(s,f),q),d=y(T(y(d,A),31n),f),s=s^d,s=x(y(s,f),q),m=y(T(y(m,A),31n),f),s=s^m,s=x(y(s,f),q),b=y(T(y(b,A),31n),f),s=s^b,s=x(y(s,f),q)):s=x(t,Ne),s=x(s,BigInt(v));p<=h-8;){let E=V(e[p+1]<<8|e[p],e[p+3]<<8|e[p+2],e[p+5]<<8|e[p+4],e[p+7]<<8|e[p+6]);E=y(T(y(E,A),31n),f),s=x(y(T(s^E,27n),f),q),p+=8}if(p+4<=h){let E=y(V(e[p+1]<<8|e[p],e[p+3]<<8|e[p+2],0,0),f);s=x(y(T(s^E,23n),A),Ie),p+=4}for(;p<h;){let E=y(V(e[p++],0,0,0),Ne);s=y(T(s^E,11n),f)}let l=s>>33n;return s=y(s^l,A),l=s>>29n,s=y(s^l,Ie),l=s>>32n,s^=l,s}var te=e=>{let t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,K(e),!0),n.setBigUint64(8,K(e,1n),!0),t},Ht=e=>{let t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,K(e),!0),n.setBigUint64(8,K(e,1n),!0),n.setBigUint64(16,K(e,2n),!0),n.setBigUint64(24,K(e,3n),!0),t},fe=e=>(0,Me.mergeUint8)(Pe.u64.enc(K(e)),e);var L=require("@polkadot-api/utils");var ze=new TextEncoder,Rt=e=>{let t=te(ze.encode(e));return(n,d,...m)=>{let b=(0,L.mergeUint8)(t,te(ze.encode(n))),v=(0,L.toHex)(b),h=m.map(l=>l[1]).map(l=>l===le?0:l===fe?8:l===pe?16:null).filter(Boolean),D=l=>{if(!l.startsWith(v))throw new Error(`key does not match this storage (${e}.${n})`);if(h.length!==m.length)throw new Error("Impossible to decode this key");if(m.length===0)return[];let E=l.slice(v.length),o=new Array(m.length);for(let k=0,_=0;k<h.length;k++){let w=m[k][0];_+=h[k],o[k]=w.dec(E.slice(_*2)),_+=w.enc(o[k]).length}return o},s=m.map(([{enc:l},E])=>o=>E(l(o)));return{enc:(...l)=>(0,L.toHex)((0,L.mergeUint8)(b,...l.map((E,o)=>s[o](E)))),dec:d,keyDecoder:D}}};
//# sourceMappingURL=index.js.map
{
"name": "@polkadot-api/substrate-bindings",
"version": "0.0.1-fc2d544220690af6fb53e6837b4498eaf27ec832.1.0",
"version": "0.0.1-fc842ef2a18284b688469fbeed66fcaef82e0b3c.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-fc2d544220690af6fb53e6837b4498eaf27ec832.1.0"
"scale-ts": "^1.6.0",
"@polkadot-api/utils": "0.0.1-fc842ef2a18284b688469fbeed66fcaef82e0b3c.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc