@polkadot-api/substrate-bindings
Advanced tools
Comparing version 0.0.1-febf4f5005db6670d1963b033cd95c8b8f7d079b.1.0 to 0.0.1-fee5ecb6d09dea073f130fd2a58995907bd36c9c.1.0
import * as scale_ts 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'; | ||
@@ -9,2 +8,12 @@ type SS58String = string & { | ||
}; | ||
type SS58AddressInfo = { | ||
isValid: false; | ||
} | { | ||
isValid: true; | ||
ss58Format: number; | ||
publicKey: Uint8Array; | ||
}; | ||
declare const getSs58AddressInfo: (address: SS58String) => SS58AddressInfo; | ||
declare const fromBufferToBase58: (ss58Format: number) => (publicKey: Uint8Array) => SS58String; | ||
declare const AccountId: (ss58Format?: number, nBytes?: 32 | 33) => scale_ts.Codec<SS58String>; | ||
@@ -21,8 +30,12 @@ | ||
interface Binary { | ||
declare class Binary { | ||
#private; | ||
constructor(data: Uint8Array); | ||
asText: () => string; | ||
asHex: () => string; | ||
asBytes: () => Uint8Array; | ||
asHex: () => HexString; | ||
asText: () => string; | ||
static fromText(input: string): Binary; | ||
static fromHex(input: HexString): Binary; | ||
static fromBytes(input: Uint8Array): Binary; | ||
} | ||
declare const Binary: ((bytes: Uint8Array) => Binary) & ((hex: HexString) => Binary) & ((text: string) => Binary); | ||
declare const Bin: { | ||
@@ -59,3 +72,3 @@ (nBytes?: number): Codec<Binary>; | ||
type RestrictedLenTuple<T, O extends StringRecord<any>> = Tuple<T, TuplifyUnion<keyof O> extends Tuple<any, infer V> ? V : 0>; | ||
type ExtractValue<T extends { | ||
type ExtractEnumValue<T extends { | ||
type: string; | ||
@@ -73,28 +86,7 @@ value?: any; | ||
type: K; | ||
value: ExtractValue<T, K>; | ||
value: ExtractEnumValue<T, K>; | ||
}>; | ||
as<K extends T["type"]>(type: K): ExtractValue<T, K>; | ||
as<K extends T["type"]>(type: K): ExtractEnumValue<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: Anonymize<Args>) => Anonymize<R> : T extends MyTuple<any> ? { | ||
[K in keyof T]: Anonymize<T[K]>; | ||
} : 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 { | ||
@@ -107,5 +99,5 @@ 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 : { | ||
}, Key extends T["type"]>(type: Key, ...args: ExtractEnumValue<T, Key> extends undefined ? [] : [value: ExtractEnumValue<T, Key>]) => Enum<ExtractEnumValue<T, Key> extends undefined ? T : ExtractEnumValue<T, Key> extends never ? T : { | ||
type: Key; | ||
value: ExtractValue<T, Key>; | ||
value: ExtractEnumValue<T, Key>; | ||
}>; | ||
@@ -127,3 +119,3 @@ declare const Variant: { | ||
declare const blockHeader: scale_ts_dist_types.Codec<{ | ||
declare const blockHeader: Codec<{ | ||
parentHash: HexString; | ||
@@ -163,3 +155,3 @@ number: number; | ||
name: string; | ||
type: number | void | undefined; | ||
type: number | undefined; | ||
}[]; | ||
@@ -169,5 +161,5 @@ def: { | ||
value: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -180,5 +172,5 @@ }[]; | ||
fields: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -258,5 +250,2 @@ }[]; | ||
}; | ||
} | { | ||
tag: "historicMetaCompat"; | ||
value: string; | ||
}; | ||
@@ -286,3 +275,3 @@ docs: string[]; | ||
name: string; | ||
type: number | void | undefined; | ||
type: number | undefined; | ||
}[]; | ||
@@ -292,5 +281,5 @@ def: { | ||
value: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -303,5 +292,5 @@ }[]; | ||
fields: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -381,5 +370,2 @@ }[]; | ||
}; | ||
} | { | ||
tag: "historicMetaCompat"; | ||
value: string; | ||
}; | ||
@@ -390,3 +376,3 @@ docs: string[]; | ||
name: string; | ||
storage: void | { | ||
storage: { | ||
prefix: string; | ||
@@ -432,4 +418,4 @@ items: { | ||
} | undefined; | ||
calls: number | void | undefined; | ||
events: number | void | undefined; | ||
calls: number | undefined; | ||
events: number | undefined; | ||
constants: { | ||
@@ -441,3 +427,3 @@ name: string; | ||
}[]; | ||
errors: number | void | undefined; | ||
errors: number | undefined; | ||
index: number; | ||
@@ -539,3 +525,3 @@ docs: string[]; | ||
name: string; | ||
type: number | void | undefined; | ||
type: number | undefined; | ||
}[]; | ||
@@ -545,5 +531,5 @@ def: { | ||
value: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -556,5 +542,5 @@ }[]; | ||
fields: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -634,5 +620,2 @@ }[]; | ||
}; | ||
} | { | ||
tag: "historicMetaCompat"; | ||
value: string; | ||
}; | ||
@@ -643,3 +626,3 @@ docs: string[]; | ||
name: string; | ||
storage: void | { | ||
storage: { | ||
prefix: string; | ||
@@ -685,4 +668,4 @@ items: { | ||
} | undefined; | ||
calls: number | void | undefined; | ||
events: number | void | undefined; | ||
calls: number | undefined; | ||
events: number | undefined; | ||
constants: { | ||
@@ -694,3 +677,3 @@ name: string; | ||
}[]; | ||
errors: number | void | undefined; | ||
errors: number | undefined; | ||
index: number; | ||
@@ -757,6 +740,9 @@ docs: string[]; | ||
type PlainDescriptor<T> = string & { | ||
type PlainDescriptor<T> = number & { | ||
_type?: T; | ||
}; | ||
type StorageDescriptor<Args extends Array<any>, T, Optional extends true | false> = string & { | ||
type AssetDescriptor<T> = string & { | ||
_type?: T; | ||
}; | ||
type StorageDescriptor<Args extends Array<any>, T, Optional extends true | false> = number & { | ||
_type: T; | ||
@@ -766,6 +752,6 @@ _args: Args; | ||
}; | ||
type TxDescriptor<Args extends {} | undefined> = string & { | ||
type TxDescriptor<Args extends {} | undefined> = number & { | ||
___: Args; | ||
}; | ||
type RuntimeDescriptor<Args extends Array<any>, T> = string & { | ||
type RuntimeDescriptor<Args extends Array<any>, T> = number & { | ||
__: [Args, T]; | ||
@@ -782,2 +768,4 @@ }; | ||
apis: Record<string, Record<string, RuntimeDescriptor<any, any>>>; | ||
asset: AssetDescriptor<any>; | ||
checksums: string[]; | ||
}; | ||
@@ -790,4 +778,4 @@ type PickDescriptors<Idx extends 0 | 1 | 2 | 3 | 4, T extends Descriptors["pallets"]> = { | ||
[KK in keyof T[K]]: T[K][KK] extends StorageDescriptor<infer Key, infer Value, infer Optional> ? { | ||
KeyArgs: Anonymize<Key>; | ||
Value: Anonymize<Value>; | ||
KeyArgs: Key; | ||
Value: Value; | ||
IsOptional: Optional; | ||
@@ -799,3 +787,3 @@ } : unknown; | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends TxDescriptor<infer Args> ? Anonymize<Args> : unknown; | ||
[KK in keyof T[K]]: T[K][KK] extends TxDescriptor<infer Args> ? Args : unknown; | ||
}; | ||
@@ -805,3 +793,3 @@ }; | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends PlainDescriptor<infer Value> ? Anonymize<Value> : unknown; | ||
[KK in keyof T[K]]: T[K][KK] extends PlainDescriptor<infer Value> ? Value : unknown; | ||
}; | ||
@@ -815,2 +803,9 @@ }; | ||
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 }; | ||
type GetEnum<T extends Enum<{ | ||
type: string; | ||
value: any; | ||
}>> = { | ||
[K in T["type"]]: (...args: ExtractEnumValue<T, K> extends undefined ? [] : [value: ExtractEnumValue<T, K>]) => T; | ||
}; | ||
export { AccountId, type AssetDescriptor, Bin, Binary, type BitSequence, Blake2128, Blake2128Concat, Blake2256, type BlockHeader, type ConstFromDescriptors, type Descriptors, type Discriminant, type EncoderWithHash, Enum, type ErrorsFromDescriptors, type EventsFromDescriptors, type ExtractEnumValue, type GetEnum, Hex, type HexString, Identity, type PlainDescriptor, type QueryFromDescriptors, type RuntimeDescriptor, type SS58AddressInfo, 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, fromBufferToBase58, getSs58AddressInfo, 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) => { | ||
@@ -20,2 +21,24 @@ 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; | ||
}; | ||
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; | ||
}; | ||
@@ -61,2 +84,4 @@ // src/index.ts | ||
fixedStr: () => fixedStr, | ||
fromBufferToBase58: () => fromBufferToBase58, | ||
getSs58AddressInfo: () => getSs58AddressInfo, | ||
h64: () => h64, | ||
@@ -85,6 +110,39 @@ i128: () => import_scale_ts8.i128, | ||
var import_scale_ts = require("scale-ts"); | ||
// src/utils/ss58-util.ts | ||
var import_base = require("@scure/base"); | ||
var import_blake2b = require("@noble/hashes/blake2b"); | ||
var import_base = require("@scure/base"); | ||
var SS58_PREFIX = new TextEncoder().encode("SS58PRE"); | ||
var CHECKSUM_LENGTH = 2; | ||
var getSs58AddressInfo = (address) => { | ||
try { | ||
const decoded = import_base.base58.decode(address); | ||
const prefixBytes = decoded.subarray(0, decoded[0] & 64 ? 2 : 1); | ||
const publicKey = decoded.subarray( | ||
prefixBytes.length, | ||
decoded.length - CHECKSUM_LENGTH | ||
); | ||
const checksum = decoded.subarray(prefixBytes.length + publicKey.length); | ||
const expectedChecksum = (0, import_blake2b.blake2b)( | ||
Uint8Array.of(...SS58_PREFIX, ...prefixBytes, ...publicKey), | ||
{ | ||
dkLen: 64 | ||
} | ||
).subarray(0, CHECKSUM_LENGTH); | ||
const isChecksumValid = checksum[0] === expectedChecksum[0] && checksum[1] === expectedChecksum[1]; | ||
if (!isChecksumValid) | ||
return { isValid: false }; | ||
return { | ||
isValid: true, | ||
ss58Format: prefixBytesToNumber(prefixBytes), | ||
publicKey: publicKey.slice() | ||
}; | ||
} catch (_) { | ||
return { isValid: false }; | ||
} | ||
}; | ||
var prefixBytesToNumber = (bytes) => { | ||
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); | ||
return dv.byteLength === 1 ? dv.getUint8(0) : dv.getUint16(0); | ||
}; | ||
var fromBufferToBase58 = (ss58Format) => { | ||
@@ -107,24 +165,13 @@ const prefixBytes = ss58Format < 64 ? Uint8Array.of(ss58Format) : Uint8Array.of( | ||
}; | ||
function fromBase58ToBuffer(nBytes, ss58Format) { | ||
// src/codecs/scale/AccountId.ts | ||
function fromBase58ToBuffer(nBytes, _ss58Format) { | ||
return (address) => { | ||
const decoded = import_base.base58.decode(address); | ||
const prefixBytes = decoded.subarray(0, decoded[0] & 64 ? 2 : 1); | ||
const publicKey = decoded.subarray( | ||
prefixBytes.length, | ||
decoded.length - CHECKSUM_LENGTH | ||
); | ||
const info = getSs58AddressInfo(address); | ||
if (!info.isValid) | ||
throw new Error("Invalid checksum"); | ||
const { publicKey } = info; | ||
if (publicKey.length !== nBytes) | ||
throw new Error("Invalid public key length"); | ||
const checksum = decoded.subarray(prefixBytes.length + publicKey.length); | ||
const expectedChecksum = (0, import_blake2b.blake2b)( | ||
Uint8Array.of(...SS58_PREFIX, ...prefixBytes, ...publicKey), | ||
{ | ||
dkLen: 64 | ||
} | ||
).subarray(0, CHECKSUM_LENGTH); | ||
if (checksum[0] !== expectedChecksum[0] || checksum[1] !== expectedChecksum[1]) | ||
throw new Error("Invalid checksum"); | ||
if (prefixBytesToNumber(prefixBytes) != ss58Format) | ||
throw new Error("Invalid SS58 prefix"); | ||
return publicKey.slice(); | ||
return publicKey; | ||
}; | ||
@@ -137,31 +184,33 @@ } | ||
); | ||
var prefixBytesToNumber = (bytes) => { | ||
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); | ||
return dv.byteLength === 1 ? dv.getUint8(0) : dv.getUint16(0); | ||
}; | ||
// src/codecs/scale/Binary.ts | ||
var import_scale_ts2 = require("scale-ts"); | ||
var import_utils = require("@polkadot-api/utils"); | ||
var import_scale_ts2 = require("scale-ts"); | ||
var textEncoder = new TextEncoder(); | ||
var textDecoder = new TextDecoder(); | ||
var Binary = (data) => { | ||
let bytes; | ||
let hex = null; | ||
let str5 = null; | ||
if (data instanceof Uint8Array) { | ||
bytes = data; | ||
} else if (data.match(/0[xX][0-9a-fA-F]+/)) { | ||
bytes = (0, import_utils.fromHex)(data); | ||
hex = data; | ||
} else { | ||
bytes = textEncoder.encode(data); | ||
str5 = data; | ||
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); | ||
} | ||
return { | ||
asText: () => str5 === null ? str5 = textDecoder.decode(bytes) : str5, | ||
asHex: () => hex === null ? hex = (0, import_utils.toHex)(bytes) : hex, | ||
asBytes: () => bytes | ||
}; | ||
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) => { | ||
@@ -173,3 +222,3 @@ const _enc = import_scale_ts2.Bytes.enc(nBytes); | ||
const _dec = import_scale_ts2.Bytes.dec(nBytes); | ||
return (value) => Binary(_dec(value)); | ||
return (value) => Binary.fromBytes(_dec(value)); | ||
}; | ||
@@ -399,4 +448,3 @@ var Bin = (nBytes) => (0, import_scale_ts2.createCodec)(enc(nBytes), dec(nBytes)); | ||
compact: compactNumber, | ||
bitSequence: bitSequence2, | ||
historicMetaCompat: import_scale_ts11.str | ||
bitSequence: bitSequence2 | ||
}); | ||
@@ -403,0 +451,0 @@ var param = (0, import_scale_ts11.Struct)({ |
import * as scale_ts 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'; | ||
@@ -9,2 +8,12 @@ type SS58String = string & { | ||
}; | ||
type SS58AddressInfo = { | ||
isValid: false; | ||
} | { | ||
isValid: true; | ||
ss58Format: number; | ||
publicKey: Uint8Array; | ||
}; | ||
declare const getSs58AddressInfo: (address: SS58String) => SS58AddressInfo; | ||
declare const fromBufferToBase58: (ss58Format: number) => (publicKey: Uint8Array) => SS58String; | ||
declare const AccountId: (ss58Format?: number, nBytes?: 32 | 33) => scale_ts.Codec<SS58String>; | ||
@@ -21,8 +30,12 @@ | ||
interface Binary { | ||
declare class Binary { | ||
#private; | ||
constructor(data: Uint8Array); | ||
asText: () => string; | ||
asHex: () => string; | ||
asBytes: () => Uint8Array; | ||
asHex: () => HexString; | ||
asText: () => string; | ||
static fromText(input: string): Binary; | ||
static fromHex(input: HexString): Binary; | ||
static fromBytes(input: Uint8Array): Binary; | ||
} | ||
declare const Binary: ((bytes: Uint8Array) => Binary) & ((hex: HexString) => Binary) & ((text: string) => Binary); | ||
declare const Bin: { | ||
@@ -59,3 +72,3 @@ (nBytes?: number): Codec<Binary>; | ||
type RestrictedLenTuple<T, O extends StringRecord<any>> = Tuple<T, TuplifyUnion<keyof O> extends Tuple<any, infer V> ? V : 0>; | ||
type ExtractValue<T extends { | ||
type ExtractEnumValue<T extends { | ||
type: string; | ||
@@ -73,28 +86,7 @@ value?: any; | ||
type: K; | ||
value: ExtractValue<T, K>; | ||
value: ExtractEnumValue<T, K>; | ||
}>; | ||
as<K extends T["type"]>(type: K): ExtractValue<T, K>; | ||
as<K extends T["type"]>(type: K): ExtractEnumValue<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: Anonymize<Args>) => Anonymize<R> : T extends MyTuple<any> ? { | ||
[K in keyof T]: Anonymize<T[K]>; | ||
} : 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 { | ||
@@ -107,5 +99,5 @@ 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 : { | ||
}, Key extends T["type"]>(type: Key, ...args: ExtractEnumValue<T, Key> extends undefined ? [] : [value: ExtractEnumValue<T, Key>]) => Enum<ExtractEnumValue<T, Key> extends undefined ? T : ExtractEnumValue<T, Key> extends never ? T : { | ||
type: Key; | ||
value: ExtractValue<T, Key>; | ||
value: ExtractEnumValue<T, Key>; | ||
}>; | ||
@@ -127,3 +119,3 @@ declare const Variant: { | ||
declare const blockHeader: scale_ts_dist_types.Codec<{ | ||
declare const blockHeader: Codec<{ | ||
parentHash: HexString; | ||
@@ -163,3 +155,3 @@ number: number; | ||
name: string; | ||
type: number | void | undefined; | ||
type: number | undefined; | ||
}[]; | ||
@@ -169,5 +161,5 @@ def: { | ||
value: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -180,5 +172,5 @@ }[]; | ||
fields: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -258,5 +250,2 @@ }[]; | ||
}; | ||
} | { | ||
tag: "historicMetaCompat"; | ||
value: string; | ||
}; | ||
@@ -286,3 +275,3 @@ docs: string[]; | ||
name: string; | ||
type: number | void | undefined; | ||
type: number | undefined; | ||
}[]; | ||
@@ -292,5 +281,5 @@ def: { | ||
value: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -303,5 +292,5 @@ }[]; | ||
fields: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -381,5 +370,2 @@ }[]; | ||
}; | ||
} | { | ||
tag: "historicMetaCompat"; | ||
value: string; | ||
}; | ||
@@ -390,3 +376,3 @@ docs: string[]; | ||
name: string; | ||
storage: void | { | ||
storage: { | ||
prefix: string; | ||
@@ -432,4 +418,4 @@ items: { | ||
} | undefined; | ||
calls: number | void | undefined; | ||
events: number | void | undefined; | ||
calls: number | undefined; | ||
events: number | undefined; | ||
constants: { | ||
@@ -441,3 +427,3 @@ name: string; | ||
}[]; | ||
errors: number | void | undefined; | ||
errors: number | undefined; | ||
index: number; | ||
@@ -539,3 +525,3 @@ docs: string[]; | ||
name: string; | ||
type: number | void | undefined; | ||
type: number | undefined; | ||
}[]; | ||
@@ -545,5 +531,5 @@ def: { | ||
value: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -556,5 +542,5 @@ }[]; | ||
fields: { | ||
name: string | void | undefined; | ||
name: string | undefined; | ||
type: number; | ||
typeName: string | void | undefined; | ||
typeName: string | undefined; | ||
docs: string[]; | ||
@@ -634,5 +620,2 @@ }[]; | ||
}; | ||
} | { | ||
tag: "historicMetaCompat"; | ||
value: string; | ||
}; | ||
@@ -643,3 +626,3 @@ docs: string[]; | ||
name: string; | ||
storage: void | { | ||
storage: { | ||
prefix: string; | ||
@@ -685,4 +668,4 @@ items: { | ||
} | undefined; | ||
calls: number | void | undefined; | ||
events: number | void | undefined; | ||
calls: number | undefined; | ||
events: number | undefined; | ||
constants: { | ||
@@ -694,3 +677,3 @@ name: string; | ||
}[]; | ||
errors: number | void | undefined; | ||
errors: number | undefined; | ||
index: number; | ||
@@ -757,6 +740,9 @@ docs: string[]; | ||
type PlainDescriptor<T> = string & { | ||
type PlainDescriptor<T> = number & { | ||
_type?: T; | ||
}; | ||
type StorageDescriptor<Args extends Array<any>, T, Optional extends true | false> = string & { | ||
type AssetDescriptor<T> = string & { | ||
_type?: T; | ||
}; | ||
type StorageDescriptor<Args extends Array<any>, T, Optional extends true | false> = number & { | ||
_type: T; | ||
@@ -766,6 +752,6 @@ _args: Args; | ||
}; | ||
type TxDescriptor<Args extends {} | undefined> = string & { | ||
type TxDescriptor<Args extends {} | undefined> = number & { | ||
___: Args; | ||
}; | ||
type RuntimeDescriptor<Args extends Array<any>, T> = string & { | ||
type RuntimeDescriptor<Args extends Array<any>, T> = number & { | ||
__: [Args, T]; | ||
@@ -782,2 +768,4 @@ }; | ||
apis: Record<string, Record<string, RuntimeDescriptor<any, any>>>; | ||
asset: AssetDescriptor<any>; | ||
checksums: string[]; | ||
}; | ||
@@ -790,4 +778,4 @@ type PickDescriptors<Idx extends 0 | 1 | 2 | 3 | 4, T extends Descriptors["pallets"]> = { | ||
[KK in keyof T[K]]: T[K][KK] extends StorageDescriptor<infer Key, infer Value, infer Optional> ? { | ||
KeyArgs: Anonymize<Key>; | ||
Value: Anonymize<Value>; | ||
KeyArgs: Key; | ||
Value: Value; | ||
IsOptional: Optional; | ||
@@ -799,3 +787,3 @@ } : unknown; | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends TxDescriptor<infer Args> ? Anonymize<Args> : unknown; | ||
[KK in keyof T[K]]: T[K][KK] extends TxDescriptor<infer Args> ? Args : unknown; | ||
}; | ||
@@ -805,3 +793,3 @@ }; | ||
[K in keyof T]: { | ||
[KK in keyof T[K]]: T[K][KK] extends PlainDescriptor<infer Value> ? Anonymize<Value> : unknown; | ||
[KK in keyof T[K]]: T[K][KK] extends PlainDescriptor<infer Value> ? Value : unknown; | ||
}; | ||
@@ -815,2 +803,9 @@ }; | ||
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 }; | ||
type GetEnum<T extends Enum<{ | ||
type: string; | ||
value: any; | ||
}>> = { | ||
[K in T["type"]]: (...args: ExtractEnumValue<T, K> extends undefined ? [] : [value: ExtractEnumValue<T, K>]) => T; | ||
}; | ||
export { AccountId, type AssetDescriptor, Bin, Binary, type BitSequence, Blake2128, Blake2128Concat, Blake2256, type BlockHeader, type ConstFromDescriptors, type Descriptors, type Discriminant, type EncoderWithHash, Enum, type ErrorsFromDescriptors, type EventsFromDescriptors, type ExtractEnumValue, type GetEnum, Hex, type HexString, Identity, type PlainDescriptor, type QueryFromDescriptors, type RuntimeDescriptor, type SS58AddressInfo, 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, fromBufferToBase58, getSs58AddressInfo, h64, metadata, selfDecoder, selfEncoder, v15 }; |
@@ -1,2 +0,2 @@ | ||
"use strict";var G=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var _e=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of Re(t))!Le.call(e,m)&&m!==n&&G(e,m,{get:()=>t[m],enumerable:!(d=He(t,m))||d.enumerable});return e};var Ne=e=>Ie(G({},"__esModule",{value:!0}),e);var Ut={};_e(Ut,{AccountId:()=>ze,Bin:()=>Q,Binary:()=>de,Blake2128:()=>Ce,Blake2128Concat:()=>oe,Blake2256:()=>vt,Bytes:()=>r.Bytes,Enum:()=>F,Hex:()=>U,Identity:()=>ce,Option:()=>r.Option,Result:()=>r.Result,Self:()=>et,Storage:()=>kt,Struct:()=>r.Struct,Tuple:()=>r.Tuple,Twox128:()=>$,Twox256:()=>St,Twox64Concat:()=>ie,Variant:()=>_,Vector:()=>r.Vector,_Enum:()=>tt,_void:()=>r._void,bitSequence:()=>Je,blockHeader:()=>ot,bool:()=>r.bool,char:()=>Qe,compact:()=>r.compact,compactBn:()=>Ge,compactNumber:()=>a,createCodec:()=>r.createCodec,createDecoder:()=>r.createDecoder,enhanceCodec:()=>r.enhanceCodec,enhanceDecoder:()=>r.enhanceDecoder,enhanceEncoder:()=>r.enhanceEncoder,fixedStr:()=>Fe,h64:()=>w,i128:()=>r.i128,i16:()=>r.i16,i256:()=>r.i256,i32:()=>r.i32,i64:()=>r.i64,i8:()=>r.i8,metadata:()=>Et,selfDecoder:()=>fe,selfEncoder:()=>xe,str:()=>r.str,u128:()=>r.u128,u16:()=>r.u16,u256:()=>r.u256,u32:()=>r.u32,u64:()=>r.u64,u8:()=>r.u8,v15:()=>ne});module.exports=Ne(Ut);var N=require("scale-ts"),j=require("@noble/hashes/blake2b"),J=require("@scure/base"),ae=new TextEncoder().encode("SS58PRE"),X=2,Me=e=>{let t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{let d=(0,j.blake2b)(Uint8Array.of(...ae,...t,...n),{dkLen:64}).subarray(0,X);return J.base58.encode(Uint8Array.of(...t,...n,...d))}};function Pe(e,t){return n=>{let d=J.base58.decode(n),m=d.subarray(0,d[0]&64?2:1),b=d.subarray(m.length,d.length-X);if(b.length!==e)throw new Error("Invalid public key length");let v=d.subarray(m.length+b.length),E=(0,j.blake2b)(Uint8Array.of(...ae,...m,...b),{dkLen:64}).subarray(0,X);if(v[0]!==E[0]||v[1]!==E[1])throw new Error("Invalid checksum");if(qe(m)!=t)throw new Error("Invalid SS58 prefix");return b.slice()}}var ze=(e=42,t=32)=>(0,N.enhanceCodec)((0,N.Bytes)(t),Pe(t,e),Me(e)),qe=e=>{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)};var M=require("@polkadot-api/utils"),H=require("scale-ts"),We=new TextEncoder,$e=new TextDecoder,de=e=>{let t,n=null,d=null;return e instanceof Uint8Array?t=e:e.match(/0[xX][0-9a-fA-F]+/)?(t=(0,M.fromHex)(e),n=e):(t=We.encode(e),d=e),{asText:()=>d===null?d=$e.decode(t):d,asHex:()=>n===null?n=(0,M.toHex)(t):n,asBytes:()=>t}},ye=e=>{let t=H.Bytes.enc(e);return n=>t(n.asBytes())},me=e=>{let t=H.Bytes.dec(e);return n=>de(t(n))},Q=e=>(0,H.createCodec)(ye(e),me(e));Q.enc=ye;Q.dec=me;var V=require("scale-ts");var Y=require("scale-ts"),a=Y.compact,Ge=Y.compact;var Xe=(0,V.createDecoder)(e=>{let t=a.dec(e),n=Math.ceil(t/8);return{bytes:(0,V.Bytes)(n).dec(e),bitsLen:t}}),je=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},Je=(0,V.createCodec)(je,Xe);var P=require("scale-ts"),Qe=(0,P.enhanceCodec)(P.u8,e=>e.charCodeAt(0),String.fromCharCode);var z=require("@polkadot-api/utils"),R=require("scale-ts"),ue=e=>{let t=R.Bytes.enc(e);return n=>t((0,z.fromHex)(n))},le=e=>{let t=R.Bytes.dec(e);return n=>(0,z.toHex)(t(n))},U=e=>(0,R.createCodec)(ue(e),le(e));U.enc=ue;U.dec=le;var q=require("scale-ts"),Ye=new TextEncoder,Ze=new TextDecoder,Fe=e=>(0,q.enhanceCodec)((0,q.Bytes)(e),t=>Ye.encode(t),t=>Ze.decode(t));var r=require("scale-ts");var pe=require("scale-ts"),xe=e=>{let t=n=>{let d=e();return t=d,d(n)};return n=>t(n)},fe=e=>{let t=n=>{let d=e(),m=d;return t=d,m(n)};return n=>t(n)},et=e=>(0,pe.createCodec)(xe(()=>e().enc),fe(()=>e().dec));var L=require("scale-ts"),Z=require("@polkadot-api/utils"),tt=new Proxy({},{get(e,t){return n=>F(t,n)}}),F=(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}),Te=(...e)=>{let t=L.Enum.enc(...e);return n=>t({tag:n.type,value:n.value})},ge=(...e)=>{let t=L.Enum.dec(...e);return n=>{let{tag:d,value:m}=t(n);return F(d,m)}},_=(e,...t)=>(0,L.createCodec)(Te((0,Z.mapObject)(e,([n])=>n),...t),ge((0,Z.mapObject)(e,([,n])=>n),...t));_.enc=Te;_.dec=ge;var be=new TextEncoder,Ee=new TextDecoder,nt=(0,r.enhanceCodec)((0,r.Bytes)(4),be.encode.bind(be),Ee.decode.bind(Ee)),ee=(0,r.Struct)({engine:nt,payload:U()}),rt=_({consensus:ee,seal:ee,preRuntime:ee,runtimeUpdated:r._void},[4,5,6,8]),te=U(32),ot=(0,r.Struct)({parentHash:te,number:a,stateRoot:te,extrinsicRoot:te,digests:(0,r.Vector)(rt)});var u=require("scale-ts");var c=require("scale-ts"),he=(0,c.Option)(c.str),W=(0,c.Vector)(c.str),ct=(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:he,type:a,typeName:he,docs:W})),st=(0,c.Struct)({len:c.u32,type:a}),it=(0,c.Struct)({bitStoreType:a,bitOrderType:a}),at=(0,c.Vector)((0,c.Struct)({name:c.str,fields:ve,index:c.u8,docs:W})),dt=(0,c.Enum)({composite:ve,variant:at,sequence:a,array:st,tuple:(0,c.Vector)(a),primitive:ct,compact:a,bitSequence:it,historicMetaCompat:c.str}),yt=(0,c.Struct)({name:c.str,type:(0,c.Option)(a)}),mt=(0,c.Vector)(yt),ut=(0,c.Struct)({id:a,path:W,params:mt,def:dt,docs:W}),Ae=(0,c.Vector)(ut);var i=require("scale-ts"),lt=(0,i.Enum)({Blake2128:i._void,Blake2256:i._void,Blake2128Concat:i._void,Twox128:i._void,Twox256:i._void,Twox64Concat:i._void,Identity:i._void}),pt=(0,i.Vector)(lt),xt=(0,i.Struct)({hashers:pt,key:a,value:a}),ft=(0,i.Struct)({name:i.str,modifier:i.u8,type:(0,i.Enum)({plain:a,map:xt}),fallback:U(),docs:(0,i.Vector)(i.str)}),Tt=(0,i.Option)((0,i.Struct)({prefix:i.str,items:(0,i.Vector)(ft)})),Se=(0,i.Vector)((0,i.Struct)({name:i.str,storage:Tt,calls:(0,i.Option)(a),events:(0,i.Option)(a),constants:(0,i.Vector)((0,i.Struct)({name:i.str,type:a,value:U(),docs:(0,i.Vector)(i.str)})),errors:(0,i.Option)(a),index:i.u8,docs:(0,i.Vector)(i.str)}));var ke=(0,u.Vector)(u.str),gt=(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:ke})),docs:ke}),bt=(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}))}),ne=(0,u.Struct)({lookup:Ae,pallets:Se,extrinsic:bt,type:a,apis:(0,u.Vector)(gt),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:U()})))});var C=require("scale-ts");var Ue=()=>{throw new Error("Unsupported metadata version!")},g=(0,C.createCodec)(Ue,Ue),Et=(0,C.Struct)({magicNumber:C.u32,metadata:(0,C.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:ne})});var we=require("@polkadot-api/utils"),re=require("@noble/hashes/blake2b"),ht={dkLen:32},vt=e=>(0,re.blake2b)(e,ht),At={dkLen:16},Ce=e=>(0,re.blake2b)(e,At),oe=e=>(0,we.mergeUint8)(Ce(e),e);var ce=e=>e;var Ve=require("@polkadot-api/utils"),De=require("scale-ts");var K=(e,t,n,d)=>new DataView(new Uint16Array([e,t,n,d]).buffer).getBigUint64(0,!0),se=2n**64n-1n,T=(e,t)=>e<<t&se|e>>64n-t,y=(e,t)=>e*t&se,x=(e,t)=>e+t&se,f=11400714785074694791n,A=14029467366897019727n,Ke=1609587929392839161n,I=9650029242287828579n,Be=2870177450012600261n;function w(e,t=0n){let n=x(x(t,f),A),d=x(t,A),m=t,b=t-f,v=e.length,E=0,B=null;(function(){let o=0,S=o+v;if(v){if(B=new Uint8Array(32),v<32){B.set(e.subarray(0,v),E),E+=v;return}if(o<=S-32){let O=S-32;do{let k;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]),n=y(T(x(n,y(k,A)),31n),f),o+=8,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]),d=y(T(x(d,y(k,A)),31n),f),o+=8,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]),m=y(T(x(m,y(k,A)),31n),f),o+=8,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]),b=y(T(x(b,y(k,A)),31n),f),o+=8}while(o<=O)}o<S&&(B.set(e.subarray(o,S),E),E=S-o)}})(),e=B||e;let s,l=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),I),d=y(T(y(d,A),31n),f),s=s^d,s=x(y(s,f),I),m=y(T(y(m,A),31n),f),s=s^m,s=x(y(s,f),I),b=y(T(y(b,A),31n),f),s=s^b,s=x(y(s,f),I)):s=x(t,Be),s=x(s,BigInt(v));l<=E-8;){let h=K(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);h=y(T(y(h,A),31n),f),s=x(y(T(s^h,27n),f),I),l+=8}if(l+4<=E){let h=y(K(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),f);s=x(y(T(s^h,23n),A),Ke),l+=4}for(;l<E;){let h=y(K(e[l++],0,0,0),Be);s=y(T(s^h,11n),f)}let p=s>>33n;return s=y(s^p,A),p=s>>29n,s=y(s^p,Ke),p=s>>32n,s^=p,s}var $=e=>{let t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,w(e),!0),n.setBigUint64(8,w(e,1n),!0),t},St=e=>{let t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,w(e),!0),n.setBigUint64(8,w(e,1n),!0),n.setBigUint64(16,w(e,2n),!0),n.setBigUint64(24,w(e,3n),!0),t},ie=e=>(0,Ve.mergeUint8)(De.u64.enc(w(e)),e);var D=require("@polkadot-api/utils");var Oe=new TextEncoder,kt=e=>{let t=$(Oe.encode(e));return(n,d,...m)=>{let b=(0,D.mergeUint8)(t,$(Oe.encode(n))),v=(0,D.toHex)(b),E=m.map(p=>p[1]).map(p=>p===ce?0:p===ie?8:p===oe?16:null).filter(Boolean),B=p=>{if(!p.startsWith(v))throw new Error(`key does not match this storage (${e}.${n})`);if(E.length!==m.length)throw new Error("Impossible to decode this key");if(m.length===0)return[];let h=p.slice(v.length),o=new Array(m.length);for(let S=0,O=0;S<E.length;S++){let k=m[S][0];O+=E[S],o[S]=k.dec(h.slice(O*2)),O+=k.enc(o[S]).length}return o},s=m.map(([{enc:p},h])=>o=>h(p(o)));return{enc:(...p)=>(0,D.toHex)((0,D.mergeUint8)(b,...p.map((h,o)=>s[o](h)))),dec:d,keyDecoder:B}}}; | ||
"use strict";var $=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var Ge=(e,t,n)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Xe=(e,t)=>{for(var n in t)$(e,n,{get:t[n],enumerable:!0})},Je=(e,t,n,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let y of ze(t))!Fe.call(e,y)&&y!==n&&$(e,y,{get:()=>t[y],enumerable:!(d=je(t,y))||d.enumerable});return e};var Qe=e=>Je($({},"__esModule",{value:!0}),e);var j=(e,t,n)=>(Ge(e,typeof t!="symbol"?t+"":t,n),n),be=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var A=(e,t,n)=>(be(e,t,"read from private field"),n?n.call(e):t.get(e)),z=(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)},F=(e,t,n,d)=>(be(e,t,"write to private field"),d?d.call(e,n):t.set(e,n),n);var _t={};Xe(_t,{AccountId:()=>et,Bin:()=>ie,Binary:()=>X,Blake2128:()=>Ne,Blake2128Concat:()=>fe,Blake2256:()=>Ot,Bytes:()=>r.Bytes,Enum:()=>ye,Hex:()=>C,Identity:()=>xe,Option:()=>r.Option,Result:()=>r.Result,Self:()=>mt,Storage:()=>Lt,Struct:()=>r.Struct,Tuple:()=>r.Tuple,Twox128:()=>te,Twox256:()=>Rt,Twox64Concat:()=>Te,Variant:()=>q,Vector:()=>r.Vector,_Enum:()=>ut,_void:()=>r._void,bitSequence:()=>st,blockHeader:()=>ft,bool:()=>r.bool,char:()=>it,compact:()=>r.compact,compactBn:()=>rt,compactNumber:()=>a,createCodec:()=>r.createCodec,createDecoder:()=>r.createDecoder,enhanceCodec:()=>r.enhanceCodec,enhanceDecoder:()=>r.enhanceDecoder,enhanceEncoder:()=>r.enhanceEncoder,fixedStr:()=>yt,fromBufferToBase58:()=>se,getSs58AddressInfo:()=>ce,h64:()=>U,i128:()=>r.i128,i16:()=>r.i16,i256:()=>r.i256,i32:()=>r.i32,i64:()=>r.i64,i8:()=>r.i8,metadata:()=>Bt,selfDecoder:()=>Ue,selfEncoder:()=>Ce,str:()=>r.str,u128:()=>r.u128,u16:()=>r.u16,u256:()=>r.u256,u32:()=>r.u32,u64:()=>r.u64,u8:()=>r.u8,v15:()=>le});module.exports=Qe(_t);var G=require("scale-ts");var re=require("@scure/base"),oe=require("@noble/hashes/blake2b"),he=new TextEncoder().encode("SS58PRE"),ne=2,ce=e=>{try{let t=re.base58.decode(e),n=t.subarray(0,t[0]&64?2:1),d=t.subarray(n.length,t.length-ne),y=t.subarray(n.length+d.length),E=(0,oe.blake2b)(Uint8Array.of(...he,...n,...d),{dkLen:64}).subarray(0,ne);return y[0]===E[0]&&y[1]===E[1]?{isValid:!0,ss58Format:Ye(n),publicKey:d.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Ye=e=>{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},se=e=>{let t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{let d=(0,oe.blake2b)(Uint8Array.of(...he,...t,...n),{dkLen:64}).subarray(0,ne);return re.base58.encode(Uint8Array.of(...t,...n,...d))}};function Ze(e,t){return n=>{let d=ce(n);if(!d.isValid)throw new Error("Invalid checksum");let{publicKey:y}=d;if(y.length!==e)throw new Error("Invalid public key length");return y}}var et=(e=42,t=32)=>(0,G.enhanceCodec)((0,G.Bytes)(t),Ze(t,e),se(e));var N=require("scale-ts"),J=require("@polkadot-api/utils");var tt=new TextEncoder,nt=new TextDecoder,V,O,H,I=class I{constructor(t){z(this,V,void 0);z(this,O,null);z(this,H,null);j(this,"asText",()=>A(this,H)===null?F(this,H,nt.decode(A(this,V))):A(this,H));j(this,"asHex",()=>A(this,O)===null?F(this,O,(0,J.toHex)(A(this,V))):A(this,O));j(this,"asBytes",()=>A(this,V));F(this,V,t)}static fromText(t){return new I(tt.encode(t))}static fromHex(t){return new I((0,J.fromHex)(t))}static fromBytes(t){return new I(t)}};V=new WeakMap,O=new WeakMap,H=new WeakMap;var X=I,Ee=e=>{let t=N.Bytes.enc(e);return n=>t(n.asBytes())},ve=e=>{let t=N.Bytes.dec(e);return n=>X.fromBytes(t(n))},ie=e=>(0,N.createCodec)(Ee(e),ve(e));ie.enc=Ee;ie.dec=ve;var R=require("scale-ts");var ae=require("scale-ts"),a=ae.compact,rt=ae.compact;var ot=(0,R.createDecoder)(e=>{let t=a.dec(e),n=Math.ceil(t/8);return{bytes:(0,R.Bytes)(n).dec(e),bitsLen:t}}),ct=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},st=(0,R.createCodec)(ct,ot);var Q=require("scale-ts"),it=(0,Q.enhanceCodec)(Q.u8,e=>e.charCodeAt(0),String.fromCharCode);var Y=require("@polkadot-api/utils"),P=require("scale-ts"),Se=e=>{let t=P.Bytes.enc(e);return n=>t((0,Y.fromHex)(n))},ke=e=>{let t=P.Bytes.dec(e);return n=>(0,Y.toHex)(t(n))},C=e=>(0,P.createCodec)(Se(e),ke(e));C.enc=Se;C.dec=ke;var Z=require("scale-ts"),at=new TextEncoder,dt=new TextDecoder,yt=e=>(0,Z.enhanceCodec)((0,Z.Bytes)(e),t=>at.encode(t),t=>dt.decode(t));var r=require("scale-ts");var we=require("scale-ts"),Ce=e=>{let t=n=>{let d=e();return t=d,d(n)};return n=>t(n)},Ue=e=>{let t=n=>{let d=e(),y=d;return t=d,y(n)};return n=>t(n)},mt=e=>(0,we.createCodec)(Ce(()=>e().enc),Ue(()=>e().dec));var M=require("scale-ts"),de=require("@polkadot-api/utils"),ut=new Proxy({},{get(e,t){return n=>ye(t,n)}}),ye=(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}),Ae=(...e)=>{let t=M.Enum.enc(...e);return n=>t({tag:n.type,value:n.value})},Ke=(...e)=>{let t=M.Enum.dec(...e);return n=>{let{tag:d,value:y}=t(n);return ye(d,y)}},q=(e,...t)=>(0,M.createCodec)(Ae((0,de.mapObject)(e,([n])=>n),...t),Ke((0,de.mapObject)(e,([,n])=>n),...t));q.enc=Ae;q.dec=Ke;var Ve=new TextEncoder,Be=new TextDecoder,lt=(0,r.enhanceCodec)((0,r.Bytes)(4),Ve.encode.bind(Ve),Be.decode.bind(Be)),me=(0,r.Struct)({engine:lt,payload:C()}),pt=q({consensus:me,seal:me,preRuntime:me,runtimeUpdated:r._void},[4,5,6,8]),ue=C(32),ft=(0,r.Struct)({parentHash:ue,number:a,stateRoot:ue,extrinsicRoot:ue,digests:(0,r.Vector)(pt)});var u=require("scale-ts");var c=require("scale-ts"),De=(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}),Oe=(0,c.Vector)((0,c.Struct)({name:De,type:a,typeName:De,docs:ee})),gt=(0,c.Struct)({len:c.u32,type:a}),Tt=(0,c.Struct)({bitStoreType:a,bitOrderType:a}),bt=(0,c.Vector)((0,c.Struct)({name:c.str,fields:Oe,index:c.u8,docs:ee})),ht=(0,c.Enum)({composite:Oe,variant:bt,sequence:a,array:gt,tuple:(0,c.Vector)(a),primitive:xt,compact:a,bitSequence:Tt}),Et=(0,c.Struct)({name:c.str,type:(0,c.Option)(a)}),vt=(0,c.Vector)(Et),St=(0,c.Struct)({id:a,path:ee,params:vt,def:ht,docs:ee}),He=(0,c.Vector)(St);var i=require("scale-ts"),kt=(0,i.Enum)({Blake2128:i._void,Blake2256:i._void,Blake2128Concat:i._void,Twox128:i._void,Twox256:i._void,Twox64Concat:i._void,Identity:i._void}),wt=(0,i.Vector)(kt),Ct=(0,i.Struct)({hashers:wt,key:a,value:a}),Ut=(0,i.Struct)({name:i.str,modifier:i.u8,type:(0,i.Enum)({plain:a,map:Ct}),fallback:C(),docs:(0,i.Vector)(i.str)}),At=(0,i.Option)((0,i.Struct)({prefix:i.str,items:(0,i.Vector)(Ut)})),Re=(0,i.Vector)((0,i.Struct)({name:i.str,storage:At,calls:(0,i.Option)(a),events:(0,i.Option)(a),constants:(0,i.Vector)((0,i.Struct)({name:i.str,type:a,value:C(),docs:(0,i.Vector)(i.str)})),errors:(0,i.Option)(a),index:i.u8,docs:(0,i.Vector)(i.str)}));var Le=(0,u.Vector)(u.str),Kt=(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:Le})),docs:Le}),Vt=(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}))}),le=(0,u.Struct)({lookup:He,pallets:Re,extrinsic:Vt,type:a,apis:(0,u.Vector)(Kt),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:C()})))});var K=require("scale-ts");var _e=()=>{throw new Error("Unsupported metadata version!")},T=(0,K.createCodec)(_e,_e),Bt=(0,K.Struct)({magicNumber:K.u32,metadata:(0,K.Enum)({v0:T,v1:T,v2:T,v3:T,v4:T,v5:T,v6:T,v7:T,v8:T,v9:T,v10:T,v11:T,v12:T,v13:T,v14:T,v15:le})});var Ie=require("@polkadot-api/utils"),pe=require("@noble/hashes/blake2b"),Dt={dkLen:32},Ot=e=>(0,pe.blake2b)(e,Dt),Ht={dkLen:16},Ne=e=>(0,pe.blake2b)(e,Ht),fe=e=>(0,Ie.mergeUint8)(Ne(e),e);var xe=e=>e;var qe=require("@polkadot-api/utils"),We=require("scale-ts");var B=(e,t,n,d)=>new DataView(new Uint16Array([e,t,n,d]).buffer).getBigUint64(0,!0),ge=2n**64n-1n,g=(e,t)=>e<<t&ge|e>>64n-t,m=(e,t)=>e*t&ge,f=(e,t)=>e+t&ge,x=11400714785074694791n,h=14029467366897019727n,Pe=1609587929392839161n,W=9650029242287828579n,Me=2870177450012600261n;function U(e,t=0n){let n=f(f(t,x),h),d=f(t,h),y=t,E=t-x,S=e.length,k=0,D=null;(function(){let o=0,v=o+S;if(S){if(D=new Uint8Array(32),S<32){D.set(e.subarray(0,S),k),k+=S;return}if(o<=v-32){let _=v-32;do{let w;w=B(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=m(g(f(n,m(w,h)),31n),x),o+=8,w=B(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(f(d,m(w,h)),31n),x),o+=8,w=B(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=m(g(f(y,m(w,h)),31n),x),o+=8,w=B(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]),E=m(g(f(E,m(w,h)),31n),x),o+=8}while(o<=_)}o<v&&(D.set(e.subarray(o,v),k),k=v-o)}})(),e=D||e;let s,l=0;for(S>=32?(s=g(n,1n),s=f(s,g(d,7n)),s=f(s,g(y,12n)),s=f(s,g(E,18n)),n=m(g(m(n,h),31n),x),s=s^n,s=f(m(s,x),W),d=m(g(m(d,h),31n),x),s=s^d,s=f(m(s,x),W),y=m(g(m(y,h),31n),x),s=s^y,s=f(m(s,x),W),E=m(g(m(E,h),31n),x),s=s^E,s=f(m(s,x),W)):s=f(t,Me),s=f(s,BigInt(S));l<=k-8;){let b=B(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);b=m(g(m(b,h),31n),x),s=f(m(g(s^b,27n),x),W),l+=8}if(l+4<=k){let b=m(B(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),x);s=f(m(g(s^b,23n),h),Pe),l+=4}for(;l<k;){let b=m(B(e[l++],0,0,0),Me);s=m(g(s^b,11n),x)}let p=s>>33n;return s=m(s^p,h),p=s>>29n,s=m(s^p,Pe),p=s>>32n,s^=p,s}var te=e=>{let t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,U(e),!0),n.setBigUint64(8,U(e,1n),!0),t},Rt=e=>{let t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,U(e),!0),n.setBigUint64(8,U(e,1n),!0),n.setBigUint64(16,U(e,2n),!0),n.setBigUint64(24,U(e,3n),!0),t},Te=e=>(0,qe.mergeUint8)(We.u64.enc(U(e)),e);var L=require("@polkadot-api/utils");var $e=new TextEncoder,Lt=e=>{let t=te($e.encode(e));return(n,d,...y)=>{let E=(0,L.mergeUint8)(t,te($e.encode(n))),S=(0,L.toHex)(E),k=y.map(p=>p[1]).map(p=>p===xe?0:p===Te?8:p===fe?16:null).filter(Boolean),D=p=>{if(!p.startsWith(S))throw new Error(`key does not match this storage (${e}.${n})`);if(k.length!==y.length)throw new Error("Impossible to decode this key");if(y.length===0)return[];let b=p.slice(S.length),o=new Array(y.length);for(let v=0,_=0;v<k.length;v++){let w=y[v][0];_+=k[v],o[v]=w.dec(b.slice(_*2)),_+=w.enc(o[v]).length}return o},s=y.map(([{enc:p},b])=>o=>b(p(o)));return{enc:(...p)=>(0,L.toHex)((0,L.mergeUint8)(E,...p.map((b,o)=>s[o](b)))),dec:d,keyDecoder:D}}}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@polkadot-api/substrate-bindings", | ||
"version": "0.0.1-febf4f5005db6670d1963b033cd95c8b8f7d079b.1.0", | ||
"version": "0.0.1-fee5ecb6d09dea073f130fd2a58995907bd36c9c.1.0", | ||
"author": "Josep M Sobrepere (https://github.com/josepot)", | ||
@@ -45,4 +45,4 @@ "repository": { | ||
"@scure/base": "^1.1.1", | ||
"scale-ts": "^1.5.0", | ||
"@polkadot-api/utils": "0.0.1-febf4f5005db6670d1963b033cd95c8b8f7d079b.1.0" | ||
"scale-ts": "^1.6.0", | ||
"@polkadot-api/utils": "0.0.1-fee5ecb6d09dea073f130fd2a58995907bd36c9c.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
265457
3152