@scallop-io/sui-kit 0.37.1 → 0.38.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.
Files changed (43) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +236 -183
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +246 -193
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/libs/suiAccountManager/index.d.ts +1 -1
  7. package/dist/libs/suiAccountManager/keypair.d.ts +1 -1
  8. package/dist/libs/{suiRpcProvider/defaultChainConfigs.d.ts → suiInteractor/defaultConfig.d.ts} +4 -2
  9. package/dist/libs/suiInteractor/index.d.ts +2 -0
  10. package/dist/libs/suiInteractor/suiInteractor.d.ts +33 -0
  11. package/dist/libs/suiInteractor/util.d.ts +1 -0
  12. package/dist/libs/suiModel/index.d.ts +2 -0
  13. package/dist/libs/suiModel/suiOwnedObject.d.ts +24 -0
  14. package/dist/libs/suiModel/suiSharedObject.d.ts +12 -0
  15. package/dist/libs/suiTxBuilder/index.d.ts +1 -1
  16. package/dist/libs/suiTxBuilder/util.d.ts +1 -1
  17. package/dist/suiKit.d.ts +10 -13
  18. package/dist/types/index.d.ts +33 -5
  19. package/package.json +3 -5
  20. package/src/index.ts +0 -1
  21. package/src/libs/suiAccountManager/index.ts +1 -1
  22. package/src/libs/suiAccountManager/keypair.ts +1 -1
  23. package/src/libs/{suiRpcProvider/defaultChainConfigs.ts → suiInteractor/defaultConfig.ts} +5 -2
  24. package/src/libs/suiInteractor/index.ts +2 -0
  25. package/src/libs/suiInteractor/suiInteractor.ts +168 -0
  26. package/src/libs/suiInteractor/util.ts +1 -0
  27. package/src/libs/suiModel/index.ts +2 -0
  28. package/src/libs/suiModel/suiOwnedObject.ts +63 -0
  29. package/src/libs/suiModel/suiSharedObject.ts +30 -0
  30. package/src/libs/suiTxBuilder/index.ts +1 -1
  31. package/src/libs/suiTxBuilder/util.ts +1 -1
  32. package/src/suiKit.ts +23 -39
  33. package/src/types/index.ts +65 -9
  34. package/dist/libs/suiAccountManager/types.d.ts +0 -9
  35. package/dist/libs/suiRpcProvider/faucet.d.ts +0 -8
  36. package/dist/libs/suiRpcProvider/index.d.ts +0 -40
  37. package/dist/libs/suiRpcProvider/types.d.ts +0 -14
  38. package/dist/libs/suiTxBuilder/types.d.ts +0 -12
  39. package/src/libs/suiAccountManager/types.ts +0 -10
  40. package/src/libs/suiRpcProvider/faucet.ts +0 -57
  41. package/src/libs/suiRpcProvider/index.ts +0 -114
  42. package/src/libs/suiRpcProvider/types.ts +0 -17
  43. package/src/libs/suiTxBuilder/types.ts +0 -32
package/dist/index.d.ts CHANGED
@@ -2,5 +2,4 @@ export { TransactionBlock, SUI_CLOCK_OBJECT_ID, SUI_SYSTEM_STATE_OBJECT_ID, } fr
2
2
  export { SuiKit } from './suiKit';
3
3
  export { SuiAccountManager } from './libs/suiAccountManager';
4
4
  export { SuiTxBlock } from './libs/suiTxBuilder';
5
- export { SuiRpcProvider } from './libs/suiRpcProvider';
6
5
  export type * from './types';
package/dist/index.js CHANGED
@@ -24,7 +24,6 @@ __export(src_exports, {
24
24
  SUI_SYSTEM_STATE_OBJECT_ID: () => import_sui10.SUI_SYSTEM_STATE_OBJECT_ID,
25
25
  SuiAccountManager: () => SuiAccountManager,
26
26
  SuiKit: () => SuiKit,
27
- SuiRpcProvider: () => SuiRpcProvider,
28
27
  SuiTxBlock: () => SuiTxBlock,
29
28
  TransactionBlock: () => import_sui10.TransactionBlock
30
29
  });
