@talismn/sapi 0.0.0-pr1876-20250414012202

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.
Files changed (30) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +1 -0
  3. package/dist/declarations/src/helpers/errors.d.ts +2 -0
  4. package/dist/declarations/src/helpers/getCallDocs.d.ts +2 -0
  5. package/dist/declarations/src/helpers/getChainInfo.d.ts +7 -0
  6. package/dist/declarations/src/helpers/getConstantValue.d.ts +2 -0
  7. package/dist/declarations/src/helpers/getDecodedCall.d.ts +11 -0
  8. package/dist/declarations/src/helpers/getDryRunCall.d.ts +11 -0
  9. package/dist/declarations/src/helpers/getExtrinsicDispatchInfo.d.ts +7 -0
  10. package/dist/declarations/src/helpers/getFeeEstimate.d.ts +3 -0
  11. package/dist/declarations/src/helpers/getPayloadWithMetadataHash.d.ts +6 -0
  12. package/dist/declarations/src/helpers/getRuntimeCallResult.d.ts +2 -0
  13. package/dist/declarations/src/helpers/getSapiConnector.d.ts +3 -0
  14. package/dist/declarations/src/helpers/getSendRequestResult.d.ts +2 -0
  15. package/dist/declarations/src/helpers/getSignerPayloadJSON.d.ts +7 -0
  16. package/dist/declarations/src/helpers/getStorageValue.d.ts +2 -0
  17. package/dist/declarations/src/helpers/getTypeRegistry.d.ts +4 -0
  18. package/dist/declarations/src/helpers/isApiAvailable.d.ts +2 -0
  19. package/dist/declarations/src/helpers/papi.d.ts +5 -0
  20. package/dist/declarations/src/helpers/types.d.ts +26 -0
  21. package/dist/declarations/src/index.d.ts +2 -0
  22. package/dist/declarations/src/log.d.ts +2 -0
  23. package/dist/declarations/src/sapi.d.ts +50 -0
  24. package/dist/declarations/src/types.d.ts +18 -0
  25. package/dist/talismn-sapi.cjs.d.ts +1 -0
  26. package/dist/talismn-sapi.cjs.dev.js +535 -0
  27. package/dist/talismn-sapi.cjs.js +7 -0
  28. package/dist/talismn-sapi.cjs.prod.js +535 -0
  29. package/dist/talismn-sapi.esm.js +529 -0
  30. package/package.json +55 -0
