@scallop-io/sui-kit 0.37.0 → 0.38.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 (41) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +243 -183
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +253 -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/suiModel/index.d.ts +2 -0
  12. package/dist/libs/suiModel/suiOwnedObject.d.ts +24 -0
  13. package/dist/libs/suiModel/suiSharedObject.d.ts +12 -0
  14. package/dist/libs/suiTxBuilder/index.d.ts +1 -1
  15. package/dist/libs/suiTxBuilder/util.d.ts +1 -1
  16. package/dist/suiKit.d.ts +10 -13
  17. package/dist/types/index.d.ts +33 -5
  18. package/package.json +5 -7
  19. package/src/index.ts +0 -1
  20. package/src/libs/suiAccountManager/index.ts +1 -1
  21. package/src/libs/suiAccountManager/keypair.ts +1 -1
  22. package/src/libs/{suiRpcProvider/defaultChainConfigs.ts → suiInteractor/defaultConfig.ts} +5 -2
  23. package/src/libs/suiInteractor/index.ts +2 -0
  24. package/src/libs/suiInteractor/suiInteractor.ts +167 -0
  25. package/src/libs/suiModel/index.ts +2 -0
  26. package/src/libs/suiModel/suiOwnedObject.ts +63 -0
  27. package/src/libs/suiModel/suiSharedObject.ts +30 -0
  28. package/src/libs/suiTxBuilder/index.ts +1 -1
  29. package/src/libs/suiTxBuilder/util.ts +1 -1
  30. package/src/suiKit.ts +23 -39
  31. package/src/types/index.ts +65 -9
  32. package/dist/libs/suiAccountManager/types.d.ts +0 -9
  33. package/dist/libs/suiRpcProvider/faucet.d.ts +0 -8
  34. package/dist/libs/suiRpcProvider/index.d.ts +0 -40
  35. package/dist/libs/suiRpcProvider/types.d.ts +0 -14
  36. package/dist/libs/suiTxBuilder/types.d.ts +0 -12
  37. package/src/libs/suiAccountManager/types.ts +0 -10
  38. package/src/libs/suiRpcProvider/faucet.ts +0 -57
  39. package/src/libs/suiRpcProvider/index.ts +0 -114
  40. package/src/libs/suiRpcProvider/types.ts +0 -17
  41. 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,224 @@ 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/suiInteractor.ts
