@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.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/core/CreateHelper.ts
|
|
5
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isSameAddress,
|
|
4
|
+
MultiSigAccount,
|
|
5
|
+
PublicKeySerde,
|
|
6
|
+
SigningMessageHelper
|
|
7
|
+
} from "@msafe/sui3-utils";
|
|
6
8
|
var CreateHelper = class {
|
|
7
|
-
static {
|
|
8
|
-
__name(this, "CreateHelper");
|
|
9
|
-
}
|
|
10
|
-
globals;
|
|
11
|
-
pkHelper;
|
|
12
9
|
constructor(globals, pkHelper) {
|
|
13
10
|
this.globals = globals;
|
|
14
11
|
this.pkHelper = pkHelper;
|
|
@@ -26,13 +23,13 @@ var CreateHelper = class {
|
|
|
26
23
|
return this.calculateMSafeAddress(createInfo);
|
|
27
24
|
}
|
|
28
25
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
* Add user manually added public key for an address. If user input the public key with
|
|
27
|
+
* extra signature scheme flag, the scheme value will be automatically fixed.
|
|
28
|
+
*
|
|
29
|
+
* @param address
|
|
30
|
+
* @param pkEncoded
|
|
31
|
+
* @throws error if the public key does not match
|
|
32
|
+
*/
|
|
36
33
|
addPublicKey(address, pkEncoded) {
|
|
37
34
|
const pk = PublicKeySerde.de(pkEncoded);
|
|
38
35
|
if (!isSameAddress(address, pk.toSuiAddress())) {
|
|
@@ -43,9 +40,7 @@ var CreateHelper = class {
|
|
|
43
40
|
async submitMSafeCreation(creationInfo) {
|
|
44
41
|
const msafeAddress = await this.validateCreateInfo(creationInfo);
|
|
45
42
|
const signingMessage = SigningMessageHelper.createMSafeMessage(msafeAddress);
|
|
46
|
-
const signature = await this.globals.wallet.signPersonalMessage({
|
|
47
|
-
messageStr: signingMessage
|
|
48
|
-
});
|
|
43
|
+
const signature = await this.globals.wallet.signPersonalMessage({ messageStr: signingMessage });
|
|
49
44
|
await this.submitToBackend(creationInfo, signature.signature);
|
|
50
45
|
return msafeAddress;
|
|
51
46
|
}
|
|
@@ -76,7 +71,9 @@ var CreateHelper = class {
|
|
|
76
71
|
})),
|
|
77
72
|
threshold: createInfo.threshold,
|
|
78
73
|
name: createInfo.name,
|
|
74
|
+
// name validation is deferred to backend
|
|
79
75
|
description: createInfo.description,
|
|
76
|
+
// description validation is deferred to backend
|
|
80
77
|
creationNonce: createInfo.creationNonce,
|
|
81
78
|
signature
|
|
82
79
|
});
|
|
@@ -84,15 +81,14 @@ var CreateHelper = class {
|
|
|
84
81
|
};
|
|
85
82
|
|
|
86
83
|
// src/core/MSafeClient.ts
|
|
87
|
-
import {
|
|
84
|
+
import {
|
|
85
|
+
SigningMessageHelper as SigningMessageHelper4,
|
|
86
|
+
UserMSafeStatus as UserMSafeStatus2
|
|
87
|
+
} from "@msafe/sui3-utils";
|
|
88
88
|
|
|
89
89
|
// src/core/AddressBookSDK.ts
|
|
90
90
|
import { SigningMessageHelper as SigningMessageHelper2 } from "@msafe/sui3-utils";
|
|
91
91
|
var AddressBookSDK = class {
|
|
92
|
-
static {
|
|
93
|
-
__name(this, "AddressBookSDK");
|
|
94
|
-
}
|
|
95
|
-
globals;
|
|
96
92
|
constructor(globals) {
|
|
97
93
|
this.globals = globals;
|
|
98
94
|
}
|
|
@@ -101,51 +97,42 @@ var AddressBookSDK = class {
|
|
|
101
97
|
}
|
|
102
98
|
async update(updates) {
|
|
103
99
|
const messageStr = SigningMessageHelper2.updateAddressBookMessage(updates);
|
|
104
|
-
const sig = await this.globals.wallet.signPersonalMessage({
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
return this.globals.backend.updateAddressBook({
|
|
108
|
-
updates,
|
|
109
|
-
signature: sig.signature
|
|
110
|
-
});
|
|
100
|
+
const sig = await this.globals.wallet.signPersonalMessage({ messageStr });
|
|
101
|
+
return this.globals.backend.updateAddressBook({ updates, signature: sig.signature });
|
|
111
102
|
}
|
|
112
103
|
async getMode() {
|
|
113
104
|
const res = await this.globals.backend.getAddressBookMode();
|
|
114
105
|
return res.mode;
|
|
115
106
|
}
|
|
116
107
|
async setMode(mode) {
|
|
117
|
-
return this.globals.backend.setAddressBookMode({
|
|
118
|
-
mode
|
|
119
|
-
});
|
|
108
|
+
return this.globals.backend.setAddressBookMode({ mode });
|
|
120
109
|
}
|
|
121
110
|
};
|
|
122
111
|
|
|
123
112
|
// src/core/InvitationSDK.ts
|
|
124
113
|
var InvitationSDK = class {
|
|
125
|
-
static {
|
|
126
|
-
__name(this, "InvitationSDK");
|
|
127
|
-
}
|
|
128
|
-
globals;
|
|
129
114
|
constructor(globals) {
|
|
130
115
|
this.globals = globals;
|
|
131
116
|
}
|
|
132
117
|
async getMSafeByStatus(status, pagination) {
|
|
133
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
134
|
-
status,
|
|
135
|
-
pagination
|
|
136
|
-
});
|
|
118
|
+
return this.globals.backend.getOwnedMSafeByStatus({ status, pagination });
|
|
137
119
|
}
|
|
138
120
|
async updateMSafeStatus(msafeAddress, status) {
|
|
139
|
-
return this.globals.backend.updateMSafeStatus({
|
|
140
|
-
msafeAddress,
|
|
141
|
-
status
|
|
142
|
-
});
|
|
121
|
+
return this.globals.backend.updateMSafeStatus({ msafeAddress, status });
|
|
143
122
|
}
|
|
144
123
|
};
|
|
145
124
|
|
|
146
125
|
// src/core/MSafeAccount.ts
|
|
147
126
|
import { appHelpers } from "@msafe/sui-app-store";
|
|
148
|
-
import {
|
|
127
|
+
import {
|
|
128
|
+
MultiSigAccount as MultiSigAccount2,
|
|
129
|
+
SigningMessageHelper as SigningMessageHelper3,
|
|
130
|
+
TransactionDefaultApplication,
|
|
131
|
+
TransactionSubTypes,
|
|
132
|
+
TransactionType,
|
|
133
|
+
buildRejectTxb,
|
|
134
|
+
isSameAddress as isSameAddress2
|
|
135
|
+
} from "@msafe/sui3-utils";
|
|
149
136
|
import { Transaction as Transaction3 } from "@mysten/sui/transactions";
|
|
150
137
|
import { fromHex, normalizeStructTag as normalizeStructTag3, toHex } from "@mysten/sui/utils";
|
|
151
138
|
import { SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN } from "@mysten/wallet-standard";
|
|
@@ -156,25 +143,15 @@ var GAS_SAFE_OVERHEAD = 1000n;
|
|
|
156
143
|
function formatExecutionError(error) {
|
|
157
144
|
return error.message;
|
|
158
145
|
}
|
|
159
|
-
__name(formatExecutionError, "formatExecutionError");
|
|
160
146
|
function gasObjectToReference(gas) {
|
|
161
147
|
if (!gas?.objectId) {
|
|
162
148
|
throw new Error("Gas object missing from simulation effects");
|
|
163
149
|
}
|
|
164
150
|
const version = gas.outputVersion ?? gas.inputVersion ?? "0";
|
|
165
151
|
const digest = gas.outputDigest ?? gas.inputDigest ?? "";
|
|
166
|
-
return {
|
|
167
|
-
objectId: gas.objectId,
|
|
168
|
-
version,
|
|
169
|
-
digest
|
|
170
|
-
};
|
|
152
|
+
return { objectId: gas.objectId, version, digest };
|
|
171
153
|
}
|
|
172
|
-
__name(gasObjectToReference, "gasObjectToReference");
|
|
173
154
|
var Simulator = class {
|
|
174
|
-
static {
|
|
175
|
-
__name(this, "Simulator");
|
|
176
|
-
}
|
|
177
|
-
globals;
|
|
178
155
|
constructor(globals) {
|
|
179
156
|
this.globals = globals;
|
|
180
157
|
}
|
|
@@ -186,9 +163,7 @@ var Simulator = class {
|
|
|
186
163
|
tx.setSender(input.sender);
|
|
187
164
|
let built;
|
|
188
165
|
try {
|
|
189
|
-
built = await tx.build({
|
|
190
|
-
client: suiClient
|
|
191
|
-
});
|
|
166
|
+
built = await tx.build({ client: suiClient });
|
|
192
167
|
} catch (e) {
|
|
193
168
|
const message = e instanceof Error ? e.message : String(e);
|
|
194
169
|
return {
|
|
@@ -256,24 +231,21 @@ var Simulator = class {
|
|
|
256
231
|
return gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead;
|
|
257
232
|
}
|
|
258
233
|
copyTransaction(tx) {
|
|
259
|
-
return Transaction.from(tx
|
|
234
|
+
return Transaction.from(tx);
|
|
260
235
|
}
|
|
261
236
|
};
|
|
262
237
|
|
|
263
238
|
// src/utils/buffer.ts
|
|
264
|
-
import { Buffer
|
|
239
|
+
import { Buffer } from "buffer";
|
|
265
240
|
function stringToBuffer(s) {
|
|
266
|
-
return
|
|
241
|
+
return Buffer.from(s, "utf-8");
|
|
267
242
|
}
|
|
268
|
-
__name(stringToBuffer, "stringToBuffer");
|
|
269
243
|
function Uint8ArrayToHex(b) {
|
|
270
244
|
return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
|
|
271
245
|
}
|
|
272
|
-
__name(Uint8ArrayToHex, "Uint8ArrayToHex");
|
|
273
246
|
function HexToUint8Array(hex) {
|
|
274
|
-
return Uint8Array.from(
|
|
247
|
+
return Uint8Array.from(Buffer.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
|
|
275
248
|
}
|
|
276
|
-
__name(HexToUint8Array, "HexToUint8Array");
|
|
277
249
|
|
|
278
250
|
// src/utils/crypto.ts
|
|
279
251
|
import { verifyPersonalMessageSignature, verifyTransactionSignature } from "@mysten/sui/verify";
|
|
@@ -284,9 +256,6 @@ import { normalizeSuiAddress, normalizeStructTag as normalizeStructTag2 } from "
|
|
|
284
256
|
// src/utils/coin.ts
|
|
285
257
|
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
286
258
|
var CoinHelper = class {
|
|
287
|
-
static {
|
|
288
|
-
__name(this, "CoinHelper");
|
|
289
|
-
}
|
|
290
259
|
_client;
|
|
291
260
|
_coinMetaReg;
|
|
292
261
|
constructor(client) {
|
|
@@ -305,17 +274,12 @@ var CoinHelper = class {
|
|
|
305
274
|
return meta;
|
|
306
275
|
}
|
|
307
276
|
async queryCoinMeta(coinType) {
|
|
308
|
-
const res = await this._client.getCoinMetadata({
|
|
309
|
-
coinType
|
|
310
|
-
});
|
|
277
|
+
const res = await this._client.getCoinMetadata({ coinType });
|
|
311
278
|
return res.coinMetadata ?? void 0;
|
|
312
279
|
}
|
|
313
280
|
};
|
|
314
281
|
var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
|
|
315
282
|
var Coin = class _Coin {
|
|
316
|
-
static {
|
|
317
|
-
__name(this, "Coin");
|
|
318
|
-
}
|
|
319
283
|
static isCoin(type) {
|
|
320
284
|
if (!type) {
|
|
321
285
|
return false;
|
|
@@ -350,9 +314,6 @@ var Coin = class _Coin {
|
|
|
350
314
|
|
|
351
315
|
// src/utils/format.ts
|
|
352
316
|
var Formatter = class {
|
|
353
|
-
static {
|
|
354
|
-
__name(this, "Formatter");
|
|
355
|
-
}
|
|
356
317
|
static normalizeSuiAddress(addr) {
|
|
357
318
|
return normalizeSuiAddress(addr);
|
|
358
319
|
}
|
|
@@ -375,13 +336,9 @@ function addPrefix(s, prefix) {
|
|
|
375
336
|
}
|
|
376
337
|
return prefix + s;
|
|
377
338
|
}
|
|
378
|
-
__name(addPrefix, "addPrefix");
|
|
379
339
|
|
|
380
340
|
// src/utils/crypto.ts
|
|
381
341
|
var SignatureVerifier = class _SignatureVerifier {
|
|
382
|
-
static {
|
|
383
|
-
__name(this, "SignatureVerifier");
|
|
384
|
-
}
|
|
385
342
|
static async getPublicKeyFromSignature(input) {
|
|
386
343
|
if (input.messageType === "TransactionBlock") {
|
|
387
344
|
return verifyTransactionSignature(input.message, input.signature);
|
|
@@ -432,35 +389,24 @@ var GRAPHQL_URL_BY_NETWORK = {
|
|
|
432
389
|
};
|
|
433
390
|
function graphqlClientForGrpc(suiClient) {
|
|
434
391
|
const url = GRAPHQL_URL_BY_NETWORK[suiClient.network] ?? GRAPHQL_URL_BY_NETWORK.testnet;
|
|
435
|
-
return new SuiGraphQLClient({
|
|
436
|
-
url,
|
|
437
|
-
network: suiClient.network
|
|
438
|
-
});
|
|
392
|
+
return new SuiGraphQLClient({ url, network: suiClient.network });
|
|
439
393
|
}
|
|
440
|
-
__name(graphqlClientForGrpc, "graphqlClientForGrpc");
|
|
441
394
|
function collectSignatureStrings(value) {
|
|
442
395
|
if (typeof value === "string") {
|
|
443
|
-
return [
|
|
444
|
-
value
|
|
445
|
-
];
|
|
396
|
+
return [value];
|
|
446
397
|
}
|
|
447
398
|
if (!value || typeof value !== "object") {
|
|
448
399
|
return [];
|
|
449
400
|
}
|
|
450
401
|
if ("base64" in value && typeof value.base64 === "string") {
|
|
451
|
-
return [
|
|
452
|
-
value.base64
|
|
453
|
-
];
|
|
402
|
+
return [value.base64];
|
|
454
403
|
}
|
|
455
404
|
if ("scheme" in value && "base64" in value) {
|
|
456
405
|
const b64 = value.base64;
|
|
457
|
-
return typeof b64 === "string" ? [
|
|
458
|
-
b64
|
|
459
|
-
] : [];
|
|
406
|
+
return typeof b64 === "string" ? [b64] : [];
|
|
460
407
|
}
|
|
461
408
|
return [];
|
|
462
409
|
}
|
|
463
|
-
__name(collectSignatureStrings, "collectSignatureStrings");
|
|
464
410
|
var TX_SIG_QUERY = `
|
|
465
411
|
query PublicKeyTxSigs($sender: SuiAddress!, $first: Int!) {
|
|
466
412
|
transactions(first: $first, filter: { sentAddress: $sender }) {
|
|
@@ -476,10 +422,7 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
476
422
|
try {
|
|
477
423
|
const res = await graphql.query({
|
|
478
424
|
query: TX_SIG_QUERY,
|
|
479
|
-
variables: {
|
|
480
|
-
sender: address,
|
|
481
|
-
first: 2
|
|
482
|
-
}
|
|
425
|
+
variables: { sender: address, first: 2 }
|
|
483
426
|
});
|
|
484
427
|
if (res.errors?.length) {
|
|
485
428
|
return void 0;
|
|
@@ -508,7 +451,6 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
508
451
|
}
|
|
509
452
|
return void 0;
|
|
510
453
|
}
|
|
511
|
-
__name(getPublicKeyFromChain, "getPublicKeyFromChain");
|
|
512
454
|
function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
513
455
|
const decoded = parseSerializedSignature(serializedSig);
|
|
514
456
|
switch (decoded.signatureScheme) {
|
|
@@ -523,10 +465,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
523
465
|
case "ED25519":
|
|
524
466
|
case "Secp256k1":
|
|
525
467
|
case "Secp256r1": {
|
|
526
|
-
const pk = PublicKeySerde2.de({
|
|
527
|
-
publicKeyEncoded: decoded.publicKey,
|
|
528
|
-
schema: decoded.signatureScheme
|
|
529
|
-
});
|
|
468
|
+
const pk = PublicKeySerde2.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
|
|
530
469
|
if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
|
|
531
470
|
return pk;
|
|
532
471
|
}
|
|
@@ -536,7 +475,6 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
536
475
|
throw new Error("Unknown schema");
|
|
537
476
|
}
|
|
538
477
|
}
|
|
539
|
-
__name(getAddressFromSignatures, "getAddressFromSignatures");
|
|
540
478
|
async function getAllCoins(input) {
|
|
541
479
|
let hasNext = true;
|
|
542
480
|
let cursor;
|
|
@@ -553,7 +491,6 @@ async function getAllCoins(input) {
|
|
|
553
491
|
}
|
|
554
492
|
return res;
|
|
555
493
|
}
|
|
556
|
-
__name(getAllCoins, "getAllCoins");
|
|
557
494
|
|
|
558
495
|
// src/utils/transaction.ts
|
|
559
496
|
import { Transaction as Transaction2, isTransaction } from "@mysten/sui/transactions";
|
|
@@ -564,7 +501,6 @@ function toSuiTransaction(txb) {
|
|
|
564
501
|
const legacy = txb;
|
|
565
502
|
return Transaction2.from(legacy.serialize());
|
|
566
503
|
}
|
|
567
|
-
__name(toSuiTransaction, "toSuiTransaction");
|
|
568
504
|
|
|
569
505
|
// src/utils/iter/iterator.ts
|
|
570
506
|
var REQUEST_PAGE_SIZE = 25;
|
|
@@ -579,19 +515,14 @@ async function getAllFromIterator(it) {
|
|
|
579
515
|
}
|
|
580
516
|
return res;
|
|
581
517
|
}
|
|
582
|
-
__name(getAllFromIterator, "getAllFromIterator");
|
|
583
518
|
var PagedIterator = class {
|
|
584
|
-
static {
|
|
585
|
-
__name(this, "PagedIterator");
|
|
586
|
-
}
|
|
587
|
-
requester;
|
|
588
|
-
curPage;
|
|
589
|
-
init;
|
|
590
519
|
constructor(requester) {
|
|
591
520
|
this.requester = requester;
|
|
592
521
|
this.curPage = void 0;
|
|
593
522
|
this.init = true;
|
|
594
523
|
}
|
|
524
|
+
curPage;
|
|
525
|
+
init;
|
|
595
526
|
async hasNext() {
|
|
596
527
|
if (this.init) {
|
|
597
528
|
if (!this.curPage) {
|
|
@@ -617,19 +548,15 @@ var PagedIterator = class {
|
|
|
617
548
|
}
|
|
618
549
|
};
|
|
619
550
|
var EntryIterator = class {
|
|
620
|
-
static {
|
|
621
|
-
__name(this, "EntryIterator");
|
|
622
|
-
}
|
|
623
|
-
requester;
|
|
624
|
-
cursor;
|
|
625
|
-
pager;
|
|
626
|
-
curData;
|
|
627
551
|
constructor(requester) {
|
|
628
552
|
this.requester = requester;
|
|
629
553
|
this.pager = new PagedIterator(requester);
|
|
630
554
|
this.curData = [];
|
|
631
555
|
this.cursor = 0;
|
|
632
556
|
}
|
|
557
|
+
cursor;
|
|
558
|
+
pager;
|
|
559
|
+
curData;
|
|
633
560
|
async hasNext() {
|
|
634
561
|
if (this.cursor < this.curData.length - 1) {
|
|
635
562
|
return true;
|
|
@@ -651,28 +578,15 @@ var EntryIterator = class {
|
|
|
651
578
|
};
|
|
652
579
|
|
|
653
580
|
// src/utils/iter/object.ts
|
|
654
|
-
var defaultObjectInclude = {
|
|
655
|
-
json: true
|
|
656
|
-
};
|
|
581
|
+
var defaultObjectInclude = { json: true };
|
|
657
582
|
function mergeInclude(options) {
|
|
658
|
-
return {
|
|
659
|
-
...defaultObjectInclude,
|
|
660
|
-
...options?.objectInclude
|
|
661
|
-
};
|
|
583
|
+
return { ...defaultObjectInclude, ...options?.objectInclude };
|
|
662
584
|
}
|
|
663
|
-
__name(mergeInclude, "mergeInclude");
|
|
664
585
|
async function getAllOwnedObjects(provider, owner, options) {
|
|
665
586
|
const iter = new OwnedObjectIterator(provider, owner, options);
|
|
666
587
|
return await getAllFromIterator(iter);
|
|
667
588
|
}
|
|
668
|
-
__name(getAllOwnedObjects, "getAllOwnedObjects");
|
|
669
589
|
var OwnedObjectIterator = class extends EntryIterator {
|
|
670
|
-
static {
|
|
671
|
-
__name(this, "OwnedObjectIterator");
|
|
672
|
-
}
|
|
673
|
-
provider;
|
|
674
|
-
owner;
|
|
675
|
-
options;
|
|
676
590
|
constructor(provider, owner, options) {
|
|
677
591
|
super(new OwnedObjectRequester(provider, owner, options));
|
|
678
592
|
this.provider = provider;
|
|
@@ -681,16 +595,6 @@ var OwnedObjectIterator = class extends EntryIterator {
|
|
|
681
595
|
}
|
|
682
596
|
};
|
|
683
597
|
var OwnedObjectRequester = class {
|
|
684
|
-
static {
|
|
685
|
-
__name(this, "OwnedObjectRequester");
|
|
686
|
-
}
|
|
687
|
-
provider;
|
|
688
|
-
owner;
|
|
689
|
-
options;
|
|
690
|
-
nextCursor;
|
|
691
|
-
filter;
|
|
692
|
-
pageSize;
|
|
693
|
-
objectInclude;
|
|
694
598
|
constructor(provider, owner, options) {
|
|
695
599
|
this.provider = provider;
|
|
696
600
|
this.owner = owner;
|
|
@@ -700,6 +604,10 @@ var OwnedObjectRequester = class {
|
|
|
700
604
|
this.pageSize = options?.pageSize || REQUEST_PAGE_SIZE;
|
|
701
605
|
this.objectInclude = mergeInclude(options);
|
|
702
606
|
}
|
|
607
|
+
nextCursor;
|
|
608
|
+
filter;
|
|
609
|
+
pageSize;
|
|
610
|
+
objectInclude;
|
|
703
611
|
async doNextRequest() {
|
|
704
612
|
const res = await this.provider.listOwnedObjects({
|
|
705
613
|
owner: this.owner,
|
|
@@ -724,14 +632,6 @@ var OwnedObjectRequester = class {
|
|
|
724
632
|
|
|
725
633
|
// src/core/MSafeAccount.ts
|
|
726
634
|
var MSafeAccount = class _MSafeAccount {
|
|
727
|
-
static {
|
|
728
|
-
__name(this, "MSafeAccount");
|
|
729
|
-
}
|
|
730
|
-
globals;
|
|
731
|
-
info;
|
|
732
|
-
multiSig;
|
|
733
|
-
simulator;
|
|
734
|
-
coinHelper;
|
|
735
635
|
constructor(globals, info) {
|
|
736
636
|
this.globals = globals;
|
|
737
637
|
this.info = info;
|
|
@@ -743,6 +643,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
743
643
|
this.coinHelper = new CoinHelper(this.suiClient);
|
|
744
644
|
this.simulator = new Simulator(globals);
|
|
745
645
|
}
|
|
646
|
+
multiSig;
|
|
647
|
+
simulator;
|
|
648
|
+
coinHelper;
|
|
746
649
|
static async New(globals, address) {
|
|
747
650
|
const info = await globals.backend.getMSafeAccountInfo(address);
|
|
748
651
|
const ms = new _MSafeAccount(globals, info);
|
|
@@ -755,23 +658,21 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
755
658
|
let cursor = null;
|
|
756
659
|
let hasNext = true;
|
|
757
660
|
while (hasNext) {
|
|
758
|
-
const page = await this.suiClient.listBalances({
|
|
759
|
-
owner: this.address,
|
|
760
|
-
cursor,
|
|
761
|
-
limit: 50
|
|
762
|
-
});
|
|
661
|
+
const page = await this.suiClient.listBalances({ owner: this.address, cursor, limit: 50 });
|
|
763
662
|
balances.push(...page.balances);
|
|
764
663
|
hasNext = page.hasNextPage;
|
|
765
664
|
cursor = page.cursor;
|
|
766
665
|
}
|
|
767
|
-
return Promise.all(
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
666
|
+
return Promise.all(
|
|
667
|
+
balances.map(async (balance) => {
|
|
668
|
+
const meta = await this.coinHelper.getCoinMeta(balance.coinType);
|
|
669
|
+
return {
|
|
670
|
+
type: normalizeStructTag3(balance.coinType),
|
|
671
|
+
balance: BigInt(balance.addressBalance),
|
|
672
|
+
metadata: meta
|
|
673
|
+
};
|
|
674
|
+
})
|
|
675
|
+
);
|
|
775
676
|
}
|
|
776
677
|
async ownedObjects(options) {
|
|
777
678
|
const filterCoinObjectOptions = {
|
|
@@ -781,9 +682,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
781
682
|
return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
|
|
782
683
|
}
|
|
783
684
|
async pendingTransaction() {
|
|
784
|
-
const res = await this.backend.getPendingTransactions({
|
|
785
|
-
msafeAddress: this.address
|
|
786
|
-
});
|
|
685
|
+
const res = await this.backend.getPendingTransactions({ msafeAddress: this.address });
|
|
787
686
|
if (!res?.pending) {
|
|
788
687
|
return void 0;
|
|
789
688
|
}
|
|
@@ -815,10 +714,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
815
714
|
});
|
|
816
715
|
}
|
|
817
716
|
async futureIntentions(pagination) {
|
|
818
|
-
return this.backend.getFutureIntentions({
|
|
819
|
-
msafeAddress: this.address,
|
|
820
|
-
...pagination
|
|
821
|
-
});
|
|
717
|
+
return this.backend.getFutureIntentions({ msafeAddress: this.address, ...pagination });
|
|
822
718
|
}
|
|
823
719
|
async currentSequenceNumber() {
|
|
824
720
|
return this.backend.getCurrentSequenceNumber(this.address);
|
|
@@ -835,28 +731,24 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
835
731
|
if (!appHelper) {
|
|
836
732
|
throw new Error(`Can't find app helper for application ${request.application}`);
|
|
837
733
|
}
|
|
838
|
-
txb = toSuiTransaction(
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
SUI_MAINNET_CHAIN,
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}));
|
|
734
|
+
txb = toSuiTransaction(
|
|
735
|
+
await appHelper.build({
|
|
736
|
+
network: this.globals.config.network,
|
|
737
|
+
intentionData: request.intention,
|
|
738
|
+
txType: request.txType,
|
|
739
|
+
txSubType: request.txSubType,
|
|
740
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
741
|
+
account: {
|
|
742
|
+
address: this.address,
|
|
743
|
+
publicKey: fromHex(this.address),
|
|
744
|
+
chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
|
|
745
|
+
features: []
|
|
746
|
+
}
|
|
747
|
+
})
|
|
748
|
+
);
|
|
854
749
|
}
|
|
855
750
|
txb.setSender(this.address);
|
|
856
|
-
return this.simulator.simulate({
|
|
857
|
-
txb,
|
|
858
|
-
sender: this.address
|
|
859
|
-
});
|
|
751
|
+
return this.simulator.simulate({ txb, sender: this.address });
|
|
860
752
|
}
|
|
861
753
|
async proposeIntention(input) {
|
|
862
754
|
const message = SigningMessageHelper3.proposeIntentionMessage({
|
|
@@ -882,35 +774,28 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
882
774
|
if (!appHelper) {
|
|
883
775
|
throw new Error(`Can't find app helper for application ${input.application}`);
|
|
884
776
|
}
|
|
885
|
-
txb = toSuiTransaction(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
SUI_MAINNET_CHAIN,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
}));
|
|
777
|
+
txb = toSuiTransaction(
|
|
778
|
+
await appHelper.build({
|
|
779
|
+
network: this.globals.config.network,
|
|
780
|
+
intentionData: input.intention,
|
|
781
|
+
txType: input.txType,
|
|
782
|
+
txSubType: input.txSubType,
|
|
783
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
784
|
+
account: {
|
|
785
|
+
address: this.address,
|
|
786
|
+
publicKey: fromHex(this.address),
|
|
787
|
+
chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
|
|
788
|
+
features: []
|
|
789
|
+
}
|
|
790
|
+
})
|
|
791
|
+
);
|
|
901
792
|
}
|
|
902
793
|
txb.setGasPrice(input.gasPrice);
|
|
903
794
|
txb.setGasBudget(input.gasBudget);
|
|
904
795
|
txb.setSender(this.address);
|
|
905
|
-
const payload = await txb.build({
|
|
906
|
-
|
|
907
|
-
});
|
|
908
|
-
const digest = await txb.getDigest({
|
|
909
|
-
client: this.globals.suiClient
|
|
910
|
-
});
|
|
911
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
912
|
-
transactionBlock: payload
|
|
913
|
-
});
|
|
796
|
+
const payload = await txb.build({ client: this.globals.suiClient });
|
|
797
|
+
const digest = await txb.getDigest({ client: this.globals.suiClient });
|
|
798
|
+
const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
|
|
914
799
|
return this.backend.proposeIntentionAndBuildVote({
|
|
915
800
|
...input,
|
|
916
801
|
payload: toHex(payload),
|
|
@@ -986,9 +871,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
986
871
|
}
|
|
987
872
|
async voteForTransaction(digest, payload) {
|
|
988
873
|
const payloadBytes = HexToUint8Array(payload);
|
|
989
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
990
|
-
transactionBlock: payloadBytes
|
|
991
|
-
});
|
|
874
|
+
const signature = await this.wallet.signTransactionBlock({ transactionBlock: payloadBytes });
|
|
992
875
|
return this.backend.voteForTransaction({
|
|
993
876
|
msafeAddress: this.address,
|
|
994
877
|
digest,
|
|
@@ -1002,10 +885,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1002
885
|
}
|
|
1003
886
|
const txb = toSuiTransaction(buildRejectTxb(this.address));
|
|
1004
887
|
txb.setSender(this.address);
|
|
1005
|
-
return this.simulator.simulate({
|
|
1006
|
-
txb,
|
|
1007
|
-
sender: this.address
|
|
1008
|
-
});
|
|
888
|
+
return this.simulator.simulate({ txb, sender: this.address });
|
|
1009
889
|
}
|
|
1010
890
|
async rejectCurrentTx(input) {
|
|
1011
891
|
const pendingTx = await this.pendingTransaction();
|
|
@@ -1013,15 +893,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1013
893
|
throw new Error("Already rejected");
|
|
1014
894
|
}
|
|
1015
895
|
const rejectTxb = toSuiTransaction(buildRejectTxb(this.address));
|
|
1016
|
-
const digest = await rejectTxb.getDigest({
|
|
1017
|
-
|
|
1018
|
-
});
|
|
1019
|
-
const payload = await rejectTxb.build({
|
|
1020
|
-
client: this.suiClient
|
|
1021
|
-
});
|
|
1022
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
1023
|
-
transactionBlock: payload
|
|
1024
|
-
});
|
|
896
|
+
const digest = await rejectTxb.getDigest({ client: this.suiClient });
|
|
897
|
+
const payload = await rejectTxb.build({ client: this.suiClient });
|
|
898
|
+
const signature = await this.wallet.signTransactionBlock({ transactionBlock: payload });
|
|
1025
899
|
return this.backend.rejectCurrentTx({
|
|
1026
900
|
msafeAddress: this.address,
|
|
1027
901
|
digest,
|
|
@@ -1030,34 +904,28 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1030
904
|
});
|
|
1031
905
|
}
|
|
1032
906
|
async simulateBuildTransaction() {
|
|
1033
|
-
const intention = await this.backend.getNextIntention({
|
|
1034
|
-
msafeAddress: this.address
|
|
1035
|
-
});
|
|
907
|
+
const intention = await this.backend.getNextIntention({ msafeAddress: this.address });
|
|
1036
908
|
const appHelper = appHelpers.getAppHelper(intention.application);
|
|
1037
909
|
if (!appHelper) {
|
|
1038
910
|
throw new Error(`Can't find app helper for application ${intention.application}`);
|
|
1039
911
|
}
|
|
1040
|
-
const txb = toSuiTransaction(
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
SUI_MAINNET_CHAIN,
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}));
|
|
912
|
+
const txb = toSuiTransaction(
|
|
913
|
+
await appHelper.build({
|
|
914
|
+
network: this.globals.config.network,
|
|
915
|
+
intentionData: intention.intention,
|
|
916
|
+
txType: intention.txType,
|
|
917
|
+
txSubType: intention.txSubType,
|
|
918
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
919
|
+
account: {
|
|
920
|
+
address: this.address,
|
|
921
|
+
publicKey: fromHex(this.address),
|
|
922
|
+
chains: [SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN],
|
|
923
|
+
features: []
|
|
924
|
+
}
|
|
925
|
+
})
|
|
926
|
+
);
|
|
1056
927
|
txb.setSender(this.address);
|
|
1057
|
-
return this.simulator.simulate({
|
|
1058
|
-
txb,
|
|
1059
|
-
sender: this.address
|
|
1060
|
-
});
|
|
928
|
+
return this.simulator.simulate({ txb, sender: this.address });
|
|
1061
929
|
}
|
|
1062
930
|
async buildNextIntentionAndAddToPending(gasOption) {
|
|
1063
931
|
return this.backend.buildNextIntentionAndAddToPending({
|
|
@@ -1068,14 +936,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1068
936
|
});
|
|
1069
937
|
}
|
|
1070
938
|
async skipNextFailedIntention() {
|
|
1071
|
-
return this.backend.skipNextFailedIntention({
|
|
1072
|
-
msafeAddress: this.address
|
|
1073
|
-
});
|
|
939
|
+
return this.backend.skipNextFailedIntention({ msafeAddress: this.address });
|
|
1074
940
|
}
|
|
1075
941
|
async fetchTransaction() {
|
|
1076
|
-
return this.backend.fetchTransaction({
|
|
1077
|
-
msafeAddress: this.address
|
|
1078
|
-
});
|
|
942
|
+
return this.backend.fetchTransaction({ msafeAddress: this.address });
|
|
1079
943
|
}
|
|
1080
944
|
async executePendingTx(pending, isRejectTx = false) {
|
|
1081
945
|
const votes = isRejectTx ? pending.rejectVotes : pending.votes;
|
|
@@ -1084,10 +948,7 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1084
948
|
throw new Error("Not enough signature");
|
|
1085
949
|
}
|
|
1086
950
|
const sortedSigs = [];
|
|
1087
|
-
const gotSigs = new Map(votes.map((vote) => [
|
|
1088
|
-
vote.userAddress,
|
|
1089
|
-
vote.signature
|
|
1090
|
-
]));
|
|
951
|
+
const gotSigs = new Map(votes.map((vote) => [vote.userAddress, vote.signature]));
|
|
1091
952
|
for (let i = 0; i < this.info.owners.length; i++) {
|
|
1092
953
|
const owner = this.info.owners[i];
|
|
1093
954
|
const signature = gotSigs.get(owner.address);
|
|
@@ -1098,13 +959,8 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1098
959
|
const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
|
|
1099
960
|
return this.suiClient.executeTransaction({
|
|
1100
961
|
transaction: HexToUint8Array(payload),
|
|
1101
|
-
signatures: [
|
|
1102
|
-
|
|
1103
|
-
],
|
|
1104
|
-
include: {
|
|
1105
|
-
effects: true,
|
|
1106
|
-
events: true
|
|
1107
|
-
}
|
|
962
|
+
signatures: [multiSignature],
|
|
963
|
+
include: { effects: true, events: true }
|
|
1108
964
|
});
|
|
1109
965
|
}
|
|
1110
966
|
async dashboard() {
|
|
@@ -1146,15 +1002,11 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
1146
1002
|
import { isSameAddress as isSameAddress3 } from "@msafe/sui3-utils";
|
|
1147
1003
|
import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui/utils";
|
|
1148
1004
|
var PublicKeyHelper = class {
|
|
1149
|
-
static {
|
|
1150
|
-
__name(this, "PublicKeyHelper");
|
|
1151
|
-
}
|
|
1152
|
-
globals;
|
|
1153
|
-
knownPublicKeys;
|
|
1154
1005
|
constructor(globals) {
|
|
1155
1006
|
this.globals = globals;
|
|
1156
1007
|
this.knownPublicKeys = /* @__PURE__ */ new Map();
|
|
1157
1008
|
}
|
|
1009
|
+
knownPublicKeys;
|
|
1158
1010
|
async getPublicKey(address) {
|
|
1159
1011
|
const cached = this.knownPublicKeys.get(address);
|
|
1160
1012
|
if (cached) {
|
|
@@ -1225,10 +1077,6 @@ var PublicKeyHelper = class {
|
|
|
1225
1077
|
|
|
1226
1078
|
// src/core/ReportSDK.ts
|
|
1227
1079
|
var ReportSDK = class {
|
|
1228
|
-
static {
|
|
1229
|
-
__name(this, "ReportSDK");
|
|
1230
|
-
}
|
|
1231
|
-
globals;
|
|
1232
1080
|
constructor(globals) {
|
|
1233
1081
|
this.globals = globals;
|
|
1234
1082
|
}
|
|
@@ -1241,19 +1089,17 @@ var ReportSDK = class {
|
|
|
1241
1089
|
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
1242
1090
|
|
|
1243
1091
|
// src/backend/BackendImpl.ts
|
|
1244
|
-
import {
|
|
1092
|
+
import {
|
|
1093
|
+
PublicKeySerde as PublicKeySerde3,
|
|
1094
|
+
UserMSafeStatus
|
|
1095
|
+
} from "@msafe/sui3-utils";
|
|
1245
1096
|
import axios from "axios";
|
|
1246
1097
|
var BackendImpl = class _BackendImpl {
|
|
1247
|
-
static {
|
|
1248
|
-
__name(this, "BackendImpl");
|
|
1249
|
-
}
|
|
1250
|
-
apiURL;
|
|
1251
|
-
mockAddress;
|
|
1252
|
-
_token;
|
|
1253
1098
|
constructor(apiURL, mockAddress) {
|
|
1254
1099
|
this.apiURL = apiURL;
|
|
1255
1100
|
this.mockAddress = mockAddress;
|
|
1256
1101
|
}
|
|
1102
|
+
_token;
|
|
1257
1103
|
getNotificationInfo() {
|
|
1258
1104
|
return this.get(`/notification`, {
|
|
1259
1105
|
headers: this.headers()
|
|
@@ -1276,9 +1122,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1276
1122
|
}
|
|
1277
1123
|
async verifyToken(jwt) {
|
|
1278
1124
|
try {
|
|
1279
|
-
const res = await this.get(`/auth`, {
|
|
1280
|
-
headers: this.headers(jwt)
|
|
1281
|
-
});
|
|
1125
|
+
const res = await this.get(`/auth`, { headers: this.headers(jwt) });
|
|
1282
1126
|
return res.status === 200;
|
|
1283
1127
|
} catch (_) {
|
|
1284
1128
|
return false;
|
|
@@ -1288,9 +1132,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1288
1132
|
this._token = token;
|
|
1289
1133
|
}
|
|
1290
1134
|
async getPublicKey(address) {
|
|
1291
|
-
return (await this.getPublicKeyBatch([
|
|
1292
|
-
address
|
|
1293
|
-
]))[0];
|
|
1135
|
+
return (await this.getPublicKeyBatch([address]))[0];
|
|
1294
1136
|
}
|
|
1295
1137
|
async getPublicKeyBatch(addresses) {
|
|
1296
1138
|
const query = {
|
|
@@ -1300,7 +1142,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1300
1142
|
params: query,
|
|
1301
1143
|
headers: this.headers()
|
|
1302
1144
|
});
|
|
1303
|
-
return res.data?.map(
|
|
1145
|
+
return res.data?.map(
|
|
1146
|
+
(publicKeyWithSchema) => publicKeyWithSchema ? PublicKeySerde3.de(publicKeyWithSchema) : void 0
|
|
1147
|
+
);
|
|
1304
1148
|
}
|
|
1305
1149
|
async getMSafeAccountInfo(msafeAddress) {
|
|
1306
1150
|
const q = {
|
|
@@ -1337,9 +1181,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1337
1181
|
}
|
|
1338
1182
|
async updateMSafeStatus(input) {
|
|
1339
1183
|
const p = input;
|
|
1340
|
-
await this.post(`/msafe/status`, p, {
|
|
1341
|
-
headers: this.headers()
|
|
1342
|
-
});
|
|
1184
|
+
await this.post(`/msafe/status`, p, { headers: this.headers() });
|
|
1343
1185
|
}
|
|
1344
1186
|
async getPendingTransactions(input) {
|
|
1345
1187
|
const res = await this.get(`/transaction/pending`, {
|
|
@@ -1393,18 +1235,16 @@ var BackendImpl = class _BackendImpl {
|
|
|
1393
1235
|
});
|
|
1394
1236
|
}
|
|
1395
1237
|
async proposeIntention(input) {
|
|
1396
|
-
await this.post(`/transaction/intention`, input, {
|
|
1397
|
-
headers: this.headers()
|
|
1398
|
-
});
|
|
1238
|
+
await this.post(`/transaction/intention`, input, { headers: this.headers() });
|
|
1399
1239
|
}
|
|
1400
1240
|
async rejectCurrentTx(input) {
|
|
1401
|
-
await this.post(
|
|
1402
|
-
|
|
1403
|
-
gasPrice: input.gasPrice.toString(),
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1241
|
+
await this.post(
|
|
1242
|
+
`/transaction/pending/reject`,
|
|
1243
|
+
{ ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
|
|
1244
|
+
{
|
|
1245
|
+
headers: this.headers()
|
|
1246
|
+
}
|
|
1247
|
+
);
|
|
1408
1248
|
}
|
|
1409
1249
|
async voteForTransaction(input) {
|
|
1410
1250
|
await this.post(`/transaction/pending/vote`, input, {
|
|
@@ -1412,32 +1252,24 @@ var BackendImpl = class _BackendImpl {
|
|
|
1412
1252
|
});
|
|
1413
1253
|
}
|
|
1414
1254
|
async buildNextIntentionAndAddToPending(input) {
|
|
1415
|
-
await this.post(
|
|
1416
|
-
|
|
1417
|
-
gasPrice: input.gasPrice.toString(),
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
headers: this.headers()
|
|
1421
|
-
});
|
|
1255
|
+
await this.post(
|
|
1256
|
+
`/transaction/pending/build`,
|
|
1257
|
+
{ ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
|
|
1258
|
+
{ headers: this.headers() }
|
|
1259
|
+
);
|
|
1422
1260
|
}
|
|
1423
1261
|
async proposeIntentionAndBuildVote(input) {
|
|
1424
|
-
await this.post(
|
|
1425
|
-
|
|
1426
|
-
gasPrice: input.gasPrice.toString(),
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
headers: this.headers()
|
|
1430
|
-
});
|
|
1262
|
+
await this.post(
|
|
1263
|
+
`/transaction/intention/build`,
|
|
1264
|
+
{ ...input, gasPrice: input.gasPrice.toString(), gasBudget: input.gasBudget.toString() },
|
|
1265
|
+
{ headers: this.headers() }
|
|
1266
|
+
);
|
|
1431
1267
|
}
|
|
1432
1268
|
async skipNextFailedIntention(input) {
|
|
1433
|
-
await this.post(`/transaction/pending/skip`, input, {
|
|
1434
|
-
headers: this.headers()
|
|
1435
|
-
});
|
|
1269
|
+
await this.post(`/transaction/pending/skip`, input, { headers: this.headers() });
|
|
1436
1270
|
}
|
|
1437
1271
|
async fetchTransaction(input) {
|
|
1438
|
-
const res = await this.post(`/transaction/fetch`, input, {
|
|
1439
|
-
headers: this.headers()
|
|
1440
|
-
});
|
|
1272
|
+
const res = await this.post(`/transaction/fetch`, input, { headers: this.headers() });
|
|
1441
1273
|
return res.data;
|
|
1442
1274
|
}
|
|
1443
1275
|
async getAddressBookEntries(pagination) {
|
|
@@ -1448,22 +1280,14 @@ var BackendImpl = class _BackendImpl {
|
|
|
1448
1280
|
return res.data;
|
|
1449
1281
|
}
|
|
1450
1282
|
async updateAddressBook(input) {
|
|
1451
|
-
await this.post(`/address-book`, input, {
|
|
1452
|
-
headers: this.headers()
|
|
1453
|
-
});
|
|
1283
|
+
await this.post(`/address-book`, input, { headers: this.headers() });
|
|
1454
1284
|
}
|
|
1455
1285
|
async getAddressBookMode() {
|
|
1456
|
-
const res = await this.get("/address-book/mode", {
|
|
1457
|
-
headers: this.headers()
|
|
1458
|
-
});
|
|
1286
|
+
const res = await this.get("/address-book/mode", { headers: this.headers() });
|
|
1459
1287
|
return res.data;
|
|
1460
1288
|
}
|
|
1461
1289
|
async setAddressBookMode(input) {
|
|
1462
|
-
await this.post("/address-book/mode", {
|
|
1463
|
-
mode: input.mode
|
|
1464
|
-
}, {
|
|
1465
|
-
headers: this.headers()
|
|
1466
|
-
});
|
|
1290
|
+
await this.post("/address-book/mode", { mode: input.mode }, { headers: this.headers() });
|
|
1467
1291
|
}
|
|
1468
1292
|
async submitReport(report) {
|
|
1469
1293
|
await this.post("/report", report);
|
|
@@ -1476,10 +1300,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1476
1300
|
return res.data;
|
|
1477
1301
|
}
|
|
1478
1302
|
headers(token) {
|
|
1479
|
-
return {
|
|
1480
|
-
Authorization: `Bearer ${token || this._token}`,
|
|
1481
|
-
"sui-mock-user": this.mockAddress
|
|
1482
|
-
};
|
|
1303
|
+
return { Authorization: `Bearer ${token || this._token}`, "sui-mock-user": this.mockAddress };
|
|
1483
1304
|
}
|
|
1484
1305
|
static toMSafeConfig(resp) {
|
|
1485
1306
|
return {
|
|
@@ -1535,9 +1356,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1535
1356
|
} else if (transformRequest instanceof Array) {
|
|
1536
1357
|
transformRequests = transformRequest;
|
|
1537
1358
|
} else {
|
|
1538
|
-
transformRequests = [
|
|
1539
|
-
transformRequest
|
|
1540
|
-
];
|
|
1359
|
+
transformRequests = [transformRequest];
|
|
1541
1360
|
}
|
|
1542
1361
|
return [
|
|
1543
1362
|
(d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
|
|
@@ -1546,10 +1365,6 @@ var BackendImpl = class _BackendImpl {
|
|
|
1546
1365
|
}
|
|
1547
1366
|
};
|
|
1548
1367
|
var BackendError = class _BackendError extends Error {
|
|
1549
|
-
static {
|
|
1550
|
-
__name(this, "BackendError");
|
|
1551
|
-
}
|
|
1552
|
-
e;
|
|
1553
1368
|
constructor(e) {
|
|
1554
1369
|
super();
|
|
1555
1370
|
this.e = e;
|
|
@@ -1586,15 +1401,14 @@ var BackendError = class _BackendError extends Error {
|
|
|
1586
1401
|
function msafeChainToSuiNetwork(chain) {
|
|
1587
1402
|
return chain === "sui:mainnet" ? "mainnet" : "testnet";
|
|
1588
1403
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
})(MSafeEnv || (MSafeEnv = {}));
|
|
1404
|
+
var MSafeEnv = /* @__PURE__ */ ((MSafeEnv3) => {
|
|
1405
|
+
MSafeEnv3["local"] = "local";
|
|
1406
|
+
MSafeEnv3["unit"] = "unit";
|
|
1407
|
+
MSafeEnv3["dev"] = "dev";
|
|
1408
|
+
MSafeEnv3["prev"] = "prev";
|
|
1409
|
+
MSafeEnv3["prod"] = "prod";
|
|
1410
|
+
return MSafeEnv3;
|
|
1411
|
+
})(MSafeEnv || {});
|
|
1598
1412
|
function httpUrlToGrpcBaseUrl(url) {
|
|
1599
1413
|
const parsed = new URL(url);
|
|
1600
1414
|
if (parsed.protocol === "https:" && parsed.port === "") {
|
|
@@ -1605,7 +1419,6 @@ function httpUrlToGrpcBaseUrl(url) {
|
|
|
1605
1419
|
}
|
|
1606
1420
|
return `${parsed.origin}${parsed.pathname}${parsed.search}`;
|
|
1607
1421
|
}
|
|
1608
|
-
__name(httpUrlToGrpcBaseUrl, "httpUrlToGrpcBaseUrl");
|
|
1609
1422
|
var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
|
|
1610
1423
|
var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
|
|
1611
1424
|
var LOCAL_API_URL = "http://127.0.0.1:3000";
|
|
@@ -1616,7 +1429,7 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
|
|
|
1616
1429
|
var PROD_API_URL = "https://sui.m-safe.link";
|
|
1617
1430
|
var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
1618
1431
|
[
|
|
1619
|
-
"unit"
|
|
1432
|
+
"unit" /* unit */,
|
|
1620
1433
|
{
|
|
1621
1434
|
suiClient: {
|
|
1622
1435
|
url: TESTNET_RPC_URL
|
|
@@ -1629,7 +1442,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1629
1442
|
}
|
|
1630
1443
|
],
|
|
1631
1444
|
[
|
|
1632
|
-
"local"
|
|
1445
|
+
"local" /* local */,
|
|
1633
1446
|
{
|
|
1634
1447
|
suiClient: {
|
|
1635
1448
|
url: TESTNET_RPC_URL
|
|
@@ -1642,7 +1455,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1642
1455
|
}
|
|
1643
1456
|
],
|
|
1644
1457
|
[
|
|
1645
|
-
"dev"
|
|
1458
|
+
"dev" /* dev */,
|
|
1646
1459
|
{
|
|
1647
1460
|
suiClient: {
|
|
1648
1461
|
url: TESTNET_RPC_URL
|
|
@@ -1655,7 +1468,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1655
1468
|
}
|
|
1656
1469
|
],
|
|
1657
1470
|
[
|
|
1658
|
-
"prev"
|
|
1471
|
+
"prev" /* prev */,
|
|
1659
1472
|
{
|
|
1660
1473
|
suiClient: {
|
|
1661
1474
|
url: MAINNET_RPC_URL
|
|
@@ -1668,7 +1481,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1668
1481
|
}
|
|
1669
1482
|
],
|
|
1670
1483
|
[
|
|
1671
|
-
"prod"
|
|
1484
|
+
"prod" /* prod */,
|
|
1672
1485
|
{
|
|
1673
1486
|
suiClient: {
|
|
1674
1487
|
url: MAINNET_RPC_URL
|
|
@@ -1697,13 +1510,9 @@ function getMSafeConfig(env, options) {
|
|
|
1697
1510
|
}
|
|
1698
1511
|
return config;
|
|
1699
1512
|
}
|
|
1700
|
-
__name(getMSafeConfig, "getMSafeConfig");
|
|
1701
1513
|
|
|
1702
1514
|
// src/globals/MSafeGlobals.ts
|
|
1703
1515
|
var MSafeGlobals = class _MSafeGlobals {
|
|
1704
|
-
static {
|
|
1705
|
-
__name(this, "MSafeGlobals");
|
|
1706
|
-
}
|
|
1707
1516
|
backend;
|
|
1708
1517
|
suiClient;
|
|
1709
1518
|
config;
|
|
@@ -1745,15 +1554,11 @@ var MSafeGlobals = class _MSafeGlobals {
|
|
|
1745
1554
|
|
|
1746
1555
|
// src/core/MSafeClient.ts
|
|
1747
1556
|
var MSafeClient = class _MSafeClient {
|
|
1748
|
-
static {
|
|
1749
|
-
__name(this, "MSafeClient");
|
|
1750
|
-
}
|
|
1751
|
-
globals;
|
|
1752
|
-
_creationHelper;
|
|
1753
|
-
_publicKeyHelper;
|
|
1754
1557
|
constructor(globals) {
|
|
1755
1558
|
this.globals = globals;
|
|
1756
1559
|
}
|
|
1560
|
+
_creationHelper;
|
|
1561
|
+
_publicKeyHelper;
|
|
1757
1562
|
static async New(env, options) {
|
|
1758
1563
|
const globals = await MSafeGlobals.New(env, options);
|
|
1759
1564
|
return new _MSafeClient(globals);
|
|
@@ -1788,10 +1593,7 @@ var MSafeClient = class _MSafeClient {
|
|
|
1788
1593
|
return this.globals.backend.getUserInfo();
|
|
1789
1594
|
}
|
|
1790
1595
|
async ownedMSafe(pagination) {
|
|
1791
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
1792
|
-
status: UserMSafeStatus2.active,
|
|
1793
|
-
pagination
|
|
1794
|
-
});
|
|
1596
|
+
return this.globals.backend.getOwnedMSafeByStatus({ status: UserMSafeStatus2.active, pagination });
|
|
1795
1597
|
}
|
|
1796
1598
|
async createAccount(info) {
|
|
1797
1599
|
return this.creationHelper.submitMSafeCreation(info);
|
|
@@ -1841,38 +1643,26 @@ var MSafeClient = class _MSafeClient {
|
|
|
1841
1643
|
};
|
|
1842
1644
|
|
|
1843
1645
|
// src/backend/types/notification.ts
|
|
1844
|
-
var InfoTypeKey
|
|
1845
|
-
(function(InfoTypeKey2) {
|
|
1646
|
+
var InfoTypeKey = /* @__PURE__ */ ((InfoTypeKey2) => {
|
|
1846
1647
|
InfoTypeKey2["receive"] = "info_type_receive";
|
|
1847
1648
|
InfoTypeKey2["send"] = "info_type_send";
|
|
1848
1649
|
InfoTypeKey2["invitation"] = "info_type_invitation";
|
|
1849
1650
|
InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
|
|
1850
|
-
|
|
1651
|
+
return InfoTypeKey2;
|
|
1652
|
+
})(InfoTypeKey || {});
|
|
1851
1653
|
var NotificationSubscribeDto = class {
|
|
1852
|
-
static {
|
|
1853
|
-
__name(this, "NotificationSubscribeDto");
|
|
1854
|
-
}
|
|
1855
1654
|
email;
|
|
1856
1655
|
};
|
|
1857
1656
|
var NotificationUpdateDto = class {
|
|
1858
|
-
static {
|
|
1859
|
-
__name(this, "NotificationUpdateDto");
|
|
1860
|
-
}
|
|
1861
1657
|
email;
|
|
1862
1658
|
infoTypes;
|
|
1863
1659
|
msafeEnabled;
|
|
1864
1660
|
};
|
|
1865
1661
|
var InfoTypeEnabledDto = class {
|
|
1866
|
-
static {
|
|
1867
|
-
__name(this, "InfoTypeEnabledDto");
|
|
1868
|
-
}
|
|
1869
1662
|
infoType;
|
|
1870
1663
|
enabled;
|
|
1871
1664
|
};
|
|
1872
1665
|
var MSafeEnabledDto = class {
|
|
1873
|
-
static {
|
|
1874
|
-
__name(this, "MSafeEnabledDto");
|
|
1875
|
-
}
|
|
1876
1666
|
msafeAddress;
|
|
1877
1667
|
enabled;
|
|
1878
1668
|
};
|