@msafe/sui3-sdk 1.0.6 → 1.0.8
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 +394 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +403 -191
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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 });
|
|
@@ -72,6 +73,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
72
73
|
// src/core/CreateHelper.ts
|
|
73
74
|
var import_sui3_utils = require("@msafe/sui3-utils");
|
|
74
75
|
var CreateHelper = class {
|
|
76
|
+
static {
|
|
77
|
+
__name(this, "CreateHelper");
|
|
78
|
+
}
|
|
79
|
+
globals;
|
|
80
|
+
pkHelper;
|
|
75
81
|
constructor(globals, pkHelper) {
|
|
76
82
|
this.globals = globals;
|
|
77
83
|
this.pkHelper = pkHelper;
|
|
@@ -89,13 +95,13 @@ var CreateHelper = class {
|
|
|
89
95
|
return this.calculateMSafeAddress(createInfo);
|
|
90
96
|
}
|
|
91
97
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
+
*/
|
|
99
105
|
addPublicKey(address, pkEncoded) {
|
|
100
106
|
const pk = import_sui3_utils.PublicKeySerde.de(pkEncoded);
|
|
101
107
|
if (!(0, import_sui3_utils.isSameAddress)(address, pk.toSuiAddress())) {
|
|
@@ -106,7 +112,9 @@ var CreateHelper = class {
|
|
|
106
112
|
async submitMSafeCreation(creationInfo) {
|
|
107
113
|
const msafeAddress = await this.validateCreateInfo(creationInfo);
|
|
108
114
|
const signingMessage = import_sui3_utils.SigningMessageHelper.createMSafeMessage(msafeAddress);
|
|
109
|
-
const signature = await this.globals.wallet.signPersonalMessage({
|
|
115
|
+
const signature = await this.globals.wallet.signPersonalMessage({
|
|
116
|
+
messageStr: signingMessage
|
|
117
|
+
});
|
|
110
118
|
await this.submitToBackend(creationInfo, signature.signature);
|
|
111
119
|
return msafeAddress;
|
|
112
120
|
}
|
|
@@ -137,9 +145,7 @@ var CreateHelper = class {
|
|
|
137
145
|
})),
|
|
138
146
|
threshold: createInfo.threshold,
|
|
139
147
|
name: createInfo.name,
|
|
140
|
-
// name validation is deferred to backend
|
|
141
148
|
description: createInfo.description,
|
|
142
|
-
// description validation is deferred to backend
|
|
143
149
|
creationNonce: createInfo.creationNonce,
|
|
144
150
|
signature
|
|
145
151
|
});
|
|
@@ -152,6 +158,10 @@ var import_sui3_utils7 = require("@msafe/sui3-utils");
|
|
|
152
158
|
// src/core/AddressBookSDK.ts
|
|
153
159
|
var import_sui3_utils2 = require("@msafe/sui3-utils");
|
|
154
160
|
var AddressBookSDK = class {
|
|
161
|
+
static {
|
|
162
|
+
__name(this, "AddressBookSDK");
|
|
163
|
+
}
|
|
164
|
+
globals;
|
|
155
165
|
constructor(globals) {
|
|
156
166
|
this.globals = globals;
|
|
157
167
|
}
|
|
@@ -160,28 +170,45 @@ var AddressBookSDK = class {
|
|
|
160
170
|
}
|
|
161
171
|
async update(updates) {
|
|
162
172
|
const messageStr = import_sui3_utils2.SigningMessageHelper.updateAddressBookMessage(updates);
|
|
163
|
-
const sig = await this.globals.wallet.signPersonalMessage({
|
|
164
|
-
|
|
173
|
+
const sig = await this.globals.wallet.signPersonalMessage({
|
|
174
|
+
messageStr
|
|
175
|
+
});
|
|
176
|
+
return this.globals.backend.updateAddressBook({
|
|
177
|
+
updates,
|
|
178
|
+
signature: sig.signature
|
|
179
|
+
});
|
|
165
180
|
}
|
|
166
181
|
async getMode() {
|
|
167
182
|
const res = await this.globals.backend.getAddressBookMode();
|
|
168
183
|
return res.mode;
|
|
169
184
|
}
|
|
170
185
|
async setMode(mode) {
|
|
171
|
-
return this.globals.backend.setAddressBookMode({
|
|
186
|
+
return this.globals.backend.setAddressBookMode({
|
|
187
|
+
mode
|
|
188
|
+
});
|
|
172
189
|
}
|
|
173
190
|
};
|
|
174
191
|
|
|
175
192
|
// src/core/InvitationSDK.ts
|
|
176
193
|
var InvitationSDK = class {
|
|
194
|
+
static {
|
|
195
|
+
__name(this, "InvitationSDK");
|
|
196
|
+
}
|
|
197
|
+
globals;
|
|
177
198
|
constructor(globals) {
|
|
178
199
|
this.globals = globals;
|
|
179
200
|
}
|
|
180
201
|
async getMSafeByStatus(status, pagination) {
|
|
181
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
202
|
+
return this.globals.backend.getOwnedMSafeByStatus({
|
|
203
|
+
status,
|
|
204
|
+
pagination
|
|
205
|
+
});
|
|
182
206
|
}
|
|
183
207
|
async updateMSafeStatus(msafeAddress, status) {
|
|
184
|
-
return this.globals.backend.updateMSafeStatus({
|
|
208
|
+
return this.globals.backend.updateMSafeStatus({
|
|
209
|
+
msafeAddress,
|
|
210
|
+
status
|
|
211
|
+
});
|
|
185
212
|
}
|
|
186
213
|
};
|
|
187
214
|
|
|
@@ -198,15 +225,25 @@ var GAS_SAFE_OVERHEAD = 1000n;
|
|
|
198
225
|
function formatExecutionError(error) {
|
|
199
226
|
return error.message;
|
|
200
227
|
}
|
|
228
|
+
__name(formatExecutionError, "formatExecutionError");
|
|
201
229
|
function gasObjectToReference(gas) {
|
|
202
230
|
if (!gas?.objectId) {
|
|
203
231
|
throw new Error("Gas object missing from simulation effects");
|
|
204
232
|
}
|
|
205
233
|
const version = gas.outputVersion ?? gas.inputVersion ?? "0";
|
|
206
234
|
const digest = gas.outputDigest ?? gas.inputDigest ?? "";
|
|
207
|
-
return {
|
|
235
|
+
return {
|
|
236
|
+
objectId: gas.objectId,
|
|
237
|
+
version,
|
|
238
|
+
digest
|
|
239
|
+
};
|
|
208
240
|
}
|
|
241
|
+
__name(gasObjectToReference, "gasObjectToReference");
|
|
209
242
|
var Simulator = class {
|
|
243
|
+
static {
|
|
244
|
+
__name(this, "Simulator");
|
|
245
|
+
}
|
|
246
|
+
globals;
|
|
210
247
|
constructor(globals) {
|
|
211
248
|
this.globals = globals;
|
|
212
249
|
}
|
|
@@ -217,7 +254,9 @@ var Simulator = class {
|
|
|
217
254
|
tx.setGasPrice(gasPrice);
|
|
218
255
|
let built;
|
|
219
256
|
try {
|
|
220
|
-
built = await tx.build({
|
|
257
|
+
built = await tx.build({
|
|
258
|
+
client: suiClient
|
|
259
|
+
});
|
|
221
260
|
} catch (e) {
|
|
222
261
|
const message = e instanceof Error ? e.message : String(e);
|
|
223
262
|
return {
|
|
@@ -230,7 +269,9 @@ var Simulator = class {
|
|
|
230
269
|
try {
|
|
231
270
|
inspectResult = await suiClient.simulateTransaction({
|
|
232
271
|
transaction: built,
|
|
233
|
-
include: {
|
|
272
|
+
include: {
|
|
273
|
+
effects: true
|
|
274
|
+
}
|
|
234
275
|
});
|
|
235
276
|
} catch (e) {
|
|
236
277
|
const message = e instanceof Error ? e.message : String(e);
|
|
@@ -286,12 +327,15 @@ var import_buffer = require("buffer");
|
|
|
286
327
|
function stringToBuffer(s) {
|
|
287
328
|
return import_buffer.Buffer.from(s, "utf-8");
|
|
288
329
|
}
|
|
330
|
+
__name(stringToBuffer, "stringToBuffer");
|
|
289
331
|
function Uint8ArrayToHex(b) {
|
|
290
332
|
return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
|
|
291
333
|
}
|
|
334
|
+
__name(Uint8ArrayToHex, "Uint8ArrayToHex");
|
|
292
335
|
function HexToUint8Array(hex) {
|
|
293
336
|
return Uint8Array.from(import_buffer.Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
|
|
294
337
|
}
|
|
338
|
+
__name(HexToUint8Array, "HexToUint8Array");
|
|
295
339
|
|
|
296
340
|
// src/utils/crypto.ts
|
|
297
341
|
var import_verify = require("@mysten/sui/verify");
|
|
@@ -302,6 +346,9 @@ var import_utils2 = require("@mysten/sui/utils");
|
|
|
302
346
|
// src/utils/coin.ts
|
|
303
347
|
var import_utils = require("@mysten/sui/utils");
|
|
304
348
|
var CoinHelper = class {
|
|
349
|
+
static {
|
|
350
|
+
__name(this, "CoinHelper");
|
|
351
|
+
}
|
|
305
352
|
_client;
|
|
306
353
|
_coinMetaReg;
|
|
307
354
|
constructor(client) {
|
|
@@ -320,12 +367,17 @@ var CoinHelper = class {
|
|
|
320
367
|
return meta;
|
|
321
368
|
}
|
|
322
369
|
async queryCoinMeta(coinType) {
|
|
323
|
-
const res = await this._client.getCoinMetadata({
|
|
370
|
+
const res = await this._client.getCoinMetadata({
|
|
371
|
+
coinType
|
|
372
|
+
});
|
|
324
373
|
return res.coinMetadata ?? void 0;
|
|
325
374
|
}
|
|
326
375
|
};
|
|
327
376
|
var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
|
|
328
377
|
var Coin = class _Coin {
|
|
378
|
+
static {
|
|
379
|
+
__name(this, "Coin");
|
|
380
|
+
}
|
|
329
381
|
static isCoin(type) {
|
|
330
382
|
if (!type) {
|
|
331
383
|
return false;
|
|
@@ -360,6 +412,9 @@ var Coin = class _Coin {
|
|
|
360
412
|
|
|
361
413
|
// src/utils/format.ts
|
|
362
414
|
var Formatter = class {
|
|
415
|
+
static {
|
|
416
|
+
__name(this, "Formatter");
|
|
417
|
+
}
|
|
363
418
|
static normalizeSuiAddress(addr) {
|
|
364
419
|
return (0, import_utils2.normalizeSuiAddress)(addr);
|
|
365
420
|
}
|
|
@@ -382,9 +437,13 @@ function addPrefix(s, prefix) {
|
|
|
382
437
|
}
|
|
383
438
|
return prefix + s;
|
|
384
439
|
}
|
|
440
|
+
__name(addPrefix, "addPrefix");
|
|
385
441
|
|
|
386
442
|
// src/utils/crypto.ts
|
|
387
443
|
var SignatureVerifier = class _SignatureVerifier {
|
|
444
|
+
static {
|
|
445
|
+
__name(this, "SignatureVerifier");
|
|
446
|
+
}
|
|
388
447
|
static async getPublicKeyFromSignature(input) {
|
|
389
448
|
if (input.messageType === "TransactionBlock") {
|
|
390
449
|
return (0, import_verify.verifyTransactionSignature)(input.message, input.signature);
|
|
@@ -435,24 +494,35 @@ var GRAPHQL_URL_BY_NETWORK = {
|
|
|
435
494
|
};
|
|
436
495
|
function graphqlClientForGrpc(suiClient) {
|
|
437
496
|
const url = GRAPHQL_URL_BY_NETWORK[suiClient.network] ?? GRAPHQL_URL_BY_NETWORK.testnet;
|
|
438
|
-
return new import_graphql.SuiGraphQLClient({
|
|
497
|
+
return new import_graphql.SuiGraphQLClient({
|
|
498
|
+
url,
|
|
499
|
+
network: suiClient.network
|
|
500
|
+
});
|
|
439
501
|
}
|
|
502
|
+
__name(graphqlClientForGrpc, "graphqlClientForGrpc");
|
|
440
503
|
function collectSignatureStrings(value) {
|
|
441
504
|
if (typeof value === "string") {
|
|
442
|
-
return [
|
|
505
|
+
return [
|
|
506
|
+
value
|
|
507
|
+
];
|
|
443
508
|
}
|
|
444
509
|
if (!value || typeof value !== "object") {
|
|
445
510
|
return [];
|
|
446
511
|
}
|
|
447
512
|
if ("base64" in value && typeof value.base64 === "string") {
|
|
448
|
-
return [
|
|
513
|
+
return [
|
|
514
|
+
value.base64
|
|
515
|
+
];
|
|
449
516
|
}
|
|
450
517
|
if ("scheme" in value && "base64" in value) {
|
|
451
518
|
const b64 = value.base64;
|
|
452
|
-
return typeof b64 === "string" ? [
|
|
519
|
+
return typeof b64 === "string" ? [
|
|
520
|
+
b64
|
|
521
|
+
] : [];
|
|
453
522
|
}
|
|
454
523
|
return [];
|
|
455
524
|
}
|
|
525
|
+
__name(collectSignatureStrings, "collectSignatureStrings");
|
|
456
526
|
var TX_SIG_QUERY = `
|
|
457
527
|
query PublicKeyTxSigs($sender: SuiAddress!, $first: Int!) {
|
|
458
528
|
transactions(first: $first, filter: { sentAddress: $sender }) {
|
|
@@ -468,7 +538,10 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
468
538
|
try {
|
|
469
539
|
const res = await graphql.query({
|
|
470
540
|
query: TX_SIG_QUERY,
|
|
471
|
-
variables: {
|
|
541
|
+
variables: {
|
|
542
|
+
sender: address,
|
|
543
|
+
first: 2
|
|
544
|
+
}
|
|
472
545
|
});
|
|
473
546
|
if (res.errors?.length) {
|
|
474
547
|
return void 0;
|
|
@@ -497,6 +570,7 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
497
570
|
}
|
|
498
571
|
return void 0;
|
|
499
572
|
}
|
|
573
|
+
__name(getPublicKeyFromChain, "getPublicKeyFromChain");
|
|
500
574
|
function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
501
575
|
const decoded = (0, import_cryptography.parseSerializedSignature)(serializedSig);
|
|
502
576
|
switch (decoded.signatureScheme) {
|
|
@@ -511,7 +585,10 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
511
585
|
case "ED25519":
|
|
512
586
|
case "Secp256k1":
|
|
513
587
|
case "Secp256r1": {
|
|
514
|
-
const pk = import_sui3_utils3.PublicKeySerde.de({
|
|
588
|
+
const pk = import_sui3_utils3.PublicKeySerde.de({
|
|
589
|
+
publicKeyEncoded: decoded.publicKey,
|
|
590
|
+
schema: decoded.signatureScheme
|
|
591
|
+
});
|
|
515
592
|
if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
|
|
516
593
|
return pk;
|
|
517
594
|
}
|
|
@@ -521,6 +598,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
521
598
|
throw new Error("Unknown schema");
|
|
522
599
|
}
|
|
523
600
|
}
|
|
601
|
+
__name(getAddressFromSignatures, "getAddressFromSignatures");
|
|
524
602
|
async function getAllCoins(input) {
|
|
525
603
|
let hasNext = true;
|
|
526
604
|
let cursor;
|
|
@@ -537,6 +615,7 @@ async function getAllCoins(input) {
|
|
|
537
615
|
}
|
|
538
616
|
return res;
|
|
539
617
|
}
|
|
618
|
+
__name(getAllCoins, "getAllCoins");
|
|
540
619
|
|
|
541
620
|
// src/utils/transaction.ts
|
|
542
621
|
var import_transactions2 = require("@mysten/sui/transactions");
|
|
@@ -547,6 +626,7 @@ function toSuiTransaction(txb) {
|
|
|
547
626
|
const legacy = txb;
|
|
548
627
|
return import_transactions2.Transaction.from(legacy.serialize());
|
|
549
628
|
}
|
|
629
|
+
__name(toSuiTransaction, "toSuiTransaction");
|
|
550
630
|
|
|
551
631
|
// src/utils/iter/iterator.ts
|
|
552
632
|
var REQUEST_PAGE_SIZE = 25;
|
|
@@ -561,14 +641,19 @@ async function getAllFromIterator(it) {
|
|
|
561
641
|
}
|
|
562
642
|
return res;
|
|
563
643
|
}
|
|
644
|
+
__name(getAllFromIterator, "getAllFromIterator");
|
|
564
645
|
var PagedIterator = class {
|
|
646
|
+
static {
|
|
647
|
+
__name(this, "PagedIterator");
|
|
648
|
+
}
|
|
649
|
+
requester;
|
|
650
|
+
curPage;
|
|
651
|
+
init;
|
|
565
652
|
constructor(requester) {
|
|
566
653
|
this.requester = requester;
|
|
567
654
|
this.curPage = void 0;
|
|
568
655
|
this.init = true;
|
|
569
656
|
}
|
|
570
|
-
curPage;
|
|
571
|
-
init;
|
|
572
657
|
async hasNext() {
|
|
573
658
|
if (this.init) {
|
|
574
659
|
if (!this.curPage) {
|
|
@@ -594,15 +679,19 @@ var PagedIterator = class {
|
|
|
594
679
|
}
|
|
595
680
|
};
|
|
596
681
|
var EntryIterator = class {
|
|
682
|
+
static {
|
|
683
|
+
__name(this, "EntryIterator");
|
|
684
|
+
}
|
|
685
|
+
requester;
|
|
686
|
+
cursor;
|
|
687
|
+
pager;
|
|
688
|
+
curData;
|
|
597
689
|
constructor(requester) {
|
|
598
690
|
this.requester = requester;
|
|
599
691
|
this.pager = new PagedIterator(requester);
|
|
600
692
|
this.curData = [];
|
|
601
693
|
this.cursor = 0;
|
|
602
694
|
}
|
|
603
|
-
cursor;
|
|
604
|
-
pager;
|
|
605
|
-
curData;
|
|
606
695
|
async hasNext() {
|
|
607
696
|
if (this.cursor < this.curData.length - 1) {
|
|
608
697
|
return true;
|
|
@@ -624,15 +713,28 @@ var EntryIterator = class {
|
|
|
624
713
|
};
|
|
625
714
|
|
|
626
715
|
// src/utils/iter/object.ts
|
|
627
|
-
var defaultObjectInclude = {
|
|
716
|
+
var defaultObjectInclude = {
|
|
717
|
+
json: true
|
|
718
|
+
};
|
|
628
719
|
function mergeInclude(options) {
|
|
629
|
-
return {
|
|
720
|
+
return {
|
|
721
|
+
...defaultObjectInclude,
|
|
722
|
+
...options?.objectInclude
|
|
723
|
+
};
|
|
630
724
|
}
|
|
725
|
+
__name(mergeInclude, "mergeInclude");
|
|
631
726
|
async function getAllOwnedObjects(provider, owner, options) {
|
|
632
727
|
const iter = new OwnedObjectIterator(provider, owner, options);
|
|
633
728
|
return await getAllFromIterator(iter);
|
|
634
729
|
}
|
|
730
|
+
__name(getAllOwnedObjects, "getAllOwnedObjects");
|
|
635
731
|
var OwnedObjectIterator = class extends EntryIterator {
|
|
732
|
+
static {
|
|
733
|
+
__name(this, "OwnedObjectIterator");
|
|
734
|
+
}
|
|
735
|
+
provider;
|
|
736
|
+
owner;
|
|
737
|
+
options;
|
|
636
738
|
constructor(provider, owner, options) {
|
|
637
739
|
super(new OwnedObjectRequester(provider, owner, options));
|
|
638
740
|
this.provider = provider;
|
|
@@ -641,6 +743,16 @@ var OwnedObjectIterator = class extends EntryIterator {
|
|
|
641
743
|
}
|
|
642
744
|
};
|
|
643
745
|
var OwnedObjectRequester = class {
|
|
746
|
+
static {
|
|
747
|
+
__name(this, "OwnedObjectRequester");
|
|
748
|
+
}
|
|
749
|
+
provider;
|
|
750
|
+
owner;
|
|
751
|
+
options;
|
|
752
|
+
nextCursor;
|
|
753
|
+
filter;
|
|
754
|
+
pageSize;
|
|
755
|
+
objectInclude;
|
|
644
756
|
constructor(provider, owner, options) {
|
|
645
757
|
this.provider = provider;
|
|
646
758
|
this.owner = owner;
|
|
@@ -650,10 +762,6 @@ var OwnedObjectRequester = class {
|
|
|
650
762
|
this.pageSize = options?.pageSize || REQUEST_PAGE_SIZE;
|
|
651
763
|
this.objectInclude = mergeInclude(options);
|
|
652
764
|
}
|
|
653
|
-
nextCursor;
|
|
654
|
-
filter;
|
|
655
|
-
pageSize;
|
|
656
|
-
objectInclude;
|
|
657
765
|
async doNextRequest() {
|
|
658
766
|
const res = await this.provider.listOwnedObjects({
|
|
659
767
|
owner: this.owner,
|
|
@@ -678,6 +786,14 @@ var OwnedObjectRequester = class {
|
|
|
678
786
|
|
|
679
787
|
// src/core/MSafeAccount.ts
|
|
680
788
|
var MSafeAccount = class _MSafeAccount {
|
|
789
|
+
static {
|
|
790
|
+
__name(this, "MSafeAccount");
|
|
791
|
+
}
|
|
792
|
+
globals;
|
|
793
|
+
info;
|
|
794
|
+
multiSig;
|
|
795
|
+
simulator;
|
|
796
|
+
coinHelper;
|
|
681
797
|
constructor(globals, info) {
|
|
682
798
|
this.globals = globals;
|
|
683
799
|
this.info = info;
|
|
@@ -689,9 +805,6 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
689
805
|
this.coinHelper = new CoinHelper(this.suiClient);
|
|
690
806
|
this.simulator = new Simulator(globals);
|
|
691
807
|
}
|
|
692
|
-
multiSig;
|
|
693
|
-
simulator;
|
|
694
|
-
coinHelper;
|
|
695
808
|
static async New(globals, address) {
|
|
696
809
|
const info = await globals.backend.getMSafeAccountInfo(address);
|
|
697
810
|
const ms = new _MSafeAccount(globals, info);
|
|
@@ -704,21 +817,23 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
704
817
|
let cursor = null;
|
|
705
818
|
let hasNext = true;
|
|
706
819
|
while (hasNext) {
|
|
707
|
-
const page = await this.suiClient.listBalances({
|
|
820
|
+
const page = await this.suiClient.listBalances({
|
|
821
|
+
owner: this.address,
|
|
822
|
+
cursor,
|
|
823
|
+
limit: 50
|
|
824
|
+
});
|
|
708
825
|
balances.push(...page.balances);
|
|
709
826
|
hasNext = page.hasNextPage;
|
|
710
827
|
cursor = page.cursor;
|
|
711
828
|
}
|
|
712
|
-
return Promise.all(
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
})
|
|
721
|
-
);
|
|
829
|
+
return Promise.all(balances.map(async (balance) => {
|
|
830
|
+
const meta = await this.coinHelper.getCoinMeta(balance.coinType);
|
|
831
|
+
return {
|
|
832
|
+
type: (0, import_utils3.normalizeStructTag)(balance.coinType),
|
|
833
|
+
balance: BigInt(balance.addressBalance),
|
|
834
|
+
metadata: meta
|
|
835
|
+
};
|
|
836
|
+
}));
|
|
722
837
|
}
|
|
723
838
|
async ownedObjects(options) {
|
|
724
839
|
const filterCoinObjectOptions = {
|
|
@@ -728,7 +843,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
728
843
|
return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
|
|
729
844
|
}
|
|
730
845
|
async pendingTransaction() {
|
|
731
|
-
const res = await this.backend.getPendingTransactions({
|
|
846
|
+
const res = await this.backend.getPendingTransactions({
|
|
847
|
+
msafeAddress: this.address
|
|
848
|
+
});
|
|
732
849
|
if (!res?.pending) {
|
|
733
850
|
return void 0;
|
|
734
851
|
}
|
|
@@ -760,7 +877,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
760
877
|
});
|
|
761
878
|
}
|
|
762
879
|
async futureIntentions(pagination) {
|
|
763
|
-
return this.backend.getFutureIntentions({
|
|
880
|
+
return this.backend.getFutureIntentions({
|
|
881
|
+
msafeAddress: this.address,
|
|
882
|
+
...pagination
|
|
883
|
+
});
|
|
764
884
|
}
|
|
765
885
|
async currentSequenceNumber() {
|
|
766
886
|
return this.backend.getCurrentSequenceNumber(this.address);
|
|
@@ -777,24 +897,28 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
777
897
|
if (!appHelper) {
|
|
778
898
|
throw new Error(`Can't find app helper for application ${request.application}`);
|
|
779
899
|
}
|
|
780
|
-
txb = toSuiTransaction(
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
900
|
+
txb = toSuiTransaction(await appHelper.build({
|
|
901
|
+
network: this.globals.config.network,
|
|
902
|
+
intentionData: request.intention,
|
|
903
|
+
txType: request.txType,
|
|
904
|
+
txSubType: request.txSubType,
|
|
905
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
906
|
+
account: {
|
|
907
|
+
address: this.address,
|
|
908
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
909
|
+
chains: [
|
|
910
|
+
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
911
|
+
import_wallet_standard.SUI_TESTNET_CHAIN
|
|
912
|
+
],
|
|
913
|
+
features: []
|
|
914
|
+
}
|
|
915
|
+
}));
|
|
795
916
|
}
|
|
796
917
|
txb.setSender(this.address);
|
|
797
|
-
return this.simulator.simulate({
|
|
918
|
+
return this.simulator.simulate({
|
|
919
|
+
txb,
|
|
920
|
+
sender: this.address
|
|
921
|
+
});
|
|
798
922
|
}
|
|
799
923
|
async proposeIntention(input) {
|
|
800
924
|
const message = import_sui3_utils4.SigningMessageHelper.proposeIntentionMessage({
|
|
@@ -820,28 +944,35 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
820
944
|
if (!appHelper) {
|
|
821
945
|
throw new Error(`Can't find app helper for application ${input.application}`);
|
|
822
946
|
}
|
|
823
|
-
txb = toSuiTransaction(
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
947
|
+
txb = toSuiTransaction(await appHelper.build({
|
|
948
|
+
network: this.globals.config.network,
|
|
949
|
+
intentionData: input.intention,
|
|
950
|
+
txType: input.txType,
|
|
951
|
+
txSubType: input.txSubType,
|
|
952
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
953
|
+
account: {
|
|
954
|
+
address: this.address,
|
|
955
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
956
|
+
chains: [
|
|
957
|
+
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
958
|
+
import_wallet_standard.SUI_TESTNET_CHAIN
|
|
959
|
+
],
|
|
960
|
+
features: []
|
|
961
|
+
}
|
|
962
|
+
}));
|
|
838
963
|
}
|
|
839
964
|
txb.setGasPrice(input.gasPrice);
|
|
840
965
|
txb.setGasBudget(input.gasBudget);
|
|
841
966
|
txb.setSender(this.address);
|
|
842
|
-
const payload = await txb.build({
|
|
843
|
-
|
|
844
|
-
|
|
967
|
+
const payload = await txb.build({
|
|
968
|
+
client: this.globals.suiClient
|
|
969
|
+
});
|
|
970
|
+
const digest = await txb.getDigest({
|
|
971
|
+
client: this.globals.suiClient
|
|
972
|
+
});
|
|
973
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
974
|
+
transactionBlock: payload
|
|
975
|
+
});
|
|
845
976
|
return this.backend.proposeIntentionAndBuildVote({
|
|
846
977
|
...input,
|
|
847
978
|
payload: (0, import_utils3.toHex)(payload),
|
|
@@ -917,7 +1048,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
917
1048
|
}
|
|
918
1049
|
async voteForTransaction(digest, payload) {
|
|
919
1050
|
const payloadBytes = HexToUint8Array(payload);
|
|
920
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
1051
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
1052
|
+
transactionBlock: payloadBytes
|
|
1053
|
+
});
|
|
921
1054
|
return this.backend.voteForTransaction({
|
|
922
1055
|
msafeAddress: this.address,
|
|
923
1056
|
digest,
|
|
@@ -931,7 +1064,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
931
1064
|
}
|
|
932
1065
|
const txb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
|
|
933
1066
|
txb.setSender(this.address);
|
|
934
|
-
return this.simulator.simulate({
|
|
1067
|
+
return this.simulator.simulate({
|
|
1068
|
+
txb,
|
|
1069
|
+
sender: this.address
|
|
1070
|
+
});
|
|
935
1071
|
}
|
|
936
1072
|
async rejectCurrentTx(input) {
|
|
937
1073
|
const pendingTx = await this.pendingTransaction();
|
|
@@ -939,9 +1075,15 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
939
1075
|
throw new Error("Already rejected");
|
|
940
1076
|
}
|
|
941
1077
|
const rejectTxb = toSuiTransaction((0, import_sui3_utils4.buildRejectTxb)(this.address));
|
|
942
|
-
const digest = await rejectTxb.getDigest({
|
|
943
|
-
|
|
944
|
-
|
|
1078
|
+
const digest = await rejectTxb.getDigest({
|
|
1079
|
+
client: this.suiClient
|
|
1080
|
+
});
|
|
1081
|
+
const payload = await rejectTxb.build({
|
|
1082
|
+
client: this.suiClient
|
|
1083
|
+
});
|
|
1084
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
1085
|
+
transactionBlock: payload
|
|
1086
|
+
});
|
|
945
1087
|
return this.backend.rejectCurrentTx({
|
|
946
1088
|
msafeAddress: this.address,
|
|
947
1089
|
digest,
|
|
@@ -950,28 +1092,34 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
950
1092
|
});
|
|
951
1093
|
}
|
|
952
1094
|
async simulateBuildTransaction() {
|
|
953
|
-
const intention = await this.backend.getNextIntention({
|
|
1095
|
+
const intention = await this.backend.getNextIntention({
|
|
1096
|
+
msafeAddress: this.address
|
|
1097
|
+
});
|
|
954
1098
|
const appHelper = import_sui_app_store.appHelpers.getAppHelper(intention.application);
|
|
955
1099
|
if (!appHelper) {
|
|
956
1100
|
throw new Error(`Can't find app helper for application ${intention.application}`);
|
|
957
1101
|
}
|
|
958
|
-
const txb = toSuiTransaction(
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1102
|
+
const txb = toSuiTransaction(await appHelper.build({
|
|
1103
|
+
network: this.globals.config.network,
|
|
1104
|
+
intentionData: intention.intention,
|
|
1105
|
+
txType: intention.txType,
|
|
1106
|
+
txSubType: intention.txSubType,
|
|
1107
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
1108
|
+
account: {
|
|
1109
|
+
address: this.address,
|
|
1110
|
+
publicKey: (0, import_utils3.fromHex)(this.address),
|
|
1111
|
+
chains: [
|
|
1112
|
+
import_wallet_standard.SUI_MAINNET_CHAIN,
|
|
1113
|
+
import_wallet_standard.SUI_TESTNET_CHAIN
|
|
1114
|
+
],
|
|
1115
|
+
features: []
|
|
1116
|
+
}
|
|
1117
|
+
}));
|
|
973
1118
|
txb.setSender(this.address);
|
|
974
|
-
return this.simulator.simulate({
|
|
1119
|
+
return this.simulator.simulate({
|
|
1120
|
+
txb,
|
|
1121
|
+
sender: this.address
|
|
1122
|
+
});
|
|
975
1123
|
}
|
|
976
1124
|
async buildNextIntentionAndAddToPending(gasOption) {
|
|
977
1125
|
return this.backend.buildNextIntentionAndAddToPending({
|
|
@@ -982,10 +1130,14 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
982
1130
|
});
|
|
983
1131
|
}
|
|
984
1132
|
async skipNextFailedIntention() {
|
|
985
|
-
return this.backend.skipNextFailedIntention({
|
|
1133
|
+
return this.backend.skipNextFailedIntention({
|
|
1134
|
+
msafeAddress: this.address
|
|
1135
|
+
});
|
|
986
1136
|
}
|
|
987
1137
|
async fetchTransaction() {
|
|
988
|
-
return this.backend.fetchTransaction({
|
|
1138
|
+
return this.backend.fetchTransaction({
|
|
1139
|
+
msafeAddress: this.address
|
|
1140
|
+
});
|
|
989
1141
|
}
|
|
990
1142
|
async executePendingTx(pending, isRejectTx = false) {
|
|
991
1143
|
const votes = isRejectTx ? pending.rejectVotes : pending.votes;
|
|
@@ -994,7 +1146,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
994
1146
|
throw new Error("Not enough signature");
|
|
995
1147
|
}
|
|
996
1148
|
const sortedSigs = [];
|
|
997
|
-
const gotSigs = new Map(votes.map((vote) => [
|
|
1149
|
+
const gotSigs = new Map(votes.map((vote) => [
|
|
1150
|
+
vote.userAddress,
|
|
1151
|
+
vote.signature
|
|
1152
|
+
]));
|
|
998
1153
|
for (let i = 0; i < this.info.owners.length; i++) {
|
|
999
1154
|
const owner = this.info.owners[i];
|
|
1000
1155
|
const signature = gotSigs.get(owner.address);
|
|
@@ -1005,8 +1160,13 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1005
1160
|
const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
|
|
1006
1161
|
return this.suiClient.executeTransaction({
|
|
1007
1162
|
transaction: HexToUint8Array(payload),
|
|
1008
|
-
signatures: [
|
|
1009
|
-
|
|
1163
|
+
signatures: [
|
|
1164
|
+
multiSignature
|
|
1165
|
+
],
|
|
1166
|
+
include: {
|
|
1167
|
+
effects: true,
|
|
1168
|
+
events: true
|
|
1169
|
+
}
|
|
1010
1170
|
});
|
|
1011
1171
|
}
|
|
1012
1172
|
async dashboard() {
|
|
@@ -1048,11 +1208,15 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1048
1208
|
var import_sui3_utils5 = require("@msafe/sui3-utils");
|
|
1049
1209
|
var import_utils5 = require("@mysten/sui/utils");
|
|
1050
1210
|
var PublicKeyHelper = class {
|
|
1211
|
+
static {
|
|
1212
|
+
__name(this, "PublicKeyHelper");
|
|
1213
|
+
}
|
|
1214
|
+
globals;
|
|
1215
|
+
knownPublicKeys;
|
|
1051
1216
|
constructor(globals) {
|
|
1052
1217
|
this.globals = globals;
|
|
1053
1218
|
this.knownPublicKeys = /* @__PURE__ */ new Map();
|
|
1054
1219
|
}
|
|
1055
|
-
knownPublicKeys;
|
|
1056
1220
|
async getPublicKey(address) {
|
|
1057
1221
|
const cached = this.knownPublicKeys.get(address);
|
|
1058
1222
|
if (cached) {
|
|
@@ -1123,6 +1287,10 @@ var PublicKeyHelper = class {
|
|
|
1123
1287
|
|
|
1124
1288
|
// src/core/ReportSDK.ts
|
|
1125
1289
|
var ReportSDK = class {
|
|
1290
|
+
static {
|
|
1291
|
+
__name(this, "ReportSDK");
|
|
1292
|
+
}
|
|
1293
|
+
globals;
|
|
1126
1294
|
constructor(globals) {
|
|
1127
1295
|
this.globals = globals;
|
|
1128
1296
|
}
|
|
@@ -1138,11 +1306,16 @@ var import_grpc = require("@mysten/sui/grpc");
|
|
|
1138
1306
|
var import_sui3_utils6 = require("@msafe/sui3-utils");
|
|
1139
1307
|
var import_axios = __toESM(require("axios"), 1);
|
|
1140
1308
|
var BackendImpl = class _BackendImpl {
|
|
1309
|
+
static {
|
|
1310
|
+
__name(this, "BackendImpl");
|
|
1311
|
+
}
|
|
1312
|
+
apiURL;
|
|
1313
|
+
mockAddress;
|
|
1314
|
+
_token;
|
|
1141
1315
|
constructor(apiURL, mockAddress) {
|
|
1142
1316
|
this.apiURL = apiURL;
|
|
1143
1317
|
this.mockAddress = mockAddress;
|
|
1144
1318
|
}
|
|
1145
|
-
_token;
|
|
1146
1319
|
getNotificationInfo() {
|
|
1147
1320
|
return this.get(`/notification`, {
|
|
1148
1321
|
headers: this.headers()
|
|
@@ -1165,7 +1338,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1165
1338
|
}
|
|
1166
1339
|
async verifyToken(jwt) {
|
|
1167
1340
|
try {
|
|
1168
|
-
const res = await this.get(`/auth`, {
|
|
1341
|
+
const res = await this.get(`/auth`, {
|
|
1342
|
+
headers: this.headers(jwt)
|
|
1343
|
+
});
|
|
1169
1344
|
return res.status === 200;
|
|
1170
1345
|
} catch (_) {
|
|
1171
1346
|
return false;
|
|
@@ -1175,7 +1350,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1175
1350
|
this._token = token;
|
|
1176
1351
|
}
|
|
1177
1352
|
async getPublicKey(address) {
|
|
1178
|
-
return (await this.getPublicKeyBatch([
|
|
1353
|
+
return (await this.getPublicKeyBatch([
|
|
1354
|
+
address
|
|
1355
|
+
]))[0];
|
|
1179
1356
|
}
|
|
1180
1357
|
async getPublicKeyBatch(addresses) {
|
|
1181
1358
|
const query = {
|
|
@@ -1185,9 +1362,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1185
1362
|
params: query,
|
|
1186
1363
|
headers: this.headers()
|
|
1187
1364
|
});
|
|
1188
|
-
return res.data?.map(
|
|
1189
|
-
(publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0
|
|
1190
|
-
);
|
|
1365
|
+
return res.data?.map((publicKeyWithSchema) => publicKeyWithSchema ? import_sui3_utils6.PublicKeySerde.de(publicKeyWithSchema) : void 0);
|
|
1191
1366
|
}
|
|
1192
1367
|
async getMSafeAccountInfo(msafeAddress) {
|
|
1193
1368
|
const q = {
|
|
@@ -1224,7 +1399,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1224
1399
|
}
|
|
1225
1400
|
async updateMSafeStatus(input) {
|
|
1226
1401
|
const p = input;
|
|
1227
|
-
await this.post(`/msafe/status`, p, {
|
|
1402
|
+
await this.post(`/msafe/status`, p, {
|
|
1403
|
+
headers: this.headers()
|
|
1404
|
+
});
|
|
1228
1405
|
}
|
|
1229
1406
|
async getPendingTransactions(input) {
|
|
1230
1407
|
const res = await this.get(`/transaction/pending`, {
|
|
@@ -1278,16 +1455,18 @@ var BackendImpl = class _BackendImpl {
|
|
|
1278
1455
|
});
|
|
1279
1456
|
}
|
|
1280
1457
|
async proposeIntention(input) {
|
|
1281
|
-
await this.post(`/transaction/intention`, input, {
|
|
1458
|
+
await this.post(`/transaction/intention`, input, {
|
|
1459
|
+
headers: this.headers()
|
|
1460
|
+
});
|
|
1282
1461
|
}
|
|
1283
1462
|
async rejectCurrentTx(input) {
|
|
1284
|
-
await this.post(
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
);
|
|
1463
|
+
await this.post(`/transaction/pending/reject`, {
|
|
1464
|
+
...input,
|
|
1465
|
+
gasPrice: input.gasPrice.toString(),
|
|
1466
|
+
gasBudget: input.gasBudget.toString()
|
|
1467
|
+
}, {
|
|
1468
|
+
headers: this.headers()
|
|
1469
|
+
});
|
|
1291
1470
|
}
|
|
1292
1471
|
async voteForTransaction(input) {
|
|
1293
1472
|
await this.post(`/transaction/pending/vote`, input, {
|
|
@@ -1295,24 +1474,32 @@ var BackendImpl = class _BackendImpl {
|
|
|
1295
1474
|
});
|
|
1296
1475
|
}
|
|
1297
1476
|
async buildNextIntentionAndAddToPending(input) {
|
|
1298
|
-
await this.post(
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1477
|
+
await this.post(`/transaction/pending/build`, {
|
|
1478
|
+
...input,
|
|
1479
|
+
gasPrice: input.gasPrice.toString(),
|
|
1480
|
+
gasBudget: input.gasBudget.toString()
|
|
1481
|
+
}, {
|
|
1482
|
+
headers: this.headers()
|
|
1483
|
+
});
|
|
1303
1484
|
}
|
|
1304
1485
|
async proposeIntentionAndBuildVote(input) {
|
|
1305
|
-
await this.post(
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1486
|
+
await this.post(`/transaction/intention/build`, {
|
|
1487
|
+
...input,
|
|
1488
|
+
gasPrice: input.gasPrice.toString(),
|
|
1489
|
+
gasBudget: input.gasBudget.toString()
|
|
1490
|
+
}, {
|
|
1491
|
+
headers: this.headers()
|
|
1492
|
+
});
|
|
1310
1493
|
}
|
|
1311
1494
|
async skipNextFailedIntention(input) {
|
|
1312
|
-
await this.post(`/transaction/pending/skip`, input, {
|
|
1495
|
+
await this.post(`/transaction/pending/skip`, input, {
|
|
1496
|
+
headers: this.headers()
|
|
1497
|
+
});
|
|
1313
1498
|
}
|
|
1314
1499
|
async fetchTransaction(input) {
|
|
1315
|
-
const res = await this.post(`/transaction/fetch`, input, {
|
|
1500
|
+
const res = await this.post(`/transaction/fetch`, input, {
|
|
1501
|
+
headers: this.headers()
|
|
1502
|
+
});
|
|
1316
1503
|
return res.data;
|
|
1317
1504
|
}
|
|
1318
1505
|
async getAddressBookEntries(pagination) {
|
|
@@ -1323,14 +1510,22 @@ var BackendImpl = class _BackendImpl {
|
|
|
1323
1510
|
return res.data;
|
|
1324
1511
|
}
|
|
1325
1512
|
async updateAddressBook(input) {
|
|
1326
|
-
await this.post(`/address-book`, input, {
|
|
1513
|
+
await this.post(`/address-book`, input, {
|
|
1514
|
+
headers: this.headers()
|
|
1515
|
+
});
|
|
1327
1516
|
}
|
|
1328
1517
|
async getAddressBookMode() {
|
|
1329
|
-
const res = await this.get("/address-book/mode", {
|
|
1518
|
+
const res = await this.get("/address-book/mode", {
|
|
1519
|
+
headers: this.headers()
|
|
1520
|
+
});
|
|
1330
1521
|
return res.data;
|
|
1331
1522
|
}
|
|
1332
1523
|
async setAddressBookMode(input) {
|
|
1333
|
-
await this.post("/address-book/mode", {
|
|
1524
|
+
await this.post("/address-book/mode", {
|
|
1525
|
+
mode: input.mode
|
|
1526
|
+
}, {
|
|
1527
|
+
headers: this.headers()
|
|
1528
|
+
});
|
|
1334
1529
|
}
|
|
1335
1530
|
async submitReport(report) {
|
|
1336
1531
|
await this.post("/report", report);
|
|
@@ -1343,7 +1538,10 @@ var BackendImpl = class _BackendImpl {
|
|
|
1343
1538
|
return res.data;
|
|
1344
1539
|
}
|
|
1345
1540
|
headers(token) {
|
|
1346
|
-
return {
|
|
1541
|
+
return {
|
|
1542
|
+
Authorization: `Bearer ${token || this._token}`,
|
|
1543
|
+
"sui-mock-user": this.mockAddress
|
|
1544
|
+
};
|
|
1347
1545
|
}
|
|
1348
1546
|
static toMSafeConfig(resp) {
|
|
1349
1547
|
return {
|
|
@@ -1399,7 +1597,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1399
1597
|
} else if (transformRequest instanceof Array) {
|
|
1400
1598
|
transformRequests = transformRequest;
|
|
1401
1599
|
} else {
|
|
1402
|
-
transformRequests = [
|
|
1600
|
+
transformRequests = [
|
|
1601
|
+
transformRequest
|
|
1602
|
+
];
|
|
1403
1603
|
}
|
|
1404
1604
|
return [
|
|
1405
1605
|
(d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
|
|
@@ -1408,6 +1608,10 @@ var BackendImpl = class _BackendImpl {
|
|
|
1408
1608
|
}
|
|
1409
1609
|
};
|
|
1410
1610
|
var BackendError = class _BackendError extends Error {
|
|
1611
|
+
static {
|
|
1612
|
+
__name(this, "BackendError");
|
|
1613
|
+
}
|
|
1614
|
+
e;
|
|
1411
1615
|
constructor(e) {
|
|
1412
1616
|
super();
|
|
1413
1617
|
this.e = e;
|
|
@@ -1444,14 +1648,15 @@ var BackendError = class _BackendError extends Error {
|
|
|
1444
1648
|
function msafeChainToSuiNetwork(chain) {
|
|
1445
1649
|
return chain === "sui:mainnet" ? "mainnet" : "testnet";
|
|
1446
1650
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1651
|
+
__name(msafeChainToSuiNetwork, "msafeChainToSuiNetwork");
|
|
1652
|
+
var MSafeEnv;
|
|
1653
|
+
(function(MSafeEnv2) {
|
|
1654
|
+
MSafeEnv2["local"] = "local";
|
|
1655
|
+
MSafeEnv2["unit"] = "unit";
|
|
1656
|
+
MSafeEnv2["dev"] = "dev";
|
|
1657
|
+
MSafeEnv2["prev"] = "prev";
|
|
1658
|
+
MSafeEnv2["prod"] = "prod";
|
|
1659
|
+
})(MSafeEnv || (MSafeEnv = {}));
|
|
1455
1660
|
function httpUrlToGrpcBaseUrl(url) {
|
|
1456
1661
|
const parsed = new URL(url);
|
|
1457
1662
|
if (parsed.protocol === "https:" && parsed.port === "") {
|
|
@@ -1462,6 +1667,7 @@ function httpUrlToGrpcBaseUrl(url) {
|
|
|
1462
1667
|
}
|
|
1463
1668
|
return `${parsed.origin}${parsed.pathname}${parsed.search}`;
|
|
1464
1669
|
}
|
|
1670
|
+
__name(httpUrlToGrpcBaseUrl, "httpUrlToGrpcBaseUrl");
|
|
1465
1671
|
var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
|
|
1466
1672
|
var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
|
|
1467
1673
|
var LOCAL_API_URL = "http://127.0.0.1:3000";
|
|
@@ -1472,7 +1678,7 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
|
|
|
1472
1678
|
var PROD_API_URL = "https://sui.m-safe.link";
|
|
1473
1679
|
var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
1474
1680
|
[
|
|
1475
|
-
"unit"
|
|
1681
|
+
"unit",
|
|
1476
1682
|
{
|
|
1477
1683
|
suiClient: {
|
|
1478
1684
|
url: TESTNET_RPC_URL
|
|
@@ -1485,7 +1691,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1485
1691
|
}
|
|
1486
1692
|
],
|
|
1487
1693
|
[
|
|
1488
|
-
"local"
|
|
1694
|
+
"local",
|
|
1489
1695
|
{
|
|
1490
1696
|
suiClient: {
|
|
1491
1697
|
url: TESTNET_RPC_URL
|
|
@@ -1498,7 +1704,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1498
1704
|
}
|
|
1499
1705
|
],
|
|
1500
1706
|
[
|
|
1501
|
-
"dev"
|
|
1707
|
+
"dev",
|
|
1502
1708
|
{
|
|
1503
1709
|
suiClient: {
|
|
1504
1710
|
url: TESTNET_RPC_URL
|
|
@@ -1511,7 +1717,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1511
1717
|
}
|
|
1512
1718
|
],
|
|
1513
1719
|
[
|
|
1514
|
-
"prev"
|
|
1720
|
+
"prev",
|
|
1515
1721
|
{
|
|
1516
1722
|
suiClient: {
|
|
1517
1723
|
url: MAINNET_RPC_URL
|
|
@@ -1524,7 +1730,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1524
1730
|
}
|
|
1525
1731
|
],
|
|
1526
1732
|
[
|
|
1527
|
-
"prod"
|
|
1733
|
+
"prod",
|
|
1528
1734
|
{
|
|
1529
1735
|
suiClient: {
|
|
1530
1736
|
url: MAINNET_RPC_URL
|
|
@@ -1553,9 +1759,13 @@ function getMSafeConfig(env, options) {
|
|
|
1553
1759
|
}
|
|
1554
1760
|
return config;
|
|
1555
1761
|
}
|
|
1762
|
+
__name(getMSafeConfig, "getMSafeConfig");
|
|
1556
1763
|
|
|
1557
1764
|
// src/globals/MSafeGlobals.ts
|
|
1558
1765
|
var MSafeGlobals = class _MSafeGlobals {
|
|
1766
|
+
static {
|
|
1767
|
+
__name(this, "MSafeGlobals");
|
|
1768
|
+
}
|
|
1559
1769
|
backend;
|
|
1560
1770
|
suiClient;
|
|
1561
1771
|
config;
|
|
@@ -1597,11 +1807,15 @@ var MSafeGlobals = class _MSafeGlobals {
|
|
|
1597
1807
|
|
|
1598
1808
|
// src/core/MSafeClient.ts
|
|
1599
1809
|
var MSafeClient = class _MSafeClient {
|
|
1600
|
-
|
|
1601
|
-
this
|
|
1810
|
+
static {
|
|
1811
|
+
__name(this, "MSafeClient");
|
|
1602
1812
|
}
|
|
1813
|
+
globals;
|
|
1603
1814
|
_creationHelper;
|
|
1604
1815
|
_publicKeyHelper;
|
|
1816
|
+
constructor(globals) {
|
|
1817
|
+
this.globals = globals;
|
|
1818
|
+
}
|
|
1605
1819
|
static async New(env, options) {
|
|
1606
1820
|
const globals = await MSafeGlobals.New(env, options);
|
|
1607
1821
|
return new _MSafeClient(globals);
|
|
@@ -1636,7 +1850,10 @@ var MSafeClient = class _MSafeClient {
|
|
|
1636
1850
|
return this.globals.backend.getUserInfo();
|
|
1637
1851
|
}
|
|
1638
1852
|
async ownedMSafe(pagination) {
|
|
1639
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
1853
|
+
return this.globals.backend.getOwnedMSafeByStatus({
|
|
1854
|
+
status: import_sui3_utils7.UserMSafeStatus.active,
|
|
1855
|
+
pagination
|
|
1856
|
+
});
|
|
1640
1857
|
}
|
|
1641
1858
|
async createAccount(info) {
|
|
1642
1859
|
return this.creationHelper.submitMSafeCreation(info);
|
|
@@ -1686,26 +1903,38 @@ var MSafeClient = class _MSafeClient {
|
|
|
1686
1903
|
};
|
|
1687
1904
|
|
|
1688
1905
|
// src/backend/types/notification.ts
|
|
1689
|
-
var InfoTypeKey
|
|
1906
|
+
var InfoTypeKey;
|
|
1907
|
+
(function(InfoTypeKey2) {
|
|
1690
1908
|
InfoTypeKey2["receive"] = "info_type_receive";
|
|
1691
1909
|
InfoTypeKey2["send"] = "info_type_send";
|
|
1692
1910
|
InfoTypeKey2["invitation"] = "info_type_invitation";
|
|
1693
1911
|
InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
|
|
1694
|
-
|
|
1695
|
-
})(InfoTypeKey || {});
|
|
1912
|
+
})(InfoTypeKey || (InfoTypeKey = {}));
|
|
1696
1913
|
var NotificationSubscribeDto = class {
|
|
1914
|
+
static {
|
|
1915
|
+
__name(this, "NotificationSubscribeDto");
|
|
1916
|
+
}
|
|
1697
1917
|
email;
|
|
1698
1918
|
};
|
|
1699
1919
|
var NotificationUpdateDto = class {
|
|
1920
|
+
static {
|
|
1921
|
+
__name(this, "NotificationUpdateDto");
|
|
1922
|
+
}
|
|
1700
1923
|
email;
|
|
1701
1924
|
infoTypes;
|
|
1702
1925
|
msafeEnabled;
|
|
1703
1926
|
};
|
|
1704
1927
|
var InfoTypeEnabledDto = class {
|
|
1928
|
+
static {
|
|
1929
|
+
__name(this, "InfoTypeEnabledDto");
|
|
1930
|
+
}
|
|
1705
1931
|
infoType;
|
|
1706
1932
|
enabled;
|
|
1707
1933
|
};
|
|
1708
1934
|
var MSafeEnabledDto = class {
|
|
1935
|
+
static {
|
|
1936
|
+
__name(this, "MSafeEnabledDto");
|
|
1937
|
+
}
|
|
1709
1938
|
msafeAddress;
|
|
1710
1939
|
enabled;
|
|
1711
1940
|
};
|