@talismn/sapi 0.0.0-pr2277-20251211071316 → 0.0.0-pr2295-20260110031023

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 (36) hide show
  1. package/dist/index.d.mts +111 -0
  2. package/dist/index.d.ts +111 -0
  3. package/dist/index.js +658 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +619 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +21 -7
  8. package/dist/declarations/src/fetchBestMetadata.d.ts +0 -10
  9. package/dist/declarations/src/helpers/errors.d.ts +0 -2
  10. package/dist/declarations/src/helpers/getCallDocs.d.ts +0 -2
  11. package/dist/declarations/src/helpers/getChainInfo.d.ts +0 -7
  12. package/dist/declarations/src/helpers/getConstantValue.d.ts +0 -2
  13. package/dist/declarations/src/helpers/getDecodedCall.d.ts +0 -13
  14. package/dist/declarations/src/helpers/getDryRunCall.d.ts +0 -13
  15. package/dist/declarations/src/helpers/getExtrinsicDispatchInfo.d.ts +0 -7
  16. package/dist/declarations/src/helpers/getFeeEstimate.d.ts +0 -3
  17. package/dist/declarations/src/helpers/getPayloadWithMetadataHash.d.ts +0 -6
  18. package/dist/declarations/src/helpers/getRuntimeCallResult.d.ts +0 -2
  19. package/dist/declarations/src/helpers/getSapiConnector.d.ts +0 -3
  20. package/dist/declarations/src/helpers/getSendRequestResult.d.ts +0 -2
  21. package/dist/declarations/src/helpers/getSignerPayloadJSON.d.ts +0 -8
  22. package/dist/declarations/src/helpers/getStorageValue.d.ts +0 -2
  23. package/dist/declarations/src/helpers/getTypeRegistry.d.ts +0 -4
  24. package/dist/declarations/src/helpers/isApiAvailable.d.ts +0 -2
  25. package/dist/declarations/src/helpers/papi.d.ts +0 -5
  26. package/dist/declarations/src/helpers/submit.d.ts +0 -6
  27. package/dist/declarations/src/helpers/types.d.ts +0 -24
  28. package/dist/declarations/src/index.d.ts +0 -3
  29. package/dist/declarations/src/log.d.ts +0 -2
  30. package/dist/declarations/src/sapi.d.ts +0 -58
  31. package/dist/declarations/src/types.d.ts +0 -21
  32. package/dist/talismn-sapi.cjs.d.ts +0 -1
  33. package/dist/talismn-sapi.cjs.dev.js +0 -601
  34. package/dist/talismn-sapi.cjs.js +0 -7
  35. package/dist/talismn-sapi.cjs.prod.js +0 -601
  36. package/dist/talismn-sapi.esm.js +0 -593