472
+ var SuiInteractor = class {
473
+ constructor(fullNodeUrls) {
474
+ if (fullNodeUrls.length === 0)
475
+ throw new Error("fullNodeUrls must not be empty");
476
+ this.providers = fullNodeUrls.map((url) => new import_sui7.JsonRpcProvider(new import_sui7.Connection({ fullnode: url })));
477
+ this.currentProvider = this.providers[0];
478
+ }
479
+ switchToNextProvider() {
480
+ const currentProviderIdx = this.providers.indexOf(this.currentProvider);
481
+ this.currentProvider = this.providers[(currentProviderIdx + 1) % this.providers.length];
482
+ }
483
+ async sendTx(transactionBlock, signature) {
484
+ const txResOptions = {
485
+ showEvents: true,
486
+ showEffects: true,
487
+ showObjectChanges: true,
488
+ showBalanceChanges: true
489
+ };
490
+ const currentProviderIdx = this.providers.indexOf(this.currentProvider);
491
+ const providers = [
492
+ ...this.providers.slice(currentProviderIdx, this.providers.length),
493
+ ...this.providers.slice(0, currentProviderIdx)
494
+ ];
495
+ for (const provider of providers) {
496
+ try {
497
+ const res = await this.currentProvider.executeTransactionBlock({
498
+ transactionBlock,
499
+ signature,
500
+ options: txResOptions
501
+ });
502
+ this.currentProvider = provider;
503
+ return res;
504
+ } catch (err) {
505
+ console.warn(`Failed to send transaction with fullnode ${provider.connection.fullnode}: ${err}`);
506
+ }
507
+ }
508
+ throw new Error("Failed to send transaction with all fullnodes");
509
+ }
510
+ async getObjects(ids) {
511
+ const options = { showContent: true, showDisplay: true, showType: true, showOwner: true };
512
+ const currentProviderIdx = this.providers.indexOf(this.currentProvider);
513
+ const providers = [
514
+ ...this.providers.slice(currentProviderIdx, this.providers.length),
515
+ ...this.providers.slice(0, currentProviderIdx)
516
+ ];
517
+ for (const provider of providers) {
518
+ try {
519
+ const objects = await this.currentProvider.multiGetObjects({ ids, options });
520
+ this.currentProvider = provider;
521
+ const parsedObjects = objects.map((object) => {
522
+ const objectId = (0, import_sui7.getObjectId)(object);
523
+ const objectType = (0, import_sui7.getObjectType)(object);
524
+ const objectVersion = (0, import_sui7.getObjectVersion)(object);
525
+ const objectDigest = object.data ? object.data.digest : void 0;
526
+ const initialSharedVersion = (0, import_sui7.getSharedObjectInitialVersion)(object);
527
+ const objectFields = (0, import_sui7.getObjectFields)(object);
528
+ const objectDisplay = (0, import_sui7.getObjectDisplay)(object);
529
+ return {
530
+ objectId,
531
+ objectType,
532
+ objectVersion,
533
+ objectDigest,
534
+ objectFields,
535
+ objectDisplay,
536
+ initialSharedVersion
537
+ };
538
+ });
539
+ return parsedObjects;
540
+ } catch (err) {
541
+ console.warn(`Failed to get objects with fullnode ${provider.connection.fullnode}: ${err}`);
542
+ }
543
+ }
544
+ throw new Error("Failed to get objects with all fullnodes");
545
+ }
546
+ async getObject(id) {
547
+ const objects = await this.getObjects([id]);
548
+ return objects[0];
549
+ }
550
+ /**
551
+ * @description Update objects in a batch
552
+ * @param suiObjects
553
+ */
554
+ async updateObjects(suiObjects) {
555
+ const objectIds = suiObjects.map((obj) => obj.objectId);
556
+ const objects = await this.getObjects(objectIds);
557
+ for (const object of objects) {
558
+ const suiObject = suiObjects.find((obj) => obj.objectId === object.objectId);
559
+ if (suiObject instanceof SuiSharedObject) {
560
+ suiObject.initialSharedVersion = object.initialSharedVersion;
561
+ } else if (suiObject instanceof SuiOwnedObject) {
562
+ suiObject.version = object.objectVersion;
563
+ suiObject.digest = object.objectDigest;
564
+ }
565
+ }
566
+ }
567
+ /**
568
+ * @description Select coins that add up to the given amount.
569
+ * @param addr the address of the owner
570
+ * @param amount the amount that is needed for the coin
571
+ * @param coinType the coin type, default is '0x2::SUI::SUI'
572
+ */
573
+ async selectCoins(addr, amount, coinType = "0x2::SUI::SUI") {
574
+ const coins = await this.currentProvider.getCoins({ owner: addr, coinType });
575
+ const selectedCoins = [];
576
+ let totalAmount = 0;
577
+ coins.data.sort((a, b) => parseInt(b.balance) - parseInt(a.balance));
578
+ for (const coinData of coins.data) {
579
+ selectedCoins.push({
580
+ objectId: coinData.coinObjectId,
581
+ digest: coinData.digest,
582
+ version: coinData.version
583
+ });
584
+ totalAmount = totalAmount + parseInt(coinData.balance);
585
+ if (totalAmount >= amount) {
586
+ break;
587
+ }
588
+ }
589
+ if (!selectedCoins.length) {
590
+ throw new Error("No valid coins found for the transaction.");
591
+ }
592
+ return selectedCoins;
593
+ }
594
+ };
595
+
596
+ // src/libs/suiInteractor/defaultConfig.ts
597
+ var import_sui8 = require("@mysten/sui.js");
598
+ var defaultGasBudget = 10 ** 8;
599
+ var getDefaultConnection = (networkType = "devnet") => {
600
+ switch (networkType) {
601
+ case "localnet":
602
+ return import_sui8.localnetConnection;
603
+ case "devnet":
604
+ return import_sui8.devnetConnection;
605
+ case "testnet":
606
+ return import_sui8.testnetConnection;
607
+ case "mainnet":
608
+ return import_sui8.mainnetConnection;
609
+ default:
610
+ return import_sui8.devnetConnection;
611
+ }
612
+ };
613
+
539
614
  // src/suiKit.ts
