@mysten/sui 1.26.0 → 1.27.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.
Files changed (129) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/bcs/bcs.d.ts +28 -0
  3. package/dist/cjs/bcs/bcs.js +15 -0
  4. package/dist/cjs/bcs/bcs.js.map +2 -2
  5. package/dist/cjs/bcs/effects.d.ts +84 -6
  6. package/dist/cjs/bcs/effects.js +6 -14
  7. package/dist/cjs/bcs/effects.js.map +2 -2
  8. package/dist/cjs/bcs/index.d.ts +551 -445
  9. package/dist/cjs/bcs/index.js +5 -4
  10. package/dist/cjs/bcs/index.js.map +2 -2
  11. package/dist/cjs/client/client.d.ts +40 -17
  12. package/dist/cjs/client/client.js +142 -62
  13. package/dist/cjs/client/client.js.map +2 -2
  14. package/dist/cjs/client/http-transport.d.ts +2 -0
  15. package/dist/cjs/client/http-transport.js +7 -0
  16. package/dist/cjs/client/http-transport.js.map +2 -2
  17. package/dist/cjs/client/rpc-websocket-client.d.ts +2 -1
  18. package/dist/cjs/client/rpc-websocket-client.js +7 -2
  19. package/dist/cjs/client/rpc-websocket-client.js.map +2 -2
  20. package/dist/cjs/client/types/generated.d.ts +1 -0
  21. package/dist/cjs/client/types/generated.js.map +1 -1
  22. package/dist/cjs/client/types/params.d.ts +56 -0
  23. package/dist/cjs/client/types/params.js.map +1 -1
  24. package/dist/cjs/experimental/cache.d.ts +11 -0
  25. package/dist/cjs/experimental/cache.js +79 -0
  26. package/dist/cjs/experimental/cache.js.map +7 -0
  27. package/dist/cjs/experimental/client.d.ts +4 -2
  28. package/dist/cjs/experimental/client.js +4 -2
  29. package/dist/cjs/experimental/client.js.map +2 -2
  30. package/dist/cjs/experimental/core.d.ts +10 -2
  31. package/dist/cjs/experimental/core.js +59 -1
  32. package/dist/cjs/experimental/core.js.map +2 -2
  33. package/dist/cjs/experimental/index.d.ts +5 -0
  34. package/dist/cjs/experimental/index.js +29 -0
  35. package/dist/cjs/experimental/index.js.map +7 -0
  36. package/dist/cjs/experimental/transports/jsonRPC.d.ts +19 -5
  37. package/dist/cjs/experimental/transports/jsonRPC.js +270 -12
  38. package/dist/cjs/experimental/transports/jsonRPC.js.map +2 -2
  39. package/dist/cjs/experimental/types.d.ts +84 -41
  40. package/dist/cjs/experimental/types.js.map +1 -1
  41. package/dist/cjs/keypairs/secp256k1/keypair.js +1 -1
  42. package/dist/cjs/keypairs/secp256k1/keypair.js.map +2 -2
  43. package/dist/cjs/keypairs/secp256r1/keypair.js +1 -1
  44. package/dist/cjs/keypairs/secp256r1/keypair.js.map +2 -2
  45. package/dist/cjs/multisig/publickey.js +5 -5
  46. package/dist/cjs/multisig/publickey.js.map +2 -2
  47. package/dist/cjs/multisig/signer.js +2 -2
  48. package/dist/cjs/multisig/signer.js.map +2 -2
  49. package/dist/cjs/transactions/Transaction.d.ts +3 -2
  50. package/dist/cjs/transactions/plugins/utils.js +2 -2
  51. package/dist/cjs/transactions/plugins/utils.js.map +2 -2
  52. package/dist/cjs/version.d.ts +1 -1
  53. package/dist/cjs/version.js +1 -1
  54. package/dist/cjs/version.js.map +1 -1
  55. package/dist/esm/bcs/bcs.d.ts +28 -0
  56. package/dist/esm/bcs/bcs.js +15 -0
  57. package/dist/esm/bcs/bcs.js.map +2 -2
  58. package/dist/esm/bcs/effects.d.ts +84 -6
  59. package/dist/esm/bcs/effects.js +1 -9
  60. package/dist/esm/bcs/effects.js.map +2 -2
  61. package/dist/esm/bcs/index.d.ts +551 -445
  62. package/dist/esm/bcs/index.js +6 -4
  63. package/dist/esm/bcs/index.js.map +2 -2
  64. package/dist/esm/client/client.d.ts +40 -17
  65. package/dist/esm/client/client.js +143 -63
  66. package/dist/esm/client/client.js.map +2 -2
  67. package/dist/esm/client/http-transport.d.ts +2 -0
  68. package/dist/esm/client/http-transport.js +7 -0
  69. package/dist/esm/client/http-transport.js.map +2 -2
  70. package/dist/esm/client/rpc-websocket-client.d.ts +2 -1
  71. package/dist/esm/client/rpc-websocket-client.js +7 -2
  72. package/dist/esm/client/rpc-websocket-client.js.map +2 -2
  73. package/dist/esm/client/types/generated.d.ts +1 -0
  74. package/dist/esm/client/types/params.d.ts +56 -0
  75. package/dist/esm/experimental/cache.d.ts +11 -0
  76. package/dist/esm/experimental/cache.js +59 -0
  77. package/dist/esm/experimental/cache.js.map +7 -0
  78. package/dist/esm/experimental/client.d.ts +4 -2
  79. package/dist/esm/experimental/client.js +4 -2
  80. package/dist/esm/experimental/client.js.map +2 -2
  81. package/dist/esm/experimental/core.d.ts +10 -2
  82. package/dist/esm/experimental/core.js +60 -2
  83. package/dist/esm/experimental/core.js.map +2 -2
  84. package/dist/esm/experimental/index.d.ts +5 -0
  85. package/dist/esm/experimental/index.js +9 -0
  86. package/dist/esm/experimental/index.js.map +7 -0
  87. package/dist/esm/experimental/transports/jsonRPC.d.ts +19 -5
  88. package/dist/esm/experimental/transports/jsonRPC.js +270 -12
  89. package/dist/esm/experimental/transports/jsonRPC.js.map +2 -2
  90. package/dist/esm/experimental/types.d.ts +84 -41
  91. package/dist/esm/keypairs/secp256k1/keypair.js +1 -1
  92. package/dist/esm/keypairs/secp256k1/keypair.js.map +2 -2
  93. package/dist/esm/keypairs/secp256r1/keypair.js +1 -1
  94. package/dist/esm/keypairs/secp256r1/keypair.js.map +2 -2
  95. package/dist/esm/multisig/publickey.js +5 -5
  96. package/dist/esm/multisig/publickey.js.map +2 -2
  97. package/dist/esm/multisig/signer.js +2 -2
  98. package/dist/esm/multisig/signer.js.map +2 -2
  99. package/dist/esm/transactions/Transaction.d.ts +3 -2
  100. package/dist/esm/transactions/plugins/utils.js +2 -2
  101. package/dist/esm/transactions/plugins/utils.js.map +2 -2
  102. package/dist/esm/version.d.ts +1 -1
  103. package/dist/esm/version.js +1 -1
  104. package/dist/esm/version.js.map +1 -1
  105. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  106. package/dist/tsconfig.tsbuildinfo +1 -1
  107. package/experimental/package.json +6 -0
  108. package/package.json +23 -18
  109. package/src/bcs/bcs.ts +15 -0
  110. package/src/bcs/effects.ts +1 -10
  111. package/src/bcs/index.ts +5 -3
  112. package/src/client/client.ts +119 -26
  113. package/src/client/http-transport.ts +10 -0
  114. package/src/client/rpc-websocket-client.ts +8 -1
  115. package/src/client/types/generated.ts +1 -0
  116. package/src/client/types/params.ts +68 -6
  117. package/src/experimental/cache.ts +64 -0
  118. package/src/experimental/client.ts +4 -2
  119. package/src/experimental/core.ts +89 -2
  120. package/src/experimental/index.ts +20 -0
  121. package/src/experimental/transports/jsonRPC.ts +319 -9
  122. package/src/experimental/types.ts +92 -48
  123. package/src/keypairs/secp256k1/keypair.ts +1 -1
  124. package/src/keypairs/secp256r1/keypair.ts +1 -1
  125. package/src/multisig/publickey.ts +5 -5
  126. package/src/multisig/signer.ts +2 -2
  127. package/src/transactions/__tests__/bcs.test.ts +2 -2
  128. package/src/transactions/plugins/utils.ts +2 -2
  129. package/src/version.ts +1 -1
