@talismn/scale 0.0.2 → 0.1.1
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/index.d.ts +2 -3
- package/dist/declarations/src/papito.d.ts +6 -0
- package/dist/declarations/src/util/compactMetadata.d.ts +24 -0
- package/dist/declarations/src/util/decodeMetadata.d.ts +13 -0
- package/dist/declarations/src/util/decodeScale.d.ts +4 -0
- package/dist/declarations/src/util/encodeMetadata.d.ts +8 -0
- package/dist/declarations/src/util/encodeStateKey.d.ts +4 -0
- package/dist/declarations/src/util/getMetadataVersion.d.ts +6 -0
- package/dist/declarations/src/util/index.d.ts +7 -0
- package/dist/declarations/src/util/serdePapi.d.ts +30 -0
- package/dist/talismn-scale.cjs.dev.js +338 -1691
- package/dist/talismn-scale.cjs.prod.js +338 -1691
- package/dist/talismn-scale.esm.js +305 -1618
- package/package.json +16 -20
- package/CHANGELOG.md +0 -15
- package/dist/declarations/src/capi/crypto/base58.d.ts +0 -18
- package/dist/declarations/src/capi/crypto/hashers.d.ts +0 -67
- package/dist/declarations/src/capi/crypto/index.d.ts +0 -3
- package/dist/declarations/src/capi/crypto/ss58.d.ts +0 -16
- package/dist/declarations/src/capi/crypto/util/index.d.ts +0 -4
- package/dist/declarations/src/capi/crypto/util/nosimd.d.ts +0 -19
- package/dist/declarations/src/capi/crypto/util/simd.d.ts +0 -1
- package/dist/declarations/src/capi/frame_metadata/Extrinsic.d.ts +0 -50
- package/dist/declarations/src/capi/frame_metadata/FrameMetadata.d.ts +0 -61
- package/dist/declarations/src/capi/frame_metadata/decodeMetadata.d.ts +0 -312
- package/dist/declarations/src/capi/frame_metadata/index.d.ts +0 -4
- package/dist/declarations/src/capi/frame_metadata/key_codecs.d.ts +0 -27
- package/dist/declarations/src/capi/frame_metadata/raw/v14.d.ts +0 -312
- package/dist/declarations/src/capi/index.d.ts +0 -4
- package/dist/declarations/src/capi/scale_info/index.d.ts +0 -4
- package/dist/declarations/src/capi/scale_info/overrides/ChainError.d.ts +0 -26
- package/dist/declarations/src/capi/scale_info/overrides/Era.d.ts +0 -33
- package/dist/declarations/src/capi/scale_info/overrides/index.d.ts +0 -1
- package/dist/declarations/src/capi/scale_info/overrides/overrides.d.ts +0 -23
- package/dist/declarations/src/capi/scale_info/raw/Ty.d.ts +0 -313
- package/dist/declarations/src/capi/scale_info/transformTys.d.ts +0 -34
- package/dist/declarations/src/capi/util/index.d.ts +0 -3
- package/dist/declarations/src/capi/util/key.d.ts +0 -22
- package/dist/declarations/src/capi/util/normalize.d.ts +0 -25
- package/dist/declarations/src/capi/util/state.d.ts +0 -25
- package/dist/declarations/src/metadata/index.d.ts +0 -2
- package/dist/declarations/src/metadata/util.d.ts +0 -10
- package/dist/declarations/src/storage/getShape.d.ts +0 -15
- package/dist/declarations/src/storage/getTypeName.d.ts +0 -25
- package/dist/declarations/src/storage/index.d.ts +0 -11
- package/dist/declarations/src/suppressPortableRegistryConsoleWarnings.d.ts +0 -1
- package/dist/nosimd-18c022ec.cjs.dev.js +0 -46
- package/dist/nosimd-8c31fb2d.esm.js +0 -43
- package/dist/nosimd-b32b4901.cjs.prod.js +0 -46
- package/dist/simd-133b8f48.cjs.prod.js +0 -14
- package/dist/simd-2ddb8d7c.cjs.dev.js +0 -14
- package/dist/simd-b794dbff.esm.js +0 -1
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./storage";
|
|
1
|
+
export * from "./papito";
|
|
2
|
+
export * from "./util";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getDynamicBuilder, getLookupFn } from "@polkadot-api/metadata-builders";
|
|
2
|
+
export type { V14, V15, V15Extrinsic, Codec, Binary } from "@polkadot-api/substrate-bindings";
|
|
3
|
+
export { toHex, fromHex } from "@polkadot-api/utils";
|
|
4
|
+
/** Constant: https://docs.substrate.io/build/application-development/#metadata-format */
|
|
5
|
+
export declare const magicNumber = 1635018093;
|
|
6
|
+
export { v14, v15, metadata } from "@polkadot-api/substrate-bindings";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { V14, V15 } from "../papito";
|
|
2
|
+
export type V14Type = V14["lookup"][0];
|
|
3
|
+
export type V14Pallet = V14["pallets"][0];
|
|
4
|
+
export type V14StorageItem = NonNullable<V14Pallet["storage"]>["items"][0];
|
|
5
|
+
export type V15Type = V15["lookup"][0];
|
|
6
|
+
export type V15Pallet = V15["pallets"][0];
|
|
7
|
+
export type V15StorageItem = NonNullable<V15Pallet["storage"]>["items"][0];
|
|
8
|
+
/**
|
|
9
|
+
* Converts a `Metadata` into a `MiniMetadata`.
|
|
10
|
+
*
|
|
11
|
+
* A `MiniMetadata` only contains the types inside of its `lookup` which are relevant for
|
|
12
|
+
* the storage queries specified in `palletsAndItems`.
|
|
13
|
+
*
|
|
14
|
+
* E.g. if `palletsAndItems` is `{ pallet: "System", items: ["Account"] }`, then only the
|
|
15
|
+
* types used in the `System.Account` storage query will remain inside of metadata.lookups.
|
|
16
|
+
*/
|
|
17
|
+
export declare const compactMetadata: (metadata: V15 | V14, palletsAndItems?: Array<{
|
|
18
|
+
pallet: string;
|
|
19
|
+
constants?: string[];
|
|
20
|
+
items: string[];
|
|
21
|
+
}>, runtimeApisAndMethods?: Array<{
|
|
22
|
+
runtimeApi: string;
|
|
23
|
+
methods: string[];
|
|
24
|
+
}>, extraKeepTypes?: number[]) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { V14, V15 } from "@polkadot-api/substrate-bindings";
|
|
2
|
+
export declare const decodeMetadata: (metadataRpc: string) => {
|
|
3
|
+
metadataVersion: number;
|
|
4
|
+
} & ({
|
|
5
|
+
metadata: V15;
|
|
6
|
+
tag: "v15";
|
|
7
|
+
} | {
|
|
8
|
+
metadata: V14;
|
|
9
|
+
tag: "v14";
|
|
10
|
+
} | {
|
|
11
|
+
metadata?: undefined;
|
|
12
|
+
tag?: undefined;
|
|
13
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getDynamicBuilder } from "@polkadot-api/metadata-builders";
|
|
2
|
+
type ScaleStorageCoder = ReturnType<ReturnType<typeof getDynamicBuilder>["buildStorage"]>;
|
|
3
|
+
export declare const decodeScale: <T>(scaleCoder: ScaleStorageCoder | undefined, change: string | null, error?: string) => T | null;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getDynamicBuilder } from "@polkadot-api/metadata-builders";
|
|
2
|
+
type ScaleStorageCoder = ReturnType<ReturnType<typeof getDynamicBuilder>["buildStorage"]>;
|
|
3
|
+
export declare const encodeStateKey: (scaleCoder: ScaleStorageCoder | undefined, error?: string, ...args: any[]) => string | undefined;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For the substrate-tokens (and other) modules, we configure the `onChainId` field in chaindata to tell the module how to query each token.
|
|
3
|
+
* These queries are made to the tokens pallet.
|
|
4
|
+
* E.g. api.query.Tokens.Account(accountAddress, papiParse(onChainId))
|
|
5
|
+
*
|
|
6
|
+
* The `onChainId` field on chaindata must be a JSON-parseable string, but for some SCALE types (especially the Binary type) we must
|
|
7
|
+
* use specific `polkadot-api` classes to handle SCALE-encoding the statekey.
|
|
8
|
+
*
|
|
9
|
+
* Some examples:
|
|
10
|
+
* Input: `5`
|
|
11
|
+
* Output: `5`
|
|
12
|
+
*
|
|
13
|
+
* Input: `{ type: "DexShare", value: [ { type: "Token", value: { type: "ACA" } }, { type: "Token", value: { type: "AUSD" } } ] }`
|
|
14
|
+
* Output: `Enum("DexShare", [Enum("Token", Enum("ACA")), Enum("Token", Enum("AUSD"))])`
|
|
15
|
+
*
|
|
16
|
+
* Input: `{ type: "LiquidCrowdloan", value: 13 }`
|
|
17
|
+
* Output: `Enum("LiquidCrowdloan", 13)`
|
|
18
|
+
*
|
|
19
|
+
* Input: `{ type: "NativeToken", value: "bigint:2" }`
|
|
20
|
+
* Output: `Enum("NativeToken", 2n)`
|
|
21
|
+
*
|
|
22
|
+
* Input: `{ type: "Erc20", value: "hex:0x07df96d1341a7d16ba1ad431e2c847d978bc2bce" }`
|
|
23
|
+
* Output: `Enum("Erc20", Binary.fromHex("0x07df96d1341a7d16ba1ad431e2c847d978bc2bce"))`
|
|
24
|
+
*
|
|
25
|
+
* Input: `{ type: "Stellar", value: { code: "bin:TZS", issuer: "hex:0x34c94b2a4ba9e8b57b22547dcbb30f443c4cb02da3829a89aa1bd4780e4466ba" } }`
|
|
26
|
+
* Output: `Enum("Stellar", { code: Binary.fromText("TZS"), issuer: Binary.fromHex("0x34c94b2a4ba9e8b57b22547dcbb30f443c4cb02da3829a89aa1bd4780e4466ba") })`
|
|
27
|
+
*/
|
|
28
|
+
export declare const papiParse: <T = unknown>(text: string | T) => T;
|
|
29
|
+
export declare const papiStringify: (value: any, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
30
|
+
space?: string | number) => string;
|