@talismn/scale 0.0.0-pr2277-20251211071316 → 0.0.0-pr2295-20260110044132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{declarations/src/util/parseMetadataRpc.d.ts → index.d.mts} +124 -32
- package/dist/index.d.ts +927 -0
- package/dist/index.js +503 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +456 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +21 -10
- package/dist/declarations/src/index.d.ts +0 -2
- package/dist/declarations/src/log.d.ts +0 -2
- package/dist/declarations/src/papito.d.ts +0 -8
- package/dist/declarations/src/util/Prettify.d.ts +0 -3
- package/dist/declarations/src/util/compactMetadata.d.ts +0 -26
- package/dist/declarations/src/util/decodeScale.d.ts +0 -4
- package/dist/declarations/src/util/encodeMetadata.d.ts +0 -2
- package/dist/declarations/src/util/encodeStateKey.d.ts +0 -3
- package/dist/declarations/src/util/getConstantValueFromMetadata.d.ts +0 -5
- package/dist/declarations/src/util/getMetadataVersion.d.ts +0 -6
- package/dist/declarations/src/util/getStorageKeyPrefix.d.ts +0 -1
- package/dist/declarations/src/util/hash.d.ts +0 -1
- package/dist/declarations/src/util/index.d.ts +0 -10
- package/dist/declarations/src/util/serdePapi.d.ts +0 -30
- package/dist/talismn-scale.cjs.d.ts +0 -1
- package/dist/talismn-scale.cjs.dev.js +0 -495
- package/dist/talismn-scale.cjs.js +0 -7
- package/dist/talismn-scale.cjs.prod.js +0 -495
- package/dist/talismn-scale.esm.js +0 -410
|
@@ -1,4 +1,87 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _polkadot_api_metadata_builders from '@polkadot-api/metadata-builders';
|
|
2
|
+
import { getDynamicBuilder } from '@polkadot-api/metadata-builders';
|
|
3
|
+
export { MetadataLookup, getDynamicBuilder, getLookupFn } from '@polkadot-api/metadata-builders';
|
|
4
|
+
import * as _polkadot_api_substrate_bindings from '@polkadot-api/substrate-bindings';
|
|
5
|
+
import { Metadata, UnifiedMetadata } from '@polkadot-api/substrate-bindings';
|
|
6
|
+
export { Binary, Blake2128, Blake2128Concat, Blake2256, Blake3256, Blake3256Concat, Codec, FixedSizeBinary, Twox128, Twox256, Twox64Concat, UnifiedMetadata, decAnyMetadata, metadata, unifyMetadata } from '@polkadot-api/substrate-bindings';
|
|
7
|
+
export { fromHex, mergeUint8, toHex } from '@polkadot-api/utils';
|
|
8
|
+
|
|
9
|
+
/** Constant: https://docs.substrate.io/build/application-development/#metadata-format */
|
|
10
|
+
declare const magicNumber = 1635018093;
|
|
11
|
+
type MetadataBuilder = ReturnType<typeof getDynamicBuilder>;
|
|
12
|
+
|
|
13
|
+
type MetadataType = SupportedMetadata["lookup"][number];
|
|
14
|
+
type MetadataPallet = SupportedMetadata["pallets"][number];
|
|
15
|
+
type MetadataStorageItem = NonNullable<MetadataPallet["storage"]>["items"][number];
|
|
16
|
+
type SupportedMetadata = Extract<Metadata["metadata"], {
|
|
17
|
+
tag: SupportedMetadataVersion;
|
|
18
|
+
}>["value"];
|
|
19
|
+
type SupportedMetadataVersion = "v14" | "v15" | "v16";
|
|
20
|
+
/**
|
|
21
|
+
* Converts a `Metadata` into a `MiniMetadata`.
|
|
22
|
+
*
|
|
23
|
+
* A `MiniMetadata` only contains the types inside of its `lookup` which are relevant for
|
|
24
|
+
* the storage queries specified in `palletsAndItems`.
|
|
25
|
+
*
|
|
26
|
+
* E.g. if `palletsAndItems` is `{ pallet: "System", items: ["Account"] }`, then only the
|
|
27
|
+
* types used in the `System.Account` storage query will remain inside of metadata.lookups.
|
|
28
|
+
*/
|
|
29
|
+
declare const compactMetadata: (anyMetadata: Metadata, palletsAndItems?: Array<{
|
|
30
|
+
pallet: string;
|
|
31
|
+
constants?: string[];
|
|
32
|
+
items: string[];
|
|
33
|
+
}>, runtimeApisAndMethods?: Array<{
|
|
34
|
+
runtimeApi: string;
|
|
35
|
+
methods: string[];
|
|
36
|
+
}>, extraKeepTypes?: number[]) => void;
|
|
37
|
+
|
|
38
|
+
type ScaleStorageCoder$1 = ReturnType<MetadataBuilder["buildStorage"]>;
|
|
39
|
+
declare const decodeScale: <T>(scaleCoder: ScaleStorageCoder$1 | undefined, change: string | null, error?: string) => T | null;
|
|
40
|
+
|
|
41
|
+
declare const encodeMetadata: (metadata: Metadata) => `0x${string}`;
|
|
42
|
+
|
|
43
|
+
type ScaleStorageCoder = ReturnType<MetadataBuilder["buildStorage"]>;
|
|
44
|
+
declare const encodeStateKey: (scaleCoder: ScaleStorageCoder | undefined, error?: string, ...args: any[]) => `0x${string}` | undefined;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Extracts the `version` u8 from a SCALE-encoded metadata blob and returns it as a `number`.
|
|
48
|
+
*
|
|
49
|
+
* Only reads the first 40 bytes of the blob.
|
|
50
|
+
*/
|
|
51
|
+
declare const getMetadataVersion: (metadataRpc: string | Uint8Array | ArrayBuffer) => number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* For the substrate-tokens (and other) modules, we configure the `onChainId` field in chaindata to tell the module how to query each token.
|
|
55
|
+
* These queries are made to the tokens pallet.
|
|
56
|
+
* E.g. api.query.Tokens.Account(accountAddress, papiParse(onChainId))
|
|
57
|
+
*
|
|
58
|
+
* The `onChainId` field on chaindata must be a JSON-parseable string, but for some SCALE types (especially the Binary type) we must
|
|
59
|
+
* use specific `polkadot-api` classes to handle SCALE-encoding the statekey.
|
|
60
|
+
*
|
|
61
|
+
* Some examples:
|
|
62
|
+
* Input: `5`
|
|
63
|
+
* Output: `5`
|
|
64
|
+
*
|
|
65
|
+
* Input: `{ type: "DexShare", value: [ { type: "Token", value: { type: "ACA" } }, { type: "Token", value: { type: "AUSD" } } ] }`
|
|
66
|
+
* Output: `Enum("DexShare", [Enum("Token", Enum("ACA")), Enum("Token", Enum("AUSD"))])`
|
|
67
|
+
*
|
|
68
|
+
* Input: `{ type: "LiquidCrowdloan", value: 13 }`
|
|
69
|
+
* Output: `Enum("LiquidCrowdloan", 13)`
|
|
70
|
+
*
|
|
71
|
+
* Input: `{ type: "NativeToken", value: "bigint:2" }`
|
|
72
|
+
* Output: `Enum("NativeToken", 2n)`
|
|
73
|
+
*
|
|
74
|
+
* Input: `{ type: "Erc20", value: "hex:0x07df96d1341a7d16ba1ad431e2c847d978bc2bce" }`
|
|
75
|
+
* Output: `Enum("Erc20", Binary.fromHex("0x07df96d1341a7d16ba1ad431e2c847d978bc2bce"))`
|
|
76
|
+
*
|
|
77
|
+
* Input: `{ type: "Stellar", value: { code: "bin:TZS", issuer: "hex:0x34c94b2a4ba9e8b57b22547dcbb30f443c4cb02da3829a89aa1bd4780e4466ba" } }`
|
|
78
|
+
* Output: `Enum("Stellar", { code: Binary.fromText("TZS"), issuer: Binary.fromHex("0x34c94b2a4ba9e8b57b22547dcbb30f443c4cb02da3829a89aa1bd4780e4466ba") })`
|
|
79
|
+
*/
|
|
80
|
+
declare const papiParse: <T = unknown>(text: string | T) => T;
|
|
81
|
+
declare const papiStringify: (value: any, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
82
|
+
space?: string | number) => string;
|
|
83
|
+
|
|
84
|
+
declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
2
85
|
metadata: {
|
|
3
86
|
magicNumber: number;
|
|
4
87
|
metadata: {
|
|
@@ -186,7 +269,7 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
186
269
|
tag: "plain";
|
|
187
270
|
value: number;
|
|
188
271
|
};
|
|
189
|
-
fallback:
|
|
272
|
+
fallback: _polkadot_api_substrate_bindings.HexString;
|
|
190
273
|
docs: string[];
|
|
191
274
|
}[];
|
|
192
275
|
} | undefined;
|
|
@@ -195,7 +278,7 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
195
278
|
constants: {
|
|
196
279
|
name: string;
|
|
197
280
|
type: number;
|
|
198
|
-
value:
|
|
281
|
+
value: _polkadot_api_substrate_bindings.HexString;
|
|
199
282
|
docs: string[];
|
|
200
283
|
}[];
|
|
201
284
|
errors: number | undefined;
|
|
@@ -395,7 +478,7 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
395
478
|
tag: "plain";
|
|
396
479
|
value: number;
|
|
397
480
|
};
|
|
398
|
-
fallback:
|
|
481
|
+
fallback: _polkadot_api_substrate_bindings.HexString;
|
|
399
482
|
docs: string[];
|
|
400
483
|
}[];
|
|
401
484
|
} | undefined;
|
|
@@ -404,7 +487,7 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
404
487
|
constants: {
|
|
405
488
|
name: string;
|
|
406
489
|
type: number;
|
|
407
|
-
value:
|
|
490
|
+
value: _polkadot_api_substrate_bindings.HexString;
|
|
408
491
|
docs: string[];
|
|
409
492
|
}[];
|
|
410
493
|
errors: number | undefined;
|
|
@@ -443,7 +526,7 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
443
526
|
};
|
|
444
527
|
custom: [string, {
|
|
445
528
|
type: number;
|
|
446
|
-
value:
|
|
529
|
+
value: _polkadot_api_substrate_bindings.HexString;
|
|
447
530
|
}][];
|
|
448
531
|
};
|
|
449
532
|
} | {
|
|
@@ -601,7 +684,7 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
601
684
|
tag: "plain";
|
|
602
685
|
value: number;
|
|
603
686
|
};
|
|
604
|
-
fallback:
|
|
687
|
+
fallback: _polkadot_api_substrate_bindings.HexString;
|
|
605
688
|
docs: string[];
|
|
606
689
|
}[];
|
|
607
690
|
} | undefined;
|
|
@@ -640,7 +723,7 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
640
723
|
constants: {
|
|
641
724
|
name: string;
|
|
642
725
|
type: number;
|
|
643
|
-
value:
|
|
726
|
+
value: _polkadot_api_substrate_bindings.HexString;
|
|
644
727
|
docs: string[];
|
|
645
728
|
deprecationInfo: {
|
|
646
729
|
tag: "NotDeprecated";
|
|
@@ -698,7 +781,7 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
698
781
|
}[];
|
|
699
782
|
output: number;
|
|
700
783
|
docs: string[];
|
|
701
|
-
id:
|
|
784
|
+
id: _polkadot_api_substrate_bindings.HexString;
|
|
702
785
|
}[];
|
|
703
786
|
index: number;
|
|
704
787
|
docs: string[];
|
|
@@ -775,61 +858,70 @@ export declare const parseMetadataRpc: (metadataRpc: `0x${string}`) => {
|
|
|
775
858
|
};
|
|
776
859
|
custom: [string, {
|
|
777
860
|
type: number;
|
|
778
|
-
value:
|
|
861
|
+
value: _polkadot_api_substrate_bindings.HexString;
|
|
779
862
|
}][];
|
|
780
863
|
};
|
|
781
864
|
};
|
|
782
865
|
};
|
|
783
|
-
unifiedMetadata:
|
|
784
|
-
lookupFn:
|
|
866
|
+
unifiedMetadata: _polkadot_api_substrate_bindings.UnifiedMetadata<14 | 15 | 16>;
|
|
867
|
+
lookupFn: _polkadot_api_metadata_builders.MetadataLookup;
|
|
785
868
|
builder: {
|
|
786
|
-
buildDefinition: (id: number) =>
|
|
869
|
+
buildDefinition: (id: number) => _polkadot_api_substrate_bindings.Codec<any>;
|
|
787
870
|
buildStorage: (pallet: string, entry: string) => {
|
|
788
|
-
args: [
|
|
789
|
-
enc:
|
|
790
|
-
dec:
|
|
871
|
+
args: [_polkadot_api_substrate_bindings.Encoder<any[]>, _polkadot_api_substrate_bindings.Decoder<any[]>] & {
|
|
872
|
+
enc: _polkadot_api_substrate_bindings.Encoder<any[]>;
|
|
873
|
+
dec: _polkadot_api_substrate_bindings.Decoder<any[]>;
|
|
791
874
|
} & {
|
|
792
|
-
inner:
|
|
875
|
+
inner: _polkadot_api_substrate_bindings.Codec<any>[];
|
|
793
876
|
};
|
|
794
877
|
keys: {
|
|
795
878
|
enc: (...args: any[]) => string;
|
|
796
879
|
dec: (value: string) => any[];
|
|
797
880
|
};
|
|
798
|
-
value:
|
|
881
|
+
value: _polkadot_api_substrate_bindings.Codec<any>;
|
|
799
882
|
len: number;
|
|
800
883
|
fallback: any;
|
|
801
884
|
};
|
|
802
885
|
buildEvent: (pallet: string, name: string) => {
|
|
803
|
-
codec:
|
|
886
|
+
codec: _polkadot_api_substrate_bindings.Codec<any>;
|
|
804
887
|
location: [number, number];
|
|
805
888
|
};
|
|
806
889
|
buildError: (pallet: string, name: string) => {
|
|
807
|
-
codec:
|
|
890
|
+
codec: _polkadot_api_substrate_bindings.Codec<any>;
|
|
808
891
|
location: [number, number];
|
|
809
892
|
};
|
|
810
893
|
buildViewFn: (pallet: string, entry: string) => {
|
|
811
|
-
args: [
|
|
812
|
-
enc:
|
|
813
|
-
dec:
|
|
894
|
+
args: [_polkadot_api_substrate_bindings.Encoder<any[]>, _polkadot_api_substrate_bindings.Decoder<any[]>] & {
|
|
895
|
+
enc: _polkadot_api_substrate_bindings.Encoder<any[]>;
|
|
896
|
+
dec: _polkadot_api_substrate_bindings.Decoder<any[]>;
|
|
814
897
|
} & {
|
|
815
|
-
inner:
|
|
898
|
+
inner: _polkadot_api_substrate_bindings.Codec<any>[];
|
|
816
899
|
};
|
|
817
|
-
value:
|
|
900
|
+
value: _polkadot_api_substrate_bindings.Codec<any>;
|
|
818
901
|
};
|
|
819
902
|
buildRuntimeCall: (api: string, method: string) => {
|
|
820
|
-
args: [
|
|
821
|
-
enc:
|
|
822
|
-
dec:
|
|
903
|
+
args: [_polkadot_api_substrate_bindings.Encoder<any[]>, _polkadot_api_substrate_bindings.Decoder<any[]>] & {
|
|
904
|
+
enc: _polkadot_api_substrate_bindings.Encoder<any[]>;
|
|
905
|
+
dec: _polkadot_api_substrate_bindings.Decoder<any[]>;
|
|
823
906
|
} & {
|
|
824
|
-
inner:
|
|
907
|
+
inner: _polkadot_api_substrate_bindings.Codec<any>[];
|
|
825
908
|
};
|
|
826
|
-
value:
|
|
909
|
+
value: _polkadot_api_substrate_bindings.Codec<any>;
|
|
827
910
|
};
|
|
828
911
|
buildCall: (pallet: string, name: string) => {
|
|
829
|
-
codec:
|
|
912
|
+
codec: _polkadot_api_substrate_bindings.Codec<any>;
|
|
830
913
|
location: [number, number];
|
|
831
914
|
};
|
|
832
|
-
buildConstant: (pallet: string, constantName: string) =>
|
|
915
|
+
buildConstant: (pallet: string, constantName: string) => _polkadot_api_substrate_bindings.Codec<any>;
|
|
833
916
|
ss58Prefix: number | undefined;
|
|
834
917
|
};
|
|
835
918
|
};
|
|
919
|
+
|
|
920
|
+
declare const getStorageKeyPrefix: (palletName: string, storageName: string) => string;
|
|
921
|
+
|
|
922
|
+
declare const getConstantValueFromMetadata: <T>(metadata: `0x${string}` | {
|
|
923
|
+
builder: MetadataBuilder;
|
|
924
|
+
unifiedMetadata: UnifiedMetadata;
|
|
925
|
+
}, pallet: string, constant: string) => T;
|
|
926
|
+
|
|
927
|
+
export { type MetadataBuilder, type MetadataPallet, type MetadataStorageItem, type MetadataType, type ScaleStorageCoder, compactMetadata, decodeScale, encodeMetadata, encodeStateKey, getConstantValueFromMetadata, getMetadataVersion, getStorageKeyPrefix, magicNumber, papiParse, papiStringify, parseMetadataRpc };
|