@msafe/sui3-sdk 1.0.4 → 1.0.6

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