@@ -23,6 +23,7 @@ export interface DevInspectTransactionBlockParams {
23
23
  epoch?: string | null | undefined;
24
24
  /** Additional arguments including gas_budget, gas_objects, gas_sponsor and skip_checks. */
25
25
  additionalArgs?: RpcTypes.DevInspectArgs | null | undefined;
26
+ signal?: AbortSignal;
26
27
  }
27
28
  /**
28
29
  * Return transaction execution effects including the gas cost summary, while the effects are not
@@ -30,6 +31,7 @@ export interface DevInspectTransactionBlockParams {
30
31
  */
31
32
  export interface DryRunTransactionBlockParams {
32
33
  transactionBlock: Uint8Array | string;
34
+ signal?: AbortSignal;
33
35
  }
34
36
  /**
35
37
  * Execute the transaction and wait for results if desired. Request types: 1. WaitForEffectsCert: waits
@@ -53,14 +55,17 @@ export interface ExecuteTransactionBlockParams {
53
55
  options?: RpcTypes.SuiTransactionBlockResponseOptions | null | undefined;
54
56
  /** @deprecated requestType will be ignored by JSON RPC in the future */
55
57
  requestType?: RpcTypes.ExecuteTransactionRequestType | null | undefined;
58
+ signal?: AbortSignal;
56
59
  }
57
60
  /** Return the first four bytes of the chain's genesis checkpoint digest. */
58
61
  export interface GetChainIdentifierParams {
62
+ signal?: AbortSignal;
59
63
  }
60
64
  /** Return a checkpoint */
61
65
  export interface GetCheckpointParams {
62
66
  /** Checkpoint identifier, can use either checkpoint digest, or checkpoint sequence number as input. */
63
67
  id: RpcTypes.CheckpointId;
68
+ signal?: AbortSignal;
64
69
  }
65
70
  /** Return paginated list of checkpoints */
66
71
  export interface GetCheckpointsParams {
@@ -73,41 +78,49 @@ export interface GetCheckpointsParams {
73
78
  limit?: number | null | undefined;
74
79
  /** query result ordering, default to false (ascending order), oldest record first. */
75
80
  descendingOrder: boolean;
81
+ signal?: AbortSignal;
76
82
  }
77
83
  /** Return transaction events. */
78
84
  export interface GetEventsParams {
79
85
  /** the event query criteria. */
80
86
  transactionDigest: string;
87
+ signal?: AbortSignal;
81
88
  }
82
89
  /** Return the sequence number of the latest checkpoint that has been executed */
83
90
  export interface GetLatestCheckpointSequenceNumberParams {
91
+ signal?: AbortSignal;
84
92
  }
85
93
  /** Return the argument types of a Move function, based on normalized Type. */
86
94
  export interface GetMoveFunctionArgTypesParams {
87
95
  package: string;
88
96
  module: string;
89
97
  function: string;
98
+ signal?: AbortSignal;
90
99
  }
91
100
  /** Return a structured representation of Move function */
92
101
  export interface GetNormalizedMoveFunctionParams {
93
102
  package: string;
94
103
  module: string;
95
104
  function: string;
105
+ signal?: AbortSignal;
96
106
  }
97
107
  /** Return a structured representation of Move module */
98
108
  export interface GetNormalizedMoveModuleParams {
99
109
  package: string;
100
110
  module: string;
111
+ signal?: AbortSignal;
101
112
  }
102
113
  /** Return structured representations of all modules in the given package */
103
114
  export interface GetNormalizedMoveModulesByPackageParams {
104
115
  package: string;
116
+ signal?: AbortSignal;
105
117
  }
106
118
  /** Return a structured representation of Move struct */
107
119
  export interface GetNormalizedMoveStructParams {
108
120
  package: string;
109
121
  module: string;
110
122
  struct: string;
123
+ signal?: AbortSignal;
111
124
  }
112
125
  /** Return the object information for a specified object */
113
126
  export interface GetObjectParams {
@@ -115,6 +128,7 @@ export interface GetObjectParams {
115
128
  id: string;
116
129
  /** options for specifying the content to be returned */
117
130
  options?: RpcTypes.SuiObjectDataOptions | null | undefined;
131
+ signal?: AbortSignal;
118
132
  }
119
133
  /**
120
134
  * Return the protocol config table for the given version number. If the version number is not
@@ -126,9 +140,11 @@ export interface GetProtocolConfigParams {
126
140
  * will be returned.
127
141
  */
128
142
  version?: string | null | undefined;
143
+ signal?: AbortSignal;
129
144
  }
130
145
  /** Return the total number of transaction blocks known to the server. */
131
146
  export interface GetTotalTransactionBlocksParams {
147
+ signal?: AbortSignal;
132
148
  }
133
149
  /** Return the transaction response object. */
134
150
  export interface GetTransactionBlockParams {
@@ -136,6 +152,7 @@ export interface GetTransactionBlockParams {
136
152
  digest: string;
137
153
  /** options for specifying the content to be returned */
138
154
  options?: RpcTypes.SuiTransactionBlockResponseOptions | null | undefined;
155
+ signal?: AbortSignal;
139
156
  }
140
157
  /** Return the object data for a list of objects */
141
158
  export interface MultiGetObjectsParams {
@@ -143,6 +160,7 @@ export interface MultiGetObjectsParams {
143
160
  ids: string[];
144
161
  /** options for specifying the content to be returned */
145
162
  options?: RpcTypes.SuiObjectDataOptions | null | undefined;
163
+ signal?: AbortSignal;
146
164
  }
147
165
  /**
148
166
  * Returns an ordered list of transaction responses The method will throw an error if the input
@@ -153,6 +171,7 @@ export interface MultiGetTransactionBlocksParams {
153
171
  digests: string[];
154
172
  /** config options to control which fields to fetch */
155
173
  options?: RpcTypes.SuiTransactionBlockResponseOptions | null | undefined;
174
+ signal?: AbortSignal;
156
175
  }
157
176
  /**
158
177
  * Note there is no software-level guarantee/SLA that objects with past versions can be retrieved by
@@ -166,6 +185,7 @@ export interface TryGetPastObjectParams {
166
185
  version: number;
167
186
  /** options for specifying the content to be returned */
168
187
  options?: RpcTypes.SuiObjectDataOptions | null | undefined;
188
+ signal?: AbortSignal;
169
189
  }
170
190
  /**
171
191
  * Note there is no software-level guarantee/SLA that objects with past versions can be retrieved by
@@ -177,6 +197,7 @@ export interface TryMultiGetPastObjectsParams {
177
197
  pastObjects: RpcTypes.GetPastObjectRequest[];
178
198
  /** options for specifying the content to be returned */
179
199
  options?: RpcTypes.SuiObjectDataOptions | null | undefined;
200
+ signal?: AbortSignal;
180
201
  }