@@ -0,0 +1,111 @@
1
+ import { SignerPayloadJSON } from '@polkadot/types/types';
2
+ import * as _polkadot_types from '@polkadot/types';
3
+ import { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
4
+ import { UnifiedMetadata, MetadataLookup, MetadataBuilder } from '@talismn/scale';
5
+
6
+ type DecodedCall<Args = any> = {
7
+ pallet: string;
8
+ method: string;
9
+ args: Args;
10
+ };
11
+ type PayloadSignerConfig = {
12
+ address: string;
13
+ tip?: bigint;
14
+ };
15
+ type JsonRpcRequestSend = (method: string, params: unknown[], isCacheable?: boolean) => Promise<unknown>;
16
+ type SapiConnectorProps = {
17
+ chainId: string;
18
+ send: JsonRpcRequestSend;
19
+ submit?: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: any) => Promise<{
20
+ hash: `0x${string}`;
21
+ }>;
22
+ submitWithBittensorMevShield?: (payload: SignerPayloadJSON, txInfo?: any) => Promise<{
23
+ hash: `0x${string}`;
24
+ }>;
25
+ };
26
+
27
+ type SapiConnector = Required<SapiConnectorProps>;
28
+
29
+ type Chain = {
30
+ connector: SapiConnector;
31
+ hexMetadata: `0x${string}`;
32
+ token: {
33
+ symbol: string;
34
+ decimals: number;
35
+ };
36
+ hasCheckMetadataHash?: boolean;
37
+ signedExtensions?: ExtDef;
38
+ registryTypes?: unknown;
39
+ metadata: UnifiedMetadata;
40
+ lookup: MetadataLookup;
41
+ builder: MetadataBuilder;
42
+ metadataRpc: `0x${string}`;
43
+ };
44
+
45
+ type ScaleApiSubmitMode = "default" | "bittensor-mev-shield";
46
+
47
+ type ScaleApi = NonNullable<ReturnType<typeof getScaleApi>>;
48
+ declare const getScaleApi: (connector: SapiConnectorProps, hexMetadata: `0x${string}`, token: {
49
+ symbol: string;
50
+ decimals: number;
51
+ }, hasCheckMetadataHash?: boolean, signedExtensions?: ExtDef, registryTypes?: unknown) => {
52
+ id: string;
53
+ chainId: string;
54
+ specName: string;
55
+ specVersion: number;
56
+ hasCheckMetadataHash: boolean | undefined;
57
+ base58Prefix: number;
58
+ token: {
59
+ symbol: string;
60
+ decimals: number;
61
+ };
62
+ chain: Chain;
63
+ getConstant: <T>(pallet: string, constant: string) => T;
64
+ getStorage: <T>(pallet: string, entry: string, keys: unknown[], at?: string) => Promise<T>;
65
+ getDecodedCall: (pallet: string, method: string, args: unknown) => {
66
+ type: string;
67
+ value: {
68
+ type: string;
69
+ value: unknown;
70
+ };
71
+ };
72
+ getDecodedCallFromPayload: <Res extends DecodedCall>(payload: {
73
+ method: SignerPayloadJSON["method"];
74
+ }) => Res;
75
+ getExtrinsicPayload: (pallet: string, method: string, args: unknown, config: PayloadSignerConfig) => Promise<{
76
+ payload: SignerPayloadJSON;
77
+ txMetadata: Uint8Array | undefined;
78
+ shortMetadata: `0x${string}` | undefined;
79
+ }>;
80
+ getFeeEstimate: (payload: SignerPayloadJSON) => Promise<bigint>;
81
+ getRuntimeCallValue: <T>(apiName: string, method: string, args: unknown[]) => Promise<T>;
82
+ getTypeRegistry: (payload: SignerPayloadJSON) => _polkadot_types.TypeRegistry;
83
+ submit: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: unknown, mode?: ScaleApiSubmitMode) => Promise<{
84
+ hash: `0x${string}`;
85
+ }>;
86
+ getCallDocs: (pallet: string, method: string) => string | null;
87
+ getDryRunCall: <T>(from: string, decodedCall: DecodedCall<unknown>) => Promise<{
88
+ available: boolean;
89
+ data: null;
90
+ ok?: undefined;
91
+ errorMessage?: undefined;
92
+ } | {
93
+ available: boolean;
94
+ data: T;
95
+ ok: boolean;
96
+ errorMessage: string | null;
97
+ }>;
98
+ isApiAvailable: (name: string, method: string) => boolean;
99
+ };
100
+
101
+ declare const MAX_SUPPORTED_METADATA_VERSION = 15;
102
+ type RpcSendFunc = <T>(method: string, params: unknown[], isCacheable?: boolean) => Promise<T>;
103
+ /**
104
+ * Fetches the highest supported version of metadata from the chain.
105
+ *
106
+ * @param rpcSend
107
+ * @returns hex-encoded metadata starting with the magic number
108
+ */
109
+ declare const fetchBestMetadata: (rpcSend: RpcSendFunc, allowLegacyFallback?: boolean) => Promise<`0x${string}`>;
110
+
111
+ export { type DecodedCall, type JsonRpcRequestSend, MAX_SUPPORTED_METADATA_VERSION, type PayloadSignerConfig, type SapiConnectorProps, type ScaleApi, fetchBestMetadata, getScaleApi };
@@ -0,0 +1,111 @@
1
+ import { SignerPayloadJSON } from '@polkadot/types/types';
2
+ import * as _polkadot_types from '@polkadot/types';
3
+ import { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
4
+ import { UnifiedMetadata, MetadataLookup, MetadataBuilder } from '@talismn/scale';
5
+
6
+ type DecodedCall<Args = any> = {
7
+ pallet: string;
8
+ method: string;
9
+ args: Args;
10
+ };
11
+ type PayloadSignerConfig = {
12
+ address: string;
13
+ tip?: bigint;
14
+ };
15
+ type JsonRpcRequestSend = (method: string, params: unknown[], isCacheable?: boolean) => Promise<unknown>;
16
+ type SapiConnectorProps = {
17
+ chainId: string;
18
+ send: JsonRpcRequestSend;
19
+ submit?: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: any) => Promise<{
20
+ hash: `0x${string}`;
21
+ }>;
22
+ submitWithBittensorMevShield?: (payload: SignerPayloadJSON, txInfo?: any) => Promise<{
23
+ hash: `0x${string}`;
24
+ }>;
25
+ };
26
+
27
+ type SapiConnector = Required<SapiConnectorProps>;
28
+
29
+ type Chain = {
30
+ connector: SapiConnector;
31
+ hexMetadata: `0x${string}`;
32
+ token: {
33
+ symbol: string;
34
+ decimals: number;
35
+ };
36
+ hasCheckMetadataHash?: boolean;
37
+ signedExtensions?: ExtDef;
38
+ registryTypes?: unknown;
39
+ metadata: UnifiedMetadata;
40
+ lookup: MetadataLookup;
41
+ builder: MetadataBuilder;
42
+ metadataRpc: `0x${string}`;
43
+ };
44
+
45
+ type ScaleApiSubmitMode = "default" | "bittensor-mev-shield";
46
+
47
+ type ScaleApi = NonNullable<ReturnType<typeof getScaleApi>>;
48
+ declare const getScaleApi: (connector: SapiConnectorProps, hexMetadata: `0x${string}`, token: {
49
+ symbol: string;
50
+ decimals: number;
51
+ }, hasCheckMetadataHash?: boolean, signedExtensions?: ExtDef, registryTypes?: unknown) => {
52
+ id: string;
53
+ chainId: string;
54
+ specName: string;
55
+ specVersion: number;
56
+ hasCheckMetadataHash: boolean | undefined;
57
+ base58Prefix: number;
58
+ token: {
59
+ symbol: string;
60
+ decimals: number;
61
+ };
62
+ chain: Chain;
63
+ getConstant: <T>(pallet: string, constant: string) => T;
64
+ getStorage: <T>(pallet: string, entry: string, keys: unknown[], at?: string) => Promise<T>;
65
+ getDecodedCall: (pallet: string, method: string, args: unknown) => {
66
+ type: string;
67
+ value: {
68
+ type: string;
69
+ value: unknown;
70
+ };
71
+ };
72
+ getDecodedCallFromPayload: <Res extends DecodedCall>(payload: {
73
+ method: SignerPayloadJSON["method"];
74
+ }) => Res;
75
+ getExtrinsicPayload: (pallet: string, method: string, args: unknown, config: PayloadSignerConfig) => Promise<{
76
+ payload: SignerPayloadJSON;
77
+ txMetadata: Uint8Array | undefined;
78
+ shortMetadata: `0x${string}` | undefined;
79
+ }>;
80
+ getFeeEstimate: (payload: SignerPayloadJSON) => Promise<bigint>;
81
+ getRuntimeCallValue: <T>(apiName: string, method: string, args: unknown[]) => Promise<T>;
82
+ getTypeRegistry: (payload: SignerPayloadJSON) => _polkadot_types.TypeRegistry;
83
+ submit: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: unknown, mode?: ScaleApiSubmitMode) => Promise<{
84
+ hash: `0x${string}`;
85
+ }>;
86
+ getCallDocs: (pallet: string, method: string) => string | null;
87
+ getDryRunCall: <T>(from: string, decodedCall: DecodedCall<unknown>) => Promise<{
88
+ available: boolean;
89
+ data: null;
90
+ ok?: undefined;
91
+ errorMessage?: undefined;
92
+ } | {
93
+ available: boolean;
94
+ data: T;
95
+ ok: boolean;
96
+ errorMessage: string | null;
97
+ }>;
98
+ isApiAvailable: (name: string, method: string) => boolean;
99
+ };
100
+
101
+ declare const MAX_SUPPORTED_METADATA_VERSION = 15;
102
+ type RpcSendFunc = <T>(method: string, params: unknown[], isCacheable?: boolean) => Promise<T>;
103
+ /**
104
+ * Fetches the highest supported version of metadata from the chain.
105
+ *
106
+ * @param rpcSend
107
+ * @returns hex-encoded metadata starting with the magic number
108
+ */
109
+ declare const fetchBestMetadata: (rpcSend: RpcSendFunc, allowLegacyFallback?: boolean) => Promise<`0x${string}`>;
110
+
111
+ export { type DecodedCall, type JsonRpcRequestSend, MAX_SUPPORTED_METADATA_VERSION, type PayloadSignerConfig, type SapiConnectorProps, type ScaleApi, fetchBestMetadata, getScaleApi };