@msafe/sui3-sdk 1.0.14 → 1.0.15
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 +165 -392
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +191 -401
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/simulate/simulator.ts +1 -1
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 });
|
|
@@ -73,11 +72,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
73
72
|
// src/core/CreateHelper.ts
|
|
74
73
|
var import_sui3_utils = require("@msafe/sui3-utils");
|
|
75
74
|
var CreateHelper = class {
|
|
76
|
-
static {
|
|
77
|
-
__name(this, "CreateHelper");
|
|
78
|
-
}
|
|
79
|
-
globals;
|
|
80
|
-
pkHelper;
|
|
81
75
|
constructor(globals, pkHelper) {
|
|
82
76
|
this.globals = globals;
|
|
83
77
|
this.pkHelper = pkHelper;
|
|
@@ -95,13 +89,13 @@ var CreateHelper = class {
|
|
|
95
89
|
return this.calculateMSafeAddress(createInfo);
|
|
96
90
|
}
|
|
97
91
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
* Add user manually added public key for an address. If user input the public key with
|
|
93
|
+
* extra signature scheme flag, the scheme value will be automatically fixed.
|
|
94
|
+
*
|
|
95
|
+
* @param address
|
|
96
|
+
* @param pkEncoded
|
|
97
|
+
* @throws error if the public key does not match
|
|
98
|
+
*/
|
|
105
99
|
addPublicKey(address, pkEncoded) {
|
|
106
100
|
const pk = import_sui3_utils.PublicKeySerde.de(pkEncoded);
|
|
107
101
|
if (!(0, import_sui3_utils.isSameAddress)(address, pk.toSuiAddress())) {
|
|
@@ -112,9 +106,7 @@ var CreateHelper = class {
|
|
|
112
106
|
async submitMSafeCreation(creationInfo) {
|
|
113
107
|
const msafeAddress = await this.validateCreateInfo(creationInfo);
|
|
114
108
|
const signingMessage = import_sui3_utils.SigningMessageHelper.createMSafeMessage(msafeAddress);
|
|
115
|
-
const signature = await this.globals.wallet.signPersonalMessage({
|
|
116
|
-
messageStr: signingMessage
|
|
117
|
-
});
|
|
109
|
+
const signature = await this.globals.wallet.signPersonalMessage({ messageStr: signingMessage });
|
|
118
110
|
await this.submitToBackend(creationInfo, signature.signature);
|
|
119
111
|
return msafeAddress;
|
|
120
112
|
}
|
|
@@ -145,7 +137,9 @@ var CreateHelper = class {
|
|
|
145
137
|
})),
|
|
146
138
|
threshold: createInfo.threshold,
|
|
147
139
|
name: createInfo.name,
|
|
140
|
+
// name validation is deferred to backend
|
|
148
141
|
description: createInfo.description,
|
|
142
|
+
// description validation is deferred to backend
|
|
149
143
|
creationNonce: createInfo.creationNonce,
|
|
150
144
|
signature
|
|
151
145
|
});
|
|
@@ -158,10 +152,6 @@ var import_sui3_utils7 = require("@msafe/sui3-utils");
|
|
|
158
152
|
// src/core/AddressBookSDK.ts
|
|
159
153
|
var import_sui3_utils2 = require("@msafe/sui3-utils");
|
|
160
154
|
var AddressBookSDK = class {
|
|
161
|
-
static {
|
|
162
|
-
__name(this, "AddressBookSDK");
|
|
163
|
-
}
|
|
164
|
-
globals;
|
|
165
155
|
constructor(globals) {
|
|
166
156
|
this.globals = globals;
|
|
167
157
|
}
|
|
@@ -170,45 +160,28 @@ var AddressBookSDK = class {
|
|
|
170
160
|
}
|
|
171
161
|
async update(updates) {
|
|
172
162
|
const messageStr = import_sui3_utils2.SigningMessageHelper.updateAddressBookMessage(updates);
|
|
173
|
-
const sig = await this.globals.wallet.signPersonalMessage({
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
return this.globals.backend.updateAddressBook({
|
|
177
|
-
updates,
|
|
178
|
-
signature: sig.signature
|
|
179
|
-
});
|
|
163
|
+
const sig = await this.globals.wallet.signPersonalMessage({ messageStr });
|
|
164
|
+
return this.globals.backend.updateAddressBook({ updates, signature: sig.signature });
|
|
180
165
|
}
|
|
181
166
|
async getMode() {
|
|
182
167
|
const res = await this.globals.backend.getAddressBookMode();
|
|
183
168
|
return res.mode;
|
|
184
169
|
}
|
|
185
170
|
async setMode(mode) {
|
|
186
|
-
return this.globals.backend.setAddressBookMode({
|
|
187
|
-
mode
|
|
188
|
-
});
|
|
171
|
+
return this.globals.backend.setAddressBookMode({ mode });
|
|
189
172
|
}
|
|
190
173
|
};
|
|
191
174
|
|
|
192
175
|
// src/core/InvitationSDK.ts
|
|
193
176
|
var InvitationSDK = class {
|
|
194
|
-
static {
|
|
195
|
-
__name(this, "InvitationSDK");
|
|
196
|
-
}
|
|
197
|
-
globals;
|
|
198
177
|
constructor(globals) {
|
|
199
178
|
this.globals = globals;
|
|
200
179
|
}
|
|
201
180
|
async getMSafeByStatus(status, pagination) {
|
|
202
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
203
|
-
status,
|
|
204
|
-
pagination
|
|
205
|
-
});
|
|
181
|
+
return this.globals.backend.getOwnedMSafeByStatus({ status, pagination });
|
|
206
182
|
}
|
|
207
183
|
async updateMSafeStatus(msafeAddress, status) {
|
|
208
|
-
return this.globals.backend.updateMSafeStatus({
|
|
209
|
-
msafeAddress,
|
|
210
|
-
status
|
|
211
|
-
});
|
|
184
|
+
return this.globals.backend.updateMSafeStatus({ msafeAddress, status });
|
|
212
185
|
}
|
|
213
186
|
};
|
|
214
187
|
|
|
@@ -225,25 +198,15 @@ var GAS_SAFE_OVERHEAD = 1000n;
|
|
|
225
198
|
function formatExecutionError(error) {
|
|
226
199
|
return error.message;
|
|
227
200
|
}
|
|
228
|
-
__name(formatExecutionError, "formatExecutionError");
|
|
229
201
|
function gasObjectToReference(gas) {
|
|
230
202
|
if (!gas?.objectId) {
|
|
231
203
|
throw new Error("Gas object missing from simulation effects");
|
|
232
204
|
}
|
|
233
205
|
const version = gas.outputVersion ?? gas.inputVersion ?? "0";
|
|
234
206
|
const digest = gas.outputDigest ?? gas.inputDigest ?? "";
|
|
235
|
-
return {
|
|
236
|
-
objectId: gas.objectId,
|
|
237
|
-
version,
|
|
238
|
-
digest
|
|
239
|
-
};
|
|
207
|
+
return { objectId: gas.objectId, version, digest };
|
|
240
208
|
}
|
|
241
|
-
__name(gasObjectToReference, "gasObjectToReference");
|
|
242
209
|
var Simulator = class {
|
|
243
|
-
static {
|
|
244
|
-
__name(this, "Simulator");
|
|
245
|
-
}
|
|
246
|
-
globals;
|
|
247
210
|
constructor(globals) {
|
|
248
211
|
this.globals = globals;
|
|
249
212
|
}
|
|
@@ -255,9 +218,7 @@ var Simulator = class {
|
|
|
255
218
|
tx.setSender(input.sender);
|
|
256
219
|
let built;
|
|
257
220
|
try {
|
|
258
|
-
built = await tx.build({
|
|
259
|
-
client: suiClient
|
|
260
|
-
});
|
|
221
|
+
built = await tx.build({ client: suiClient });
|
|
261
222
|
} catch (e) {
|
|
262
223
|
const message = e instanceof Error ? e.message : String(e);
|
|
263
224
|
return {
|
|
@@ -325,7 +286,7 @@ var Simulator = class {
|
|
|
325
286
|
return gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead;
|
|
326
287
|
}
|
|
327
288
|
copyTransaction(tx) {
|
|
328
|
-
return import_transactions.Transaction.from(tx
|
|
289
|
+
return import_transactions.Transaction.from(tx);
|
|
329
290
|
}
|
|
330
291
|
};
|
|
331
292
|
|
|
@@ -334,15 +295,12 @@ var import_buffer = require("buffer");
|
|
|
334
295
|
function stringToBuffer(s) {
|
|
335
296
|
return import_buffer.Buffer.from(s, "utf-8");
|
|
336
297
|
}
|
|
337
|
-
__name(stringToBuffer, "stringToBuffer");
|
|
338
298
|
function Uint8ArrayToHex(b) {
|
|
339
299
|
return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
|
|
340
300
|
}
|
|
341
|
-
__name(Uint8ArrayToHex, "Uint8ArrayToHex");
|
|
342
301
|
function HexToUint8Array(hex) {
|
|
343
302
|
return Uint8Array.from(import_buffer.Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
|
|
344
303
|
}
|
|
345
|
-
__name(HexToUint8Array, "HexToUint8Array");
|
|
346
304
|
|
|
347
305
|
// src/utils/crypto.ts
|
|
348
306
|
var import_verify = require("@mysten/sui/verify");
|
|
@@ -353,9 +311,6 @@ var import_utils2 = require("@mysten/sui/utils");
|
|
|
353
311
|
// src/utils/coin.ts
|
|
354
312
|
var import_utils = require("@mysten/sui/utils");
|
|
355
313
|
var CoinHelper = class {
|
|
356
|
-
static {
|
|
357
|
-
__name(this, "CoinHelper");
|
|
358
|
-
}
|
|
359
314
|
_client;
|
|
360
315
|
_coinMetaReg;
|
|
361
316
|
constructor(client) {
|
|
@@ -374,17 +329,12 @@ var CoinHelper = class {
|
|
|
374
329
|
return meta;
|
|
375
330
|
}
|
|
376
331
|
async queryCoinMeta(coinType) {
|
|
377
|
-
const res = await this._client.getCoinMetadata({
|
|
378
|
-
coinType
|
|
379
|
-
});
|
|
332
|
+
const res = await this._client.getCoinMetadata({ coinType });
|
|
380
333
|
return res.coinMetadata ?? void 0;
|
|
381
334
|
}
|
|
382
335
|
};
|
|
383
336
|
var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
|
|
384
337
|
var Coin = class _Coin {
|
|
385
|
-
static {
|
|
386
|
-
__name(this, "Coin");
|
|
387
|
-
}
|
|
388
338
|
static isCoin(type) {
|
|
389
339
|
if (!type) {
|
|
390
340
|
return false;
|
|
@@ -419,9 +369,6 @@ var Coin = class _Coin {
|
|
|
419
369
|
|
|
420
370
|
// src/utils/format.ts
|
|
421
371
|
var Formatter = class {
|
|
422
|
-
static {
|
|
423
|
-
__name(this, "Formatter");
|
|
424
|
-
}
|
|
425
372
|
static normalizeSuiAddress(addr) {
|
|
426
373
|
return (0, import_utils2.normalizeSuiAddress)(addr);
|
|
427
374
|
}
|
|
@@ -444,13 +391,9 @@ function addPrefix(s, prefix) {
|
|
|
444
391
|
}
|
|
445
392
|
return prefix + s;
|
|
446
393
|
}
|
|
447
|
-
__name(addPrefix, "addPrefix");
|
|
448
394
|
|
|
449
395
|
// src/utils/crypto.ts
|
|
450
396
|
var SignatureVerifier = class _SignatureVerifier {
|
|
451
|
-
static {
|
|
452
|
-
__name(this, "SignatureVerifier");
|
|
453
|
-
}
|
|
454
397
|
static async getPublicKeyFromSignature(input) {
|
|
455
398
|
if (input.messageType === "TransactionBlock") {
|
|
456
399
|
return (0, import_verify.verifyTransactionSignature)(input.message, input.signature);
|
|
@@ -501,35 +444,24 @@ var GRAPHQL_URL_BY_NETWORK = {
|
|
|
501
444
|
};
|
|
502
445
|
function graphqlClientForGrpc(suiClient) {
|
|
503
446
|
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
|
-
});
|
|
447
|
+
return new import_graphql.SuiGraphQLClient({ url, network: suiClient.network });
|
|
508
448
|
}
|
|
509
|
-
__name(graphqlClientForGrpc, "graphqlClientForGrpc");
|
|
510
449
|
function collectSignatureStrings(value) {
|
|
511
450
|
if (typeof value === "string") {
|
|
512
|
-
return [
|
|
513
|
-
value
|
|
514
|
-
];
|
|
451
|
+
return [value];
|
|
515
452
|
}
|
|
516
453
|
if (!value || typeof value !== "object") {
|
|
517
454
|
return [];
|
|
518
455
|
}
|
|
519
456
|
if ("base64" in value && typeof value.base64 === "string") {
|
|
520
|
-
return [
|
|
521
|
-
value.base64
|
|
522
|
-
];
|
|
457
|
+
return [value.base64];
|
|
523
458
|
}
|
|
524
459
|
if ("scheme" in value && "base64" in value) {
|
|
525
460
|
const b64 = value.base64;
|
|
526
|
-
return typeof b64 === "string" ? [
|
|
527
|
-
b64
|
|
528
|
-
] : [];
|
|
461
|
+
return typeof b64 === "string" ? [b64] : [];
|
|
529
462
|
}
|
|
530
463
|
return [];
|
|
531
464
|
}
|
|
532
|
-
__name(collectSignatureStrings, "collectSignatureStrings");
|
|
533
465
|
var TX_SIG_QUERY = `
|
|
534
466
|
query PublicKeyTxSigs($sender: SuiAddress!, $first: Int!) {
|
|
535
467
|
transactions(first: $first, filter: { sentAddress: $sender }) {
|
|
@@ -545,10 +477,7 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
545
477
|
try {
|
|
546
478
|
const res = await graphql.query({
|
|
547
479
|
query: TX_SIG_QUERY,
|
|
548
|
-
variables: {
|
|
549
|
-
sender: address,
|
|
550
|
-
first: 2
|
|
551
|
-
}
|
|
480
|
+
variables: { sender: address, first: 2 }
|
|
552
481
|
});
|
|
553
482
|
if (res.errors?.length) {
|
|
554
483
|
return void 0;
|
|
@@ -577,7 +506,6 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
577
506
|
}
|
|
578
507
|
return void 0;
|
|
579
508
|
}
|
|
580
|
-
__name(getPublicKeyFromChain, "getPublicKeyFromChain");
|
|
581
509
|
function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
582
510
|
const decoded = (0, import_cryptography.parseSerializedSignature)(serializedSig);
|
|
583
511
|
switch (decoded.signatureScheme) {
|
|
@@ -592,10 +520,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
592
520
|
case "ED25519":
|
|
593
521
|
case "Secp256k1":
|
|
594
522
|
case "Secp256r1": {
|
|
595
|
-
const pk = import_sui3_utils3.PublicKeySerde.de({
|
|
596
|
-
publicKeyEncoded: decoded.publicKey,
|
|
597
|
-
schema: decoded.signatureScheme
|
|
598
|
-
});
|
|
523
|
+
const pk = import_sui3_utils3.PublicKeySerde.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
|
|
599
524
|
if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
|
|
600
525
|
return pk;
|
|
601
526
|
}
|
|
@@ -605,7 +530,6 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
605
530
|
throw new Error("Unknown schema");
|
|
606
531
|
}
|
|
607
532
|
}
|
|
608
|
-
__name(getAddressFromSignatures, "getAddressFromSignatures");
|
|
609
533
|
async function getAllCoins(input) {
|
|
610
534
|
let hasNext = true;
|
|
611
535
|
let cursor;
|
|
@@ -622,7 +546,6 @@ async function getAllCoins(input) {
|
|
|
622
546
|
}
|
|
623
547
|
return res;
|
|
624
548
|
}
|
|
625
|
-
__name(getAllCoins, "getAllCoins");
|
|
626
549
|
|
|
627
550
|
// src/utils/transaction.ts
|
|
628
551
|
var import_transactions2 = require("@mysten/sui/transactions");
|
|
@@ -633,7 +556,6 @@ function toSuiTransaction(txb) {
|
|
|
633
556
|
const legacy = txb;
|
|
634
557
|
return import_transactions2.Transaction.from(legacy.serialize());
|
|
635
558
|
}
|
|
636
|
-
__name(toSuiTransaction, "toSuiTransaction");
|
|
637
559
|
|
|
638
560
|
// src/utils/iter/iterator.ts
|
|
639
561
|
var REQUEST_PAGE_SIZE = 25;
|
|
@@ -648,19 +570,14 @@ async function getAllFromIterator(it) {
|
|
|
648
570
|
}
|
|
649
571
|
return res;
|
|
650
572
|
}
|
|
651
|
-
__name(getAllFromIterator, "getAllFromIterator");
|
|
652
573
|
var PagedIterator = class {
|
|
653
|
-
static {
|
|
654
|
-
__name(this, "PagedIterator");
|
|
655
|
-
}
|
|
656
|
-
requester;
|
|
657
|
-
curPage;
|
|
658
|
-
init;
|
|
659
574
|
constructor(requester) {
|
|
660
575
|
this.requester = requester;
|
|
661
576
|
this.curPage = void 0;
|
|
662
577
|
this.init = true;
|
|
663
578
|
}
|
|
579
|
+
curPage;
|
|
580
|
+
init;
|
|
664
581
|
async hasNext() {
|
|
665
582
|
if (this.init) {
|
|
666
583
|
if (!this.curPage) {
|
|
@@ -686,19 +603,15 @@ var PagedIterator = class {
|
|
|
686
603
|
}
|
|
687
604
|
};
|
|
688
605
|
var EntryIterator = class {
|
|
689
|
-
static {
|
|
690
|
-
__name(this, "EntryIterator");
|
|
691
|
-
}
|
|
692
|
-
requester;
|
|
693
|
-
cursor;
|
|
694
|
-
pager;
|
|
695
|
-
curData;
|
|
696
606
|
constructor(requester) {
|
|
697
607
|
this.requester = requester;
|
|
698
608
|
this.pager = new PagedIterator(requester);
|
|
699
609
|
this.curData = [];
|
|
700
610
|
this.cursor = 0;
|
|
701
611
|
}
|
|
612
|
+
cursor;
|
|
613
|
+
pager;
|
|
614
|
+
curData;
|
|
702
615
|
async hasNext() {
|
|
703
616
|
if (this.cursor < this.curData.length - 1) {
|
|
704
617
|
return true;
|
|
@@ -720,28 +633,15 @@ var EntryIterator = class {
|
|
|
720
633
|
};
|
|
721
634
|
|
|
722
635
|
// src/utils/iter/object.ts
|
|
723
|
-
var defaultObjectInclude = {
|
|
724
|
-
json: true
|
|
725
|
-
};
|
|
636
|
+
var defaultObjectInclude = { json: true };
|
|
726
637
|
function mergeInclude(options) {
|
|
727
|
-
return {
|
|
728
|
-
...defaultObjectInclude,
|
|
729
|
-
...options?.objectInclude
|
|
730
|
-
};
|
|
638
|
+
return { ...defaultObjectInclude, ...options?.objectInclude };
|
|
731
639
|
}
|
|
732
|
-
__name(mergeInclude, "mergeInclude");
|
|
733
640
|
async function getAllOwnedObjects(provider, owner, options) {
|
|
734
641
|
const iter = new OwnedObjectIterator(provider, owner, options);
|
|
735
642
|
return await getAllFromIterator(iter);
|
|
736
643
|
}
|
|
737
|
-
__name(getAllOwnedObjects, "getAllOwnedObjects");
|
|
738
644
|
var OwnedObjectIterator = class extends EntryIterator {
|
|
739
|
-
static {
|
|
740
|
-
__name(this, "OwnedObjectIterator");
|
|
741
|
-
}
|
|
742
|
-
provider;
|
|
743
|
-
owner;
|
|
744
|
-
options;
|
|
745
645
|
constructor(provider, owner, options) {
|
|
746
646
|
super(new OwnedObjectRequester(provider, owner, options));
|
|
747
647
|
this.provider = provider;
|
|
@@ -750,16 +650,6 @@ var OwnedObjectIterator = class extends EntryIterator {
|
|
|
750
650
|
}
|
|
751
651
|
};
|
|
752
652
|
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
653
|
constructor(provider, owner, options) {
|
|
764
654
|
this.provider = provider;
|
|
765
655
|
this.owner = owner;
|
|
@@ -769,6 +659,10 @@ var OwnedObjectRequester = class {
|
|
|
769
659
|
this.pageSize = options?.pageSize || REQUEST_PAGE_SIZE;
|
|
770
660
|
this.objectInclude = mergeInclude(options);
|
|
771
661
|
}
|
|
662
|
+
nextCursor;
|
|
663
|
+
filter;
|
|
664
|
+
pageSize;
|
|
665
|
+
objectInclude;
|
|
772
666
|
async doNextRequest() {
|
|
773
667
|
const res = await this.provider.listOwnedObjects({
|
|
774
668
|
owner: this.owner,
|
|
@@ -793,14 +687,6 @@ var OwnedObjectRequester = class {
|
|
|
793
687
|
|
|
794
688
|
// src/core/MSafeAccount.ts
|
|
795
689
|
var MSafeAccount = class _MSafeAccount {
|
|
796
|
-
static {
|
|
797
|
-
__name(this, "MSafeAccount");
|
|
798
|
-
}
|
|
799
|
-
globals;
|
|
800
|
-
info;
|
|
801
|
-
multiSig;
|
|
802
|
-
simulator;
|
|
803
|
-
coinHelper;
|
|
804
690
|
constructor(globals, info) {
|
|
805
691
|
this.globals = globals;
|
|
806
692
|
this.info = info;
|
|
@@ -812,6 +698,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
812
698
|
this.coinHelper = new CoinHelper(this.suiClient);
|
|
813
699
|
this.simulator = new Simulator(globals);
|
|
814
700
|
}
|
|
701
|
+
multiSig;
|
|
702
|
+
simulator;
|
|
703
|
+
coinHelper;
|
|
815
704
|
static async New(globals, address) {
|
|
816
705
|
const info = await globals.backend.getMSafeAccountInfo(address);
|
|
817
706
|
const ms = new _MSafeAccount(globals, info);
|
|
@@ -824,23 +713,21 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
824
713
|
let cursor = null;
|
|
825
714
|
let hasNext = true;
|
|
826
715
|
while (hasNext) {
|
|
827
|
-
const page = await this.suiClient.listBalances({
|
|
828
|
-
owner: this.address,
|
|
829
|
-
cursor,
|
|
830
|
-
limit: 50
|
|
831
|
-
});
|
|
716
|
+
const page = await this.suiClient.listBalances({ owner: this.address, cursor, limit: 50 });
|
|
832
717
|
balances.push(...page.balances);
|
|
833
718
|
hasNext = page.hasNextPage;
|
|
834
719
|
cursor = page.cursor;
|
|
835
720
|
}
|
|
836
|
-
return Promise.all(
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
721
|
+
return Promise.all(
|
|
722
|
+
balances.map(async (balance) => {
|
|
723
|
+
const meta = await this.coinHelper.getCoinMeta(balance.coinType);
|
|
724
|
+
return {
|
|
725
|
+
type: (0, import_utils3.normalizeStructTag)(balance.coinType),
|
|
726
|
+
balance: BigInt(balance.addressBalance),
|
|
727
|
+
metadata: meta
|
|
728
|
+
};
|
|
729
|
+
})
|
|
730
|
+
);
|
|
844
731
|
}
|
|
845
732
|
async ownedObjects(options) {
|
|
846
733
|
const filterCoinObjectOptions = {
|
|
@@ -850,9 +737,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
850
737
|
return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
|
|
851
738
|
}
|
|
852
739
|
async pendingTransaction() {
|
|
853
|
-
const res = await this.backend.getPendingTransactions({
|
|
854
|
-
msafeAddress: this.address
|
|
855
|
-
});
|
|
740
|
+
const res = await this.backend.getPendingTransactions({ msafeAddress: this.address });
|
|
856
741
|
if (!res?.pending) {
|
|
857
742
|
return void 0;
|
|
858
743
|
}
|
|
@@ -884,10 +769,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
884
769
|
});
|
|
885
770
|
}
|
|
886
771
|
async futureIntentions(pagination) {
|
|
887
|
-
return this.backend.getFutureIntentions({
|
|
888
|
-
msafeAddress: this.address,
|
|
889
|
-
...pagination
|
|
890
|
-
});
|
|
772
|
+
return this.backend.getFutureIntentions({ msafeAddress: this.address, ...pagination });
|
|
891
773
|
}
|
|
892
774
|
async currentSequenceNumber() {
|
|
893
775
|
return this.backend.getCurrentSequenceNumber(this.address);
|
|
@@ -904,28 +786,24 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
904
786
|
if (!appHelper) {
|
|
905
787
|
throw new Error(`Can't find app helper for application ${request.application}`);
|
|
906
788
|
}
|
|
907
|
-
txb = toSuiTransaction(
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
}));
|
|
789
|
+
txb = toSuiTransaction(
|
|
790
|
+
await appHelper.build({
|
|
791
|
+
network: this.globals.config.network,
|
|
792
|
+
intentionData: request.intention,
|
|
793
|
+
txType: request.txType,
|
|
794
|
+
txSubType: request.txSubType,
|
|
795
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
796
|
+
account: {
|
|
797
|
+
address: this.address,
|
|
798
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
799
|
+
chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
|
|
800
|
+
features: []
|
|
801
|
+
}
|
|
802
|
+
})
|
|
803
|
+
);
|
|
923
804
|
}
|
|
924
805
|
txb.setSender(this.address);
|
|
925
|
-
return this.simulator.simulate({
|
|
926
|
-
txb,
|
|
927
|
-
sender: this.address
|
|
928
|
-
});
|
|
806
|
+
return this.simulator.simulate({ txb, sender: this.address });
|
|
929
807
|
}
|
|
930
808
|
async proposeIntention(input) {
|
|
931
809
|
const message = import_sui3_utils4.SigningMessageHelper.proposeIntentionMessage({
|
|
@@ -951,35 +829,28 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
951
829
|
if (!appHelper) {
|
|
952
830
|
throw new Error(`Can't find app helper for application ${input.application}`);
|
|
953
831
|
}
|
|
954
|
-
txb = toSuiTransaction(
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}));
|
|
832
|
+
txb = toSuiTransaction(
|
|
833
|
+
await appHelper.build({
|
|
834
|
+
network: this.globals.config.network,
|
|
835
|
+
intentionData: input.intention,
|
|
836
|
+
txType: input.txType,
|
|
837
|
+
txSubType: input.txSubType,
|
|
838
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
839
|
+
account: {
|
|
840
|
+
address: this.address,
|
|
841
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
842
|
+
chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
|
|
843
|
+
features: []
|
|
844
|
+
}
|
|
845
|
+
})
|
|
846
|
+
);
|
|
970
847
|
}
|
|
971
848
|
txb.setGasPrice(input.gasPrice);
|
|
972
849
|
txb.setGasBudget(input.gasBudget);
|
|
973
850
|
txb.setSender(this.address);
|
|
974
|
-
const payload = await txb.build({
|
|
975
|
-
|
|
976
|
-
});
|
|
977
|
-
const digest = await txb.getDigest({
|
|
978
|
-
client: this.globals.suiClient
|
|
979
|
-
});
|
|
980
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
981
|
-
transactionBlock: payload
|
|
982
|
-
});
|
|
851
|
+
const payload = await txb.build({ client: this.globals.suiClient });
|
|
852
|
+
const digest = await txb.getDigest({ client: this.globals.suiClient });
|
|
853
|
+
const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
|
|
983
854
|
return this.backend.proposeIntentionAndBuildVote({
|
|
984
855
|
...input,
|
|
985
856
|
payload: (0, import_utils3.toHex)(payload),
|
|
@@ -1055,9 +926,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1055
926
|
}
|
|
1056
927
|
async voteForTransaction(digest, payload) {
|
|
1057
928
|
const payloadBytes = HexToUint8Array(payload);
|
|
1058
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
1059
|
-
transactionBlock: payloadBytes
|
|
1060
|
-
});
|
|
929
|
+
const signature = await this.wallet.signTransactionBlock({ transactionBlock: payloadBytes });
|
|
1061
930
|
return this.backend.voteForTransaction({
|
|
1062
931
|
msafeAddress: this.address,
|
|
1063
932
|
digest,
|
|
@@ -1071,10 +940,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1071
940
|
}
|
|
1072
941
|
const txb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
|
|
1073
942
|
txb.setSender(this.address);
|
|
1074
|
-
return this.simulator.simulate({
|
|
1075
|
-
txb,
|
|
1076
|
-
sender: this.address
|
|
1077
|
-
});
|
|
943
|
+
return this.simulator.simulate({ txb, sender: this.address });
|
|
1078
944
|
}
|
|
1079
945
|
async rejectCurrentTx(input) {
|
|
1080
946
|
const pendingTx = await this.pendingTransaction();
|
|
@@ -1082,15 +948,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1082
948
|
throw new Error("Already rejected");
|
|
1083
949
|
}
|
|
1084
950
|
const rejectTxb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
|
|
1085
|
-
const digest = await rejectTxb.getDigest({
|
|
1086
|
-
|
|
1087
|
-
});
|
|
1088
|
-
const payload = await rejectTxb.build({
|
|
1089
|
-
client: this.suiClient
|
|
1090
|
-
});
|
|
1091
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
1092
|
-
transactionBlock: payload
|
|
1093
|
-
});
|
|
951
|
+
const digest = await rejectTxb.getDigest({ client: this.suiClient });
|
|
952
|
+
const payload = await rejectTxb.build({ client: this.suiClient });
|
|
953
|
+
const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
|
|
1094
954
|
return this.backend.rejectCurrentTx({
|
|
1095
955
|
msafeAddress: this.address,
|
|
1096
956
|
digest,
|
|
@@ -1099,34 +959,28 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1099
959
|
});
|
|
1100
960
|
}
|
|
1101
961
|
async simulateBuildTransaction() {
|
|
1102
|
-
const intention = await this.backend.getNextIntention({
|
|
1103
|
-
msafeAddress: this.address
|
|
1104
|
-
});
|
|
962
|
+
const intention = await this.backend.getNextIntention({ msafeAddress: this.address });
|
|
1105
963
|
const appHelper = import_sui_app_store.appHelpers.getAppHelper(intention.application);
|
|
1106
964
|
if (!appHelper) {
|
|
1107
965
|
throw new Error(`Can't find app helper for application ${intention.application}`);
|
|
1108
966
|
}
|
|
1109
|
-
const txb = toSuiTransaction(
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
}));
|
|
967
|
+
const txb = toSuiTransaction(
|
|
968
|
+
await appHelper.build({
|
|
969
|
+
network: this.globals.config.network,
|
|
970
|
+
intentionData: intention.intention,
|
|
971
|
+
txType: intention.txType,
|
|
972
|
+
txSubType: intention.txSubType,
|
|
973
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
974
|
+
account: {
|
|
975
|
+
address: this.address,
|
|
976
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
977
|
+
chains: [import_wallet_standard.SUI_MAINNET_CHAIN, import_wallet_standard.SUI_TESTNET_CHAIN],
|
|
978
|
+
features: []
|
|
979
|
+
}
|
|
980
|
+
})
|
|
981
|
+
);
|
|
1125
982
|
txb.setSender(this.address);
|
|
1126
|
-
return this.simulator.simulate({
|
|
1127
|
-
txb,
|
|
1128
|
-
sender: this.address
|
|
1129
|
-
});
|
|
983
|
+
return this.simulator.simulate({ txb, sender: this.address });
|
|
1130
984
|
}
|
|
1131
985
|
async buildNextIntentionAndAddToPending(gasOption) {
|
|
1132
986
|
return this.backend.buildNextIntentionAndAddToPending({
|
|
@@ -1137,14 +991,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1137
991
|
});
|
|
1138
992
|
}
|
|
1139
993
|
async skipNextFailedIntention() {
|
|
1140
|
-
return this.backend.skipNextFailedIntention({
|
|
1141
|
-
msafeAddress: this.address
|
|
1142
|
-
});
|
|
994
|
+
return this.backend.skipNextFailedIntention({ msafeAddress: this.address });
|
|
1143
995
|
}
|
|
1144
996
|
async fetchTransaction() {
|
|
1145
|
-
return this.backend.fetchTransaction({
|
|
1146
|
-
msafeAddress: this.address
|
|
1147
|
-
});
|
|
997
|
+
return this.backend.fetchTransaction({ msafeAddress: this.address });
|
|
1148
998
|
}
|
|
1149
999
|
async executePendingTx(pending, isRejectTx = false) {
|
|
1150
1000
|
const votes = isRejectTx ? pending.rejectVotes : pending.votes;
|
|
@@ -1153,10 +1003,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1153
1003
|
throw new Error("Not enough signature");
|
|
1154
1004
|
}
|
|
1155
1005
|
const sortedSigs = [];
|
|
1156
|
-
const gotSigs = new Map(votes.map((vote) => [
|
|
1157
|
-
vote.userAddress,
|
|
1158
|
-
vote.signature
|
|
1159
|
-
]));
|
|
1006
|
+
const gotSigs = new Map(votes.map((vote) => [vote.userAddress, vote.signature]));
|
|
1160
1007
|
for (let i = 0; i < this.info.owners.length; i++) {
|
|
1161
1008
|
const owner = this.info.owners[i];
|
|
1162
1009
|
const signature = gotSigs.get(owner.address);
|
|
@@ -1167,13 +1014,8 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1167
1014
|
const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
|
|
1168
1015
|
return this.suiClient.executeTransaction({
|
|
1169
1016
|
transaction: HexToUint8Array(payload),
|
|
1170
|
-
signatures: [
|
|
1171
|
-
|
|
1172
|
-
],
|
|
1173
|
-
include: {
|
|
1174
|
-
effects: true,
|
|
1175
|
-
events: true
|
|
1176
|
-
}
|
|
1017
|
+
signatures: [multiSignature],
|
|
1018
|
+
include: { effects: true, events: true }
|
|
1177
1019
|
});
|
|
1178
1020
|
}
|
|
1179
1021
|
async dashboard() {
|
|
@@ -1215,15 +1057,11 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1215
1057
|
var import_sui3_utils5 = require("@msafe/sui3-utils");
|
|
1216
1058
|
var import_utils5 = require("@mysten/sui/utils");
|
|
1217
1059
|
var PublicKeyHelper = class {
|
|
1218
|
-
static {
|
|
1219
|
-
__name(this, "PublicKeyHelper");
|
|
1220
|
-
}
|
|
1221
|
-
globals;
|
|
1222
|
-
knownPublicKeys;
|
|
1223
1060
|
constructor(globals) {
|
|
1224
1061
|
this.globals = globals;
|
|
1225
1062
|
this.knownPublicKeys = /* @__PURE__ */ new Map();
|
|
1226
1063
|
}
|
|
1064
|
+
knownPublicKeys;
|
|
1227
1065
|
async getPublicKey(address) {
|
|
1228
1066
|
const cached = this.knownPublicKeys.get(address);
|
|
1229
1067
|
if (cached) {
|
|
@@ -1294,10 +1132,6 @@ var PublicKeyHelper = class {
|
|
|
1294
1132
|
|
|
1295
1133
|
// src/core/ReportSDK.ts
|
|
1296
1134
|
var ReportSDK = class {
|
|
1297
|
-
static {
|
|
1298
|
-
__name(this, "ReportSDK");
|
|
1299
|
-
}
|
|
1300
|
-
globals;
|
|
1301
1135
|
constructor(globals) {
|
|
1302
1136
|
this.globals = globals;
|
|
1303
1137
|
}
|
|
@@ -1313,16 +1147,11 @@ var import_grpc = require("@mysten/sui/grpc");
|
|
|
1313
1147
|
var import_sui3_utils6 = require("@msafe/sui3-utils");
|
|
1314
1148
|
var import_axios = __toESM(require("axios"), 1);
|
|
1315
1149
|
var BackendImpl = class _BackendImpl {
|
|
1316
|
-
static {
|
|
1317
|
-
__name(this, "BackendImpl");
|
|
1318
|
-
}
|
|
1319
|
-
apiURL;
|
|
1320
|
-
mockAddress;
|
|
1321
|
-
_token;
|
|
1322
1150
|
constructor(apiURL, mockAddress) {
|
|
1323
1151
|
this.apiURL = apiURL;
|
|
1324
1152
|
this.mockAddress = mockAddress;
|
|
1325
1153
|
}
|
|
1154
|
+
_token;
|
|
1326
1155
|
getNotificationInfo() {
|
|
1327
1156
|
return this.get(`/notification`, {
|
|
1328
1157
|
headers: this.headers()
|
|
@@ -1345,9 +1174,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1345
1174
|
}
|
|
1346
1175
|
async verifyToken(jwt) {
|
|
1347
1176
|
try {
|
|
1348
|
-
const res = await this.get(`/auth`, {
|
|
1349
|
-
headers: this.headers(jwt)
|
|
1350
|
-
});
|
|
1177
|
+
const res = await this.get(`/auth`, { headers: this.headers(jwt) });
|
|
1351
1178
|
return res.status === 200;
|
|
1352
1179
|
} catch (_) {
|
|
1353
1180
|
return false;
|
|
@@ -1357,9 +1184,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1357
1184
|
this._token = token;
|
|
1358
1185
|
}
|
|
1359
1186
|
async getPublicKey(address) {
|
|
1360
|
-
return (await this.getPublicKeyBatch([
|
|
1361
|
-
address
|
|
1362
|
-
]))[0];
|
|
1187
|
+
return (await this.getPublicKeyBatch([address]))[0];
|
|
1363
1188
|
}
|
|
1364
1189
|
async getPublicKeyBatch(addresses) {
|
|
1365
1190
|
const query = {
|
|
@@ -1369,7 +1194,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1369
1194
|
params: query,
|
|
1370
1195
|
headers: this.headers()
|
|
1371
1196
|
});
|
|
1372
|
-
return res.data?.map(
|
|
1197
|
+
return res.data?.map(
|
|
1198
|
+
(publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0
|
|
1199
|
+
);
|
|
1373
1200
|
}
|
|
1374
1201
|
async getMSafeAccountInfo(msafeAddress) {
|
|
1375
1202
|
const q = {
|
|
@@ -1406,9 +1233,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1406
1233
|
}
|
|
1407
1234
|
async updateMSafeStatus(input) {
|
|
1408
1235
|
const p = input;
|
|
1409
|
-
await this.post(`/msafe/status`, p, {
|
|
1410
|
-
headers: this.headers()
|
|
1411
|
-
});
|
|
1236
|
+
await this.post(`/msafe/status`, p, { headers: this.headers() });
|
|
1412
1237
|
}
|
|
1413
1238
|
async getPendingTransactions(input) {
|
|
1414
1239
|
const res = await this.get(`/transaction/pending`, {
|
|
@@ -1462,18 +1287,16 @@ var BackendImpl = class _BackendImpl {
|
|
|
1462
1287
|
});
|
|
1463
1288
|
}
|
|
1464
1289
|
async proposeIntention(input) {
|
|
1465
|
-
await this.post(`/transaction/intention`, input, {
|
|
1466
|
-
headers: this.headers()
|
|
1467
|
-
});
|
|
1290
|
+
await this.post(`/transaction/intention`, input, { headers: this.headers() });
|
|
1468
1291
|
}
|
|
1469
1292
|
async rejectCurrentTx(input) {
|
|
1470
|
-
await this.post(
|
|
1471
|
-
|
|
1472
|
-
gasPrice: input.gasPrice.toString(),
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1293
|
+
await this.post(
|
|
1294
|
+
`/transaction/pending/reject`,
|
|
1295
|
+
{ ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
|
|
1296
|
+
{
|
|
1297
|
+
headers: this.headers()
|
|
1298
|
+
}
|
|
1299
|
+
);
|
|
1477
1300
|
}
|
|
1478
1301
|
async voteForTransaction(input) {
|
|
1479
1302
|
await this.post(`/transaction/pending/vote`, input, {
|
|
@@ -1481,32 +1304,24 @@ var BackendImpl = class _BackendImpl {
|
|
|
1481
1304
|
});
|
|
1482
1305
|
}
|
|
1483
1306
|
async buildNextIntentionAndAddToPending(input) {
|
|
1484
|
-
await this.post(
|
|
1485
|
-
|
|
1486
|
-
gasPrice: input.gasPrice.toString(),
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
headers: this.headers()
|
|
1490
|
-
});
|
|
1307
|
+
await this.post(
|
|
1308
|
+
`/transaction/pending/build`,
|
|
1309
|
+
{ ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
|
|
1310
|
+
{ headers: this.headers() }
|
|
1311
|
+
);
|
|
1491
1312
|
}
|
|
1492
1313
|
async proposeIntentionAndBuildVote(input) {
|
|
1493
|
-
await this.post(
|
|
1494
|
-
|
|
1495
|
-
gasPrice: input.gasPrice.toString(),
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
headers: this.headers()
|
|
1499
|
-
});
|
|
1314
|
+
await this.post(
|
|
1315
|
+
`/transaction/intention/build`,
|
|
1316
|
+
{ ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
|
|
1317
|
+
{ headers: this.headers() }
|
|
1318
|
+
);
|
|
1500
1319
|
}
|
|
1501
1320
|
async skipNextFailedIntention(input) {
|
|
1502
|
-
await this.post(`/transaction/pending/skip`, input, {
|
|
1503
|
-
headers: this.headers()
|
|
1504
|
-
});
|
|
1321
|
+
await this.post(`/transaction/pending/skip`, input, { headers: this.headers() });
|
|
1505
1322
|
}
|
|
1506
1323
|
async fetchTransaction(input) {
|
|
1507
|
-
const res = await this.post(`/transaction/fetch`, input, {
|
|
1508
|
-
headers: this.headers()
|
|
1509
|
-
});
|
|
1324
|
+
const res = await this.post(`/transaction/fetch`, input, { headers: this.headers() });
|
|
1510
1325
|
return res.data;
|
|
1511
1326
|
}
|
|
1512
1327
|
async getAddressBookEntries(pagination) {
|
|
@@ -1517,22 +1332,14 @@ var BackendImpl = class _BackendImpl {
|
|
|
1517
1332
|
return res.data;
|
|
1518
1333
|
}
|
|
1519
1334
|
async updateAddressBook(input) {
|
|
1520
|
-
await this.post(`/address-book`, input, {
|
|
1521
|
-
headers: this.headers()
|
|
1522
|
-
});
|
|
1335
|
+
await this.post(`/address-book`, input, { headers: this.headers() });
|
|
1523
1336
|
}
|
|
1524
1337
|
async getAddressBookMode() {
|
|
1525
|
-
const res = await this.get("/address-book/mode", {
|
|
1526
|
-
headers: this.headers()
|
|
1527
|
-
});
|
|
1338
|
+
const res = await this.get("/address-book/mode", { headers: this.headers() });
|
|
1528
1339
|
return res.data;
|
|
1529
1340
|
}
|
|
1530
1341
|
async setAddressBookMode(input) {
|
|
1531
|
-
await this.post("/address-book/mode", {
|
|
1532
|
-
mode: input.mode
|
|
1533
|
-
}, {
|
|
1534
|
-
headers: this.headers()
|
|
1535
|
-
});
|
|
1342
|
+
await this.post("/address-book/mode", { mode: input.mode }, { headers: this.headers() });
|
|
1536
1343
|
}
|
|
1537
1344
|
async submitReport(report) {
|
|
1538
1345
|
await this.post("/report", report);
|
|
@@ -1545,10 +1352,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1545
1352
|
return res.data;
|
|
1546
1353
|
}
|
|
1547
1354
|
headers(token) {
|
|
1548
|
-
return {
|
|
1549
|
-
Authorization: `Bearer ${token || this._token}`,
|
|
1550
|
-
"sui-mock-user": this.mockAddress
|
|
1551
|
-
};
|
|
1355
|
+
return { Authorization: `Bearer ${token || this._token}`, "sui-mock-user": this.mockAddress };
|
|
1552
1356
|
}
|
|
1553
1357
|
static toMSafeConfig(resp) {
|
|
1554
1358
|
return {
|
|
@@ -1604,9 +1408,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1604
1408
|
} else if (transformRequest instanceof Array) {
|
|
1605
1409
|
transformRequests = transformRequest;
|
|
1606
1410
|
} else {
|
|
1607
|
-
transformRequests = [
|
|
1608
|
-
transformRequest
|
|
1609
|
-
];
|
|
1411
|
+
transformRequests = [transformRequest];
|
|
1610
1412
|
}
|
|
1611
1413
|
return [
|
|
1612
1414
|
(d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
|
|
@@ -1615,10 +1417,6 @@ var BackendImpl = class _BackendImpl {
|
|
|
1615
1417
|
}
|
|
1616
1418
|
};
|
|
1617
1419
|
var BackendError = class _BackendError extends Error {
|
|
1618
|
-
static {
|
|
1619
|
-
__name(this, "BackendError");
|
|
1620
|
-
}
|
|
1621
|
-
e;
|
|
1622
1420
|
constructor(e) {
|
|
1623
1421
|
super();
|
|
1624
1422
|
this.e = e;
|
|
@@ -1655,15 +1453,14 @@ var BackendError = class _BackendError extends Error {
|
|
|
1655
1453
|
function msafeChainToSuiNetwork(chain) {
|
|
1656
1454
|
return chain === "sui:mainnet" ? "mainnet" : "testnet";
|
|
1657
1455
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
})(MSafeEnv || (MSafeEnv = {}));
|
|
1456
|
+
var MSafeEnv = /* @__PURE__ */ ((MSafeEnv3) => {
|
|
1457
|
+
MSafeEnv3["local"] = "local";
|
|
1458
|
+
MSafeEnv3["unit"] = "unit";
|
|
1459
|
+
MSafeEnv3["dev"] = "dev";
|
|
1460
|
+
MSafeEnv3["prev"] = "prev";
|
|
1461
|
+
MSafeEnv3["prod"] = "prod";
|
|
1462
|
+
return MSafeEnv3;
|
|
1463
|
+
})(MSafeEnv || {});
|
|
1667
1464
|
function httpUrlToGrpcBaseUrl(url) {
|
|
1668
1465
|
const parsed = new URL(url);
|
|
1669
1466
|
if (parsed.protocol === "https:" && parsed.port === "") {
|
|
@@ -1674,7 +1471,6 @@ function httpUrlToGrpcBaseUrl(url) {
|
|
|
1674
1471
|
}
|
|
1675
1472
|
return `${parsed.origin}${parsed.pathname}${parsed.search}`;
|
|
1676
1473
|
}
|
|
1677
|
-
__name(httpUrlToGrpcBaseUrl, "httpUrlToGrpcBaseUrl");
|
|
1678
1474
|
var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
|
|
1679
1475
|
var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
|
|
1680
1476
|
var LOCAL_API_URL = "http://127.0.0.1:3000";
|
|
@@ -1685,7 +1481,7 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
|
|
|
1685
1481
|
var PROD_API_URL = "https://sui.m-safe.link";
|
|
1686
1482
|
var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
1687
1483
|
[
|
|
1688
|
-
"unit"
|
|
1484
|
+
"unit" /* unit */,
|
|
1689
1485
|
{
|
|
1690
1486
|
suiClient: {
|
|
1691
1487
|
url: TESTNET_RPC_URL
|
|
@@ -1698,7 +1494,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1698
1494
|
}
|
|
1699
1495
|
],
|
|
1700
1496
|
[
|
|
1701
|
-
"local"
|
|
1497
|
+
"local" /* local */,
|
|
1702
1498
|
{
|
|
1703
1499
|
suiClient: {
|
|
1704
1500
|
url: TESTNET_RPC_URL
|
|
@@ -1711,7 +1507,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1711
1507
|
}
|
|
1712
1508
|
],
|
|
1713
1509
|
[
|
|
1714
|
-
"dev"
|
|
1510
|
+
"dev" /* dev */,
|
|
1715
1511
|
{
|
|
1716
1512
|
suiClient: {
|
|
1717
1513
|
url: TESTNET_RPC_URL
|
|
@@ -1724,7 +1520,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1724
1520
|
}
|
|
1725
1521
|
],
|
|
1726
1522
|
[
|
|
1727
|
-
"prev"
|
|
1523
|
+
"prev" /* prev */,
|
|
1728
1524
|
{
|
|
1729
1525
|
suiClient: {
|
|
1730
1526
|
url: MAINNET_RPC_URL
|
|
@@ -1737,7 +1533,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1737
1533
|
}
|
|
1738
1534
|
],
|
|
1739
1535
|
[
|
|
1740
|
-
"prod"
|
|
1536
|
+
"prod" /* prod */,
|
|
1741
1537
|
{
|
|
1742
1538
|
suiClient: {
|
|
1743
1539
|
url: MAINNET_RPC_URL
|
|
@@ -1766,13 +1562,9 @@ function getMSafeConfig(env, options) {
|
|
|
1766
1562
|
}
|
|
1767
1563
|
return config;
|
|
1768
1564
|
}
|
|
1769
|
-
__name(getMSafeConfig, "getMSafeConfig");
|
|
1770
1565
|
|
|
1771
1566
|
// src/globals/MSafeGlobals.ts
|
|
1772
1567
|
var MSafeGlobals = class _MSafeGlobals {
|
|
1773
|
-
static {
|
|
1774
|
-
__name(this, "MSafeGlobals");
|
|
1775
|
-
}
|
|
1776
1568
|
backend;
|
|
1777
1569
|
suiClient;
|
|
1778
1570
|
config;
|
|
@@ -1814,15 +1606,11 @@ var MSafeGlobals = class _MSafeGlobals {
|
|
|
1814
1606
|
|
|
1815
1607
|
// src/core/MSafeClient.ts
|
|
1816
1608
|
var MSafeClient = class _MSafeClient {
|
|
1817
|
-
static {
|
|
1818
|
-
__name(this, "MSafeClient");
|
|
1819
|
-
}
|
|
1820
|
-
globals;
|
|
1821
|
-
_creationHelper;
|
|
1822
|
-
_publicKeyHelper;
|
|
1823
1609
|
constructor(globals) {
|
|
1824
1610
|
this.globals = globals;
|
|
1825
1611
|
}
|
|
1612
|
+
_creationHelper;
|
|
1613
|
+
_publicKeyHelper;
|
|
1826
1614
|
static async New(env, options) {
|
|
1827
1615
|
const globals = await MSafeGlobals.New(env, options);
|
|
1828
1616
|
return new _MSafeClient(globals);
|
|
@@ -1857,10 +1645,7 @@ var MSafeClient = class _MSafeClient {
|
|
|
1857
1645
|
return this.globals.backend.getUserInfo();
|
|
1858
1646
|
}
|
|
1859
1647
|
async ownedMSafe(pagination) {
|
|
1860
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
1861
|
-
status: import_sui3_utils7.UserMSafeStatus.active,
|
|
1862
|
-
pagination
|
|
1863
|
-
});
|
|
1648
|
+
return this.globals.backend.getOwnedMSafeByStatus({ status: import_sui3_utils7.UserMSafeStatus.active, pagination });
|
|
1864
1649
|
}
|
|
1865
1650
|
async createAccount(info) {
|
|
1866
1651
|
return this.creationHelper.submitMSafeCreation(info);
|
|
@@ -1910,38 +1695,26 @@ var MSafeClient = class _MSafeClient {
|
|
|
1910
1695
|
};
|
|
1911
1696
|
|
|
1912
1697
|
// src/backend/types/notification.ts
|
|
1913
|
-
var InfoTypeKey
|
|
1914
|
-
(function(InfoTypeKey2) {
|
|
1698
|
+
var InfoTypeKey = /* @__PURE__ */ ((InfoTypeKey2) => {
|
|
1915
1699
|
InfoTypeKey2["receive"] = "info_type_receive";
|
|
1916
1700
|
InfoTypeKey2["send"] = "info_type_send";
|
|
1917
1701
|
InfoTypeKey2["invitation"] = "info_type_invitation";
|
|
1918
1702
|
InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
|
|
1919
|
-
|
|
1703
|
+
return InfoTypeKey2;
|
|
1704
|
+
})(InfoTypeKey || {});
|
|
1920
1705
|
var NotificationSubscribeDto = class {
|
|
1921
|
-
static {
|
|
1922
|
-
__name(this, "NotificationSubscribeDto");
|
|
1923
|
-
}
|
|
1924
1706
|
email;
|
|
1925
1707
|
};
|
|
1926
1708
|
var NotificationUpdateDto = class {
|
|
1927
|
-
static {
|
|
1928
|
-
__name(this, "NotificationUpdateDto");
|
|
1929
|
-
}
|
|
1930
1709
|
email;
|
|
1931
1710
|
infoTypes;
|
|
1932
1711
|
msafeEnabled;
|
|
1933
1712
|
};
|
|
1934
1713
|
var InfoTypeEnabledDto = class {
|
|
1935
|
-
static {
|
|
1936
|
-
__name(this, "InfoTypeEnabledDto");
|
|
1937
|
-
}
|
|
1938
1714
|
infoType;
|
|
1939
1715
|
enabled;
|
|
1940
1716
|
};
|
|
1941
1717
|
var MSafeEnabledDto = class {
|
|
1942
|
-
static {
|
|
1943
|
-
__name(this, "MSafeEnabledDto");
|
|
1944
|
-
}
|
|
1945
1718
|
msafeAddress;
|
|
1946
1719
|
enabled;
|
|
1947
1720
|
};
|