@msafe/sui3-sdk 0.0.65 → 0.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # msafe-sui3-sdk
2
2
 
3
- SDK for MSafe SUI V3
3
+ SDK for MSafe SUI V3 //chore
4
4
 
5
5
  ## Test
6
6
 
@@ -35,3 +35,4 @@ Running this command will connect Sqlite DB only in memory.
35
35
  1. git clone processor: <https://github.com/Momentum-Safe/msafe-sui-processors>
36
36
  2. run yarn start:dev
37
37
  5. run tests in msafe-e2e.test.ts
38
+
package/dist/index.cjs CHANGED
@@ -62,7 +62,7 @@ __export(src_exports, {
62
62
  module.exports = __toCommonJS(src_exports);
63
63
 
64
64
  // src/core/CreateHelper.ts
65
- var import_iota_utils = require("@msafe/iota-utils");
65
+ var import_sui3_utils = require("@msafe/sui3-utils");
66
66
  var CreateHelper = class {
67
67
  constructor(globals, pkHelper) {
68
68
  this.globals = globals;
@@ -73,7 +73,7 @@ var CreateHelper = class {
73
73
  }
74
74
  async calculateMSafeAddress(info) {
75
75
  const msConfig = await this.reduceCreationInfoToRawConfig(info);
76
- const ms = new import_iota_utils.MultiSigAccount(msConfig);
76
+ const ms = new import_sui3_utils.MultiSigAccount(msConfig);
77
77
  return ms.address;
78
78
  }
79
79
  // Validate the create info and return the msafe address.
@@ -89,15 +89,15 @@ var CreateHelper = class {
89
89
  * @throws error if the public key does not match
90
90
  */
91
91
  addPublicKey(address, pkEncoded) {
92
- const pk = import_iota_utils.PublicKeySerde.de(pkEncoded);
93
- if (!(0, import_iota_utils.isSameAddress)(address, pk.toIotaAddress())) {
92
+ const pk = import_sui3_utils.PublicKeySerde.de(pkEncoded);
93
+ if (!(0, import_sui3_utils.isSameAddress)(address, pk.toSuiAddress())) {
94
94
  throw new Error("Public key not match");
95
95
  }
96
96
  this.pkHelper.addPublicKey(address, pk);
97
97
  }
98
98
  async submitMSafeCreation(creationInfo) {
99
99
  const msafeAddress = await this.validateCreateInfo(creationInfo);
100
- const signingMessage = import_iota_utils.SigningMessageHelper.createMSafeMessage(msafeAddress);
100
+ const signingMessage = import_sui3_utils.SigningMessageHelper.createMSafeMessage(msafeAddress);
101
101
  const signature = await this.globals.wallet.signPersonalMessage({ messageStr: signingMessage });
102
102
  await this.submitToBackend(creationInfo, signature.signature);
103
103
  return msafeAddress;
@@ -125,7 +125,7 @@ var CreateHelper = class {
125
125
  address: owner.address,
126
126
  weight: owner.weight,
127
127
  status: "",
128
- ...import_iota_utils.PublicKeySerde.ser(pks[i])
128
+ ...import_sui3_utils.PublicKeySerde.ser(pks[i])
129
129
  })),
130
130
  threshold: createInfo.threshold,
131
131
  name: createInfo.name,
@@ -139,10 +139,10 @@ var CreateHelper = class {
139
139
  };
140
140
 
141
141
  // src/core/MSafeClient.ts
142
- var import_iota_utils7 = require("@msafe/iota-utils");
142
+ var import_sui3_utils7 = require("@msafe/sui3-utils");
143
143
 
144
144
  // src/core/AddressBookSDK.ts
145
- var import_iota_utils2 = require("@msafe/iota-utils");
145
+ var import_sui3_utils2 = require("@msafe/sui3-utils");
146
146
  var AddressBookSDK = class {
147
147
  constructor(globals) {
148
148
  this.globals = globals;
@@ -151,7 +151,7 @@ var AddressBookSDK = class {
151
151
  return this.globals.backend.getAddressBookEntries(pagination);
152
152
  }
153
153
  async update(updates) {
154
- const messageStr = import_iota_utils2.SigningMessageHelper.updateAddressBookMessage(updates);
154
+ const messageStr = import_sui3_utils2.SigningMessageHelper.updateAddressBookMessage(updates);
155
155
  const sig = await this.globals.wallet.signPersonalMessage({ messageStr });
156
156
  return this.globals.backend.updateAddressBook({ updates, signature: sig.signature });
157
157
  }
@@ -178,13 +178,14 @@ var InvitationSDK = class {
178
178
  };
179
179
 
180
180
  // src/core/MSafeAccount.ts
181
- var import_iota_app_store = require("@msafe/iota-app-store");
182
- var import_iota_utils4 = require("@msafe/iota-utils");
183
- var import_transactions2 = require("@iota/iota-sdk/transactions");
184
- var import_utils3 = require("@iota/iota-sdk/utils");
181
+ var import_sui_app_store = require("@msafe/sui-app-store");
182
+ var import_sui3_utils4 = require("@msafe/sui3-utils");
183
+ var import_transactions2 = require("@mysten/sui.js/transactions");
184
+ var import_utils3 = require("@mysten/sui.js/utils");
185
+ var import_wallet_standard = require("@mysten/wallet-standard");
185
186
 
186
187
  // src/simulate/simulator.ts
187
- var import_transactions = require("@iota/iota-sdk/transactions");
188
+ var import_transactions = require("@mysten/sui.js/transactions");
188
189
  var GAS_SAFE_OVERHEAD = 1000n;
189
190
  var DEF_GAS_PRICE_NUM = 120n;
190
191
  var DEF_GAS_PRICE_DEN = 100n;
@@ -208,12 +209,12 @@ var Simulator = class {
208
209
  }
209
210
  async simulate(input, gasOption = DEF_GAS_PRICE_OPTION, budgetOption = DEF_GAS_BUDGET_OPTION) {
210
211
  const tx = this.copyTransactionBlock(input.txb);
211
- const { client } = this.globals;
212
+ const { suiClient } = this.globals;
212
213
  const gasPrice = await this.getGasPrice(gasOption);
213
214
  tx.setGasPrice(gasPrice);
214
215
  try {
215
- const inspectResult = await client.dryRunTransactionBlock({
216
- transactionBlock: await tx.build({ client })
216
+ const inspectResult = await suiClient.dryRunTransactionBlock({
217
+ transactionBlock: await tx.build({ client: suiClient })
217
218
  });
218
219
  const { gasUsed } = inspectResult.effects;
219
220
  const gasBudget = this.toGasBudget(gasUsed, gasPrice);
@@ -254,7 +255,7 @@ var Simulator = class {
254
255
  if (this.isFixedValue(option)) {
255
256
  return option.fixedVal;
256
257
  }
257
- const refGasPrice = await this.globals.client.getReferenceGasPrice();
258
+ const refGasPrice = await this.globals.suiClient.getReferenceGasPrice();
258
259
  return this.applyGasOption(refGasPrice, option);
259
260
  }
260
261
  toGasBudget(gasUsed, gasPrice) {
@@ -308,13 +309,13 @@ function HexToUint8Array(hex) {
308
309
  }
309
310
 
310
311
  // src/utils/crypto.ts
311
- var import_verify = require("@iota/iota-sdk/verify");
312
+ var import_verify = require("@mysten/sui.js/verify");
312
313
 
313
314
  // src/utils/format.ts
314
- var import_utils2 = require("@iota/iota-sdk/utils");
315
+ var import_utils2 = require("@mysten/sui.js/utils");
315
316
 
316
317
  // src/utils/coin.ts
317
- var import_utils = require("@iota/iota-sdk/utils");
318
+ var import_utils = require("@mysten/sui.js/utils");
318
319
  var CoinHelper = class {
319
320
  _client;
320
321
  _coinMetaReg;
@@ -367,14 +368,14 @@ var Coin = class _Coin {
367
368
 
368
369
  // src/utils/format.ts
369
370
  var Formatter = class {
370
- static normalizeIotaAddress(addr) {
371
- return (0, import_utils2.normalizeIotaAddress)(addr);
371
+ static normalizeSuiAddress(addr) {
372
+ return (0, import_utils2.normalizeSuiAddress)(addr);
372
373
  }
373
374
  static normalizeStructTag(struct) {
374
375
  return (0, import_utils2.normalizeStructTag)(struct);
375
376
  }
376
377
  static isSuiAddressEqual(addr1, addr2) {
377
- return (0, import_utils2.normalizeIotaAddress)(addr1) === (0, import_utils2.normalizeIotaAddress)(addr2);
378
+ return (0, import_utils2.normalizeSuiAddress)(addr1) === (0, import_utils2.normalizeSuiAddress)(addr2);
378
379
  }
379
380
  static isSuiStructEqual(struct1, struct2) {
380
381
  return (0, import_utils2.normalizeStructTag)(struct1) === (0, import_utils2.normalizeStructTag)(struct2);
@@ -408,7 +409,7 @@ var SignatureVerifier = class _SignatureVerifier {
408
409
  }
409
410
  static async verifySignature(input) {
410
411
  const publicKey = await _SignatureVerifier.getPublicKeyFromSignature(input);
411
- return Formatter.isSuiAddressEqual(publicKey.toIotaAddress(), input.targetAddress);
412
+ return Formatter.isSuiAddressEqual(publicKey.toSuiAddress(), input.targetAddress);
412
413
  }
413
414
  static async verifyPersonalSignature(input) {
414
415
  const message = stringToBuffer(input.messageStr);
@@ -430,14 +431,14 @@ var SignatureVerifier = class _SignatureVerifier {
430
431
  };
431
432
 
432
433
  // src/utils/sui.ts
433
- var import_iota_utils3 = require("@msafe/iota-utils");
434
- var import_cryptography = require("@iota/iota-sdk/cryptography");
435
- var import_multisig = require("@iota/iota-sdk/multisig");
434
+ var import_sui3_utils3 = require("@msafe/sui3-utils");
435
+ var import_cryptography = require("@mysten/sui.js/cryptography");
436
+ var import_multisig = require("@mysten/sui.js/multisig");
436
437
  var SUI_COIN = "0x2::sui::SUI";
437
- async function getPublicKeyFromChain(client, address) {
438
+ async function getPublicKeyFromChain(suiClient, address) {
438
439
  let txs;
439
440
  try {
440
- txs = await client.queryTransactionBlocks({
441
+ txs = await suiClient.queryTransactionBlocks({
441
442
  // Disable naming rule since the variable is defined by Mysten
442
443
  filter: { FromAddress: address },
443
444
  options: { showInput: true },
@@ -465,7 +466,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
465
466
  const decoded = (0, import_cryptography.parseSerializedSignature)(serializedSig);
466
467
  switch (decoded.signatureScheme) {
467
468
  case "MultiSig": {
468
- const multiSigAddress = new import_multisig.MultiSigPublicKey(decoded.multisig.multisig_pk).toIotaAddress();
469
+ const multiSigAddress = new import_multisig.MultiSigPublicKey(decoded.multisig.multisig_pk).toSuiAddress();
469
470
  if (Formatter.isSuiAddressEqual(multiSigAddress, targetAddress)) {
470
471
  throw new Error("multi-sig wallet cannot be owner");
471
472
  }
@@ -480,8 +481,8 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
480
481
  case "ED25519":
481
482
  case "Secp256k1":
482
483
  case "Secp256r1": {
483
- const pk = import_iota_utils3.PublicKeySerde.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
484
- if (Formatter.isSuiAddressEqual(pk.toIotaAddress(), targetAddress)) {
484
+ const pk = import_sui3_utils3.PublicKeySerde.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
485
+ if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
485
486
  return pk;
486
487
  }
487
488
  return void 0;
@@ -495,7 +496,7 @@ async function getAllCoins(input) {
495
496
  let cursor;
496
497
  const res = [];
497
498
  while (hasNext) {
498
- const currentPage = await input.client.getCoins({
499
+ const currentPage = await input.suiClient.getCoins({
499
500
  owner: input.owner,
500
501
  coinType: input.coinType,
501
502
  cursor
@@ -639,12 +640,12 @@ var MSafeAccount = class _MSafeAccount {
639
640
  constructor(globals, info) {
640
641
  this.globals = globals;
641
642
  this.info = info;
642
- this.multiSig = new import_iota_utils4.MultiSigAccount({
643
+ this.multiSig = new import_sui3_utils4.MultiSigAccount({
643
644
  threshold: info.threshold,
644
645
  ownersWithWeight: info.owners,
645
646
  creationNonce: info.creationNonce
646
647
  });
647
- this.coinHelper = new CoinHelper(this.client);
648
+ this.coinHelper = new CoinHelper(this.suiClient);
648
649
  this.simulator = new Simulator(globals);
649
650
  }
650
651
  multiSig;
@@ -658,7 +659,7 @@ var MSafeAccount = class _MSafeAccount {
658
659
  }
659
660
  }
660
661
  async ownedCoins() {
661
- const balances = await this.client.getAllBalances({ owner: this.address });
662
+ const balances = await this.suiClient.getAllBalances({ owner: this.address });
662
663
  return Promise.all(
663
664
  balances.map(async (balance) => {
664
665
  const meta = await this.coinHelper.getCoinMeta(balance.coinType);
@@ -676,7 +677,7 @@ var MSafeAccount = class _MSafeAccount {
676
677
  filter: (objRes) => !objRes?.data?.type?.startsWith("0x2::coin::Coin"),
677
678
  ...options
678
679
  };
679
- return getAllOwnedObjects(this.client, this.address, filterCoinObjectOptions);
680
+ return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
680
681
  }
681
682
  async pendingTransaction() {
682
683
  const res = await this.backend.getPendingTransactions({ msafeAddress: this.address });
@@ -720,7 +721,7 @@ var MSafeAccount = class _MSafeAccount {
720
721
  return this.backend.getNextSequenceNumber(this.address);
721
722
  }
722
723
  async simulateIntention(request) {
723
- const appHelper = import_iota_app_store.appHelpers.getAppHelper(request.application);
724
+ const appHelper = import_sui_app_store.appHelpers.getAppHelper(request.application);
724
725
  if (!appHelper) {
725
726
  throw new Error(`Can't find app helper for application ${request.application}`);
726
727
  }
@@ -729,11 +730,11 @@ var MSafeAccount = class _MSafeAccount {
729
730
  intentionData: request.intention,
730
731
  txType: request.txType,
731
732
  txSubType: request.txSubType,
732
- client: this.globals.client,
733
+ clientUrl: this.globals.config.suiClient.url,
733
734
  account: {
734
735
  address: this.address,
735
736
  publicKey: (0, import_utils3.fromHEX)(this.address),
736
- chains: [],
737
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
737
738
  features: []
738
739
  }
739
740
  });
@@ -741,7 +742,7 @@ var MSafeAccount = class _MSafeAccount {
741
742
  return this.simulator.simulate({ txb, sender: this.address });
742
743
  }
743
744
  async proposeIntention(input) {
744
- const message = import_iota_utils4.SigningMessageHelper.proposeIntentionMessage({
745
+ const message = import_sui3_utils4.SigningMessageHelper.proposeIntentionMessage({
745
746
  msafeAddress: this.address,
746
747
  intention: input.intention,
747
748
  sn: input.sequenceNumber
@@ -756,7 +757,7 @@ var MSafeAccount = class _MSafeAccount {
756
757
  });
757
758
  }
758
759
  async proposeIntentionAndBuildVote(input) {
759
- const appHelper = import_iota_app_store.appHelpers.getAppHelper(input.application);
760
+ const appHelper = import_sui_app_store.appHelpers.getAppHelper(input.application);
760
761
  if (!appHelper) {
761
762
  throw new Error(`Can't find app helper for application ${input.application}`);
762
763
  }
@@ -765,19 +766,19 @@ var MSafeAccount = class _MSafeAccount {
765
766
  intentionData: input.intention,
766
767
  txType: input.txType,
767
768
  txSubType: input.txSubType,
768
- client: this.globals.client,
769
+ clientUrl: this.globals.config.suiClient.url,
769
770
  account: {
770
771
  address: this.address,
771
772
  publicKey: (0, import_utils3.fromHEX)(this.address),
772
- chains: [],
773
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
773
774
  features: []
774
775
  }
775
776
  });
776
777
  txb.setGasPrice(input.gasPrice);
777
778
  txb.setGasBudget(input.gasBudget);
778
779
  txb.setSender(this.address);
779
- const payload = await txb.build({ client: this.globals.client });
780
- const digest = await txb.getDigest({ client: this.globals.client });
780
+ const payload = await txb.build({ client: this.globals.suiClient });
781
+ const digest = await txb.getDigest({ client: this.globals.suiClient });
781
782
  const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
782
783
  return this.backend.proposeIntentionAndBuildVote({
783
784
  ...input,
@@ -790,9 +791,9 @@ var MSafeAccount = class _MSafeAccount {
790
791
  async simulateCoinTransferIntention(intention) {
791
792
  const sn = await this.nextSequenceNumber();
792
793
  return this.simulateIntention({
793
- application: import_iota_utils4.TransactionDefaultApplication,
794
- txType: import_iota_utils4.TransactionType.Assets,
795
- txSubType: import_iota_utils4.TransactionSubTypes.assets.coin.send,
794
+ application: import_sui3_utils4.TransactionDefaultApplication,
795
+ txType: import_sui3_utils4.TransactionType.Assets,
796
+ txSubType: import_sui3_utils4.TransactionSubTypes.assets.coin.send,
796
797
  sequenceNumber: sn,
797
798
  intention
798
799
  });
@@ -800,9 +801,9 @@ var MSafeAccount = class _MSafeAccount {
800
801
  async proposeCoinTransferIntention(intention) {
801
802
  const sn = await this.nextSequenceNumber();
802
803
  return this.proposeIntention({
803
- application: import_iota_utils4.TransactionDefaultApplication,
804
- txType: import_iota_utils4.TransactionType.Assets,
805
- txSubType: import_iota_utils4.TransactionSubTypes.assets.coin.send,
804
+ application: import_sui3_utils4.TransactionDefaultApplication,
805
+ txType: import_sui3_utils4.TransactionType.Assets,
806
+ txSubType: import_sui3_utils4.TransactionSubTypes.assets.coin.send,
806
807
  sequenceNumber: sn,
807
808
  intention
808
809
  });
@@ -810,9 +811,9 @@ var MSafeAccount = class _MSafeAccount {
810
811
  async simulateObjectTransferIntention(intention) {
811
812
  const sn = await this.nextSequenceNumber();
812
813
  return this.simulateIntention({
813
- application: import_iota_utils4.TransactionDefaultApplication,
814
- txType: import_iota_utils4.TransactionType.Assets,
815
- txSubType: import_iota_utils4.TransactionSubTypes.assets.object.send,
814
+ application: import_sui3_utils4.TransactionDefaultApplication,
815
+ txType: import_sui3_utils4.TransactionType.Assets,
816
+ txSubType: import_sui3_utils4.TransactionSubTypes.assets.object.send,
816
817
  sequenceNumber: sn,
817
818
  intention
818
819
  });
@@ -820,9 +821,9 @@ var MSafeAccount = class _MSafeAccount {
820
821
  async proposeObjectTransferIntention(intention) {
821
822
  const sn = await this.nextSequenceNumber();
822
823
  return this.proposeIntention({
823
- application: import_iota_utils4.TransactionDefaultApplication,
824
- txType: import_iota_utils4.TransactionType.Assets,
825
- txSubType: import_iota_utils4.TransactionSubTypes.assets.object.send,
824
+ application: import_sui3_utils4.TransactionDefaultApplication,
825
+ txType: import_sui3_utils4.TransactionType.Assets,
826
+ txSubType: import_sui3_utils4.TransactionSubTypes.assets.object.send,
826
827
  sequenceNumber: sn,
827
828
  intention
828
829
  });
@@ -830,9 +831,9 @@ var MSafeAccount = class _MSafeAccount {
830
831
  async simulatePlainPayloadIntention(intention) {
831
832
  const sn = await this.nextSequenceNumber();
832
833
  return this.simulateIntention({
833
- application: import_iota_utils4.TransactionDefaultApplication,
834
- txType: import_iota_utils4.TransactionType.Other,
835
- txSubType: import_iota_utils4.TransactionSubTypes.others.plain,
834
+ application: import_sui3_utils4.TransactionDefaultApplication,
835
+ txType: import_sui3_utils4.TransactionType.Other,
836
+ txSubType: import_sui3_utils4.TransactionSubTypes.others.plain,
836
837
  sequenceNumber: sn,
837
838
  intention
838
839
  });
@@ -840,13 +841,13 @@ var MSafeAccount = class _MSafeAccount {
840
841
  async proposePlainPayloadIntention(intention) {
841
842
  const sn = await this.nextSequenceNumber();
842
843
  const tb = import_transactions2.TransactionBlock.from(intention.payload);
843
- if (!tb.blockData.sender || !(0, import_iota_utils4.isSameAddress)(tb.blockData.sender, this.address)) {
844
+ if (!tb.blockData.sender || !(0, import_sui3_utils4.isSameAddress)(tb.blockData.sender, this.address)) {
844
845
  throw new Error("Transaction sender is not same as the multisig address");
845
846
  }
846
847
  return this.proposeIntention({
847
- application: import_iota_utils4.TransactionDefaultApplication,
848
- txType: import_iota_utils4.TransactionType.Other,
849
- txSubType: import_iota_utils4.TransactionSubTypes.others.plain,
848
+ application: import_sui3_utils4.TransactionDefaultApplication,
849
+ txType: import_sui3_utils4.TransactionType.Other,
850
+ txSubType: import_sui3_utils4.TransactionSubTypes.others.plain,
850
851
  sequenceNumber: sn,
851
852
  intention
852
853
  });
@@ -865,7 +866,7 @@ var MSafeAccount = class _MSafeAccount {
865
866
  if (!pendingTx || pendingTx.rejectDigest !== "") {
866
867
  throw new Error("Already rejected");
867
868
  }
868
- const txb = (0, import_iota_utils4.buildRejectTxb)(this.address);
869
+ const txb = (0, import_sui3_utils4.buildRejectTxb)(this.address);
869
870
  txb.setSender(this.address);
870
871
  return this.simulator.simulate({ txb, sender: this.address });
871
872
  }
@@ -874,9 +875,9 @@ var MSafeAccount = class _MSafeAccount {
874
875
  if (!pendingTx || pendingTx.rejectDigest !== "") {
875
876
  throw new Error("Already rejected");
876
877
  }
877
- const rejectTxb = (0, import_iota_utils4.buildRejectTxb)(this.address);
878
- const digest = await rejectTxb.getDigest({ client: this.client });
879
- const payload = await rejectTxb.build({ client: this.client });
878
+ const rejectTxb = (0, import_sui3_utils4.buildRejectTxb)(this.address);
879
+ const digest = await rejectTxb.getDigest({ client: this.suiClient });
880
+ const payload = await rejectTxb.build({ client: this.suiClient });
880
881
  const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
881
882
  return this.backend.rejectCurrentTx({
882
883
  msafeAddress: this.address,
@@ -887,7 +888,7 @@ var MSafeAccount = class _MSafeAccount {
887
888
  }
888
889
  async simulateBuildTransaction() {
889
890
  const intention = await this.backend.getNextIntention({ msafeAddress: this.address });
890
- const appHelper = import_iota_app_store.appHelpers.getAppHelper(intention.application);
891
+ const appHelper = import_sui_app_store.appHelpers.getAppHelper(intention.application);
891
892
  if (!appHelper) {
892
893
  throw new Error(`Can't find app helper for application ${intention.application}`);
893
894
  }
@@ -896,11 +897,11 @@ var MSafeAccount = class _MSafeAccount {
896
897
  intentionData: intention.intention,
897
898
  txType: intention.txType,
898
899
  txSubType: intention.txSubType,
899
- client: this.globals.client,
900
+ clientUrl: this.globals.config.suiClient.url,
900
901
  account: {
901
902
  address: this.address,
902
903
  publicKey: (0, import_utils3.fromHEX)(this.address),
903
- chains: [],
904
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
904
905
  features: []
905
906
  }
906
907
  });
@@ -934,7 +935,7 @@ var MSafeAccount = class _MSafeAccount {
934
935
  }
935
936
  }
936
937
  const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
937
- return this.client.executeTransactionBlock({
938
+ return this.suiClient.executeTransactionBlock({
938
939
  transactionBlock: HexToUint8Array(payload),
939
940
  signature: multiSignature,
940
941
  options: { showEffects: true, showEvents: true }
@@ -951,7 +952,7 @@ var MSafeAccount = class _MSafeAccount {
951
952
  calculateWeight(addressList) {
952
953
  let gotWeight = 0;
953
954
  for (let i = 0; i < addressList.length; i++) {
954
- const found = this.info.owners.find((owner) => (0, import_iota_utils4.isSameAddress)(owner.address, addressList[i]));
955
+ const found = this.info.owners.find((owner) => (0, import_sui3_utils4.isSameAddress)(owner.address, addressList[i]));
955
956
  if (found) {
956
957
  gotWeight += found.weight;
957
958
  }
@@ -970,14 +971,14 @@ var MSafeAccount = class _MSafeAccount {
970
971
  async userAddress() {
971
972
  return this.globals.wallet.address();
972
973
  }
973
- get client() {
974
- return this.globals.client;
974
+ get suiClient() {
975
+ return this.globals.suiClient;
975
976
  }
976
977
  };
977
978
 
978
979
  // src/core/PublicKeyHelper.ts
979
- var import_iota_utils5 = require("@msafe/iota-utils");
980
- var import_utils5 = require("@iota/iota-sdk/utils");
980
+ var import_sui3_utils5 = require("@msafe/sui3-utils");
981
+ var import_utils5 = require("@mysten/sui.js/utils");
981
982
  var PublicKeyHelper = class {
982
983
  constructor(globals) {
983
984
  this.globals = globals;
@@ -1023,10 +1024,10 @@ var PublicKeyHelper = class {
1023
1024
  return results;
1024
1025
  }
1025
1026
  addPublicKey(address, publicKey) {
1026
- if (!(0, import_iota_utils5.isSameAddress)(address, publicKey.toIotaAddress())) {
1027
+ if (!(0, import_sui3_utils5.isSameAddress)(address, publicKey.toSuiAddress())) {
1027
1028
  throw new Error("Invalid public key");
1028
1029
  }
1029
- this.knownPublicKeys.set((0, import_utils5.normalizeIotaAddress)(address), publicKey);
1030
+ this.knownPublicKeys.set((0, import_utils5.normalizeSuiAddress)(address), publicKey);
1030
1031
  }
1031
1032
  async _getPublicKey(address) {
1032
1033
  const pkBackend = await this.getPublicKeyFromBackend(address);
@@ -1048,7 +1049,7 @@ var PublicKeyHelper = class {
1048
1049
  }
1049
1050
  }
1050
1051
  async getPublicKeyFromChain(address) {
1051
- return getPublicKeyFromChain(this.globals.client, address);
1052
+ return getPublicKeyFromChain(this.globals.suiClient, address);
1052
1053
  }
1053
1054
  };
1054
1055
 
@@ -1063,10 +1064,10 @@ var ReportSDK = class {
1063
1064
  };
1064
1065
 
1065
1066
  // src/globals/MSafeGlobals.ts
1066
- var import_client = require("@iota/iota-sdk/client");
1067
+ var import_client = require("@mysten/sui.js/client");
1067
1068
 
1068
1069
  // src/backend/BackendImpl.ts
1069
- var import_iota_utils6 = require("@msafe/iota-utils");
1070
+ var import_sui3_utils6 = require("@msafe/sui3-utils");
1070
1071
  var import_axios = __toESM(require("axios"), 1);
1071
1072
  var BackendImpl = class _BackendImpl {
1072
1073
  constructor(apiURL, mockAddress) {
@@ -1102,7 +1103,7 @@ var BackendImpl = class _BackendImpl {
1102
1103
  headers: this.headers()
1103
1104
  });
1104
1105
  return res.data?.map(
1105
- (publicKeyWithSchema) => publicKeyWithSchema ? import_iota_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0
1106
+ (publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0
1106
1107
  );
1107
1108
  }
1108
1109
  async getMSafeAccountInfo(msafeAddress) {
@@ -1123,7 +1124,7 @@ var BackendImpl = class _BackendImpl {
1123
1124
  }
1124
1125
  async getOwnedMSafeByStatus(input) {
1125
1126
  const q = {
1126
- status: input.status ?? import_iota_utils6.UserMSafeStatus.active,
1127
+ status: input.status ?? import_sui3_utils6.UserMSafeStatus.active,
1127
1128
  ...input.pagination ? {
1128
1129
  page: input.pagination.page.toString(),
1129
1130
  limit: input.pagination.limit.toString()
@@ -1263,7 +1264,7 @@ var BackendImpl = class _BackendImpl {
1263
1264
  owners: resp.owners.map((owner) => ({
1264
1265
  address: owner.address,
1265
1266
  weight: owner.weight,
1266
- publicKey: import_iota_utils6.PublicKeySerde.de({
1267
+ publicKey: import_sui3_utils6.PublicKeySerde.de({
1267
1268
  publicKeyEncoded: owner.publicKeyEncoded,
1268
1269
  schema: owner.schema
1269
1270
  }),
@@ -1373,7 +1374,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1373
1374
  [
1374
1375
  "unit" /* unit */,
1375
1376
  {
1376
- client: {
1377
+ suiClient: {
1377
1378
  url: TESTNET_RPC_URL
1378
1379
  },
1379
1380
  backend: {
@@ -1386,7 +1387,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1386
1387
  [
1387
1388
  "local" /* local */,
1388
1389
  {
1389
- client: {
1390
+ suiClient: {
1390
1391
  url: TESTNET_RPC_URL
1391
1392
  },
1392
1393
  backend: {
@@ -1399,7 +1400,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1399
1400
  [
1400
1401
  "dev" /* dev */,
1401
1402
  {
1402
- client: {
1403
+ suiClient: {
1403
1404
  url: TESTNET_RPC_URL
1404
1405
  },
1405
1406
  backend: {
@@ -1412,7 +1413,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1412
1413
  [
1413
1414
  "prev" /* prev */,
1414
1415
  {
1415
- client: {
1416
+ suiClient: {
1416
1417
  url: MAINNET_RPC_URL
1417
1418
  },
1418
1419
  backend: {
@@ -1425,7 +1426,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1425
1426
  [
1426
1427
  "prod" /* prod */,
1427
1428
  {
1428
- client: {
1429
+ suiClient: {
1429
1430
  url: MAINNET_RPC_URL
1430
1431
  },
1431
1432
  backend: {
@@ -1441,8 +1442,8 @@ function getMSafeConfig(env, options) {
1441
1442
  if (!config) {
1442
1443
  throw new Error("Unknown environment");
1443
1444
  }
1444
- if (options?.client?.url) {
1445
- config.client.url = options.client.url;
1445
+ if (options?.suiClient?.url) {
1446
+ config.suiClient.url = options.suiClient.url;
1446
1447
  }
1447
1448
  if (options?.backend?.url) {
1448
1449
  config.backend.url = options.backend.url;
@@ -1453,21 +1454,21 @@ function getMSafeConfig(env, options) {
1453
1454
  // src/globals/MSafeGlobals.ts
1454
1455
  var MSafeGlobals = class _MSafeGlobals {
1455
1456
  backend;
1456
- client;
1457
+ suiClient;
1457
1458
  config;
1458
1459
  _wallet;
1459
1460
  constructor(input) {
1460
1461
  this.backend = input.backend;
1461
- this.client = input.client;
1462
+ this.suiClient = input.suiClient;
1462
1463
  this.config = input.config;
1463
1464
  }
1464
1465
  static async New(env, options) {
1465
1466
  const config = getMSafeConfig(env, options);
1466
- const client = new import_client.IotaClient(config.client);
1467
+ const suiClient = new import_client.SuiClient(config.suiClient);
1467
1468
  const backend = new BackendImpl(config.backend.url, options?.mockAddress);
1468
1469
  return new _MSafeGlobals({
1469
1470
  backend,
1470
- client,
1471
+ suiClient,
1471
1472
  config
1472
1473
  });
1473
1474
  }
@@ -1511,7 +1512,7 @@ var MSafeClient = class _MSafeClient {
1511
1512
  return jwt;
1512
1513
  }
1513
1514
  async authSign(wallet) {
1514
- const messageStr = import_iota_utils7.SigningMessageHelper.loginMessageWithTimestamp((/* @__PURE__ */ new Date()).toUTCString());
1515
+ const messageStr = import_sui3_utils7.SigningMessageHelper.loginMessageWithTimestamp((/* @__PURE__ */ new Date()).toUTCString());
1515
1516
  const sig = await wallet.signPersonalMessage({
1516
1517
  messageStr
1517
1518
  });
@@ -1526,7 +1527,7 @@ var MSafeClient = class _MSafeClient {
1526
1527
  return this.globals.backend.getUserInfo();
1527
1528
  }
1528
1529
  async ownedMSafe(pagination) {
1529
- return this.globals.backend.getOwnedMSafeByStatus({ status: import_iota_utils7.UserMSafeStatus.active, pagination });
1530
+ return this.globals.backend.getOwnedMSafeByStatus({ status: import_sui3_utils7.UserMSafeStatus.active, pagination });
1530
1531
  }
1531
1532
  async createAccount(info) {
1532
1533
  return this.creationHelper.submitMSafeCreation(info);