540
615
  var SuiKit = class {
541
616
  /**
@@ -548,21 +623,16 @@ var SuiKit = class {
548
623
  * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
549
624
  * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet'
550
625
  * @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
626
  */
553
627
  constructor({
554
628
  mnemonics,
555
629
  secretKey,
556
630
  networkType,
557
- fullnodeUrl,
558
- faucetUrl
631
+ fullnodeUrls
559
632
  } = {}) {
560
633
  this.accountManager = new SuiAccountManager({ mnemonics, secretKey });
561
- this.rpcProvider = new SuiRpcProvider({
562
- fullnodeUrl,
563
- faucetUrl,
564
- networkType
565
- });
634
+ fullnodeUrls = fullnodeUrls || [getDefaultConnection(networkType).fullnode];
635
+ this.suiInteractor = new SuiInteractor(fullnodeUrls);
566
636
  }
567
637
  /**
568
638
  * if derivePathParams is not provided or mnemonics is empty, it will return the currentSigner.
@@ -572,7 +642,7 @@ var SuiKit = class {
572
642
  */
573
643
  getSigner(derivePathParams) {
574
644
  const keyPair = this.accountManager.getKeyPair(derivePathParams);
575
- return new import_sui9.RawSigner(keyPair, this.rpcProvider.provider);
645
+ return new import_sui9.RawSigner(keyPair, this.suiInteractor.currentProvider);
576
646
  }
577
647
  /**
578
648
  * @description Switch the current account with the given derivePathParams
@@ -592,22 +662,21 @@ var SuiKit = class {
592
662
  return this.accountManager.currentAddress;
593
663
  }
594
664
  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);
665
+ return this.suiInteractor.currentProvider;
604
666
  }
605
667
  async getBalance(coinType, derivePathParams) {
606
668
  const owner = this.accountManager.getAddress(derivePathParams);
607
- return this.rpcProvider.getBalance(owner, coinType);
669
+ return this.suiInteractor.currentProvider.getBalance({ owner, coinType });
608
670
  }
609
671
  async getObjects(objectIds) {
610
- return this.rpcProvider.getObjects(objectIds);
672
+ return this.suiInteractor.getObjects(objectIds);
673
+ }
674
+ /**
675
+ * @description Update objects in a batch
676
+ * @param suiObjects
677
+ */
678
+ async updateObjects(suiObjects) {
679
+ return this.suiInteractor.updateObjects(suiObjects);
611
680
  }
612
681
  async signTxn(tx, derivePathParams) {
613
682
  tx = tx instanceof SuiTxBlock ? tx.txBlock : tx;
@@ -615,16 +684,8 @@ var SuiKit = class {
615
684
  return signer.signTransactionBlock({ transactionBlock: tx });
616
685
  }
617
686
  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
- });
687
+ const { transactionBlockBytes, signature } = await this.signTxn(tx, derivePathParams);
688
+ return this.suiInteractor.sendTx(transactionBlockBytes, signature);
628
689
  }
629
690
  /**
630
691
  * Transfer the given amount of SUI to the recipient
@@ -659,7 +720,7 @@ var SuiKit = class {
659
720
  const tx = new SuiTxBlock();
660
721
  const owner = this.accountManager.getAddress(derivePathParams);
661
722
  const totalAmount = amounts.reduce((a, b) => a + b, 0);
662
- const coins = await this.rpcProvider.selectCoins(
723
+ const coins = await this.suiInteractor.selectCoins(
663
724
  owner,
664
725
  totalAmount,
665
726
  coinType
@@ -704,7 +765,7 @@ var SuiKit = class {
704
765
  */
705
766
  async selectCoinsWithAmount(amount, coinType, owner) {
706
767
  owner = owner || this.accountManager.currentAddress;
707
- const coins = await this.rpcProvider.selectCoins(owner, amount, coinType);
768
+ const coins = await this.suiInteractor.selectCoins(owner, amount, coinType);
708
769
  return coins.map((c) => c.objectId);
709
770
  }
710
771
  /**
@@ -727,7 +788,7 @@ var SuiKit = class {
727
788
  */
728
789
  async inspectTxn(tx, derivePathParams) {
729
790
  tx = tx instanceof SuiTxBlock ? tx.txBlock : tx;
730
- return this.rpcProvider.provider.devInspectTransactionBlock({
791
+ return this.suiInteractor.currentProvider.devInspectTransactionBlock({
731
792
  transactionBlock: tx,
732
793
  sender: this.getAddress(derivePathParams)
733
794
  });
@@ -739,7 +800,6 @@ var SuiKit = class {
739
800
  SUI_SYSTEM_STATE_OBJECT_ID,
740
801
  SuiAccountManager,
741
802
  SuiKit,
742
- SuiRpcProvider,
743
803
  SuiTxBlock,
744
804
  TransactionBlock
745
805
  });