@@ -150,153 +149,11 @@ var SuiAccountManager = class {
150
149
  }
151
150
  };
152
151
 
153
- // src/libs/suiRpcProvider/index.ts
154
- var import_sui6 = require("@mysten/sui.js");
155
-
156
- // src/libs/suiRpcProvider/faucet.ts
157
- var import_sui4 = require("@mysten/sui.js");
158
- var import_ts_retry_promise = require("ts-retry-promise");
159
- var requestFaucet = async (address, provider) => {
160
- console.log("\nRequesting SUI from faucet for address: ", address);
161
- const headers = {
162
- authority: "faucet.testnet.sui.io",
163
- method: "POST",
164
- path: "/gas",
165
- scheme: "https",
166
- accept: "*/*",
167
- "accept-encoding": "gzip, deflate, br",
168
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7",
169
- "content-length": "105",
170
- "content-type": "application/json",
171
- origin: "chrome-extension://opcgpfmipidbgpenhmajoajpbobppdil",
172
- cookie: '_ga=GA1.1.2092533979.1664032306; sui_io_cookie={"level":["necessary","analytics"],"revision":0,"data":null,"rfc_cookie":false}; _ga_YKP53WJMB0=GS1.1.1680531285.31.0.1680531334.11.0.0; _ga_0GW4F97GFL=GS1.1.1680826187.125.0.1680826187.60.0.0; __cf_bm=6rPjXUwuzUPy4yDlZuXgDj0v7xLPpUd5z0CFGCoN_YI-1680867579-0-AZMhU7/mKUUbUlOa27LmfW6eIFkBkXsPKqYgWjpjWpj2XzDckgUsRu/pxSRGfvXCspn3w7Df+uO1MR/b+XikJU0=; _cfuvid=zjwCXMmu19KBIVo_L9Qbq4TqFXJpophG3.EvFTxqdf4-1680867579342-0-604800000',
173
- "sec-ch-ua": '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
174
- "sec-ch-ua-mobile": "?0",
175
- "sec-ch-ua-platform": "macOS",
176
- "sec-fetch-dest": "empty",
177
- "sec-fetch-mode": "cors",
178
- "sec-fetch-site": "none",
179
- "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
180
- };
181
- const resp = await (0, import_ts_retry_promise.retry)(
182
- () => provider.requestSuiFromFaucet(address, headers),
183
- {
184
- backoff: "EXPONENTIAL",
185
- // overall timeout in 60 seconds
186
- timeout: 1e3 * 60,
187
- // skip retry if we hit the rate-limit error
188
- retryIf: (error) => !(error instanceof import_sui4.FaucetRateLimitError),
189
- logger: (msg) => console.warn(`Retry requesting faucet: ${msg}`)
190
- }
191
- );
192
- (0, import_sui4.assert)(resp, import_sui4.FaucetResponse, "Request faucet failed\n");
193
- console.log("Request faucet success\n");
194
- };
195
-
196
- // src/libs/suiRpcProvider/defaultChainConfigs.ts
197
- var import_sui5 = require("@mysten/sui.js");
198
- var getDefaultNetworkParams = (networkType = "devnet") => {
199
- switch (networkType) {
200
- case "localnet":
201
- return import_sui5.localnetConnection;
202
- case "devnet":
203
- return import_sui5.devnetConnection;
204
- case "testnet":
205
- return import_sui5.testnetConnection;
206
- case "mainnet":
207
- return import_sui5.mainnetConnection;
208
- default:
209
- return import_sui5.devnetConnection;
210
- }
211
- };
212
-
213
- // src/libs/suiRpcProvider/index.ts
214
- var SuiRpcProvider = class {
215
- /**
216
- *
217
- * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet'
218
- * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
219
- * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type
220
- */
221
- constructor({
222
- fullnodeUrl,
223
- faucetUrl,
224
- networkType
225
- } = {}) {
226
- const defaultNetworkParams = getDefaultNetworkParams(
227
- networkType || "devnet"
228
- );
229
- this.fullnodeUrl = fullnodeUrl || defaultNetworkParams.fullnode;
230
- this.faucetUrl = faucetUrl || defaultNetworkParams.faucet;
231
- const connection = new import_sui6.Connection({
232
- fullnode: this.fullnodeUrl,
233
- faucet: this.faucetUrl
234
- });
235
- this.provider = new import_sui6.JsonRpcProvider(connection);
236
- }
237
- /**
238
- * Request some SUI from faucet
239
- * @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
240
- */
241
- async requestFaucet(addr) {
242
- return requestFaucet(addr, this.provider);
243
- }
244
- async getBalance(addr, coinType) {
245
- return this.provider.getBalance({ owner: addr, coinType });
246
- }
247
- async getObjects(ids) {
248
- const options = { showContent: true, showDisplay: true, showType: true };
249
- const objects = await this.provider.multiGetObjects({ ids, options });
250
- const parsedObjects = objects.map((object) => {
251
- const objectId = (0, import_sui6.getObjectId)(object);
252
- const objectType = (0, import_sui6.getObjectType)(object);
253
- const objectVersion = (0, import_sui6.getObjectVersion)(object);
254
- const objectFields = (0, import_sui6.getObjectFields)(object);
255
- const objectDisplay = (0, import_sui6.getObjectDisplay)(object);
256
- return {
257
- objectId,
258
- objectType,
259
- objectVersion,
260
- objectFields,
261
- objectDisplay
262
- };
263
- });
264
- return parsedObjects;
265
- }
266
- /**
267
- * @description Select coins that add up to the given amount.
268
- * @param addr the address of the owner
269
- * @param amount the amount that is needed for the coin
270
- * @param coinType the coin type, default is '0x2::SUI::SUI'
271
- */
272
- async selectCoins(addr, amount, coinType = "0x2::SUI::SUI") {
273
- const coins = await this.provider.getCoins({ owner: addr, coinType });
274
- const selectedCoins = [];
275
- let totalAmount = 0;
276
- coins.data.sort((a, b) => parseInt(b.balance) - parseInt(a.balance));
277
- for (const coinData of coins.data) {
278
- selectedCoins.push({
279
- objectId: coinData.coinObjectId,
280
- digest: coinData.digest,
281
- version: coinData.version
282
- });
283
- totalAmount = totalAmount + parseInt(coinData.balance);
284
- if (totalAmount >= amount) {
285
- break;
286
- }
287
- }
288
- if (!selectedCoins.length) {
289
- throw new Error("No valid coins found for the transaction.");
290
- }
291
- return selectedCoins;
292
- }
293
- };
294
-
295
152
  // src/libs/suiTxBuilder/index.ts
