@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.
- package/LICENSE +674 -0
- package/README.md +1 -0
- package/dist/declarations/src/helpers/errors.d.ts +2 -0
- package/dist/declarations/src/helpers/getCallDocs.d.ts +2 -0
- package/dist/declarations/src/helpers/getChainInfo.d.ts +7 -0
- package/dist/declarations/src/helpers/getConstantValue.d.ts +2 -0
- package/dist/declarations/src/helpers/getDecodedCall.d.ts +11 -0
- package/dist/declarations/src/helpers/getDryRunCall.d.ts +11 -0
- package/dist/declarations/src/helpers/getExtrinsicDispatchInfo.d.ts +7 -0
- package/dist/declarations/src/helpers/getFeeEstimate.d.ts +3 -0
- package/dist/declarations/src/helpers/getPayloadWithMetadataHash.d.ts +6 -0
- package/dist/declarations/src/helpers/getRuntimeCallResult.d.ts +2 -0
- package/dist/declarations/src/helpers/getSapiConnector.d.ts +3 -0
- package/dist/declarations/src/helpers/getSendRequestResult.d.ts +2 -0
- package/dist/declarations/src/helpers/getSignerPayloadJSON.d.ts +7 -0
- package/dist/declarations/src/helpers/getStorageValue.d.ts +2 -0
- package/dist/declarations/src/helpers/getTypeRegistry.d.ts +4 -0
- package/dist/declarations/src/helpers/isApiAvailable.d.ts +2 -0
- package/dist/declarations/src/helpers/papi.d.ts +5 -0
- package/dist/declarations/src/helpers/types.d.ts +26 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/log.d.ts +2 -0
- package/dist/declarations/src/sapi.d.ts +50 -0
- package/dist/declarations/src/types.d.ts +18 -0
- package/dist/talismn-sapi.cjs.d.ts +1 -0
- package/dist/talismn-sapi.cjs.dev.js +535 -0
- package/dist/talismn-sapi.cjs.js +7 -0
- package/dist/talismn-sapi.cjs.prod.js +535 -0
- package/dist/talismn-sapi.esm.js +529 -0
- package/package.json +55 -0
|
@@ -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,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,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,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,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";
|