@msafe/sui3-sdk 1.0.13 → 1.0.15

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/dist/index.cjs CHANGED
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
8
  var __export = (target, all) => {
10
9
  for (var name in all)
11
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -73,11 +72,6 @@ module.exports = __toCommonJS(src_exports);
73
72
  // src/core/CreateHelper.ts
74
73
  var import_sui3_utils = require("@msafe/sui3-utils");
75
74
  var CreateHelper = class {
76
- static {
77
- __name(this, "CreateHelper");
78
- }
79
- globals;
80
- pkHelper;
81
75
  constructor(globals, pkHelper) {
82
76
  this.globals = globals;
83
77
  this.pkHelper = pkHelper;
@@ -95,13 +89,13 @@ var CreateHelper = class {
95
89
  return this.calculateMSafeAddress(createInfo);
96
90
  }
97
91
  /**
98
- * Add user manually added public key for an address. If user input the public key with
99
- * extra signature scheme flag, the scheme value will be automatically fixed.
100
- *
101
- * @param address
102
- * @param pkEncoded
103
- * @throws error if the public key does not match
104
- */
92
+ * Add user manually added public key for an address. If user input the public key with
93
+ * extra signature scheme flag, the scheme value will be automatically fixed.
94
+ *
95
+ * @param address
96
+ * @param pkEncoded
97
+ * @throws error if the public key does not match
98
+ */
105
99
  addPublicKey(address, pkEncoded) {
106
100
  const pk = import_sui3_utils.PublicKeySerde.de(pkEncoded);
107
101
  if (!(0, import_sui3_utils.isSameAddress)(address, pk.toSuiAddress())) {
@@ -112,9 +106,7 @@ var CreateHelper = class {
112
106
  async submitMSafeCreation(creationInfo) {
113
107
  const msafeAddress = await this.validateCreateInfo(creationInfo);
114
108
  const signingMessage = import_sui3_utils.SigningMessageHelper.createMSafeMessage(msafeAddress);
115
- const signature = await this.globals.wallet.signPersonalMessage({
116
- messageStr: signingMessage
117
- });
109
+ const signature = await this.globals.wallet.signPersonalMessage({ messageStr: signingMessage });
118
110
  await this.submitToBackend(creationInfo, signature.signature);
119
111
  return msafeAddress;
120
112
  }
@@ -145,7 +137,9 @@ var CreateHelper = class {
145
137
  })),
146
138
  threshold: createInfo.threshold,
147
139
  name: createInfo.name,
140
+ // name validation is deferred to backend
148
141
  description: createInfo.description,
142
+ // description validation is deferred to backend
149
143
  creationNonce: createInfo.creationNonce,
150
144
  signature
151
145
  });
@@ -158,10 +152,6 @@ var import_sui3_utils7 = require("@msafe/sui3-utils");
158
152
  // src/core/AddressBookSDK.ts
159
153
  var import_sui3_utils2 = require("@msafe/sui3-utils");
160
154
  var AddressBookSDK = class {
161
- static {
162
- __name(this, "AddressBookSDK");
163
- }
164
- globals;
165
155
  constructor(globals) {
166
156
  this.globals = globals;
167
157
  }
@@ -170,45 +160,28 @@ var AddressBookSDK = class {
170
160
  }
171
161
  async update(updates) {
172
162
  const messageStr = import_sui3_utils2.SigningMessageHelper.updateAddressBookMessage(updates);
173
- const sig = await this.globals.wallet.signPersonalMessage({
174
- messageStr
175
- });
176
- return this.globals.backend.updateAddressBook({
177
- updates,
178
- signature: sig.signature
179
- });
163
+ const sig = await this.globals.wallet.signPersonalMessage({ messageStr });
164
+ return this.globals.backend.updateAddressBook({ updates, signature: sig.signature });
180
165
  }
181
166
  async getMode() {
182
167
  const res = await this.globals.backend.getAddressBookMode();
183
168
  return res.mode;
184
169
  }
185
170
  async setMode(mode) {
186
- return this.globals.backend.setAddressBookMode({
187
- mode
188
- });
171
+ return this.globals.backend.setAddressBookMode({ mode });
189
172
  }
190
173
  };
191
174
 
192
175
  // src/core/InvitationSDK.ts
193
176
  var InvitationSDK = class {
194
- static {
195
- __name(this, "InvitationSDK");
196
- }
197
- globals;
198
177
  constructor(globals) {
199
178
  this.globals = globals;
200
179
  }
201
180
  async getMSafeByStatus(status, pagination) {
202
- return this.globals.backend.getOwnedMSafeByStatus({
203
- status,
204
- pagination
205
- });
181
+ return this.globals.backend.getOwnedMSafeByStatus({ status, pagination });
206
182
  }
207
183
  async updateMSafeStatus(msafeAddress, status) {
208
- return this.globals.backend.updateMSafeStatus({
209
- msafeAddress,
210
- status
211
- });
184
+ return this.globals.backend.updateMSafeStatus({ msafeAddress, status });
212
185
  }
213
186
  };
214
187
 
@@ -225,25 +198,15 @@ var GAS_SAFE_OVERHEAD = 1000n;
225
198
  function formatExecutionError(error) {
226
199
  return error.message;
227
200
  }
228
- __name(formatExecutionError, "formatExecutionError");
229
201
  function gasObjectToReference(gas) {
230
202
  if (!gas?.objectId) {
231
203
  throw new Error("Gas object missing from simulation effects");
232
204
  }
233
205
  const version = gas.outputVersion ?? gas.inputVersion ?? "0";
234
206
  const digest = gas.outputDigest ?? gas.inputDigest ?? "";
235
- return {
236
- objectId: gas.objectId,
237
- version,
238
- digest
239
- };
207
+ return { objectId: gas.objectId, version, digest };
240
208
  }
241
- __name(gasObjectToReference, "gasObjectToReference");
242
209
  var Simulator = class {
243
- static {
244
- __name(this, "Simulator");
245
- }
246
- globals;
247
210
  constructor(globals) {
248
211
  this.globals = globals;
249
212
  }
@@ -252,11 +215,10 @@ var Simulator = class {
252
215
  const { suiClient } = this.globals;
253
216
  const gasPrice = await this.getGasPrice();
254
217
  tx.setGasPrice(gasPrice);
218
+ tx.setSender(input.sender);
255
219
  let built;
256
220
  try {
257
- built = await tx.build({
258
- client: suiClient
259
- });
221
+ built = await tx.build({ client: suiClient });
260
222
  } catch (e) {
261
223
  const message = e instanceof Error ? e.message : String(e);
262
224
  return {
@@ -324,7 +286,7 @@ var Simulator = class {
324
286
  return gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead;
325
287
  }
326
288
  copyTransaction(tx) {
327
- return import_transactions.Transaction.from(tx.serialize());
289
+ return import_transactions.Transaction.from(tx);
328
290
  }
329
291
  };
330
292
 
@@ -333,15 +295,12 @@ var import_buffer = require("buffer");
333
295
  function stringToBuffer(s) {
334
296
  return import_buffer.Buffer.from(s, "utf-8");
335
297
  }
336
- __name(stringToBuffer, "stringToBuffer");
337
298
  function Uint8ArrayToHex(b) {
338
299
  return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
339
300
  }
340
- __name(Uint8ArrayToHex, "Uint8ArrayToHex");
341
301
  function HexToUint8Array(hex) {
342
302
  return Uint8Array.from(import_buffer.Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
343
303
  }
344
- __name(HexToUint8Array, "HexToUint8Array");
345
304
 
346
305
  // src/utils/crypto.ts
347
306
  var import_verify = require("@mysten/sui/verify");
@@ -352,9 +311,6 @@ var import_utils2 = require("@mysten/sui/utils");
352
311
  // src/utils/coin.ts
353
312
  var import_utils = require("@mysten/sui/utils");
354
313
  var CoinHelper = class {
355
- static {
356
- __name(this, "CoinHelper");
357
- }
358
314
  _client;
359
315
  _coinMetaReg;
360
316
  constructor(client) {
@@ -373,17 +329,12 @@ var CoinHelper = class {
373
329
  return meta;
374
330
  }
375
331
  async queryCoinMeta(coinType) {
376
- const res = await this._client.getCoinMetadata({
377
- coinType
378
- });
332
+ const res = await this._client.getCoinMetadata({ coinType });
379
333
  return res.coinMetadata ?? void 0;
380
334
  }
381
335
  };
382
336
  var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
383
337
  var Coin = class _Coin {
384
- static {
385
- __name(this, "Coin");
386
- }
387
338
  static isCoin(type) {
388
339
  if (!type) {
389
340
  return false;
@@ -418,9 +369,6 @@ var Coin = class _Coin {
418
369
 
419
370
  // src/utils/format.ts
420
371
  var Formatter = class {
421
- static {
422
- __name(this, "Formatter");
423
- }
424
372
  static normalizeSuiAddress(addr) {
425
373
  return (0, import_utils2.normalizeSuiAddress)(addr);
426
374
  }
@@ -443,13 +391,9 @@ function addPrefix(s, prefix) {
443
391
  }
444
392
  return prefix + s;
445
393
  }
446
- __name(addPrefix, "addPrefix");
447
394
 
448
395
  // src/utils/crypto.ts
449
396
  var SignatureVerifier = class _SignatureVerifier {
450
- static {
451
- __name(this, "SignatureVerifier");
452
- }
453
397
  static async getPublicKeyFromSignature(input) {
454
398
  if (input.messageType === "TransactionBlock") {
455
399
  return (0, import_verify.verifyTransactionSignature)(input.message, input.signature);
@@ -500,35 +444,24 @@ var GRAPHQL_URL_BY_NETWORK = {
500
444
  };
501
445
  function graphqlClientForGrpc(suiClient) {
502
446
  const url = GRAPHQL_URL_BY_NETWORK[suiClient.network] ?? GRAPHQL_URL_BY_NETWORK.testnet;
503
- return new import_graphql.SuiGraphQLClient({
504
- url,
505
- network: suiClient.network
506
- });
447
+ return new import_graphql.SuiGraphQLClient({ url, network: suiClient.network });
507
448
  }
508
- __name(graphqlClientForGrpc, "graphqlClientForGrpc");
509
449
  function collectSignatureStrings(value) {
510
450
  if (typeof value === "string") {
511
- return [
512
- value
513
- ];
451
+ return [value];
514
452
  }
515
453
  if (!value || typeof value !== "object") {
516
454
  return [];
517
455
  }
518
456
  if ("base64" in value && typeof value.base64 === "string") {
519
- return [
520
- value.base64
521
- ];
457
+ return [value.base64];
522
458
  }
523
459
  if ("scheme" in value && "base64" in value) {
524
460
  const b64 = value.base64;
525
- return typeof b64 === "string" ? [
526
- b64
527
- ] : [];
461
+ return typeof b64 === "string" ? [b64] : [];
528
462
  }
529
463
  return [];
530
464
  }
531
- __name(collectSignatureStrings, "collectSignatureStrings");
532
465
  var TX_SIG_QUERY = `
533
466
  query PublicKeyTxSigs($sender: SuiAddress!, $first: Int!) {
534
467
  transactions(first: $first, filter: { sentAddress: $sender }) {
@@ -544,10 +477,7 @@ async function getPublicKeyFromChain(suiClient, address) {
544
477
  try {
545
478
  const res = await graphql.query({
546
479
  query: TX_SIG_QUERY,
547
- variables: {
548
- sender: address,
549
- first: 2
550
- }
480
+ variables: { sender: address, first: 2 }
551
481
  });
552
482
  if (res.errors?.length) {
553
483
  return void 0;
@@ -576,7 +506,6 @@ async function getPublicKeyFromChain(suiClient, address) {
576
506
  }
577
507
  return void 0;
578
508
  }
579
- __name(getPublicKeyFromChain, "getPublicKeyFromChain");
580
509
  function getAddressFromSignatures(serializedSig, targetAddress) {
581
510
  const decoded = (0, import_cryptography.parseSerializedSignature)(serializedSig);
582
511
  switch (decoded.signatureScheme) {
@@ -591,10 +520,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
591
520
  case "ED25519":
592
521
  case "Secp256k1":
593
522
  case "Secp256r1": {
594
- const pk = import_sui3_utils3.PublicKeySerde.de({
595
- publicKeyEncoded: decoded.publicKey,
596
- schema: decoded.signatureScheme
597
- });
523
+ const pk = import_sui3_utils3.PublicKeySerde.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
598
524
  if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
599
525
  return pk;
600
526
  }
@@ -604,7 +530,6 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
604
530
  throw new Error("Unknown schema");
605
531
  }
606
532
  }
607
- __name(getAddressFromSignatures, "getAddressFromSignatures");
608
533
  async function getAllCoins(input) {
609
534
  let hasNext = true;
610
535
  let cursor;
@@ -621,7 +546,6 @@ async function getAllCoins(input) {
621
546
  }
622
547
  return res;
623
548
  }
624
- __name(getAllCoins, "getAllCoins");
625
549
 
626
550
  // src/utils/transaction.ts
627
551
  var import_transactions2 = require("@mysten/sui/transactions");
@@ -632,7 +556,6 @@ function toSuiTransaction(txb) {
632
556
  const legacy = txb;
633
557
  return import_transactions2.Transaction.from(legacy.serialize());
634
558
  }
635
- __name(toSuiTransaction, "toSuiTransaction");
636
559
 
637
560
  // src/utils/iter/iterator.ts
638
561
  var REQUEST_PAGE_SIZE = 25;
@@ -647,19 +570,14 @@ async function getAllFromIterator(it) {
647
570
  }
648
571
  return res;
649
572
  }
650
- __name(getAllFromIterator, "getAllFromIterator");
651
573
  var PagedIterator = class {
652
- static {
653
- __name(this, "PagedIterator");
654
- }
655
- requester;
656
- curPage;
657
- init;
658
574
  constructor(requester) {
659
575
  this.requester = requester;
660
576
  this.curPage = void 0;
661
577
  this.init = true;
662
578
  }
579
+ curPage;
580
+ init;
663
581
  async hasNext() {
664
582
  if (this.init) {
665
583
  if (!this.curPage) {
@@ -685,19 +603,15 @@ var PagedIterator = class {
685
603
  }
686
604
  };
687
605
  var EntryIterator = class {
688
- static {
689
- __name(this, "EntryIterator");
690
- }
691
- requester;
692
- cursor;
693
- pager;
694
- curData;
695
606
  constructor(requester) {
696
607
  this.requester = requester;
697
608
  this.pager = new PagedIterator(requester);
698
609
  this.curData = [];
699
610
  this.cursor = 0;
700
611
  }
612
+ cursor;
613
+ pager;
614
+ curData;
701
615
  async hasNext() {
702
616
  if (this.cursor < this.curData.length - 1) {
703
617
  return true;
@@ -719,28 +633,15 @@ var EntryIterator = class {
719
633
  };
720
634
 
721
635
  // src/utils/iter/object.ts
722
- var defaultObjectInclude = {
723
- json: true
724
- };
636
+ var defaultObjectInclude = { json: true };
725
637
  function mergeInclude(options) {
726
- return {
727
- ...defaultObjectInclude,
728
- ...options?.objectInclude
729
- };
638
+ return { ...defaultObjectInclude, ...options?.objectInclude };
730
639
  }
731
- __name(mergeInclude, "mergeInclude");
732
640
  async function getAllOwnedObjects(provider, owner, options) {
733
641
  const iter = new OwnedObjectIterator(provider, owner, options);
734
642
  return await getAllFromIterator(iter);
735
643
  }
736
- __name(getAllOwnedObjects, "getAllOwnedObjects");
737
644
  var OwnedObjectIterator = class extends EntryIterator {
738
- static {
739
- __name(this, "OwnedObjectIterator");
740
- }
741
- provider;
742
- owner;
743
- options;
744
645
  constructor(provider, owner, options) {
745
646
  super(new OwnedObjectRequester(provider, owner, options));
746
647
  this.provider = provider;
@@ -749,16 +650,6 @@ var OwnedObjectIterator = class extends EntryIterator {
749
650
  }
750
651
  };
751
652
  var OwnedObjectRequester = class {
752
- static {
753
- __name(this, "OwnedObjectRequester");
754
- }
755
- provider;
756
- owner;
757
- options;
758
- nextCursor;
759
- filter;
760
- pageSize;
761
- objectInclude;
762
653
  constructor(provider, owner, options) {
763
654
  this.provider = provider;
764
655
  this.owner = owner;
@@ -768,6 +659,10 @@ var OwnedObjectRequester = class {
768
659
  this.pageSize = options?.pageSize || REQUEST_PAGE_SIZE;
769
660
  this.objectInclude = mergeInclude(options);
770
661
  }
662
+ nextCursor;
663
+ filter;
664
+ pageSize;
665
+ objectInclude;
771
666
  async doNextRequest() {
772
667
  const res = await this.provider.listOwnedObjects({
773
668
  owner: this.owner,
@@ -792,14 +687,6 @@ var OwnedObjectRequester = class {
792
687
 
793
688
  // src/core/MSafeAccount.ts
794
689
  var MSafeAccount = class _MSafeAccount {
795
- static {
796
- __name(this, "MSafeAccount");
797
- }
798
- globals;
799
- info;
800
- multiSig;
801
- simulator;
802
- coinHelper;
803
690
  constructor(globals, info) {
804
691
  this.globals = globals;
805
692
  this.info = info;
@@ -811,6 +698,9 @@ var MSafeAccount = class _MSafeAccount {
811
698
  this.coinHelper = new CoinHelper(this.suiClient);
812
699
  this.simulator = new Simulator(globals);
813
700
  }
701
+ multiSig;
702
+ simulator;
703
+ coinHelper;
814
704
  static async New(globals, address) {
815
705
  const info = await globals.backend.getMSafeAccountInfo(address);
816
706
  const ms = new _MSafeAccount(globals, info);
@@ -823,23 +713,21 @@ var MSafeAccount = class _MSafeAccount {
823
713
  let cursor = null;
824
714
  let hasNext = true;
825
715
  while (hasNext) {
826
- const page = await this.suiClient.listBalances({
827
- owner: this.address,
828
- cursor,
829
- limit: 50
830
- });
716
+ const page = await this.suiClient.listBalances({ owner: this.address, cursor, limit: 50 });
831
717
  balances.push(...page.balances);
832
718
  hasNext = page.hasNextPage;
833
719
  cursor = page.cursor;
834
720
  }
835
- return Promise.all(balances.map(async (balance) => {
836
- const meta = await this.coinHelper.getCoinMeta(balance.coinType);
837
- return {
838
- type: (0, import_utils3.normalizeStructTag)(balance.coinType),
839
- balance: BigInt(balance.addressBalance),
840
- metadata: meta
841
- };
842
- }));
721
+ return Promise.all(
722
+ balances.map(async (balance) => {
723
+ const meta = await this.coinHelper.getCoinMeta(balance.coinType);
724
+ return {
725
+ type: (0, import_utils3.normalizeStructTag)(balance.coinType),
726
+ balance: BigInt(balance.addressBalance),
727
+ metadata: meta
728
+ };
729
+ })
730
+ );
843
731
  }
844
732
  async ownedObjects(options) {
845
733
  const filterCoinObjectOptions = {
@@ -849,9 +737,7 @@ var MSafeAccount = class _MSafeAccount {
849
737
  return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
850
738
  }
851
739
  async pendingTransaction() {
852
- const res = await this.backend.getPendingTransactions({
853
- msafeAddress: this.address
854
- });
740
+ const res = await this.backend.getPendingTransactions({ msafeAddress: this.address });
855
741
  if (!res?.pending) {
856
742
  return void 0;
857
743
  }
@@ -883,10 +769,7 @@ var MSafeAccount = class _MSafeAccount {
883
769
  });
884
770
  }
885
771
  async futureIntentions(pagination) {
886
- return this.backend.getFutureIntentions({
887
- msafeAddress: this.address,
888
- ...pagination
889
- });
772
+ return this.backend.getFutureIntentions({ msafeAddress: this.address, ...pagination });
890
773
  }
891
774
  async currentSequenceNumber() {
892
775
  return this.backend.getCurrentSequenceNumber(this.address);
@@ -903,28 +786,24 @@ var MSafeAccount = class _MSafeAccount {
903
786
  if (!appHelper) {
904
787
  throw new Error(`Can't find app helper for application ${request.application}`);
905
788
  }
906
- txb = toSuiTransaction(await appHelper.build({
907
- network: this.globals.config.network,
908
- intentionData: request.intention,
909
- txType: request.txType,
910
- txSubType: request.txSubType,
911
- clientUrl: this.globals.config.suiClient.url,
912
- account: {
913
- address: this.address,
914
- publicKey: (0, import_utils3.fromHex)(this.address),
915
- chains: [
916
- import_wallet_standard.SUI_MAINNET_CHAIN,
917
- import_wallet_standard.SUI_TESTNET_CHAIN
918
- ],
919
- features: []
920
- }
921
- }));
789
+ txb = toSuiTransaction(
790
+ await appHelper.build({
791
+ network: this.globals.config.network,
792
+ intentionData: request.intention,
793
+ txType: request.txType,
794
+ txSubType: request.txSubType,
795
+ clientUrl: this.globals.config.suiClient.url,
796
+ account: {
797
+ address: this.address,
798
+ publicKey: (0, import_utils3.fromHex)(this.address),
799
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
800
+ features: []
801
+ }
802
+ })
803
+ );
922
804
  }
923
805
  txb.setSender(this.address);
924
- return this.simulator.simulate({
925
- txb,
926
- sender: this.address
927
- });
806
+ return this.simulator.simulate({ txb, sender: this.address });
928
807
  }
929
808
  async proposeIntention(input) {
930
809
  const message = import_sui3_utils4.SigningMessageHelper.proposeIntentionMessage({
@@ -950,35 +829,28 @@ var MSafeAccount = class _MSafeAccount {
950
829
  if (!appHelper) {
951
830
  throw new Error(`Can't find app helper for application ${input.application}`);
952
831
  }
953
- txb = toSuiTransaction(await appHelper.build({
954
- network: this.globals.config.network,
955
- intentionData: input.intention,
956
- txType: input.txType,
957
- txSubType: input.txSubType,
958
- clientUrl: this.globals.config.suiClient.url,
959
- account: {
960
- address: this.address,
961
- publicKey: (0, import_utils3.fromHex)(this.address),
962
- chains: [
963
- import_wallet_standard.SUI_MAINNET_CHAIN,
964
- import_wallet_standard.SUI_TESTNET_CHAIN
965
- ],
966
- features: []
967
- }
968
- }));
832
+ txb = toSuiTransaction(
833
+ await appHelper.build({
834
+ network: this.globals.config.network,
835
+ intentionData: input.intention,
836
+ txType: input.txType,
837
+ txSubType: input.txSubType,
838
+ clientUrl: this.globals.config.suiClient.url,
839
+ account: {
840
+ address: this.address,
841
+ publicKey: (0, import_utils3.fromHex)(this.address),
842
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
843
+ features: []
844
+ }
845
+ })
846
+ );
969
847
  }
970
848
  txb.setGasPrice(input.gasPrice);
971
849
  txb.setGasBudget(input.gasBudget);
972
850
  txb.setSender(this.address);
973
- const payload = await txb.build({
974
- client: this.globals.suiClient
975
- });
976
- const digest = await txb.getDigest({
977
- client: this.globals.suiClient
978
- });
979
- const signature = await this.wallet.signTransactionBlock({
980
- transactionBlock: payload
981
- });
851
+ const payload = await txb.build({ client: this.globals.suiClient });
852
+ const digest = await txb.getDigest({ client: this.globals.suiClient });
853
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
982
854
  return this.backend.proposeIntentionAndBuildVote({
983
855
  ...input,
984
856
  payload: (0, import_utils3.toHex)(payload),
@@ -1054,9 +926,7 @@ var MSafeAccount = class _MSafeAccount {
1054
926
  }
1055
927
  async voteForTransaction(digest, payload) {
1056
928
  const payloadBytes = HexToUint8Array(payload);
1057
- const signature = await this.wallet.signTransactionBlock({
1058
- transactionBlock: payloadBytes
1059
- });
929
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payloadBytes });
1060
930
  return this.backend.voteForTransaction({
1061
931
  msafeAddress: this.address,
1062
932
  digest,
@@ -1070,10 +940,7 @@ var MSafeAccount = class _MSafeAccount {
1070
940
  }
1071
941
  const txb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
1072
942
  txb.setSender(this.address);
1073
- return this.simulator.simulate({
1074
- txb,
1075
- sender: this.address
1076
- });
943
+ return this.simulator.simulate({ txb, sender: this.address });
1077
944
  }
1078
945
  async rejectCurrentTx(input) {
1079
946
  const pendingTx = await this.pendingTransaction();
@@ -1081,15 +948,9 @@ var MSafeAccount = class _MSafeAccount {
1081
948
  throw new Error("Already rejected");
1082
949
  }
1083
950
  const rejectTxb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
1084
- const digest = await rejectTxb.getDigest({
1085
- client: this.suiClient
1086
- });
1087
- const payload = await rejectTxb.build({
1088
- client: this.suiClient
1089
- });
1090
- const signature = await this.wallet.signTransactionBlock({
1091
- transactionBlock: payload
1092
- });
951
+ const digest = await rejectTxb.getDigest({ client: this.suiClient });
952
+ const payload = await rejectTxb.build({ client: this.suiClient });
953
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
1093
954
  return this.backend.rejectCurrentTx({
1094
955
  msafeAddress: this.address,
1095
956
  digest,
@@ -1098,34 +959,28 @@ var MSafeAccount = class _MSafeAccount {
1098
959
  });
1099
960
  }
1100
961
  async simulateBuildTransaction() {
1101
- const intention = await this.backend.getNextIntention({
1102
- msafeAddress: this.address
1103
- });
962
+ const intention = await this.backend.getNextIntention({ msafeAddress: this.address });
1104
963
  const appHelper = import_sui_app_store.appHelpers.getAppHelper(intention.application);
1105
964
  if (!appHelper) {
1106
965
  throw new Error(`Can't find app helper for application ${intention.application}`);
1107
966
  }
1108
- const txb = toSuiTransaction(await appHelper.build({
1109
- network: this.globals.config.network,
1110
- intentionData: intention.intention,
1111
- txType: intention.txType,
1112
- txSubType: intention.txSubType,
1113
- clientUrl: this.globals.config.suiClient.url,
1114
- account: {
1115
- address: this.address,
1116
- publicKey: (0, import_utils3.fromHex)(this.address),
1117
- chains: [
1118
- import_wallet_standard.SUI_MAINNET_CHAIN,
1119
- import_wallet_standard.SUI_TESTNET_CHAIN
1120
- ],
1121
- features: []
1122
- }
1123
- }));
967
+ const txb = toSuiTransaction(
968
+ await appHelper.build({
969
+ network: this.globals.config.network,
970
+ intentionData: intention.intention,
971
+ txType: intention.txType,
972
+ txSubType: intention.txSubType,
973
+ clientUrl: this.globals.config.suiClient.url,
974
+ account: {
975
+ address: this.address,
976
+ publicKey: (0, import_utils3.fromHex)(this.address),
977
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
978
+ features: []
979
+ }
980
+ })
981
+ );
1124
982
  txb.setSender(this.address);
1125
- return this.simulator.simulate({
1126
- txb,
1127
- sender: this.address
1128
- });
983
+ return this.simulator.simulate({ txb, sender: this.address });
1129
984
  }
1130
985
  async buildNextIntentionAndAddToPending(gasOption) {
1131
986
  return this.backend.buildNextIntentionAndAddToPending({
@@ -1136,14 +991,10 @@ var MSafeAccount = class _MSafeAccount {
1136
991
  });
1137
992
  }
1138
993
  async skipNextFailedIntention() {
1139
- return this.backend.skipNextFailedIntention({
1140
- msafeAddress: this.address
1141
- });
994
+ return this.backend.skipNextFailedIntention({ msafeAddress: this.address });
1142
995
  }
1143
996
  async fetchTransaction() {
1144
- return this.backend.fetchTransaction({
1145
- msafeAddress: this.address
1146
- });
997
+ return this.backend.fetchTransaction({ msafeAddress: this.address });
1147
998
  }
1148
999
  async executePendingTx(pending, isRejectTx = false) {
1149
1000
  const votes = isRejectTx ? pending.rejectVotes : pending.votes;
@@ -1152,10 +1003,7 @@ var MSafeAccount = class _MSafeAccount {
1152
1003
  throw new Error("Not enough signature");
1153
1004
  }
1154
1005
  const sortedSigs = [];
1155
- const gotSigs = new Map(votes.map((vote) => [
1156
- vote.userAddress,
1157
- vote.signature
1158
- ]));
1006
+ const gotSigs = new Map(votes.map((vote) => [vote.userAddress, vote.signature]));
1159
1007
  for (let i = 0; i < this.info.owners.length; i++) {
1160
1008
  const owner = this.info.owners[i];
1161
1009
  const signature = gotSigs.get(owner.address);
@@ -1166,13 +1014,8 @@ var MSafeAccount = class _MSafeAccount {
1166
1014
  const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
1167
1015
  return this.suiClient.executeTransaction({
1168
1016
  transaction: HexToUint8Array(payload),
1169
- signatures: [
1170
- multiSignature
1171
- ],
1172
- include: {
1173
- effects: true,
1174
- events: true
1175
- }
1017
+ signatures: [multiSignature],
1018
+ include: { effects: true, events: true }
1176
1019
  });
1177
1020
  }
1178
1021
  async dashboard() {
@@ -1214,15 +1057,11 @@ var MSafeAccount = class _MSafeAccount {
1214
1057
  var import_sui3_utils5 = require("@msafe/sui3-utils");
1215
1058
  var import_utils5 = require("@mysten/sui/utils");
1216
1059
  var PublicKeyHelper = class {
1217
- static {
1218
- __name(this, "PublicKeyHelper");
1219
- }
1220
- globals;
1221
- knownPublicKeys;
1222
1060
  constructor(globals) {
1223
1061
  this.globals = globals;
1224
1062
  this.knownPublicKeys = /* @__PURE__ */ new Map();
1225
1063
  }
1064
+ knownPublicKeys;
1226
1065
  async getPublicKey(address) {
1227
1066
  const cached = this.knownPublicKeys.get(address);
1228
1067
  if (cached) {
@@ -1293,10 +1132,6 @@ var PublicKeyHelper = class {
1293
1132
 
1294
1133
  // src/core/ReportSDK.ts
1295
1134
  var ReportSDK = class {
1296
- static {
1297
- __name(this, "ReportSDK");
1298
- }
1299
- globals;
1300
1135
  constructor(globals) {
1301
1136
  this.globals = globals;
1302
1137
  }
@@ -1312,16 +1147,11 @@ var import_grpc = require("@mysten/sui/grpc");
1312
1147
  var import_sui3_utils6 = require("@msafe/sui3-utils");
1313
1148
  var import_axios = __toESM(require("axios"), 1);
1314
1149
  var BackendImpl = class _BackendImpl {
1315
- static {
1316
- __name(this, "BackendImpl");
1317
- }
1318
- apiURL;
1319
- mockAddress;
1320
- _token;
1321
1150
  constructor(apiURL, mockAddress) {
1322
1151
  this.apiURL = apiURL;
1323
1152
  this.mockAddress = mockAddress;
1324
1153
  }
1154
+ _token;
1325
1155
  getNotificationInfo() {
1326
1156
  return this.get(`/notification`, {
1327
1157
  headers: this.headers()
@@ -1344,9 +1174,7 @@ var BackendImpl = class _BackendImpl {
1344
1174
  }
1345
1175
  async verifyToken(jwt) {
1346
1176
  try {
1347
- const res = await this.get(`/auth`, {
1348
- headers: this.headers(jwt)
1349
- });
1177
+ const res = await this.get(`/auth`, { headers: this.headers(jwt) });
1350
1178
  return res.status === 200;
1351
1179
  } catch (_) {
1352
1180
  return false;
@@ -1356,9 +1184,7 @@ var BackendImpl = class _BackendImpl {
1356
1184
  this._token = token;
1357
1185
  }
1358
1186
  async getPublicKey(address) {
1359
- return (await this.getPublicKeyBatch([
1360
- address
1361
- ]))[0];
1187
+ return (await this.getPublicKeyBatch([address]))[0];
1362
1188
  }
1363
1189
  async getPublicKeyBatch(addresses) {
1364
1190
  const query = {
@@ -1368,7 +1194,9 @@ var BackendImpl = class _BackendImpl {
1368
1194
  params: query,
1369
1195
  headers: this.headers()
1370
1196
  });
1371
- return res.data?.map((publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0);
1197
+ return res.data?.map(
1198
+ (publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0
1199
+ );
1372
1200
  }
1373
1201
  async getMSafeAccountInfo(msafeAddress) {
1374
1202
  const q = {
@@ -1405,9 +1233,7 @@ var BackendImpl = class _BackendImpl {
1405
1233
  }
1406
1234
  async updateMSafeStatus(input) {
1407
1235
  const p = input;
1408
- await this.post(`/msafe/status`, p, {
1409
- headers: this.headers()
1410
- });
1236
+ await this.post(`/msafe/status`, p, { headers: this.headers() });
1411
1237
  }
1412
1238
  async getPendingTransactions(input) {
1413
1239
  const res = await this.get(`/transaction/pending`, {
@@ -1461,18 +1287,16 @@ var BackendImpl = class _BackendImpl {
1461
1287
  });
1462
1288
  }
1463
1289
  async proposeIntention(input) {
1464
- await this.post(`/transaction/intention`, input, {
1465
- headers: this.headers()
1466
- });
1290
+ await this.post(`/transaction/intention`, input, { headers: this.headers() });
1467
1291
  }
1468
1292
  async rejectCurrentTx(input) {
1469
- await this.post(`/transaction/pending/reject`, {
1470
- ...input,
1471
- gasPrice: input.gasPrice.toString(),
1472
- gasBudget: input.gasBudget.toString()
1473
- }, {
1474
- headers: this.headers()
1475
- });
1293
+ await this.post(
1294
+ `/transaction/pending/reject`,
1295
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1296
+ {
1297
+ headers: this.headers()
1298
+ }
1299
+ );
1476
1300
  }
1477
1301
  async voteForTransaction(input) {
1478
1302
  await this.post(`/transaction/pending/vote`, input, {
@@ -1480,32 +1304,24 @@ var BackendImpl = class _BackendImpl {
1480
1304
  });
1481
1305
  }
1482
1306
  async buildNextIntentionAndAddToPending(input) {
1483
- await this.post(`/transaction/pending/build`, {
1484
- ...input,
1485
- gasPrice: input.gasPrice.toString(),
1486
- gasBudget: input.gasBudget.toString()
1487
- }, {
1488
- headers: this.headers()
1489
- });
1307
+ await this.post(
1308
+ `/transaction/pending/build`,
1309
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1310
+ { headers: this.headers() }
1311
+ );
1490
1312
  }
1491
1313
  async proposeIntentionAndBuildVote(input) {
1492
- await this.post(`/transaction/intention/build`, {
1493
- ...input,
1494
- gasPrice: input.gasPrice.toString(),
1495
- gasBudget: input.gasBudget.toString()
1496
- }, {
1497
- headers: this.headers()
1498
- });
1314
+ await this.post(
1315
+ `/transaction/intention/build`,
1316
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1317
+ { headers: this.headers() }
1318
+ );
1499
1319
  }
1500
1320
  async skipNextFailedIntention(input) {
1501
- await this.post(`/transaction/pending/skip`, input, {
1502
- headers: this.headers()
1503
- });
1321
+ await this.post(`/transaction/pending/skip`, input, { headers: this.headers() });
1504
1322
  }
1505
1323
  async fetchTransaction(input) {
1506
- const res = await this.post(`/transaction/fetch`, input, {
1507
- headers: this.headers()
1508
- });
1324
+ const res = await this.post(`/transaction/fetch`, input, { headers: this.headers() });
1509
1325
  return res.data;
1510
1326
  }
1511
1327
  async getAddressBookEntries(pagination) {
@@ -1516,22 +1332,14 @@ var BackendImpl = class _BackendImpl {
1516
1332
  return res.data;
1517
1333
  }
1518
1334
  async updateAddressBook(input) {
1519
- await this.post(`/address-book`, input, {
1520
- headers: this.headers()
1521
- });
1335
+ await this.post(`/address-book`, input, { headers: this.headers() });
1522
1336
  }
1523
1337
  async getAddressBookMode() {
1524
- const res = await this.get("/address-book/mode", {
1525
- headers: this.headers()
1526
- });
1338
+ const res = await this.get("/address-book/mode", { headers: this.headers() });
1527
1339
  return res.data;
1528
1340
  }
1529
1341
  async setAddressBookMode(input) {
1530
- await this.post("/address-book/mode", {
1531
- mode: input.mode
1532
- }, {
1533
- headers: this.headers()
1534
- });
1342
+ await this.post("/address-book/mode", { mode: input.mode }, { headers: this.headers() });
1535
1343
  }
1536
1344
  async submitReport(report) {
1537
1345
  await this.post("/report", report);
@@ -1544,10 +1352,7 @@ var BackendImpl = class _BackendImpl {
1544
1352
  return res.data;
1545
1353
  }
1546
1354
  headers(token) {
1547
- return {
1548
- Authorization: `Bearer ${token || this._token}`,
1549
- "sui-mock-user": this.mockAddress
1550
- };
1355
+ return { Authorization: `Bearer ${token || this._token}`, "sui-mock-user": this.mockAddress };
1551
1356
  }
1552
1357
  static toMSafeConfig(resp) {
1553
1358
  return {
@@ -1603,9 +1408,7 @@ var BackendImpl = class _BackendImpl {
1603
1408
  } else if (transformRequest instanceof Array) {
1604
1409
  transformRequests = transformRequest;
1605
1410
  } else {
1606
- transformRequests = [
1607
- transformRequest
1608
- ];
1411
+ transformRequests = [transformRequest];
1609
1412
  }
1610
1413
  return [
1611
1414
  (d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
@@ -1614,10 +1417,6 @@ var BackendImpl = class _BackendImpl {
1614
1417
  }
1615
1418
  };
1616
1419
  var BackendError = class _BackendError extends Error {
1617
- static {
1618
- __name(this, "BackendError");
1619
- }
1620
- e;
1621
1420
  constructor(e) {
1622
1421
  super();
1623
1422
  this.e = e;
@@ -1654,15 +1453,14 @@ var BackendError = class _BackendError extends Error {
1654
1453
  function msafeChainToSuiNetwork(chain) {
1655
1454
  return chain === "sui:mainnet" ? "mainnet" : "testnet";
1656
1455
  }
1657
- __name(msafeChainToSuiNetwork, "msafeChainToSuiNetwork");
1658
- var MSafeEnv;
1659
- (function(MSafeEnv2) {
1660
- MSafeEnv2["local"] = "local";
1661
- MSafeEnv2["unit"] = "unit";
1662
- MSafeEnv2["dev"] = "dev";
1663
- MSafeEnv2["prev"] = "prev";
1664
- MSafeEnv2["prod"] = "prod";
1665
- })(MSafeEnv || (MSafeEnv = {}));
1456
+ var MSafeEnv = /* @__PURE__ */ ((MSafeEnv3) => {
1457
+ MSafeEnv3["local"] = "local";
1458
+ MSafeEnv3["unit"] = "unit";
1459
+ MSafeEnv3["dev"] = "dev";
1460
+ MSafeEnv3["prev"] = "prev";
1461
+ MSafeEnv3["prod"] = "prod";
1462
+ return MSafeEnv3;
1463
+ })(MSafeEnv || {});
1666
1464
  function httpUrlToGrpcBaseUrl(url) {
1667
1465
  const parsed = new URL(url);
1668
1466
  if (parsed.protocol === "https:" && parsed.port === "") {
@@ -1673,7 +1471,6 @@ function httpUrlToGrpcBaseUrl(url) {
1673
1471
  }
1674
1472
  return `${parsed.origin}${parsed.pathname}${parsed.search}`;
1675
1473
  }
1676
- __name(httpUrlToGrpcBaseUrl, "httpUrlToGrpcBaseUrl");
1677
1474
  var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
1678
1475
  var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
1679
1476
  var LOCAL_API_URL = "http://127.0.0.1:3000";
@@ -1684,7 +1481,7 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
1684
1481
  var PROD_API_URL = "https://sui.m-safe.link";
1685
1482
  var ENV_CONFIGS = /* @__PURE__ */ new Map([
1686
1483
  [
1687
- "unit",
1484
+ "unit" /* unit */,
1688
1485
  {
1689
1486
  suiClient: {
1690
1487
  url: TESTNET_RPC_URL
@@ -1697,7 +1494,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1697
1494
  }
1698
1495
  ],
1699
1496
  [
1700
- "local",
1497
+ "local" /* local */,
1701
1498
  {
1702
1499
  suiClient: {
1703
1500
  url: TESTNET_RPC_URL
@@ -1710,7 +1507,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1710
1507
  }
1711
1508
  ],
1712
1509
  [
1713
- "dev",
1510
+ "dev" /* dev */,
1714
1511
  {
1715
1512
  suiClient: {
1716
1513
  url: TESTNET_RPC_URL
@@ -1723,7 +1520,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1723
1520
  }
1724
1521
  ],
1725
1522
  [
1726
- "prev",
1523
+ "prev" /* prev */,
1727
1524
  {
1728
1525
  suiClient: {
1729
1526
  url: MAINNET_RPC_URL
@@ -1736,7 +1533,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1736
1533
  }
1737
1534
  ],
1738
1535
  [
1739
- "prod",
1536
+ "prod" /* prod */,
1740
1537
  {
1741
1538
  suiClient: {
1742
1539
  url: MAINNET_RPC_URL
@@ -1765,13 +1562,9 @@ function getMSafeConfig(env, options) {
1765
1562
  }
1766
1563
  return config;
1767
1564
  }
1768
- __name(getMSafeConfig, "getMSafeConfig");
1769
1565
 
1770
1566
  // src/globals/MSafeGlobals.ts
1771
1567
  var MSafeGlobals = class _MSafeGlobals {
1772
- static {
1773
- __name(this, "MSafeGlobals");
1774
- }
1775
1568
  backend;
1776
1569
  suiClient;
1777
1570
  config;
@@ -1813,15 +1606,11 @@ var MSafeGlobals = class _MSafeGlobals {
1813
1606
 
1814
1607
  // src/core/MSafeClient.ts
1815
1608
  var MSafeClient = class _MSafeClient {
1816
- static {
1817
- __name(this, "MSafeClient");
1818
- }
1819
- globals;
1820
- _creationHelper;
1821
- _publicKeyHelper;
1822
1609
  constructor(globals) {
1823
1610
  this.globals = globals;
1824
1611
  }
1612
+ _creationHelper;
1613
+ _publicKeyHelper;
1825
1614
  static async New(env, options) {
1826
1615
  const globals = await MSafeGlobals.New(env, options);
1827
1616
  return new _MSafeClient(globals);
@@ -1856,10 +1645,7 @@ var MSafeClient = class _MSafeClient {
1856
1645
  return this.globals.backend.getUserInfo();
1857
1646
  }
1858
1647
  async ownedMSafe(pagination) {
1859
- return this.globals.backend.getOwnedMSafeByStatus({
1860
- status: import_sui3_utils7.UserMSafeStatus.active,
1861
- pagination
1862
- });
1648
+ return this.globals.backend.getOwnedMSafeByStatus({ status: import_sui3_utils7.UserMSafeStatus.active, pagination });
1863
1649
  }
1864
1650
  async createAccount(info) {
1865
1651
  return this.creationHelper.submitMSafeCreation(info);
@@ -1909,38 +1695,26 @@ var MSafeClient = class _MSafeClient {
1909
1695
  };
1910
1696
 
1911
1697
  // src/backend/types/notification.ts
1912
- var InfoTypeKey;
1913
- (function(InfoTypeKey2) {
1698
+ var InfoTypeKey = /* @__PURE__ */ ((InfoTypeKey2) => {
1914
1699
  InfoTypeKey2["receive"] = "info_type_receive";
1915
1700
  InfoTypeKey2["send"] = "info_type_send";
1916
1701
  InfoTypeKey2["invitation"] = "info_type_invitation";
1917
1702
  InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
1918
- })(InfoTypeKey || (InfoTypeKey = {}));
1703
+ return InfoTypeKey2;
1704
+ })(InfoTypeKey || {});
1919
1705
  var NotificationSubscribeDto = class {
1920
- static {
1921
- __name(this, "NotificationSubscribeDto");
1922
- }
1923
1706
  email;
1924
1707
  };
1925
1708
  var NotificationUpdateDto = class {
1926
- static {
1927
- __name(this, "NotificationUpdateDto");
1928
- }
1929
1709
  email;
1930
1710
  infoTypes;
1931
1711
  msafeEnabled;
1932
1712
  };
1933
1713
  var InfoTypeEnabledDto = class {
1934
- static {
1935
- __name(this, "InfoTypeEnabledDto");
1936
- }
1937
1714
  infoType;
1938
1715
  enabled;
1939
1716
  };
1940
1717
  var MSafeEnabledDto = class {
1941
- static {
1942
- __name(this, "MSafeEnabledDto");
1943
- }
1944
1718
  msafeAddress;
1945
1719
  enabled;
1946
1720
  };