@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.js CHANGED
@@ -1,14 +1,11 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/core/CreateHelper.ts
5
- import { isSameAddress, MultiSigAccount, PublicKeySerde, SigningMessageHelper } from "@msafe/sui3-utils";
2
+ import {
3
+ isSameAddress,
4
+ MultiSigAccount,
5
+ PublicKeySerde,
6
+ SigningMessageHelper
7
+ } from "@msafe/sui3-utils";
6
8
  var CreateHelper = class {
7
- static {
8
- __name(this, "CreateHelper");
9
- }
10
- globals;
11
- pkHelper;
12
9
  constructor(globals, pkHelper) {
13
10
  this.globals = globals;
14
11
  this.pkHelper = pkHelper;
@@ -26,13 +23,13 @@ var CreateHelper = class {
26
23
  return this.calculateMSafeAddress(createInfo);
27
24
  }
28
25
  /**
29
- * Add user manually added public key for an address. If user input the public key with
30
- * extra signature scheme flag, the scheme value will be automatically fixed.
31
- *
32
- * @param address
33
- * @param pkEncoded
34
- * @throws error if the public key does not match
35
- */
26
+ * Add user manually added public key for an address. If user input the public key with
27
+ * extra signature scheme flag, the scheme value will be automatically fixed.
28
+ *
29
+ * @param address
30
+ * @param pkEncoded
31
+ * @throws error if the public key does not match
32
+ */
36
33
  addPublicKey(address, pkEncoded) {
37
34
  const pk = PublicKeySerde.de(pkEncoded);
38
35
  if (!isSameAddress(address, pk.toSuiAddress())) {
@@ -43,9 +40,7 @@ var CreateHelper = class {
43
40
  async submitMSafeCreation(creationInfo) {
44
41
  const msafeAddress = await this.validateCreateInfo(creationInfo);
45
42
  const signingMessage = SigningMessageHelper.createMSafeMessage(msafeAddress);
46
- const signature = await this.globals.wallet.signPersonalMessage({
47
- messageStr: signingMessage
48
- });
43
+ const signature = await this.globals.wallet.signPersonalMessage({ messageStr: signingMessage });
49
44
  await this.submitToBackend(creationInfo, signature.signature);
50
45
  return msafeAddress;
51
46
  }
@@ -76,7 +71,9 @@ var CreateHelper = class {
76
71
  })),
77
72
  threshold: createInfo.threshold,
78
73
  name: createInfo.name,
74
+ // name validation is deferred to backend
79
75
  description: createInfo.description,
76
+ // description validation is deferred to backend
80
77
  creationNonce: createInfo.creationNonce,
81
78
  signature
82
79
  });
@@ -84,15 +81,14 @@ var CreateHelper = class {
84
81
  };
85
82
 
86
83
  // src/core/MSafeClient.ts
87
- import { SigningMessageHelper as SigningMessageHelper4, UserMSafeStatus as UserMSafeStatus2 } from "@msafe/sui3-utils";
84
+ import {
85
+ SigningMessageHelper as SigningMessageHelper4,
86
+ UserMSafeStatus as UserMSafeStatus2
87
+ } from "@msafe/sui3-utils";
88
88
 
89
89
  // src/core/AddressBookSDK.ts
90
90
  import { SigningMessageHelper as SigningMessageHelper2 } from "@msafe/sui3-utils";
91
91
  var AddressBookSDK = class {
92
- static {
93
- __name(this, "AddressBookSDK");
94
- }
95
- globals;
96
92
  constructor(globals) {
97
93
  this.globals = globals;
98
94
  }
@@ -101,51 +97,42 @@ var AddressBookSDK = class {
101
97
  }
102
98
  async update(updates) {
103
99
  const messageStr = SigningMessageHelper2.updateAddressBookMessage(updates);
104
- const sig = await this.globals.wallet.signPersonalMessage({
105
- messageStr
106
- });
107
- return this.globals.backend.updateAddressBook({
108
- updates,
109
- signature: sig.signature
110
- });
100
+ const sig = await this.globals.wallet.signPersonalMessage({ messageStr });
101
+ return this.globals.backend.updateAddressBook({ updates, signature: sig.signature });
111
102
  }
112
103
  async getMode() {
113
104
  const res = await this.globals.backend.getAddressBookMode();
114
105
  return res.mode;
115
106
  }
116
107
  async setMode(mode) {
117
- return this.globals.backend.setAddressBookMode({
118
- mode
119
- });
108
+ return this.globals.backend.setAddressBookMode({ mode });
120
109
  }
121
110
  };
122
111
 
123
112
  // src/core/InvitationSDK.ts
124
113
  var InvitationSDK = class {
125
- static {
126
- __name(this, "InvitationSDK");
127
- }
128
- globals;
129
114
  constructor(globals) {
130
115
  this.globals = globals;
131
116
  }
132
117
  async getMSafeByStatus(status, pagination) {
133
- return this.globals.backend.getOwnedMSafeByStatus({
134
- status,
135
- pagination
136
- });
118
+ return this.globals.backend.getOwnedMSafeByStatus({ status, pagination });
137
119
  }
138
120
  async updateMSafeStatus(msafeAddress, status) {
139
- return this.globals.backend.updateMSafeStatus({
140
- msafeAddress,
141
- status
142
- });
121
+ return this.globals.backend.updateMSafeStatus({ msafeAddress, status });
143
122
  }
144
123
  };
145
124
 
146
125
  // src/core/MSafeAccount.ts
147
126
  import { appHelpers } from "@msafe/sui-app-store";
148
- import { MultiSigAccount as MultiSigAccount2, SigningMessageHelper as SigningMessageHelper3, TransactionDefaultApplication, TransactionSubTypes, TransactionType, buildRejectTxb, isSameAddress as isSameAddress2 } from "@msafe/sui3-utils";
127
+ import {
128
+ MultiSigAccount as MultiSigAccount2,
129
+ SigningMessageHelper as SigningMessageHelper3,
130
+ TransactionDefaultApplication,
131
+ TransactionSubTypes,
132
+ TransactionType,
133
+ buildRejectTxb,
134
+ isSameAddress as isSameAddress2
135
+ } from "@msafe/sui3-utils";
149
136
  import { Transaction as Transaction3 } from "@mysten/sui/transactions";
150
137
  import { fromHex, normalizeStructTag as normalizeStructTag3, toHex } from "@mysten/sui/utils";
151
138
  import { SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN } from "@mysten/wallet-standard";
@@ -153,11 +140,18 @@ import { SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN } from "@mysten/wallet-standard";
153
140
  // src/simulate/simulator.ts
154
141
  import { Transaction } from "@mysten/sui/transactions";
155
142
  var GAS_SAFE_OVERHEAD = 1000n;
156
- var Simulator = class {
157
- static {
158
- __name(this, "Simulator");
143
+ function formatExecutionError(error) {
144
+ return error.message;
145
+ }
146
+ function gasObjectToReference(gas) {
147
+ if (!gas?.objectId) {
148
+ throw new Error("Gas object missing from simulation effects");
159
149
  }
160
- globals;
150
+ const version = gas.outputVersion ?? gas.inputVersion ?? "0";
151
+ const digest = gas.outputDigest ?? gas.inputDigest ?? "";
152
+ return { objectId: gas.objectId, version, digest };
153
+ }
154
+ var Simulator = class {
161
155
  constructor(globals) {
162
156
  this.globals = globals;
163
157
  }
@@ -166,32 +160,59 @@ var Simulator = class {
166
160
  const { suiClient } = this.globals;
167
161
  const gasPrice = await this.getGasPrice();
168
162
  tx.setGasPrice(gasPrice);
169
- const inspectResult = await suiClient.dryRunTransactionBlock({
170
- transactionBlock: await tx.build({
171
- client: suiClient
172
- })
173
- });
174
- const success = inspectResult.effects.status.status === "success";
163
+ let built;
164
+ try {
165
+ built = await tx.build({ client: suiClient });
166
+ } catch (e) {
167
+ const message = e instanceof Error ? e.message : String(e);
168
+ return {
169
+ success: false,
170
+ gasPrice,
171
+ simulationError: message
172
+ };
173
+ }
174
+ let inspectResult;
175
+ try {
176
+ inspectResult = await suiClient.simulateTransaction({
177
+ transaction: built,
178
+ include: { effects: true }
179
+ });
180
+ } catch (e) {
181
+ const message = e instanceof Error ? e.message : String(e);
182
+ return {
183
+ success: false,
184
+ gasPrice,
185
+ simulationError: message
186
+ };
187
+ }
188
+ const txRow = inspectResult.Transaction ?? inspectResult.FailedTransaction;
189
+ const { effects } = txRow;
190
+ if (!effects) {
191
+ throw new Error("simulateTransaction did not return effects");
192
+ }
193
+ const success = effects.status.success === true;
175
194
  if (!success) {
195
+ const err = effects.status.success === false ? effects.status.error : null;
176
196
  return {
177
197
  success,
178
198
  gasPrice,
179
199
  response: inspectResult,
180
- simulationError: inspectResult.effects.status.error
200
+ simulationError: err ? formatExecutionError(err) : "Simulation failed"
181
201
  };
182
202
  }
183
- const gasBudget = this.toGasBudget(inspectResult.effects.gasUsed, gasPrice);
203
+ const gasBudget = this.toGasBudget(effects.gasUsed, gasPrice);
184
204
  return {
185
205
  success,
186
206
  gasPrice,
187
- gasObject: inspectResult.effects.gasObject.reference,
188
- gasUsed: inspectResult.effects.gasUsed,
207
+ gasObject: gasObjectToReference(effects.gasObject),
208
+ gasUsed: effects.gasUsed,
189
209
  gasBudget,
190
210
  response: inspectResult
191
211
  };
192
212
  }
193
213
  async getGasPrice() {
194
- return this.globals.suiClient.getReferenceGasPrice();
214
+ const { referenceGasPrice } = await this.globals.suiClient.getReferenceGasPrice();
215
+ return BigInt(referenceGasPrice);
195
216
  }
196
217
  toGasBudget(gasUsed, gasPrice) {
197
218
  const { computationCost, storageCost, storageRebate } = gasUsed;
@@ -206,19 +227,16 @@ var Simulator = class {
206
227
  };
207
228
 
208
229
  // src/utils/buffer.ts
209
- import { Buffer as Buffer2 } from "buffer";
230
+ import { Buffer } from "buffer";
210
231
  function stringToBuffer(s) {
211
- return Buffer2.from(s, "utf-8");
232
+ return Buffer.from(s, "utf-8");
212
233
  }
213
- __name(stringToBuffer, "stringToBuffer");
214
234
  function Uint8ArrayToHex(b) {
215
235
  return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
216
236
  }
217
- __name(Uint8ArrayToHex, "Uint8ArrayToHex");
218
237
  function HexToUint8Array(hex) {
219
- return Uint8Array.from(Buffer2.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
238
+ return Uint8Array.from(Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
220
239
  }
221
- __name(HexToUint8Array, "HexToUint8Array");
222
240
 
223
241
  // src/utils/crypto.ts
224
242
  import { verifyPersonalMessageSignature, verifyTransactionSignature } from "@mysten/sui/verify";
@@ -229,9 +247,6 @@ import { normalizeSuiAddress, normalizeStructTag as normalizeStructTag2 } from "
229
247
  // src/utils/coin.ts
230
248
  import { normalizeStructTag } from "@mysten/sui/utils";
231
249
  var CoinHelper = class {
232
- static {
233
- __name(this, "CoinHelper");
234
- }
235
250
  _client;
236
251
  _coinMetaReg;
237
252
  constructor(client) {
@@ -250,17 +265,12 @@ var CoinHelper = class {
250
265
  return meta;
251
266
  }
252
267
  async queryCoinMeta(coinType) {
253
- const res = await this._client.getCoinMetadata({
254
- coinType
255
- });
256
- return res || void 0;
268
+ const res = await this._client.getCoinMetadata({ coinType });
269
+ return res.coinMetadata ?? void 0;
257
270
  }
258
271
  };
259
272
  var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
260
273
  var Coin = class _Coin {
261
- static {
262
- __name(this, "Coin");
263
- }
264
274
  static isCoin(type) {
265
275
  if (!type) {
266
276
  return false;
@@ -275,6 +285,13 @@ var Coin = class _Coin {
275
285
  if (!_Coin.isCoin(data.type)) {
276
286
  return void 0;
277
287
  }
288
+ if (data.json && typeof data.json === "object" && "balance" in data.json) {
289
+ const { balance: balance2 } = data.json;
290
+ if (balance2 === void 0) {
291
+ return void 0;
292
+ }
293
+ return BigInt(balance2);
294
+ }
278
295
  if (data.content?.dataType !== "moveObject") {
279
296
  return void 0;
280
297
  }
@@ -288,9 +305,6 @@ var Coin = class _Coin {
288
305
 
289
306
  // src/utils/format.ts
290
307
  var Formatter = class {
291
- static {
292
- __name(this, "Formatter");
293
- }
294
308
  static normalizeSuiAddress(addr) {
295
309
  return normalizeSuiAddress(addr);
296
310
  }
@@ -313,13 +327,9 @@ function addPrefix(s, prefix) {
313
327
  }
314
328
  return prefix + s;
315
329
  }
316
- __name(addPrefix, "addPrefix");
317
330
 
318
331
  // src/utils/crypto.ts
319
332
  var SignatureVerifier = class _SignatureVerifier {
320
- static {
321
- __name(this, "SignatureVerifier");
322
- }
323
333
  static async getPublicKeyFromSignature(input) {
324
334
  if (input.messageType === "TransactionBlock") {
325
335
  return verifyTransactionSignature(input.message, input.signature);
@@ -360,29 +370,68 @@ var SignatureVerifier = class _SignatureVerifier {
360
370
  // src/utils/sui.ts
361
371
  import { PublicKeySerde as PublicKeySerde2 } from "@msafe/sui3-utils";
362
372
  import { parseSerializedSignature } from "@mysten/sui/cryptography";
373
+ import { SuiGraphQLClient } from "@mysten/sui/graphql";
363
374
  import { MultiSigPublicKey } from "@mysten/sui/multisig";
364
375
  var SUI_COIN = "0x2::sui::SUI";
376
+ var GRAPHQL_URL_BY_NETWORK = {
377
+ mainnet: "https://sui-mainnet.mystenlabs.com/graphql",
378
+ testnet: "https://sui-testnet.mystenlabs.com/graphql",
379
+ devnet: "https://sui-devnet.mystenlabs.com/graphql"
380
+ };
381
+ function graphqlClientForGrpc(suiClient) {
382
+ const url = GRAPHQL_URL_BY_NETWORK[suiClient.network] ?? GRAPHQL_URL_BY_NETWORK.testnet;
383
+ return new SuiGraphQLClient({ url, network: suiClient.network });
384
+ }
385
+ function collectSignatureStrings(value) {
386
+ if (typeof value === "string") {
387
+ return [value];
388
+ }
389
+ if (!value || typeof value !== "object") {
390
+ return [];
391
+ }
392
+ if ("base64" in value && typeof value.base64 === "string") {
393
+ return [value.base64];
394
+ }
395
+ if ("scheme" in value && "base64" in value) {
396
+ const b64 = value.base64;
397
+ return typeof b64 === "string" ? [b64] : [];
398
+ }
399
+ return [];
400
+ }
401
+ var TX_SIG_QUERY = `
402
+ query PublicKeyTxSigs($sender: SuiAddress!, $first: Int!) {
403
+ transactions(first: $first, filter: { sentAddress: $sender }) {
404
+ nodes {
405
+ signatures
406
+ }
407
+ }
408
+ }
409
+ `;
365
410
  async function getPublicKeyFromChain(suiClient, address) {
411
+ const graphql = graphqlClientForGrpc(suiClient);
366
412
  let txs;
367
413
  try {
368
- txs = await suiClient.queryTransactionBlocks({
369
- // Disable naming rule since the variable is defined by Mysten
370
- filter: {
371
- FromAddress: address
372
- },
373
- options: {
374
- showInput: true
375
- },
376
- limit: 2
414
+ const res = await graphql.query({
415
+ query: TX_SIG_QUERY,
416
+ variables: { sender: address, first: 2 }
377
417
  });
418
+ if (res.errors?.length) {
419
+ return void 0;
420
+ }
421
+ txs = res.data ?? {};
378
422
  } catch (e) {
379
423
  return void 0;
380
424
  }
381
- if (txs.data.length === 0 || !txs.data[0].transaction?.txSignatures) {
425
+ const nodes = txs.transactions?.nodes ?? [];
426
+ if (nodes.length === 0) {
427
+ return void 0;
428
+ }
429
+ const first = nodes[0];
430
+ const rawSigs = first.signatures;
431
+ const signatures = Array.isArray(rawSigs) ? rawSigs.flatMap((item) => collectSignatureStrings(item)) : [];
432
+ if (signatures.length === 0) {
382
433
  return void 0;
383
434
  }
384
- const tx = txs.data[0];
385
- const signatures = tx.transaction?.txSignatures;
386
435
  for (let i = 0; i !== signatures.length; i++) {
387
436
  const serializedSig = signatures[i];
388
437
  const pk = getAddressFromSignatures(serializedSig, address);
@@ -393,7 +442,6 @@ async function getPublicKeyFromChain(suiClient, address) {
393
442
  }
394
443
  return void 0;
395
444
  }
396
- __name(getPublicKeyFromChain, "getPublicKeyFromChain");
397
445
  function getAddressFromSignatures(serializedSig, targetAddress) {
398
446
  const decoded = parseSerializedSignature(serializedSig);
399
447
  switch (decoded.signatureScheme) {
@@ -408,10 +456,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
408
456
  case "ED25519":
409
457
  case "Secp256k1":
410
458
  case "Secp256r1": {
411
- const pk = PublicKeySerde2.de({
412
- publicKeyEncoded: decoded.publicKey,
413
- schema: decoded.signatureScheme
414
- });
459
+ const pk = PublicKeySerde2.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
415
460
  if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
416
461
  return pk;
417
462
  }
@@ -421,24 +466,22 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
421
466
  throw new Error("Unknown schema");
422
467
  }
423
468
  }
424
- __name(getAddressFromSignatures, "getAddressFromSignatures");
425
469
  async function getAllCoins(input) {
426
470
  let hasNext = true;
427
471
  let cursor;
428
472
  const res = [];
429
473
  while (hasNext) {
430
- const currentPage = await input.suiClient.getCoins({
474
+ const currentPage = await input.suiClient.listCoins({
431
475
  owner: input.owner,
432
476
  coinType: input.coinType,
433
477
  cursor
434
478
  });
435
- res.push(...currentPage.data);
479
+ res.push(...currentPage.objects);
436
480
  hasNext = currentPage.hasNextPage;
437
- cursor = currentPage.nextCursor;
481
+ cursor = currentPage.cursor;
438
482
  }
439
483
  return res;
440
484
  }
441
- __name(getAllCoins, "getAllCoins");
442
485
 
443
486
  // src/utils/transaction.ts
444
487
  import { Transaction as Transaction2, isTransaction } from "@mysten/sui/transactions";
@@ -449,7 +492,6 @@ function toSuiTransaction(txb) {
449
492
  const legacy = txb;
450
493
  return Transaction2.from(legacy.serialize());
451
494
  }
452
- __name(toSuiTransaction, "toSuiTransaction");
453
495
 
454
496
  // src/utils/iter/iterator.ts
455
497
  var REQUEST_PAGE_SIZE = 25;
@@ -464,19 +506,14 @@ async function getAllFromIterator(it) {
464
506
  }
465
507
  return res;
466
508
  }
467
- __name(getAllFromIterator, "getAllFromIterator");
468
509
  var PagedIterator = class {
469
- static {
470
- __name(this, "PagedIterator");
471
- }
472
- requester;
473
- curPage;
474
- init;
475
510
  constructor(requester) {
476
511
  this.requester = requester;
477
512
  this.curPage = void 0;
478
513
  this.init = true;
479
514
  }
515
+ curPage;
516
+ init;
480
517
  async hasNext() {
481
518
  if (this.init) {
482
519
  if (!this.curPage) {
@@ -502,19 +539,15 @@ var PagedIterator = class {
502
539
  }
503
540
  };
504
541
  var EntryIterator = class {
505
- static {
506
- __name(this, "EntryIterator");
507
- }
508
- requester;
509
- cursor;
510
- pager;
511
- curData;
512
542
  constructor(requester) {
513
543
  this.requester = requester;
514
544
  this.pager = new PagedIterator(requester);
515
545
  this.curData = [];
516
546
  this.cursor = 0;
517
547
  }
548
+ cursor;
549
+ pager;
550
+ curData;
518
551
  async hasNext() {
519
552
  if (this.cursor < this.curData.length - 1) {
520
553
  return true;
@@ -536,18 +569,15 @@ var EntryIterator = class {
536
569
  };
537
570
 
538
571
  // src/utils/iter/object.ts
572
+ var defaultObjectInclude = { json: true };
573
+ function mergeInclude(options) {
574
+ return { ...defaultObjectInclude, ...options?.objectInclude };
575
+ }
539
576
  async function getAllOwnedObjects(provider, owner, options) {
540
577
  const iter = new OwnedObjectIterator(provider, owner, options);
541
578
  return await getAllFromIterator(iter);
542
579
  }
543
- __name(getAllOwnedObjects, "getAllOwnedObjects");
544
580
  var OwnedObjectIterator = class extends EntryIterator {
545
- static {
546
- __name(this, "OwnedObjectIterator");
547
- }
548
- provider;
549
- owner;
550
- options;
551
581
  constructor(provider, owner, options) {
552
582
  super(new OwnedObjectRequester(provider, owner, options));
553
583
  this.provider = provider;
@@ -556,16 +586,6 @@ var OwnedObjectIterator = class extends EntryIterator {
556
586
  }
557
587
  };
558
588
  var OwnedObjectRequester = class {
559
- static {
560
- __name(this, "OwnedObjectRequester");
561
- }
562
- provider;
563
- owner;
564
- options;
565
- nextCursor;
566
- filter;
567
- pageSize;
568
- objectOptions;
569
589
  constructor(provider, owner, options) {
570
590
  this.provider = provider;
571
591
  this.owner = owner;
@@ -573,28 +593,29 @@ var OwnedObjectRequester = class {
573
593
  this.nextCursor = null;
574
594
  this.filter = options?.filter;
575
595
  this.pageSize = options?.pageSize || REQUEST_PAGE_SIZE;
576
- this.objectOptions = options?.objectOptions || {
577
- showType: true,
578
- showContent: true
579
- };
596
+ this.objectInclude = mergeInclude(options);
580
597
  }
598
+ nextCursor;
599
+ filter;
600
+ pageSize;
601
+ objectInclude;
581
602
  async doNextRequest() {
582
- const res = await this.provider.getOwnedObjects({
603
+ const res = await this.provider.listOwnedObjects({
583
604
  owner: this.owner,
584
- options: this.objectOptions,
605
+ include: this.objectInclude,
585
606
  cursor: this.nextCursor,
586
607
  limit: this.pageSize
587
608
  });
588
- this.nextCursor = res.nextCursor;
609
+ this.nextCursor = res.cursor;
589
610
  let filtered;
590
611
  if (this.filter) {
591
612
  const { filter } = this;
592
- filtered = res.data.filter((obj) => filter?.(obj));
613
+ filtered = res.objects.filter((obj) => filter(obj));
593
614
  } else {
594
- filtered = res.data;
615
+ filtered = res.objects;
595
616
  }
596
617
  return {
597
- data: filtered.map((r) => r.data).filter((data) => data),
618
+ data: filtered,
598
619
  hasNext: res.hasNextPage
599
620
  };
600
621
  }
@@ -602,14 +623,6 @@ var OwnedObjectRequester = class {
602
623
 
603
624
  // src/core/MSafeAccount.ts
604
625
  var MSafeAccount = class _MSafeAccount {
605
- static {
606
- __name(this, "MSafeAccount");
607
- }
608
- globals;
609
- info;
610
- multiSig;
611
- simulator;
612
- coinHelper;
613
626
  constructor(globals, info) {
614
627
  this.globals = globals;
615
628
  this.info = info;
@@ -621,6 +634,9 @@ var MSafeAccount = class _MSafeAccount {
621
634
  this.coinHelper = new CoinHelper(this.suiClient);
622
635
  this.simulator = new Simulator(globals);
623
636
  }
637
+ multiSig;
638
+ simulator;
639
+ coinHelper;
624
640
  static async New(globals, address) {
625
641
  const info = await globals.backend.getMSafeAccountInfo(address);
626
642
  const ms = new _MSafeAccount(globals, info);
@@ -629,31 +645,35 @@ var MSafeAccount = class _MSafeAccount {
629
645
  }
630
646
  }
631
647
  async ownedCoins() {
632
- const balances = await this.suiClient.getAllBalances({
633
- owner: this.address
634
- });
635
- return Promise.all(balances.map(async (balance) => {
636
- const meta = await this.coinHelper.getCoinMeta(balance.coinType);
637
- const lockedEntry = balance.lockedBalance && typeof balance.lockedBalance === "object" && "number" in balance.lockedBalance && balance.lockedBalance.number ? BigInt(balance.lockedBalance.number) : 0n;
638
- const unlockedBalance = lockedEntry ? BigInt(balance.totalBalance) - lockedEntry : BigInt(balance.totalBalance);
639
- return {
640
- type: normalizeStructTag3(balance.coinType),
641
- balance: unlockedBalance,
642
- metadata: meta
643
- };
644
- }));
648
+ const balances = [];
649
+ let cursor = null;
650
+ let hasNext = true;
651
+ while (hasNext) {
652
+ const page = await this.suiClient.listBalances({ owner: this.address, cursor, limit: 50 });
653
+ balances.push(...page.balances);
654
+ hasNext = page.hasNextPage;
655
+ cursor = page.cursor;
656
+ }
657
+ return Promise.all(
658
+ balances.map(async (balance) => {
659
+ const meta = await this.coinHelper.getCoinMeta(balance.coinType);
660
+ return {
661
+ type: normalizeStructTag3(balance.coinType),
662
+ balance: BigInt(balance.addressBalance),
663
+ metadata: meta
664
+ };
665
+ })
666
+ );
645
667
  }
646
668
  async ownedObjects(options) {
647
669
  const filterCoinObjectOptions = {
648
- filter: (objRes) => !objRes?.data?.type?.startsWith("0x2::coin::Coin"),
670
+ filter: (obj) => !obj?.type?.startsWith("0x2::coin::Coin"),
649
671
  ...options
650
672
  };
651
673
  return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
652
674
  }
653
675
  async pendingTransaction() {
654
- const res = await this.backend.getPendingTransactions({
655
- msafeAddress: this.address
656
- });
676
+ const res = await this.backend.getPendingTransactions({ msafeAddress: this.address });
657
677
  if (!res?.pending) {
658
678
  return void 0;
659
679
  }
@@ -685,10 +705,7 @@ var MSafeAccount = class _MSafeAccount {
685
705
  });
686
706
  }
687
707
  async futureIntentions(pagination) {
688
- return this.backend.getFutureIntentions({
689
- msafeAddress: this.address,
690
- ...pagination
691
- });
708
+ return this.backend.getFutureIntentions({ msafeAddress: this.address, ...pagination });
692
709
  }
693
710
  async currentSequenceNumber() {
694
711
  return this.backend.getCurrentSequenceNumber(this.address);
@@ -705,28 +722,24 @@ var MSafeAccount = class _MSafeAccount {
705
722
  if (!appHelper) {
706
723
  throw new Error(`Can't find app helper for application ${request.application}`);
707
724
  }
708
- txb = toSuiTransaction(await appHelper.build({
709
- network: this.globals.config.network,
710
- intentionData: request.intention,
711
- txType: request.txType,
712
- txSubType: request.txSubType,
713
- clientUrl: this.globals.config.suiClient.url,
714
- account: {
715
- address: this.address,
716
- publicKey: fromHex(this.address),
717
- chains: [
718
- SUI_MAINNET_CHAIN,
719
- SUI_TESTNET_CHAIN
720
- ],
721
- features: []
722
- }
723
- }));
725
+ txb = toSuiTransaction(
726
+ await appHelper.build({
727
+ network: this.globals.config.network,
728
+ intentionData: request.intention,
729
+ txType: request.txType,
730
+ txSubType: request.txSubType,
731
+ clientUrl: this.globals.config.suiClient.url,
732
+ account: {
733
+ address: this.address,
734
+ publicKey: fromHex(this.address),
735
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
736
+ features: []
737
+ }
738
+ })
739
+ );
724
740
  }
725
741
  txb.setSender(this.address);
726
- return this.simulator.simulate({
727
- txb,
728
- sender: this.address
729
- });
742
+ return this.simulator.simulate({ txb, sender: this.address });
730
743
  }
731
744
  async proposeIntention(input) {
732
745
  const message = SigningMessageHelper3.proposeIntentionMessage({
@@ -752,35 +765,28 @@ var MSafeAccount = class _MSafeAccount {
752
765
  if (!appHelper) {
753
766
  throw new Error(`Can't find app helper for application ${input.application}`);
754
767
  }
755
- txb = toSuiTransaction(await appHelper.build({
756
- network: this.globals.config.network,
757
- intentionData: input.intention,
758
- txType: input.txType,
759
- txSubType: input.txSubType,
760
- clientUrl: this.globals.config.suiClient.url,
761
- account: {
762
- address: this.address,
763
- publicKey: fromHex(this.address),
764
- chains: [
765
- SUI_MAINNET_CHAIN,
766
- SUI_TESTNET_CHAIN
767
- ],
768
- features: []
769
- }
770
- }));
768
+ txb = toSuiTransaction(
769
+ await appHelper.build({
770
+ network: this.globals.config.network,
771
+ intentionData: input.intention,
772
+ txType: input.txType,
773
+ txSubType: input.txSubType,
774
+ clientUrl: this.globals.config.suiClient.url,
775
+ account: {
776
+ address: this.address,
777
+ publicKey: fromHex(this.address),
778
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
779
+ features: []
780
+ }
781
+ })
782
+ );
771
783
  }
772
784
  txb.setGasPrice(input.gasPrice);
773
785
  txb.setGasBudget(input.gasBudget);
774
786
  txb.setSender(this.address);
775
- const payload = await txb.build({
776
- client: this.globals.suiClient
777
- });
778
- const digest = await txb.getDigest({
779
- client: this.globals.suiClient
780
- });
781
- const signature = await this.wallet.signTransactionBlock({
782
- transactionBlock: payload
783
- });
787
+ const payload = await txb.build({ client: this.globals.suiClient });
788
+ const digest = await txb.getDigest({ client: this.globals.suiClient });
789
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
784
790
  return this.backend.proposeIntentionAndBuildVote({
785
791
  ...input,
786
792
  payload: toHex(payload),
@@ -856,9 +862,7 @@ var MSafeAccount = class _MSafeAccount {
856
862
  }
857
863
  async voteForTransaction(digest, payload) {
858
864
  const payloadBytes = HexToUint8Array(payload);
859
- const signature = await this.wallet.signTransactionBlock({
860
- transactionBlock: payloadBytes
861
- });
865
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payloadBytes });
862
866
  return this.backend.voteForTransaction({
863
867
  msafeAddress: this.address,
864
868
  digest,
@@ -872,10 +876,7 @@ var MSafeAccount = class _MSafeAccount {
872
876
  }
873
877
  const txb = toSuiTransaction(buildRejectTxb(this.address));
874
878
  txb.setSender(this.address);
875
- return this.simulator.simulate({
876
- txb,
877
- sender: this.address
878
- });
879
+ return this.simulator.simulate({ txb, sender: this.address });
879
880
  }
880
881
  async rejectCurrentTx(input) {
881
882
  const pendingTx = await this.pendingTransaction();
@@ -883,15 +884,9 @@ var MSafeAccount = class _MSafeAccount {
883
884
  throw new Error("Already rejected");
884
885
  }
885
886
  const rejectTxb = toSuiTransaction(buildRejectTxb(this.address));
886
- const digest = await rejectTxb.getDigest({
887
- client: this.suiClient
888
- });
889
- const payload = await rejectTxb.build({
890
- client: this.suiClient
891
- });
892
- const signature = await this.wallet.signTransactionBlock({
893
- transactionBlock: payload
894
- });
887
+ const digest = await rejectTxb.getDigest({ client: this.suiClient });
888
+ const payload = await rejectTxb.build({ client: this.suiClient });
889
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
895
890
  return this.backend.rejectCurrentTx({
896
891
  msafeAddress: this.address,
897
892
  digest,
@@ -900,34 +895,28 @@ var MSafeAccount = class _MSafeAccount {
900
895
  });
901
896
  }
902
897
  async simulateBuildTransaction() {
903
- const intention = await this.backend.getNextIntention({
904
- msafeAddress: this.address
905
- });
898
+ const intention = await this.backend.getNextIntention({ msafeAddress: this.address });
906
899
  const appHelper = appHelpers.getAppHelper(intention.application);
907
900
  if (!appHelper) {
908
901
  throw new Error(`Can't find app helper for application ${intention.application}`);
909
902
  }
910
- const txb = toSuiTransaction(await appHelper.build({
911
- network: this.globals.config.network,
912
- intentionData: intention.intention,
913
- txType: intention.txType,
914
- txSubType: intention.txSubType,
915
- clientUrl: this.globals.config.suiClient.url,
916
- account: {
917
- address: this.address,
918
- publicKey: fromHex(this.address),
919
- chains: [
920
- SUI_MAINNET_CHAIN,
921
- SUI_TESTNET_CHAIN
922
- ],
923
- features: []
924
- }
925
- }));
903
+ const txb = toSuiTransaction(
904
+ await appHelper.build({
905
+ network: this.globals.config.network,
906
+ intentionData: intention.intention,
907
+ txType: intention.txType,
908
+ txSubType: intention.txSubType,
909
+ clientUrl: this.globals.config.suiClient.url,
910
+ account: {
911
+ address: this.address,
912
+ publicKey: fromHex(this.address),
913
+ chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
914
+ features: []
915
+ }
916
+ })
917
+ );
926
918
  txb.setSender(this.address);
927
- return this.simulator.simulate({
928
- txb,
929
- sender: this.address
930
- });
919
+ return this.simulator.simulate({ txb, sender: this.address });
931
920
  }
932
921
  async buildNextIntentionAndAddToPending(gasOption) {
933
922
  return this.backend.buildNextIntentionAndAddToPending({
@@ -938,14 +927,10 @@ var MSafeAccount = class _MSafeAccount {
938
927
  });
939
928
  }
940
929
  async skipNextFailedIntention() {
941
- return this.backend.skipNextFailedIntention({
942
- msafeAddress: this.address
943
- });
930
+ return this.backend.skipNextFailedIntention({ msafeAddress: this.address });
944
931
  }
945
932
  async fetchTransaction() {
946
- return this.backend.fetchTransaction({
947
- msafeAddress: this.address
948
- });
933
+ return this.backend.fetchTransaction({ msafeAddress: this.address });
949
934
  }
950
935
  async executePendingTx(pending, isRejectTx = false) {
951
936
  const votes = isRejectTx ? pending.rejectVotes : pending.votes;
@@ -954,10 +939,7 @@ var MSafeAccount = class _MSafeAccount {
954
939
  throw new Error("Not enough signature");
955
940
  }
956
941
  const sortedSigs = [];
957
- const gotSigs = new Map(votes.map((vote) => [
958
- vote.userAddress,
959
- vote.signature
960
- ]));
942
+ const gotSigs = new Map(votes.map((vote) => [vote.userAddress, vote.signature]));
961
943
  for (let i = 0; i < this.info.owners.length; i++) {
962
944
  const owner = this.info.owners[i];
963
945
  const signature = gotSigs.get(owner.address);
@@ -966,13 +948,10 @@ var MSafeAccount = class _MSafeAccount {
966
948
  }
967
949
  }
968
950
  const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
969
- return this.suiClient.executeTransactionBlock({
970
- transactionBlock: HexToUint8Array(payload),
971
- signature: multiSignature,
972
- options: {
973
- showEffects: true,
974
- showEvents: true
975
- }
951
+ return this.suiClient.executeTransaction({
952
+ transaction: HexToUint8Array(payload),
953
+ signatures: [multiSignature],
954
+ include: { effects: true, events: true }
976
955
  });
977
956
  }
978
957
  async dashboard() {
@@ -1014,15 +993,11 @@ var MSafeAccount = class _MSafeAccount {
1014
993
  import { isSameAddress as isSameAddress3 } from "@msafe/sui3-utils";
1015
994
  import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui/utils";
1016
995
  var PublicKeyHelper = class {
1017
- static {
1018
- __name(this, "PublicKeyHelper");
1019
- }
1020
- globals;
1021
- knownPublicKeys;
1022
996
  constructor(globals) {
1023
997
  this.globals = globals;
1024
998
  this.knownPublicKeys = /* @__PURE__ */ new Map();
1025
999
  }
1000
+ knownPublicKeys;
1026
1001
  async getPublicKey(address) {
1027
1002
  const cached = this.knownPublicKeys.get(address);
1028
1003
  if (cached) {
@@ -1093,10 +1068,6 @@ var PublicKeyHelper = class {
1093
1068
 
1094
1069
  // src/core/ReportSDK.ts
1095
1070
  var ReportSDK = class {
1096
- static {
1097
- __name(this, "ReportSDK");
1098
- }
1099
- globals;
1100
1071
  constructor(globals) {
1101
1072
  this.globals = globals;
1102
1073
  }
@@ -1106,22 +1077,20 @@ var ReportSDK = class {
1106
1077
  };
1107
1078
 
1108
1079
  // src/globals/MSafeGlobals.ts
1109
- import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
1080
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
1110
1081
 
1111
1082
  // src/backend/BackendImpl.ts
1112
- import { PublicKeySerde as PublicKeySerde3, UserMSafeStatus } from "@msafe/sui3-utils";
1083
+ import {
1084
+ PublicKeySerde as PublicKeySerde3,
1085
+ UserMSafeStatus
1086
+ } from "@msafe/sui3-utils";
1113
1087
  import axios from "axios";
1114
1088
  var BackendImpl = class _BackendImpl {
1115
- static {
1116
- __name(this, "BackendImpl");
1117
- }
1118
- apiURL;
1119
- mockAddress;
1120
- _token;
1121
1089
  constructor(apiURL, mockAddress) {
1122
1090
  this.apiURL = apiURL;
1123
1091
  this.mockAddress = mockAddress;
1124
1092
  }
1093
+ _token;
1125
1094
  getNotificationInfo() {
1126
1095
  return this.get(`/notification`, {
1127
1096
  headers: this.headers()
@@ -1144,9 +1113,7 @@ var BackendImpl = class _BackendImpl {
1144
1113
  }
1145
1114
  async verifyToken(jwt) {
1146
1115
  try {
1147
- const res = await this.get(`/auth`, {
1148
- headers: this.headers(jwt)
1149
- });
1116
+ const res = await this.get(`/auth`, { headers: this.headers(jwt) });
1150
1117
  return res.status === 200;
1151
1118
  } catch (_) {
1152
1119
  return false;
@@ -1156,9 +1123,7 @@ var BackendImpl = class _BackendImpl {
1156
1123
  this._token = token;
1157
1124
  }
1158
1125
  async getPublicKey(address) {
1159
- return (await this.getPublicKeyBatch([
1160
- address
1161
- ]))[0];
1126
+ return (await this.getPublicKeyBatch([address]))[0];
1162
1127
  }
1163
1128
  async getPublicKeyBatch(addresses) {
1164
1129
  const query = {
@@ -1168,7 +1133,9 @@ var BackendImpl = class _BackendImpl {
1168
1133
  params: query,
1169
1134
  headers: this.headers()
1170
1135
  });
1171
- return res.data?.map((publicKeyWithSchema) => publicKeyWithSchema ? PublicKeySerde3.de(publicKeyWithSchema) : void 0);
1136
+ return res.data?.map(
1137
+ (publicKeyWithSchema) => publicKeyWithSchema ? PublicKeySerde3.de(publicKeyWithSchema) : void 0
1138
+ );
1172
1139
  }
1173
1140
  async getMSafeAccountInfo(msafeAddress) {
1174
1141
  const q = {
@@ -1205,9 +1172,7 @@ var BackendImpl = class _BackendImpl {
1205
1172
  }
1206
1173
  async updateMSafeStatus(input) {
1207
1174
  const p = input;
1208
- await this.post(`/msafe/status`, p, {
1209
- headers: this.headers()
1210
- });
1175
+ await this.post(`/msafe/status`, p, { headers: this.headers() });
1211
1176
  }
1212
1177
  async getPendingTransactions(input) {
1213
1178
  const res = await this.get(`/transaction/pending`, {
@@ -1261,18 +1226,16 @@ var BackendImpl = class _BackendImpl {
1261
1226
  });
1262
1227
  }
1263
1228
  async proposeIntention(input) {
1264
- await this.post(`/transaction/intention`, input, {
1265
- headers: this.headers()
1266
- });
1229
+ await this.post(`/transaction/intention`, input, { headers: this.headers() });
1267
1230
  }
1268
1231
  async rejectCurrentTx(input) {
1269
- await this.post(`/transaction/pending/reject`, {
1270
- ...input,
1271
- gasPrice: input.gasPrice.toString(),
1272
- gasBudget: input.gasBudget.toString()
1273
- }, {
1274
- headers: this.headers()
1275
- });
1232
+ await this.post(
1233
+ `/transaction/pending/reject`,
1234
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1235
+ {
1236
+ headers: this.headers()
1237
+ }
1238
+ );
1276
1239
  }
1277
1240
  async voteForTransaction(input) {
1278
1241
  await this.post(`/transaction/pending/vote`, input, {
@@ -1280,32 +1243,24 @@ var BackendImpl = class _BackendImpl {
1280
1243
  });
1281
1244
  }
1282
1245
  async buildNextIntentionAndAddToPending(input) {
1283
- await this.post(`/transaction/pending/build`, {
1284
- ...input,
1285
- gasPrice: input.gasPrice.toString(),
1286
- gasBudget: input.gasBudget.toString()
1287
- }, {
1288
- headers: this.headers()
1289
- });
1246
+ await this.post(
1247
+ `/transaction/pending/build`,
1248
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1249
+ { headers: this.headers() }
1250
+ );
1290
1251
  }
1291
1252
  async proposeIntentionAndBuildVote(input) {
1292
- await this.post(`/transaction/intention/build`, {
1293
- ...input,
1294
- gasPrice: input.gasPrice.toString(),
1295
- gasBudget: input.gasBudget.toString()
1296
- }, {
1297
- headers: this.headers()
1298
- });
1253
+ await this.post(
1254
+ `/transaction/intention/build`,
1255
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1256
+ { headers: this.headers() }
1257
+ );
1299
1258
  }
1300
1259
  async skipNextFailedIntention(input) {
1301
- await this.post(`/transaction/pending/skip`, input, {
1302
- headers: this.headers()
1303
- });
1260
+ await this.post(`/transaction/pending/skip`, input, { headers: this.headers() });
1304
1261
  }
1305
1262
  async fetchTransaction(input) {
1306
- const res = await this.post(`/transaction/fetch`, input, {
1307
- headers: this.headers()
1308
- });
1263
+ const res = await this.post(`/transaction/fetch`, input, { headers: this.headers() });
1309
1264
  return res.data;
1310
1265
  }
1311
1266
  async getAddressBookEntries(pagination) {
@@ -1316,22 +1271,14 @@ var BackendImpl = class _BackendImpl {
1316
1271
  return res.data;
1317
1272
  }
1318
1273
  async updateAddressBook(input) {
1319
- await this.post(`/address-book`, input, {
1320
- headers: this.headers()
1321
- });
1274
+ await this.post(`/address-book`, input, { headers: this.headers() });
1322
1275
  }
1323
1276
  async getAddressBookMode() {
1324
- const res = await this.get("/address-book/mode", {
1325
- headers: this.headers()
1326
- });
1277
+ const res = await this.get("/address-book/mode", { headers: this.headers() });
1327
1278
  return res.data;
1328
1279
  }
1329
1280
  async setAddressBookMode(input) {
1330
- await this.post("/address-book/mode", {
1331
- mode: input.mode
1332
- }, {
1333
- headers: this.headers()
1334
- });
1281
+ await this.post("/address-book/mode", { mode: input.mode }, { headers: this.headers() });
1335
1282
  }
1336
1283
  async submitReport(report) {
1337
1284
  await this.post("/report", report);
@@ -1344,10 +1291,7 @@ var BackendImpl = class _BackendImpl {
1344
1291
  return res.data;
1345
1292
  }
1346
1293
  headers(token) {
1347
- return {
1348
- Authorization: `Bearer ${token || this._token}`,
1349
- "sui-mock-user": this.mockAddress
1350
- };
1294
+ return { Authorization: `Bearer ${token || this._token}`, "sui-mock-user": this.mockAddress };
1351
1295
  }
1352
1296
  static toMSafeConfig(resp) {
1353
1297
  return {
@@ -1403,9 +1347,7 @@ var BackendImpl = class _BackendImpl {
1403
1347
  } else if (transformRequest instanceof Array) {
1404
1348
  transformRequests = transformRequest;
1405
1349
  } else {
1406
- transformRequests = [
1407
- transformRequest
1408
- ];
1350
+ transformRequests = [transformRequest];
1409
1351
  }
1410
1352
  return [
1411
1353
  (d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
@@ -1414,10 +1356,6 @@ var BackendImpl = class _BackendImpl {
1414
1356
  }
1415
1357
  };
1416
1358
  var BackendError = class _BackendError extends Error {
1417
- static {
1418
- __name(this, "BackendError");
1419
- }
1420
- e;
1421
1359
  constructor(e) {
1422
1360
  super();
1423
1361
  this.e = e;
@@ -1454,15 +1392,24 @@ var BackendError = class _BackendError extends Error {
1454
1392
  function msafeChainToSuiNetwork(chain) {
1455
1393
  return chain === "sui:mainnet" ? "mainnet" : "testnet";
1456
1394
  }
1457
- __name(msafeChainToSuiNetwork, "msafeChainToSuiNetwork");
1458
- var MSafeEnv;
1459
- (function(MSafeEnv2) {
1460
- MSafeEnv2["local"] = "local";
1461
- MSafeEnv2["unit"] = "unit";
1462
- MSafeEnv2["dev"] = "dev";
1463
- MSafeEnv2["prev"] = "prev";
1464
- MSafeEnv2["prod"] = "prod";
1465
- })(MSafeEnv || (MSafeEnv = {}));
1395
+ var MSafeEnv = /* @__PURE__ */ ((MSafeEnv3) => {
1396
+ MSafeEnv3["local"] = "local";
1397
+ MSafeEnv3["unit"] = "unit";
1398
+ MSafeEnv3["dev"] = "dev";
1399
+ MSafeEnv3["prev"] = "prev";
1400
+ MSafeEnv3["prod"] = "prod";
1401
+ return MSafeEnv3;
1402
+ })(MSafeEnv || {});
1403
+ function httpUrlToGrpcBaseUrl(url) {
1404
+ const parsed = new URL(url);
1405
+ if (parsed.protocol === "https:" && parsed.port === "") {
1406
+ return `https://${parsed.hostname}:443${parsed.pathname}${parsed.search}`;
1407
+ }
1408
+ if (parsed.protocol === "http:" && parsed.port === "") {
1409
+ return `http://${parsed.hostname}:80${parsed.pathname}${parsed.search}`;
1410
+ }
1411
+ return `${parsed.origin}${parsed.pathname}${parsed.search}`;
1412
+ }
1466
1413
  var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
1467
1414
  var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
1468
1415
  var LOCAL_API_URL = "http://127.0.0.1:3000";
@@ -1473,20 +1420,20 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
1473
1420
  var PROD_API_URL = "https://sui.m-safe.link";
1474
1421
  var ENV_CONFIGS = /* @__PURE__ */ new Map([
1475
1422
  [
1476
- "unit",
1423
+ "unit" /* unit */,
1477
1424
  {
1478
1425
  suiClient: {
1479
1426
  url: TESTNET_RPC_URL
1480
1427
  },
1481
1428
  backend: {
1482
- url: LOCAL_API_URL
1429
+ url: DEV_API_URL
1483
1430
  },
1484
- syncingURL: LOCAL_SYNCING_URL,
1431
+ syncingURL: DEV_SYNCING_URL,
1485
1432
  network: "sui:testnet"
1486
1433
  }
1487
1434
  ],
1488
1435
  [
1489
- "local",
1436
+ "local" /* local */,
1490
1437
  {
1491
1438
  suiClient: {
1492
1439
  url: TESTNET_RPC_URL
@@ -1499,7 +1446,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1499
1446
  }
1500
1447
  ],
1501
1448
  [
1502
- "dev",
1449
+ "dev" /* dev */,
1503
1450
  {
1504
1451
  suiClient: {
1505
1452
  url: TESTNET_RPC_URL
@@ -1512,7 +1459,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1512
1459
  }
1513
1460
  ],
1514
1461
  [
1515
- "prev",
1462
+ "prev" /* prev */,
1516
1463
  {
1517
1464
  suiClient: {
1518
1465
  url: MAINNET_RPC_URL
@@ -1525,7 +1472,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1525
1472
  }
1526
1473
  ],
1527
1474
  [
1528
- "prod",
1475
+ "prod" /* prod */,
1529
1476
  {
1530
1477
  suiClient: {
1531
1478
  url: MAINNET_RPC_URL
@@ -1554,13 +1501,9 @@ function getMSafeConfig(env, options) {
1554
1501
  }
1555
1502
  return config;
1556
1503
  }
1557
- __name(getMSafeConfig, "getMSafeConfig");
1558
1504
 
1559
1505
  // src/globals/MSafeGlobals.ts
1560
1506
  var MSafeGlobals = class _MSafeGlobals {
1561
- static {
1562
- __name(this, "MSafeGlobals");
1563
- }
1564
1507
  backend;
1565
1508
  suiClient;
1566
1509
  config;
@@ -1572,12 +1515,11 @@ var MSafeGlobals = class _MSafeGlobals {
1572
1515
  }
1573
1516
  static async New(env, options) {
1574
1517
  const config = getMSafeConfig(env, options);
1575
- const suiClient = new SuiJsonRpcClient({
1576
- ...config.suiClient.transport ? {
1577
- transport: config.suiClient.transport
1578
- } : {
1579
- url: config.suiClient.url
1580
- },
1518
+ const suiClient = config.suiClient.transport ? new SuiGrpcClient({
1519
+ transport: config.suiClient.transport,
1520
+ network: msafeChainToSuiNetwork(config.network)
1521
+ }) : new SuiGrpcClient({
1522
+ baseUrl: httpUrlToGrpcBaseUrl(config.suiClient.url),
1581
1523
  network: msafeChainToSuiNetwork(config.network)
1582
1524
  });
1583
1525
  const backend = new BackendImpl(config.backend.url, options?.mockAddress);
@@ -1603,15 +1545,11 @@ var MSafeGlobals = class _MSafeGlobals {
1603
1545
 
1604
1546
  // src/core/MSafeClient.ts
1605
1547
  var MSafeClient = class _MSafeClient {
1606
- static {
1607
- __name(this, "MSafeClient");
1608
- }
1609
- globals;
1610
- _creationHelper;
1611
- _publicKeyHelper;
1612
1548
  constructor(globals) {
1613
1549
  this.globals = globals;
1614
1550
  }
1551
+ _creationHelper;
1552
+ _publicKeyHelper;
1615
1553
  static async New(env, options) {
1616
1554
  const globals = await MSafeGlobals.New(env, options);
1617
1555
  return new _MSafeClient(globals);
@@ -1646,10 +1584,7 @@ var MSafeClient = class _MSafeClient {
1646
1584
  return this.globals.backend.getUserInfo();
1647
1585
  }
1648
1586
  async ownedMSafe(pagination) {
1649
- return this.globals.backend.getOwnedMSafeByStatus({
1650
- status: UserMSafeStatus2.active,
1651
- pagination
1652
- });
1587
+ return this.globals.backend.getOwnedMSafeByStatus({ status: UserMSafeStatus2.active, pagination });
1653
1588
  }
1654
1589
  async createAccount(info) {
1655
1590
  return this.creationHelper.submitMSafeCreation(info);
@@ -1699,38 +1634,26 @@ var MSafeClient = class _MSafeClient {
1699
1634
  };
1700
1635
 
1701
1636
  // src/backend/types/notification.ts
1702
- var InfoTypeKey;
1703
- (function(InfoTypeKey2) {
1637
+ var InfoTypeKey = /* @__PURE__ */ ((InfoTypeKey2) => {
1704
1638
  InfoTypeKey2["receive"] = "info_type_receive";
1705
1639
  InfoTypeKey2["send"] = "info_type_send";
1706
1640
  InfoTypeKey2["invitation"] = "info_type_invitation";
1707
1641
  InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
1708
- })(InfoTypeKey || (InfoTypeKey = {}));
1642
+ return InfoTypeKey2;
1643
+ })(InfoTypeKey || {});
1709
1644
  var NotificationSubscribeDto = class {
1710
- static {
1711
- __name(this, "NotificationSubscribeDto");
1712
- }
1713
1645
  email;
1714
1646
  };
1715
1647
  var NotificationUpdateDto = class {
1716
- static {
1717
- __name(this, "NotificationUpdateDto");
1718
- }
1719
1648
  email;
1720
1649
  infoTypes;
1721
1650
  msafeEnabled;
1722
1651
  };
1723
1652
  var InfoTypeEnabledDto = class {
1724
- static {
1725
- __name(this, "InfoTypeEnabledDto");
1726
- }
1727
1653
  infoType;
1728
1654
  enabled;
1729
1655
  };
1730
1656
  var MSafeEnabledDto = class {
1731
- static {
1732
- __name(this, "MSafeEnabledDto");
1733
- }
1734
1657
  msafeAddress;
1735
1658
  enabled;
1736
1659
  };
@@ -1767,6 +1690,7 @@ export {
1767
1690
  getAllCoins,
1768
1691
  getMSafeConfig,
1769
1692
  getPublicKeyFromChain,
1693
+ httpUrlToGrpcBaseUrl,
1770
1694
  msafeChainToSuiNetwork,
1771
1695
  stringToBuffer,
1772
1696
  toSuiTransaction