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