@d9-network/ink 0.2.0 → 1.0.0
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/README.md +2 -2
- package/dist/index.cjs +123 -257
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -188
- package/dist/index.d.mts +30 -188
- package/dist/index.mjs +44 -238
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,144 +1,11 @@
|
|
|
1
1
|
import { Binary, Enum, HexString, PolkadotClient, PolkadotSigner, SS58String } from "polkadot-api";
|
|
2
2
|
import { Event, InkCallableDescriptor, InkDescriptors, InkMetadata, InkStorageDescriptor } from "@polkadot-api/ink-contracts";
|
|
3
3
|
import { Observable } from "rxjs";
|
|
4
|
+
import { AbortedError, ContractError, ContractError as ContractError$1, ContractErrorType, ContractExecutionError, DecodeError, EncodeError, LangError, MetadataError, NetworkError, SignerError, TimeoutError, TransactionError, isContractError, isErrorType } from "@d9-network/spec";
|
|
4
5
|
import { Bytes } from "@subsquid/scale-codec";
|
|
5
6
|
import * as _polkadot_api_substrate_bindings0 from "@polkadot-api/substrate-bindings";
|
|
6
7
|
import { Codec } from "@polkadot-api/substrate-bindings";
|
|
7
8
|
|
|
8
|
-
//#region src/constants.d.ts
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* D9 Network constants
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* D9 SS58 address prefix.
|
|
15
|
-
*
|
|
16
|
-
* SS58 is the address format used by Substrate-based chains. Each chain has a unique
|
|
17
|
-
* prefix that determines the address format and ensures addresses are network-specific.
|
|
18
|
-
*
|
|
19
|
-
* D9 uses prefix 9, which produces addresses starting with 'c' or 'd'.
|
|
20
|
-
*
|
|
21
|
-
* This prefix is automatically applied to all AccountId encoding/decoding operations
|
|
22
|
-
* in the SDK, including:
|
|
23
|
-
* - Contract call parameter encoding
|
|
24
|
-
* - Result decoding
|
|
25
|
-
* - Event parsing
|
|
26
|
-
*
|
|
27
|
-
* @see https://github.com/paritytech/ss58-registry for the full SS58 registry
|
|
28
|
-
*/
|
|
29
|
-
declare const D9_SS58_PREFIX = 9;
|
|
30
|
-
/** D9 token decimals */
|
|
31
|
-
declare const D9_DECIMALS = 12;
|
|
32
|
-
/** D9 token symbol */
|
|
33
|
-
declare const D9_SYMBOL = "D9";
|
|
34
|
-
/** USDT token decimals */
|
|
35
|
-
declare const USDT_DECIMALS = 2;
|
|
36
|
-
/** USDT token symbol */
|
|
37
|
-
declare const USDT_SYMBOL = "USDT";
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/errors.d.ts
|
|
40
|
-
/**
|
|
41
|
-
* Structured error types for contract operations.
|
|
42
|
-
* Provides detailed error information for debugging and handling.
|
|
43
|
-
*/
|
|
44
|
-
/**
|
|
45
|
-
* Error types for contract operations
|
|
46
|
-
*/
|
|
47
|
-
type ContractErrorType = "METADATA_ERROR" | "ENCODE_ERROR" | "DECODE_ERROR" | "NETWORK_ERROR" | "CONTRACT_ERROR" | "LANG_ERROR" | "TIMEOUT_ERROR" | "ABORTED" | "SIGNER_ERROR" | "TX_ERROR";
|
|
48
|
-
/**
|
|
49
|
-
* Base error class for all contract-related errors
|
|
50
|
-
*/
|
|
51
|
-
declare class ContractError extends Error {
|
|
52
|
-
readonly type: ContractErrorType;
|
|
53
|
-
readonly label?: string | undefined;
|
|
54
|
-
readonly details?: unknown | undefined;
|
|
55
|
-
readonly timestamp: Date;
|
|
56
|
-
readonly cause?: Error;
|
|
57
|
-
constructor(message: string, type: ContractErrorType, label?: string | undefined, details?: unknown | undefined, cause?: Error);
|
|
58
|
-
/**
|
|
59
|
-
* Create a formatted error message for logging
|
|
60
|
-
*/
|
|
61
|
-
toLogString(): string;
|
|
62
|
-
/**
|
|
63
|
-
* Convert to a plain object for serialization
|
|
64
|
-
*/
|
|
65
|
-
toJSON(): Record<string, unknown>;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Error thrown when contract metadata is missing or invalid
|
|
69
|
-
*/
|
|
70
|
-
declare class MetadataError extends ContractError {
|
|
71
|
-
constructor(message: string, details?: unknown);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Error thrown when encoding call data fails
|
|
75
|
-
*/
|
|
76
|
-
declare class EncodeError extends ContractError {
|
|
77
|
-
constructor(label: string, message: string, details?: unknown);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Error thrown when decoding response fails
|
|
81
|
-
*/
|
|
82
|
-
declare class DecodeError extends ContractError {
|
|
83
|
-
constructor(label: string, message: string, details?: unknown);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Error thrown for network/RPC errors
|
|
87
|
-
*/
|
|
88
|
-
declare class NetworkError extends ContractError {
|
|
89
|
-
constructor(message: string, cause?: Error, details?: unknown);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Error thrown when contract returns an error result
|
|
93
|
-
*/
|
|
94
|
-
declare class ContractExecutionError extends ContractError {
|
|
95
|
-
readonly errorValue: unknown;
|
|
96
|
-
constructor(label: string, errorValue: unknown);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Error thrown for Ink LangError
|
|
100
|
-
*/
|
|
101
|
-
declare class LangError extends ContractError {
|
|
102
|
-
readonly variant: number;
|
|
103
|
-
constructor(label: string, variant: number);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Error thrown when request times out
|
|
107
|
-
*/
|
|
108
|
-
declare class TimeoutError extends ContractError {
|
|
109
|
-
readonly timeoutMs: number;
|
|
110
|
-
constructor(label: string, timeoutMs: number);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Error thrown when request is aborted
|
|
114
|
-
*/
|
|
115
|
-
declare class AbortedError extends ContractError {
|
|
116
|
-
constructor(label: string, reason?: string);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Error thrown for signer-related issues
|
|
120
|
-
*/
|
|
121
|
-
declare class SignerError extends ContractError {
|
|
122
|
-
constructor(message: string, details?: unknown);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Error thrown when transaction submission fails
|
|
126
|
-
*/
|
|
127
|
-
declare class TransactionError extends ContractError {
|
|
128
|
-
readonly txHash?: string | undefined;
|
|
129
|
-
constructor(label: string, message: string, txHash?: string | undefined, details?: unknown);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Type guard to check if an error is a ContractError
|
|
133
|
-
*/
|
|
134
|
-
declare function isContractError(error: unknown): error is ContractError;
|
|
135
|
-
/**
|
|
136
|
-
* Type guard to check for specific error types
|
|
137
|
-
*/
|
|
138
|
-
declare function isErrorType<T$1 extends ContractErrorType>(error: unknown, type: T$1): error is ContractError & {
|
|
139
|
-
type: T$1;
|
|
140
|
-
};
|
|
141
|
-
//#endregion
|
|
142
9
|
//#region src/event-types.d.ts
|
|
143
10
|
/**
|
|
144
11
|
* Raw event data from chain
|
|
@@ -554,7 +421,7 @@ type QueryResult<T$1> = ({
|
|
|
554
421
|
success: true;
|
|
555
422
|
} & QuerySuccessValue<T$1>) | {
|
|
556
423
|
success: false;
|
|
557
|
-
error: ContractError;
|
|
424
|
+
error: ContractError$1;
|
|
558
425
|
};
|
|
559
426
|
/**
|
|
560
427
|
* Storage query interface
|
|
@@ -566,7 +433,7 @@ interface ContractStorage {
|
|
|
566
433
|
value: unknown;
|
|
567
434
|
} | {
|
|
568
435
|
success: false;
|
|
569
|
-
value: ContractError;
|
|
436
|
+
value: ContractError$1;
|
|
570
437
|
}>;
|
|
571
438
|
/** Get a nested storage value by path */
|
|
572
439
|
getNested(path: string, ...keys: unknown[]): Promise<{
|
|
@@ -574,7 +441,7 @@ interface ContractStorage {
|
|
|
574
441
|
value: unknown;
|
|
575
442
|
} | {
|
|
576
443
|
success: false;
|
|
577
|
-
value: ContractError;
|
|
444
|
+
value: ContractError$1;
|
|
578
445
|
}>;
|
|
579
446
|
}
|
|
580
447
|
/**
|
|
@@ -803,7 +670,7 @@ interface SubstrateRpcMethods {
|
|
|
803
670
|
justifications: unknown;
|
|
804
671
|
} | null];
|
|
805
672
|
chain_getFinalizedHead: [[], HexString];
|
|
806
|
-
state_call: [[method: string, data:
|
|
673
|
+
state_call: [[method: string, data: string, at?: HexString | string], HexString];
|
|
807
674
|
state_getStorage: [[key: HexString, at?: HexString], HexString | null];
|
|
808
675
|
state_getStorageAt: [[key: HexString, at: HexString], HexString | null];
|
|
809
676
|
state_getStorageHash: [[key: HexString, at?: HexString], HexString | null];
|
|
@@ -843,45 +710,21 @@ interface SubstrateRpcMethods {
|
|
|
843
710
|
adjustedWeightFee: string;
|
|
844
711
|
} | null;
|
|
845
712
|
}];
|
|
713
|
+
referral_getParent: [[account: string, at?: HexString], string | null];
|
|
714
|
+
referral_getAncestors: [[account: string, at?: HexString], string[] | null];
|
|
715
|
+
referral_getDirectReferralCount: [[account: string, at?: HexString], number];
|
|
716
|
+
voting_getSortedCandidates: [[at?: HexString], [string, string][]];
|
|
846
717
|
}
|
|
847
718
|
/**
|
|
848
|
-
*
|
|
849
|
-
*/
|
|
850
|
-
type KnownRpcMethod = keyof SubstrateRpcMethods;
|
|
851
|
-
/**
|
|
852
|
-
* Extract parameter types for a known RPC method
|
|
853
|
-
*/
|
|
854
|
-
type RpcParams<M$1 extends KnownRpcMethod> = SubstrateRpcMethods[M$1][0];
|
|
855
|
-
/**
|
|
856
|
-
* Extract return type for a known RPC method
|
|
857
|
-
*/
|
|
858
|
-
type RpcReturn<M$1 extends KnownRpcMethod> = SubstrateRpcMethods[M$1][1];
|
|
859
|
-
/**
|
|
860
|
-
* Type-safe RPC request interface
|
|
861
|
-
*
|
|
862
|
-
* Provides full type inference for known RPC methods while allowing
|
|
863
|
-
* arbitrary method calls with explicit type parameters.
|
|
719
|
+
* Type-safe RPC interface with dot syntax
|
|
864
720
|
*
|
|
865
721
|
* @example
|
|
866
722
|
* ```ts
|
|
867
|
-
*
|
|
868
|
-
* const
|
|
869
|
-
* // hash: HexString | null
|
|
870
|
-
*
|
|
871
|
-
* // Unknown method: provide explicit types
|
|
872
|
-
* const result = await rpc<MyType>("custom_method", [arg1, arg2]);
|
|
723
|
+
* const hash = await rpc.chain_getBlockHash(12345);
|
|
724
|
+
* const result = await rpc.state_call("ContractsApi_call", message, blockHash);
|
|
873
725
|
* ```
|
|
874
726
|
*/
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* Call a known RPC method with full type inference
|
|
878
|
-
*/
|
|
879
|
-
<M$1 extends KnownRpcMethod>(method: M$1, params: RpcParams<M$1>): Promise<RpcReturn<M$1>>;
|
|
880
|
-
/**
|
|
881
|
-
* Call an unknown RPC method with explicit type parameters
|
|
882
|
-
*/
|
|
883
|
-
<Reply = unknown, Params extends unknown[] = unknown[]>(method: string, params: Params): Promise<Reply>;
|
|
884
|
-
}
|
|
727
|
+
type TypedRpc = { [M in keyof SubstrateRpcMethods]: (...args: SubstrateRpcMethods[M][0]) => Promise<SubstrateRpcMethods[M][1]> };
|
|
885
728
|
//#endregion
|
|
886
729
|
//#region src/sdk.d.ts
|
|
887
730
|
/**
|
|
@@ -899,22 +742,22 @@ interface CreateD9InkSdkOptions extends D9InkSdkOptions {
|
|
|
899
742
|
*/
|
|
900
743
|
interface D9InkSdkWithRpc extends D9InkSdk {
|
|
901
744
|
/**
|
|
902
|
-
* Type-safe RPC
|
|
745
|
+
* Type-safe RPC interface with dot syntax
|
|
903
746
|
*
|
|
904
747
|
* Provides autocomplete for known Substrate RPC methods and type inference
|
|
905
748
|
* for parameters and return values.
|
|
906
749
|
*
|
|
907
750
|
* @example
|
|
908
751
|
* ```ts
|
|
909
|
-
* //
|
|
910
|
-
* const hash = await sdk.rpc(
|
|
752
|
+
* // Dot syntax with full type inference
|
|
753
|
+
* const hash = await sdk.rpc.chain_getBlockHash(12345);
|
|
911
754
|
* // hash: HexString | null
|
|
912
755
|
*
|
|
913
|
-
*
|
|
914
|
-
*
|
|
756
|
+
* const result = await sdk.rpc.state_call("ContractsApi_call", message, blockHash);
|
|
757
|
+
* // result: HexString
|
|
915
758
|
* ```
|
|
916
759
|
*/
|
|
917
|
-
rpc:
|
|
760
|
+
rpc: TypedRpc;
|
|
918
761
|
}
|
|
919
762
|
/**
|
|
920
763
|
* Create a D9 Ink SDK instance.
|
|
@@ -1450,31 +1293,30 @@ declare function isCallType<M$1 extends InkCallableDescriptor, L extends Extract
|
|
|
1450
1293
|
//#endregion
|
|
1451
1294
|
//#region src/rpc.d.ts
|
|
1452
1295
|
/**
|
|
1453
|
-
* Create a type-safe RPC
|
|
1296
|
+
* Create a type-safe RPC proxy from a PolkadotClient
|
|
1454
1297
|
*
|
|
1455
|
-
* This wraps the client's `_request` method with
|
|
1456
|
-
*
|
|
1457
|
-
* parameters and return values.
|
|
1298
|
+
* This wraps the client's `_request` method with a Proxy that provides
|
|
1299
|
+
* a dot-syntax interface with proper TypeScript types.
|
|
1458
1300
|
*
|
|
1459
1301
|
* @param client - The PolkadotClient instance
|
|
1460
|
-
* @returns A type-safe RPC
|
|
1302
|
+
* @returns A type-safe RPC proxy object
|
|
1461
1303
|
*
|
|
1462
1304
|
* @example
|
|
1463
1305
|
* ```ts
|
|
1464
1306
|
* const rpc = createTypedRpc(client);
|
|
1465
1307
|
*
|
|
1466
|
-
* //
|
|
1467
|
-
* const hash = await rpc(
|
|
1308
|
+
* // Dot syntax with full type inference
|
|
1309
|
+
* const hash = await rpc.chain_getBlockHash(12345);
|
|
1468
1310
|
* // hash: HexString | null
|
|
1469
1311
|
*
|
|
1470
|
-
* const header = await rpc(
|
|
1312
|
+
* const header = await rpc.chain_getHeader(hash);
|
|
1471
1313
|
* // header: BlockHeader | null
|
|
1472
1314
|
*
|
|
1473
|
-
*
|
|
1474
|
-
*
|
|
1315
|
+
* const result = await rpc.state_call("ContractsApi_call", message, blockHash);
|
|
1316
|
+
* // result: HexString
|
|
1475
1317
|
* ```
|
|
1476
1318
|
*/
|
|
1477
|
-
declare function createTypedRpc(client: PolkadotClient):
|
|
1319
|
+
declare function createTypedRpc(client: PolkadotClient): TypedRpc;
|
|
1478
1320
|
//#endregion
|
|
1479
1321
|
//#region src/utils/fees.d.ts
|
|
1480
1322
|
/**
|
|
@@ -1582,5 +1424,5 @@ declare function compareGasWeight(a: GasWeight, b: GasWeight): -1 | 0 | 1;
|
|
|
1582
1424
|
*/
|
|
1583
1425
|
declare function gasExceedsLimit(gas: GasWeight, limit: GasWeight): boolean;
|
|
1584
1426
|
//#endregion
|
|
1585
|
-
export { AbortedError, type BlockHeader, type CallFilterOptions, ContractCallParser, type ContractCallResult, ContractError, type ContractErrorType, ContractEventParser, ContractExecutionError, type ContractMessageBuilder, type ContractStorage, type CreateContractOptions, type CreateD9InkSdkOptions, type D9InkContract, type D9InkContractFromDescriptor, type D9InkSdk, type D9InkSdkOptions, type D9InkSdkWithRpc,
|
|
1427
|
+
export { AbortedError, type BlockHeader, type CallFilterOptions, ContractCallParser, type ContractCallResult, ContractError, type ContractErrorType, ContractEventParser, ContractExecutionError, type ContractMessageBuilder, type ContractStorage, type CreateContractOptions, type CreateD9InkSdkOptions, type D9InkContract, type D9InkContractFromDescriptor, type D9InkSdk, type D9InkSdkOptions, type D9InkSdkWithRpc, DecodeError, type DecodedContractEvent, EncodeError, EstimatedCost, type EventFilterOptions, type EventSubscriptionOptions, type ExtractEnumDef, type ExtractEventLabels, type ExtractMessageLabels, FormattedGasInfo, type GasInfo, GasWeight, type InferEvents, type InferMessages, InkCodecs, LangError, type MessageAttributes, type MessageInfo, MetadataError, NetworkError, type QueryOptions, type QueryResult, type QuerySuccessValue, type RawContractCall, type RawContractEvent, type ResponseDecoder, type RuntimeVersion, type SendOptions, type SendableTransaction, SignerError, type StorageChangeSet, type StorageDepositInfo, type SubstrateRpcMethods, type SystemHealth, TimeoutError, TransactionError, type TxResult, type TypedCallFilterOptions, type TypedContractCall, type TypedContractEvent, type TypedEventFilterOptions, type TypedMessage, type TypedRpc, applyGasMargin, buildAllEventDecoders, buildAllMessageDecoders, buildEventDecoder, buildMessageDecoder, compareGasWeight, createAsciiEventTopic, createCodecRegistry, createContractEventStream, createD9InkContract, createD9InkSdk, createMessageBuilder, createNativeTransferStream, createPSP22TransferStream, createTypedRpc, decodeContractCallResult, decodeInkValue, encodeCall, encodeContractCall, encodeContractCallWithLimits, estimateTransactionCost, formatGasInfo, gasExceedsLimit, getEventSignature, isCallType, isContractError, isErrorType, isEventType, isLangError, unwrapInkResult };
|
|
1586
1428
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -3,142 +3,9 @@ import { Event, InkCallableDescriptor, InkDescriptors, InkMetadata, InkStorageDe
|
|
|
3
3
|
import { Bytes } from "@subsquid/scale-codec";
|
|
4
4
|
import * as _polkadot_api_substrate_bindings0 from "@polkadot-api/substrate-bindings";
|
|
5
5
|
import { Codec } from "@polkadot-api/substrate-bindings";
|
|
6
|
+
import { AbortedError, ContractError, ContractError as ContractError$1, ContractErrorType, ContractExecutionError, DecodeError, EncodeError, LangError, MetadataError, NetworkError, SignerError, TimeoutError, TransactionError, isContractError, isErrorType } from "@d9-network/spec";
|
|
6
7
|
import { Observable } from "rxjs";
|
|
7
8
|
|
|
8
|
-
//#region src/constants.d.ts
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* D9 Network constants
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* D9 SS58 address prefix.
|
|
15
|
-
*
|
|
16
|
-
* SS58 is the address format used by Substrate-based chains. Each chain has a unique
|
|
17
|
-
* prefix that determines the address format and ensures addresses are network-specific.
|
|
18
|
-
*
|
|
19
|
-
* D9 uses prefix 9, which produces addresses starting with 'c' or 'd'.
|
|
20
|
-
*
|
|
21
|
-
* This prefix is automatically applied to all AccountId encoding/decoding operations
|
|
22
|
-
* in the SDK, including:
|
|
23
|
-
* - Contract call parameter encoding
|
|
24
|
-
* - Result decoding
|
|
25
|
-
* - Event parsing
|
|
26
|
-
*
|
|
27
|
-
* @see https://github.com/paritytech/ss58-registry for the full SS58 registry
|
|
28
|
-
*/
|
|
29
|
-
declare const D9_SS58_PREFIX = 9;
|
|
30
|
-
/** D9 token decimals */
|
|
31
|
-
declare const D9_DECIMALS = 12;
|
|
32
|
-
/** D9 token symbol */
|
|
33
|
-
declare const D9_SYMBOL = "D9";
|
|
34
|
-
/** USDT token decimals */
|
|
35
|
-
declare const USDT_DECIMALS = 2;
|
|
36
|
-
/** USDT token symbol */
|
|
37
|
-
declare const USDT_SYMBOL = "USDT";
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/errors.d.ts
|
|
40
|
-
/**
|
|
41
|
-
* Structured error types for contract operations.
|
|
42
|
-
* Provides detailed error information for debugging and handling.
|
|
43
|
-
*/
|
|
44
|
-
/**
|
|
45
|
-
* Error types for contract operations
|
|
46
|
-
*/
|
|
47
|
-
type ContractErrorType = "METADATA_ERROR" | "ENCODE_ERROR" | "DECODE_ERROR" | "NETWORK_ERROR" | "CONTRACT_ERROR" | "LANG_ERROR" | "TIMEOUT_ERROR" | "ABORTED" | "SIGNER_ERROR" | "TX_ERROR";
|
|
48
|
-
/**
|
|
49
|
-
* Base error class for all contract-related errors
|
|
50
|
-
*/
|
|
51
|
-
declare class ContractError extends Error {
|
|
52
|
-
readonly type: ContractErrorType;
|
|
53
|
-
readonly label?: string | undefined;
|
|
54
|
-
readonly details?: unknown | undefined;
|
|
55
|
-
readonly timestamp: Date;
|
|
56
|
-
readonly cause?: Error;
|
|
57
|
-
constructor(message: string, type: ContractErrorType, label?: string | undefined, details?: unknown | undefined, cause?: Error);
|
|
58
|
-
/**
|
|
59
|
-
* Create a formatted error message for logging
|
|
60
|
-
*/
|
|
61
|
-
toLogString(): string;
|
|
62
|
-
/**
|
|
63
|
-
* Convert to a plain object for serialization
|
|
64
|
-
*/
|
|
65
|
-
toJSON(): Record<string, unknown>;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Error thrown when contract metadata is missing or invalid
|
|
69
|
-
*/
|
|
70
|
-
declare class MetadataError extends ContractError {
|
|
71
|
-
constructor(message: string, details?: unknown);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Error thrown when encoding call data fails
|
|
75
|
-
*/
|
|
76
|
-
declare class EncodeError extends ContractError {
|
|
77
|
-
constructor(label: string, message: string, details?: unknown);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Error thrown when decoding response fails
|
|
81
|
-
*/
|
|
82
|
-
declare class DecodeError extends ContractError {
|
|
83
|
-
constructor(label: string, message: string, details?: unknown);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Error thrown for network/RPC errors
|
|
87
|
-
*/
|
|
88
|
-
declare class NetworkError extends ContractError {
|
|
89
|
-
constructor(message: string, cause?: Error, details?: unknown);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Error thrown when contract returns an error result
|
|
93
|
-
*/
|
|
94
|
-
declare class ContractExecutionError extends ContractError {
|
|
95
|
-
readonly errorValue: unknown;
|
|
96
|
-
constructor(label: string, errorValue: unknown);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Error thrown for Ink LangError
|
|
100
|
-
*/
|
|
101
|
-
declare class LangError extends ContractError {
|
|
102
|
-
readonly variant: number;
|
|
103
|
-
constructor(label: string, variant: number);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Error thrown when request times out
|
|
107
|
-
*/
|
|
108
|
-
declare class TimeoutError extends ContractError {
|
|
109
|
-
readonly timeoutMs: number;
|
|
110
|
-
constructor(label: string, timeoutMs: number);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Error thrown when request is aborted
|
|
114
|
-
*/
|
|
115
|
-
declare class AbortedError extends ContractError {
|
|
116
|
-
constructor(label: string, reason?: string);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Error thrown for signer-related issues
|
|
120
|
-
*/
|
|
121
|
-
declare class SignerError extends ContractError {
|
|
122
|
-
constructor(message: string, details?: unknown);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Error thrown when transaction submission fails
|
|
126
|
-
*/
|
|
127
|
-
declare class TransactionError extends ContractError {
|
|
128
|
-
readonly txHash?: string | undefined;
|
|
129
|
-
constructor(label: string, message: string, txHash?: string | undefined, details?: unknown);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Type guard to check if an error is a ContractError
|
|
133
|
-
*/
|
|
134
|
-
declare function isContractError(error: unknown): error is ContractError;
|
|
135
|
-
/**
|
|
136
|
-
* Type guard to check for specific error types
|
|
137
|
-
*/
|
|
138
|
-
declare function isErrorType<T$1 extends ContractErrorType>(error: unknown, type: T$1): error is ContractError & {
|
|
139
|
-
type: T$1;
|
|
140
|
-
};
|
|
141
|
-
//#endregion
|
|
142
9
|
//#region src/event-types.d.ts
|
|
143
10
|
/**
|
|
144
11
|
* Raw event data from chain
|
|
@@ -554,7 +421,7 @@ type QueryResult<T$1> = ({
|
|
|
554
421
|
success: true;
|
|
555
422
|
} & QuerySuccessValue<T$1>) | {
|
|
556
423
|
success: false;
|
|
557
|
-
error: ContractError;
|
|
424
|
+
error: ContractError$1;
|
|
558
425
|
};
|
|
559
426
|
/**
|
|
560
427
|
* Storage query interface
|
|
@@ -566,7 +433,7 @@ interface ContractStorage {
|
|
|
566
433
|
value: unknown;
|
|
567
434
|
} | {
|
|
568
435
|
success: false;
|
|
569
|
-
value: ContractError;
|
|
436
|
+
value: ContractError$1;
|
|
570
437
|
}>;
|
|
571
438
|
/** Get a nested storage value by path */
|
|
572
439
|
getNested(path: string, ...keys: unknown[]): Promise<{
|
|
@@ -574,7 +441,7 @@ interface ContractStorage {
|
|
|
574
441
|
value: unknown;
|
|
575
442
|
} | {
|
|
576
443
|
success: false;
|
|
577
|
-
value: ContractError;
|
|
444
|
+
value: ContractError$1;
|
|
578
445
|
}>;
|
|
579
446
|
}
|
|
580
447
|
/**
|
|
@@ -803,7 +670,7 @@ interface SubstrateRpcMethods {
|
|
|
803
670
|
justifications: unknown;
|
|
804
671
|
} | null];
|
|
805
672
|
chain_getFinalizedHead: [[], HexString];
|
|
806
|
-
state_call: [[method: string, data:
|
|
673
|
+
state_call: [[method: string, data: string, at?: HexString | string], HexString];
|
|
807
674
|
state_getStorage: [[key: HexString, at?: HexString], HexString | null];
|
|
808
675
|
state_getStorageAt: [[key: HexString, at: HexString], HexString | null];
|
|
809
676
|
state_getStorageHash: [[key: HexString, at?: HexString], HexString | null];
|
|
@@ -843,45 +710,21 @@ interface SubstrateRpcMethods {
|
|
|
843
710
|
adjustedWeightFee: string;
|
|
844
711
|
} | null;
|
|
845
712
|
}];
|
|
713
|
+
referral_getParent: [[account: string, at?: HexString], string | null];
|
|
714
|
+
referral_getAncestors: [[account: string, at?: HexString], string[] | null];
|
|
715
|
+
referral_getDirectReferralCount: [[account: string, at?: HexString], number];
|
|
716
|
+
voting_getSortedCandidates: [[at?: HexString], [string, string][]];
|
|
846
717
|
}
|
|
847
718
|
/**
|
|
848
|
-
*
|
|
849
|
-
*/
|
|
850
|
-
type KnownRpcMethod = keyof SubstrateRpcMethods;
|
|
851
|
-
/**
|
|
852
|
-
* Extract parameter types for a known RPC method
|
|
853
|
-
*/
|
|
854
|
-
type RpcParams<M$1 extends KnownRpcMethod> = SubstrateRpcMethods[M$1][0];
|
|
855
|
-
/**
|
|
856
|
-
* Extract return type for a known RPC method
|
|
857
|
-
*/
|
|
858
|
-
type RpcReturn<M$1 extends KnownRpcMethod> = SubstrateRpcMethods[M$1][1];
|
|
859
|
-
/**
|
|
860
|
-
* Type-safe RPC request interface
|
|
861
|
-
*
|
|
862
|
-
* Provides full type inference for known RPC methods while allowing
|
|
863
|
-
* arbitrary method calls with explicit type parameters.
|
|
719
|
+
* Type-safe RPC interface with dot syntax
|
|
864
720
|
*
|
|
865
721
|
* @example
|
|
866
722
|
* ```ts
|
|
867
|
-
*
|
|
868
|
-
* const
|
|
869
|
-
* // hash: HexString | null
|
|
870
|
-
*
|
|
871
|
-
* // Unknown method: provide explicit types
|
|
872
|
-
* const result = await rpc<MyType>("custom_method", [arg1, arg2]);
|
|
723
|
+
* const hash = await rpc.chain_getBlockHash(12345);
|
|
724
|
+
* const result = await rpc.state_call("ContractsApi_call", message, blockHash);
|
|
873
725
|
* ```
|
|
874
726
|
*/
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* Call a known RPC method with full type inference
|
|
878
|
-
*/
|
|
879
|
-
<M$1 extends KnownRpcMethod>(method: M$1, params: RpcParams<M$1>): Promise<RpcReturn<M$1>>;
|
|
880
|
-
/**
|
|
881
|
-
* Call an unknown RPC method with explicit type parameters
|
|
882
|
-
*/
|
|
883
|
-
<Reply = unknown, Params extends unknown[] = unknown[]>(method: string, params: Params): Promise<Reply>;
|
|
884
|
-
}
|
|
727
|
+
type TypedRpc = { [M in keyof SubstrateRpcMethods]: (...args: SubstrateRpcMethods[M][0]) => Promise<SubstrateRpcMethods[M][1]> };
|
|
885
728
|
//#endregion
|
|
886
729
|
//#region src/sdk.d.ts
|
|
887
730
|
/**
|
|
@@ -899,22 +742,22 @@ interface CreateD9InkSdkOptions extends D9InkSdkOptions {
|
|
|
899
742
|
*/
|
|
900
743
|
interface D9InkSdkWithRpc extends D9InkSdk {
|
|
901
744
|
/**
|
|
902
|
-
* Type-safe RPC
|
|
745
|
+
* Type-safe RPC interface with dot syntax
|
|
903
746
|
*
|
|
904
747
|
* Provides autocomplete for known Substrate RPC methods and type inference
|
|
905
748
|
* for parameters and return values.
|
|
906
749
|
*
|
|
907
750
|
* @example
|
|
908
751
|
* ```ts
|
|
909
|
-
* //
|
|
910
|
-
* const hash = await sdk.rpc(
|
|
752
|
+
* // Dot syntax with full type inference
|
|
753
|
+
* const hash = await sdk.rpc.chain_getBlockHash(12345);
|
|
911
754
|
* // hash: HexString | null
|
|
912
755
|
*
|
|
913
|
-
*
|
|
914
|
-
*
|
|
756
|
+
* const result = await sdk.rpc.state_call("ContractsApi_call", message, blockHash);
|
|
757
|
+
* // result: HexString
|
|
915
758
|
* ```
|
|
916
759
|
*/
|
|
917
|
-
rpc:
|
|
760
|
+
rpc: TypedRpc;
|
|
918
761
|
}
|
|
919
762
|
/**
|
|
920
763
|
* Create a D9 Ink SDK instance.
|
|
@@ -1450,31 +1293,30 @@ declare function isCallType<M$1 extends InkCallableDescriptor, L extends Extract
|
|
|
1450
1293
|
//#endregion
|
|
1451
1294
|
//#region src/rpc.d.ts
|
|
1452
1295
|
/**
|
|
1453
|
-
* Create a type-safe RPC
|
|
1296
|
+
* Create a type-safe RPC proxy from a PolkadotClient
|
|
1454
1297
|
*
|
|
1455
|
-
* This wraps the client's `_request` method with
|
|
1456
|
-
*
|
|
1457
|
-
* parameters and return values.
|
|
1298
|
+
* This wraps the client's `_request` method with a Proxy that provides
|
|
1299
|
+
* a dot-syntax interface with proper TypeScript types.
|
|
1458
1300
|
*
|
|
1459
1301
|
* @param client - The PolkadotClient instance
|
|
1460
|
-
* @returns A type-safe RPC
|
|
1302
|
+
* @returns A type-safe RPC proxy object
|
|
1461
1303
|
*
|
|
1462
1304
|
* @example
|
|
1463
1305
|
* ```ts
|
|
1464
1306
|
* const rpc = createTypedRpc(client);
|
|
1465
1307
|
*
|
|
1466
|
-
* //
|
|
1467
|
-
* const hash = await rpc(
|
|
1308
|
+
* // Dot syntax with full type inference
|
|
1309
|
+
* const hash = await rpc.chain_getBlockHash(12345);
|
|
1468
1310
|
* // hash: HexString | null
|
|
1469
1311
|
*
|
|
1470
|
-
* const header = await rpc(
|
|
1312
|
+
* const header = await rpc.chain_getHeader(hash);
|
|
1471
1313
|
* // header: BlockHeader | null
|
|
1472
1314
|
*
|
|
1473
|
-
*
|
|
1474
|
-
*
|
|
1315
|
+
* const result = await rpc.state_call("ContractsApi_call", message, blockHash);
|
|
1316
|
+
* // result: HexString
|
|
1475
1317
|
* ```
|
|
1476
1318
|
*/
|
|
1477
|
-
declare function createTypedRpc(client: PolkadotClient):
|
|
1319
|
+
declare function createTypedRpc(client: PolkadotClient): TypedRpc;
|
|
1478
1320
|
//#endregion
|
|
1479
1321
|
//#region src/utils/fees.d.ts
|
|
1480
1322
|
/**
|
|
@@ -1582,5 +1424,5 @@ declare function compareGasWeight(a: GasWeight, b: GasWeight): -1 | 0 | 1;
|
|
|
1582
1424
|
*/
|
|
1583
1425
|
declare function gasExceedsLimit(gas: GasWeight, limit: GasWeight): boolean;
|
|
1584
1426
|
//#endregion
|
|
1585
|
-
export { AbortedError, type BlockHeader, type CallFilterOptions, ContractCallParser, type ContractCallResult, ContractError, type ContractErrorType, ContractEventParser, ContractExecutionError, type ContractMessageBuilder, type ContractStorage, type CreateContractOptions, type CreateD9InkSdkOptions, type D9InkContract, type D9InkContractFromDescriptor, type D9InkSdk, type D9InkSdkOptions, type D9InkSdkWithRpc,
|
|
1427
|
+
export { AbortedError, type BlockHeader, type CallFilterOptions, ContractCallParser, type ContractCallResult, ContractError, type ContractErrorType, ContractEventParser, ContractExecutionError, type ContractMessageBuilder, type ContractStorage, type CreateContractOptions, type CreateD9InkSdkOptions, type D9InkContract, type D9InkContractFromDescriptor, type D9InkSdk, type D9InkSdkOptions, type D9InkSdkWithRpc, DecodeError, type DecodedContractEvent, EncodeError, EstimatedCost, type EventFilterOptions, type EventSubscriptionOptions, type ExtractEnumDef, type ExtractEventLabels, type ExtractMessageLabels, FormattedGasInfo, type GasInfo, GasWeight, type InferEvents, type InferMessages, InkCodecs, LangError, type MessageAttributes, type MessageInfo, MetadataError, NetworkError, type QueryOptions, type QueryResult, type QuerySuccessValue, type RawContractCall, type RawContractEvent, type ResponseDecoder, type RuntimeVersion, type SendOptions, type SendableTransaction, SignerError, type StorageChangeSet, type StorageDepositInfo, type SubstrateRpcMethods, type SystemHealth, TimeoutError, TransactionError, type TxResult, type TypedCallFilterOptions, type TypedContractCall, type TypedContractEvent, type TypedEventFilterOptions, type TypedMessage, type TypedRpc, applyGasMargin, buildAllEventDecoders, buildAllMessageDecoders, buildEventDecoder, buildMessageDecoder, compareGasWeight, createAsciiEventTopic, createCodecRegistry, createContractEventStream, createD9InkContract, createD9InkSdk, createMessageBuilder, createNativeTransferStream, createPSP22TransferStream, createTypedRpc, decodeContractCallResult, decodeInkValue, encodeCall, encodeContractCall, encodeContractCallWithLimits, estimateTransactionCost, formatGasInfo, gasExceedsLimit, getEventSignature, isCallType, isContractError, isErrorType, isEventType, isLangError, unwrapInkResult };
|
|
1586
1428
|
//# sourceMappingURL=index.d.mts.map
|