@msafe/sui3-sdk 1.0.6 → 1.0.7

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,6 +5,7 @@ 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 });
8
9
  var __export = (target, all) => {
9
10
  for (var name in all)
10
11
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -62,7 +63,6 @@ __export(src_exports, {
62
63
  getAllCoins: () => getAllCoins,
63
64
  getMSafeConfig: () => getMSafeConfig,
64
65
  getPublicKeyFromChain: () => getPublicKeyFromChain,
65
- httpUrlToGrpcBaseUrl: () => httpUrlToGrpcBaseUrl,
66
66
  msafeChainToSuiNetwork: () => msafeChainToSuiNetwork,
67
67
  stringToBuffer: () => stringToBuffer,
68
68
  toSuiTransaction: () => toSuiTransaction
@@ -72,6 +72,11 @@ module.exports = __toCommonJS(src_exports);
72
72
  // src/core/CreateHelper.ts
73
73
  var import_sui3_utils = require("@msafe/sui3-utils");
74
74
  var CreateHelper = class {
75
+ static {
76
+ __name(this, "CreateHelper");
77
+ }
78
+ globals;
79
+ pkHelper;
75
80
  constructor(globals, pkHelper) {
76
81
  this.globals = globals;
77
82
  this.pkHelper = pkHelper;
@@ -89,13 +94,13 @@ var CreateHelper = class {
89
94
  return this.calculateMSafeAddress(createInfo);
90
95
  }
91
96
  /**
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
- */
97
+ * Add user manually added public key for an address. If user input the public key with
98
+ * extra signature scheme flag, the scheme value will be automatically fixed.
99
+ *
100
+ * @param address
101
+ * @param pkEncoded
102
+ * @throws error if the public key does not match
103
+ */
99
104
  addPublicKey(address, pkEncoded) {
100
105
  const pk = import_sui3_utils.PublicKeySerde.de(pkEncoded);
101
106
  if (!(0, import_sui3_utils.isSameAddress)(address, pk.toSuiAddress())) {
@@ -106,7 +111,9 @@ var CreateHelper = class {
106
111
  async submitMSafeCreation(creationInfo) {
107
112
  const msafeAddress = await this.validateCreateInfo(creationInfo);
108
113
  const signingMessage = import_sui3_utils.SigningMessageHelper.createMSafeMessage(msafeAddress);
109
- const signature = await this.globals.wallet.signPersonalMessage({ messageStr: signingMessage });
114
+ const signature = await this.globals.wallet.signPersonalMessage({
115
+ messageStr: signingMessage
116
+ });
110
117
  await this.submitToBackend(creationInfo, signature.signature);
111
118
  return msafeAddress;
112
119
  }
@@ -137,9 +144,7 @@ var CreateHelper = class {
137
144
  })),
138
145
  threshold: createInfo.threshold,
139
146
  name: createInfo.name,
140
- // name validation is deferred to backend
141
147
  description: createInfo.description,
142
- // description validation is deferred to backend
143
148
  creationNonce: createInfo.creationNonce,
144
149
  signature
145
150
  });
@@ -152,6 +157,10 @@ var import_sui3_utils7 = require("@msafe/sui3-utils");
152
157
  // src/core/AddressBookSDK.ts
153
158
  var import_sui3_utils2 = require("@msafe/sui3-utils");
154
159
  var AddressBookSDK = class {
160
+ static {
161
+ __name(this, "AddressBookSDK");
162
+ }
163
+ globals;
155
164
  constructor(globals) {
156
165
  this.globals = globals;
157
166
  }
@@ -160,28 +169,45 @@ var AddressBookSDK = class {
160
169
  }
161
170
  async update(updates) {
162
171
  const messageStr = import_sui3_utils2.SigningMessageHelper.updateAddressBookMessage(updates);
163
- const sig = await this.globals.wallet.signPersonalMessage({ messageStr });
164
- return this.globals.backend.updateAddressBook({ updates, signature: sig.signature });
172
+ const sig = await this.globals.wallet.signPersonalMessage({
173
+ messageStr
174
+ });
175
+ return this.globals.backend.updateAddressBook({
176
+ updates,
177
+ signature: sig.signature
178
+ });
165
179
  }
166
180
  async getMode() {
167
181
  const res = await this.globals.backend.getAddressBookMode();
168
182
  return res.mode;
169
183
  }
170
184
  async setMode(mode) {
171
- return this.globals.backend.setAddressBookMode({ mode });
185
+ return this.globals.backend.setAddressBookMode({
186
+ mode
187
+ });
172
188
  }
173
189
  };
174
190
 
175
191
  // src/core/InvitationSDK.ts
176
192
  var InvitationSDK = class {
193
+ static {
194
+ __name(this, "InvitationSDK");
195
+ }
196
+ globals;
177
197
  constructor(globals) {
178
198
  this.globals = globals;
179
199
  }
180
200
  async getMSafeByStatus(status, pagination) {
181
- return this.globals.backend.getOwnedMSafeByStatus({ status, pagination });
201
+ return this.globals.backend.getOwnedMSafeByStatus({
202
+ status,
203
+ pagination
204
+ });
182
205
  }
183
206
  async updateMSafeStatus(msafeAddress, status) {
184
- return this.globals.backend.updateMSafeStatus({ msafeAddress, status });
207
+ return this.globals.backend.updateMSafeStatus({
208
+ msafeAddress,
209
+ status
210
+ });
185
211
  }
186
212
  };
187
213
 
@@ -195,18 +221,11 @@ var import_wallet_standard = require("@mysten/wallet-standard");
195
221
  // src/simulate/simulator.ts
196
222
  var import_transactions = require("@mysten/sui/transactions");
197
223
  var GAS_SAFE_OVERHEAD = 1000n;
198
- function formatExecutionError(error) {
199
- return error.message;
200
- }
201
- function gasObjectToReference(gas) {
202
- if (!gas?.objectId) {
203
- throw new Error("Gas object missing from simulation effects");
204
- }
205
- const version = gas.outputVersion ?? gas.inputVersion ?? "0";
206
- const digest = gas.outputDigest ?? gas.inputDigest ?? "";
207
- return { objectId: gas.objectId, version, digest };
208
- }
209
224
  var Simulator = class {
225
+ static {
226
+ __name(this, "Simulator");
227
+ }
228
+ globals;
210
229
  constructor(globals) {
211
230
  this.globals = globals;
212
231
  }
@@ -215,59 +234,32 @@ var Simulator = class {
215
234
  const { suiClient } = this.globals;
216
235
  const gasPrice = await this.getGasPrice();
217
236
  tx.setGasPrice(gasPrice);
218
- let built;
219
- try {
220
- built = await tx.build({ client: suiClient });
221
- } catch (e) {
222
- const message = e instanceof Error ? e.message : String(e);
223
- return {
224
- success: false,
225
- gasPrice,
226
- simulationError: message
227
- };
228
- }
229
- let inspectResult;
230
- try {
231
- inspectResult = await suiClient.simulateTransaction({
232
- transaction: built,
233
- include: { effects: true }
234
- });
235
- } catch (e) {
236
- const message = e instanceof Error ? e.message : String(e);
237
- return {
238
- success: false,
239
- gasPrice,
240
- simulationError: message
241
- };
242
- }
243
- const txRow = inspectResult.Transaction ?? inspectResult.FailedTransaction;
244
- const { effects } = txRow;
245
- if (!effects) {
246
- throw new Error("simulateTransaction did not return effects");
247
- }
248
- const success = effects.status.success === true;
237
+ const inspectResult = await suiClient.dryRunTransactionBlock({
238
+ transactionBlock: await tx.build({
239
+ client: suiClient
240
+ })
241
+ });
242
+ const success = inspectResult.effects.status.status === "success";
249
243
  if (!success) {
250
- const err = effects.status.success === false ? effects.status.error : null;
251
244
  return {
252
245
  success,
253
246
  gasPrice,
254
247
  response: inspectResult,
255
- simulationError: err ? formatExecutionError(err) : "Simulation failed"
248
+ simulationError: inspectResult.effects.status.error
256
249
  };
257
250
  }
258
- const gasBudget = this.toGasBudget(effects.gasUsed, gasPrice);
251
+ const gasBudget = this.toGasBudget(inspectResult.effects.gasUsed, gasPrice);
259
252
  return {
260
253
  success,
261
254
  gasPrice,
262
- gasObject: gasObjectToReference(effects.gasObject),
263
- gasUsed: effects.gasUsed,
255
+ gasObject: inspectResult.effects.gasObject.reference,
256
+ gasUsed: inspectResult.effects.gasUsed,
264
257
  gasBudget,
265
258
  response: inspectResult
266
259
  };
267
260
  }
268
261
  async getGasPrice() {
269
- const { referenceGasPrice } = await this.globals.suiClient.getReferenceGasPrice();
270
- return BigInt(referenceGasPrice);
262
+ return this.globals.suiClient.getReferenceGasPrice();
271
263
  }
272
264
  toGasBudget(gasUsed, gasPrice) {
273
265
  const { computationCost, storageCost, storageRebate } = gasUsed;
@@ -286,12 +278,15 @@ var import_buffer = require("buffer");
286
278
  function stringToBuffer(s) {
287
279
  return import_buffer.Buffer.from(s, "utf-8");
288
280
  }
281
+ __name(stringToBuffer, "stringToBuffer");
289
282
  function Uint8ArrayToHex(b) {
290
283
  return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
291
284
  }
285
+ __name(Uint8ArrayToHex, "Uint8ArrayToHex");
292
286
  function HexToUint8Array(hex) {
293
287
  return Uint8Array.from(import_buffer.Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
294
288
  }
289
+ __name(HexToUint8Array, "HexToUint8Array");
295
290
 
296
291
  // src/utils/crypto.ts
297
292
  var import_verify = require("@mysten/sui/verify");
@@ -302,6 +297,9 @@ var import_utils2 = require("@mysten/sui/utils");
302
297
  // src/utils/coin.ts
303
298
  var import_utils = require("@mysten/sui/utils");
304
299
  var CoinHelper = class {
300
+ static {
301
+ __name(this, "CoinHelper");
302
+ }
305
303
  _client;
306
304
  _coinMetaReg;
307
305
  constructor(client) {
@@ -320,12 +318,17 @@ var CoinHelper = class {
320
318
  return meta;
321
319
  }
322
320
  async queryCoinMeta(coinType) {
323
- const res = await this._client.getCoinMetadata({ coinType });
324
- return res.coinMetadata ?? void 0;
321
+ const res = await this._client.getCoinMetadata({
322
+ coinType
323
+ });
324
+ return res || void 0;
325
325
  }
326
326
  };
327
327
  var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
328
328
  var Coin = class _Coin {
329
+ static {
330
+ __name(this, "Coin");
331
+ }
329
332
  static isCoin(type) {
330
333
  if (!type) {
331
334
  return false;
@@ -340,13 +343,6 @@ var Coin = class _Coin {
340
343
  if (!_Coin.isCoin(data.type)) {
341
344
  return void 0;
342
345
  }
343
- if (data.json && typeof data.json === "object" && "balance" in data.json) {
344
- const { balance: balance2 } = data.json;
345
- if (balance2 === void 0) {
346
- return void 0;
347
- }
348
- return BigInt(balance2);
349
- }
350
346
  if (data.content?.dataType !== "moveObject") {
351
347
  return void 0;
352
348
  }
@@ -360,6 +356,9 @@ var Coin = class _Coin {
360
356
 
361
357
  // src/utils/format.ts
362
358
  var Formatter = class {
359
+ static {
360
+ __name(this, "Formatter");
361
+ }
363
362
  static normalizeSuiAddress(addr) {
364
363
  return (0, import_utils2.normalizeSuiAddress)(addr);
365
364
  }
@@ -382,9 +381,13 @@ function addPrefix(s, prefix) {
382
381
  }
383
382
  return prefix + s;
384
383
  }
384
+ __name(addPrefix, "addPrefix");
385
385
 
386
386
  // src/utils/crypto.ts
387
387
  var SignatureVerifier = class _SignatureVerifier {
388
+ static {
389
+ __name(this, "SignatureVerifier");
390
+ }
388
391
  static async getPublicKeyFromSignature(input) {
389
392
  if (input.messageType === "TransactionBlock") {
390
393
  return (0, import_verify.verifyTransactionSignature)(input.message, input.signature);
@@ -425,68 +428,29 @@ var SignatureVerifier = class _SignatureVerifier {
425
428
  // src/utils/sui.ts
426
429
  var import_sui3_utils3 = require("@msafe/sui3-utils");
427
430
  var import_cryptography = require("@mysten/sui/cryptography");
428
- var import_graphql = require("@mysten/sui/graphql");
429
431
  var import_multisig = require("@mysten/sui/multisig");
430
432
  var SUI_COIN = "0x2::sui::SUI";
431
- var GRAPHQL_URL_BY_NETWORK = {
432
- mainnet: "https://sui-mainnet.mystenlabs.com/graphql",
433
- testnet: "https://sui-testnet.mystenlabs.com/graphql",
434
- devnet: "https://sui-devnet.mystenlabs.com/graphql"
435
- };
436
- function graphqlClientForGrpc(suiClient) {
437
- const url = GRAPHQL_URL_BY_NETWORK[suiClient.network] ?? GRAPHQL_URL_BY_NETWORK.testnet;
438
- return new import_graphql.SuiGraphQLClient({ url, network: suiClient.network });
439
- }
440
- function collectSignatureStrings(value) {
441
- if (typeof value === "string") {
442
- return [value];
443
- }
444
- if (!value || typeof value !== "object") {
445
- return [];
446
- }
447
- if ("base64" in value && typeof value.base64 === "string") {
448
- return [value.base64];
449
- }
450
- if ("scheme" in value && "base64" in value) {
451
- const b64 = value.base64;
452
- return typeof b64 === "string" ? [b64] : [];
453
- }
454
- return [];
455
- }
456
- var TX_SIG_QUERY = `
457
- query PublicKeyTxSigs($sender: SuiAddress!, $first: Int!) {
458
- transactions(first: $first, filter: { sentAddress: $sender }) {
459
- nodes {
460
- signatures
461
- }
462
- }
463
- }
464
- `;
465
433
  async function getPublicKeyFromChain(suiClient, address) {
466
- const graphql = graphqlClientForGrpc(suiClient);
467
434
  let txs;
468
435
  try {
469
- const res = await graphql.query({
470
- query: TX_SIG_QUERY,
471
- variables: { sender: address, first: 2 }
436
+ txs = await suiClient.queryTransactionBlocks({
437
+ // Disable naming rule since the variable is defined by Mysten
438
+ filter: {
439
+ FromAddress: address
440
+ },
441
+ options: {
442
+ showInput: true
443
+ },
444
+ limit: 2
472
445
  });
473
- if (res.errors?.length) {
474
- return void 0;
475
- }
476
- txs = res.data ?? {};
477
446
  } catch (e) {
478
447
  return void 0;
479
448
  }
480
- const nodes = txs.transactions?.nodes ?? [];
481
- if (nodes.length === 0) {
482
- return void 0;
483
- }
484
- const first = nodes[0];
485
- const rawSigs = first.signatures;
486
- const signatures = Array.isArray(rawSigs) ? rawSigs.flatMap((item) => collectSignatureStrings(item)) : [];
487
- if (signatures.length === 0) {
449
+ if (txs.data.length === 0 || !txs.data[0].transaction?.txSignatures) {
488
450
  return void 0;
489
451
  }
452
+ const tx = txs.data[0];
453
+ const signatures = tx.transaction?.txSignatures;
490
454
  for (let i = 0; i !== signatures.length; i++) {
491
455
  const serializedSig = signatures[i];
492
456
  const pk = getAddressFromSignatures(serializedSig, address);
@@ -497,6 +461,7 @@ async function getPublicKeyFromChain(suiClient, address) {
497
461
  }
498
462
  return void 0;
499
463
  }
464
+ __name(getPublicKeyFromChain, "getPublicKeyFromChain");
500
465
  function getAddressFromSignatures(serializedSig, targetAddress) {
501
466
  const decoded = (0, import_cryptography.parseSerializedSignature)(serializedSig);
502
467
  switch (decoded.signatureScheme) {
@@ -511,7 +476,10 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
511
476
  case "ED25519":
512
477
  case "Secp256k1":
513
478
  case "Secp256r1": {
514
- const pk = import_sui3_utils3.PublicKeySerde.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
479
+ const pk = import_sui3_utils3.PublicKeySerde.de({
480
+ publicKeyEncoded: decoded.publicKey,
481
+ schema: decoded.signatureScheme
482
+ });
515
483
  if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
516
484
  return pk;
517
485
  }
@@ -521,22 +489,24 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
521
489
  throw new Error("Unknown schema");
522
490
  }
523
491
  }
492
+ __name(getAddressFromSignatures, "getAddressFromSignatures");
524
493
  async function getAllCoins(input) {
525
494
  let hasNext = true;
526
495
  let cursor;
527
496
  const res = [];
528
497
  while (hasNext) {
529
- const currentPage = await input.suiClient.listCoins({
498
+ const currentPage = await input.suiClient.getCoins({
530
499
  owner: input.owner,
531
500
  coinType: input.coinType,
532
501
  cursor
533
502
  });
534
- res.push(...currentPage.objects);
503
+ res.push(...currentPage.data);
535
504
  hasNext = currentPage.hasNextPage;
536
- cursor = currentPage.cursor;
505
+ cursor = currentPage.nextCursor;
537
506
  }
538
507
  return res;
539
508
  }
509
+ __name(getAllCoins, "getAllCoins");
540
510
 
541
511
  // src/utils/transaction.ts
542
512
  var import_transactions2 = require("@mysten/sui/transactions");
@@ -547,6 +517,7 @@ function toSuiTransaction(txb) {
547
517
  const legacy = txb;
548
518
  return import_transactions2.Transaction.from(legacy.serialize());
549
519
  }
520
+ __name(toSuiTransaction, "toSuiTransaction");
550
521
 
551
522
  // src/utils/iter/iterator.ts
552
523
  var REQUEST_PAGE_SIZE = 25;
@@ -561,14 +532,19 @@ async function getAllFromIterator(it) {
561
532
  }
562
533
  return res;
563
534
  }
535
+ __name(getAllFromIterator, "getAllFromIterator");
564
536
  var PagedIterator = class {
537
+ static {
538
+ __name(this, "PagedIterator");
539
+ }
540
+ requester;
541
+ curPage;
542
+ init;
565
543
  constructor(requester) {
566
544
  this.requester = requester;
567
545
  this.curPage = void 0;
568
546
  this.init = true;
569
547
  }
570
- curPage;
571
- init;
572
548
  async hasNext() {
573
549
  if (this.init) {
574
550
  if (!this.curPage) {
@@ -594,15 +570,19 @@ var PagedIterator = class {
594
570
  }
595
571
  };
596
572
  var EntryIterator = class {
573
+ static {
574
+ __name(this, "EntryIterator");
575
+ }
576
+ requester;
577
+ cursor;
578
+ pager;
579
+ curData;
597
580
  constructor(requester) {
598
581
  this.requester = requester;
599
582
  this.pager = new PagedIterator(requester);
600
583
  this.curData = [];
601
584
  this.cursor = 0;
602
585
  }
603
- cursor;
604
- pager;
605
- curData;
606
586
  async hasNext() {
607
587
  if (this.cursor < this.curData.length - 1) {
608
588
  return true;
@@ -624,15 +604,18 @@ var EntryIterator = class {
624
604
  };
625
605
 
626
606
  // src/utils/iter/object.ts
627
- var defaultObjectInclude = { json: true };
628
- function mergeInclude(options) {
629
- return { ...defaultObjectInclude, ...options?.objectInclude };
630
- }
631
607
  async function getAllOwnedObjects(provider, owner, options) {
632
608
  const iter = new OwnedObjectIterator(provider, owner, options);
633
609
  return await getAllFromIterator(iter);
634
610
  }
611
+ __name(getAllOwnedObjects, "getAllOwnedObjects");
635
612
  var OwnedObjectIterator = class extends EntryIterator {
613
+ static {
614
+ __name(this, "OwnedObjectIterator");
615
+ }
616
+ provider;
617
+ owner;
618
+ options;
636
619
  constructor(provider, owner, options) {
637
620
  super(new OwnedObjectRequester(provider, owner, options));
638
621
  this.provider = provider;
@@ -641,6 +624,16 @@ var OwnedObjectIterator = class extends EntryIterator {
641
624
  }
642
625
  };
643
626
  var OwnedObjectRequester = class {
627
+ static {
628
+ __name(this, "OwnedObjectRequester");
629
+ }
630
+ provider;
631
+ owner;
632
+ options;
633
+ nextCursor;
634
+ filter;
635
+ pageSize;
636
+ objectOptions;
644
637
  constructor(provider, owner, options) {
645
638
  this.provider = provider;
646
639
  this.owner = owner;
@@ -648,29 +641,28 @@ var OwnedObjectRequester = class {
648
641
  this.nextCursor = null;
649
642
  this.filter = options?.filter;
650
643
  this.pageSize = options?.pageSize || REQUEST_PAGE_SIZE;
651
- this.objectInclude = mergeInclude(options);
644
+ this.objectOptions = options?.objectOptions || {
645
+ showType: true,
646
+ showContent: true
647
+ };
652
648
  }
653
- nextCursor;
654
- filter;
655
- pageSize;
656
- objectInclude;
657
649
  async doNextRequest() {
658
- const res = await this.provider.listOwnedObjects({
650
+ const res = await this.provider.getOwnedObjects({
659
651
  owner: this.owner,
660
- include: this.objectInclude,
652
+ options: this.objectOptions,
661
653
  cursor: this.nextCursor,
662
654
  limit: this.pageSize
663
655
  });
664
- this.nextCursor = res.cursor;
656
+ this.nextCursor = res.nextCursor;
665
657
  let filtered;
666
658
  if (this.filter) {
667
659
  const { filter } = this;
668
- filtered = res.objects.filter((obj) => filter(obj));
660
+ filtered = res.data.filter((obj) => filter?.(obj));
669
661
  } else {
670
- filtered = res.objects;
662
+ filtered = res.data;
671
663
  }
672
664
  return {
673
- data: filtered,
665
+ data: filtered.map((r) => r.data).filter((data) => data),
674
666
  hasNext: res.hasNextPage
675
667
  };
676
668
  }
@@ -678,6 +670,14 @@ var OwnedObjectRequester = class {
678
670
 
679
671
  // src/core/MSafeAccount.ts
680
672
  var MSafeAccount = class _MSafeAccount {
673
+ static {
674
+ __name(this, "MSafeAccount");
675
+ }
676
+ globals;
677
+ info;
678
+ multiSig;
679
+ simulator;
680
+ coinHelper;
681
681
  constructor(globals, info) {
682
682
  this.globals = globals;
683
683
  this.info = info;
@@ -689,9 +689,6 @@ var MSafeAccount = class _MSafeAccount {
689
689
  this.coinHelper = new CoinHelper(this.suiClient);
690
690
  this.simulator = new Simulator(globals);
691
691
  }
692
- multiSig;
693
- simulator;
694
- coinHelper;
695
692
  static async New(globals, address) {
696
693
  const info = await globals.backend.getMSafeAccountInfo(address);
697
694
  const ms = new _MSafeAccount(globals, info);
@@ -700,35 +697,31 @@ var MSafeAccount = class _MSafeAccount {
700
697
  }
701
698
  }
702
699
  async ownedCoins() {
703
- const balances = [];
704
- let cursor = null;
705
- let hasNext = true;
706
- while (hasNext) {
707
- const page = await this.suiClient.listBalances({ owner: this.address, cursor, limit: 50 });
708
- balances.push(...page.balances);
709
- hasNext = page.hasNextPage;
710
- cursor = page.cursor;
711
- }
712
- return Promise.all(
713
- balances.map(async (balance) => {
714
- const meta = await this.coinHelper.getCoinMeta(balance.coinType);
715
- return {
716
- type: (0, import_utils3.normalizeStructTag)(balance.coinType),
717
- balance: BigInt(balance.addressBalance),
718
- metadata: meta
719
- };
720
- })
721
- );
700
+ const balances = await this.suiClient.getAllBalances({
701
+ owner: this.address
702
+ });
703
+ return Promise.all(balances.map(async (balance) => {
704
+ const meta = await this.coinHelper.getCoinMeta(balance.coinType);
705
+ const lockedEntry = balance.lockedBalance && typeof balance.lockedBalance === "object" && "number" in balance.lockedBalance && balance.lockedBalance.number ? BigInt(balance.lockedBalance.number) : 0n;
706
+ const unlockedBalance = lockedEntry ? BigInt(balance.totalBalance) - lockedEntry : BigInt(balance.totalBalance);
707
+ return {
708
+ type: (0, import_utils3.normalizeStructTag)(balance.coinType),
709
+ balance: unlockedBalance,
710
+ metadata: meta
711
+ };
712
+ }));
722
713
  }
723
714
  async ownedObjects(options) {
724
715
  const filterCoinObjectOptions = {
725
- filter: (obj) => !obj?.type?.startsWith("0x2::coin::Coin"),
716
+ filter: (objRes) => !objRes?.data?.type?.startsWith("0x2::coin::Coin"),
726
717
  ...options
727
718
  };
728
719
  return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
729
720
  }
730
721
  async pendingTransaction() {
731
- const res = await this.backend.getPendingTransactions({ msafeAddress: this.address });
722
+ const res = await this.backend.getPendingTransactions({
723
+ msafeAddress: this.address
724
+ });
732
725
  if (!res?.pending) {
733
726
  return void 0;
734
727
  }
@@ -760,7 +753,10 @@ var MSafeAccount = class _MSafeAccount {
760
753
  });
761
754
  }
762
755
  async futureIntentions(pagination) {
763
- return this.backend.getFutureIntentions({ msafeAddress: this.address, ...pagination });
756
+ return this.backend.getFutureIntentions({
757
+ msafeAddress: this.address,
758
+ ...pagination
759
+ });
764
760
  }
765
761
  async currentSequenceNumber() {
766
762
  return this.backend.getCurrentSequenceNumber(this.address);
@@ -777,24 +773,28 @@ var MSafeAccount = class _MSafeAccount {
777
773
  if (!appHelper) {
778
774
  throw new Error(`Can't find app helper for application ${request.application}`);
779
775
  }
780
- txb = toSuiTransaction(
781
- await appHelper.build({
782
- network: this.globals.config.network,
783
- intentionData: request.intention,
784
- txType: request.txType,
785
- txSubType: request.txSubType,
786
- clientUrl: this.globals.config.suiClient.url,
787
- account: {
788
- address: this.address,
789
- publicKey: (0, import_utils3.fromHex)(this.address),
790
- chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
791
- features: []
792
- }
793
- })
794
- );
776
+ txb = toSuiTransaction(await appHelper.build({
777
+ network: this.globals.config.network,
778
+ intentionData: request.intention,
779
+ txType: request.txType,
780
+ txSubType: request.txSubType,
781
+ clientUrl: this.globals.config.suiClient.url,
782
+ account: {
783
+ address: this.address,
784
+ publicKey: (0, import_utils3.fromHex)(this.address),
785
+ chains: [
786
+ import_wallet_standard.SUI_MAINNET_CHAIN,
787
+ import_wallet_standard.SUI_TESTNET_CHAIN
788
+ ],
789
+ features: []
790
+ }
791
+ }));
795
792
  }
796
793
  txb.setSender(this.address);
797
- return this.simulator.simulate({ txb, sender: this.address });
794
+ return this.simulator.simulate({
795
+ txb,
796
+ sender: this.address
797
+ });
798
798
  }
799
799
  async proposeIntention(input) {
800
800
  const message = import_sui3_utils4.SigningMessageHelper.proposeIntentionMessage({
@@ -820,28 +820,35 @@ var MSafeAccount = class _MSafeAccount {
820
820
  if (!appHelper) {
821
821
  throw new Error(`Can't find app helper for application ${input.application}`);
822
822
  }
823
- txb = toSuiTransaction(
824
- await appHelper.build({
825
- network: this.globals.config.network,
826
- intentionData: input.intention,
827
- txType: input.txType,
828
- txSubType: input.txSubType,
829
- clientUrl: this.globals.config.suiClient.url,
830
- account: {
831
- address: this.address,
832
- publicKey: (0, import_utils3.fromHex)(this.address),
833
- chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
834
- features: []
835
- }
836
- })
837
- );
823
+ txb = toSuiTransaction(await appHelper.build({
824
+ network: this.globals.config.network,
825
+ intentionData: input.intention,
826
+ txType: input.txType,
827
+ txSubType: input.txSubType,
828
+ clientUrl: this.globals.config.suiClient.url,
829
+ account: {
830
+ address: this.address,
831
+ publicKey: (0, import_utils3.fromHex)(this.address),
832
+ chains: [
833
+ import_wallet_standard.SUI_MAINNET_CHAIN,
834
+ import_wallet_standard.SUI_TESTNET_CHAIN
835
+ ],
836
+ features: []
837
+ }
838
+ }));
838
839
  }
839
840
  txb.setGasPrice(input.gasPrice);
840
841
  txb.setGasBudget(input.gasBudget);
841
842
  txb.setSender(this.address);
842
- const payload = await txb.build({ client: this.globals.suiClient });
843
- const digest = await txb.getDigest({ client: this.globals.suiClient });
844
- const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
843
+ const payload = await txb.build({
844
+ client: this.globals.suiClient
845
+ });
846
+ const digest = await txb.getDigest({
847
+ client: this.globals.suiClient
848
+ });
849
+ const signature = await this.wallet.signTransactionBlock({
850
+ transactionBlock: payload
851
+ });
845
852
  return this.backend.proposeIntentionAndBuildVote({
846
853
  ...input,
847
854
  payload: (0, import_utils3.toHex)(payload),
@@ -917,7 +924,9 @@ var MSafeAccount = class _MSafeAccount {
917
924
  }
918
925
  async voteForTransaction(digest, payload) {
919
926
  const payloadBytes = HexToUint8Array(payload);
920
- const signature = await this.wallet.signTransactionBlock({ transactionBlock: payloadBytes });
927
+ const signature = await this.wallet.signTransactionBlock({
928
+ transactionBlock: payloadBytes
929
+ });
921
930
  return this.backend.voteForTransaction({
922
931
  msafeAddress: this.address,
923
932
  digest,
@@ -931,7 +940,10 @@ var MSafeAccount = class _MSafeAccount {
931
940
  }
932
941
  const txb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
933
942
  txb.setSender(this.address);
934
- return this.simulator.simulate({ txb, sender: this.address });
943
+ return this.simulator.simulate({
944
+ txb,
945
+ sender: this.address
946
+ });
935
947
  }
936
948
  async rejectCurrentTx(input) {
937
949
  const pendingTx = await this.pendingTransaction();
@@ -939,9 +951,15 @@ var MSafeAccount = class _MSafeAccount {
939
951
  throw new Error("Already rejected");
940
952
  }
941
953
  const rejectTxb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
942
- const digest = await rejectTxb.getDigest({ client: this.suiClient });
943
- const payload = await rejectTxb.build({ client: this.suiClient });
944
- const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
954
+ const digest = await rejectTxb.getDigest({
955
+ client: this.suiClient
956
+ });
957
+ const payload = await rejectTxb.build({
958
+ client: this.suiClient
959
+ });
960
+ const signature = await this.wallet.signTransactionBlock({
961
+ transactionBlock: payload
962
+ });
945
963
  return this.backend.rejectCurrentTx({
946
964
  msafeAddress: this.address,
947
965
  digest,
@@ -950,28 +968,34 @@ var MSafeAccount = class _MSafeAccount {
950
968
  });
951
969
  }
952
970
  async simulateBuildTransaction() {
953
- const intention = await this.backend.getNextIntention({ msafeAddress: this.address });
971
+ const intention = await this.backend.getNextIntention({
972
+ msafeAddress: this.address
973
+ });
954
974
  const appHelper = import_sui_app_store.appHelpers.getAppHelper(intention.application);
955
975
  if (!appHelper) {
956
976
  throw new Error(`Can't find app helper for application ${intention.application}`);
957
977
  }
958
- const txb = toSuiTransaction(
959
- await appHelper.build({
960
- network: this.globals.config.network,
961
- intentionData: intention.intention,
962
- txType: intention.txType,
963
- txSubType: intention.txSubType,
964
- clientUrl: this.globals.config.suiClient.url,
965
- account: {
966
- address: this.address,
967
- publicKey: (0, import_utils3.fromHex)(this.address),
968
- chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
969
- features: []
970
- }
971
- })
972
- );
978
+ const txb = toSuiTransaction(await appHelper.build({
979
+ network: this.globals.config.network,
980
+ intentionData: intention.intention,
981
+ txType: intention.txType,
982
+ txSubType: intention.txSubType,
983
+ clientUrl: this.globals.config.suiClient.url,
984
+ account: {
985
+ address: this.address,
986
+ publicKey: (0, import_utils3.fromHex)(this.address),
987
+ chains: [
988
+ import_wallet_standard.SUI_MAINNET_CHAIN,
989
+ import_wallet_standard.SUI_TESTNET_CHAIN
990
+ ],
991
+ features: []
992
+ }
993
+ }));
973
994
  txb.setSender(this.address);
974
- return this.simulator.simulate({ txb, sender: this.address });
995
+ return this.simulator.simulate({
996
+ txb,
997
+ sender: this.address
998
+ });
975
999
  }
976
1000
  async buildNextIntentionAndAddToPending(gasOption) {
977
1001
  return this.backend.buildNextIntentionAndAddToPending({
@@ -982,10 +1006,14 @@ var MSafeAccount = class _MSafeAccount {
982
1006
  });
983
1007
  }
984
1008
  async skipNextFailedIntention() {
985
- return this.backend.skipNextFailedIntention({ msafeAddress: this.address });
1009
+ return this.backend.skipNextFailedIntention({
1010
+ msafeAddress: this.address
1011
+ });
986
1012
  }
987
1013
  async fetchTransaction() {
988
- return this.backend.fetchTransaction({ msafeAddress: this.address });
1014
+ return this.backend.fetchTransaction({
1015
+ msafeAddress: this.address
1016
+ });
989
1017
  }
990
1018
  async executePendingTx(pending, isRejectTx = false) {
991
1019
  const votes = isRejectTx ? pending.rejectVotes : pending.votes;
@@ -994,7 +1022,10 @@ var MSafeAccount = class _MSafeAccount {
994
1022
  throw new Error("Not enough signature");
995
1023
  }
996
1024
  const sortedSigs = [];
997
- const gotSigs = new Map(votes.map((vote) => [vote.userAddress, vote.signature]));
1025
+ const gotSigs = new Map(votes.map((vote) => [
1026
+ vote.userAddress,
1027
+ vote.signature
1028
+ ]));
998
1029
  for (let i = 0; i < this.info.owners.length; i++) {
999
1030
  const owner = this.info.owners[i];
1000
1031
  const signature = gotSigs.get(owner.address);
@@ -1003,10 +1034,13 @@ var MSafeAccount = class _MSafeAccount {
1003
1034
  }
1004
1035
  }
1005
1036
  const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
1006
- return this.suiClient.executeTransaction({
1007
- transaction: HexToUint8Array(payload),
1008
- signatures: [multiSignature],
1009
- include: { effects: true, events: true }
1037
+ return this.suiClient.executeTransactionBlock({
1038
+ transactionBlock: HexToUint8Array(payload),
1039
+ signature: multiSignature,
1040
+ options: {
1041
+ showEffects: true,
1042
+ showEvents: true
1043
+ }
1010
1044
  });
1011
1045
  }
1012
1046
  async dashboard() {
@@ -1048,11 +1082,15 @@ var MSafeAccount = class _MSafeAccount {
1048
1082
  var import_sui3_utils5 = require("@msafe/sui3-utils");
1049
1083
  var import_utils5 = require("@mysten/sui/utils");
1050
1084
  var PublicKeyHelper = class {
1085
+ static {
1086
+ __name(this, "PublicKeyHelper");
1087
+ }
1088
+ globals;
1089
+ knownPublicKeys;
1051
1090
  constructor(globals) {
1052
1091
  this.globals = globals;
1053
1092
  this.knownPublicKeys = /* @__PURE__ */ new Map();
1054
1093
  }
1055
- knownPublicKeys;
1056
1094
  async getPublicKey(address) {
1057
1095
  const cached = this.knownPublicKeys.get(address);
1058
1096
  if (cached) {
@@ -1123,6 +1161,10 @@ var PublicKeyHelper = class {
1123
1161
 
1124
1162
  // src/core/ReportSDK.ts
1125
1163
  var ReportSDK = class {
1164
+ static {
1165
+ __name(this, "ReportSDK");
1166
+ }
1167
+ globals;
1126
1168
  constructor(globals) {
1127
1169
  this.globals = globals;
1128
1170
  }
@@ -1132,17 +1174,22 @@ var ReportSDK = class {
1132
1174
  };
1133
1175
 
1134
1176
  // src/globals/MSafeGlobals.ts
1135
- var import_grpc = require("@mysten/sui/grpc");
1177
+ var import_jsonRpc = require("@mysten/sui/jsonRpc");
1136
1178
 
1137
1179
  // src/backend/BackendImpl.ts
1138
1180
  var import_sui3_utils6 = require("@msafe/sui3-utils");
1139
1181
  var import_axios = __toESM(require("axios"), 1);
1140
1182
  var BackendImpl = class _BackendImpl {
1183
+ static {
1184
+ __name(this, "BackendImpl");
1185
+ }
1186
+ apiURL;
1187
+ mockAddress;
1188
+ _token;
1141
1189
  constructor(apiURL, mockAddress) {
1142
1190
  this.apiURL = apiURL;
1143
1191
  this.mockAddress = mockAddress;
1144
1192
  }
1145
- _token;
1146
1193
  getNotificationInfo() {
1147
1194
  return this.get(`/notification`, {
1148
1195
  headers: this.headers()
@@ -1165,7 +1212,9 @@ var BackendImpl = class _BackendImpl {
1165
1212
  }
1166
1213
  async verifyToken(jwt) {
1167
1214
  try {
1168
- const res = await this.get(`/auth`, { headers: this.headers(jwt) });
1215
+ const res = await this.get(`/auth`, {
1216
+ headers: this.headers(jwt)
1217
+ });
1169
1218
  return res.status === 200;
1170
1219
  } catch (_) {
1171
1220
  return false;
@@ -1175,7 +1224,9 @@ var BackendImpl = class _BackendImpl {
1175
1224
  this._token = token;
1176
1225
  }
1177
1226
  async getPublicKey(address) {
1178
- return (await this.getPublicKeyBatch([address]))[0];
1227
+ return (await this.getPublicKeyBatch([
1228
+ address
1229
+ ]))[0];
1179
1230
  }
1180
1231
  async getPublicKeyBatch(addresses) {
1181
1232
  const query = {
@@ -1185,9 +1236,7 @@ var BackendImpl = class _BackendImpl {
1185
1236
  params: query,
1186
1237
  headers: this.headers()
1187
1238
  });
1188
- return res.data?.map(
1189
- (publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0
1190
- );
1239
+ return res.data?.map((publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0);
1191
1240
  }
1192
1241
  async getMSafeAccountInfo(msafeAddress) {
1193
1242
  const q = {
@@ -1224,7 +1273,9 @@ var BackendImpl = class _BackendImpl {
1224
1273
  }
1225
1274
  async updateMSafeStatus(input) {
1226
1275
  const p = input;
1227
- await this.post(`/msafe/status`, p, { headers: this.headers() });
1276
+ await this.post(`/msafe/status`, p, {
1277
+ headers: this.headers()
1278
+ });
1228
1279
  }
1229
1280
  async getPendingTransactions(input) {
1230
1281
  const res = await this.get(`/transaction/pending`, {
@@ -1278,16 +1329,18 @@ var BackendImpl = class _BackendImpl {
1278
1329
  });
1279
1330
  }
1280
1331
  async proposeIntention(input) {
1281
- await this.post(`/transaction/intention`, input, { headers: this.headers() });
1332
+ await this.post(`/transaction/intention`, input, {
1333
+ headers: this.headers()
1334
+ });
1282
1335
  }
1283
1336
  async rejectCurrentTx(input) {
1284
- await this.post(
1285
- `/transaction/pending/reject`,
1286
- { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1287
- {
1288
- headers: this.headers()
1289
- }
1290
- );
1337
+ await this.post(`/transaction/pending/reject`, {
1338
+ ...input,
1339
+ gasPrice: input.gasPrice.toString(),
1340
+ gasBudget: input.gasBudget.toString()
1341
+ }, {
1342
+ headers: this.headers()
1343
+ });
1291
1344
  }
1292
1345
  async voteForTransaction(input) {
1293
1346
  await this.post(`/transaction/pending/vote`, input, {
@@ -1295,24 +1348,32 @@ var BackendImpl = class _BackendImpl {
1295
1348
  });
1296
1349
  }
1297
1350
  async buildNextIntentionAndAddToPending(input) {
1298
- await this.post(
1299
- `/transaction/pending/build`,
1300
- { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1301
- { headers: this.headers() }
1302
- );
1351
+ await this.post(`/transaction/pending/build`, {
1352
+ ...input,
1353
+ gasPrice: input.gasPrice.toString(),
1354
+ gasBudget: input.gasBudget.toString()
1355
+ }, {
1356
+ headers: this.headers()
1357
+ });
1303
1358
  }
1304
1359
  async proposeIntentionAndBuildVote(input) {
1305
- await this.post(
1306
- `/transaction/intention/build`,
1307
- { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1308
- { headers: this.headers() }
1309
- );
1360
+ await this.post(`/transaction/intention/build`, {
1361
+ ...input,
1362
+ gasPrice: input.gasPrice.toString(),
1363
+ gasBudget: input.gasBudget.toString()
1364
+ }, {
1365
+ headers: this.headers()
1366
+ });
1310
1367
  }
1311
1368
  async skipNextFailedIntention(input) {
1312
- await this.post(`/transaction/pending/skip`, input, { headers: this.headers() });
1369
+ await this.post(`/transaction/pending/skip`, input, {
1370
+ headers: this.headers()
1371
+ });
1313
1372
  }
1314
1373
  async fetchTransaction(input) {
1315
- const res = await this.post(`/transaction/fetch`, input, { headers: this.headers() });
1374
+ const res = await this.post(`/transaction/fetch`, input, {
1375
+ headers: this.headers()
1376
+ });
1316
1377
  return res.data;
1317
1378
  }
1318
1379
  async getAddressBookEntries(pagination) {
@@ -1323,14 +1384,22 @@ var BackendImpl = class _BackendImpl {
1323
1384
  return res.data;
1324
1385
  }
1325
1386
  async updateAddressBook(input) {
1326
- await this.post(`/address-book`, input, { headers: this.headers() });
1387
+ await this.post(`/address-book`, input, {
1388
+ headers: this.headers()
1389
+ });
1327
1390
  }
1328
1391
  async getAddressBookMode() {
1329
- const res = await this.get("/address-book/mode", { headers: this.headers() });
1392
+ const res = await this.get("/address-book/mode", {
1393
+ headers: this.headers()
1394
+ });
1330
1395
  return res.data;
1331
1396
  }
1332
1397
  async setAddressBookMode(input) {
1333
- await this.post("/address-book/mode", { mode: input.mode }, { headers: this.headers() });
1398
+ await this.post("/address-book/mode", {
1399
+ mode: input.mode
1400
+ }, {
1401
+ headers: this.headers()
1402
+ });
1334
1403
  }
1335
1404
  async submitReport(report) {
1336
1405
  await this.post("/report", report);
@@ -1343,7 +1412,10 @@ var BackendImpl = class _BackendImpl {
1343
1412
  return res.data;
1344
1413
  }
1345
1414
  headers(token) {
1346
- return { Authorization: `Bearer ${token || this._token}`, "sui-mock-user": this.mockAddress };
1415
+ return {
1416
+ Authorization: `Bearer ${token || this._token}`,
1417
+ "sui-mock-user": this.mockAddress
1418
+ };
1347
1419
  }
1348
1420
  static toMSafeConfig(resp) {
1349
1421
  return {
@@ -1399,7 +1471,9 @@ var BackendImpl = class _BackendImpl {
1399
1471
  } else if (transformRequest instanceof Array) {
1400
1472
  transformRequests = transformRequest;
1401
1473
  } else {
1402
- transformRequests = [transformRequest];
1474
+ transformRequests = [
1475
+ transformRequest
1476
+ ];
1403
1477
  }
1404
1478
  return [
1405
1479
  (d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
@@ -1408,6 +1482,10 @@ var BackendImpl = class _BackendImpl {
1408
1482
  }
1409
1483
  };
1410
1484
  var BackendError = class _BackendError extends Error {
1485
+ static {
1486
+ __name(this, "BackendError");
1487
+ }
1488
+ e;
1411
1489
  constructor(e) {
1412
1490
  super();
1413
1491
  this.e = e;
@@ -1444,24 +1522,15 @@ var BackendError = class _BackendError extends Error {
1444
1522
  function msafeChainToSuiNetwork(chain) {
1445
1523
  return chain === "sui:mainnet" ? "mainnet" : "testnet";
1446
1524
  }
1447
- var MSafeEnv = /* @__PURE__ */ ((MSafeEnv3) => {
1448
- MSafeEnv3["local"] = "local";
1449
- MSafeEnv3["unit"] = "unit";
1450
- MSafeEnv3["dev"] = "dev";
1451
- MSafeEnv3["prev"] = "prev";
1452
- MSafeEnv3["prod"] = "prod";
1453
- return MSafeEnv3;
1454
- })(MSafeEnv || {});
1455
- function httpUrlToGrpcBaseUrl(url) {
1456
- const parsed = new URL(url);
1457
- if (parsed.protocol === "https:" && parsed.port === "") {
1458
- return `https://${parsed.hostname}:443${parsed.pathname}${parsed.search}`;
1459
- }
1460
- if (parsed.protocol === "http:" && parsed.port === "") {
1461
- return `http://${parsed.hostname}:80${parsed.pathname}${parsed.search}`;
1462
- }
1463
- return `${parsed.origin}${parsed.pathname}${parsed.search}`;
1464
- }
1525
+ __name(msafeChainToSuiNetwork, "msafeChainToSuiNetwork");
1526
+ var MSafeEnv;
1527
+ (function(MSafeEnv2) {
1528
+ MSafeEnv2["local"] = "local";
1529
+ MSafeEnv2["unit"] = "unit";
1530
+ MSafeEnv2["dev"] = "dev";
1531
+ MSafeEnv2["prev"] = "prev";
1532
+ MSafeEnv2["prod"] = "prod";
1533
+ })(MSafeEnv || (MSafeEnv = {}));
1465
1534
  var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
1466
1535
  var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
1467
1536
  var LOCAL_API_URL = "http://127.0.0.1:3000";
@@ -1472,20 +1541,20 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
1472
1541
  var PROD_API_URL = "https://sui.m-safe.link";
1473
1542
  var ENV_CONFIGS = /* @__PURE__ */ new Map([
1474
1543
  [
1475
- "unit" /* unit */,
1544
+ "unit",
1476
1545
  {
1477
1546
  suiClient: {
1478
1547
  url: TESTNET_RPC_URL
1479
1548
  },
1480
1549
  backend: {
1481
- url: DEV_API_URL
1550
+ url: LOCAL_API_URL
1482
1551
  },
1483
- syncingURL: DEV_SYNCING_URL,
1552
+ syncingURL: LOCAL_SYNCING_URL,
1484
1553
  network: "sui:testnet"
1485
1554
  }
1486
1555
  ],
1487
1556
  [
1488
- "local" /* local */,
1557
+ "local",
1489
1558
  {
1490
1559
  suiClient: {
1491
1560
  url: TESTNET_RPC_URL
@@ -1498,7 +1567,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1498
1567
  }
1499
1568
  ],
1500
1569
  [
1501
- "dev" /* dev */,
1570
+ "dev",
1502
1571
  {
1503
1572
  suiClient: {
1504
1573
  url: TESTNET_RPC_URL
@@ -1511,7 +1580,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1511
1580
  }
1512
1581
  ],
1513
1582
  [
1514
- "prev" /* prev */,
1583
+ "prev",
1515
1584
  {
1516
1585
  suiClient: {
1517
1586
  url: MAINNET_RPC_URL
@@ -1524,7 +1593,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1524
1593
  }
1525
1594
  ],
1526
1595
  [
1527
- "prod" /* prod */,
1596
+ "prod",
1528
1597
  {
1529
1598
  suiClient: {
1530
1599
  url: MAINNET_RPC_URL
@@ -1553,9 +1622,13 @@ function getMSafeConfig(env, options) {
1553
1622
  }
1554
1623
  return config;
1555
1624
  }
1625
+ __name(getMSafeConfig, "getMSafeConfig");
1556
1626
 
1557
1627
  // src/globals/MSafeGlobals.ts
1558
1628
  var MSafeGlobals = class _MSafeGlobals {
1629
+ static {
1630
+ __name(this, "MSafeGlobals");
1631
+ }
1559
1632
  backend;
1560
1633
  suiClient;
1561
1634
  config;
@@ -1567,11 +1640,12 @@ var MSafeGlobals = class _MSafeGlobals {
1567
1640
  }
1568
1641
  static async New(env, options) {
1569
1642
  const config = getMSafeConfig(env, options);
1570
- const suiClient = config.suiClient.transport ? new import_grpc.SuiGrpcClient({
1571
- transport: config.suiClient.transport,
1572
- network: msafeChainToSuiNetwork(config.network)
1573
- }) : new import_grpc.SuiGrpcClient({
1574
- baseUrl: httpUrlToGrpcBaseUrl(config.suiClient.url),
1643
+ const suiClient = new import_jsonRpc.SuiJsonRpcClient({
1644
+ ...config.suiClient.transport ? {
1645
+ transport: config.suiClient.transport
1646
+ } : {
1647
+ url: config.suiClient.url
1648
+ },
1575
1649
  network: msafeChainToSuiNetwork(config.network)
1576
1650
  });
1577
1651
  const backend = new BackendImpl(config.backend.url, options?.mockAddress);
@@ -1597,11 +1671,15 @@ var MSafeGlobals = class _MSafeGlobals {
1597
1671
 
1598
1672
  // src/core/MSafeClient.ts
1599
1673
  var MSafeClient = class _MSafeClient {
1600
- constructor(globals) {
1601
- this.globals = globals;
1674
+ static {
1675
+ __name(this, "MSafeClient");
1602
1676
  }
1677
+ globals;
1603
1678
  _creationHelper;
1604
1679
  _publicKeyHelper;
1680
+ constructor(globals) {
1681
+ this.globals = globals;
1682
+ }
1605
1683
  static async New(env, options) {
1606
1684
  const globals = await MSafeGlobals.New(env, options);
1607
1685
  return new _MSafeClient(globals);
@@ -1636,7 +1714,10 @@ var MSafeClient = class _MSafeClient {
1636
1714
  return this.globals.backend.getUserInfo();
1637
1715
  }
1638
1716
  async ownedMSafe(pagination) {
1639
- return this.globals.backend.getOwnedMSafeByStatus({ status: import_sui3_utils7.UserMSafeStatus.active, pagination });
1717
+ return this.globals.backend.getOwnedMSafeByStatus({
1718
+ status: import_sui3_utils7.UserMSafeStatus.active,
1719
+ pagination
1720
+ });
1640
1721
  }
1641
1722
  async createAccount(info) {
1642
1723
  return this.creationHelper.submitMSafeCreation(info);
@@ -1686,26 +1767,38 @@ var MSafeClient = class _MSafeClient {
1686
1767
  };
1687
1768
 
1688
1769
  // src/backend/types/notification.ts
1689
- var InfoTypeKey = /* @__PURE__ */ ((InfoTypeKey2) => {
1770
+ var InfoTypeKey;
1771
+ (function(InfoTypeKey2) {
1690
1772
  InfoTypeKey2["receive"] = "info_type_receive";
1691
1773
  InfoTypeKey2["send"] = "info_type_send";
1692
1774
  InfoTypeKey2["invitation"] = "info_type_invitation";
1693
1775
  InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
1694
- return InfoTypeKey2;
1695
- })(InfoTypeKey || {});
1776
+ })(InfoTypeKey || (InfoTypeKey = {}));
1696
1777
  var NotificationSubscribeDto = class {
1778
+ static {
1779
+ __name(this, "NotificationSubscribeDto");
1780
+ }
1697
1781
  email;
1698
1782
  };
1699
1783
  var NotificationUpdateDto = class {
1784
+ static {
1785
+ __name(this, "NotificationUpdateDto");
1786
+ }
1700
1787
  email;
1701
1788
  infoTypes;
1702
1789
  msafeEnabled;
1703
1790
  };
1704
1791
  var InfoTypeEnabledDto = class {
1792
+ static {
1793
+ __name(this, "InfoTypeEnabledDto");
1794
+ }
1705
1795
  infoType;
1706
1796
  enabled;
1707
1797
  };
1708
1798
  var MSafeEnabledDto = class {
1799
+ static {
1800
+ __name(this, "MSafeEnabledDto");
1801
+ }
1709
1802
  msafeAddress;
1710
1803
  enabled;
1711
1804
  };