@mysten/sui 1.26.1 → 1.27.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/CHANGELOG.md +13 -0
- package/dist/cjs/bcs/bcs.d.ts +3 -2
- package/dist/cjs/bcs/bcs.js +3 -3
- package/dist/cjs/bcs/bcs.js.map +2 -2
- package/dist/cjs/bcs/effects.d.ts +18 -12
- package/dist/cjs/bcs/index.d.ts +460 -453
- package/dist/cjs/bcs/index.js +4 -4
- package/dist/cjs/bcs/index.js.map +1 -1
- package/dist/cjs/client/client.d.ts +38 -16
- package/dist/cjs/client/client.js +142 -62
- package/dist/cjs/client/client.js.map +2 -2
- package/dist/cjs/client/http-transport.d.ts +2 -0
- package/dist/cjs/client/http-transport.js +7 -0
- package/dist/cjs/client/http-transport.js.map +2 -2
- package/dist/cjs/client/rpc-websocket-client.d.ts +2 -1
- package/dist/cjs/client/rpc-websocket-client.js +7 -2
- package/dist/cjs/client/rpc-websocket-client.js.map +2 -2
- package/dist/cjs/client/types/generated.d.ts +1 -0
- package/dist/cjs/client/types/generated.js.map +1 -1
- package/dist/cjs/client/types/params.d.ts +56 -0
- package/dist/cjs/client/types/params.js.map +1 -1
- package/dist/cjs/experimental/cache.d.ts +11 -0
- package/dist/cjs/experimental/cache.js +79 -0
- package/dist/cjs/experimental/cache.js.map +7 -0
- package/dist/cjs/experimental/client.d.ts +4 -2
- package/dist/cjs/experimental/client.js +4 -2
- package/dist/cjs/experimental/client.js.map +2 -2
- package/dist/cjs/experimental/core.d.ts +10 -2
- package/dist/cjs/experimental/core.js +59 -1
- package/dist/cjs/experimental/core.js.map +2 -2
- package/dist/cjs/experimental/index.d.ts +5 -0
- package/dist/cjs/experimental/index.js +29 -0
- package/dist/cjs/experimental/index.js.map +7 -0
- package/dist/cjs/experimental/transports/jsonRPC.d.ts +19 -5
- package/dist/cjs/experimental/transports/jsonRPC.js +270 -12
- package/dist/cjs/experimental/transports/jsonRPC.js.map +2 -2
- package/dist/cjs/experimental/types.d.ts +84 -41
- package/dist/cjs/experimental/types.js.map +1 -1
- package/dist/cjs/keypairs/secp256k1/keypair.js +1 -1
- package/dist/cjs/keypairs/secp256k1/keypair.js.map +2 -2
- package/dist/cjs/keypairs/secp256r1/keypair.js +1 -1
- package/dist/cjs/keypairs/secp256r1/keypair.js.map +2 -2
- package/dist/cjs/multisig/publickey.js +5 -5
- package/dist/cjs/multisig/publickey.js.map +2 -2
- package/dist/cjs/multisig/signer.js +2 -2
- package/dist/cjs/multisig/signer.js.map +2 -2
- package/dist/cjs/transactions/intents/CoinWithBalance.d.ts +2 -2
- package/dist/cjs/transactions/intents/CoinWithBalance.js +6 -1
- package/dist/cjs/transactions/intents/CoinWithBalance.js.map +2 -2
- package/dist/cjs/transactions/plugins/utils.js +2 -2
- package/dist/cjs/transactions/plugins/utils.js.map +2 -2
- package/dist/cjs/version.d.ts +2 -2
- package/dist/cjs/version.js +2 -2
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/bcs/bcs.d.ts +3 -2
- package/dist/esm/bcs/bcs.js +3 -3
- package/dist/esm/bcs/bcs.js.map +2 -2
- package/dist/esm/bcs/effects.d.ts +18 -12
- package/dist/esm/bcs/index.d.ts +460 -453
- package/dist/esm/bcs/index.js +4 -4
- package/dist/esm/bcs/index.js.map +1 -1
- package/dist/esm/client/client.d.ts +38 -16
- package/dist/esm/client/client.js +143 -63
- package/dist/esm/client/client.js.map +2 -2
- package/dist/esm/client/http-transport.d.ts +2 -0
- package/dist/esm/client/http-transport.js +7 -0
- package/dist/esm/client/http-transport.js.map +2 -2
- package/dist/esm/client/rpc-websocket-client.d.ts +2 -1
- package/dist/esm/client/rpc-websocket-client.js +7 -2
- package/dist/esm/client/rpc-websocket-client.js.map +2 -2
- package/dist/esm/client/types/generated.d.ts +1 -0
- package/dist/esm/client/types/params.d.ts +56 -0
- package/dist/esm/experimental/cache.d.ts +11 -0
- package/dist/esm/experimental/cache.js +59 -0
- package/dist/esm/experimental/cache.js.map +7 -0
- package/dist/esm/experimental/client.d.ts +4 -2
- package/dist/esm/experimental/client.js +4 -2
- package/dist/esm/experimental/client.js.map +2 -2
- package/dist/esm/experimental/core.d.ts +10 -2
- package/dist/esm/experimental/core.js +60 -2
- package/dist/esm/experimental/core.js.map +2 -2
- package/dist/esm/experimental/index.d.ts +5 -0
- package/dist/esm/experimental/index.js +9 -0
- package/dist/esm/experimental/index.js.map +7 -0
- package/dist/esm/experimental/transports/jsonRPC.d.ts +19 -5
- package/dist/esm/experimental/transports/jsonRPC.js +270 -12
- package/dist/esm/experimental/transports/jsonRPC.js.map +2 -2
- package/dist/esm/experimental/types.d.ts +84 -41
- package/dist/esm/keypairs/secp256k1/keypair.js +1 -1
- package/dist/esm/keypairs/secp256k1/keypair.js.map +2 -2
- package/dist/esm/keypairs/secp256r1/keypair.js +1 -1
- package/dist/esm/keypairs/secp256r1/keypair.js.map +2 -2
- package/dist/esm/multisig/publickey.js +5 -5
- package/dist/esm/multisig/publickey.js.map +2 -2
- package/dist/esm/multisig/signer.js +2 -2
- package/dist/esm/multisig/signer.js.map +2 -2
- package/dist/esm/transactions/intents/CoinWithBalance.d.ts +2 -2
- package/dist/esm/transactions/intents/CoinWithBalance.js +6 -1
- package/dist/esm/transactions/intents/CoinWithBalance.js.map +2 -2
- package/dist/esm/transactions/plugins/utils.js +2 -2
- package/dist/esm/transactions/plugins/utils.js.map +2 -2
- package/dist/esm/version.d.ts +2 -2
- package/dist/esm/version.js +2 -2
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/experimental/package.json +6 -0
- package/package.json +7 -2
- package/src/bcs/bcs.ts +3 -3
- package/src/bcs/index.ts +3 -3
- package/src/client/client.ts +119 -26
- package/src/client/http-transport.ts +10 -0
- package/src/client/rpc-websocket-client.ts +8 -1
- package/src/client/types/generated.ts +1 -0
- package/src/client/types/params.ts +68 -6
- package/src/experimental/cache.ts +64 -0
- package/src/experimental/client.ts +4 -2
- package/src/experimental/core.ts +89 -2
- package/src/experimental/index.ts +20 -0
- package/src/experimental/transports/jsonRPC.ts +319 -9
- package/src/experimental/types.ts +92 -48
- package/src/keypairs/secp256k1/keypair.ts +1 -1
- package/src/keypairs/secp256r1/keypair.ts +1 -1
- package/src/multisig/publickey.ts +5 -5
- package/src/multisig/signer.ts +2 -2
- package/src/transactions/__tests__/bcs.test.ts +2 -2
- package/src/transactions/intents/CoinWithBalance.ts +11 -3
- package/src/transactions/plugins/utils.ts +2 -2
- package/src/version.ts +2 -2
|
@@ -28,6 +28,7 @@ export interface DevInspectTransactionBlockParams {
|
|
|
28
28
|
epoch?: string | null | undefined;
|
|
29
29
|
/** Additional arguments including gas_budget, gas_objects, gas_sponsor and skip_checks. */
|
|
30
30
|
additionalArgs?: RpcTypes.DevInspectArgs | null | undefined;
|
|
31
|
+
signal?: AbortSignal;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Return transaction execution effects including the gas cost summary, while the effects are not
|
|
@@ -35,6 +36,7 @@ export interface DevInspectTransactionBlockParams {
|
|
|
35
36
|
*/
|
|
36
37
|
export interface DryRunTransactionBlockParams {
|
|
37
38
|
transactionBlock: Uint8Array | string;
|
|
39
|
+
signal?: AbortSignal;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* Execute the transaction and wait for results if desired. Request types: 1. WaitForEffectsCert: waits
|
|
@@ -58,13 +60,17 @@ export interface ExecuteTransactionBlockParams {
|
|
|
58
60
|
options?: RpcTypes.SuiTransactionBlockResponseOptions | null | undefined;
|
|
59
61
|
/** @deprecated requestType will be ignored by JSON RPC in the future */
|
|
60
62
|
requestType?: RpcTypes.ExecuteTransactionRequestType | null | undefined;
|
|
63
|
+
signal?: AbortSignal;
|
|
61
64
|
}
|
|
62
65
|
/** Return the first four bytes of the chain's genesis checkpoint digest. */
|
|
63
|
-
export interface GetChainIdentifierParams {
|
|
66
|
+
export interface GetChainIdentifierParams {
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
}
|
|
64
69
|
/** Return a checkpoint */
|
|
65
70
|
export interface GetCheckpointParams {
|
|
66
71
|
/** Checkpoint identifier, can use either checkpoint digest, or checkpoint sequence number as input. */
|
|
67
72
|
id: RpcTypes.CheckpointId;
|
|
73
|
+
signal?: AbortSignal;
|
|
68
74
|
}
|
|
69
75
|
/** Return paginated list of checkpoints */
|
|
70
76
|
export interface GetCheckpointsParams {
|
|
@@ -77,40 +83,49 @@ export interface GetCheckpointsParams {
|
|
|
77
83
|
limit?: number | null | undefined;
|
|
78
84
|
/** query result ordering, default to false (ascending order), oldest record first. */
|
|
79
85
|
descendingOrder: boolean;
|
|
86
|
+
signal?: AbortSignal;
|
|
80
87
|
}
|
|
81
88
|
/** Return transaction events. */
|
|
82
89
|
export interface GetEventsParams {
|
|
83
90
|
/** the event query criteria. */
|
|
84
91
|
transactionDigest: string;
|
|
92
|
+
signal?: AbortSignal;
|
|
85
93
|
}
|
|
86
94
|
/** Return the sequence number of the latest checkpoint that has been executed */
|
|
87
|
-
export interface GetLatestCheckpointSequenceNumberParams {
|
|
95
|
+
export interface GetLatestCheckpointSequenceNumberParams {
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
}
|
|
88
98
|
/** Return the argument types of a Move function, based on normalized Type. */
|
|
89
99
|
export interface GetMoveFunctionArgTypesParams {
|
|
90
100
|
package: string;
|
|
91
101
|
module: string;
|
|
92
102
|
function: string;
|
|
103
|
+
signal?: AbortSignal;
|
|
93
104
|
}
|
|
94
105
|
/** Return a structured representation of Move function */
|
|
95
106
|
export interface GetNormalizedMoveFunctionParams {
|
|
96
107
|
package: string;
|
|
97
108
|
module: string;
|
|
98
109
|
function: string;
|
|
110
|
+
signal?: AbortSignal;
|
|
99
111
|
}
|
|
100
112
|
/** Return a structured representation of Move module */
|
|
101
113
|
export interface GetNormalizedMoveModuleParams {
|
|
102
114
|
package: string;
|
|
103
115
|
module: string;
|
|
116
|
+
signal?: AbortSignal;
|
|
104
117
|
}
|
|
105
118
|
/** Return structured representations of all modules in the given package */
|
|
106
119
|
export interface GetNormalizedMoveModulesByPackageParams {
|
|
107
120
|
package: string;
|
|
121
|
+
signal?: AbortSignal;
|
|
108
122
|
}
|
|
109
123
|
/** Return a structured representation of Move struct */
|
|
110
124
|
export interface GetNormalizedMoveStructParams {
|
|
111
125
|
package: string;
|
|
112
126
|
module: string;
|
|
113
127
|
struct: string;
|
|
128
|
+
signal?: AbortSignal;
|
|
114
129
|
}
|
|
115
130
|
/** Return the object information for a specified object */
|
|
116
131
|
export interface GetObjectParams {
|
|
@@ -118,6 +133,7 @@ export interface GetObjectParams {
|
|
|
118
133
|
id: string;
|
|
119
134
|
/** options for specifying the content to be returned */
|
|
120
135
|
options?: RpcTypes.SuiObjectDataOptions | null | undefined;
|
|
136
|
+
signal?: AbortSignal;
|
|
121
137
|
}
|
|
122
138
|
/**
|
|
123
139
|
* Return the protocol config table for the given version number. If the version number is not
|
|
@@ -129,15 +145,19 @@ export interface GetProtocolConfigParams {
|
|
|
129
145
|
* will be returned.
|
|
130
146
|
*/
|
|
131
147
|
version?: string | null | undefined;
|
|
148
|
+
signal?: AbortSignal;
|
|
132
149
|
}
|
|
133
150
|
/** Return the total number of transaction blocks known to the server. */
|
|
134
|
-
export interface GetTotalTransactionBlocksParams {
|
|
151
|
+
export interface GetTotalTransactionBlocksParams {
|
|
152
|
+
signal?: AbortSignal;
|
|
153
|
+
}
|
|
135
154
|
/** Return the transaction response object. */
|
|
136
155
|
export interface GetTransactionBlockParams {
|
|
137
156
|
/** the digest of the queried transaction */
|
|
138
157
|
digest: string;
|
|
139
158
|
/** options for specifying the content to be returned */
|
|
140
159
|
options?: RpcTypes.SuiTransactionBlockResponseOptions | null | undefined;
|
|
160
|
+
signal?: AbortSignal;
|
|
141
161
|
}
|
|
142
162
|
/** Return the object data for a list of objects */
|
|
143
163
|
export interface MultiGetObjectsParams {
|
|
@@ -145,6 +165,7 @@ export interface MultiGetObjectsParams {
|
|
|
145
165
|
ids: string[];
|
|
146
166
|
/** options for specifying the content to be returned */
|
|
147
167
|
options?: RpcTypes.SuiObjectDataOptions | null | undefined;
|
|
168
|
+
signal?: AbortSignal;
|
|
148
169
|
}
|
|
149
170
|
/**
|
|
150
171
|
* Returns an ordered list of transaction responses The method will throw an error if the input
|
|
@@ -155,6 +176,7 @@ export interface MultiGetTransactionBlocksParams {
|
|
|
155
176
|
digests: string[];
|
|
156
177
|
/** config options to control which fields to fetch */
|
|
157
178
|
options?: RpcTypes.SuiTransactionBlockResponseOptions | null | undefined;
|
|
179
|
+
signal?: AbortSignal;
|
|
158
180
|
}
|
|
159
181
|
/**
|
|
160
182
|
* Note there is no software-level guarantee/SLA that objects with past versions can be retrieved by
|
|
@@ -168,6 +190,7 @@ export interface TryGetPastObjectParams {
|
|
|
168
190
|
version: number;
|
|
169
191
|
/** options for specifying the content to be returned */
|
|
170
192
|
options?: RpcTypes.SuiObjectDataOptions | null | undefined;
|
|
193
|
+
signal?: AbortSignal;
|
|
171
194
|
}
|
|
172
195
|
/**
|
|
173
196
|
* Note there is no software-level guarantee/SLA that objects with past versions can be retrieved by
|
|
@@ -179,6 +202,7 @@ export interface TryMultiGetPastObjectsParams {
|
|
|
179
202
|
pastObjects: RpcTypes.GetPastObjectRequest[];
|
|
180
203
|
/** options for specifying the content to be returned */
|
|
181
204
|
options?: RpcTypes.SuiObjectDataOptions | null | undefined;
|
|
205
|
+
signal?: AbortSignal;
|
|
182
206
|
}
|
|
183
207
|
/** Verify a zklogin signature for the given bytes, intent scope and author. */
|
|
184
208
|
export interface VerifyZkLoginSignatureParams {
|
|
@@ -193,11 +217,13 @@ export interface VerifyZkLoginSignatureParams {
|
|
|
193
217
|
intentScope: RpcTypes.ZkLoginIntentScope;
|
|
194
218
|
/** The author of the signature. */
|
|
195
219
|
author: string;
|
|
220
|
+
signal?: AbortSignal;
|
|
196
221
|
}
|
|
197
222
|
/** Return the total coin balance for all coin type, owned by the address owner. */
|
|
198
223
|
export interface GetAllBalancesParams {
|
|
199
224
|
/** the owner's Sui address */
|
|
200
225
|
owner: string;
|
|
226
|
+
signal?: AbortSignal;
|
|
201
227
|
}
|
|
202
228
|
/** Return all Coin objects owned by an address. */
|
|
203
229
|
export interface GetAllCoinsParams {
|
|
@@ -207,6 +233,7 @@ export interface GetAllCoinsParams {
|
|
|
207
233
|
cursor?: string | null | undefined;
|
|
208
234
|
/** maximum number of items per page */
|
|
209
235
|
limit?: number | null | undefined;
|
|
236
|
+
signal?: AbortSignal;
|
|
210
237
|
}
|
|
211
238
|
/** Return the total coin balance for one coin type, owned by the address owner. */
|
|
212
239
|
export interface GetBalanceParams {
|
|
@@ -217,6 +244,7 @@ export interface GetBalanceParams {
|
|
|
217
244
|
* default to 0x2::sui::SUI if not specified.
|
|
218
245
|
*/
|
|
219
246
|
coinType?: string | null | undefined;
|
|
247
|
+
signal?: AbortSignal;
|
|
220
248
|
}
|
|
221
249
|
/**
|
|
222
250
|
* Return metadata (e.g., symbol, decimals) for a coin. Note that if the coin's metadata was wrapped in
|
|
@@ -226,6 +254,7 @@ export interface GetBalanceParams {
|
|
|
226
254
|
export interface GetCoinMetadataParams {
|
|
227
255
|
/** type name for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC) */
|
|
228
256
|
coinType: string;
|
|
257
|
+
signal?: AbortSignal;
|
|
229
258
|
}
|
|
230
259
|
/** Return all Coin<`coin_type`> objects owned by an address. */
|
|
231
260
|
export interface GetCoinsParams {
|
|
@@ -240,11 +269,13 @@ export interface GetCoinsParams {
|
|
|
240
269
|
cursor?: string | null | undefined;
|
|
241
270
|
/** maximum number of items per page */
|
|
242
271
|
limit?: number | null | undefined;
|
|
272
|
+
signal?: AbortSignal;
|
|
243
273
|
}
|
|
244
274
|
/** Return the committee information for the asked `epoch`. */
|
|
245
275
|
export interface GetCommitteeInfoParams {
|
|
246
276
|
/** The epoch of interest. If None, default to the latest epoch */
|
|
247
277
|
epoch?: string | null | undefined;
|
|
278
|
+
signal?: AbortSignal;
|
|
248
279
|
}
|
|
249
280
|
/** Return the dynamic field object information for a specified object */
|
|
250
281
|
export interface GetDynamicFieldObjectParams {
|
|
@@ -252,6 +283,7 @@ export interface GetDynamicFieldObjectParams {
|
|
|
252
283
|
parentId: string;
|
|
253
284
|
/** The Name of the dynamic field */
|
|
254
285
|
name: RpcTypes.DynamicFieldName;
|
|
286
|
+
signal?: AbortSignal;
|
|
255
287
|
}
|
|
256
288
|
/** Return the list of dynamic field objects owned by an object. */
|
|
257
289
|
export interface GetDynamicFieldsParams {
|
|
@@ -264,9 +296,12 @@ export interface GetDynamicFieldsParams {
|
|
|
264
296
|
cursor?: string | null | undefined;
|
|
265
297
|
/** Maximum item returned per page, default to [QUERY_MAX_RESULT_LIMIT] if not specified. */
|
|
266
298
|
limit?: number | null | undefined;
|
|
299
|
+
signal?: AbortSignal;
|
|
267
300
|
}
|
|
268
301
|
/** Return the latest SUI system state object on-chain. */
|
|
269
|
-
export interface GetLatestSuiSystemStateParams {
|
|
302
|
+
export interface GetLatestSuiSystemStateParams {
|
|
303
|
+
signal?: AbortSignal;
|
|
304
|
+
}
|
|
270
305
|
/**
|
|
271
306
|
* Return the list of objects owned by an address. Note that if the address owns more than
|
|
272
307
|
* `QUERY_MAX_RESULT_LIMIT` objects, the pagination is not accurate, because previous page may have
|
|
@@ -282,24 +317,32 @@ export type GetOwnedObjectsParams = {
|
|
|
282
317
|
cursor?: string | null | undefined;
|
|
283
318
|
/** Max number of items returned per page, default to [QUERY_MAX_RESULT_LIMIT] if not specified. */
|
|
284
319
|
limit?: number | null | undefined;
|
|
320
|
+
signal?: AbortSignal;
|
|
285
321
|
} & RpcTypes.SuiObjectResponseQuery;
|
|
286
322
|
/** Return the reference gas price for the network */
|
|
287
|
-
export interface GetReferenceGasPriceParams {
|
|
323
|
+
export interface GetReferenceGasPriceParams {
|
|
324
|
+
signal?: AbortSignal;
|
|
325
|
+
}
|
|
288
326
|
/** Return all [DelegatedStake]. */
|
|
289
327
|
export interface GetStakesParams {
|
|
290
328
|
owner: string;
|
|
329
|
+
signal?: AbortSignal;
|
|
291
330
|
}
|
|
292
331
|
/** Return one or more [DelegatedStake]. If a Stake was withdrawn its status will be Unstaked. */
|
|
293
332
|
export interface GetStakesByIdsParams {
|
|
294
333
|
stakedSuiIds: string[];
|
|
334
|
+
signal?: AbortSignal;
|
|
295
335
|
}
|
|
296
336
|
/** Return total supply for a coin */
|
|
297
337
|
export interface GetTotalSupplyParams {
|
|
298
338
|
/** type name for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC) */
|
|
299
339
|
coinType: string;
|
|
340
|
+
signal?: AbortSignal;
|
|
300
341
|
}
|
|
301
342
|
/** Return the validator APY */
|
|
302
|
-
export interface GetValidatorsApyParams {
|
|
343
|
+
export interface GetValidatorsApyParams {
|
|
344
|
+
signal?: AbortSignal;
|
|
345
|
+
}
|
|
303
346
|
/** Return list of events for a specified query criteria. */
|
|
304
347
|
export interface QueryEventsParams {
|
|
305
348
|
/**
|
|
@@ -313,6 +356,7 @@ export interface QueryEventsParams {
|
|
|
313
356
|
limit?: number | null | undefined;
|
|
314
357
|
/** query result ordering, default to false (ascending order), oldest record first. */
|
|
315
358
|
order?: 'ascending' | 'descending' | null | undefined;
|
|
359
|
+
signal?: AbortSignal;
|
|
316
360
|
}
|
|
317
361
|
/** Return list of transactions for a specified query criteria. */
|
|
318
362
|
export type QueryTransactionBlocksParams = {
|
|
@@ -325,11 +369,13 @@ export type QueryTransactionBlocksParams = {
|
|
|
325
369
|
limit?: number | null | undefined;
|
|
326
370
|
/** query result ordering, default to false (ascending order), oldest record first. */
|
|
327
371
|
order?: 'ascending' | 'descending' | null | undefined;
|
|
372
|
+
signal?: AbortSignal;
|
|
328
373
|
} & RpcTypes.SuiTransactionBlockResponseQuery;
|
|
329
374
|
/** Return the resolved address given resolver and name */
|
|
330
375
|
export interface ResolveNameServiceAddressParams {
|
|
331
376
|
/** The name to resolve */
|
|
332
377
|
name: string;
|
|
378
|
+
signal?: AbortSignal;
|
|
333
379
|
}
|
|
334
380
|
/**
|
|
335
381
|
* Return the resolved names given address, if multiple names are resolved, the first one is the
|
|
@@ -340,6 +386,7 @@ export interface ResolveNameServiceNamesParams {
|
|
|
340
386
|
address: string;
|
|
341
387
|
cursor?: string | null | undefined;
|
|
342
388
|
limit?: number | null | undefined;
|
|
389
|
+
signal?: AbortSignal;
|
|
343
390
|
}
|
|
344
391
|
/** Subscribe to a stream of Sui event */
|
|
345
392
|
export interface SubscribeEventParams {
|
|
@@ -348,10 +395,12 @@ export interface SubscribeEventParams {
|
|
|
348
395
|
* [Event filter](https://docs.sui.io/build/event_api#event-filters) documentation for examples.
|
|
349
396
|
*/
|
|
350
397
|
filter: RpcTypes.SuiEventFilter;
|
|
398
|
+
signal?: AbortSignal;
|
|
351
399
|
}
|
|
352
400
|
/** Subscribe to a stream of Sui transaction effects */
|
|
353
401
|
export interface SubscribeTransactionParams {
|
|
354
402
|
filter: RpcTypes.TransactionFilter;
|
|
403
|
+
signal?: AbortSignal;
|
|
355
404
|
}
|
|
356
405
|
/** Create an unsigned batched transaction. */
|
|
357
406
|
export interface UnsafeBatchTransactionParams {
|
|
@@ -368,6 +417,7 @@ export interface UnsafeBatchTransactionParams {
|
|
|
368
417
|
gasBudget: string;
|
|
369
418
|
/** Whether this is a regular transaction or a Dev Inspect Transaction */
|
|
370
419
|
txnBuilderMode?: RpcTypes.SuiTransactionBlockBuilderMode | null | undefined;
|
|
420
|
+
signal?: AbortSignal;
|
|
371
421
|
}
|
|
372
422
|
/** Create an unsigned transaction to merge multiple coins into one coin. */
|
|
373
423
|
export interface UnsafeMergeCoinsParams {
|
|
@@ -387,6 +437,7 @@ export interface UnsafeMergeCoinsParams {
|
|
|
387
437
|
gas?: string | null | undefined;
|
|
388
438
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
389
439
|
gasBudget: string;
|
|
440
|
+
signal?: AbortSignal;
|
|
390
441
|
}
|
|
391
442
|
/**
|
|
392
443
|
* Create an unsigned transaction to execute a Move call on the network, by calling the specified
|
|
@@ -420,6 +471,7 @@ export interface UnsafeMoveCallParams {
|
|
|
420
471
|
* `SuiTransactionBlockBuilderMode::Commit` when it's None.
|
|
421
472
|
*/
|
|
422
473
|
executionMode?: RpcTypes.SuiTransactionBlockBuilderMode | null | undefined;
|
|
474
|
+
signal?: AbortSignal;
|
|
423
475
|
}
|
|
424
476
|
/**
|
|
425
477
|
* Send `Coin<T>` to a list of addresses, where `T` can be any coin type, following a list of amounts,
|
|
@@ -443,6 +495,7 @@ export interface UnsafePayParams {
|
|
|
443
495
|
gas?: string | null | undefined;
|
|
444
496
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
445
497
|
gasBudget: string;
|
|
498
|
+
signal?: AbortSignal;
|
|
446
499
|
}
|
|
447
500
|
/**
|
|
448
501
|
* Send all SUI coins to one recipient. This is for SUI coin only and does not require a separate gas
|
|
@@ -460,6 +513,7 @@ export interface UnsafePayAllSuiParams {
|
|
|
460
513
|
recipient: string;
|
|
461
514
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
462
515
|
gasBudget: string;
|
|
516
|
+
signal?: AbortSignal;
|
|
463
517
|
}
|
|
464
518
|
/**
|
|
465
519
|
* Send SUI coins to a list of addresses, following a list of amounts. This is for SUI coin only and
|
|
@@ -481,6 +535,7 @@ export interface UnsafePaySuiParams {
|
|
|
481
535
|
amounts: string[];
|
|
482
536
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
483
537
|
gasBudget: string;
|
|
538
|
+
signal?: AbortSignal;
|
|
484
539
|
}
|
|
485
540
|
/** Create an unsigned transaction to publish a Move package. */
|
|
486
541
|
export interface UnsafePublishParams {
|
|
@@ -497,6 +552,7 @@ export interface UnsafePublishParams {
|
|
|
497
552
|
gas?: string | null | undefined;
|
|
498
553
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
499
554
|
gasBudget: string;
|
|
555
|
+
signal?: AbortSignal;
|
|
500
556
|
}
|
|
501
557
|
/** Add stake to a validator's staking pool using multiple coins and amount. */
|
|
502
558
|
export interface UnsafeRequestAddStakeParams {
|
|
@@ -515,6 +571,7 @@ export interface UnsafeRequestAddStakeParams {
|
|
|
515
571
|
gas?: string | null | undefined;
|
|
516
572
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
517
573
|
gasBudget: string;
|
|
574
|
+
signal?: AbortSignal;
|
|
518
575
|
}
|
|
519
576
|
/** Withdraw stake from a validator's staking pool. */
|
|
520
577
|
export interface UnsafeRequestWithdrawStakeParams {
|
|
@@ -529,6 +586,7 @@ export interface UnsafeRequestWithdrawStakeParams {
|
|
|
529
586
|
gas?: string | null | undefined;
|
|
530
587
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
531
588
|
gasBudget: string;
|
|
589
|
+
signal?: AbortSignal;
|
|
532
590
|
}
|
|
533
591
|
/** Create an unsigned transaction to split a coin object into multiple coins. */
|
|
534
592
|
export interface UnsafeSplitCoinParams {
|
|
@@ -545,6 +603,7 @@ export interface UnsafeSplitCoinParams {
|
|
|
545
603
|
gas?: string | null | undefined;
|
|
546
604
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
547
605
|
gasBudget: string;
|
|
606
|
+
signal?: AbortSignal;
|
|
548
607
|
}
|
|
549
608
|
/** Create an unsigned transaction to split a coin object into multiple equal-size coins. */
|
|
550
609
|
export interface UnsafeSplitCoinEqualParams {
|
|
@@ -561,6 +620,7 @@ export interface UnsafeSplitCoinEqualParams {
|
|
|
561
620
|
gas?: string | null | undefined;
|
|
562
621
|
/** the gas budget, the transaction will fail if the gas cost exceed the budget */
|
|
563
622
|
gasBudget: string;
|
|
623
|
+
signal?: AbortSignal;
|
|
564
624
|
}
|
|
565
625
|
/**
|
|
566
626
|
* Create an unsigned transaction to transfer an object from one address to another. The object's type
|
|
@@ -580,6 +640,7 @@ export interface UnsafeTransferObjectParams {
|
|
|
580
640
|
gasBudget: string;
|
|
581
641
|
/** the recipient's Sui address */
|
|
582
642
|
recipient: string;
|
|
643
|
+
signal?: AbortSignal;
|
|
583
644
|
}
|
|
584
645
|
/**
|
|
585
646
|
* Create an unsigned transaction to send SUI coin object to a Sui address. The SUI object is also used
|
|
@@ -596,4 +657,5 @@ export interface UnsafeTransferSuiParams {
|
|
|
596
657
|
recipient: string;
|
|
597
658
|
/** the amount to be split out and transferred */
|
|
598
659
|
amount?: string | null | undefined;
|
|
660
|
+
signal?: AbortSignal;
|
|
599
661
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export interface ClientCacheOptions {
|
|
5
|
+
prefix?: string[];
|
|
6
|
+
cache?: Map<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class ClientCache {
|
|
10
|
+
#prefix: string[];
|
|
11
|
+
#cache: Map<string, unknown>;
|
|
12
|
+
|
|
13
|
+
constructor({ prefix, cache }: ClientCacheOptions = {}) {
|
|
14
|
+
this.#prefix = prefix ?? [];
|
|
15
|
+
this.#cache = cache ?? new Map();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
read<T>(key: [string, ...string[]], load: () => T | Promise<T>): T | Promise<T> {
|
|
19
|
+
const cacheKey = [this.#prefix, ...key].join(':');
|
|
20
|
+
|
|
21
|
+
if (this.#cache.has(cacheKey)) {
|
|
22
|
+
return this.#cache.get(cacheKey) as T;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const result = load();
|
|
26
|
+
|
|
27
|
+
this.#cache.set(cacheKey, result);
|
|
28
|
+
|
|
29
|
+
if (typeof result === 'object' && result !== null && 'then' in result) {
|
|
30
|
+
return Promise.resolve(result)
|
|
31
|
+
.then((v) => {
|
|
32
|
+
this.#cache.set(cacheKey, v);
|
|
33
|
+
return v as T;
|
|
34
|
+
})
|
|
35
|
+
.catch((err) => {
|
|
36
|
+
this.#cache.delete(cacheKey);
|
|
37
|
+
throw err;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return result as T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
clear(prefix?: string[]) {
|
|
45
|
+
const prefixKey = [...this.#prefix, ...(prefix ?? [])].join(':');
|
|
46
|
+
if (!prefixKey) {
|
|
47
|
+
this.#cache.clear();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (const key of this.#cache.keys()) {
|
|
52
|
+
if (key.startsWith(prefixKey)) {
|
|
53
|
+
this.#cache.delete(key);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
scope(prefix: string | string[]) {
|
|
59
|
+
return new ClientCache({
|
|
60
|
+
prefix: [...this.#prefix, ...(Array.isArray(prefix) ? prefix : [prefix])],
|
|
61
|
+
cache: this.#cache,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
4
4
|
|
|
5
|
+
import { ClientCache } from './cache.js';
|
|
5
6
|
import type { Experimental_CoreClient } from './core.js';
|
|
6
7
|
import type {
|
|
7
8
|
ClientWithExtensions,
|
|
@@ -11,8 +12,9 @@ import type {
|
|
|
11
12
|
UnionToIntersection,
|
|
12
13
|
} from './types.js';
|
|
13
14
|
|
|
14
|
-
export abstract class
|
|
15
|
+
export abstract class Experimental_BaseClient {
|
|
15
16
|
network: Experimental_SuiClientTypes.Network;
|
|
17
|
+
cache = new ClientCache();
|
|
16
18
|
|
|
17
19
|
constructor({ network }: Experimental_SuiClientTypes.SuiClientOptions) {
|
|
18
20
|
this.network = network;
|
|
@@ -40,7 +42,7 @@ export abstract class Experimental_SuiClient {
|
|
|
40
42
|
{
|
|
41
43
|
[K in keyof this]: this[K];
|
|
42
44
|
},
|
|
43
|
-
keyof
|
|
45
|
+
keyof Experimental_BaseClient
|
|
44
46
|
> &
|
|
45
47
|
UnionToIntersection<
|
|
46
48
|
{
|
package/src/experimental/core.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { TypeTagSerializer } from '../bcs/type-tag-serializer.js';
|
|
5
|
+
import { deriveDynamicFieldID } from '../utils/dynamic-fields.js';
|
|
6
|
+
import { normalizeStructTag, parseStructTag, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';
|
|
7
|
+
import { Experimental_BaseClient } from './client.js';
|
|
5
8
|
import type { Experimental_SuiClientTypes } from './types.js';
|
|
6
9
|
|
|
7
10
|
export abstract class Experimental_CoreClient
|
|
8
|
-
extends
|
|
11
|
+
extends Experimental_BaseClient
|
|
9
12
|
implements Experimental_SuiClientTypes.TransportMethods
|
|
10
13
|
{
|
|
11
14
|
core = this;
|
|
@@ -43,4 +46,88 @@ export abstract class Experimental_CoreClient
|
|
|
43
46
|
): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse>;
|
|
44
47
|
|
|
45
48
|
abstract getReferenceGasPrice(): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse>;
|
|
49
|
+
|
|
50
|
+
abstract getDynamicFields(
|
|
51
|
+
options: Experimental_SuiClientTypes.GetDynamicFieldsOptions,
|
|
52
|
+
): Promise<Experimental_SuiClientTypes.GetDynamicFieldsResponse>;
|
|
53
|
+
|
|
54
|
+
async getDynamicField(
|
|
55
|
+
options: Experimental_SuiClientTypes.GetDynamicFieldOptions,
|
|
56
|
+
): Promise<Experimental_SuiClientTypes.GetDynamicFieldResponse> {
|
|
57
|
+
const fieldId = deriveDynamicFieldID(
|
|
58
|
+
options.parentId,
|
|
59
|
+
TypeTagSerializer.parseFromStr(options.name.type),
|
|
60
|
+
options.name.bcs,
|
|
61
|
+
);
|
|
62
|
+
const {
|
|
63
|
+
objects: [fieldObject],
|
|
64
|
+
} = await this.getObjects({
|
|
65
|
+
objectIds: [fieldId],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (fieldObject instanceof Error) {
|
|
69
|
+
throw fieldObject;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const fieldType = parseStructTag(fieldObject.type);
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
dynamicField: {
|
|
76
|
+
id: fieldObject.id,
|
|
77
|
+
digest: fieldObject.digest,
|
|
78
|
+
version: fieldObject.version,
|
|
79
|
+
type: fieldObject.type,
|
|
80
|
+
name: {
|
|
81
|
+
type:
|
|
82
|
+
typeof fieldType.typeParams[0] === 'string'
|
|
83
|
+
? fieldType.typeParams[0]
|
|
84
|
+
: normalizeStructTag(fieldType.typeParams[0]),
|
|
85
|
+
bcs: options.name.bcs,
|
|
86
|
+
},
|
|
87
|
+
value: {
|
|
88
|
+
type:
|
|
89
|
+
typeof fieldType.typeParams[1] === 'string'
|
|
90
|
+
? fieldType.typeParams[1]
|
|
91
|
+
: normalizeStructTag(fieldType.typeParams[1]),
|
|
92
|
+
bcs: fieldObject.content.slice(SUI_ADDRESS_LENGTH + options.name.bcs.length),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async waitForTransaction({
|
|
99
|
+
signal,
|
|
100
|
+
timeout = 60 * 1000,
|
|
101
|
+
...input
|
|
102
|
+
}: {
|
|
103
|
+
/** An optional abort signal that can be used to cancel the wait. */
|
|
104
|
+
signal?: AbortSignal;
|
|
105
|
+
/** The amount of time to wait for transaction. Defaults to one minute. */
|
|
106
|
+
timeout?: number;
|
|
107
|
+
} & Experimental_SuiClientTypes.GetTransactionOptions): Promise<Experimental_SuiClientTypes.GetTransactionResponse> {
|
|
108
|
+
const abortSignal = signal
|
|
109
|
+
? AbortSignal.any([AbortSignal.timeout(timeout), signal])
|
|
110
|
+
: AbortSignal.timeout(timeout);
|
|
111
|
+
|
|
112
|
+
const abortPromise = new Promise((_, reject) => {
|
|
113
|
+
abortSignal.addEventListener('abort', () => reject(abortSignal.reason));
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
abortPromise.catch(() => {
|
|
117
|
+
// Swallow unhandled rejections that might be thrown after early return
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// eslint-disable-next-line no-constant-condition
|
|
121
|
+
while (true) {
|
|
122
|
+
abortSignal.throwIfAborted();
|
|
123
|
+
try {
|
|
124
|
+
return await this.getTransaction({
|
|
125
|
+
...input,
|
|
126
|
+
signal: abortSignal,
|
|
127
|
+
});
|
|
128
|
+
} catch (e) {
|
|
129
|
+
await Promise.race([new Promise((resolve) => setTimeout(resolve, 2_000)), abortPromise]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
46
133
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { Experimental_BaseClient } from './client.js';
|
|
5
|
+
import { Experimental_CoreClient } from './core.js';
|
|
6
|
+
import type {
|
|
7
|
+
ClientWithExtensions,
|
|
8
|
+
Experimental_SuiClientTypes,
|
|
9
|
+
SuiClientRegistration,
|
|
10
|
+
} from './types.js';
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
Experimental_BaseClient,
|
|
14
|
+
Experimental_CoreClient,
|
|
15
|
+
type ClientWithExtensions,
|
|
16
|
+
type Experimental_SuiClientTypes,
|
|
17
|
+
type SuiClientRegistration,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { ClientCache, type ClientCacheOptions } from './cache.js';
|