@msafe/sui3-sdk 1.0.14 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
8
  var __export = (target, all) => {
10
9
  for (var name in all)
11
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -32,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
31
  var src_exports = {};
33
32
  __export(src_exports, {
34
33
  AddressBookSDK: () => AddressBookSDK,
34
+ COIN_RESERVATION_MAGIC: () => COIN_RESERVATION_MAGIC,
35
35
  COIN_TYPE_ARG_REGEX: () => COIN_TYPE_ARG_REGEX,
36
36
  Coin: () => Coin,
37
37
  CoinHelper: () => CoinHelper,
@@ -43,6 +43,7 @@ __export(src_exports, {
43
43
  HexToUint8Array: () => HexToUint8Array,
44
44
  InfoTypeEnabledDto: () => InfoTypeEnabledDto,
45
45
  InfoTypeKey: () => InfoTypeKey,
46
+ InsufficientGasFundsError: () => InsufficientGasFundsError,
46
47
  LOCAL_API_URL: () => LOCAL_API_URL,
47
48
  LOCAL_SYNCING_URL: () => LOCAL_SYNCING_URL,
48
49
  MAINNET_RPC_URL: () => MAINNET_RPC_URL,
@@ -60,11 +61,18 @@ __export(src_exports, {
60
61
  TESTNET_RPC_URL: () => TESTNET_RPC_URL,
61
62
  Uint8ArrayToHex: () => Uint8ArrayToHex,
62
63
  addPrefix: () => addPrefix,
64
+ computeGasBudget: () => computeGasBudget,
65
+ createCoinReservationRef: () => createCoinReservationRef,
66
+ estimateGasBudget: () => estimateGasBudget,
63
67
  getAllCoins: () => getAllCoins,
64
68
  getMSafeConfig: () => getMSafeConfig,
65
69
  getPublicKeyFromChain: () => getPublicKeyFromChain,
66
70
  httpUrlToGrpcBaseUrl: () => httpUrlToGrpcBaseUrl,
71
+ isCoinReservationDigest: () => isCoinReservationDigest,
67
72
  msafeChainToSuiNetwork: () => msafeChainToSuiNetwork,
73
+ preferClassicGasPayment: () => preferClassicGasPayment,
74
+ prepareGasFunding: () => prepareGasFunding,
75
+ selectGasFunding: () => selectGasFunding,
68
76
  stringToBuffer: () => stringToBuffer,
69
77
  toSuiTransaction: () => toSuiTransaction
70
78
  });
@@ -73,11 +81,6 @@ module.exports = __toCommonJS(src_exports);
73
81
  // src/core/CreateHelper.ts
74
82
  var import_sui3_utils = require("@msafe/sui3-utils");
75
83
  var CreateHelper = class {
76
- static {
77
- __name(this, "CreateHelper");
78
- }
79
- globals;
80
- pkHelper;
81
84
  constructor(globals, pkHelper) {
82
85
  this.globals = globals;
83
86
  this.pkHelper = pkHelper;
@@ -95,13 +98,13 @@ var CreateHelper = class {
95
98
  return this.calculateMSafeAddress(createInfo);
96
99
  }
97
100
  /**
98
- * Add user manually added public key for an address. If user input the public key with
99
- * extra signature scheme flag, the scheme value will be automatically fixed.
100
- *
101
- * @param address
102
- * @param pkEncoded
103
- * @throws error if the public key does not match
104
- */
101
+ * Add user manually added public key for an address. If user input the public key with
102
+ * extra signature scheme flag, the scheme value will be automatically fixed.
103
+ *
104
+ * @param address
105
+ * @param pkEncoded
106
+ * @throws error if the public key does not match
107
+ */
105
108
  addPublicKey(address, pkEncoded) {
106
109
  const pk = import_sui3_utils.PublicKeySerde.de(pkEncoded);
107
110
  if (!(0, import_sui3_utils.isSameAddress)(address, pk.toSuiAddress())) {
@@ -112,9 +115,7 @@ var CreateHelper = class {
112
115
  async submitMSafeCreation(creationInfo) {
113
116
  const msafeAddress = await this.validateCreateInfo(creationInfo);
114
117
  const signingMessage = import_sui3_utils.SigningMessageHelper.createMSafeMessage(msafeAddress);
115
- const signature = await this.globals.wallet.signPersonalMessage({
116
- messageStr: signingMessage
117
- });
118
+ const signature = await this.globals.wallet.signPersonalMessage({ messageStr: signingMessage });
118
119
  await this.submitToBackend(creationInfo, signature.signature);
119
120
  return msafeAddress;
120
121
  }
@@ -145,7 +146,9 @@ var CreateHelper = class {
145
146
  })),
146
147
  threshold: createInfo.threshold,
147
148
  name: createInfo.name,
149
+ // name validation is deferred to backend
148
150
  description: createInfo.description,
151
+ // description validation is deferred to backend
149
152
  creationNonce: createInfo.creationNonce,
150
153
  signature
151
154
  });
@@ -158,10 +161,6 @@ var import_sui3_utils7 = require("@msafe/sui3-utils");
158
161
  // src/core/AddressBookSDK.ts
159
162
  var import_sui3_utils2 = require("@msafe/sui3-utils");
160
163
  var AddressBookSDK = class {
161
- static {
162
- __name(this, "AddressBookSDK");
163
- }
164
- globals;
165
164
  constructor(globals) {
166
165
  this.globals = globals;
167
166
  }
@@ -170,192 +169,122 @@ var AddressBookSDK = class {
170
169
  }
171
170
  async update(updates) {
172
171
  const messageStr = import_sui3_utils2.SigningMessageHelper.updateAddressBookMessage(updates);
173
- const sig = await this.globals.wallet.signPersonalMessage({
174
- messageStr
175
- });
176
- return this.globals.backend.updateAddressBook({
177
- updates,
178
- signature: sig.signature
179
- });
172
+ const sig = await this.globals.wallet.signPersonalMessage({ messageStr });
173
+ return this.globals.backend.updateAddressBook({ updates, signature: sig.signature });
180
174
  }
181
175
  async getMode() {
182
176
  const res = await this.globals.backend.getAddressBookMode();
183
177
  return res.mode;
184
178
  }
185
179
  async setMode(mode) {
186
- return this.globals.backend.setAddressBookMode({
187
- mode
188
- });
180
+ return this.globals.backend.setAddressBookMode({ mode });
189
181
  }
190
182
  };
191
183
 
192
184
  // src/core/InvitationSDK.ts
193
185
  var InvitationSDK = class {
194
- static {
195
- __name(this, "InvitationSDK");
196
- }
197
- globals;
198
186
  constructor(globals) {
199
187
  this.globals = globals;
200
188
  }
201
189
  async getMSafeByStatus(status, pagination) {
202
- return this.globals.backend.getOwnedMSafeByStatus({
203
- status,
204
- pagination
205
- });
190
+ return this.globals.backend.getOwnedMSafeByStatus({ status, pagination });
206
191
  }
207
192
  async updateMSafeStatus(msafeAddress, status) {
208
- return this.globals.backend.updateMSafeStatus({
209
- msafeAddress,
210
- status
211
- });
193
+ return this.globals.backend.updateMSafeStatus({ msafeAddress, status });
212
194
  }
213
195
  };
214
196
 
215
197
  // src/core/MSafeAccount.ts
216
198
  var import_sui_app_store = require("@msafe/sui-app-store");
217
199
  var import_sui3_utils4 = require("@msafe/sui3-utils");
218
- var import_transactions3 = require("@mysten/sui/transactions");
219
- var import_utils3 = require("@mysten/sui/utils");
200
+ var import_transactions4 = require("@mysten/sui/transactions");
201
+ var import_utils5 = require("@mysten/sui/utils");
220
202
  var import_wallet_standard = require("@mysten/wallet-standard");
221
203
 
222
204
  // src/simulate/simulator.ts
205
+ var import_transactions2 = require("@mysten/sui/transactions");
206
+
207
+ // src/utils/gasFunding.ts
223
208
  var import_transactions = require("@mysten/sui/transactions");
224
- var GAS_SAFE_OVERHEAD = 1000n;
225
- function formatExecutionError(error) {
226
- return error.message;
227
- }
228
- __name(formatExecutionError, "formatExecutionError");
229
- function gasObjectToReference(gas) {
230
- if (!gas?.objectId) {
231
- throw new Error("Gas object missing from simulation effects");
232
- }
233
- const version = gas.outputVersion ?? gas.inputVersion ?? "0";
234
- const digest = gas.outputDigest ?? gas.inputDigest ?? "";
235
- return {
236
- objectId: gas.objectId,
237
- version,
238
- digest
239
- };
240
- }
241
- __name(gasObjectToReference, "gasObjectToReference");
242
- var Simulator = class {
243
- static {
244
- __name(this, "Simulator");
245
- }
246
- globals;
247
- constructor(globals) {
248
- this.globals = globals;
249
- }
250
- async simulate(input) {
251
- const tx = this.copyTransaction(input.txb);
252
- const { suiClient } = this.globals;
253
- const gasPrice = await this.getGasPrice();
254
- tx.setGasPrice(gasPrice);
255
- tx.setSender(input.sender);
256
- let built;
257
- try {
258
- built = await tx.build({
259
- client: suiClient
260
- });
261
- } catch (e) {
262
- const message = e instanceof Error ? e.message : String(e);
263
- return {
264
- success: false,
265
- gasPrice,
266
- simulationError: message
267
- };
268
- }
269
- let inspectResult;
270
- try {
271
- inspectResult = await suiClient.simulateTransaction({
272
- transaction: built,
273
- include: {
274
- effects: true,
275
- balanceChanges: true,
276
- events: true,
277
- objectTypes: true,
278
- transaction: true,
279
- bcs: true,
280
- commandResults: true
281
- }
282
- });
283
- } catch (e) {
284
- const message = e instanceof Error ? e.message : String(e);
285
- return {
286
- success: false,
287
- gasPrice,
288
- simulationError: message
289
- };
290
- }
291
- const txRow = inspectResult.Transaction ?? inspectResult.FailedTransaction;
292
- const { effects } = txRow;
293
- if (!effects) {
294
- throw new Error("simulateTransaction did not return effects");
295
- }
296
- const success = effects.status.success === true;
297
- if (!success) {
298
- const err = effects.status.success === false ? effects.status.error : null;
299
- return {
300
- success,
301
- gasPrice,
302
- response: inspectResult,
303
- simulationError: err ? formatExecutionError(err) : "Simulation failed"
304
- };
305
- }
306
- const gasBudget = this.toGasBudget(effects.gasUsed, gasPrice);
307
- return {
308
- success,
309
- gasPrice,
310
- gasObject: gasObjectToReference(effects.gasObject),
311
- gasUsed: effects.gasUsed,
312
- gasBudget,
313
- response: inspectResult
314
- };
315
- }
316
- async getGasPrice() {
317
- const { referenceGasPrice } = await this.globals.suiClient.getReferenceGasPrice();
318
- return BigInt(referenceGasPrice);
319
- }
320
- toGasBudget(gasUsed, gasPrice) {
321
- const { computationCost, storageCost, storageRebate } = gasUsed;
322
- const safeOverhead = GAS_SAFE_OVERHEAD * gasPrice;
323
- const baseComputationCostWithOverhead = BigInt(computationCost) + safeOverhead;
324
- const gasBudget = baseComputationCostWithOverhead + BigInt(storageCost) - BigInt(storageRebate);
325
- return gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead;
326
- }
327
- copyTransaction(tx) {
328
- return import_transactions.Transaction.from(tx.serialize());
329
- }
330
- };
209
+ var import_utils4 = require("@mysten/sui/utils");
331
210
 
332
- // src/utils/buffer.ts
333
- var import_buffer = require("buffer");
334
- function stringToBuffer(s) {
335
- return import_buffer.Buffer.from(s, "utf-8");
211
+ // src/utils/coinReservation.ts
212
+ var import_bcs = require("@mysten/sui/bcs");
213
+ var import_utils = require("@mysten/sui/utils");
214
+ var SUI_ACCUMULATOR_ROOT_OBJECT_ID = (0, import_utils.normalizeSuiAddress)("0xacc");
215
+ var ACCUMULATOR_KEY_TYPE_TAG = import_bcs.TypeTagSerializer.parseFromStr(
216
+ "0x2::accumulator::Key<0x2::balance::Balance<0x2::sui::SUI>>"
217
+ );
218
+ var COIN_RESERVATION_MAGIC = new Uint8Array([
219
+ 172,
220
+ 172,
221
+ 172,
222
+ 172,
223
+ 172,
224
+ 172,
225
+ 172,
226
+ 172,
227
+ 172,
228
+ 172,
229
+ 172,
230
+ 172,
231
+ 172,
232
+ 172,
233
+ 172,
234
+ 172,
235
+ 172,
236
+ 172,
237
+ 172,
238
+ 172
239
+ ]);
240
+ function isCoinReservationDigest(digestBase58) {
241
+ const digestBytes = (0, import_utils.fromBase58)(digestBase58);
242
+ const last20Bytes = digestBytes.slice(12, 32);
243
+ return last20Bytes.every((byte, i) => byte === COIN_RESERVATION_MAGIC[i]);
336
244
  }
337
- __name(stringToBuffer, "stringToBuffer");
338
- function Uint8ArrayToHex(b) {
339
- return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
245
+ function deriveReservationObjectId(owner, chainIdentifier) {
246
+ const keyBcs = import_bcs.bcs.Address.serialize(owner).toBytes();
247
+ const accumulatorId = (0, import_utils.deriveDynamicFieldID)(SUI_ACCUMULATOR_ROOT_OBJECT_ID, ACCUMULATOR_KEY_TYPE_TAG, keyBcs);
248
+ const accBytes = (0, import_utils.fromHex)(accumulatorId.slice(2));
249
+ const chainBytes = (0, import_utils.fromBase58)(chainIdentifier);
250
+ if (chainBytes.length !== 32) {
251
+ throw new Error(`Invalid chain identifier length: expected 32 bytes, got ${chainBytes.length}`);
252
+ }
253
+ const xored = new Uint8Array(32);
254
+ for (let i = 0; i < 32; i++) {
255
+ xored[i] = accBytes[i] ^ chainBytes[i];
256
+ }
257
+ return `0x${(0, import_utils.toHex)(xored)}`;
340
258
  }
341
- __name(Uint8ArrayToHex, "Uint8ArrayToHex");
342
- function HexToUint8Array(hex) {
343
- return Uint8Array.from(import_buffer.Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
259
+ function createCoinReservationRef(reservedBalance, owner, chainIdentifier, epoch) {
260
+ const digestBytes = new Uint8Array(32);
261
+ const view = new DataView(digestBytes.buffer);
262
+ view.setBigUint64(0, reservedBalance, true);
263
+ const epochNum = Number(epoch);
264
+ if (!Number.isSafeInteger(epochNum) || epochNum < 0 || epochNum > 4294967295) {
265
+ throw new Error(`Epoch ${epoch} out of u32 range for coin reservation digest`);
266
+ }
267
+ view.setUint32(8, epochNum, true);
268
+ digestBytes.set(COIN_RESERVATION_MAGIC, 12);
269
+ return {
270
+ objectId: deriveReservationObjectId(owner, chainIdentifier),
271
+ version: "0",
272
+ digest: (0, import_utils.toBase58)(digestBytes)
273
+ };
344
274
  }
345
- __name(HexToUint8Array, "HexToUint8Array");
346
275
 
347
- // src/utils/crypto.ts
348
- var import_verify = require("@mysten/sui/verify");
276
+ // src/utils/sui.ts
277
+ var import_sui3_utils3 = require("@msafe/sui3-utils");
278
+ var import_cryptography = require("@mysten/sui/cryptography");
279
+ var import_graphql = require("@mysten/sui/graphql");
280
+ var import_multisig = require("@mysten/sui/multisig");
349
281
 
350
282
  // src/utils/format.ts
351
- var import_utils2 = require("@mysten/sui/utils");
283
+ var import_utils3 = require("@mysten/sui/utils");
352
284
 
353
285
  // src/utils/coin.ts
354
- var import_utils = require("@mysten/sui/utils");
286
+ var import_utils2 = require("@mysten/sui/utils");
355
287
  var CoinHelper = class {
356
- static {
357
- __name(this, "CoinHelper");
358
- }
359
288
  _client;
360
289
  _coinMetaReg;
361
290
  constructor(client) {
@@ -363,7 +292,7 @@ var CoinHelper = class {
363
292
  this._coinMetaReg = /* @__PURE__ */ new Map();
364
293
  }
365
294
  async getCoinMeta(coinType) {
366
- const normalized = (0, import_utils.normalizeStructTag)(coinType);
295
+ const normalized = (0, import_utils2.normalizeStructTag)(coinType);
367
296
  if (this._coinMetaReg.has(normalized)) {
368
297
  return this._coinMetaReg.get(normalized);
369
298
  }
@@ -374,25 +303,20 @@ var CoinHelper = class {
374
303
  return meta;
375
304
  }
376
305
  async queryCoinMeta(coinType) {
377
- const res = await this._client.getCoinMetadata({
378
- coinType
379
- });
306
+ const res = await this._client.getCoinMetadata({ coinType });
380
307
  return res.coinMetadata ?? void 0;
381
308
  }
382
309
  };
383
310
  var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
384
311
  var Coin = class _Coin {
385
- static {
386
- __name(this, "Coin");
387
- }
388
312
  static isCoin(type) {
389
313
  if (!type) {
390
314
  return false;
391
315
  }
392
- return (0, import_utils.normalizeStructTag)(type).match(COIN_TYPE_ARG_REGEX) != null;
316
+ return (0, import_utils2.normalizeStructTag)(type).match(COIN_TYPE_ARG_REGEX) != null;
393
317
  }
394
318
  static getCoinType(type) {
395
- const [, res] = (0, import_utils.normalizeStructTag)(type).match(COIN_TYPE_ARG_REGEX) ?? [];
319
+ const [, res] = (0, import_utils2.normalizeStructTag)(type).match(COIN_TYPE_ARG_REGEX) ?? [];
396
320
  return res || null;
397
321
  }
398
322
  static getBalance(data) {
@@ -419,20 +343,17 @@ var Coin = class _Coin {
419
343
 
420
344
  // src/utils/format.ts
421
345
  var Formatter = class {
422
- static {
423
- __name(this, "Formatter");
424
- }
425
346
  static normalizeSuiAddress(addr) {
426
- return (0, import_utils2.normalizeSuiAddress)(addr);
347
+ return (0, import_utils3.normalizeSuiAddress)(addr);
427
348
  }
428
349
  static normalizeStructTag(struct) {
429
- return (0, import_utils2.normalizeStructTag)(struct);
350
+ return (0, import_utils3.normalizeStructTag)(struct);
430
351
  }
431
352
  static isSuiAddressEqual(addr1, addr2) {
432
- return (0, import_utils2.normalizeSuiAddress)(addr1) === (0, import_utils2.normalizeSuiAddress)(addr2);
353
+ return (0, import_utils3.normalizeSuiAddress)(addr1) === (0, import_utils3.normalizeSuiAddress)(addr2);
433
354
  }
434
355
  static isSuiStructEqual(struct1, struct2) {
435
- return (0, import_utils2.normalizeStructTag)(struct1) === (0, import_utils2.normalizeStructTag)(struct2);
356
+ return (0, import_utils3.normalizeStructTag)(struct1) === (0, import_utils3.normalizeStructTag)(struct2);
436
357
  }
437
358
  static isCoinObjectType(struct) {
438
359
  return Coin.isCoin(struct);
@@ -444,55 +365,8 @@ function addPrefix(s, prefix) {
444
365
  }
445
366
  return prefix + s;
446
367
  }
447
- __name(addPrefix, "addPrefix");
448
-
449
- // src/utils/crypto.ts
450
- var SignatureVerifier = class _SignatureVerifier {
451
- static {
452
- __name(this, "SignatureVerifier");
453
- }
454
- static async getPublicKeyFromSignature(input) {
455
- if (input.messageType === "TransactionBlock") {
456
- return (0, import_verify.verifyTransactionSignature)(input.message, input.signature);
457
- }
458
- return (0, import_verify.verifyPersonalMessageSignature)(input.message, input.signature);
459
- }
460
- static async getPublicKeyFromPersonalSignature(input) {
461
- const message = stringToBuffer(input.messageStr);
462
- return this.getPublicKeyFromSignature({
463
- message,
464
- messageType: "Personal",
465
- signature: input.signature
466
- });
467
- }
468
- static async verifySignature(input) {
469
- const publicKey = await _SignatureVerifier.getPublicKeyFromSignature(input);
470
- return Formatter.isSuiAddressEqual(publicKey.toSuiAddress(), input.targetAddress);
471
- }
472
- static async verifyPersonalSignature(input) {
473
- const message = stringToBuffer(input.messageStr);
474
- return this.verifySignature({
475
- message,
476
- messageType: "Personal",
477
- signature: input.signature,
478
- targetAddress: input.targetAddress
479
- });
480
- }
481
- static async verifyTransactionSignature(input) {
482
- return this.verifySignature({
483
- messageType: "TransactionBlock",
484
- message: input.payload,
485
- signature: input.signature,
486
- targetAddress: input.targetAddress
487
- });
488
- }
489
- };
490
368
 
491
369
  // src/utils/sui.ts
492
- var import_sui3_utils3 = require("@msafe/sui3-utils");
493
- var import_cryptography = require("@mysten/sui/cryptography");
494
- var import_graphql = require("@mysten/sui/graphql");
495
- var import_multisig = require("@mysten/sui/multisig");
496
370
  var SUI_COIN = "0x2::sui::SUI";
497
371
  var GRAPHQL_URL_BY_NETWORK = {
498
372
  mainnet: "https://sui-mainnet.mystenlabs.com/graphql",
@@ -501,35 +375,24 @@ var GRAPHQL_URL_BY_NETWORK = {
501
375
  };
502
376
  function graphqlClientForGrpc(suiClient) {
503
377
  const url = GRAPHQL_URL_BY_NETWORK[suiClient.network] ?? GRAPHQL_URL_BY_NETWORK.testnet;
504
- return new import_graphql.SuiGraphQLClient({
505
- url,
506
- network: suiClient.network
507
- });
378
+ return new import_graphql.SuiGraphQLClient({ url, network: suiClient.network });
508
379
  }
509
- __name(graphqlClientForGrpc, "graphqlClientForGrpc");
510
380
  function collectSignatureStrings(value) {
511
381
  if (typeof value === "string") {
512
- return [
513
- value
514
- ];
382
+ return [value];
515
383
  }
516
384
  if (!value || typeof value !== "object") {
517
385
  return [];
518
386
  }
519
387
  if ("base64" in value && typeof value.base64 === "string") {
520
- return [
521
- value.base64
522
- ];
388
+ return [value.base64];
523
389
  }
524
390
  if ("scheme" in value && "base64" in value) {
525
391
  const b64 = value.base64;
526
- return typeof b64 === "string" ? [
527
- b64
528
- ] : [];
392
+ return typeof b64 === "string" ? [b64] : [];
529
393
  }
530
394
  return [];
531
395
  }
532
- __name(collectSignatureStrings, "collectSignatureStrings");
533
396
  var TX_SIG_QUERY = `
534
397
  query PublicKeyTxSigs($sender: SuiAddress!, $first: Int!) {
535
398
  transactions(first: $first, filter: { sentAddress: $sender }) {
@@ -545,10 +408,7 @@ async function getPublicKeyFromChain(suiClient, address) {
545
408
  try {
546
409
  const res = await graphql.query({
547
410
  query: TX_SIG_QUERY,
548
- variables: {
549
- sender: address,
550
- first: 2
551
- }
411
+ variables: { sender: address, first: 2 }
552
412
  });
553
413
  if (res.errors?.length) {
554
414
  return void 0;
@@ -577,7 +437,6 @@ async function getPublicKeyFromChain(suiClient, address) {
577
437
  }
578
438
  return void 0;
579
439
  }
580
- __name(getPublicKeyFromChain, "getPublicKeyFromChain");
581
440
  function getAddressFromSignatures(serializedSig, targetAddress) {
582
441
  const decoded = (0, import_cryptography.parseSerializedSignature)(serializedSig);
583
442
  switch (decoded.signatureScheme) {
@@ -592,10 +451,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
592
451
  case "ED25519":
593
452
  case "Secp256k1":
594
453
  case "Secp256r1": {
595
- const pk = import_sui3_utils3.PublicKeySerde.de({
596
- publicKeyEncoded: decoded.publicKey,
597
- schema: decoded.signatureScheme
598
- });
454
+ const pk = import_sui3_utils3.PublicKeySerde.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
599
455
  if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
600
456
  return pk;
601
457
  }
@@ -605,7 +461,6 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
605
461
  throw new Error("Unknown schema");
606
462
  }
607
463
  }
608
- __name(getAddressFromSignatures, "getAddressFromSignatures");
609
464
  async function getAllCoins(input) {
610
465
  let hasNext = true;
611
466
  let cursor;
@@ -622,18 +477,357 @@ async function getAllCoins(input) {
622
477
  }
623
478
  return res;
624
479
  }
625
- __name(getAllCoins, "getAllCoins");
480
+
481
+ // src/utils/gasFunding.ts
482
+ var GAS_SAFE_OVERHEAD = 1000n;
483
+ var InsufficientGasFundsError = class extends Error {
484
+ gasBudget;
485
+ coinBalance;
486
+ addressBalance;
487
+ constructor(gasBudget, coinBalance, addressBalance) {
488
+ const total = coinBalance + addressBalance;
489
+ super(
490
+ `Insufficient gas funds: need ${gasBudget}, have coinBalance=${coinBalance} + addressBalance=${addressBalance} = ${total}`
491
+ );
492
+ this.name = "InsufficientGasFundsError";
493
+ this.gasBudget = gasBudget;
494
+ this.coinBalance = coinBalance;
495
+ this.addressBalance = addressBalance;
496
+ }
497
+ };
498
+ function computeGasBudget(gasUsed, gasPrice) {
499
+ const { computationCost, storageCost } = gasUsed;
500
+ const safeOverhead = GAS_SAFE_OVERHEAD * gasPrice;
501
+ return BigInt(computationCost) + BigInt(storageCost) + safeOverhead;
502
+ }
503
+ function collectUsedObjectIds(tx) {
504
+ return tx.getData().inputs.reduce((used, input) => {
505
+ const immOrOwned = input.Object?.ImmOrOwnedObject?.objectId;
506
+ if (immOrOwned) {
507
+ used.add((0, import_utils4.normalizeSuiObjectId)(immOrOwned));
508
+ return used;
509
+ }
510
+ const unresolved = input.UnresolvedObject?.objectId;
511
+ if (unresolved) {
512
+ used.add((0, import_utils4.normalizeSuiObjectId)(unresolved));
513
+ }
514
+ return used;
515
+ }, /* @__PURE__ */ new Set());
516
+ }
517
+ async function loadSuiGasFunding(suiClient, owner, tx) {
518
+ const usedObjectIds = collectUsedObjectIds(tx);
519
+ const [coins, balanceRes] = await Promise.all([
520
+ getAllCoins({ suiClient, owner, coinType: SUI_COIN }),
521
+ suiClient.getBalance({ owner, coinType: SUI_COIN })
522
+ ]);
523
+ const paymentCoins = coins.filter((coin) => !usedObjectIds.has((0, import_utils4.normalizeSuiObjectId)(coin.objectId)) && BigInt(coin.balance) > 0n).map((coin) => ({
524
+ objectId: coin.objectId,
525
+ version: coin.version,
526
+ digest: coin.digest,
527
+ balance: BigInt(coin.balance)
528
+ }));
529
+ const coinBalance = paymentCoins.reduce((sum, coin) => sum + coin.balance, 0n);
530
+ const addressBalance = BigInt(balanceRes.balance.addressBalance);
531
+ return {
532
+ paymentCoins,
533
+ coinBalance,
534
+ addressBalance,
535
+ total: coinBalance + addressBalance
536
+ };
537
+ }
538
+ function toObjectRefs(coins) {
539
+ return coins.map(({ objectId, version, digest }) => ({ objectId, version, digest }));
540
+ }
541
+ async function applyMixedTopUp(input) {
542
+ const { tx, suiClient, owner, paymentCoins, topUpAmount } = input;
543
+ if (paymentCoins.length === 0) {
544
+ throw new Error("mixed gas top-up requires at least one SUI coin object");
545
+ }
546
+ if (topUpAmount <= 0n) {
547
+ tx.setGasPayment(toObjectRefs(paymentCoins));
548
+ return;
549
+ }
550
+ const [{ chainIdentifier }, { systemState }] = await Promise.all([
551
+ suiClient.core.getChainIdentifier(),
552
+ suiClient.core.getCurrentSystemState()
553
+ ]);
554
+ const reservation = createCoinReservationRef(topUpAmount, owner, chainIdentifier, systemState.epoch);
555
+ tx.setGasPayment([...toObjectRefs(paymentCoins), reservation]);
556
+ }
557
+ async function selectGasFunding(input) {
558
+ const { tx, suiClient, owner, gasBudget } = input;
559
+ const { payment } = tx.getData().gasData;
560
+ if (payment != null && payment.length > 0) {
561
+ const funding2 = await loadSuiGasFunding(suiClient, owner, tx);
562
+ return {
563
+ mode: "classic",
564
+ gasBudget,
565
+ coinBalance: funding2.coinBalance,
566
+ addressBalance: funding2.addressBalance
567
+ };
568
+ }
569
+ const funding = await loadSuiGasFunding(suiClient, owner, tx);
570
+ const { paymentCoins, coinBalance, addressBalance, total } = funding;
571
+ if (total < gasBudget) {
572
+ throw new InsufficientGasFundsError(gasBudget, coinBalance, addressBalance);
573
+ }
574
+ if (paymentCoins.length > 0 && coinBalance >= gasBudget) {
575
+ tx.setGasPayment(toObjectRefs(paymentCoins));
576
+ return { mode: "classic", gasBudget, coinBalance, addressBalance };
577
+ }
578
+ if (paymentCoins.length > 0 && total >= gasBudget) {
579
+ const topUpAmount = gasBudget - coinBalance;
580
+ await applyMixedTopUp({
581
+ tx,
582
+ suiClient,
583
+ owner,
584
+ paymentCoins,
585
+ topUpAmount
586
+ });
587
+ return { mode: "mixedTopUp", gasBudget, coinBalance, addressBalance };
588
+ }
589
+ if (addressBalance >= gasBudget) {
590
+ tx.setGasPayment([]);
591
+ return { mode: "addressBalance", gasBudget, coinBalance, addressBalance };
592
+ }
593
+ throw new InsufficientGasFundsError(gasBudget, coinBalance, addressBalance);
594
+ }
595
+ async function estimateGasBudget(input) {
596
+ const { tx, suiClient, owner, gasPrice } = input;
597
+ const funding = await loadSuiGasFunding(suiClient, owner, tx);
598
+ if (funding.total <= 0n) {
599
+ throw new InsufficientGasFundsError(0n, funding.coinBalance, funding.addressBalance);
600
+ }
601
+ const probe = import_transactions.Transaction.from(tx);
602
+ probe.setSender(owner);
603
+ probe.setGasPrice(gasPrice);
604
+ if (funding.paymentCoins.length > 0) {
605
+ probe.setGasPayment(toObjectRefs(funding.paymentCoins));
606
+ }
607
+ let built;
608
+ try {
609
+ built = await probe.build({ client: suiClient });
610
+ } catch (e) {
611
+ const message = e instanceof Error ? e.message : String(e);
612
+ throw new Error(`Failed to estimate gas budget: ${message}`);
613
+ }
614
+ const inspect = await suiClient.simulateTransaction({
615
+ transaction: built,
616
+ include: { effects: true }
617
+ });
618
+ const effects = (inspect.Transaction ?? inspect.FailedTransaction)?.effects;
619
+ if (!effects?.gasUsed) {
620
+ throw new Error("Failed to estimate gas budget: simulateTransaction returned no gasUsed");
621
+ }
622
+ if (effects.status.success !== true) {
623
+ const err = effects.status.success === false ? effects.status.error?.message : void 0;
624
+ throw new Error(`Failed to estimate gas budget: ${err ?? "simulation failed"}`);
625
+ }
626
+ return computeGasBudget(effects.gasUsed, gasPrice);
627
+ }
628
+ async function prepareGasFunding(input) {
629
+ const { tx, suiClient, owner, gasPrice } = input;
630
+ const { payment, budget: existingBudget } = tx.getData().gasData;
631
+ const bakedAddressBalanceGas = payment != null && payment.length === 0;
632
+ let { gasBudget } = input;
633
+ if (gasBudget == null) {
634
+ if (bakedAddressBalanceGas || existingBudget == null) {
635
+ gasBudget = await estimateGasBudget({ tx, suiClient, owner, gasPrice });
636
+ } else {
637
+ gasBudget = BigInt(existingBudget);
638
+ }
639
+ }
640
+ tx.setGasBudget(gasBudget);
641
+ return selectGasFunding({ tx, suiClient, owner, gasBudget });
642
+ }
643
+ async function preferClassicGasPayment(input) {
644
+ const { tx, suiClient, owner } = input;
645
+ const { payment } = tx.getData().gasData;
646
+ if (payment != null) {
647
+ return payment.length > 0;
648
+ }
649
+ const funding = await loadSuiGasFunding(suiClient, owner, tx);
650
+ if (funding.paymentCoins.length === 0) {
651
+ return false;
652
+ }
653
+ tx.setGasPayment(toObjectRefs(funding.paymentCoins));
654
+ return true;
655
+ }
656
+
657
+ // src/simulate/simulator.ts
658
+ function formatExecutionError(error) {
659
+ return error.message;
660
+ }
661
+ function gasObjectToReference(gas) {
662
+ if (!gas?.objectId) {
663
+ throw new Error("Gas object missing from simulation effects");
664
+ }
665
+ const version = gas.outputVersion ?? gas.inputVersion ?? "0";
666
+ const digest = gas.outputDigest ?? gas.inputDigest ?? "";
667
+ return { objectId: gas.objectId, version, digest };
668
+ }
669
+ var Simulator = class {
670
+ constructor(globals) {
671
+ this.globals = globals;
672
+ }
673
+ async simulate(input) {
674
+ const tx = this.copyTransaction(input.txb);
675
+ const { suiClient } = this.globals;
676
+ const gasPrice = await this.getGasPrice();
677
+ tx.setGasPrice(gasPrice);
678
+ tx.setSender(input.sender);
679
+ try {
680
+ await prepareGasFunding({
681
+ tx,
682
+ suiClient,
683
+ owner: input.sender,
684
+ gasPrice
685
+ });
686
+ } catch (e) {
687
+ const message = e instanceof Error ? e.message : String(e);
688
+ return {
689
+ success: false,
690
+ gasPrice,
691
+ simulationError: message
692
+ };
693
+ }
694
+ let built;
695
+ try {
696
+ built = await tx.build({ client: suiClient });
697
+ } catch (e) {
698
+ const message = e instanceof Error ? e.message : String(e);
699
+ return {
700
+ success: false,
701
+ gasPrice,
702
+ simulationError: message
703
+ };
704
+ }
705
+ let inspectResult;
706
+ try {
707
+ inspectResult = await suiClient.simulateTransaction({
708
+ transaction: built,
709
+ include: {
710
+ effects: true,
711
+ balanceChanges: true,
712
+ events: true,
713
+ objectTypes: true,
714
+ transaction: true,
715
+ bcs: true,
716
+ commandResults: true
717
+ }
718
+ });
719
+ } catch (e) {
720
+ const message = e instanceof Error ? e.message : String(e);
721
+ return {
722
+ success: false,
723
+ gasPrice,
724
+ simulationError: message
725
+ };
726
+ }
727
+ const txRow = inspectResult.Transaction ?? inspectResult.FailedTransaction;
728
+ const { effects } = txRow;
729
+ if (!effects) {
730
+ throw new Error("simulateTransaction did not return effects");
731
+ }
732
+ const success = effects.status.success === true;
733
+ if (!success) {
734
+ const err = effects.status.success === false ? effects.status.error : null;
735
+ return {
736
+ success,
737
+ gasPrice,
738
+ response: inspectResult,
739
+ simulationError: err ? formatExecutionError(err) : "Simulation failed"
740
+ };
741
+ }
742
+ const gasBudget = this.toGasBudget(effects.gasUsed, gasPrice);
743
+ return {
744
+ success,
745
+ gasPrice,
746
+ gasObject: gasObjectToReference(effects.gasObject),
747
+ gasUsed: effects.gasUsed,
748
+ gasBudget,
749
+ response: inspectResult
750
+ };
751
+ }
752
+ async getGasPrice() {
753
+ const { referenceGasPrice } = await this.globals.suiClient.getReferenceGasPrice();
754
+ return BigInt(referenceGasPrice);
755
+ }
756
+ toGasBudget(gasUsed, gasPrice) {
757
+ return computeGasBudget(gasUsed, gasPrice);
758
+ }
759
+ copyTransaction(tx) {
760
+ return import_transactions2.Transaction.from(tx);
761
+ }
762
+ };
763
+
764
+ // src/utils/buffer.ts
765
+ var import_buffer = require("buffer");
766
+ function stringToBuffer(s) {
767
+ return import_buffer.Buffer.from(s, "utf-8");
768
+ }
769
+ function Uint8ArrayToHex(b) {
770
+ return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
771
+ }
772
+ function HexToUint8Array(hex) {
773
+ return Uint8Array.from(import_buffer.Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
774
+ }
775
+
776
+ // src/utils/crypto.ts
777
+ var import_verify = require("@mysten/sui/verify");
778
+ var SignatureVerifier = class _SignatureVerifier {
779
+ static async getPublicKeyFromSignature(input) {
780
+ if (input.messageType === "TransactionBlock") {
781
+ return (0, import_verify.verifyTransactionSignature)(input.message, input.signature);
782
+ }
783
+ return (0, import_verify.verifyPersonalMessageSignature)(input.message, input.signature);
784
+ }
785
+ static async getPublicKeyFromPersonalSignature(input) {
786
+ const message = stringToBuffer(input.messageStr);
787
+ return this.getPublicKeyFromSignature({
788
+ message,
789
+ messageType: "Personal",
790
+ signature: input.signature
791
+ });
792
+ }
793
+ static async verifySignature(input) {
794
+ const publicKey = await _SignatureVerifier.getPublicKeyFromSignature(input);
795
+ return Formatter.isSuiAddressEqual(publicKey.toSuiAddress(), input.targetAddress);
796
+ }
797
+ static async verifyPersonalSignature(input) {
798
+ const message = stringToBuffer(input.messageStr);
799
+ return this.verifySignature({
800
+ message,
801
+ messageType: "Personal",
802
+ signature: input.signature,
803
+ targetAddress: input.targetAddress
804
+ });
805
+ }
806
+ static async verifyTransactionSignature(input) {
807
+ return this.verifySignature({
808
+ messageType: "TransactionBlock",
809
+ message: input.payload,
810
+ signature: input.signature,
811
+ targetAddress: input.targetAddress
812
+ });
813
+ }
814
+ };
626
815
 
627
816
  // src/utils/transaction.ts
628
- var import_transactions2 = require("@mysten/sui/transactions");
817
+ var import_transactions3 = require("@mysten/sui/transactions");
629
818
  function toSuiTransaction(txb) {
630
- if ((0, import_transactions2.isTransaction)(txb)) {
819
+ if ((0, import_transactions3.isTransaction)(txb)) {
631
820
  return txb;
632
821
  }
822
+ if (typeof txb === "string" || txb instanceof Uint8Array) {
823
+ return import_transactions3.Transaction.from(txb);
824
+ }
633
825
  const legacy = txb;
634
- return import_transactions2.Transaction.from(legacy.serialize());
826
+ if (typeof legacy?.serialize === "function") {
827
+ return import_transactions3.Transaction.from(legacy.serialize());
828
+ }
829
+ throw new Error("Unsupported transaction value for toSuiTransaction");
635
830
  }
636
- __name(toSuiTransaction, "toSuiTransaction");
637
831
 
638
832
  // src/utils/iter/iterator.ts
639
833
  var REQUEST_PAGE_SIZE = 25;
@@ -648,19 +842,14 @@ async function getAllFromIterator(it) {
648
842
  }
649
843
  return res;
650
844
  }
651
- __name(getAllFromIterator, "getAllFromIterator");
652
845
  var PagedIterator = class {
653
- static {
654
- __name(this, "PagedIterator");
655
- }
656
- requester;
657
- curPage;
658
- init;
659
846
  constructor(requester) {
660
847
  this.requester = requester;
661
848
  this.curPage = void 0;
662
849
  this.init = true;
663
850
  }
851
+ curPage;
852
+ init;
664
853
  async hasNext() {
665
854
  if (this.init) {
666
855
  if (!this.curPage) {
@@ -686,19 +875,15 @@ var PagedIterator = class {
686
875
  }
687
876
  };
688
877
  var EntryIterator = class {
689
- static {
690
- __name(this, "EntryIterator");
691
- }
692
- requester;
693
- cursor;
694
- pager;
695
- curData;
696
878
  constructor(requester) {
697
879
  this.requester = requester;
698
880
  this.pager = new PagedIterator(requester);
699
881
  this.curData = [];
700
882
  this.cursor = 0;
701
883
  }
884
+ cursor;
885
+ pager;
886
+ curData;
702
887
  async hasNext() {
703
888
  if (this.cursor < this.curData.length - 1) {
704
889
  return true;
@@ -720,28 +905,15 @@ var EntryIterator = class {
720
905
  };
721
906
 
722
907
  // src/utils/iter/object.ts
723
- var defaultObjectInclude = {
724
- json: true
725
- };
908
+ var defaultObjectInclude = { json: true };
726
909
  function mergeInclude(options) {
727
- return {
728
- ...defaultObjectInclude,
729
- ...options?.objectInclude
730
- };
910
+ return { ...defaultObjectInclude, ...options?.objectInclude };
731
911
  }
732
- __name(mergeInclude, "mergeInclude");
733
912
  async function getAllOwnedObjects(provider, owner, options) {
734
913
  const iter = new OwnedObjectIterator(provider, owner, options);
735
914
  return await getAllFromIterator(iter);
736
915
  }
737
- __name(getAllOwnedObjects, "getAllOwnedObjects");
738
916
  var OwnedObjectIterator = class extends EntryIterator {
739
- static {
740
- __name(this, "OwnedObjectIterator");
741
- }
742
- provider;
743
- owner;
744
- options;
745
917
  constructor(provider, owner, options) {
746
918
  super(new OwnedObjectRequester(provider, owner, options));
747
919
  this.provider = provider;
@@ -750,16 +922,6 @@ var OwnedObjectIterator = class extends EntryIterator {
750
922
  }
751
923
  };
752
924
  var OwnedObjectRequester = class {
753
- static {
754
- __name(this, "OwnedObjectRequester");
755
- }
756
- provider;
757
- owner;
758
- options;
759
- nextCursor;
760
- filter;
761
- pageSize;
762
- objectInclude;
763
925
  constructor(provider, owner, options) {
764
926
  this.provider = provider;
765
927
  this.owner = owner;
@@ -769,6 +931,10 @@ var OwnedObjectRequester = class {
769
931
  this.pageSize = options?.pageSize || REQUEST_PAGE_SIZE;
770
932
  this.objectInclude = mergeInclude(options);
771
933
  }
934
+ nextCursor;
935
+ filter;
936
+ pageSize;
937
+ objectInclude;
772
938
  async doNextRequest() {
773
939
  const res = await this.provider.listOwnedObjects({
774
940
  owner: this.owner,
@@ -793,14 +959,6 @@ var OwnedObjectRequester = class {
793
959
 
794
960
  // src/core/MSafeAccount.ts
795
961
  var MSafeAccount = class _MSafeAccount {
796
- static {
797
- __name(this, "MSafeAccount");
798
- }
799
- globals;
800
- info;
801
- multiSig;
802
- simulator;
803
- coinHelper;
804
962
  constructor(globals, info) {
805
963
  this.globals = globals;
806
964
  this.info = info;
@@ -812,6 +970,9 @@ var MSafeAccount = class _MSafeAccount {
812
970
  this.coinHelper = new CoinHelper(this.suiClient);
813
971
  this.simulator = new Simulator(globals);
814
972
  }
973
+ multiSig;
974
+ simulator;
975
+ coinHelper;
815
976
  static async New(globals, address) {
816
977
  const info = await globals.backend.getMSafeAccountInfo(address);
817
978
  const ms = new _MSafeAccount(globals, info);
@@ -824,23 +985,21 @@ var MSafeAccount = class _MSafeAccount {
824
985
  let cursor = null;
825
986
  let hasNext = true;
826
987
  while (hasNext) {
827
- const page = await this.suiClient.listBalances({
828
- owner: this.address,
829
- cursor,
830
- limit: 50
831
- });
988
+ const page = await this.suiClient.listBalances({ owner: this.address, cursor, limit: 50 });
832
989
  balances.push(...page.balances);
833
990
  hasNext = page.hasNextPage;
834
991
  cursor = page.cursor;
835
992
  }
836
- return Promise.all(balances.map(async (balance) => {
837
- const meta = await this.coinHelper.getCoinMeta(balance.coinType);
838
- return {
839
- type: (0, import_utils3.normalizeStructTag)(balance.coinType),
840
- balance: BigInt(balance.addressBalance),
841
- metadata: meta
842
- };
843
- }));
993
+ return Promise.all(
994
+ balances.map(async (balance) => {
995
+ const meta = await this.coinHelper.getCoinMeta(balance.coinType);
996
+ return {
997
+ type: (0, import_utils5.normalizeStructTag)(balance.coinType),
998
+ balance: BigInt(balance.addressBalance),
999
+ metadata: meta
1000
+ };
1001
+ })
1002
+ );
844
1003
  }
845
1004
  async ownedObjects(options) {
846
1005
  const filterCoinObjectOptions = {
@@ -850,9 +1009,7 @@ var MSafeAccount = class _MSafeAccount {
850
1009
  return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
851
1010
  }
852
1011
  async pendingTransaction() {
853
- const res = await this.backend.getPendingTransactions({
854
- msafeAddress: this.address
855
- });
1012
+ const res = await this.backend.getPendingTransactions({ msafeAddress: this.address });
856
1013
  if (!res?.pending) {
857
1014
  return void 0;
858
1015
  }
@@ -884,10 +1041,7 @@ var MSafeAccount = class _MSafeAccount {
884
1041
  });
885
1042
  }
886
1043
  async futureIntentions(pagination) {
887
- return this.backend.getFutureIntentions({
888
- msafeAddress: this.address,
889
- ...pagination
890
- });
1044
+ return this.backend.getFutureIntentions({ msafeAddress: this.address, ...pagination });
891
1045
  }
892
1046
  async currentSequenceNumber() {
893
1047
  return this.backend.getCurrentSequenceNumber(this.address);
@@ -904,28 +1058,24 @@ var MSafeAccount = class _MSafeAccount {
904
1058
  if (!appHelper) {
905
1059
  throw new Error(`Can't find app helper for application ${request.application}`);
906
1060
  }
907
- txb = toSuiTransaction(await appHelper.build({
908
- network: this.globals.config.network,
909
- intentionData: request.intention,
910
- txType: request.txType,
911
- txSubType: request.txSubType,
912
- clientUrl: this.globals.config.suiClient.url,
913
- account: {
914
- address: this.address,
915
- publicKey: (0, import_utils3.fromHex)(this.address),
916
- chains: [
917
- import_wallet_standard.SUI_MAINNET_CHAIN,
918
- import_wallet_standard.SUI_TESTNET_CHAIN
919
- ],
920
- features: []
921
- }
922
- }));
1061
+ txb = toSuiTransaction(
1062
+ await appHelper.build({
1063
+ network: this.globals.config.network,
1064
+ intentionData: request.intention,
1065
+ txType: request.txType,
1066
+ txSubType: request.txSubType,
1067
+ clientUrl: this.globals.config.suiClient.url,
1068
+ account: {
1069
+ address: this.address,
1070
+ publicKey: (0, import_utils5.fromHex)(this.address),
1071
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
1072
+ features: []
1073
+ }
1074
+ })
1075
+ );
923
1076
  }
924
1077
  txb.setSender(this.address);
925
- return this.simulator.simulate({
926
- txb,
927
- sender: this.address
928
- });
1078
+ return this.simulator.simulate({ txb, sender: this.address });
929
1079
  }
930
1080
  async proposeIntention(input) {
931
1081
  const message = import_sui3_utils4.SigningMessageHelper.proposeIntentionMessage({
@@ -951,38 +1101,37 @@ var MSafeAccount = class _MSafeAccount {
951
1101
  if (!appHelper) {
952
1102
  throw new Error(`Can't find app helper for application ${input.application}`);
953
1103
  }
954
- txb = toSuiTransaction(await appHelper.build({
955
- network: this.globals.config.network,
956
- intentionData: input.intention,
957
- txType: input.txType,
958
- txSubType: input.txSubType,
959
- clientUrl: this.globals.config.suiClient.url,
960
- account: {
961
- address: this.address,
962
- publicKey: (0, import_utils3.fromHex)(this.address),
963
- chains: [
964
- import_wallet_standard.SUI_MAINNET_CHAIN,
965
- import_wallet_standard.SUI_TESTNET_CHAIN
966
- ],
967
- features: []
968
- }
969
- }));
1104
+ txb = toSuiTransaction(
1105
+ await appHelper.build({
1106
+ network: this.globals.config.network,
1107
+ intentionData: input.intention,
1108
+ txType: input.txType,
1109
+ txSubType: input.txSubType,
1110
+ clientUrl: this.globals.config.suiClient.url,
1111
+ account: {
1112
+ address: this.address,
1113
+ publicKey: (0, import_utils5.fromHex)(this.address),
1114
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
1115
+ features: []
1116
+ }
1117
+ })
1118
+ );
970
1119
  }
971
1120
  txb.setGasPrice(input.gasPrice);
972
- txb.setGasBudget(input.gasBudget);
973
1121
  txb.setSender(this.address);
974
- const payload = await txb.build({
975
- client: this.globals.suiClient
976
- });
977
- const digest = await txb.getDigest({
978
- client: this.globals.suiClient
979
- });
980
- const signature = await this.wallet.signTransactionBlock({
981
- transactionBlock: payload
982
- });
1122
+ await prepareGasFunding({
1123
+ tx: txb,
1124
+ suiClient: this.globals.suiClient,
1125
+ owner: this.address,
1126
+ gasPrice: input.gasPrice,
1127
+ gasBudget: input.gasBudget
1128
+ });
1129
+ const payload = await txb.build({ client: this.globals.suiClient });
1130
+ const digest = await txb.getDigest({ client: this.globals.suiClient });
1131
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
983
1132
  return this.backend.proposeIntentionAndBuildVote({
984
1133
  ...input,
985
- payload: (0, import_utils3.toHex)(payload),
1134
+ payload: (0, import_utils5.toHex)(payload),
986
1135
  digest,
987
1136
  msafeAddress: this.address,
988
1137
  signature: signature.signature
@@ -1040,7 +1189,7 @@ var MSafeAccount = class _MSafeAccount {
1040
1189
  }
1041
1190
  async proposePlainPayloadIntention(intention) {
1042
1191
  const sn = await this.nextSequenceNumber();
1043
- const tb = import_transactions3.Transaction.from(intention.payload);
1192
+ const tb = import_transactions4.Transaction.from(intention.payload);
1044
1193
  const data = tb.getData();
1045
1194
  if (!data.sender || !(0, import_sui3_utils4.isSameAddress)(data.sender, this.address)) {
1046
1195
  throw new Error("Transaction sender is not same as the multisig address");
@@ -1055,9 +1204,7 @@ var MSafeAccount = class _MSafeAccount {
1055
1204
  }
1056
1205
  async voteForTransaction(digest, payload) {
1057
1206
  const payloadBytes = HexToUint8Array(payload);
1058
- const signature = await this.wallet.signTransactionBlock({
1059
- transactionBlock: payloadBytes
1060
- });
1207
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payloadBytes });
1061
1208
  return this.backend.voteForTransaction({
1062
1209
  msafeAddress: this.address,
1063
1210
  digest,
@@ -1071,10 +1218,7 @@ var MSafeAccount = class _MSafeAccount {
1071
1218
  }
1072
1219
  const txb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
1073
1220
  txb.setSender(this.address);
1074
- return this.simulator.simulate({
1075
- txb,
1076
- sender: this.address
1077
- });
1221
+ return this.simulator.simulate({ txb, sender: this.address });
1078
1222
  }
1079
1223
  async rejectCurrentTx(input) {
1080
1224
  const pendingTx = await this.pendingTransaction();
@@ -1082,15 +1226,17 @@ var MSafeAccount = class _MSafeAccount {
1082
1226
  throw new Error("Already rejected");
1083
1227
  }
1084
1228
  const rejectTxb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
1085
- const digest = await rejectTxb.getDigest({
1086
- client: this.suiClient
1087
- });
1088
- const payload = await rejectTxb.build({
1089
- client: this.suiClient
1090
- });
1091
- const signature = await this.wallet.signTransactionBlock({
1092
- transactionBlock: payload
1093
- });
1229
+ rejectTxb.setGasPrice(input.gasPrice);
1230
+ await prepareGasFunding({
1231
+ tx: rejectTxb,
1232
+ suiClient: this.suiClient,
1233
+ owner: this.address,
1234
+ gasPrice: input.gasPrice,
1235
+ gasBudget: input.gasBudget
1236
+ });
1237
+ const digest = await rejectTxb.getDigest({ client: this.suiClient });
1238
+ const payload = await rejectTxb.build({ client: this.suiClient });
1239
+ const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
1094
1240
  return this.backend.rejectCurrentTx({
1095
1241
  msafeAddress: this.address,
1096
1242
  digest,
@@ -1099,34 +1245,28 @@ var MSafeAccount = class _MSafeAccount {
1099
1245
  });
1100
1246
  }
1101
1247
  async simulateBuildTransaction() {
1102
- const intention = await this.backend.getNextIntention({
1103
- msafeAddress: this.address
1104
- });
1248
+ const intention = await this.backend.getNextIntention({ msafeAddress: this.address });
1105
1249
  const appHelper = import_sui_app_store.appHelpers.getAppHelper(intention.application);
1106
1250
  if (!appHelper) {
1107
1251
  throw new Error(`Can't find app helper for application ${intention.application}`);
1108
1252
  }
1109
- const txb = toSuiTransaction(await appHelper.build({
1110
- network: this.globals.config.network,
1111
- intentionData: intention.intention,
1112
- txType: intention.txType,
1113
- txSubType: intention.txSubType,
1114
- clientUrl: this.globals.config.suiClient.url,
1115
- account: {
1116
- address: this.address,
1117
- publicKey: (0, import_utils3.fromHex)(this.address),
1118
- chains: [
1119
- import_wallet_standard.SUI_MAINNET_CHAIN,
1120
- import_wallet_standard.SUI_TESTNET_CHAIN
1121
- ],
1122
- features: []
1123
- }
1124
- }));
1253
+ const txb = toSuiTransaction(
1254
+ await appHelper.build({
1255
+ network: this.globals.config.network,
1256
+ intentionData: intention.intention,
1257
+ txType: intention.txType,
1258
+ txSubType: intention.txSubType,
1259
+ clientUrl: this.globals.config.suiClient.url,
1260
+ account: {
1261
+ address: this.address,
1262
+ publicKey: (0, import_utils5.fromHex)(this.address),
1263
+ chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
1264
+ features: []
1265
+ }
1266
+ })
1267
+ );
1125
1268
  txb.setSender(this.address);
1126
- return this.simulator.simulate({
1127
- txb,
1128
- sender: this.address
1129
- });
1269
+ return this.simulator.simulate({ txb, sender: this.address });
1130
1270
  }
1131
1271
  async buildNextIntentionAndAddToPending(gasOption) {
1132
1272
  return this.backend.buildNextIntentionAndAddToPending({
@@ -1137,14 +1277,10 @@ var MSafeAccount = class _MSafeAccount {
1137
1277
  });
1138
1278
  }
1139
1279
  async skipNextFailedIntention() {
1140
- return this.backend.skipNextFailedIntention({
1141
- msafeAddress: this.address
1142
- });
1280
+ return this.backend.skipNextFailedIntention({ msafeAddress: this.address });
1143
1281
  }
1144
1282
  async fetchTransaction() {
1145
- return this.backend.fetchTransaction({
1146
- msafeAddress: this.address
1147
- });
1283
+ return this.backend.fetchTransaction({ msafeAddress: this.address });
1148
1284
  }
1149
1285
  async executePendingTx(pending, isRejectTx = false) {
1150
1286
  const votes = isRejectTx ? pending.rejectVotes : pending.votes;
@@ -1153,10 +1289,7 @@ var MSafeAccount = class _MSafeAccount {
1153
1289
  throw new Error("Not enough signature");
1154
1290
  }
1155
1291
  const sortedSigs = [];
1156
- const gotSigs = new Map(votes.map((vote) => [
1157
- vote.userAddress,
1158
- vote.signature
1159
- ]));
1292
+ const gotSigs = new Map(votes.map((vote) => [vote.userAddress, vote.signature]));
1160
1293
  for (let i = 0; i < this.info.owners.length; i++) {
1161
1294
  const owner = this.info.owners[i];
1162
1295
  const signature = gotSigs.get(owner.address);
@@ -1167,13 +1300,8 @@ var MSafeAccount = class _MSafeAccount {
1167
1300
  const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
1168
1301
  return this.suiClient.executeTransaction({
1169
1302
  transaction: HexToUint8Array(payload),
1170
- signatures: [
1171
- multiSignature
1172
- ],
1173
- include: {
1174
- effects: true,
1175
- events: true
1176
- }
1303
+ signatures: [multiSignature],
1304
+ include: { effects: true, events: true }
1177
1305
  });
1178
1306
  }
1179
1307
  async dashboard() {
@@ -1213,17 +1341,13 @@ var MSafeAccount = class _MSafeAccount {
1213
1341
 
1214
1342
  // src/core/PublicKeyHelper.ts
1215
1343
  var import_sui3_utils5 = require("@msafe/sui3-utils");
1216
- var import_utils5 = require("@mysten/sui/utils");
1344
+ var import_utils7 = require("@mysten/sui/utils");
1217
1345
  var PublicKeyHelper = class {
1218
- static {
1219
- __name(this, "PublicKeyHelper");
1220
- }
1221
- globals;
1222
- knownPublicKeys;
1223
1346
  constructor(globals) {
1224
1347
  this.globals = globals;
1225
1348
  this.knownPublicKeys = /* @__PURE__ */ new Map();
1226
1349
  }
1350
+ knownPublicKeys;
1227
1351
  async getPublicKey(address) {
1228
1352
  const cached = this.knownPublicKeys.get(address);
1229
1353
  if (cached) {
@@ -1266,7 +1390,7 @@ var PublicKeyHelper = class {
1266
1390
  if (!(0, import_sui3_utils5.isSameAddress)(address, publicKey.toSuiAddress())) {
1267
1391
  throw new Error("Invalid public key");
1268
1392
  }
1269
- this.knownPublicKeys.set((0, import_utils5.normalizeSuiAddress)(address), publicKey);
1393
+ this.knownPublicKeys.set((0, import_utils7.normalizeSuiAddress)(address), publicKey);
1270
1394
  }
1271
1395
  async _getPublicKey(address) {
1272
1396
  const pkBackend = await this.getPublicKeyFromBackend(address);
@@ -1294,10 +1418,6 @@ var PublicKeyHelper = class {
1294
1418
 
1295
1419
  // src/core/ReportSDK.ts
1296
1420
  var ReportSDK = class {
1297
- static {
1298
- __name(this, "ReportSDK");
1299
- }
1300
- globals;
1301
1421
  constructor(globals) {
1302
1422
  this.globals = globals;
1303
1423
  }
@@ -1313,16 +1433,11 @@ var import_grpc = require("@mysten/sui/grpc");
1313
1433
  var import_sui3_utils6 = require("@msafe/sui3-utils");
1314
1434
  var import_axios = __toESM(require("axios"), 1);
1315
1435
  var BackendImpl = class _BackendImpl {
1316
- static {
1317
- __name(this, "BackendImpl");
1318
- }
1319
- apiURL;
1320
- mockAddress;
1321
- _token;
1322
1436
  constructor(apiURL, mockAddress) {
1323
1437
  this.apiURL = apiURL;
1324
1438
  this.mockAddress = mockAddress;
1325
1439
  }
1440
+ _token;
1326
1441
  getNotificationInfo() {
1327
1442
  return this.get(`/notification`, {
1328
1443
  headers: this.headers()
@@ -1345,9 +1460,7 @@ var BackendImpl = class _BackendImpl {
1345
1460
  }
1346
1461
  async verifyToken(jwt) {
1347
1462
  try {
1348
- const res = await this.get(`/auth`, {
1349
- headers: this.headers(jwt)
1350
- });
1463
+ const res = await this.get(`/auth`, { headers: this.headers(jwt) });
1351
1464
  return res.status === 200;
1352
1465
  } catch (_) {
1353
1466
  return false;
@@ -1357,9 +1470,7 @@ var BackendImpl = class _BackendImpl {
1357
1470
  this._token = token;
1358
1471
  }
1359
1472
  async getPublicKey(address) {
1360
- return (await this.getPublicKeyBatch([
1361
- address
1362
- ]))[0];
1473
+ return (await this.getPublicKeyBatch([address]))[0];
1363
1474
  }
1364
1475
  async getPublicKeyBatch(addresses) {
1365
1476
  const query = {
@@ -1369,7 +1480,9 @@ var BackendImpl = class _BackendImpl {
1369
1480
  params: query,
1370
1481
  headers: this.headers()
1371
1482
  });
1372
- return res.data?.map((publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0);
1483
+ return res.data?.map(
1484
+ (publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0
1485
+ );
1373
1486
  }
1374
1487
  async getMSafeAccountInfo(msafeAddress) {
1375
1488
  const q = {
@@ -1406,9 +1519,7 @@ var BackendImpl = class _BackendImpl {
1406
1519
  }
1407
1520
  async updateMSafeStatus(input) {
1408
1521
  const p = input;
1409
- await this.post(`/msafe/status`, p, {
1410
- headers: this.headers()
1411
- });
1522
+ await this.post(`/msafe/status`, p, { headers: this.headers() });
1412
1523
  }
1413
1524
  async getPendingTransactions(input) {
1414
1525
  const res = await this.get(`/transaction/pending`, {
@@ -1462,18 +1573,16 @@ var BackendImpl = class _BackendImpl {
1462
1573
  });
1463
1574
  }
1464
1575
  async proposeIntention(input) {
1465
- await this.post(`/transaction/intention`, input, {
1466
- headers: this.headers()
1467
- });
1576
+ await this.post(`/transaction/intention`, input, { headers: this.headers() });
1468
1577
  }
1469
1578
  async rejectCurrentTx(input) {
1470
- await this.post(`/transaction/pending/reject`, {
1471
- ...input,
1472
- gasPrice: input.gasPrice.toString(),
1473
- gasBudget: input.gasBudget.toString()
1474
- }, {
1475
- headers: this.headers()
1476
- });
1579
+ await this.post(
1580
+ `/transaction/pending/reject`,
1581
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1582
+ {
1583
+ headers: this.headers()
1584
+ }
1585
+ );
1477
1586
  }
1478
1587
  async voteForTransaction(input) {
1479
1588
  await this.post(`/transaction/pending/vote`, input, {
@@ -1481,32 +1590,24 @@ var BackendImpl = class _BackendImpl {
1481
1590
  });
1482
1591
  }
1483
1592
  async buildNextIntentionAndAddToPending(input) {
1484
- await this.post(`/transaction/pending/build`, {
1485
- ...input,
1486
- gasPrice: input.gasPrice.toString(),
1487
- gasBudget: input.gasBudget.toString()
1488
- }, {
1489
- headers: this.headers()
1490
- });
1593
+ await this.post(
1594
+ `/transaction/pending/build`,
1595
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1596
+ { headers: this.headers() }
1597
+ );
1491
1598
  }
1492
1599
  async proposeIntentionAndBuildVote(input) {
1493
- await this.post(`/transaction/intention/build`, {
1494
- ...input,
1495
- gasPrice: input.gasPrice.toString(),
1496
- gasBudget: input.gasBudget.toString()
1497
- }, {
1498
- headers: this.headers()
1499
- });
1600
+ await this.post(
1601
+ `/transaction/intention/build`,
1602
+ { ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
1603
+ { headers: this.headers() }
1604
+ );
1500
1605
  }
1501
1606
  async skipNextFailedIntention(input) {
1502
- await this.post(`/transaction/pending/skip`, input, {
1503
- headers: this.headers()
1504
- });
1607
+ await this.post(`/transaction/pending/skip`, input, { headers: this.headers() });
1505
1608
  }
1506
1609
  async fetchTransaction(input) {
1507
- const res = await this.post(`/transaction/fetch`, input, {
1508
- headers: this.headers()
1509
- });
1610
+ const res = await this.post(`/transaction/fetch`, input, { headers: this.headers() });
1510
1611
  return res.data;
1511
1612
  }
1512
1613
  async getAddressBookEntries(pagination) {
@@ -1517,22 +1618,14 @@ var BackendImpl = class _BackendImpl {
1517
1618
  return res.data;
1518
1619
  }
1519
1620
  async updateAddressBook(input) {
1520
- await this.post(`/address-book`, input, {
1521
- headers: this.headers()
1522
- });
1621
+ await this.post(`/address-book`, input, { headers: this.headers() });
1523
1622
  }
1524
1623
  async getAddressBookMode() {
1525
- const res = await this.get("/address-book/mode", {
1526
- headers: this.headers()
1527
- });
1624
+ const res = await this.get("/address-book/mode", { headers: this.headers() });
1528
1625
  return res.data;
1529
1626
  }
1530
1627
  async setAddressBookMode(input) {
1531
- await this.post("/address-book/mode", {
1532
- mode: input.mode
1533
- }, {
1534
- headers: this.headers()
1535
- });
1628
+ await this.post("/address-book/mode", { mode: input.mode }, { headers: this.headers() });
1536
1629
  }
1537
1630
  async submitReport(report) {
1538
1631
  await this.post("/report", report);
@@ -1545,10 +1638,7 @@ var BackendImpl = class _BackendImpl {
1545
1638
  return res.data;
1546
1639
  }
1547
1640
  headers(token) {
1548
- return {
1549
- Authorization: `Bearer ${token || this._token}`,
1550
- "sui-mock-user": this.mockAddress
1551
- };
1641
+ return { Authorization: `Bearer ${token || this._token}`, "sui-mock-user": this.mockAddress };
1552
1642
  }
1553
1643
  static toMSafeConfig(resp) {
1554
1644
  return {
@@ -1604,9 +1694,7 @@ var BackendImpl = class _BackendImpl {
1604
1694
  } else if (transformRequest instanceof Array) {
1605
1695
  transformRequests = transformRequest;
1606
1696
  } else {
1607
- transformRequests = [
1608
- transformRequest
1609
- ];
1697
+ transformRequests = [transformRequest];
1610
1698
  }
1611
1699
  return [
1612
1700
  (d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
@@ -1615,10 +1703,6 @@ var BackendImpl = class _BackendImpl {
1615
1703
  }
1616
1704
  };
1617
1705
  var BackendError = class _BackendError extends Error {
1618
- static {
1619
- __name(this, "BackendError");
1620
- }
1621
- e;
1622
1706
  constructor(e) {
1623
1707
  super();
1624
1708
  this.e = e;
@@ -1655,15 +1739,14 @@ var BackendError = class _BackendError extends Error {
1655
1739
  function msafeChainToSuiNetwork(chain) {
1656
1740
  return chain === "sui:mainnet" ? "mainnet" : "testnet";
1657
1741
  }
1658
- __name(msafeChainToSuiNetwork, "msafeChainToSuiNetwork");
1659
- var MSafeEnv;
1660
- (function(MSafeEnv2) {
1661
- MSafeEnv2["local"] = "local";
1662
- MSafeEnv2["unit"] = "unit";
1663
- MSafeEnv2["dev"] = "dev";
1664
- MSafeEnv2["prev"] = "prev";
1665
- MSafeEnv2["prod"] = "prod";
1666
- })(MSafeEnv || (MSafeEnv = {}));
1742
+ var MSafeEnv = /* @__PURE__ */ ((MSafeEnv3) => {
1743
+ MSafeEnv3["local"] = "local";
1744
+ MSafeEnv3["unit"] = "unit";
1745
+ MSafeEnv3["dev"] = "dev";
1746
+ MSafeEnv3["prev"] = "prev";
1747
+ MSafeEnv3["prod"] = "prod";
1748
+ return MSafeEnv3;
1749
+ })(MSafeEnv || {});
1667
1750
  function httpUrlToGrpcBaseUrl(url) {
1668
1751
  const parsed = new URL(url);
1669
1752
  if (parsed.protocol === "https:" && parsed.port === "") {
@@ -1674,7 +1757,6 @@ function httpUrlToGrpcBaseUrl(url) {
1674
1757
  }
1675
1758
  return `${parsed.origin}${parsed.pathname}${parsed.search}`;
1676
1759
  }
1677
- __name(httpUrlToGrpcBaseUrl, "httpUrlToGrpcBaseUrl");
1678
1760
  var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
1679
1761
  var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
1680
1762
  var LOCAL_API_URL = "http://127.0.0.1:3000";
@@ -1685,7 +1767,7 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
1685
1767
  var PROD_API_URL = "https://sui.m-safe.link";
1686
1768
  var ENV_CONFIGS = /* @__PURE__ */ new Map([
1687
1769
  [
1688
- "unit",
1770
+ "unit" /* unit */,
1689
1771
  {
1690
1772
  suiClient: {
1691
1773
  url: TESTNET_RPC_URL
@@ -1698,7 +1780,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1698
1780
  }
1699
1781
  ],
1700
1782
  [
1701
- "local",
1783
+ "local" /* local */,
1702
1784
  {
1703
1785
  suiClient: {
1704
1786
  url: TESTNET_RPC_URL
@@ -1711,7 +1793,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1711
1793
  }
1712
1794
  ],
1713
1795
  [
1714
- "dev",
1796
+ "dev" /* dev */,
1715
1797
  {
1716
1798
  suiClient: {
1717
1799
  url: TESTNET_RPC_URL
@@ -1724,7 +1806,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1724
1806
  }
1725
1807
  ],
1726
1808
  [
1727
- "prev",
1809
+ "prev" /* prev */,
1728
1810
  {
1729
1811
  suiClient: {
1730
1812
  url: MAINNET_RPC_URL
@@ -1737,7 +1819,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1737
1819
  }
1738
1820
  ],
1739
1821
  [
1740
- "prod",
1822
+ "prod" /* prod */,
1741
1823
  {
1742
1824
  suiClient: {
1743
1825
  url: MAINNET_RPC_URL
@@ -1766,13 +1848,9 @@ function getMSafeConfig(env, options) {
1766
1848
  }
1767
1849
  return config;
1768
1850
  }
1769
- __name(getMSafeConfig, "getMSafeConfig");
1770
1851
 
1771
1852
  // src/globals/MSafeGlobals.ts
1772
1853
  var MSafeGlobals = class _MSafeGlobals {
1773
- static {
1774
- __name(this, "MSafeGlobals");
1775
- }
1776
1854
  backend;
1777
1855
  suiClient;
1778
1856
  config;
@@ -1814,15 +1892,11 @@ var MSafeGlobals = class _MSafeGlobals {
1814
1892
 
1815
1893
  // src/core/MSafeClient.ts
1816
1894
  var MSafeClient = class _MSafeClient {
1817
- static {
1818
- __name(this, "MSafeClient");
1819
- }
1820
- globals;
1821
- _creationHelper;
1822
- _publicKeyHelper;
1823
1895
  constructor(globals) {
1824
1896
  this.globals = globals;
1825
1897
  }
1898
+ _creationHelper;
1899
+ _publicKeyHelper;
1826
1900
  static async New(env, options) {
1827
1901
  const globals = await MSafeGlobals.New(env, options);
1828
1902
  return new _MSafeClient(globals);
@@ -1857,10 +1931,7 @@ var MSafeClient = class _MSafeClient {
1857
1931
  return this.globals.backend.getUserInfo();
1858
1932
  }
1859
1933
  async ownedMSafe(pagination) {
1860
- return this.globals.backend.getOwnedMSafeByStatus({
1861
- status: import_sui3_utils7.UserMSafeStatus.active,
1862
- pagination
1863
- });
1934
+ return this.globals.backend.getOwnedMSafeByStatus({ status: import_sui3_utils7.UserMSafeStatus.active, pagination });
1864
1935
  }
1865
1936
  async createAccount(info) {
1866
1937
  return this.creationHelper.submitMSafeCreation(info);
@@ -1910,38 +1981,26 @@ var MSafeClient = class _MSafeClient {
1910
1981
  };
1911
1982
 
1912
1983
  // src/backend/types/notification.ts
1913
- var InfoTypeKey;
1914
- (function(InfoTypeKey2) {
1984
+ var InfoTypeKey = /* @__PURE__ */ ((InfoTypeKey2) => {
1915
1985
  InfoTypeKey2["receive"] = "info_type_receive";
1916
1986
  InfoTypeKey2["send"] = "info_type_send";
1917
1987
  InfoTypeKey2["invitation"] = "info_type_invitation";
1918
1988
  InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
1919
- })(InfoTypeKey || (InfoTypeKey = {}));
1989
+ return InfoTypeKey2;
1990
+ })(InfoTypeKey || {});
1920
1991
  var NotificationSubscribeDto = class {
1921
- static {
1922
- __name(this, "NotificationSubscribeDto");
1923
- }
1924
1992
  email;
1925
1993
  };
1926
1994
  var NotificationUpdateDto = class {
1927
- static {
1928
- __name(this, "NotificationUpdateDto");
1929
- }
1930
1995
  email;
1931
1996
  infoTypes;
1932
1997
  msafeEnabled;
1933
1998
  };
1934
1999
  var InfoTypeEnabledDto = class {
1935
- static {
1936
- __name(this, "InfoTypeEnabledDto");
1937
- }
1938
2000
  infoType;
1939
2001
  enabled;
1940
2002
  };
1941
2003
  var MSafeEnabledDto = class {
1942
- static {
1943
- __name(this, "MSafeEnabledDto");
1944
- }
1945
2004
  msafeAddress;
1946
2005
  enabled;
1947
2006
  };