@msafe/sui3-sdk 0.0.89 → 1.0.4
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 +377 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -29
- package/dist/index.d.ts +35 -29
- package/dist/index.js +386 -175
- package/dist/index.js.map +1 -1
- package/package.json +34 -19
- package/src/backend/BackendImpl.ts +3 -3
- package/src/backend/interface.ts +2 -2
- package/src/core/CreateHelper.ts +6 -6
- package/src/core/MSafeAccount.ts +76 -66
- package/src/core/PublicKeyHelper.ts +2 -2
- package/src/globals/MSafeGlobals.ts +20 -7
- package/src/globals/const.ts +21 -5
- package/src/simulate/simulator.ts +60 -17
- package/src/types/assets.ts +3 -1
- package/src/types/msafe.ts +15 -7
- package/src/types/wallet.ts +7 -12
- package/src/utils/coin.ts +20 -7
- package/src/utils/crypto.ts +8 -13
- package/src/utils/format.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/iter/object.ts +56 -43
- package/src/utils/sui.ts +71 -21
- package/src/utils/transaction.ts +12 -0
- package/tsconfig.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
10
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -62,13 +63,20 @@ __export(src_exports, {
|
|
|
62
63
|
getAllCoins: () => getAllCoins,
|
|
63
64
|
getMSafeConfig: () => getMSafeConfig,
|
|
64
65
|
getPublicKeyFromChain: () => getPublicKeyFromChain,
|
|
65
|
-
|
|
66
|
+
msafeChainToSuiNetwork: () => msafeChainToSuiNetwork,
|
|
67
|
+
stringToBuffer: () => stringToBuffer,
|
|
68
|
+
toSuiTransaction: () => toSuiTransaction
|
|
66
69
|
});
|
|
67
70
|
module.exports = __toCommonJS(src_exports);
|
|
68
71
|
|
|
69
72
|
// src/core/CreateHelper.ts
|
|
70
73
|
var import_sui3_utils = require("@msafe/sui3-utils");
|
|
71
74
|
var CreateHelper = class {
|
|
75
|
+
static {
|
|
76
|
+
__name(this, "CreateHelper");
|
|
77
|
+
}
|
|
78
|
+
globals;
|
|
79
|
+
pkHelper;
|
|
72
80
|
constructor(globals, pkHelper) {
|
|
73
81
|
this.globals = globals;
|
|
74
82
|
this.pkHelper = pkHelper;
|
|
@@ -86,13 +94,13 @@ var CreateHelper = class {
|
|
|
86
94
|
return this.calculateMSafeAddress(createInfo);
|
|
87
95
|
}
|
|
88
96
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
* Add user manually added public key for an address. If user input the public key with
|
|
98
|
+
* extra signature scheme flag, the scheme value will be automatically fixed.
|
|
99
|
+
*
|
|
100
|
+
* @param address
|
|
101
|
+
* @param pkEncoded
|
|
102
|
+
* @throws error if the public key does not match
|
|
103
|
+
*/
|
|
96
104
|
addPublicKey(address, pkEncoded) {
|
|
97
105
|
const pk = import_sui3_utils.PublicKeySerde.de(pkEncoded);
|
|
98
106
|
if (!(0, import_sui3_utils.isSameAddress)(address, pk.toSuiAddress())) {
|
|
@@ -103,7 +111,9 @@ var CreateHelper = class {
|
|
|
103
111
|
async submitMSafeCreation(creationInfo) {
|
|
104
112
|
const msafeAddress = await this.validateCreateInfo(creationInfo);
|
|
105
113
|
const signingMessage = import_sui3_utils.SigningMessageHelper.createMSafeMessage(msafeAddress);
|
|
106
|
-
const signature = await this.globals.wallet.signPersonalMessage({
|
|
114
|
+
const signature = await this.globals.wallet.signPersonalMessage({
|
|
115
|
+
messageStr: signingMessage
|
|
116
|
+
});
|
|
107
117
|
await this.submitToBackend(creationInfo, signature.signature);
|
|
108
118
|
return msafeAddress;
|
|
109
119
|
}
|
|
@@ -134,9 +144,7 @@ var CreateHelper = class {
|
|
|
134
144
|
})),
|
|
135
145
|
threshold: createInfo.threshold,
|
|
136
146
|
name: createInfo.name,
|
|
137
|
-
// name validation is deferred to backend
|
|
138
147
|
description: createInfo.description,
|
|
139
|
-
// description validation is deferred to backend
|
|
140
148
|
creationNonce: createInfo.creationNonce,
|
|
141
149
|
signature
|
|
142
150
|
});
|
|
@@ -149,6 +157,10 @@ var import_sui3_utils7 = require("@msafe/sui3-utils");
|
|
|
149
157
|
// src/core/AddressBookSDK.ts
|
|
150
158
|
var import_sui3_utils2 = require("@msafe/sui3-utils");
|
|
151
159
|
var AddressBookSDK = class {
|
|
160
|
+
static {
|
|
161
|
+
__name(this, "AddressBookSDK");
|
|
162
|
+
}
|
|
163
|
+
globals;
|
|
152
164
|
constructor(globals) {
|
|
153
165
|
this.globals = globals;
|
|
154
166
|
}
|
|
@@ -157,52 +169,75 @@ var AddressBookSDK = class {
|
|
|
157
169
|
}
|
|
158
170
|
async update(updates) {
|
|
159
171
|
const messageStr = import_sui3_utils2.SigningMessageHelper.updateAddressBookMessage(updates);
|
|
160
|
-
const sig = await this.globals.wallet.signPersonalMessage({
|
|
161
|
-
|
|
172
|
+
const sig = await this.globals.wallet.signPersonalMessage({
|
|
173
|
+
messageStr
|
|
174
|
+
});
|
|
175
|
+
return this.globals.backend.updateAddressBook({
|
|
176
|
+
updates,
|
|
177
|
+
signature: sig.signature
|
|
178
|
+
});
|
|
162
179
|
}
|
|
163
180
|
async getMode() {
|
|
164
181
|
const res = await this.globals.backend.getAddressBookMode();
|
|
165
182
|
return res.mode;
|
|
166
183
|
}
|
|
167
184
|
async setMode(mode) {
|
|
168
|
-
return this.globals.backend.setAddressBookMode({
|
|
185
|
+
return this.globals.backend.setAddressBookMode({
|
|
186
|
+
mode
|
|
187
|
+
});
|
|
169
188
|
}
|
|
170
189
|
};
|
|
171
190
|
|
|
172
191
|
// src/core/InvitationSDK.ts
|
|
173
192
|
var InvitationSDK = class {
|
|
193
|
+
static {
|
|
194
|
+
__name(this, "InvitationSDK");
|
|
195
|
+
}
|
|
196
|
+
globals;
|
|
174
197
|
constructor(globals) {
|
|
175
198
|
this.globals = globals;
|
|
176
199
|
}
|
|
177
200
|
async getMSafeByStatus(status, pagination) {
|
|
178
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
201
|
+
return this.globals.backend.getOwnedMSafeByStatus({
|
|
202
|
+
status,
|
|
203
|
+
pagination
|
|
204
|
+
});
|
|
179
205
|
}
|
|
180
206
|
async updateMSafeStatus(msafeAddress, status) {
|
|
181
|
-
return this.globals.backend.updateMSafeStatus({
|
|
207
|
+
return this.globals.backend.updateMSafeStatus({
|
|
208
|
+
msafeAddress,
|
|
209
|
+
status
|
|
210
|
+
});
|
|
182
211
|
}
|
|
183
212
|
};
|
|
184
213
|
|
|
185
214
|
// src/core/MSafeAccount.ts
|
|
186
215
|
var import_sui_app_store = require("@msafe/sui-app-store");
|
|
187
216
|
var import_sui3_utils4 = require("@msafe/sui3-utils");
|
|
188
|
-
var
|
|
189
|
-
var import_utils3 = require("@mysten/sui
|
|
217
|
+
var import_transactions3 = require("@mysten/sui/transactions");
|
|
218
|
+
var import_utils3 = require("@mysten/sui/utils");
|
|
190
219
|
var import_wallet_standard = require("@mysten/wallet-standard");
|
|
191
220
|
|
|
192
221
|
// src/simulate/simulator.ts
|
|
193
|
-
var import_transactions = require("@mysten/sui
|
|
222
|
+
var import_transactions = require("@mysten/sui/transactions");
|
|
194
223
|
var GAS_SAFE_OVERHEAD = 1000n;
|
|
195
224
|
var Simulator = class {
|
|
225
|
+
static {
|
|
226
|
+
__name(this, "Simulator");
|
|
227
|
+
}
|
|
228
|
+
globals;
|
|
196
229
|
constructor(globals) {
|
|
197
230
|
this.globals = globals;
|
|
198
231
|
}
|
|
199
232
|
async simulate(input) {
|
|
200
|
-
const tx = this.
|
|
233
|
+
const tx = this.copyTransaction(input.txb);
|
|
201
234
|
const { suiClient } = this.globals;
|
|
202
235
|
const gasPrice = await this.getGasPrice();
|
|
203
236
|
tx.setGasPrice(gasPrice);
|
|
204
237
|
const inspectResult = await suiClient.dryRunTransactionBlock({
|
|
205
|
-
transactionBlock: await tx.build({
|
|
238
|
+
transactionBlock: await tx.build({
|
|
239
|
+
client: suiClient
|
|
240
|
+
})
|
|
206
241
|
});
|
|
207
242
|
const success = inspectResult.effects.status.status === "success";
|
|
208
243
|
if (!success) {
|
|
@@ -233,8 +268,8 @@ var Simulator = class {
|
|
|
233
268
|
const gasBudget = baseComputationCostWithOverhead + BigInt(storageCost) - BigInt(storageRebate);
|
|
234
269
|
return gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead;
|
|
235
270
|
}
|
|
236
|
-
|
|
237
|
-
return import_transactions.
|
|
271
|
+
copyTransaction(tx) {
|
|
272
|
+
return import_transactions.Transaction.from(tx.serialize());
|
|
238
273
|
}
|
|
239
274
|
};
|
|
240
275
|
|
|
@@ -243,22 +278,28 @@ var import_buffer = require("buffer");
|
|
|
243
278
|
function stringToBuffer(s) {
|
|
244
279
|
return import_buffer.Buffer.from(s, "utf-8");
|
|
245
280
|
}
|
|
281
|
+
__name(stringToBuffer, "stringToBuffer");
|
|
246
282
|
function Uint8ArrayToHex(b) {
|
|
247
283
|
return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
|
|
248
284
|
}
|
|
285
|
+
__name(Uint8ArrayToHex, "Uint8ArrayToHex");
|
|
249
286
|
function HexToUint8Array(hex) {
|
|
250
287
|
return Uint8Array.from(import_buffer.Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
|
|
251
288
|
}
|
|
289
|
+
__name(HexToUint8Array, "HexToUint8Array");
|
|
252
290
|
|
|
253
291
|
// src/utils/crypto.ts
|
|
254
|
-
var import_verify = require("@mysten/sui
|
|
292
|
+
var import_verify = require("@mysten/sui/verify");
|
|
255
293
|
|
|
256
294
|
// src/utils/format.ts
|
|
257
|
-
var import_utils2 = require("@mysten/sui
|
|
295
|
+
var import_utils2 = require("@mysten/sui/utils");
|
|
258
296
|
|
|
259
297
|
// src/utils/coin.ts
|
|
260
|
-
var import_utils = require("@mysten/sui
|
|
298
|
+
var import_utils = require("@mysten/sui/utils");
|
|
261
299
|
var CoinHelper = class {
|
|
300
|
+
static {
|
|
301
|
+
__name(this, "CoinHelper");
|
|
302
|
+
}
|
|
262
303
|
_client;
|
|
263
304
|
_coinMetaReg;
|
|
264
305
|
constructor(client) {
|
|
@@ -277,12 +318,17 @@ var CoinHelper = class {
|
|
|
277
318
|
return meta;
|
|
278
319
|
}
|
|
279
320
|
async queryCoinMeta(coinType) {
|
|
280
|
-
const res = await this._client.getCoinMetadata({
|
|
321
|
+
const res = await this._client.getCoinMetadata({
|
|
322
|
+
coinType
|
|
323
|
+
});
|
|
281
324
|
return res || void 0;
|
|
282
325
|
}
|
|
283
326
|
};
|
|
284
327
|
var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
|
|
285
328
|
var Coin = class _Coin {
|
|
329
|
+
static {
|
|
330
|
+
__name(this, "Coin");
|
|
331
|
+
}
|
|
286
332
|
static isCoin(type) {
|
|
287
333
|
if (!type) {
|
|
288
334
|
return false;
|
|
@@ -310,6 +356,9 @@ var Coin = class _Coin {
|
|
|
310
356
|
|
|
311
357
|
// src/utils/format.ts
|
|
312
358
|
var Formatter = class {
|
|
359
|
+
static {
|
|
360
|
+
__name(this, "Formatter");
|
|
361
|
+
}
|
|
313
362
|
static normalizeSuiAddress(addr) {
|
|
314
363
|
return (0, import_utils2.normalizeSuiAddress)(addr);
|
|
315
364
|
}
|
|
@@ -332,14 +381,18 @@ function addPrefix(s, prefix) {
|
|
|
332
381
|
}
|
|
333
382
|
return prefix + s;
|
|
334
383
|
}
|
|
384
|
+
__name(addPrefix, "addPrefix");
|
|
335
385
|
|
|
336
386
|
// src/utils/crypto.ts
|
|
337
387
|
var SignatureVerifier = class _SignatureVerifier {
|
|
388
|
+
static {
|
|
389
|
+
__name(this, "SignatureVerifier");
|
|
390
|
+
}
|
|
338
391
|
static async getPublicKeyFromSignature(input) {
|
|
339
392
|
if (input.messageType === "TransactionBlock") {
|
|
340
|
-
return (0, import_verify.
|
|
393
|
+
return (0, import_verify.verifyTransactionSignature)(input.message, input.signature);
|
|
341
394
|
}
|
|
342
|
-
return (0, import_verify.
|
|
395
|
+
return (0, import_verify.verifyPersonalMessageSignature)(input.message, input.signature);
|
|
343
396
|
}
|
|
344
397
|
static async getPublicKeyFromPersonalSignature(input) {
|
|
345
398
|
const message = stringToBuffer(input.messageStr);
|
|
@@ -374,16 +427,20 @@ var SignatureVerifier = class _SignatureVerifier {
|
|
|
374
427
|
|
|
375
428
|
// src/utils/sui.ts
|
|
376
429
|
var import_sui3_utils3 = require("@msafe/sui3-utils");
|
|
377
|
-
var import_cryptography = require("@mysten/sui
|
|
378
|
-
var import_multisig = require("@mysten/sui
|
|
430
|
+
var import_cryptography = require("@mysten/sui/cryptography");
|
|
431
|
+
var import_multisig = require("@mysten/sui/multisig");
|
|
379
432
|
var SUI_COIN = "0x2::sui::SUI";
|
|
380
433
|
async function getPublicKeyFromChain(suiClient, address) {
|
|
381
434
|
let txs;
|
|
382
435
|
try {
|
|
383
436
|
txs = await suiClient.queryTransactionBlocks({
|
|
384
437
|
// Disable naming rule since the variable is defined by Mysten
|
|
385
|
-
filter: {
|
|
386
|
-
|
|
438
|
+
filter: {
|
|
439
|
+
FromAddress: address
|
|
440
|
+
},
|
|
441
|
+
options: {
|
|
442
|
+
showInput: true
|
|
443
|
+
},
|
|
387
444
|
limit: 2
|
|
388
445
|
});
|
|
389
446
|
} catch (e) {
|
|
@@ -404,6 +461,7 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
404
461
|
}
|
|
405
462
|
return void 0;
|
|
406
463
|
}
|
|
464
|
+
__name(getPublicKeyFromChain, "getPublicKeyFromChain");
|
|
407
465
|
function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
408
466
|
const decoded = (0, import_cryptography.parseSerializedSignature)(serializedSig);
|
|
409
467
|
switch (decoded.signatureScheme) {
|
|
@@ -418,7 +476,10 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
418
476
|
case "ED25519":
|
|
419
477
|
case "Secp256k1":
|
|
420
478
|
case "Secp256r1": {
|
|
421
|
-
const pk = import_sui3_utils3.PublicKeySerde.de({
|
|
479
|
+
const pk = import_sui3_utils3.PublicKeySerde.de({
|
|
480
|
+
publicKeyEncoded: decoded.publicKey,
|
|
481
|
+
schema: decoded.signatureScheme
|
|
482
|
+
});
|
|
422
483
|
if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
|
|
423
484
|
return pk;
|
|
424
485
|
}
|
|
@@ -428,6 +489,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
428
489
|
throw new Error("Unknown schema");
|
|
429
490
|
}
|
|
430
491
|
}
|
|
492
|
+
__name(getAddressFromSignatures, "getAddressFromSignatures");
|
|
431
493
|
async function getAllCoins(input) {
|
|
432
494
|
let hasNext = true;
|
|
433
495
|
let cursor;
|
|
@@ -444,6 +506,18 @@ async function getAllCoins(input) {
|
|
|
444
506
|
}
|
|
445
507
|
return res;
|
|
446
508
|
}
|
|
509
|
+
__name(getAllCoins, "getAllCoins");
|
|
510
|
+
|
|
511
|
+
// src/utils/transaction.ts
|
|
512
|
+
var import_transactions2 = require("@mysten/sui/transactions");
|
|
513
|
+
function toSuiTransaction(txb) {
|
|
514
|
+
if ((0, import_transactions2.isTransaction)(txb)) {
|
|
515
|
+
return txb;
|
|
516
|
+
}
|
|
517
|
+
const legacy = txb;
|
|
518
|
+
return import_transactions2.Transaction.from(legacy.serialize());
|
|
519
|
+
}
|
|
520
|
+
__name(toSuiTransaction, "toSuiTransaction");
|
|
447
521
|
|
|
448
522
|
// src/utils/iter/iterator.ts
|
|
449
523
|
var REQUEST_PAGE_SIZE = 25;
|
|
@@ -458,14 +532,19 @@ async function getAllFromIterator(it) {
|
|
|
458
532
|
}
|
|
459
533
|
return res;
|
|
460
534
|
}
|
|
535
|
+
__name(getAllFromIterator, "getAllFromIterator");
|
|
461
536
|
var PagedIterator = class {
|
|
537
|
+
static {
|
|
538
|
+
__name(this, "PagedIterator");
|
|
539
|
+
}
|
|
540
|
+
requester;
|
|
541
|
+
curPage;
|
|
542
|
+
init;
|
|
462
543
|
constructor(requester) {
|
|
463
544
|
this.requester = requester;
|
|
464
545
|
this.curPage = void 0;
|
|
465
546
|
this.init = true;
|
|
466
547
|
}
|
|
467
|
-
curPage;
|
|
468
|
-
init;
|
|
469
548
|
async hasNext() {
|
|
470
549
|
if (this.init) {
|
|
471
550
|
if (!this.curPage) {
|
|
@@ -491,15 +570,19 @@ var PagedIterator = class {
|
|
|
491
570
|
}
|
|
492
571
|
};
|
|
493
572
|
var EntryIterator = class {
|
|
573
|
+
static {
|
|
574
|
+
__name(this, "EntryIterator");
|
|
575
|
+
}
|
|
576
|
+
requester;
|
|
577
|
+
cursor;
|
|
578
|
+
pager;
|
|
579
|
+
curData;
|
|
494
580
|
constructor(requester) {
|
|
495
581
|
this.requester = requester;
|
|
496
582
|
this.pager = new PagedIterator(requester);
|
|
497
583
|
this.curData = [];
|
|
498
584
|
this.cursor = 0;
|
|
499
585
|
}
|
|
500
|
-
cursor;
|
|
501
|
-
pager;
|
|
502
|
-
curData;
|
|
503
586
|
async hasNext() {
|
|
504
587
|
if (this.cursor < this.curData.length - 1) {
|
|
505
588
|
return true;
|
|
@@ -525,7 +608,14 @@ async function getAllOwnedObjects(provider, owner, options) {
|
|
|
525
608
|
const iter = new OwnedObjectIterator(provider, owner, options);
|
|
526
609
|
return await getAllFromIterator(iter);
|
|
527
610
|
}
|
|
611
|
+
__name(getAllOwnedObjects, "getAllOwnedObjects");
|
|
528
612
|
var OwnedObjectIterator = class extends EntryIterator {
|
|
613
|
+
static {
|
|
614
|
+
__name(this, "OwnedObjectIterator");
|
|
615
|
+
}
|
|
616
|
+
provider;
|
|
617
|
+
owner;
|
|
618
|
+
options;
|
|
529
619
|
constructor(provider, owner, options) {
|
|
530
620
|
super(new OwnedObjectRequester(provider, owner, options));
|
|
531
621
|
this.provider = provider;
|
|
@@ -534,6 +624,16 @@ var OwnedObjectIterator = class extends EntryIterator {
|
|
|
534
624
|
}
|
|
535
625
|
};
|
|
536
626
|
var OwnedObjectRequester = class {
|
|
627
|
+
static {
|
|
628
|
+
__name(this, "OwnedObjectRequester");
|
|
629
|
+
}
|
|
630
|
+
provider;
|
|
631
|
+
owner;
|
|
632
|
+
options;
|
|
633
|
+
nextCursor;
|
|
634
|
+
filter;
|
|
635
|
+
pageSize;
|
|
636
|
+
objectOptions;
|
|
537
637
|
constructor(provider, owner, options) {
|
|
538
638
|
this.provider = provider;
|
|
539
639
|
this.owner = owner;
|
|
@@ -546,10 +646,6 @@ var OwnedObjectRequester = class {
|
|
|
546
646
|
showContent: true
|
|
547
647
|
};
|
|
548
648
|
}
|
|
549
|
-
nextCursor;
|
|
550
|
-
filter;
|
|
551
|
-
pageSize;
|
|
552
|
-
objectOptions;
|
|
553
649
|
async doNextRequest() {
|
|
554
650
|
const res = await this.provider.getOwnedObjects({
|
|
555
651
|
owner: this.owner,
|
|
@@ -574,6 +670,14 @@ var OwnedObjectRequester = class {
|
|
|
574
670
|
|
|
575
671
|
// src/core/MSafeAccount.ts
|
|
576
672
|
var MSafeAccount = class _MSafeAccount {
|
|
673
|
+
static {
|
|
674
|
+
__name(this, "MSafeAccount");
|
|
675
|
+
}
|
|
676
|
+
globals;
|
|
677
|
+
info;
|
|
678
|
+
multiSig;
|
|
679
|
+
simulator;
|
|
680
|
+
coinHelper;
|
|
577
681
|
constructor(globals, info) {
|
|
578
682
|
this.globals = globals;
|
|
579
683
|
this.info = info;
|
|
@@ -585,9 +689,6 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
585
689
|
this.coinHelper = new CoinHelper(this.suiClient);
|
|
586
690
|
this.simulator = new Simulator(globals);
|
|
587
691
|
}
|
|
588
|
-
multiSig;
|
|
589
|
-
simulator;
|
|
590
|
-
coinHelper;
|
|
591
692
|
static async New(globals, address) {
|
|
592
693
|
const info = await globals.backend.getMSafeAccountInfo(address);
|
|
593
694
|
const ms = new _MSafeAccount(globals, info);
|
|
@@ -596,18 +697,19 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
596
697
|
}
|
|
597
698
|
}
|
|
598
699
|
async ownedCoins() {
|
|
599
|
-
const balances = await this.suiClient.getAllBalances({
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
700
|
+
const balances = await this.suiClient.getAllBalances({
|
|
701
|
+
owner: this.address
|
|
702
|
+
});
|
|
703
|
+
return Promise.all(balances.map(async (balance) => {
|
|
704
|
+
const meta = await this.coinHelper.getCoinMeta(balance.coinType);
|
|
705
|
+
const lockedEntry = balance.lockedBalance && typeof balance.lockedBalance === "object" && "number" in balance.lockedBalance && balance.lockedBalance.number ? BigInt(balance.lockedBalance.number) : 0n;
|
|
706
|
+
const unlockedBalance = lockedEntry ? BigInt(balance.totalBalance) - lockedEntry : BigInt(balance.totalBalance);
|
|
707
|
+
return {
|
|
708
|
+
type: (0, import_utils3.normalizeStructTag)(balance.coinType),
|
|
709
|
+
balance: unlockedBalance,
|
|
710
|
+
metadata: meta
|
|
711
|
+
};
|
|
712
|
+
}));
|
|
611
713
|
}
|
|
612
714
|
async ownedObjects(options) {
|
|
613
715
|
const filterCoinObjectOptions = {
|
|
@@ -617,7 +719,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
617
719
|
return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
|
|
618
720
|
}
|
|
619
721
|
async pendingTransaction() {
|
|
620
|
-
const res = await this.backend.getPendingTransactions({
|
|
722
|
+
const res = await this.backend.getPendingTransactions({
|
|
723
|
+
msafeAddress: this.address
|
|
724
|
+
});
|
|
621
725
|
if (!res?.pending) {
|
|
622
726
|
return void 0;
|
|
623
727
|
}
|
|
@@ -649,7 +753,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
649
753
|
});
|
|
650
754
|
}
|
|
651
755
|
async futureIntentions(pagination) {
|
|
652
|
-
return this.backend.getFutureIntentions({
|
|
756
|
+
return this.backend.getFutureIntentions({
|
|
757
|
+
msafeAddress: this.address,
|
|
758
|
+
...pagination
|
|
759
|
+
});
|
|
653
760
|
}
|
|
654
761
|
async currentSequenceNumber() {
|
|
655
762
|
return this.backend.getCurrentSequenceNumber(this.address);
|
|
@@ -666,7 +773,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
666
773
|
if (!appHelper) {
|
|
667
774
|
throw new Error(`Can't find app helper for application ${request.application}`);
|
|
668
775
|
}
|
|
669
|
-
txb = await appHelper.build({
|
|
776
|
+
txb = toSuiTransaction(await appHelper.build({
|
|
670
777
|
network: this.globals.config.network,
|
|
671
778
|
intentionData: request.intention,
|
|
672
779
|
txType: request.txType,
|
|
@@ -674,14 +781,20 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
674
781
|
clientUrl: this.globals.config.suiClient.url,
|
|
675
782
|
account: {
|
|
676
783
|
address: this.address,
|
|
677
|
-
publicKey: (0, import_utils3.
|
|
678
|
-
chains: [
|
|
784
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
785
|
+
chains: [
|
|
786
|
+
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
787
|
+
import_wallet_standard.SUI_TESTNET_CHAIN
|
|
788
|
+
],
|
|
679
789
|
features: []
|
|
680
790
|
}
|
|
681
|
-
});
|
|
791
|
+
}));
|
|
682
792
|
}
|
|
683
793
|
txb.setSender(this.address);
|
|
684
|
-
return this.simulator.simulate({
|
|
794
|
+
return this.simulator.simulate({
|
|
795
|
+
txb,
|
|
796
|
+
sender: this.address
|
|
797
|
+
});
|
|
685
798
|
}
|
|
686
799
|
async proposeIntention(input) {
|
|
687
800
|
const message = import_sui3_utils4.SigningMessageHelper.proposeIntentionMessage({
|
|
@@ -707,7 +820,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
707
820
|
if (!appHelper) {
|
|
708
821
|
throw new Error(`Can't find app helper for application ${input.application}`);
|
|
709
822
|
}
|
|
710
|
-
txb = await appHelper.build({
|
|
823
|
+
txb = toSuiTransaction(await appHelper.build({
|
|
711
824
|
network: this.globals.config.network,
|
|
712
825
|
intentionData: input.intention,
|
|
713
826
|
txType: input.txType,
|
|
@@ -715,21 +828,30 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
715
828
|
clientUrl: this.globals.config.suiClient.url,
|
|
716
829
|
account: {
|
|
717
830
|
address: this.address,
|
|
718
|
-
publicKey: (0, import_utils3.
|
|
719
|
-
chains: [
|
|
831
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
832
|
+
chains: [
|
|
833
|
+
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
834
|
+
import_wallet_standard.SUI_TESTNET_CHAIN
|
|
835
|
+
],
|
|
720
836
|
features: []
|
|
721
837
|
}
|
|
722
|
-
});
|
|
838
|
+
}));
|
|
723
839
|
}
|
|
724
840
|
txb.setGasPrice(input.gasPrice);
|
|
725
841
|
txb.setGasBudget(input.gasBudget);
|
|
726
842
|
txb.setSender(this.address);
|
|
727
|
-
const payload = await txb.build({
|
|
728
|
-
|
|
729
|
-
|
|
843
|
+
const payload = await txb.build({
|
|
844
|
+
client: this.globals.suiClient
|
|
845
|
+
});
|
|
846
|
+
const digest = await txb.getDigest({
|
|
847
|
+
client: this.globals.suiClient
|
|
848
|
+
});
|
|
849
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
850
|
+
transactionBlock: payload
|
|
851
|
+
});
|
|
730
852
|
return this.backend.proposeIntentionAndBuildVote({
|
|
731
853
|
...input,
|
|
732
|
-
payload: (0, import_utils3.
|
|
854
|
+
payload: (0, import_utils3.toHex)(payload),
|
|
733
855
|
digest,
|
|
734
856
|
msafeAddress: this.address,
|
|
735
857
|
signature: signature.signature
|
|
@@ -787,8 +909,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
787
909
|
}
|
|
788
910
|
async proposePlainPayloadIntention(intention) {
|
|
789
911
|
const sn = await this.nextSequenceNumber();
|
|
790
|
-
const tb =
|
|
791
|
-
|
|
912
|
+
const tb = import_transactions3.Transaction.from(intention.payload);
|
|
913
|
+
const data = tb.getData();
|
|
914
|
+
if (!data.sender || !(0, import_sui3_utils4.isSameAddress)(data.sender, this.address)) {
|
|
792
915
|
throw new Error("Transaction sender is not same as the multisig address");
|
|
793
916
|
}
|
|
794
917
|
return this.proposeIntention({
|
|
@@ -801,7 +924,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
801
924
|
}
|
|
802
925
|
async voteForTransaction(digest, payload) {
|
|
803
926
|
const payloadBytes = HexToUint8Array(payload);
|
|
804
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
927
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
928
|
+
transactionBlock: payloadBytes
|
|
929
|
+
});
|
|
805
930
|
return this.backend.voteForTransaction({
|
|
806
931
|
msafeAddress: this.address,
|
|
807
932
|
digest,
|
|
@@ -813,19 +938,28 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
813
938
|
if (!pendingTx || pendingTx.rejectDigest !== "") {
|
|
814
939
|
throw new Error("Already rejected");
|
|
815
940
|
}
|
|
816
|
-
const txb = (0, import_sui3_utils4.buildRejectTxb)(this.address);
|
|
941
|
+
const txb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
|
|
817
942
|
txb.setSender(this.address);
|
|
818
|
-
return this.simulator.simulate({
|
|
943
|
+
return this.simulator.simulate({
|
|
944
|
+
txb,
|
|
945
|
+
sender: this.address
|
|
946
|
+
});
|
|
819
947
|
}
|
|
820
948
|
async rejectCurrentTx(input) {
|
|
821
949
|
const pendingTx = await this.pendingTransaction();
|
|
822
950
|
if (!pendingTx || pendingTx.rejectDigest !== "") {
|
|
823
951
|
throw new Error("Already rejected");
|
|
824
952
|
}
|
|
825
|
-
const rejectTxb = (0, import_sui3_utils4.buildRejectTxb)(this.address);
|
|
826
|
-
const digest = await rejectTxb.getDigest({
|
|
827
|
-
|
|
828
|
-
|
|
953
|
+
const rejectTxb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
|
|
954
|
+
const digest = await rejectTxb.getDigest({
|
|
955
|
+
client: this.suiClient
|
|
956
|
+
});
|
|
957
|
+
const payload = await rejectTxb.build({
|
|
958
|
+
client: this.suiClient
|
|
959
|
+
});
|
|
960
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
961
|
+
transactionBlock: payload
|
|
962
|
+
});
|
|
829
963
|
return this.backend.rejectCurrentTx({
|
|
830
964
|
msafeAddress: this.address,
|
|
831
965
|
digest,
|
|
@@ -834,12 +968,14 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
834
968
|
});
|
|
835
969
|
}
|
|
836
970
|
async simulateBuildTransaction() {
|
|
837
|
-
const intention = await this.backend.getNextIntention({
|
|
971
|
+
const intention = await this.backend.getNextIntention({
|
|
972
|
+
msafeAddress: this.address
|
|
973
|
+
});
|
|
838
974
|
const appHelper = import_sui_app_store.appHelpers.getAppHelper(intention.application);
|
|
839
975
|
if (!appHelper) {
|
|
840
976
|
throw new Error(`Can't find app helper for application ${intention.application}`);
|
|
841
977
|
}
|
|
842
|
-
const txb = await appHelper.build({
|
|
978
|
+
const txb = toSuiTransaction(await appHelper.build({
|
|
843
979
|
network: this.globals.config.network,
|
|
844
980
|
intentionData: intention.intention,
|
|
845
981
|
txType: intention.txType,
|
|
@@ -847,13 +983,19 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
847
983
|
clientUrl: this.globals.config.suiClient.url,
|
|
848
984
|
account: {
|
|
849
985
|
address: this.address,
|
|
850
|
-
publicKey: (0, import_utils3.
|
|
851
|
-
chains: [
|
|
986
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
987
|
+
chains: [
|
|
988
|
+
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
989
|
+
import_wallet_standard.SUI_TESTNET_CHAIN
|
|
990
|
+
],
|
|
852
991
|
features: []
|
|
853
992
|
}
|
|
854
|
-
});
|
|
993
|
+
}));
|
|
855
994
|
txb.setSender(this.address);
|
|
856
|
-
return this.simulator.simulate({
|
|
995
|
+
return this.simulator.simulate({
|
|
996
|
+
txb,
|
|
997
|
+
sender: this.address
|
|
998
|
+
});
|
|
857
999
|
}
|
|
858
1000
|
async buildNextIntentionAndAddToPending(gasOption) {
|
|
859
1001
|
return this.backend.buildNextIntentionAndAddToPending({
|
|
@@ -864,10 +1006,14 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
864
1006
|
});
|
|
865
1007
|
}
|
|
866
1008
|
async skipNextFailedIntention() {
|
|
867
|
-
return this.backend.skipNextFailedIntention({
|
|
1009
|
+
return this.backend.skipNextFailedIntention({
|
|
1010
|
+
msafeAddress: this.address
|
|
1011
|
+
});
|
|
868
1012
|
}
|
|
869
1013
|
async fetchTransaction() {
|
|
870
|
-
return this.backend.fetchTransaction({
|
|
1014
|
+
return this.backend.fetchTransaction({
|
|
1015
|
+
msafeAddress: this.address
|
|
1016
|
+
});
|
|
871
1017
|
}
|
|
872
1018
|
async executePendingTx(pending, isRejectTx = false) {
|
|
873
1019
|
const votes = isRejectTx ? pending.rejectVotes : pending.votes;
|
|
@@ -876,7 +1022,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
876
1022
|
throw new Error("Not enough signature");
|
|
877
1023
|
}
|
|
878
1024
|
const sortedSigs = [];
|
|
879
|
-
const gotSigs = new Map(votes.map((vote) => [
|
|
1025
|
+
const gotSigs = new Map(votes.map((vote) => [
|
|
1026
|
+
vote.userAddress,
|
|
1027
|
+
vote.signature
|
|
1028
|
+
]));
|
|
880
1029
|
for (let i = 0; i < this.info.owners.length; i++) {
|
|
881
1030
|
const owner = this.info.owners[i];
|
|
882
1031
|
const signature = gotSigs.get(owner.address);
|
|
@@ -888,7 +1037,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
888
1037
|
return this.suiClient.executeTransactionBlock({
|
|
889
1038
|
transactionBlock: HexToUint8Array(payload),
|
|
890
1039
|
signature: multiSignature,
|
|
891
|
-
options: {
|
|
1040
|
+
options: {
|
|
1041
|
+
showEffects: true,
|
|
1042
|
+
showEvents: true
|
|
1043
|
+
}
|
|
892
1044
|
});
|
|
893
1045
|
}
|
|
894
1046
|
async dashboard() {
|
|
@@ -928,13 +1080,17 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
928
1080
|
|
|
929
1081
|
// src/core/PublicKeyHelper.ts
|
|
930
1082
|
var import_sui3_utils5 = require("@msafe/sui3-utils");
|
|
931
|
-
var import_utils5 = require("@mysten/sui
|
|
1083
|
+
var import_utils5 = require("@mysten/sui/utils");
|
|
932
1084
|
var PublicKeyHelper = class {
|
|
1085
|
+
static {
|
|
1086
|
+
__name(this, "PublicKeyHelper");
|
|
1087
|
+
}
|
|
1088
|
+
globals;
|
|
1089
|
+
knownPublicKeys;
|
|
933
1090
|
constructor(globals) {
|
|
934
1091
|
this.globals = globals;
|
|
935
1092
|
this.knownPublicKeys = /* @__PURE__ */ new Map();
|
|
936
1093
|
}
|
|
937
|
-
knownPublicKeys;
|
|
938
1094
|
async getPublicKey(address) {
|
|
939
1095
|
const cached = this.knownPublicKeys.get(address);
|
|
940
1096
|
if (cached) {
|
|
@@ -1005,6 +1161,10 @@ var PublicKeyHelper = class {
|
|
|
1005
1161
|
|
|
1006
1162
|
// src/core/ReportSDK.ts
|
|
1007
1163
|
var ReportSDK = class {
|
|
1164
|
+
static {
|
|
1165
|
+
__name(this, "ReportSDK");
|
|
1166
|
+
}
|
|
1167
|
+
globals;
|
|
1008
1168
|
constructor(globals) {
|
|
1009
1169
|
this.globals = globals;
|
|
1010
1170
|
}
|
|
@@ -1014,17 +1174,22 @@ var ReportSDK = class {
|
|
|
1014
1174
|
};
|
|
1015
1175
|
|
|
1016
1176
|
// src/globals/MSafeGlobals.ts
|
|
1017
|
-
var
|
|
1177
|
+
var import_jsonRpc = require("@mysten/sui/jsonRpc");
|
|
1018
1178
|
|
|
1019
1179
|
// src/backend/BackendImpl.ts
|
|
1020
1180
|
var import_sui3_utils6 = require("@msafe/sui3-utils");
|
|
1021
1181
|
var import_axios = __toESM(require("axios"), 1);
|
|
1022
1182
|
var BackendImpl = class _BackendImpl {
|
|
1183
|
+
static {
|
|
1184
|
+
__name(this, "BackendImpl");
|
|
1185
|
+
}
|
|
1186
|
+
apiURL;
|
|
1187
|
+
mockAddress;
|
|
1188
|
+
_token;
|
|
1023
1189
|
constructor(apiURL, mockAddress) {
|
|
1024
1190
|
this.apiURL = apiURL;
|
|
1025
1191
|
this.mockAddress = mockAddress;
|
|
1026
1192
|
}
|
|
1027
|
-
_token;
|
|
1028
1193
|
getNotificationInfo() {
|
|
1029
1194
|
return this.get(`/notification`, {
|
|
1030
1195
|
headers: this.headers()
|
|
@@ -1047,7 +1212,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1047
1212
|
}
|
|
1048
1213
|
async verifyToken(jwt) {
|
|
1049
1214
|
try {
|
|
1050
|
-
const res = await this.get(`/auth`, {
|
|
1215
|
+
const res = await this.get(`/auth`, {
|
|
1216
|
+
headers: this.headers(jwt)
|
|
1217
|
+
});
|
|
1051
1218
|
return res.status === 200;
|
|
1052
1219
|
} catch (_) {
|
|
1053
1220
|
return false;
|
|
@@ -1057,7 +1224,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1057
1224
|
this._token = token;
|
|
1058
1225
|
}
|
|
1059
1226
|
async getPublicKey(address) {
|
|
1060
|
-
return (await this.getPublicKeyBatch([
|
|
1227
|
+
return (await this.getPublicKeyBatch([
|
|
1228
|
+
address
|
|
1229
|
+
]))[0];
|
|
1061
1230
|
}
|
|
1062
1231
|
async getPublicKeyBatch(addresses) {
|
|
1063
1232
|
const query = {
|
|
@@ -1067,9 +1236,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1067
1236
|
params: query,
|
|
1068
1237
|
headers: this.headers()
|
|
1069
1238
|
});
|
|
1070
|
-
return res.data?.map(
|
|
1071
|
-
(publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0
|
|
1072
|
-
);
|
|
1239
|
+
return res.data?.map((publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0);
|
|
1073
1240
|
}
|
|
1074
1241
|
async getMSafeAccountInfo(msafeAddress) {
|
|
1075
1242
|
const q = {
|
|
@@ -1106,7 +1273,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1106
1273
|
}
|
|
1107
1274
|
async updateMSafeStatus(input) {
|
|
1108
1275
|
const p = input;
|
|
1109
|
-
await this.post(`/msafe/status`, p, {
|
|
1276
|
+
await this.post(`/msafe/status`, p, {
|
|
1277
|
+
headers: this.headers()
|
|
1278
|
+
});
|
|
1110
1279
|
}
|
|
1111
1280
|
async getPendingTransactions(input) {
|
|
1112
1281
|
const res = await this.get(`/transaction/pending`, {
|
|
@@ -1160,16 +1329,18 @@ var BackendImpl = class _BackendImpl {
|
|
|
1160
1329
|
});
|
|
1161
1330
|
}
|
|
1162
1331
|
async proposeIntention(input) {
|
|
1163
|
-
await this.post(`/transaction/intention`, input, {
|
|
1332
|
+
await this.post(`/transaction/intention`, input, {
|
|
1333
|
+
headers: this.headers()
|
|
1334
|
+
});
|
|
1164
1335
|
}
|
|
1165
1336
|
async rejectCurrentTx(input) {
|
|
1166
|
-
await this.post(
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
);
|
|
1337
|
+
await this.post(`/transaction/pending/reject`, {
|
|
1338
|
+
...input,
|
|
1339
|
+
gasPrice: input.gasPrice.toString(),
|
|
1340
|
+
gasBudget: input.gasBudget.toString()
|
|
1341
|
+
}, {
|
|
1342
|
+
headers: this.headers()
|
|
1343
|
+
});
|
|
1173
1344
|
}
|
|
1174
1345
|
async voteForTransaction(input) {
|
|
1175
1346
|
await this.post(`/transaction/pending/vote`, input, {
|
|
@@ -1177,24 +1348,32 @@ var BackendImpl = class _BackendImpl {
|
|
|
1177
1348
|
});
|
|
1178
1349
|
}
|
|
1179
1350
|
async buildNextIntentionAndAddToPending(input) {
|
|
1180
|
-
await this.post(
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1351
|
+
await this.post(`/transaction/pending/build`, {
|
|
1352
|
+
...input,
|
|
1353
|
+
gasPrice: input.gasPrice.toString(),
|
|
1354
|
+
gasBudget: input.gasBudget.toString()
|
|
1355
|
+
}, {
|
|
1356
|
+
headers: this.headers()
|
|
1357
|
+
});
|
|
1185
1358
|
}
|
|
1186
1359
|
async proposeIntentionAndBuildVote(input) {
|
|
1187
|
-
await this.post(
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1360
|
+
await this.post(`/transaction/intention/build`, {
|
|
1361
|
+
...input,
|
|
1362
|
+
gasPrice: input.gasPrice.toString(),
|
|
1363
|
+
gasBudget: input.gasBudget.toString()
|
|
1364
|
+
}, {
|
|
1365
|
+
headers: this.headers()
|
|
1366
|
+
});
|
|
1192
1367
|
}
|
|
1193
1368
|
async skipNextFailedIntention(input) {
|
|
1194
|
-
await this.post(`/transaction/pending/skip`, input, {
|
|
1369
|
+
await this.post(`/transaction/pending/skip`, input, {
|
|
1370
|
+
headers: this.headers()
|
|
1371
|
+
});
|
|
1195
1372
|
}
|
|
1196
1373
|
async fetchTransaction(input) {
|
|
1197
|
-
const res = await this.post(`/transaction/fetch`, input, {
|
|
1374
|
+
const res = await this.post(`/transaction/fetch`, input, {
|
|
1375
|
+
headers: this.headers()
|
|
1376
|
+
});
|
|
1198
1377
|
return res.data;
|
|
1199
1378
|
}
|
|
1200
1379
|
async getAddressBookEntries(pagination) {
|
|
@@ -1205,14 +1384,22 @@ var BackendImpl = class _BackendImpl {
|
|
|
1205
1384
|
return res.data;
|
|
1206
1385
|
}
|
|
1207
1386
|
async updateAddressBook(input) {
|
|
1208
|
-
await this.post(`/address-book`, input, {
|
|
1387
|
+
await this.post(`/address-book`, input, {
|
|
1388
|
+
headers: this.headers()
|
|
1389
|
+
});
|
|
1209
1390
|
}
|
|
1210
1391
|
async getAddressBookMode() {
|
|
1211
|
-
const res = await this.get("/address-book/mode", {
|
|
1392
|
+
const res = await this.get("/address-book/mode", {
|
|
1393
|
+
headers: this.headers()
|
|
1394
|
+
});
|
|
1212
1395
|
return res.data;
|
|
1213
1396
|
}
|
|
1214
1397
|
async setAddressBookMode(input) {
|
|
1215
|
-
await this.post("/address-book/mode", {
|
|
1398
|
+
await this.post("/address-book/mode", {
|
|
1399
|
+
mode: input.mode
|
|
1400
|
+
}, {
|
|
1401
|
+
headers: this.headers()
|
|
1402
|
+
});
|
|
1216
1403
|
}
|
|
1217
1404
|
async submitReport(report) {
|
|
1218
1405
|
await this.post("/report", report);
|
|
@@ -1225,7 +1412,10 @@ var BackendImpl = class _BackendImpl {
|
|
|
1225
1412
|
return res.data;
|
|
1226
1413
|
}
|
|
1227
1414
|
headers(token) {
|
|
1228
|
-
return {
|
|
1415
|
+
return {
|
|
1416
|
+
Authorization: `Bearer ${token || this._token}`,
|
|
1417
|
+
"sui-mock-user": this.mockAddress
|
|
1418
|
+
};
|
|
1229
1419
|
}
|
|
1230
1420
|
static toMSafeConfig(resp) {
|
|
1231
1421
|
return {
|
|
@@ -1281,7 +1471,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1281
1471
|
} else if (transformRequest instanceof Array) {
|
|
1282
1472
|
transformRequests = transformRequest;
|
|
1283
1473
|
} else {
|
|
1284
|
-
transformRequests = [
|
|
1474
|
+
transformRequests = [
|
|
1475
|
+
transformRequest
|
|
1476
|
+
];
|
|
1285
1477
|
}
|
|
1286
1478
|
return [
|
|
1287
1479
|
(d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
|
|
@@ -1290,6 +1482,10 @@ var BackendImpl = class _BackendImpl {
|
|
|
1290
1482
|
}
|
|
1291
1483
|
};
|
|
1292
1484
|
var BackendError = class _BackendError extends Error {
|
|
1485
|
+
static {
|
|
1486
|
+
__name(this, "BackendError");
|
|
1487
|
+
}
|
|
1488
|
+
e;
|
|
1293
1489
|
constructor(e) {
|
|
1294
1490
|
super();
|
|
1295
1491
|
this.e = e;
|
|
@@ -1323,14 +1519,18 @@ var BackendError = class _BackendError extends Error {
|
|
|
1323
1519
|
};
|
|
1324
1520
|
|
|
1325
1521
|
// src/globals/const.ts
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1522
|
+
function msafeChainToSuiNetwork(chain) {
|
|
1523
|
+
return chain === "sui:mainnet" ? "mainnet" : "testnet";
|
|
1524
|
+
}
|
|
1525
|
+
__name(msafeChainToSuiNetwork, "msafeChainToSuiNetwork");
|
|
1526
|
+
var MSafeEnv;
|
|
1527
|
+
(function(MSafeEnv2) {
|
|
1528
|
+
MSafeEnv2["local"] = "local";
|
|
1529
|
+
MSafeEnv2["unit"] = "unit";
|
|
1530
|
+
MSafeEnv2["dev"] = "dev";
|
|
1531
|
+
MSafeEnv2["prev"] = "prev";
|
|
1532
|
+
MSafeEnv2["prod"] = "prod";
|
|
1533
|
+
})(MSafeEnv || (MSafeEnv = {}));
|
|
1334
1534
|
var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
|
|
1335
1535
|
var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
|
|
1336
1536
|
var LOCAL_API_URL = "http://127.0.0.1:3000";
|
|
@@ -1341,7 +1541,7 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
|
|
|
1341
1541
|
var PROD_API_URL = "https://sui.m-safe.link";
|
|
1342
1542
|
var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
1343
1543
|
[
|
|
1344
|
-
"unit"
|
|
1544
|
+
"unit",
|
|
1345
1545
|
{
|
|
1346
1546
|
suiClient: {
|
|
1347
1547
|
url: TESTNET_RPC_URL
|
|
@@ -1354,7 +1554,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1354
1554
|
}
|
|
1355
1555
|
],
|
|
1356
1556
|
[
|
|
1357
|
-
"local"
|
|
1557
|
+
"local",
|
|
1358
1558
|
{
|
|
1359
1559
|
suiClient: {
|
|
1360
1560
|
url: TESTNET_RPC_URL
|
|
@@ -1367,7 +1567,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1367
1567
|
}
|
|
1368
1568
|
],
|
|
1369
1569
|
[
|
|
1370
|
-
"dev"
|
|
1570
|
+
"dev",
|
|
1371
1571
|
{
|
|
1372
1572
|
suiClient: {
|
|
1373
1573
|
url: TESTNET_RPC_URL
|
|
@@ -1380,7 +1580,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1380
1580
|
}
|
|
1381
1581
|
],
|
|
1382
1582
|
[
|
|
1383
|
-
"prev"
|
|
1583
|
+
"prev",
|
|
1384
1584
|
{
|
|
1385
1585
|
suiClient: {
|
|
1386
1586
|
url: MAINNET_RPC_URL
|
|
@@ -1393,7 +1593,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1393
1593
|
}
|
|
1394
1594
|
],
|
|
1395
1595
|
[
|
|
1396
|
-
"prod"
|
|
1596
|
+
"prod",
|
|
1397
1597
|
{
|
|
1398
1598
|
suiClient: {
|
|
1399
1599
|
url: MAINNET_RPC_URL
|
|
@@ -1422,9 +1622,13 @@ function getMSafeConfig(env, options) {
|
|
|
1422
1622
|
}
|
|
1423
1623
|
return config;
|
|
1424
1624
|
}
|
|
1625
|
+
__name(getMSafeConfig, "getMSafeConfig");
|
|
1425
1626
|
|
|
1426
1627
|
// src/globals/MSafeGlobals.ts
|
|
1427
1628
|
var MSafeGlobals = class _MSafeGlobals {
|
|
1629
|
+
static {
|
|
1630
|
+
__name(this, "MSafeGlobals");
|
|
1631
|
+
}
|
|
1428
1632
|
backend;
|
|
1429
1633
|
suiClient;
|
|
1430
1634
|
config;
|
|
@@ -1436,9 +1640,14 @@ var MSafeGlobals = class _MSafeGlobals {
|
|
|
1436
1640
|
}
|
|
1437
1641
|
static async New(env, options) {
|
|
1438
1642
|
const config = getMSafeConfig(env, options);
|
|
1439
|
-
const suiClient = new
|
|
1440
|
-
config.suiClient.transport ? {
|
|
1441
|
-
|
|
1643
|
+
const suiClient = new import_jsonRpc.SuiJsonRpcClient({
|
|
1644
|
+
...config.suiClient.transport ? {
|
|
1645
|
+
transport: config.suiClient.transport
|
|
1646
|
+
} : {
|
|
1647
|
+
url: config.suiClient.url
|
|
1648
|
+
},
|
|
1649
|
+
network: msafeChainToSuiNetwork(config.network)
|
|
1650
|
+
});
|
|
1442
1651
|
const backend = new BackendImpl(config.backend.url, options?.mockAddress);
|
|
1443
1652
|
return new _MSafeGlobals({
|
|
1444
1653
|
backend,
|
|
@@ -1462,11 +1671,15 @@ var MSafeGlobals = class _MSafeGlobals {
|
|
|
1462
1671
|
|
|
1463
1672
|
// src/core/MSafeClient.ts
|
|
1464
1673
|
var MSafeClient = class _MSafeClient {
|
|
1465
|
-
|
|
1466
|
-
this
|
|
1674
|
+
static {
|
|
1675
|
+
__name(this, "MSafeClient");
|
|
1467
1676
|
}
|
|
1677
|
+
globals;
|
|
1468
1678
|
_creationHelper;
|
|
1469
1679
|
_publicKeyHelper;
|
|
1680
|
+
constructor(globals) {
|
|
1681
|
+
this.globals = globals;
|
|
1682
|
+
}
|
|
1470
1683
|
static async New(env, options) {
|
|
1471
1684
|
const globals = await MSafeGlobals.New(env, options);
|
|
1472
1685
|
return new _MSafeClient(globals);
|
|
@@ -1501,7 +1714,10 @@ var MSafeClient = class _MSafeClient {
|
|
|
1501
1714
|
return this.globals.backend.getUserInfo();
|
|
1502
1715
|
}
|
|
1503
1716
|
async ownedMSafe(pagination) {
|
|
1504
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
1717
|
+
return this.globals.backend.getOwnedMSafeByStatus({
|
|
1718
|
+
status: import_sui3_utils7.UserMSafeStatus.active,
|
|
1719
|
+
pagination
|
|
1720
|
+
});
|
|
1505
1721
|
}
|
|
1506
1722
|
async createAccount(info) {
|
|
1507
1723
|
return this.creationHelper.submitMSafeCreation(info);
|
|
@@ -1551,26 +1767,38 @@ var MSafeClient = class _MSafeClient {
|
|
|
1551
1767
|
};
|
|
1552
1768
|
|
|
1553
1769
|
// src/backend/types/notification.ts
|
|
1554
|
-
var InfoTypeKey
|
|
1770
|
+
var InfoTypeKey;
|
|
1771
|
+
(function(InfoTypeKey2) {
|
|
1555
1772
|
InfoTypeKey2["receive"] = "info_type_receive";
|
|
1556
1773
|
InfoTypeKey2["send"] = "info_type_send";
|
|
1557
1774
|
InfoTypeKey2["invitation"] = "info_type_invitation";
|
|
1558
1775
|
InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
|
|
1559
|
-
|
|
1560
|
-
})(InfoTypeKey || {});
|
|
1776
|
+
})(InfoTypeKey || (InfoTypeKey = {}));
|
|
1561
1777
|
var NotificationSubscribeDto = class {
|
|
1778
|
+
static {
|
|
1779
|
+
__name(this, "NotificationSubscribeDto");
|
|
1780
|
+
}
|
|
1562
1781
|
email;
|
|
1563
1782
|
};
|
|
1564
1783
|
var NotificationUpdateDto = class {
|
|
1784
|
+
static {
|
|
1785
|
+
__name(this, "NotificationUpdateDto");
|
|
1786
|
+
}
|
|
1565
1787
|
email;
|
|
1566
1788
|
infoTypes;
|
|
1567
1789
|
msafeEnabled;
|
|
1568
1790
|
};
|
|
1569
1791
|
var InfoTypeEnabledDto = class {
|
|
1792
|
+
static {
|
|
1793
|
+
__name(this, "InfoTypeEnabledDto");
|
|
1794
|
+
}
|
|
1570
1795
|
infoType;
|
|
1571
1796
|
enabled;
|
|
1572
1797
|
};
|
|
1573
1798
|
var MSafeEnabledDto = class {
|
|
1799
|
+
static {
|
|
1800
|
+
__name(this, "MSafeEnabledDto");
|
|
1801
|
+
}
|
|
1574
1802
|
msafeAddress;
|
|
1575
1803
|
enabled;
|
|
1576
1804
|
};
|