181
202
  /** Verify a zklogin signature for the given bytes, intent scope and author. */
182
203
  export interface VerifyZkLoginSignatureParams {
@@ -191,11 +212,13 @@ export interface VerifyZkLoginSignatureParams {
191
212
  intentScope: RpcTypes.ZkLoginIntentScope;
192
213
  /** The author of the signature. */
193
214
  author: string;
215
+ signal?: AbortSignal;
194
216
  }
195
217
  /** Return the total coin balance for all coin type, owned by the address owner. */
196
218
  export interface GetAllBalancesParams {
197
219
  /** the owner's Sui address */
198
220
  owner: string;
221
+ signal?: AbortSignal;
199
222
  }
200
223
  /** Return all Coin objects owned by an address. */
201
224
  export interface GetAllCoinsParams {
@@ -205,6 +228,7 @@ export interface GetAllCoinsParams {
205
228
  cursor?: string | null | undefined;
206
229
  /** maximum number of items per page */
207
230
  limit?: number | null | undefined;
231
+ signal?: AbortSignal;
208
232
  }
209
233
  /** Return the total coin balance for one coin type, owned by the address owner. */
210
234
  export interface GetBalanceParams {
@@ -215,6 +239,7 @@ export interface GetBalanceParams {
215
239
  * default to 0x2::sui::SUI if not specified.
216
240
  */
217
241
  coinType?: string | null | undefined;
242
+ signal?: AbortSignal;
218
243
  }
219
244
  /**
220
245
  * Return metadata (e.g., symbol, decimals) for a coin. Note that if the coin's metadata was wrapped in
@@ -224,6 +249,7 @@ export interface GetBalanceParams {
224
249
  export interface GetCoinMetadataParams {
225
250
  /** type name for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC) */
226
251
  coinType: string;
252
+ signal?: AbortSignal;
227
253
  }
228
254
  /** Return all Coin<`coin_type`> objects owned by an address. */
229
255
  export interface GetCoinsParams {
@@ -238,11 +264,13 @@ export interface GetCoinsParams {
238
264
  cursor?: string | null | undefined;
239
265
  /** maximum number of items per page */
240
266
  limit?: number | null | undefined;
267
+ signal?: AbortSignal;
241
268
  }
242
269
  /** Return the committee information for the asked `epoch`. */
243
270
  export interface GetCommitteeInfoParams {
244
271
  /** The epoch of interest. If None, default to the latest epoch */
245
272
  epoch?: string | null | undefined;
273
+ signal?: AbortSignal;
246
274
  }
247
275
  /** Return the dynamic field object information for a specified object */
248
276
  export interface GetDynamicFieldObjectParams {
@@ -250,6 +278,7 @@ export interface GetDynamicFieldObjectParams {
250
278
  parentId: string;
251
279
  /** The Name of the dynamic field */
252
280
  name: RpcTypes.DynamicFieldName;
281
+ signal?: AbortSignal;
253
282
  }
254
283
  /** Return the list of dynamic field objects owned by an object. */
255
284
  export interface GetDynamicFieldsParams {
@@ -262,9 +291,11 @@ export interface GetDynamicFieldsParams {
262
291
  cursor?: string | null | undefined;
263
292
  /** Maximum item returned per page, default to [QUERY_MAX_RESULT_LIMIT] if not specified. */
264
293
  limit?: number | null | undefined;
294
+ signal?: AbortSignal;
265
295
  }
266
296
  /** Return the latest SUI system state object on-chain. */
267
297
  export interface GetLatestSuiSystemStateParams {
298
+ signal?: AbortSignal;
268
299
  }
269
300
  /**
270
301
  * Return the list of objects owned by an address. Note that if the address owns more than
@@ -281,25 +312,31 @@ export type GetOwnedObjectsParams = {
281
312
  cursor?: string | null | undefined;
282
313
  /** Max number of items returned per page, default to [QUERY_MAX_RESULT_LIMIT] if not specified. */
283
314
  limit?: number | null | undefined;
315
+ signal?: AbortSignal;
284
316
  } & RpcTypes.SuiObjectResponseQuery;
285
317
  /** Return the reference gas price for the network */
286
318
  export interface GetReferenceGasPriceParams {
319
+ signal?: AbortSignal;
287
320
  }
288
321
  /** Return all [DelegatedStake]. */
289
322
  export interface GetStakesParams {
290
323
  owner: string;
324
+ signal?: AbortSignal;
291
325
  }
292
326
  /** Return one or more [DelegatedStake]. If a Stake was withdrawn its status will be Unstaked. */
293
327
  export interface GetStakesByIdsParams {
294
328
  stakedSuiIds: string[];
329
+ signal?: AbortSignal;
295
330
  }
296
331
  /** Return total supply for a coin */
297
332
  export interface GetTotalSupplyParams {
298
333
  /** type name for the coin (e.g., 0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC) */
299
334
  coinType: string;
335
+ signal?: AbortSignal;
300
336
  }
301
337
  /** Return the validator APY */
302
338
  export interface GetValidatorsApyParams {
339
+ signal?: AbortSignal;
303
340
  }
304
341
  /** Return list of events for a specified query criteria. */
305
342
  export interface QueryEventsParams {
@@ -314,6 +351,7 @@ export interface QueryEventsParams {
314
351
  limit?: number | null | undefined;
315
352
  /** query result ordering, default to false (ascending order), oldest record first. */
316
353
  order?: 'ascending' | 'descending' | null | undefined;
354
+ signal?: AbortSignal;
317
355
  }
318
356
  /** Return list of transactions for a specified query criteria. */
319
357
  export type QueryTransactionBlocksParams = {
@@ -326,11 +364,13 @@ export type QueryTransactionBlocksParams = {
326
364
  limit?: number | null | undefined;
327
365
  /** query result ordering, default to false (ascending order), oldest record first. */
328
366
  order?: 'ascending' | 'descending' | null | undefined;
367
+ signal?: AbortSignal;
329
368
  } & RpcTypes.SuiTransactionBlockResponseQuery;
330
369
  /** Return the resolved address given resolver and name */
331
370
  export interface ResolveNameServiceAddressParams {
332
371
  /** The name to resolve */
333
372
  name: string;
373
+ signal?: AbortSignal;
334
374
  }
335
375
  /**
336
376
  * Return the resolved names given address, if multiple names are resolved, the first one is the
@@ -341,6 +381,7 @@ export interface ResolveNameServiceNamesParams {
341
381
  address: string;
342
382
  cursor?: string | null | undefined;
343
383
  limit?: number | null | undefined;
384
+ signal?: AbortSignal;
344
385
  }
345
386
  /** Subscribe to a stream of Sui event */
346
387
  export interface SubscribeEventParams {
@@ -349,10 +390,12 @@ export interface SubscribeEventParams {
349
390
  * [Event filter](https://docs.sui.io/build/event_api#event-filters) documentation for examples.
350
391
  */
351
392
  filter: RpcTypes.SuiEventFilter;
393
+ signal?: AbortSignal;
352
394
  }
353
395
  /** Subscribe to a stream of Sui transaction effects */
354
396
  export interface SubscribeTransactionParams {
355
397
  filter: RpcTypes.TransactionFilter;
398
+ signal?: AbortSignal;
356
399
  }
357
400
  /** Create an unsigned batched transaction. */
358
401
  export interface UnsafeBatchTransactionParams {
@@ -369,6 +412,7 @@ export interface UnsafeBatchTransactionParams {
369
412
  gasBudget: string;
370
413
  /** Whether this is a regular transaction or a Dev Inspect Transaction */
371
414
  txnBuilderMode?: RpcTypes.SuiTransactionBlockBuilderMode | null | undefined;
415
+ signal?: AbortSignal;
372
416
  }
373
417
  /** Create an unsigned transaction to merge multiple coins into one coin. */
374
418
  export interface UnsafeMergeCoinsParams {
@@ -388,6 +432,7 @@ export interface UnsafeMergeCoinsParams {
388
432
  gas?: string | null | undefined;
389
433
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
390
434
  gasBudget: string;
435
+ signal?: AbortSignal;
391
436
  }
392
437
  /**
393
438
  * Create an unsigned transaction to execute a Move call on the network, by calling the specified
@@ -421,6 +466,7 @@ export interface UnsafeMoveCallParams {
421
466
  * `SuiTransactionBlockBuilderMode::Commit` when it's None.
422
467
  */
423
468
  executionMode?: RpcTypes.SuiTransactionBlockBuilderMode | null | undefined;
469
+ signal?: AbortSignal;
424
470
  }
425
471
  /**
426
472
  * Send `Coin<T>` to a list of addresses, where `T` can be any coin type, following a list of amounts,
@@ -444,6 +490,7 @@ export interface UnsafePayParams {
444
490
  gas?: string | null | undefined;
445
491
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
446
492
  gasBudget: string;
493
+ signal?: AbortSignal;
447
494
  }
448
495
  /**
449
496
  * Send all SUI coins to one recipient. This is for SUI coin only and does not require a separate gas
@@ -461,6 +508,7 @@ export interface UnsafePayAllSuiParams {
461
508
  recipient: string;
462
509
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
463
510
  gasBudget: string;
511
+ signal?: AbortSignal;
464
512
  }
465
513
  /**
466
514
  * Send SUI coins to a list of addresses, following a list of amounts. This is for SUI coin only and
@@ -482,6 +530,7 @@ export interface UnsafePaySuiParams {
482
530
  amounts: string[];
483
531
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
484
532
  gasBudget: string;
533
+ signal?: AbortSignal;
485
534
  }
486
535
  /** Create an unsigned transaction to publish a Move package. */
487
536
  export interface UnsafePublishParams {
@@ -498,6 +547,7 @@ export interface UnsafePublishParams {
498
547
  gas?: string | null | undefined;
499
548
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
500
549
  gasBudget: string;
550
+ signal?: AbortSignal;
501
551
  }
502
552
  /** Add stake to a validator's staking pool using multiple coins and amount. */
503
553
  export interface UnsafeRequestAddStakeParams {
@@ -516,6 +566,7 @@ export interface UnsafeRequestAddStakeParams {
516
566
  gas?: string | null | undefined;
517
567
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
518
568
  gasBudget: string;
569
+ signal?: AbortSignal;
519
570
  }
520
571
  /** Withdraw stake from a validator's staking pool. */
521
572
  export interface UnsafeRequestWithdrawStakeParams {
@@ -530,6 +581,7 @@ export interface UnsafeRequestWithdrawStakeParams {
530
581
  gas?: string | null | undefined;
531
582
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
532
583
  gasBudget: string;
584
+ signal?: AbortSignal;
533
585
  }
534
586
  /** Create an unsigned transaction to split a coin object into multiple coins. */
535
587
  export interface UnsafeSplitCoinParams {
@@ -546,6 +598,7 @@ export interface UnsafeSplitCoinParams {
546
598
  gas?: string | null | undefined;
547
599
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
548
600
  gasBudget: string;
601
+ signal?: AbortSignal;
549
602
  }
550
603
  /** Create an unsigned transaction to split a coin object into multiple equal-size coins. */
551
604
  export interface UnsafeSplitCoinEqualParams {
@@ -562,6 +615,7 @@ export interface UnsafeSplitCoinEqualParams {
562
615
  gas?: string | null | undefined;
563
616
  /** the gas budget, the transaction will fail if the gas cost exceed the budget */
564
617
  gasBudget: string;
618
+ signal?: AbortSignal;
565
619
  }
566
620
  /**
567
621
  * Create an unsigned transaction to transfer an object from one address to another. The object's type
@@ -581,6 +635,7 @@ export interface UnsafeTransferObjectParams {
581
635
  gasBudget: string;
582
636
  /** the recipient's Sui address */
583
637
  recipient: string;
638
+ signal?: AbortSignal;
584
639
  }
585
640
  /**
586
641
  * Create an unsigned transaction to send SUI coin object to a Sui address. The SUI object is also used
@@ -597,4 +652,5 @@ export interface UnsafeTransferSuiParams {
597
652
  recipient: string;
598
653
  /** the amount to be split out and transferred */
599
654
  amount?: string | null | undefined;
655
+ signal?: AbortSignal;
600
656
  }
@@ -0,0 +1,11 @@
1
+ export interface ClientCacheOptions {
2
+ prefix?: string[];
3
+ cache?: Map<string, unknown>;
4
+ }
5
+ export declare class ClientCache {
6
+ #private;
7
+ constructor({ prefix, cache }?: ClientCacheOptions);
8
+ read<T>(key: [string, ...string[]], load: () => T | Promise<T>): T | Promise<T>;
9
+ clear(prefix?: string[]): void;
10
+ scope(prefix: string | string[]): ClientCache;
11
+ }
@@ -0,0 +1,59 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var _prefix, _cache;
9
+ const _ClientCache = class _ClientCache {
10
+ constructor({ prefix, cache } = {}) {
11
+ __privateAdd(this, _prefix);
12
+ __privateAdd(this, _cache);
13
+ __privateSet(this, _prefix, prefix ?? []);
14
+ __privateSet(this, _cache, cache ?? /* @__PURE__ */ new Map());
15
+ }
16
+ read(key, load) {
17
+ const cacheKey = [__privateGet(this, _prefix), ...key].join(":");
18
+ if (__privateGet(this, _cache).has(cacheKey)) {
19
+ return __privateGet(this, _cache).get(cacheKey);
20
+ }
21
+ const result = load();
22
+ __privateGet(this, _cache).set(cacheKey, result);
23
+ if (typeof result === "object" && result !== null && "then" in result) {
24
+ return Promise.resolve(result).then((v) => {
25
+ __privateGet(this, _cache).set(cacheKey, v);
26
+ return v;
27
+ }).catch((err) => {
28
+ __privateGet(this, _cache).delete(cacheKey);
29
+ throw err;
30
+ });
31
+ }
32
+ return result;
33
+ }
34
+ clear(prefix) {
35
+ const prefixKey = [...__privateGet(this, _prefix), ...prefix ?? []].join(":");
36
+ if (!prefixKey) {
37
+ __privateGet(this, _cache).clear();
38
+ return;
39
+ }
40
+ for (const key of __privateGet(this, _cache).keys()) {
41
+ if (key.startsWith(prefixKey)) {
42
+ __privateGet(this, _cache).delete(key);
43
+ }
44
+ }
45
+ }
46
+ scope(prefix) {
47
+ return new _ClientCache({
48
+ prefix: [...__privateGet(this, _prefix), ...Array.isArray(prefix) ? prefix : [prefix]],
49
+ cache: __privateGet(this, _cache)
50
+ });
51
+ }
52
+ };
53
+ _prefix = new WeakMap();
54
+ _cache = new WeakMap();
55
+ let ClientCache = _ClientCache;
56
+ export {
57
+ ClientCache
58
+ };
59
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/experimental/cache.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface ClientCacheOptions {\n\tprefix?: string[];\n\tcache?: Map<string, unknown>;\n}\n\nexport class ClientCache {\n\t#prefix: string[];\n\t#cache: Map<string, unknown>;\n\n\tconstructor({ prefix, cache }: ClientCacheOptions = {}) {\n\t\tthis.#prefix = prefix ?? [];\n\t\tthis.#cache = cache ?? new Map();\n\t}\n\n\tread<T>(key: [string, ...string[]], load: () => T | Promise<T>): T | Promise<T> {\n\t\tconst cacheKey = [this.#prefix, ...key].join(':');\n\n\t\tif (this.#cache.has(cacheKey)) {\n\t\t\treturn this.#cache.get(cacheKey) as T;\n\t\t}\n\n\t\tconst result = load();\n\n\t\tthis.#cache.set(cacheKey, result);\n\n\t\tif (typeof result === 'object' && result !== null && 'then' in result) {\n\t\t\treturn Promise.resolve(result)\n\t\t\t\t.then((v) => {\n\t\t\t\t\tthis.#cache.set(cacheKey, v);\n\t\t\t\t\treturn v as T;\n\t\t\t\t})\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tthis.#cache.delete(cacheKey);\n\t\t\t\t\tthrow err;\n\t\t\t\t});\n\t\t}\n\n\t\treturn result as T;\n\t}\n\n\tclear(prefix?: string[]) {\n\t\tconst prefixKey = [...this.#prefix, ...(prefix ?? [])].join(':');\n\t\tif (!prefixKey) {\n\t\t\tthis.#cache.clear();\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const key of this.#cache.keys()) {\n\t\t\tif (key.startsWith(prefixKey)) {\n\t\t\t\tthis.#cache.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tscope(prefix: string | string[]) {\n\t\treturn new ClientCache({\n\t\t\tprefix: [...this.#prefix, ...(Array.isArray(prefix) ? prefix : [prefix])],\n\t\t\tcache: this.#cache,\n\t\t});\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;AAAA;AAQO,MAAM,eAAN,MAAM,aAAY;AAAA,EAIxB,YAAY,EAAE,QAAQ,MAAM,IAAwB,CAAC,GAAG;AAHxD;AACA;AAGC,uBAAK,SAAU,UAAU,CAAC;AAC1B,uBAAK,QAAS,SAAS,oBAAI,IAAI;AAAA,EAChC;AAAA,EAEA,KAAQ,KAA4B,MAA4C;AAC/E,UAAM,WAAW,CAAC,mBAAK,UAAS,GAAG,GAAG,EAAE,KAAK,GAAG;AAEhD,QAAI,mBAAK,QAAO,IAAI,QAAQ,GAAG;AAC9B,aAAO,mBAAK,QAAO,IAAI,QAAQ;AAAA,IAChC;AAEA,UAAM,SAAS,KAAK;AAEpB,uBAAK,QAAO,IAAI,UAAU,MAAM;AAEhC,QAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,UAAU,QAAQ;AACtE,aAAO,QAAQ,QAAQ,MAAM,EAC3B,KAAK,CAAC,MAAM;AACZ,2BAAK,QAAO,IAAI,UAAU,CAAC;AAC3B,eAAO;AAAA,MACR,CAAC,EACA,MAAM,CAAC,QAAQ;AACf,2BAAK,QAAO,OAAO,QAAQ;AAC3B,cAAM;AAAA,MACP,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,QAAmB;AACxB,UAAM,YAAY,CAAC,GAAG,mBAAK,UAAS,GAAI,UAAU,CAAC,CAAE,EAAE,KAAK,GAAG;AAC/D,QAAI,CAAC,WAAW;AACf,yBAAK,QAAO,MAAM;AAClB;AAAA,IACD;AAEA,eAAW,OAAO,mBAAK,QAAO,KAAK,GAAG;AACrC,UAAI,IAAI,WAAW,SAAS,GAAG;AAC9B,2BAAK,QAAO,OAAO,GAAG;AAAA,MACvB;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM,QAA2B;AAChC,WAAO,IAAI,aAAY;AAAA,MACtB,QAAQ,CAAC,GAAG,mBAAK,UAAS,GAAI,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM,CAAE;AAAA,MACxE,OAAO,mBAAK;AAAA,IACb,CAAC;AAAA,EACF;AACD;AAtDC;AACA;AAFM,IAAM,cAAN;",
6
+ "names": []
7
+ }
@@ -1,8 +1,10 @@
1
+ import { ClientCache } from './cache.js';
1
2
  import type { Experimental_CoreClient } from './core.js';
2
3
  import type { ClientWithExtensions, Experimental_SuiClientTypes, Simplify, SuiClientRegistration, UnionToIntersection } from './types.js';
3
- export declare abstract class Experimental_SuiClient {
4
+ export declare abstract class Experimental_BaseClient {
4
5
  network: Experimental_SuiClientTypes.Network;
6
+ cache: ClientCache;
5
7
  constructor({ network }: Experimental_SuiClientTypes.SuiClientOptions);
6
8
  abstract core: Experimental_CoreClient;
7
- $extend<const Registrations extends SuiClientRegistration<this>[]>(...registrations: Registrations): ClientWithExtensions<Simplify<Omit<{ [K in keyof this]: this[K]; }, keyof Experimental_SuiClient> & UnionToIntersection<{ [K in keyof Registrations]: Registrations[K] extends SuiClientRegistration<this, infer Name extends string, infer Extension> ? { [K2 in Name]: Extension; } : never; }[number]>>>;
9
+ $extend<const Registrations extends SuiClientRegistration<this>[]>(...registrations: Registrations): ClientWithExtensions<Simplify<Omit<{ [K in keyof this]: this[K]; }, keyof Experimental_BaseClient> & UnionToIntersection<{ [K in keyof Registrations]: Registrations[K] extends SuiClientRegistration<this, infer Name extends string, infer Extension> ? { [K2 in Name]: Extension; } : never; }[number]>>>;
8
10
  }
@@ -1,5 +1,7 @@
1
- class Experimental_SuiClient {
1
+ import { ClientCache } from "./cache.js";
2
+ class Experimental_BaseClient {
2
3
  constructor({ network }) {
4
+ this.cache = new ClientCache();
3
5
  this.network = network;
4
6
  }
5
7
  $extend(...registrations) {
@@ -18,6 +20,6 @@ class Experimental_SuiClient {
18
20
  }
19
21
  }
20
22
  export {
21
- Experimental_SuiClient
23
+ Experimental_BaseClient
22
24
  };
23
25
  //# sourceMappingURL=client.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/experimental/client.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n/* eslint-disable @typescript-eslint/ban-types */\n\nimport type { Experimental_CoreClient } from './core.js';\nimport type {\n\tClientWithExtensions,\n\tExperimental_SuiClientTypes,\n\tSimplify,\n\tSuiClientRegistration,\n\tUnionToIntersection,\n} from './types.js';\n\nexport abstract class Experimental_SuiClient {\n\tnetwork: Experimental_SuiClientTypes.Network;\n\n\tconstructor({ network }: Experimental_SuiClientTypes.SuiClientOptions) {\n\t\tthis.network = network;\n\t}\n\n\tabstract core: Experimental_CoreClient;\n\n\t$extend<const Registrations extends SuiClientRegistration<this>[]>(\n\t\t...registrations: Registrations\n\t) {\n\t\treturn Object.create(\n\t\t\tthis,\n\t\t\tObject.fromEntries(\n\t\t\t\tregistrations.map((registration) => {\n\t\t\t\t\tif ('experimental_asClientExtension' in registration) {\n\t\t\t\t\t\tconst { name, register } = registration.experimental_asClientExtension();\n\t\t\t\t\t\treturn [name, { value: register(this) }];\n\t\t\t\t\t}\n\t\t\t\t\treturn [registration.name, { value: registration.register(this) }];\n\t\t\t\t}),\n\t\t\t),\n\t\t) as ClientWithExtensions<\n\t\t\tSimplify<\n\t\t\t\tOmit<\n\t\t\t\t\t{\n\t\t\t\t\t\t[K in keyof this]: this[K];\n\t\t\t\t\t},\n\t\t\t\t\tkeyof Experimental_SuiClient\n\t\t\t\t> &\n\t\t\t\t\tUnionToIntersection<\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[K in keyof Registrations]: Registrations[K] extends SuiClientRegistration<\n\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\tinfer Name extends string,\n\t\t\t\t\t\t\t\tinfer Extension\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t[K2 in Name]: Extension;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: never;\n\t\t\t\t\t\t}[number]\n\t\t\t\t\t>\n\t\t\t>\n\t\t>;\n\t}\n}\n"],
5
- "mappings": "AAaO,MAAe,uBAAuB;AAAA,EAG5C,YAAY,EAAE,QAAQ,GAAiD;AACtE,SAAK,UAAU;AAAA,EAChB;AAAA,EAIA,WACI,eACF;AACD,WAAO,OAAO;AAAA,MACb;AAAA,MACA,OAAO;AAAA,QACN,cAAc,IAAI,CAAC,iBAAiB;AACnC,cAAI,oCAAoC,cAAc;AACrD,kBAAM,EAAE,MAAM,SAAS,IAAI,aAAa,+BAA+B;AACvE,mBAAO,CAAC,MAAM,EAAE,OAAO,SAAS,IAAI,EAAE,CAAC;AAAA,UACxC;AACA,iBAAO,CAAC,aAAa,MAAM,EAAE,OAAO,aAAa,SAAS,IAAI,EAAE,CAAC;AAAA,QAClE,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EAuBD;AACD;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n/* eslint-disable @typescript-eslint/ban-types */\n\nimport { ClientCache } from './cache.js';\nimport type { Experimental_CoreClient } from './core.js';\nimport type {\n\tClientWithExtensions,\n\tExperimental_SuiClientTypes,\n\tSimplify,\n\tSuiClientRegistration,\n\tUnionToIntersection,\n} from './types.js';\n\nexport abstract class Experimental_BaseClient {\n\tnetwork: Experimental_SuiClientTypes.Network;\n\tcache = new ClientCache();\n\n\tconstructor({ network }: Experimental_SuiClientTypes.SuiClientOptions) {\n\t\tthis.network = network;\n\t}\n\n\tabstract core: Experimental_CoreClient;\n\n\t$extend<const Registrations extends SuiClientRegistration<this>[]>(\n\t\t...registrations: Registrations\n\t) {\n\t\treturn Object.create(\n\t\t\tthis,\n\t\t\tObject.fromEntries(\n\t\t\t\tregistrations.map((registration) => {\n\t\t\t\t\tif ('experimental_asClientExtension' in registration) {\n\t\t\t\t\t\tconst { name, register } = registration.experimental_asClientExtension();\n\t\t\t\t\t\treturn [name, { value: register(this) }];\n\t\t\t\t\t}\n\t\t\t\t\treturn [registration.name, { value: registration.register(this) }];\n\t\t\t\t}),\n\t\t\t),\n\t\t) as ClientWithExtensions<\n\t\t\tSimplify<\n\t\t\t\tOmit<\n\t\t\t\t\t{\n\t\t\t\t\t\t[K in keyof this]: this[K];\n\t\t\t\t\t},\n\t\t\t\t\tkeyof Experimental_BaseClient\n\t\t\t\t> &\n\t\t\t\t\tUnionToIntersection<\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[K in keyof Registrations]: Registrations[K] extends SuiClientRegistration<\n\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\tinfer Name extends string,\n\t\t\t\t\t\t\t\tinfer Extension\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t[K2 in Name]: Extension;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: never;\n\t\t\t\t\t\t}[number]\n\t\t\t\t\t>\n\t\t\t>\n\t\t>;\n\t}\n}\n"],
5
+ "mappings": "AAIA,SAAS,mBAAmB;AAUrB,MAAe,wBAAwB;AAAA,EAI7C,YAAY,EAAE,QAAQ,GAAiD;AAFvE,iBAAQ,IAAI,YAAY;AAGvB,SAAK,UAAU;AAAA,EAChB;AAAA,EAIA,WACI,eACF;AACD,WAAO,OAAO;AAAA,MACb;AAAA,MACA,OAAO;AAAA,QACN,cAAc,IAAI,CAAC,iBAAiB;AACnC,cAAI,oCAAoC,cAAc;AACrD,kBAAM,EAAE,MAAM,SAAS,IAAI,aAAa,+BAA+B;AACvE,mBAAO,CAAC,MAAM,EAAE,OAAO,SAAS,IAAI,EAAE,CAAC;AAAA,UACxC;AACA,iBAAO,CAAC,aAAa,MAAM,EAAE,OAAO,aAAa,SAAS,IAAI,EAAE,CAAC;AAAA,QAClE,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EAuBD;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
- import { Experimental_SuiClient } from './client.js';
1
+ import { Experimental_BaseClient } from './client.js';
2
2
  import type { Experimental_SuiClientTypes } from './types.js';
3
- export declare abstract class Experimental_CoreClient extends Experimental_SuiClient implements Experimental_SuiClientTypes.TransportMethods {
3
+ export declare abstract class Experimental_CoreClient extends Experimental_BaseClient implements Experimental_SuiClientTypes.TransportMethods {
4
4
  core: this;
5
5
  abstract getObjects(options: Experimental_SuiClientTypes.GetObjectsOptions): Promise<Experimental_SuiClientTypes.GetObjectsResponse>;
6
6
  abstract getCoins(options: Experimental_SuiClientTypes.GetCoinsOptions): Promise<Experimental_SuiClientTypes.GetCoinsResponse>;
@@ -11,4 +11,12 @@ export declare abstract class Experimental_CoreClient extends Experimental_SuiCl
11
11
  abstract executeTransaction(options: Experimental_SuiClientTypes.ExecuteTransactionOptions): Promise<Experimental_SuiClientTypes.ExecuteTransactionResponse>;
12
12
  abstract dryRunTransaction(options: Experimental_SuiClientTypes.DryRunTransactionOptions): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse>;
13
13
  abstract getReferenceGasPrice(): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse>;
14
+ abstract getDynamicFields(options: Experimental_SuiClientTypes.GetDynamicFieldsOptions): Promise<Experimental_SuiClientTypes.GetDynamicFieldsResponse>;
15
+ getDynamicField(options: Experimental_SuiClientTypes.GetDynamicFieldOptions): Promise<Experimental_SuiClientTypes.GetDynamicFieldResponse>;
16
+ waitForTransaction({ signal, timeout, ...input }: {
17
+ /** An optional abort signal that can be used to cancel the wait. */
18
+ signal?: AbortSignal;
19
+ /** The amount of time to wait for transaction. Defaults to one minute. */
20
+ timeout?: number;
21
+ } & Experimental_SuiClientTypes.GetTransactionOptions): Promise<Experimental_SuiClientTypes.GetTransactionResponse>;
14
22
  }
@@ -1,9 +1,67 @@
1
- import { Experimental_SuiClient } from "./client.js";
2
- class Experimental_CoreClient extends Experimental_SuiClient {
1
+ import { TypeTagSerializer } from "../bcs/type-tag-serializer.js";
2
+ import { deriveDynamicFieldID } from "../utils/dynamic-fields.js";
3
+ import { normalizeStructTag, parseStructTag, SUI_ADDRESS_LENGTH } from "../utils/sui-types.js";
4
+ import { Experimental_BaseClient } from "./client.js";
5
+ class Experimental_CoreClient extends Experimental_BaseClient {
3
6
  constructor() {
4
7
  super(...arguments);
5
8
  this.core = this;
6
9
  }
10
+ async getDynamicField(options) {
11
+ const fieldId = deriveDynamicFieldID(
12
+ options.parentId,
13
+ TypeTagSerializer.parseFromStr(options.name.type),
14
+ options.name.bcs
15
+ );
16
+ const {
17
+ objects: [fieldObject]
18
+ } = await this.getObjects({
19
+ objectIds: [fieldId]
20
+ });
21
+ if (fieldObject instanceof Error) {
22
+ throw fieldObject;
23
+ }
24
+ const fieldType = parseStructTag(fieldObject.type);
25
+ return {
26
+ dynamicField: {
27
+ id: fieldObject.id,
28
+ digest: fieldObject.digest,
29
+ version: fieldObject.version,
30
+ type: fieldObject.type,
31
+ name: {
32
+ type: typeof fieldType.typeParams[0] === "string" ? fieldType.typeParams[0] : normalizeStructTag(fieldType.typeParams[0]),
33
+ bcs: options.name.bcs
34
+ },
35
+ value: {
36
+ type: typeof fieldType.typeParams[1] === "string" ? fieldType.typeParams[1] : normalizeStructTag(fieldType.typeParams[1]),
37
+ bcs: fieldObject.content.slice(SUI_ADDRESS_LENGTH + options.name.bcs.length)
38
+ }
39
+ }
40
+ };
41
+ }
42
+ async waitForTransaction({
43
+ signal,
44
+ timeout = 60 * 1e3,
45
+ ...input
46
+ }) {
47
+ const abortSignal = signal ? AbortSignal.any([AbortSignal.timeout(timeout), signal]) : AbortSignal.timeout(timeout);
48
+ const abortPromise = new Promise((_, reject) => {
49
+ abortSignal.addEventListener("abort", () => reject(abortSignal.reason));
50
+ });
51
+ abortPromise.catch(() => {
52
+ });
53
+ while (true) {
54
+ abortSignal.throwIfAborted();
55
+ try {
56
+ return await this.getTransaction({
57
+ ...input,
58
+ signal: abortSignal
59
+ });
60
+ } catch (e) {
61
+ await Promise.race([new Promise((resolve) => setTimeout(resolve, 2e3)), abortPromise]);
62
+ }
63
+ }
64
+ }
7
65
  }
8
66
  export {
9
67
  Experimental_CoreClient
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/experimental/core.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Experimental_SuiClient } from './client.js';\nimport type { Experimental_SuiClientTypes } from './types.js';\n\nexport abstract class Experimental_CoreClient\n\textends Experimental_SuiClient\n\timplements Experimental_SuiClientTypes.TransportMethods\n{\n\tcore = this;\n\n\tabstract getObjects(\n\t\toptions: Experimental_SuiClientTypes.GetObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetObjectsResponse>;\n\n\tabstract getCoins(\n\t\toptions: Experimental_SuiClientTypes.GetCoinsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetCoinsResponse>;\n\n\tabstract getOwnedObjects(\n\t\toptions: Experimental_SuiClientTypes.GetOwnedObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetOwnedObjectsResponse>;\n\n\tabstract getBalance(\n\t\toptions: Experimental_SuiClientTypes.GetBalanceOptions,\n\t): Promise<Experimental_SuiClientTypes.GetBalanceResponse>;\n\n\tabstract getAllBalances(\n\t\toptions: Experimental_SuiClientTypes.GetAllBalancesOptions,\n\t): Promise<Experimental_SuiClientTypes.GetAllBalancesResponse>;\n\n\tabstract getTransaction(\n\t\toptions: Experimental_SuiClientTypes.GetTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.GetTransactionResponse>;\n\n\tabstract executeTransaction(\n\t\toptions: Experimental_SuiClientTypes.ExecuteTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.ExecuteTransactionResponse>;\n\n\tabstract dryRunTransaction(\n\t\toptions: Experimental_SuiClientTypes.DryRunTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse>;\n\n\tabstract getReferenceGasPrice(): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse>;\n}\n"],
5
- "mappings": "AAGA,SAAS,8BAA8B;AAGhC,MAAe,gCACb,uBAET;AAAA,EAHO;AAAA;AAIN,gBAAO;AAAA;AAmCR;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TypeTagSerializer } from '../bcs/type-tag-serializer.js';\nimport { deriveDynamicFieldID } from '../utils/dynamic-fields.js';\nimport { normalizeStructTag, parseStructTag, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport { Experimental_BaseClient } from './client.js';\nimport type { Experimental_SuiClientTypes } from './types.js';\n\nexport abstract class Experimental_CoreClient\n\textends Experimental_BaseClient\n\timplements Experimental_SuiClientTypes.TransportMethods\n{\n\tcore = this;\n\n\tabstract getObjects(\n\t\toptions: Experimental_SuiClientTypes.GetObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetObjectsResponse>;\n\n\tabstract getCoins(\n\t\toptions: Experimental_SuiClientTypes.GetCoinsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetCoinsResponse>;\n\n\tabstract getOwnedObjects(\n\t\toptions: Experimental_SuiClientTypes.GetOwnedObjectsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetOwnedObjectsResponse>;\n\n\tabstract getBalance(\n\t\toptions: Experimental_SuiClientTypes.GetBalanceOptions,\n\t): Promise<Experimental_SuiClientTypes.GetBalanceResponse>;\n\n\tabstract getAllBalances(\n\t\toptions: Experimental_SuiClientTypes.GetAllBalancesOptions,\n\t): Promise<Experimental_SuiClientTypes.GetAllBalancesResponse>;\n\n\tabstract getTransaction(\n\t\toptions: Experimental_SuiClientTypes.GetTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.GetTransactionResponse>;\n\n\tabstract executeTransaction(\n\t\toptions: Experimental_SuiClientTypes.ExecuteTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.ExecuteTransactionResponse>;\n\n\tabstract dryRunTransaction(\n\t\toptions: Experimental_SuiClientTypes.DryRunTransactionOptions,\n\t): Promise<Experimental_SuiClientTypes.DryRunTransactionResponse>;\n\n\tabstract getReferenceGasPrice(): Promise<Experimental_SuiClientTypes.GetReferenceGasPriceResponse>;\n\n\tabstract getDynamicFields(\n\t\toptions: Experimental_SuiClientTypes.GetDynamicFieldsOptions,\n\t): Promise<Experimental_SuiClientTypes.GetDynamicFieldsResponse>;\n\n\tasync getDynamicField(\n\t\toptions: Experimental_SuiClientTypes.GetDynamicFieldOptions,\n\t): Promise<Experimental_SuiClientTypes.GetDynamicFieldResponse> {\n\t\tconst fieldId = deriveDynamicFieldID(\n\t\t\toptions.parentId,\n\t\t\tTypeTagSerializer.parseFromStr(options.name.type),\n\t\t\toptions.name.bcs,\n\t\t);\n\t\tconst {\n\t\t\tobjects: [fieldObject],\n\t\t} = await this.getObjects({\n\t\t\tobjectIds: [fieldId],\n\t\t});\n\n\t\tif (fieldObject instanceof Error) {\n\t\t\tthrow fieldObject;\n\t\t}\n\n\t\tconst fieldType = parseStructTag(fieldObject.type);\n\n\t\treturn {\n\t\t\tdynamicField: {\n\t\t\t\tid: fieldObject.id,\n\t\t\t\tdigest: fieldObject.digest,\n\t\t\t\tversion: fieldObject.version,\n\t\t\t\ttype: fieldObject.type,\n\t\t\t\tname: {\n\t\t\t\t\ttype:\n\t\t\t\t\t\ttypeof fieldType.typeParams[0] === 'string'\n\t\t\t\t\t\t\t? fieldType.typeParams[0]\n\t\t\t\t\t\t\t: normalizeStructTag(fieldType.typeParams[0]),\n\t\t\t\t\tbcs: options.name.bcs,\n\t\t\t\t},\n\t\t\t\tvalue: {\n\t\t\t\t\ttype:\n\t\t\t\t\t\ttypeof fieldType.typeParams[1] === 'string'\n\t\t\t\t\t\t\t? fieldType.typeParams[1]\n\t\t\t\t\t\t\t: normalizeStructTag(fieldType.typeParams[1]),\n\t\t\t\t\tbcs: fieldObject.content.slice(SUI_ADDRESS_LENGTH + options.name.bcs.length),\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync waitForTransaction({\n\t\tsignal,\n\t\ttimeout = 60 * 1000,\n\t\t...input\n\t}: {\n\t\t/** An optional abort signal that can be used to cancel the wait. */\n\t\tsignal?: AbortSignal;\n\t\t/** The amount of time to wait for transaction. Defaults to one minute. */\n\t\ttimeout?: number;\n\t} & Experimental_SuiClientTypes.GetTransactionOptions): Promise<Experimental_SuiClientTypes.GetTransactionResponse> {\n\t\tconst abortSignal = signal\n\t\t\t? AbortSignal.any([AbortSignal.timeout(timeout), signal])\n\t\t\t: AbortSignal.timeout(timeout);\n\n\t\tconst abortPromise = new Promise((_, reject) => {\n\t\t\tabortSignal.addEventListener('abort', () => reject(abortSignal.reason));\n\t\t});\n\n\t\tabortPromise.catch(() => {\n\t\t\t// Swallow unhandled rejections that might be thrown after early return\n\t\t});\n\n\t\t// eslint-disable-next-line no-constant-condition\n\t\twhile (true) {\n\t\t\tabortSignal.throwIfAborted();\n\t\t\ttry {\n\t\t\t\treturn await this.getTransaction({\n\t\t\t\t\t...input,\n\t\t\t\t\tsignal: abortSignal,\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tawait Promise.race([new Promise((resolve) => setTimeout(resolve, 2_000)), abortPromise]);\n\t\t\t}\n\t\t}\n\t}\n}\n"],
5
+ "mappings": "AAGA,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB,gBAAgB,0BAA0B;AACvE,SAAS,+BAA+B;AAGjC,MAAe,gCACb,wBAET;AAAA,EAHO;AAAA;AAIN,gBAAO;AAAA;AAAA,EAwCP,MAAM,gBACL,SAC+D;AAC/D,UAAM,UAAU;AAAA,MACf,QAAQ;AAAA,MACR,kBAAkB,aAAa,QAAQ,KAAK,IAAI;AAAA,MAChD,QAAQ,KAAK;AAAA,IACd;AACA,UAAM;AAAA,MACL,SAAS,CAAC,WAAW;AAAA,IACtB,IAAI,MAAM,KAAK,WAAW;AAAA,MACzB,WAAW,CAAC,OAAO;AAAA,IACpB,CAAC;AAED,QAAI,uBAAuB,OAAO;AACjC,YAAM;AAAA,IACP;AAEA,UAAM,YAAY,eAAe,YAAY,IAAI;AAEjD,WAAO;AAAA,MACN,cAAc;AAAA,QACb,IAAI,YAAY;AAAA,QAChB,QAAQ,YAAY;AAAA,QACpB,SAAS,YAAY;AAAA,QACrB,MAAM,YAAY;AAAA,QAClB,MAAM;AAAA,UACL,MACC,OAAO,UAAU,WAAW,CAAC,MAAM,WAChC,UAAU,WAAW,CAAC,IACtB,mBAAmB,UAAU,WAAW,CAAC,CAAC;AAAA,UAC9C,KAAK,QAAQ,KAAK;AAAA,QACnB;AAAA,QACA,OAAO;AAAA,UACN,MACC,OAAO,UAAU,WAAW,CAAC,MAAM,WAChC,UAAU,WAAW,CAAC,IACtB,mBAAmB,UAAU,WAAW,CAAC,CAAC;AAAA,UAC9C,KAAK,YAAY,QAAQ,MAAM,qBAAqB,QAAQ,KAAK,IAAI,MAAM;AAAA,QAC5E;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM,mBAAmB;AAAA,IACxB;AAAA,IACA,UAAU,KAAK;AAAA,IACf,GAAG;AAAA,EACJ,GAKoH;AACnH,UAAM,cAAc,SACjB,YAAY,IAAI,CAAC,YAAY,QAAQ,OAAO,GAAG,MAAM,CAAC,IACtD,YAAY,QAAQ,OAAO;AAE9B,UAAM,eAAe,IAAI,QAAQ,CAAC,GAAG,WAAW;AAC/C,kBAAY,iBAAiB,SAAS,MAAM,OAAO,YAAY,MAAM,CAAC;AAAA,IACvE,CAAC;AAED,iBAAa,MAAM,MAAM;AAAA,IAEzB,CAAC;AAGD,WAAO,MAAM;AACZ,kBAAY,eAAe;AAC3B,UAAI;AACH,eAAO,MAAM,KAAK,eAAe;AAAA,UAChC,GAAG;AAAA,UACH,QAAQ;AAAA,QACT,CAAC;AAAA,MACF,SAAS,GAAG;AACX,cAAM,QAAQ,KAAK,CAAC,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAK,CAAC,GAAG,YAAY,CAAC;AAAA,MACxF;AAAA,IACD;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,5 @@
1
+ import { Experimental_BaseClient } from './client.js';
2
+ import { Experimental_CoreClient } from './core.js';
3
+ import type { ClientWithExtensions, Experimental_SuiClientTypes, SuiClientRegistration } from './types.js';
4
+ export { Experimental_BaseClient, Experimental_CoreClient, type ClientWithExtensions, type Experimental_SuiClientTypes, type SuiClientRegistration, };
5
+ export { ClientCache, type ClientCacheOptions } from './cache.js';
@@ -0,0 +1,9 @@
1
+ import { Experimental_BaseClient } from "./client.js";
2
+ import { Experimental_CoreClient } from "./core.js";
3
+ import { ClientCache } from "./cache.js";
4
+ export {
5
+ ClientCache,
6
+ Experimental_BaseClient,
7
+ Experimental_CoreClient
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/experimental/index.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Experimental_BaseClient } from './client.js';\nimport { Experimental_CoreClient } from './core.js';\nimport type {\n\tClientWithExtensions,\n\tExperimental_SuiClientTypes,\n\tSuiClientRegistration,\n} from './types.js';\n\nexport {\n\tExperimental_BaseClient,\n\tExperimental_CoreClient,\n\ttype ClientWithExtensions,\n\ttype Experimental_SuiClientTypes,\n\ttype SuiClientRegistration,\n};\n\nexport { ClientCache, type ClientCacheOptions } from './cache.js';\n"],
5
+ "mappings": "AAGA,SAAS,+BAA+B;AACxC,SAAS,+BAA+B;AAexC,SAAS,mBAA4C;",
6
+ "names": []
7
+ }