@msafe/sui3-sdk 1.0.6 → 1.0.7

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