296
- var import_sui8 = require("@mysten/sui.js");
153
+ var import_sui5 = require("@mysten/sui.js");
297
154
 
298
155
  // src/libs/suiTxBuilder/util.ts
299
- var import_sui7 = require("@mysten/sui.js");
156
+ var import_sui4 = require("@mysten/sui.js");
300
157
  var getDefaultSuiInputType = (value) => {
301
158
  if (typeof value === "string" && value.startsWith("0x")) {
302
159
  return "object";
@@ -314,7 +171,7 @@ function makeVecParam(txBlock, args, type) {
314
171
  const defaultSuiType = getDefaultSuiInputType(args[0]);
315
172
  if (type === "object" || !type && defaultSuiType === "object") {
316
173
  const objects = args.map(
317
- (arg) => typeof arg === "string" ? txBlock.object((0, import_sui7.normalizeSuiObjectId)(arg)) : arg
174
+ (arg) => typeof arg === "string" ? txBlock.object((0, import_sui4.normalizeSuiObjectId)(arg)) : arg
318
175
  );
319
176
  return txBlock.makeMoveVec({ objects });
320
177
  } else {
@@ -330,7 +187,7 @@ function isMoveVecArg(arg) {
330
187
  function convertArgs(txBlock, args) {
331
188
  return args.map((arg) => {
332
189
  if (typeof arg === "string" && arg.startsWith("0x")) {
333
- return txBlock.object((0, import_sui7.normalizeSuiObjectId)(arg));
190
+ return txBlock.object((0, import_sui4.normalizeSuiObjectId)(arg));
334
191
  } else if (isMoveVecArg(arg)) {
335
192
  const vecType = arg.vecType || void 0;
336
193
  return vecType ? makeVecParam(txBlock, arg.value, vecType) : makeVecParam(txBlock, arg);
@@ -345,7 +202,7 @@ function convertArgs(txBlock, args) {
345
202
  // src/libs/suiTxBuilder/index.ts
346
203
  var SuiTxBlock = class {
347
204
  constructor(transaction) {
348
- this.txBlock = new import_sui8.TransactionBlock(transaction);
205
+ this.txBlock = new import_sui5.TransactionBlock(transaction);
349
206
  }
350
207
  //======== override methods of TransactionBlock ============
351
208
  address(value) {
@@ -527,7 +384,7 @@ var SuiTxBlock = class {
527
384
  tx.moveCall({
528
385
  target: "0x3::sui_system::request_add_stake",
529
386
  arguments: [
530
- tx.object(import_sui8.SUI_SYSTEM_STATE_OBJECT_ID),
387
+ tx.object(import_sui5.SUI_SYSTEM_STATE_OBJECT_ID),
531
388
  stakeCoin,
532
389
  tx.pure(validatorAddr)
533
390
  ]
@@ -536,6 +393,217 @@ var SuiTxBlock = class {
536
393
  }
537
394
  };
538
395
 
396
+ // src/libs/suiInteractor/suiInteractor.ts
397
+ var import_sui7 = require("@mysten/sui.js");
398
+
399
+ // src/libs/suiModel/suiOwnedObject.ts
400
+ var import_sui6 = require("@mysten/sui.js");
401
+ var SuiOwnedObject = class {
402
+ constructor(param) {
403
+ this.objectId = param.objectId;
404
+ this.version = param.version;
405
+ this.digest = param.digest;
406
+ }
407
+ /**
408
+ * Check if the object is fully initialized.
409
+ * So that when it's used as an input, it won't be necessary to fetch from fullnode again.
410
+ * Which can save time when sending transactions.
411
+ */
412
+ isFullObject() {
413
+ return !!this.version && !!this.digest;
414
+ }
415
+ asCallArg() {
416
+ if (!this.version || !this.digest) {
417
+ return this.objectId;
418
+ }
419
+ return {
420
+ Object: {
421
+ ImmOrOwned: {
422
+ objectId: this.objectId,
423
+ version: this.version,
424
+ digest: this.digest
425
+ }
426
+ }
427
+ };
428
+ }
429
+ /**
430
+ * Update object version & digest based on the transaction response.
431
+ * @param txResponse
432
+ */
433
+ updateFromTxResponse(txResponse) {
434
+ const changes = (0, import_sui6.getObjectChanges)(txResponse);
435
+ if (!changes) {
436
+ throw new Error("Bad transaction response!");
437
+ }
438
+ for (const change of changes) {
439
+ if (change.type === "mutated" && change.objectId === this.objectId) {
440
+ this.digest = change.digest;
441
+ this.version = change.version;
442
+ return;
443
+ }
444
+ }
445
+ throw new Error("Could not find object in transaction response!");
446
+ }
447
+ };
448
+
449
+ // src/libs/suiModel/suiSharedObject.ts
450
+ var SuiSharedObject = class {
451
+ constructor(param) {
452
+ this.objectId = param.objectId;
453
+ this.initialSharedVersion = param.initialSharedVersion;
454
+ }
455
+ asCallArg(mutable = false) {
456
+ if (!this.initialSharedVersion) {
457
+ return this.objectId;
458
+ }
459
+ return {
460
+ Object: {
461
+ Shared: {
462
+ objectId: this.objectId,
463
+ initialSharedVersion: this.initialSharedVersion,
464
+ mutable
465
+ }
466
+ }
467
+ };
468
+ }
469
+ };
470
+
471
+ // src/libs/suiInteractor/util.ts
472
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
473
+
474
+ // src/libs/suiInteractor/suiInteractor.ts
475
+ var SuiInteractor = class {
476
+ constructor(fullNodeUrls) {
477
+ if (fullNodeUrls.length === 0)
478
+ throw new Error("fullNodeUrls must not be empty");
479
+ this.providers = fullNodeUrls.map((url) => new import_sui7.JsonRpcProvider(new import_sui7.Connection({ fullnode: url })));
480
+ this.currentProvider = this.providers[0];
481
+ }
482
+ switchToNextProvider() {
483
+ const currentProviderIdx = this.providers.indexOf(this.currentProvider);
484
+ this.currentProvider = this.providers[(currentProviderIdx + 1) % this.providers.length];
485
+ }
486
+ async sendTx(transactionBlock, signature) {
487
+ const txResOptions = {
488
+ showEvents: true,
489
+ showEffects: true,
490
+ showObjectChanges: true,
491
+ showBalanceChanges: true
492
+ };
493
+ for (const provider of this.providers) {
494
+ try {
495
+ const res = await provider.executeTransactionBlock({
496
+ transactionBlock,
497
+ signature,
498
+ options: txResOptions
499
+ });
500
+ return res;
501
+ } catch (err) {
502
+ console.warn(`Failed to send transaction with fullnode ${provider.connection.fullnode}: ${err}`);
503
+ await delay(2e3);
504
+ }
505
+ }
506
+ throw new Error("Failed to send transaction with all fullnodes");
507
+ }
508
+ async getObjects(ids) {
509
+ const options = { showContent: true, showDisplay: true, showType: true, showOwner: true };
510
+ for (const provider of this.providers) {
511
+ try {
512
+ const objects = await provider.multiGetObjects({ ids, options });
513
+ const parsedObjects = objects.map((object) => {
514
+ const objectId = (0, import_sui7.getObjectId)(object);
515
+ const objectType = (0, import_sui7.getObjectType)(object);
516
+ const objectVersion = (0, import_sui7.getObjectVersion)(object);
517
+ const objectDigest = object.data ? object.data.digest : void 0;
518
+ const initialSharedVersion = (0, import_sui7.getSharedObjectInitialVersion)(object);
519
+ const objectFields = (0, import_sui7.getObjectFields)(object);
520
+ const objectDisplay = (0, import_sui7.getObjectDisplay)(object);
521
+ return {
522
+ objectId,
523
+ objectType,
524
+ objectVersion,
525
+ objectDigest,
526
+ objectFields,
527
+ objectDisplay,
528
+ initialSharedVersion
529
+ };
530
+ });
531
+ return parsedObjects;
532
+ } catch (err) {
533
+ await delay(2e3);
534
+ console.warn(`Failed to get objects with fullnode ${provider.connection.fullnode}: ${err}`);
535
+ }
536
+ }
537
+ throw new Error("Failed to get objects with all fullnodes");
538
+ }
539
+ async getObject(id) {
540
+ const objects = await this.getObjects([id]);
541
+ return objects[0];
542
+ }
543
+ /**
544
+ * @description Update objects in a batch
545
+ * @param suiObjects
546
+ */
547
+ async updateObjects(suiObjects) {
548
+ const objectIds = suiObjects.map((obj) => obj.objectId);
549
+ const objects = await this.getObjects(objectIds);
550
+ for (const object of objects) {
551
+ const suiObject = suiObjects.find((obj) => obj.objectId === object.objectId);
552
+ if (suiObject instanceof SuiSharedObject) {
553
+ suiObject.initialSharedVersion = object.initialSharedVersion;
554
+ } else if (suiObject instanceof SuiOwnedObject) {
555
+ suiObject.version = object.objectVersion;
556
+ suiObject.digest = object.objectDigest;
557
+ }
558
+ }
559
+ }
560
+ /**
561
+ * @description Select coins that add up to the given amount.
562
+ * @param addr the address of the owner
563
+ * @param amount the amount that is needed for the coin
564
+ * @param coinType the coin type, default is '0x2::SUI::SUI'
565
+ */
566
+ async selectCoins(addr, amount, coinType = "0x2::SUI::SUI") {
567
+ const coins = await this.currentProvider.getCoins({ owner: addr, coinType });
568
+ const selectedCoins = [];
569
+ let totalAmount = 0;
570
+ coins.data.sort((a, b) => parseInt(b.balance) - parseInt(a.balance));
571
+ for (const coinData of coins.data) {
572
+ selectedCoins.push({
573
+ objectId: coinData.coinObjectId,
574
+ digest: coinData.digest,
575
+ version: coinData.version
576
+ });
577
+ totalAmount = totalAmount + parseInt(coinData.balance);
578
+ if (totalAmount >= amount) {
579
+ break;
580
+ }
581
+ }
582
+ if (!selectedCoins.length) {
583
+ throw new Error("No valid coins found for the transaction.");
584
+ }
585
+ return selectedCoins;
586
+ }
587
+ };
588
+
589
+ // src/libs/suiInteractor/defaultConfig.ts
590
+ var import_sui8 = require("@mysten/sui.js");
591
+ var defaultGasBudget = 10 ** 8;
592
+ var getDefaultConnection = (networkType = "devnet") => {
593
+ switch (networkType) {
594
+ case "localnet":
595
+ return import_sui8.localnetConnection;
596
+ case "devnet":
597
+ return import_sui8.devnetConnection;
598
+ case "testnet":
599
+ return import_sui8.testnetConnection;
600
+ case "mainnet":
601
+ return import_sui8.mainnetConnection;
602
+ default:
603
+ return import_sui8.devnetConnection;
604
+ }
605
+ };
606
+
539
607
  // src/suiKit.ts
540
608
  var SuiKit = class {
541
609
  /**
@@ -548,21 +616,16 @@ var SuiKit = class {
548
616
  * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
549
617
  * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet'
550
618
  * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
551
- * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type
552
619
  */
553
620
  constructor({
554
621
  mnemonics,
555
622
  secretKey,
556
623
  networkType,
557
- fullnodeUrl,
558
- faucetUrl
624
+ fullnodeUrls
559
625
  } = {}) {
560
626
  this.accountManager = new SuiAccountManager({ mnemonics, secretKey });
561
- this.rpcProvider = new SuiRpcProvider({
562
- fullnodeUrl,
563
- faucetUrl,
564
- networkType
565
- });
627
+ fullnodeUrls = fullnodeUrls || [getDefaultConnection(networkType).fullnode];
628
+ this.suiInteractor = new SuiInteractor(fullnodeUrls);
566
629
  }
567
630
  /**
568
631
  * if derivePathParams is not provided or mnemonics is empty, it will return the currentSigner.
@@ -572,7 +635,7 @@ var SuiKit = class {
572
635
  */
573
636
  getSigner(derivePathParams) {
574
637
  const keyPair = this.accountManager.getKeyPair(derivePathParams);
575
- return new import_sui9.RawSigner(keyPair, this.rpcProvider.provider);
638
+ return new import_sui9.RawSigner(keyPair, this.suiInteractor.currentProvider);
576
639
  }
577
640
  /**
578
641
  * @description Switch the current account with the given derivePathParams
@@ -592,22 +655,21 @@ var SuiKit = class {
592
655
  return this.accountManager.currentAddress;
593
656
  }
594
657
  provider() {
595
- return this.rpcProvider.provider;
596
- }
597
- /**
598
- * Request some SUI from faucet
599
- * @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
600
- */
601
- async requestFaucet(derivePathParams) {
602
- const addr = this.accountManager.getAddress(derivePathParams);
603
- return this.rpcProvider.requestFaucet(addr);
658
+ return this.suiInteractor.currentProvider;
604
659
  }
605
660
  async getBalance(coinType, derivePathParams) {
606
661
  const owner = this.accountManager.getAddress(derivePathParams);
607
- return this.rpcProvider.getBalance(owner, coinType);
662
+ return this.suiInteractor.currentProvider.getBalance({ owner, coinType });
608
663
  }
609
664
  async getObjects(objectIds) {
610
- return this.rpcProvider.getObjects(objectIds);
665
+ return this.suiInteractor.getObjects(objectIds);
666
+ }
667
+ /**
668
+ * @description Update objects in a batch
669
+ * @param suiObjects
670
+ */
671
+ async updateObjects(suiObjects) {
672
+ return this.suiInteractor.updateObjects(suiObjects);
611
673
  }
612
674
  async signTxn(tx, derivePathParams) {
613
675
  tx = tx instanceof SuiTxBlock ? tx.txBlock : tx;
@@ -615,16 +677,8 @@ var SuiKit = class {
615
677
  return signer.signTransactionBlock({ transactionBlock: tx });
616
678
  }
617
679
  async signAndSendTxn(tx, derivePathParams) {
618
- tx = tx instanceof SuiTxBlock ? tx.txBlock : tx;
619
- const signer = this.getSigner(derivePathParams);
620
- return signer.signAndExecuteTransactionBlock({
621
- transactionBlock: tx,
622
- options: {
623
- showEffects: true,
624
- showEvents: true,
625
- showObjectChanges: true
626
- }
627
- });
680
+ const { transactionBlockBytes, signature } = await this.signTxn(tx, derivePathParams);
681
+ return this.suiInteractor.sendTx(transactionBlockBytes, signature);
628
682
  }
629
683
  /**
630
684
  * Transfer the given amount of SUI to the recipient
@@ -659,7 +713,7 @@ var SuiKit = class {
659
713
  const tx = new SuiTxBlock();
660
714
  const owner = this.accountManager.getAddress(derivePathParams);
661
715
  const totalAmount = amounts.reduce((a, b) => a + b, 0);
662
- const coins = await this.rpcProvider.selectCoins(
716
+ const coins = await this.suiInteractor.selectCoins(
663
717
  owner,
664
718
  totalAmount,
665
719
  coinType
@@ -704,7 +758,7 @@ var SuiKit = class {
704
758
  */
705
759
  async selectCoinsWithAmount(amount, coinType, owner) {
706
760
  owner = owner || this.accountManager.currentAddress;
707
- const coins = await this.rpcProvider.selectCoins(owner, amount, coinType);
761
+ const coins = await this.suiInteractor.selectCoins(owner, amount, coinType);
708
762
  return coins.map((c) => c.objectId);
709
763
  }
710
764
  /**
@@ -727,7 +781,7 @@ var SuiKit = class {
727
781
  */
728
782
  async inspectTxn(tx, derivePathParams) {
729
783
  tx = tx instanceof SuiTxBlock ? tx.txBlock : tx;
730
- return this.rpcProvider.provider.devInspectTransactionBlock({
784
+ return this.suiInteractor.currentProvider.devInspectTransactionBlock({
731
785
  transactionBlock: tx,
732
786
  sender: this.getAddress(derivePathParams)
733
787
  });
@@ -739,7 +793,6 @@ var SuiKit = class {
739
793
  SUI_SYSTEM_STATE_OBJECT_ID,
740
794
  SuiAccountManager,
741
795
  SuiKit,
742
- SuiRpcProvider,
743
796
  SuiTxBlock,
744
797
  TransactionBlock
745
798
  });