@@ -0,0 +1,2 @@
1
+ import { Chain } from "./types";
2
+ export declare const getCallDocs: (chain: Chain, pallet: string, method: string) => string | null;
@@ -0,0 +1,7 @@
1
+ import { Chain } from "./types";
2
+ export declare const getChainInfo: (chain: Chain) => {
3
+ specName: string;
4
+ specVersion: number;
5
+ transactionVersion: number;
6
+ base58Prefix: number;
7
+ };
@@ -0,0 +1,2 @@
1
+ import { Chain } from "./types";
2
+ export declare const getConstantValue: <T>(chain: Chain, pallet: string, constant: string) => T;
@@ -0,0 +1,11 @@
1
+ import { SignerPayloadJSON } from "@polkadot/types/types";
2
+ import { DecodedCall } from "../types";
3
+ import { Chain } from "./types";
4
+ export declare const getDecodedCall: (palletName: string, methodName: string, args: unknown) => {
5
+ type: string;
6
+ value: {
7
+ type: string;
8
+ value: unknown;
9
+ };
10
+ };
11
+ export declare const getDecodedCallFromPayload: <Res extends DecodedCall>(chain: Chain, payload: SignerPayloadJSON) => Res;
@@ -0,0 +1,11 @@
1
+ import { DecodedCall } from "../types";
2
+ import { Chain } from "./types";
3
+ export declare const getDryRunCall: <T>(chain: Chain, from: string, decodedCall: DecodedCall<unknown>) => Promise<{
4
+ available: false;
5
+ data: null;
6
+ } | {
7
+ available: true;
8
+ data: T;
9
+ ok: boolean;
10
+ errorMessage: string | null;
11
+ }>;
@@ -0,0 +1,7 @@
1
+ import { GenericExtrinsic } from "@polkadot/types";
2
+ import { Chain } from "./types";
3
+ type ExtrinsicDispatchInfo = {
4
+ partialFee: string;
5
+ };
6
+ export declare const getExtrinsicDispatchInfo: (chain: Chain, signedExtrinsic: GenericExtrinsic) => Promise<ExtrinsicDispatchInfo>;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ import { SignerPayloadJSON } from "@polkadot/types/types";
2
+ import { Chain, ChainInfo } from "./types";
3
+ export declare const getFeeEstimate: (chain: Chain, payload: SignerPayloadJSON, chainInfo: ChainInfo) => Promise<bigint>;
@@ -0,0 +1,6 @@
1
+ import { SignerPayloadJSON } from "@polkadot/types/types";
2
+ import { Chain, ChainInfo } from "./types";
3
+ export declare const getPayloadWithMetadataHash: (chain: Chain, chainInfo: ChainInfo, payload: SignerPayloadJSON) => {
4
+ payload: SignerPayloadJSON;
5
+ txMetadata?: Uint8Array;
6
+ };
@@ -0,0 +1,2 @@
1
+ import { Chain } from "./types";
2
+ export declare const getRuntimeCallResult: <T>(chain: Chain, apiName: string, method: string, args: unknown[]) => Promise<T>;
@@ -0,0 +1,3 @@
1
+ import { SapiConnectorProps } from "../types";
2
+ export type SapiConnector = Required<SapiConnectorProps>;
3
+ export declare const getSapiConnector: ({ chainId, send, submit }: SapiConnectorProps) => SapiConnector;
@@ -0,0 +1,2 @@
1
+ import { Chain } from "./types";
2
+ export declare const getSendRequestResult: <Res>(chain: Chain, method: string, params: unknown[], isCacheable?: boolean) => Promise<Res>;
@@ -0,0 +1,7 @@
1
+ import { SignerPayloadJSON } from "@polkadot/types/types";
2
+ import { PayloadSignerConfig } from "../types";
3
+ import { Chain, ChainInfo } from "./types";
4
+ export declare const getSignerPayloadJSON: (chain: Chain, palletName: string, methodName: string, args: unknown, signerConfig: PayloadSignerConfig, chainInfo: ChainInfo) => Promise<{
5
+ payload: SignerPayloadJSON;
6
+ txMetadata?: Uint8Array;
7
+ }>;
@@ -0,0 +1,2 @@
1
+ import { Chain } from "./types";
2
+ export declare const getStorageValue: <T>(chain: Chain, pallet: string, entry: string, keys: unknown[], at?: string) => Promise<T>;
@@ -0,0 +1,4 @@
1
+ import { TypeRegistry } from "@polkadot/types";
2
+ import { SignerPayloadJSON } from "@polkadot/types/types";
3
+ import { Chain } from "./types";
4
+ export declare const getTypeRegistry: (chain: Chain, payload: SignerPayloadJSON) => TypeRegistry;
@@ -0,0 +1,2 @@
1
+ import { Chain } from "./types";
2
+ export declare const isApiAvailable: (chain: Chain, name: string, method: string) => boolean;
@@ -0,0 +1,5 @@
1
+ export declare const toPjsHex: (value: number | bigint, minByteLen?: number) => `0x${string}`;
2
+ export declare const mortal: import("@polkadot-api/substrate-bindings").Encoder<{
3
+ period: number;
4
+ phase: number;
5
+ }>;
@@ -0,0 +1,26 @@
1
+ import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
2
+ import { getDynamicBuilder, getLookupFn, V14, V15 } from "@talismn/scale";
3
+ import { SapiConnector } from "./getSapiConnector";
4
+ export type ScaleMetadata = V14 | V15;
5
+ export type ScaleBuilder = ReturnType<typeof getDynamicBuilder>;
6
+ export type ScaleLookup = ReturnType<typeof getLookupFn>;
7
+ export type Chain = {
8
+ connector: SapiConnector;
9
+ hexMetadata: `0x${string}`;
10
+ token: {
11
+ symbol: string;
12
+ decimals: number;
13
+ };
14
+ hasCheckMetadataHash?: boolean;
15
+ signedExtensions?: ExtDef;
16
+ registryTypes?: unknown;
17
+ metadata: ScaleMetadata;
18
+ lookup: ScaleLookup;
19
+ builder: ScaleBuilder;
20
+ };
21
+ export type ChainInfo = {
22
+ specName: string;
23
+ specVersion: number;
24
+ transactionVersion: number;
25
+ base58Prefix: number;
26
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export * from "./sapi";
@@ -0,0 +1,2 @@
1
+ declare const _default: import("anylogger").Logger<import("anylogger").BaseLevels>;
2
+ export default _default;
@@ -0,0 +1,50 @@
1
+ import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
2
+ import { SignerPayloadJSON } from "@polkadot/types/types";
3
+ import { DecodedCall, PayloadSignerConfig, SapiConnectorProps } from "./types";
4
+ export type ScaleApi = NonNullable<ReturnType<typeof getScaleApi>>;
5
+ export declare const getScaleApi: (connector: SapiConnectorProps, hexMetadata: `0x${string}`, token: {
6
+ symbol: string;
7
+ decimals: number;
8
+ }, hasCheckMetadataHash?: boolean, signedExtensions?: ExtDef, registryTypes?: unknown) => {
9
+ id: string;
10
+ chainId: string;
11
+ specName: string;
12
+ specVersion: number;
13
+ hasCheckMetadataHash: boolean | undefined;
14
+ base58Prefix: number;
15
+ token: {
16
+ symbol: string;
17
+ decimals: number;
18
+ };
19
+ getConstant: <T>(pallet: string, constant: string) => T;
20
+ getStorage: <T>(pallet: string, entry: string, keys: unknown[], at?: string) => Promise<T>;
21
+ getDecodedCall: (pallet: string, method: string, args: unknown) => {
22
+ type: string;
23
+ value: {
24
+ type: string;
25
+ value: unknown;
26
+ };
27
+ };
28
+ getDecodedCallFromPayload: <Res extends DecodedCall>(payload: SignerPayloadJSON) => Res;
29
+ getExtrinsicPayload: (pallet: string, method: string, args: unknown, config: PayloadSignerConfig) => Promise<{
30
+ payload: SignerPayloadJSON;
31
+ txMetadata?: Uint8Array;
32
+ }>;
33
+ getFeeEstimate: (payload: SignerPayloadJSON) => Promise<bigint>;
34
+ getRuntimeCallValue: <T>(apiName: string, method: string, args: unknown[]) => Promise<T>;
35
+ getTypeRegistry: (payload: SignerPayloadJSON) => import("@polkadot/types").TypeRegistry;
36
+ submit: (payload: SignerPayloadJSON, signature?: `0x${string}`) => Promise<{
37
+ hash: `0x${string}`;
38
+ }>;
39
+ getCallDocs: (pallet: string, method: string) => string | null;
40
+ getDryRunCall: <T>(from: string, decodedCall: DecodedCall<unknown>) => Promise<{
41
+ available: false;
42
+ data: null;
43
+ } | {
44
+ available: true;
45
+ data: T;
46
+ ok: boolean;
47
+ errorMessage: string | null;
48
+ }>;
49
+ isApiAvailable: (name: string, method: string) => boolean;
50
+ };
@@ -0,0 +1,18 @@
1
+ import { SignerPayloadJSON } from "@polkadot/types/types";
2
+ export type DecodedCall<Args = any> = {
3
+ pallet: string;
4
+ method: string;
5
+ args: Args;
6
+ };
7
+ export type PayloadSignerConfig = {
8
+ address: string;
9
+ tip?: bigint;
10
+ };
11
+ export type JsonRpcRequestSend = (method: string, params: unknown[], isCacheable?: boolean) => Promise<unknown>;
12
+ export type SapiConnectorProps = {
13
+ chainId: string;
14
+ send: JsonRpcRequestSend;
15
+ submit?: (payload: SignerPayloadJSON, signature?: `0x${string}`) => Promise<{
16
+ hash: `0x${string}`;
17
+ }>;
18
+ };
@@ -0,0 +1 @@
1
+ export * from "./declarations/src/index";