@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.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/core/CreateHelper.ts
|
|
2
|
-
import {
|
|
3
|
-
isSameAddress,
|
|
4
|
-
MultiSigAccount,
|
|
5
|
-
PublicKeySerde,
|
|
6
|
-
SigningMessageHelper
|
|
7
|
-
} from "@msafe/sui3-utils";
|
|
5
|
+
import { isSameAddress, MultiSigAccount, PublicKeySerde, SigningMessageHelper } from "@msafe/sui3-utils";
|
|
8
6
|
var CreateHelper = class {
|
|
7
|
+
static {
|
|
8
|
+
__name(this, "CreateHelper");
|
|
9
|
+
}
|
|
10
|
+
globals;
|
|
11
|
+
pkHelper;
|
|
9
12
|
constructor(globals, pkHelper) {
|
|
10
13
|
this.globals = globals;
|
|
11
14
|
this.pkHelper = pkHelper;
|
|
@@ -23,13 +26,13 @@ var CreateHelper = class {
|
|
|
23
26
|
return this.calculateMSafeAddress(createInfo);
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
* Add user manually added public key for an address. If user input the public key with
|
|
30
|
+
* extra signature scheme flag, the scheme value will be automatically fixed.
|
|
31
|
+
*
|
|
32
|
+
* @param address
|
|
33
|
+
* @param pkEncoded
|
|
34
|
+
* @throws error if the public key does not match
|
|
35
|
+
*/
|
|
33
36
|
addPublicKey(address, pkEncoded) {
|
|
34
37
|
const pk = PublicKeySerde.de(pkEncoded);
|
|
35
38
|
if (!isSameAddress(address, pk.toSuiAddress())) {
|
|
@@ -40,7 +43,9 @@ var CreateHelper = class {
|
|
|
40
43
|
async submitMSafeCreation(creationInfo) {
|
|
41
44
|
const msafeAddress = await this.validateCreateInfo(creationInfo);
|
|
42
45
|
const signingMessage = SigningMessageHelper.createMSafeMessage(msafeAddress);
|
|
43
|
-
const signature = await this.globals.wallet.signPersonalMessage({
|
|
46
|
+
const signature = await this.globals.wallet.signPersonalMessage({
|
|
47
|
+
messageStr: signingMessage
|
|
48
|
+
});
|
|
44
49
|
await this.submitToBackend(creationInfo, signature.signature);
|
|
45
50
|
return msafeAddress;
|
|
46
51
|
}
|
|
@@ -71,9 +76,7 @@ var CreateHelper = class {
|
|
|
71
76
|
})),
|
|
72
77
|
threshold: createInfo.threshold,
|
|
73
78
|
name: createInfo.name,
|
|
74
|
-
// name validation is deferred to backend
|
|
75
79
|
description: createInfo.description,
|
|
76
|
-
// description validation is deferred to backend
|
|
77
80
|
creationNonce: createInfo.creationNonce,
|
|
78
81
|
signature
|
|
79
82
|
});
|
|
@@ -81,14 +84,15 @@ var CreateHelper = class {
|
|
|
81
84
|
};
|
|
82
85
|
|
|
83
86
|
// src/core/MSafeClient.ts
|
|
84
|
-
import {
|
|
85
|
-
SigningMessageHelper as SigningMessageHelper4,
|
|
86
|
-
UserMSafeStatus as UserMSafeStatus2
|
|
87
|
-
} from "@msafe/sui3-utils";
|
|
87
|
+
import { SigningMessageHelper as SigningMessageHelper4, UserMSafeStatus as UserMSafeStatus2 } 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;
|
|
92
96
|
constructor(globals) {
|
|
93
97
|
this.globals = globals;
|
|
94
98
|
}
|
|
@@ -97,42 +101,51 @@ var AddressBookSDK = class {
|
|
|
97
101
|
}
|
|
98
102
|
async update(updates) {
|
|
99
103
|
const messageStr = SigningMessageHelper2.updateAddressBookMessage(updates);
|
|
100
|
-
const sig = await this.globals.wallet.signPersonalMessage({
|
|
101
|
-
|
|
104
|
+
const sig = await this.globals.wallet.signPersonalMessage({
|
|
105
|
+
messageStr
|
|
106
|
+
});
|
|
107
|
+
return this.globals.backend.updateAddressBook({
|
|
108
|
+
updates,
|
|
109
|
+
signature: sig.signature
|
|
110
|
+
});
|
|
102
111
|
}
|
|
103
112
|
async getMode() {
|
|
104
113
|
const res = await this.globals.backend.getAddressBookMode();
|
|
105
114
|
return res.mode;
|
|
106
115
|
}
|
|
107
116
|
async setMode(mode) {
|
|
108
|
-
return this.globals.backend.setAddressBookMode({
|
|
117
|
+
return this.globals.backend.setAddressBookMode({
|
|
118
|
+
mode
|
|
119
|
+
});
|
|
109
120
|
}
|
|
110
121
|
};
|
|
111
122
|
|
|
112
123
|
// src/core/InvitationSDK.ts
|
|
113
124
|
var InvitationSDK = class {
|
|
125
|
+
static {
|
|
126
|
+
__name(this, "InvitationSDK");
|
|
127
|
+
}
|
|
128
|
+
globals;
|
|
114
129
|
constructor(globals) {
|
|
115
130
|
this.globals = globals;
|
|
116
131
|
}
|
|
117
132
|
async getMSafeByStatus(status, pagination) {
|
|
118
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
133
|
+
return this.globals.backend.getOwnedMSafeByStatus({
|
|
134
|
+
status,
|
|
135
|
+
pagination
|
|
136
|
+
});
|
|
119
137
|
}
|
|
120
138
|
async updateMSafeStatus(msafeAddress, status) {
|
|
121
|
-
return this.globals.backend.updateMSafeStatus({
|
|
139
|
+
return this.globals.backend.updateMSafeStatus({
|
|
140
|
+
msafeAddress,
|
|
141
|
+
status
|
|
142
|
+
});
|
|
122
143
|
}
|
|
123
144
|
};
|
|
124
145
|
|
|
125
146
|
// src/core/MSafeAccount.ts
|
|
126
147
|
import { appHelpers } from "@msafe/sui-app-store";
|
|
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";
|
|
148
|
+
import { MultiSigAccount as MultiSigAccount2, SigningMessageHelper as SigningMessageHelper3, TransactionDefaultApplication, TransactionSubTypes, TransactionType, buildRejectTxb, isSameAddress as isSameAddress2 } from "@msafe/sui3-utils";
|
|
136
149
|
import { Transaction as Transaction3 } from "@mysten/sui/transactions";
|
|
137
150
|
import { fromHex, normalizeStructTag as normalizeStructTag3, toHex } from "@mysten/sui/utils";
|
|
138
151
|
import { SUI_MAINNET_CHAIN, SUI_TESTNET_CHAIN } from "@mysten/wallet-standard";
|
|
@@ -143,15 +156,25 @@ var GAS_SAFE_OVERHEAD = 1000n;
|
|
|
143
156
|
function formatExecutionError(error) {
|
|
144
157
|
return error.message;
|
|
145
158
|
}
|
|
159
|
+
__name(formatExecutionError, "formatExecutionError");
|
|
146
160
|
function gasObjectToReference(gas) {
|
|
147
161
|
if (!gas?.objectId) {
|
|
148
162
|
throw new Error("Gas object missing from simulation effects");
|
|
149
163
|
}
|
|
150
164
|
const version = gas.outputVersion ?? gas.inputVersion ?? "0";
|
|
151
165
|
const digest = gas.outputDigest ?? gas.inputDigest ?? "";
|
|
152
|
-
return {
|
|
166
|
+
return {
|
|
167
|
+
objectId: gas.objectId,
|
|
168
|
+
version,
|
|
169
|
+
digest
|
|
170
|
+
};
|
|
153
171
|
}
|
|
172
|
+
__name(gasObjectToReference, "gasObjectToReference");
|
|
154
173
|
var Simulator = class {
|
|
174
|
+
static {
|
|
175
|
+
__name(this, "Simulator");
|
|
176
|
+
}
|
|
177
|
+
globals;
|
|
155
178
|
constructor(globals) {
|
|
156
179
|
this.globals = globals;
|
|
157
180
|
}
|
|
@@ -162,7 +185,9 @@ var Simulator = class {
|
|
|
162
185
|
tx.setGasPrice(gasPrice);
|
|
163
186
|
let built;
|
|
164
187
|
try {
|
|
165
|
-
built = await tx.build({
|
|
188
|
+
built = await tx.build({
|
|
189
|
+
client: suiClient
|
|
190
|
+
});
|
|
166
191
|
} catch (e) {
|
|
167
192
|
const message = e instanceof Error ? e.message : String(e);
|
|
168
193
|
return {
|
|
@@ -175,7 +200,9 @@ var Simulator = class {
|
|
|
175
200
|
try {
|
|
176
201
|
inspectResult = await suiClient.simulateTransaction({
|
|
177
202
|
transaction: built,
|
|
178
|
-
include: {
|
|
203
|
+
include: {
|
|
204
|
+
effects: true
|
|
205
|
+
}
|
|
179
206
|
});
|
|
180
207
|
} catch (e) {
|
|
181
208
|
const message = e instanceof Error ? e.message : String(e);
|
|
@@ -227,16 +254,19 @@ var Simulator = class {
|
|
|
227
254
|
};
|
|
228
255
|
|
|
229
256
|
// src/utils/buffer.ts
|
|
230
|
-
import { Buffer } from "buffer";
|
|
257
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
231
258
|
function stringToBuffer(s) {
|
|
232
|
-
return
|
|
259
|
+
return Buffer2.from(s, "utf-8");
|
|
233
260
|
}
|
|
261
|
+
__name(stringToBuffer, "stringToBuffer");
|
|
234
262
|
function Uint8ArrayToHex(b) {
|
|
235
263
|
return `0x${Array.prototype.map.call(b, (x) => `0${x.toString(16)}`.slice(-2)).join("")}`;
|
|
236
264
|
}
|
|
265
|
+
__name(Uint8ArrayToHex, "Uint8ArrayToHex");
|
|
237
266
|
function HexToUint8Array(hex) {
|
|
238
|
-
return Uint8Array.from(
|
|
267
|
+
return Uint8Array.from(Buffer2.from(hex.startsWith("0x") ? hex.slice(2) : hex, "hex"));
|
|
239
268
|
}
|
|
269
|
+
__name(HexToUint8Array, "HexToUint8Array");
|
|
240
270
|
|
|
241
271
|
// src/utils/crypto.ts
|
|
242
272
|
import { verifyPersonalMessageSignature, verifyTransactionSignature } from "@mysten/sui/verify";
|
|
@@ -247,6 +277,9 @@ import { normalizeSuiAddress, normalizeStructTag as normalizeStructTag2 } from "
|
|
|
247
277
|
// src/utils/coin.ts
|
|
248
278
|
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
249
279
|
var CoinHelper = class {
|
|
280
|
+
static {
|
|
281
|
+
__name(this, "CoinHelper");
|
|
282
|
+
}
|
|
250
283
|
_client;
|
|
251
284
|
_coinMetaReg;
|
|
252
285
|
constructor(client) {
|
|
@@ -265,12 +298,17 @@ var CoinHelper = class {
|
|
|
265
298
|
return meta;
|
|
266
299
|
}
|
|
267
300
|
async queryCoinMeta(coinType) {
|
|
268
|
-
const res = await this._client.getCoinMetadata({
|
|
301
|
+
const res = await this._client.getCoinMetadata({
|
|
302
|
+
coinType
|
|
303
|
+
});
|
|
269
304
|
return res.coinMetadata ?? void 0;
|
|
270
305
|
}
|
|
271
306
|
};
|
|
272
307
|
var COIN_TYPE_ARG_REGEX = /^0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<(.+)>$/;
|
|
273
308
|
var Coin = class _Coin {
|
|
309
|
+
static {
|
|
310
|
+
__name(this, "Coin");
|
|
311
|
+
}
|
|
274
312
|
static isCoin(type) {
|
|
275
313
|
if (!type) {
|
|
276
314
|
return false;
|
|
@@ -305,6 +343,9 @@ var Coin = class _Coin {
|
|
|
305
343
|
|
|
306
344
|
// src/utils/format.ts
|
|
307
345
|
var Formatter = class {
|
|
346
|
+
static {
|
|
347
|
+
__name(this, "Formatter");
|
|
348
|
+
}
|
|
308
349
|
static normalizeSuiAddress(addr) {
|
|
309
350
|
return normalizeSuiAddress(addr);
|
|
310
351
|
}
|
|
@@ -327,9 +368,13 @@ function addPrefix(s, prefix) {
|
|
|
327
368
|
}
|
|
328
369
|
return prefix + s;
|
|
329
370
|
}
|
|
371
|
+
__name(addPrefix, "addPrefix");
|
|
330
372
|
|
|
331
373
|
// src/utils/crypto.ts
|
|
332
374
|
var SignatureVerifier = class _SignatureVerifier {
|
|
375
|
+
static {
|
|
376
|
+
__name(this, "SignatureVerifier");
|
|
377
|
+
}
|
|
333
378
|
static async getPublicKeyFromSignature(input) {
|
|
334
379
|
if (input.messageType === "TransactionBlock") {
|
|
335
380
|
return verifyTransactionSignature(input.message, input.signature);
|
|
@@ -380,24 +425,35 @@ var GRAPHQL_URL_BY_NETWORK = {
|
|
|
380
425
|
};
|
|
381
426
|
function graphqlClientForGrpc(suiClient) {
|
|
382
427
|
const url = GRAPHQL_URL_BY_NETWORK[suiClient.network] ?? GRAPHQL_URL_BY_NETWORK.testnet;
|
|
383
|
-
return new SuiGraphQLClient({
|
|
428
|
+
return new SuiGraphQLClient({
|
|
429
|
+
url,
|
|
430
|
+
network: suiClient.network
|
|
431
|
+
});
|
|
384
432
|
}
|
|
433
|
+
__name(graphqlClientForGrpc, "graphqlClientForGrpc");
|
|
385
434
|
function collectSignatureStrings(value) {
|
|
386
435
|
if (typeof value === "string") {
|
|
387
|
-
return [
|
|
436
|
+
return [
|
|
437
|
+
value
|
|
438
|
+
];
|
|
388
439
|
}
|
|
389
440
|
if (!value || typeof value !== "object") {
|
|
390
441
|
return [];
|
|
391
442
|
}
|
|
392
443
|
if ("base64" in value && typeof value.base64 === "string") {
|
|
393
|
-
return [
|
|
444
|
+
return [
|
|
445
|
+
value.base64
|
|
446
|
+
];
|
|
394
447
|
}
|
|
395
448
|
if ("scheme" in value && "base64" in value) {
|
|
396
449
|
const b64 = value.base64;
|
|
397
|
-
return typeof b64 === "string" ? [
|
|
450
|
+
return typeof b64 === "string" ? [
|
|
451
|
+
b64
|
|
452
|
+
] : [];
|
|
398
453
|
}
|
|
399
454
|
return [];
|
|
400
455
|
}
|
|
456
|
+
__name(collectSignatureStrings, "collectSignatureStrings");
|
|
401
457
|
var TX_SIG_QUERY = `
|
|
402
458
|
query PublicKeyTxSigs($sender: SuiAddress!, $first: Int!) {
|
|
403
459
|
transactions(first: $first, filter: { sentAddress: $sender }) {
|
|
@@ -413,7 +469,10 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
413
469
|
try {
|
|
414
470
|
const res = await graphql.query({
|
|
415
471
|
query: TX_SIG_QUERY,
|
|
416
|
-
variables: {
|
|
472
|
+
variables: {
|
|
473
|
+
sender: address,
|
|
474
|
+
first: 2
|
|
475
|
+
}
|
|
417
476
|
});
|
|
418
477
|
if (res.errors?.length) {
|
|
419
478
|
return void 0;
|
|
@@ -442,6 +501,7 @@ async function getPublicKeyFromChain(suiClient, address) {
|
|
|
442
501
|
}
|
|
443
502
|
return void 0;
|
|
444
503
|
}
|
|
504
|
+
__name(getPublicKeyFromChain, "getPublicKeyFromChain");
|
|
445
505
|
function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
446
506
|
const decoded = parseSerializedSignature(serializedSig);
|
|
447
507
|
switch (decoded.signatureScheme) {
|
|
@@ -456,7 +516,10 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
456
516
|
case "ED25519":
|
|
457
517
|
case "Secp256k1":
|
|
458
518
|
case "Secp256r1": {
|
|
459
|
-
const pk = PublicKeySerde2.de({
|
|
519
|
+
const pk = PublicKeySerde2.de({
|
|
520
|
+
publicKeyEncoded: decoded.publicKey,
|
|
521
|
+
schema: decoded.signatureScheme
|
|
522
|
+
});
|
|
460
523
|
if (Formatter.isSuiAddressEqual(pk.toSuiAddress(), targetAddress)) {
|
|
461
524
|
return pk;
|
|
462
525
|
}
|
|
@@ -466,6 +529,7 @@ function getAddressFromSignatures(serializedSig, targetAddress) {
|
|
|
466
529
|
throw new Error("Unknown schema");
|
|
467
530
|
}
|
|
468
531
|
}
|
|
532
|
+
__name(getAddressFromSignatures, "getAddressFromSignatures");
|
|
469
533
|
async function getAllCoins(input) {
|
|
470
534
|
let hasNext = true;
|
|
471
535
|
let cursor;
|
|
@@ -482,6 +546,7 @@ async function getAllCoins(input) {
|
|
|
482
546
|
}
|
|
483
547
|
return res;
|
|
484
548
|
}
|
|
549
|
+
__name(getAllCoins, "getAllCoins");
|
|
485
550
|
|
|
486
551
|
// src/utils/transaction.ts
|
|
487
552
|
import { Transaction as Transaction2, isTransaction } from "@mysten/sui/transactions";
|
|
@@ -492,6 +557,7 @@ function toSuiTransaction(txb) {
|
|
|
492
557
|
const legacy = txb;
|
|
493
558
|
return Transaction2.from(legacy.serialize());
|
|
494
559
|
}
|
|
560
|
+
__name(toSuiTransaction, "toSuiTransaction");
|
|
495
561
|
|
|
496
562
|
// src/utils/iter/iterator.ts
|
|
497
563
|
var REQUEST_PAGE_SIZE = 25;
|
|
@@ -506,14 +572,19 @@ async function getAllFromIterator(it) {
|
|
|
506
572
|
}
|
|
507
573
|
return res;
|
|
508
574
|
}
|
|
575
|
+
__name(getAllFromIterator, "getAllFromIterator");
|
|
509
576
|
var PagedIterator = class {
|
|
577
|
+
static {
|
|
578
|
+
__name(this, "PagedIterator");
|
|
579
|
+
}
|
|
580
|
+
requester;
|
|
581
|
+
curPage;
|
|
582
|
+
init;
|
|
510
583
|
constructor(requester) {
|
|
511
584
|
this.requester = requester;
|
|
512
585
|
this.curPage = void 0;
|
|
513
586
|
this.init = true;
|
|
514
587
|
}
|
|
515
|
-
curPage;
|
|
516
|
-
init;
|
|
517
588
|
async hasNext() {
|
|
518
589
|
if (this.init) {
|
|
519
590
|
if (!this.curPage) {
|
|
@@ -539,15 +610,19 @@ var PagedIterator = class {
|
|
|
539
610
|
}
|
|
540
611
|
};
|
|
541
612
|
var EntryIterator = class {
|
|
613
|
+
static {
|
|
614
|
+
__name(this, "EntryIterator");
|
|
615
|
+
}
|
|
616
|
+
requester;
|
|
617
|
+
cursor;
|
|
618
|
+
pager;
|
|
619
|
+
curData;
|
|
542
620
|
constructor(requester) {
|
|
543
621
|
this.requester = requester;
|
|
544
622
|
this.pager = new PagedIterator(requester);
|
|
545
623
|
this.curData = [];
|
|
546
624
|
this.cursor = 0;
|
|
547
625
|
}
|
|
548
|
-
cursor;
|
|
549
|
-
pager;
|
|
550
|
-
curData;
|
|
551
626
|
async hasNext() {
|
|
552
627
|
if (this.cursor < this.curData.length - 1) {
|
|
553
628
|
return true;
|
|
@@ -569,15 +644,28 @@ var EntryIterator = class {
|
|
|
569
644
|
};
|
|
570
645
|
|
|
571
646
|
// src/utils/iter/object.ts
|
|
572
|
-
var defaultObjectInclude = {
|
|
647
|
+
var defaultObjectInclude = {
|
|
648
|
+
json: true
|
|
649
|
+
};
|
|
573
650
|
function mergeInclude(options) {
|
|
574
|
-
return {
|
|
651
|
+
return {
|
|
652
|
+
...defaultObjectInclude,
|
|
653
|
+
...options?.objectInclude
|
|
654
|
+
};
|
|
575
655
|
}
|
|
656
|
+
__name(mergeInclude, "mergeInclude");
|
|
576
657
|
async function getAllOwnedObjects(provider, owner, options) {
|
|
577
658
|
const iter = new OwnedObjectIterator(provider, owner, options);
|
|
578
659
|
return await getAllFromIterator(iter);
|
|
579
660
|
}
|
|
661
|
+
__name(getAllOwnedObjects, "getAllOwnedObjects");
|
|
580
662
|
var OwnedObjectIterator = class extends EntryIterator {
|
|
663
|
+
static {
|
|
664
|
+
__name(this, "OwnedObjectIterator");
|
|
665
|
+
}
|
|
666
|
+
provider;
|
|
667
|
+
owner;
|
|
668
|
+
options;
|
|
581
669
|
constructor(provider, owner, options) {
|
|
582
670
|
super(new OwnedObjectRequester(provider, owner, options));
|
|
583
671
|
this.provider = provider;
|
|
@@ -586,6 +674,16 @@ var OwnedObjectIterator = class extends EntryIterator {
|
|
|
586
674
|
}
|
|
587
675
|
};
|
|
588
676
|
var OwnedObjectRequester = class {
|
|
677
|
+
static {
|
|
678
|
+
__name(this, "OwnedObjectRequester");
|
|
679
|
+
}
|
|
680
|
+
provider;
|
|
681
|
+
owner;
|
|
682
|
+
options;
|
|
683
|
+
nextCursor;
|
|
684
|
+
filter;
|
|
685
|
+
pageSize;
|
|
686
|
+
objectInclude;
|
|
589
687
|
constructor(provider, owner, options) {
|
|
590
688
|
this.provider = provider;
|
|
591
689
|
this.owner = owner;
|
|
@@ -595,10 +693,6 @@ var OwnedObjectRequester = class {
|
|
|
595
693
|
this.pageSize = options?.pageSize || REQUEST_PAGE_SIZE;
|
|
596
694
|
this.objectInclude = mergeInclude(options);
|
|
597
695
|
}
|
|
598
|
-
nextCursor;
|
|
599
|
-
filter;
|
|
600
|
-
pageSize;
|
|
601
|
-
objectInclude;
|
|
602
696
|
async doNextRequest() {
|
|
603
697
|
const res = await this.provider.listOwnedObjects({
|
|
604
698
|
owner: this.owner,
|
|
@@ -623,6 +717,14 @@ var OwnedObjectRequester = class {
|
|
|
623
717
|
|
|
624
718
|
// src/core/MSafeAccount.ts
|
|
625
719
|
var MSafeAccount = class _MSafeAccount {
|
|
720
|
+
static {
|
|
721
|
+
__name(this, "MSafeAccount");
|
|
722
|
+
}
|
|
723
|
+
globals;
|
|
724
|
+
info;
|
|
725
|
+
multiSig;
|
|
726
|
+
simulator;
|
|
727
|
+
coinHelper;
|
|
626
728
|
constructor(globals, info) {
|
|
627
729
|
this.globals = globals;
|
|
628
730
|
this.info = info;
|
|
@@ -634,9 +736,6 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
634
736
|
this.coinHelper = new CoinHelper(this.suiClient);
|
|
635
737
|
this.simulator = new Simulator(globals);
|
|
636
738
|
}
|
|
637
|
-
multiSig;
|
|
638
|
-
simulator;
|
|
639
|
-
coinHelper;
|
|
640
739
|
static async New(globals, address) {
|
|
641
740
|
const info = await globals.backend.getMSafeAccountInfo(address);
|
|
642
741
|
const ms = new _MSafeAccount(globals, info);
|
|
@@ -649,21 +748,23 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
649
748
|
let cursor = null;
|
|
650
749
|
let hasNext = true;
|
|
651
750
|
while (hasNext) {
|
|
652
|
-
const page = await this.suiClient.listBalances({
|
|
751
|
+
const page = await this.suiClient.listBalances({
|
|
752
|
+
owner: this.address,
|
|
753
|
+
cursor,
|
|
754
|
+
limit: 50
|
|
755
|
+
});
|
|
653
756
|
balances.push(...page.balances);
|
|
654
757
|
hasNext = page.hasNextPage;
|
|
655
758
|
cursor = page.cursor;
|
|
656
759
|
}
|
|
657
|
-
return Promise.all(
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
})
|
|
666
|
-
);
|
|
760
|
+
return Promise.all(balances.map(async (balance) => {
|
|
761
|
+
const meta = await this.coinHelper.getCoinMeta(balance.coinType);
|
|
762
|
+
return {
|
|
763
|
+
type: normalizeStructTag3(balance.coinType),
|
|
764
|
+
balance: BigInt(balance.addressBalance),
|
|
765
|
+
metadata: meta
|
|
766
|
+
};
|
|
767
|
+
}));
|
|
667
768
|
}
|
|
668
769
|
async ownedObjects(options) {
|
|
669
770
|
const filterCoinObjectOptions = {
|
|
@@ -673,7 +774,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
673
774
|
return getAllOwnedObjects(this.suiClient, this.address, filterCoinObjectOptions);
|
|
674
775
|
}
|
|
675
776
|
async pendingTransaction() {
|
|
676
|
-
const res = await this.backend.getPendingTransactions({
|
|
777
|
+
const res = await this.backend.getPendingTransactions({
|
|
778
|
+
msafeAddress: this.address
|
|
779
|
+
});
|
|
677
780
|
if (!res?.pending) {
|
|
678
781
|
return void 0;
|
|
679
782
|
}
|
|
@@ -705,7 +808,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
705
808
|
});
|
|
706
809
|
}
|
|
707
810
|
async futureIntentions(pagination) {
|
|
708
|
-
return this.backend.getFutureIntentions({
|
|
811
|
+
return this.backend.getFutureIntentions({
|
|
812
|
+
msafeAddress: this.address,
|
|
813
|
+
...pagination
|
|
814
|
+
});
|
|
709
815
|
}
|
|
710
816
|
async currentSequenceNumber() {
|
|
711
817
|
return this.backend.getCurrentSequenceNumber(this.address);
|
|
@@ -722,24 +828,28 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
722
828
|
if (!appHelper) {
|
|
723
829
|
throw new Error(`Can't find app helper for application ${request.application}`);
|
|
724
830
|
}
|
|
725
|
-
txb = toSuiTransaction(
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
831
|
+
txb = toSuiTransaction(await appHelper.build({
|
|
832
|
+
network: this.globals.config.network,
|
|
833
|
+
intentionData: request.intention,
|
|
834
|
+
txType: request.txType,
|
|
835
|
+
txSubType: request.txSubType,
|
|
836
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
837
|
+
account: {
|
|
838
|
+
address: this.address,
|
|
839
|
+
publicKey: fromHex(this.address),
|
|
840
|
+
chains: [
|
|
841
|
+
SUI_MAINNET_CHAIN,
|
|
842
|
+
SUI_TESTNET_CHAIN
|
|
843
|
+
],
|
|
844
|
+
features: []
|
|
845
|
+
}
|
|
846
|
+
}));
|
|
740
847
|
}
|
|
741
848
|
txb.setSender(this.address);
|
|
742
|
-
return this.simulator.simulate({
|
|
849
|
+
return this.simulator.simulate({
|
|
850
|
+
txb,
|
|
851
|
+
sender: this.address
|
|
852
|
+
});
|
|
743
853
|
}
|
|
744
854
|
async proposeIntention(input) {
|
|
745
855
|
const message = SigningMessageHelper3.proposeIntentionMessage({
|
|
@@ -765,28 +875,35 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
765
875
|
if (!appHelper) {
|
|
766
876
|
throw new Error(`Can't find app helper for application ${input.application}`);
|
|
767
877
|
}
|
|
768
|
-
txb = toSuiTransaction(
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
878
|
+
txb = toSuiTransaction(await appHelper.build({
|
|
879
|
+
network: this.globals.config.network,
|
|
880
|
+
intentionData: input.intention,
|
|
881
|
+
txType: input.txType,
|
|
882
|
+
txSubType: input.txSubType,
|
|
883
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
884
|
+
account: {
|
|
885
|
+
address: this.address,
|
|
886
|
+
publicKey: fromHex(this.address),
|
|
887
|
+
chains: [
|
|
888
|
+
SUI_MAINNET_CHAIN,
|
|
889
|
+
SUI_TESTNET_CHAIN
|
|
890
|
+
],
|
|
891
|
+
features: []
|
|
892
|
+
}
|
|
893
|
+
}));
|
|
783
894
|
}
|
|
784
895
|
txb.setGasPrice(input.gasPrice);
|
|
785
896
|
txb.setGasBudget(input.gasBudget);
|
|
786
897
|
txb.setSender(this.address);
|
|
787
|
-
const payload = await txb.build({
|
|
788
|
-
|
|
789
|
-
|
|
898
|
+
const payload = await txb.build({
|
|
899
|
+
client: this.globals.suiClient
|
|
900
|
+
});
|
|
901
|
+
const digest = await txb.getDigest({
|
|
902
|
+
client: this.globals.suiClient
|
|
903
|
+
});
|
|
904
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
905
|
+
transactionBlock: payload
|
|
906
|
+
});
|
|
790
907
|
return this.backend.proposeIntentionAndBuildVote({
|
|
791
908
|
...input,
|
|
792
909
|
payload: toHex(payload),
|
|
@@ -862,7 +979,9 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
862
979
|
}
|
|
863
980
|
async voteForTransaction(digest, payload) {
|
|
864
981
|
const payloadBytes = HexToUint8Array(payload);
|
|
865
|
-
const signature = await this.wallet.signTransactionBlock({
|
|
982
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
983
|
+
transactionBlock: payloadBytes
|
|
984
|
+
});
|
|
866
985
|
return this.backend.voteForTransaction({
|
|
867
986
|
msafeAddress: this.address,
|
|
868
987
|
digest,
|
|
@@ -876,7 +995,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
876
995
|
}
|
|
877
996
|
const txb = toSuiTransaction(buildRejectTxb(this.address));
|
|
878
997
|
txb.setSender(this.address);
|
|
879
|
-
return this.simulator.simulate({
|
|
998
|
+
return this.simulator.simulate({
|
|
999
|
+
txb,
|
|
1000
|
+
sender: this.address
|
|
1001
|
+
});
|
|
880
1002
|
}
|
|
881
1003
|
async rejectCurrentTx(input) {
|
|
882
1004
|
const pendingTx = await this.pendingTransaction();
|
|
@@ -884,9 +1006,15 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
884
1006
|
throw new Error("Already rejected");
|
|
885
1007
|
}
|
|
886
1008
|
const rejectTxb = toSuiTransaction(buildRejectTxb(this.address));
|
|
887
|
-
const digest = await rejectTxb.getDigest({
|
|
888
|
-
|
|
889
|
-
|
|
1009
|
+
const digest = await rejectTxb.getDigest({
|
|
1010
|
+
client: this.suiClient
|
|
1011
|
+
});
|
|
1012
|
+
const payload = await rejectTxb.build({
|
|
1013
|
+
client: this.suiClient
|
|
1014
|
+
});
|
|
1015
|
+
const signature = await this.wallet.signTransactionBlock({
|
|
1016
|
+
transactionBlock: payload
|
|
1017
|
+
});
|
|
890
1018
|
return this.backend.rejectCurrentTx({
|
|
891
1019
|
msafeAddress: this.address,
|
|
892
1020
|
digest,
|
|
@@ -895,28 +1023,34 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
895
1023
|
});
|
|
896
1024
|
}
|
|
897
1025
|
async simulateBuildTransaction() {
|
|
898
|
-
const intention = await this.backend.getNextIntention({
|
|
1026
|
+
const intention = await this.backend.getNextIntention({
|
|
1027
|
+
msafeAddress: this.address
|
|
1028
|
+
});
|
|
899
1029
|
const appHelper = appHelpers.getAppHelper(intention.application);
|
|
900
1030
|
if (!appHelper) {
|
|
901
1031
|
throw new Error(`Can't find app helper for application ${intention.application}`);
|
|
902
1032
|
}
|
|
903
|
-
const txb = toSuiTransaction(
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
1033
|
+
const txb = toSuiTransaction(await appHelper.build({
|
|
1034
|
+
network: this.globals.config.network,
|
|
1035
|
+
intentionData: intention.intention,
|
|
1036
|
+
txType: intention.txType,
|
|
1037
|
+
txSubType: intention.txSubType,
|
|
1038
|
+
clientUrl: this.globals.config.suiClient.url,
|
|
1039
|
+
account: {
|
|
1040
|
+
address: this.address,
|
|
1041
|
+
publicKey: fromHex(this.address),
|
|
1042
|
+
chains: [
|
|
1043
|
+
SUI_MAINNET_CHAIN,
|
|
1044
|
+
SUI_TESTNET_CHAIN
|
|
1045
|
+
],
|
|
1046
|
+
features: []
|
|
1047
|
+
}
|
|
1048
|
+
}));
|
|
918
1049
|
txb.setSender(this.address);
|
|
919
|
-
return this.simulator.simulate({
|
|
1050
|
+
return this.simulator.simulate({
|
|
1051
|
+
txb,
|
|
1052
|
+
sender: this.address
|
|
1053
|
+
});
|
|
920
1054
|
}
|
|
921
1055
|
async buildNextIntentionAndAddToPending(gasOption) {
|
|
922
1056
|
return this.backend.buildNextIntentionAndAddToPending({
|
|
@@ -927,10 +1061,14 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
927
1061
|
});
|
|
928
1062
|
}
|
|
929
1063
|
async skipNextFailedIntention() {
|
|
930
|
-
return this.backend.skipNextFailedIntention({
|
|
1064
|
+
return this.backend.skipNextFailedIntention({
|
|
1065
|
+
msafeAddress: this.address
|
|
1066
|
+
});
|
|
931
1067
|
}
|
|
932
1068
|
async fetchTransaction() {
|
|
933
|
-
return this.backend.fetchTransaction({
|
|
1069
|
+
return this.backend.fetchTransaction({
|
|
1070
|
+
msafeAddress: this.address
|
|
1071
|
+
});
|
|
934
1072
|
}
|
|
935
1073
|
async executePendingTx(pending, isRejectTx = false) {
|
|
936
1074
|
const votes = isRejectTx ? pending.rejectVotes : pending.votes;
|
|
@@ -939,7 +1077,10 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
939
1077
|
throw new Error("Not enough signature");
|
|
940
1078
|
}
|
|
941
1079
|
const sortedSigs = [];
|
|
942
|
-
const gotSigs = new Map(votes.map((vote) => [
|
|
1080
|
+
const gotSigs = new Map(votes.map((vote) => [
|
|
1081
|
+
vote.userAddress,
|
|
1082
|
+
vote.signature
|
|
1083
|
+
]));
|
|
943
1084
|
for (let i = 0; i < this.info.owners.length; i++) {
|
|
944
1085
|
const owner = this.info.owners[i];
|
|
945
1086
|
const signature = gotSigs.get(owner.address);
|
|
@@ -950,8 +1091,13 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
950
1091
|
const multiSignature = this.multiSig.combinePartialSignatures(sortedSigs);
|
|
951
1092
|
return this.suiClient.executeTransaction({
|
|
952
1093
|
transaction: HexToUint8Array(payload),
|
|
953
|
-
signatures: [
|
|
954
|
-
|
|
1094
|
+
signatures: [
|
|
1095
|
+
multiSignature
|
|
1096
|
+
],
|
|
1097
|
+
include: {
|
|
1098
|
+
effects: true,
|
|
1099
|
+
events: true
|
|
1100
|
+
}
|
|
955
1101
|
});
|
|
956
1102
|
}
|
|
957
1103
|
async dashboard() {
|
|
@@ -993,11 +1139,15 @@ var MSafeAccount = class _MSafeAccount {
|
|
|
993
1139
|
import { isSameAddress as isSameAddress3 } from "@msafe/sui3-utils";
|
|
994
1140
|
import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui/utils";
|
|
995
1141
|
var PublicKeyHelper = class {
|
|
1142
|
+
static {
|
|
1143
|
+
__name(this, "PublicKeyHelper");
|
|
1144
|
+
}
|
|
1145
|
+
globals;
|
|
1146
|
+
knownPublicKeys;
|
|
996
1147
|
constructor(globals) {
|
|
997
1148
|
this.globals = globals;
|
|
998
1149
|
this.knownPublicKeys = /* @__PURE__ */ new Map();
|
|
999
1150
|
}
|
|
1000
|
-
knownPublicKeys;
|
|
1001
1151
|
async getPublicKey(address) {
|
|
1002
1152
|
const cached = this.knownPublicKeys.get(address);
|
|
1003
1153
|
if (cached) {
|
|
@@ -1068,6 +1218,10 @@ var PublicKeyHelper = class {
|
|
|
1068
1218
|
|
|
1069
1219
|
// src/core/ReportSDK.ts
|
|
1070
1220
|
var ReportSDK = class {
|
|
1221
|
+
static {
|
|
1222
|
+
__name(this, "ReportSDK");
|
|
1223
|
+
}
|
|
1224
|
+
globals;
|
|
1071
1225
|
constructor(globals) {
|
|
1072
1226
|
this.globals = globals;
|
|
1073
1227
|
}
|
|
@@ -1080,17 +1234,19 @@ var ReportSDK = class {
|
|
|
1080
1234
|
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
1081
1235
|
|
|
1082
1236
|
// src/backend/BackendImpl.ts
|
|
1083
|
-
import {
|
|
1084
|
-
PublicKeySerde as PublicKeySerde3,
|
|
1085
|
-
UserMSafeStatus
|
|
1086
|
-
} from "@msafe/sui3-utils";
|
|
1237
|
+
import { PublicKeySerde as PublicKeySerde3, UserMSafeStatus } from "@msafe/sui3-utils";
|
|
1087
1238
|
import axios from "axios";
|
|
1088
1239
|
var BackendImpl = class _BackendImpl {
|
|
1240
|
+
static {
|
|
1241
|
+
__name(this, "BackendImpl");
|
|
1242
|
+
}
|
|
1243
|
+
apiURL;
|
|
1244
|
+
mockAddress;
|
|
1245
|
+
_token;
|
|
1089
1246
|
constructor(apiURL, mockAddress) {
|
|
1090
1247
|
this.apiURL = apiURL;
|
|
1091
1248
|
this.mockAddress = mockAddress;
|
|
1092
1249
|
}
|
|
1093
|
-
_token;
|
|
1094
1250
|
getNotificationInfo() {
|
|
1095
1251
|
return this.get(`/notification`, {
|
|
1096
1252
|
headers: this.headers()
|
|
@@ -1113,7 +1269,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1113
1269
|
}
|
|
1114
1270
|
async verifyToken(jwt) {
|
|
1115
1271
|
try {
|
|
1116
|
-
const res = await this.get(`/auth`, {
|
|
1272
|
+
const res = await this.get(`/auth`, {
|
|
1273
|
+
headers: this.headers(jwt)
|
|
1274
|
+
});
|
|
1117
1275
|
return res.status === 200;
|
|
1118
1276
|
} catch (_) {
|
|
1119
1277
|
return false;
|
|
@@ -1123,7 +1281,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1123
1281
|
this._token = token;
|
|
1124
1282
|
}
|
|
1125
1283
|
async getPublicKey(address) {
|
|
1126
|
-
return (await this.getPublicKeyBatch([
|
|
1284
|
+
return (await this.getPublicKeyBatch([
|
|
1285
|
+
address
|
|
1286
|
+
]))[0];
|
|
1127
1287
|
}
|
|
1128
1288
|
async getPublicKeyBatch(addresses) {
|
|
1129
1289
|
const query = {
|
|
@@ -1133,9 +1293,7 @@ var BackendImpl = class _BackendImpl {
|
|
|
1133
1293
|
params: query,
|
|
1134
1294
|
headers: this.headers()
|
|
1135
1295
|
});
|
|
1136
|
-
return res.data?.map(
|
|
1137
|
-
(publicKeyWithSchema) => publicKeyWithSchema ? PublicKeySerde3.de(publicKeyWithSchema) : void 0
|
|
1138
|
-
);
|
|
1296
|
+
return res.data?.map((publicKeyWithSchema) => publicKeyWithSchema ? PublicKeySerde3.de(publicKeyWithSchema) : void 0);
|
|
1139
1297
|
}
|
|
1140
1298
|
async getMSafeAccountInfo(msafeAddress) {
|
|
1141
1299
|
const q = {
|
|
@@ -1172,7 +1330,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1172
1330
|
}
|
|
1173
1331
|
async updateMSafeStatus(input) {
|
|
1174
1332
|
const p = input;
|
|
1175
|
-
await this.post(`/msafe/status`, p, {
|
|
1333
|
+
await this.post(`/msafe/status`, p, {
|
|
1334
|
+
headers: this.headers()
|
|
1335
|
+
});
|
|
1176
1336
|
}
|
|
1177
1337
|
async getPendingTransactions(input) {
|
|
1178
1338
|
const res = await this.get(`/transaction/pending`, {
|
|
@@ -1226,16 +1386,18 @@ var BackendImpl = class _BackendImpl {
|
|
|
1226
1386
|
});
|
|
1227
1387
|
}
|
|
1228
1388
|
async proposeIntention(input) {
|
|
1229
|
-
await this.post(`/transaction/intention`, input, {
|
|
1389
|
+
await this.post(`/transaction/intention`, input, {
|
|
1390
|
+
headers: this.headers()
|
|
1391
|
+
});
|
|
1230
1392
|
}
|
|
1231
1393
|
async rejectCurrentTx(input) {
|
|
1232
|
-
await this.post(
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
);
|
|
1394
|
+
await this.post(`/transaction/pending/reject`, {
|
|
1395
|
+
...input,
|
|
1396
|
+
gasPrice: input.gasPrice.toString(),
|
|
1397
|
+
gasBudget: input.gasBudget.toString()
|
|
1398
|
+
}, {
|
|
1399
|
+
headers: this.headers()
|
|
1400
|
+
});
|
|
1239
1401
|
}
|
|
1240
1402
|
async voteForTransaction(input) {
|
|
1241
1403
|
await this.post(`/transaction/pending/vote`, input, {
|
|
@@ -1243,24 +1405,32 @@ var BackendImpl = class _BackendImpl {
|
|
|
1243
1405
|
});
|
|
1244
1406
|
}
|
|
1245
1407
|
async buildNextIntentionAndAddToPending(input) {
|
|
1246
|
-
await this.post(
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1408
|
+
await this.post(`/transaction/pending/build`, {
|
|
1409
|
+
...input,
|
|
1410
|
+
gasPrice: input.gasPrice.toString(),
|
|
1411
|
+
gasBudget: input.gasBudget.toString()
|
|
1412
|
+
}, {
|
|
1413
|
+
headers: this.headers()
|
|
1414
|
+
});
|
|
1251
1415
|
}
|
|
1252
1416
|
async proposeIntentionAndBuildVote(input) {
|
|
1253
|
-
await this.post(
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1417
|
+
await this.post(`/transaction/intention/build`, {
|
|
1418
|
+
...input,
|
|
1419
|
+
gasPrice: input.gasPrice.toString(),
|
|
1420
|
+
gasBudget: input.gasBudget.toString()
|
|
1421
|
+
}, {
|
|
1422
|
+
headers: this.headers()
|
|
1423
|
+
});
|
|
1258
1424
|
}
|
|
1259
1425
|
async skipNextFailedIntention(input) {
|
|
1260
|
-
await this.post(`/transaction/pending/skip`, input, {
|
|
1426
|
+
await this.post(`/transaction/pending/skip`, input, {
|
|
1427
|
+
headers: this.headers()
|
|
1428
|
+
});
|
|
1261
1429
|
}
|
|
1262
1430
|
async fetchTransaction(input) {
|
|
1263
|
-
const res = await this.post(`/transaction/fetch`, input, {
|
|
1431
|
+
const res = await this.post(`/transaction/fetch`, input, {
|
|
1432
|
+
headers: this.headers()
|
|
1433
|
+
});
|
|
1264
1434
|
return res.data;
|
|
1265
1435
|
}
|
|
1266
1436
|
async getAddressBookEntries(pagination) {
|
|
@@ -1271,14 +1441,22 @@ var BackendImpl = class _BackendImpl {
|
|
|
1271
1441
|
return res.data;
|
|
1272
1442
|
}
|
|
1273
1443
|
async updateAddressBook(input) {
|
|
1274
|
-
await this.post(`/address-book`, input, {
|
|
1444
|
+
await this.post(`/address-book`, input, {
|
|
1445
|
+
headers: this.headers()
|
|
1446
|
+
});
|
|
1275
1447
|
}
|
|
1276
1448
|
async getAddressBookMode() {
|
|
1277
|
-
const res = await this.get("/address-book/mode", {
|
|
1449
|
+
const res = await this.get("/address-book/mode", {
|
|
1450
|
+
headers: this.headers()
|
|
1451
|
+
});
|
|
1278
1452
|
return res.data;
|
|
1279
1453
|
}
|
|
1280
1454
|
async setAddressBookMode(input) {
|
|
1281
|
-
await this.post("/address-book/mode", {
|
|
1455
|
+
await this.post("/address-book/mode", {
|
|
1456
|
+
mode: input.mode
|
|
1457
|
+
}, {
|
|
1458
|
+
headers: this.headers()
|
|
1459
|
+
});
|
|
1282
1460
|
}
|
|
1283
1461
|
async submitReport(report) {
|
|
1284
1462
|
await this.post("/report", report);
|
|
@@ -1291,7 +1469,10 @@ var BackendImpl = class _BackendImpl {
|
|
|
1291
1469
|
return res.data;
|
|
1292
1470
|
}
|
|
1293
1471
|
headers(token) {
|
|
1294
|
-
return {
|
|
1472
|
+
return {
|
|
1473
|
+
Authorization: `Bearer ${token || this._token}`,
|
|
1474
|
+
"sui-mock-user": this.mockAddress
|
|
1475
|
+
};
|
|
1295
1476
|
}
|
|
1296
1477
|
static toMSafeConfig(resp) {
|
|
1297
1478
|
return {
|
|
@@ -1347,7 +1528,9 @@ var BackendImpl = class _BackendImpl {
|
|
|
1347
1528
|
} else if (transformRequest instanceof Array) {
|
|
1348
1529
|
transformRequests = transformRequest;
|
|
1349
1530
|
} else {
|
|
1350
|
-
transformRequests = [
|
|
1531
|
+
transformRequests = [
|
|
1532
|
+
transformRequest
|
|
1533
|
+
];
|
|
1351
1534
|
}
|
|
1352
1535
|
return [
|
|
1353
1536
|
(d) => JSON.parse(JSON.stringify(d, (_, value) => typeof value === "bigint" ? `${value.toString()}n` : value)),
|
|
@@ -1356,6 +1539,10 @@ var BackendImpl = class _BackendImpl {
|
|
|
1356
1539
|
}
|
|
1357
1540
|
};
|
|
1358
1541
|
var BackendError = class _BackendError extends Error {
|
|
1542
|
+
static {
|
|
1543
|
+
__name(this, "BackendError");
|
|
1544
|
+
}
|
|
1545
|
+
e;
|
|
1359
1546
|
constructor(e) {
|
|
1360
1547
|
super();
|
|
1361
1548
|
this.e = e;
|
|
@@ -1392,14 +1579,15 @@ var BackendError = class _BackendError extends Error {
|
|
|
1392
1579
|
function msafeChainToSuiNetwork(chain) {
|
|
1393
1580
|
return chain === "sui:mainnet" ? "mainnet" : "testnet";
|
|
1394
1581
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1582
|
+
__name(msafeChainToSuiNetwork, "msafeChainToSuiNetwork");
|
|
1583
|
+
var MSafeEnv;
|
|
1584
|
+
(function(MSafeEnv2) {
|
|
1585
|
+
MSafeEnv2["local"] = "local";
|
|
1586
|
+
MSafeEnv2["unit"] = "unit";
|
|
1587
|
+
MSafeEnv2["dev"] = "dev";
|
|
1588
|
+
MSafeEnv2["prev"] = "prev";
|
|
1589
|
+
MSafeEnv2["prod"] = "prod";
|
|
1590
|
+
})(MSafeEnv || (MSafeEnv = {}));
|
|
1403
1591
|
function httpUrlToGrpcBaseUrl(url) {
|
|
1404
1592
|
const parsed = new URL(url);
|
|
1405
1593
|
if (parsed.protocol === "https:" && parsed.port === "") {
|
|
@@ -1410,6 +1598,7 @@ function httpUrlToGrpcBaseUrl(url) {
|
|
|
1410
1598
|
}
|
|
1411
1599
|
return `${parsed.origin}${parsed.pathname}${parsed.search}`;
|
|
1412
1600
|
}
|
|
1601
|
+
__name(httpUrlToGrpcBaseUrl, "httpUrlToGrpcBaseUrl");
|
|
1413
1602
|
var TESTNET_RPC_URL = "https://fullnode.testnet.sui.io";
|
|
1414
1603
|
var MAINNET_RPC_URL = "https://fullnode.mainnet.sui.io";
|
|
1415
1604
|
var LOCAL_API_URL = "http://127.0.0.1:3000";
|
|
@@ -1420,7 +1609,7 @@ var PREV_API_URL = "https://sui-preview.m-safe.link";
|
|
|
1420
1609
|
var PROD_API_URL = "https://sui.m-safe.link";
|
|
1421
1610
|
var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
1422
1611
|
[
|
|
1423
|
-
"unit"
|
|
1612
|
+
"unit",
|
|
1424
1613
|
{
|
|
1425
1614
|
suiClient: {
|
|
1426
1615
|
url: TESTNET_RPC_URL
|
|
@@ -1433,7 +1622,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1433
1622
|
}
|
|
1434
1623
|
],
|
|
1435
1624
|
[
|
|
1436
|
-
"local"
|
|
1625
|
+
"local",
|
|
1437
1626
|
{
|
|
1438
1627
|
suiClient: {
|
|
1439
1628
|
url: TESTNET_RPC_URL
|
|
@@ -1446,7 +1635,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1446
1635
|
}
|
|
1447
1636
|
],
|
|
1448
1637
|
[
|
|
1449
|
-
"dev"
|
|
1638
|
+
"dev",
|
|
1450
1639
|
{
|
|
1451
1640
|
suiClient: {
|
|
1452
1641
|
url: TESTNET_RPC_URL
|
|
@@ -1459,7 +1648,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1459
1648
|
}
|
|
1460
1649
|
],
|
|
1461
1650
|
[
|
|
1462
|
-
"prev"
|
|
1651
|
+
"prev",
|
|
1463
1652
|
{
|
|
1464
1653
|
suiClient: {
|
|
1465
1654
|
url: MAINNET_RPC_URL
|
|
@@ -1472,7 +1661,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
|
|
|
1472
1661
|
}
|
|
1473
1662
|
],
|
|
1474
1663
|
[
|
|
1475
|
-
"prod"
|
|
1664
|
+
"prod",
|
|
1476
1665
|
{
|
|
1477
1666
|
suiClient: {
|
|
1478
1667
|
url: MAINNET_RPC_URL
|
|
@@ -1501,9 +1690,13 @@ function getMSafeConfig(env, options) {
|
|
|
1501
1690
|
}
|
|
1502
1691
|
return config;
|
|
1503
1692
|
}
|
|
1693
|
+
__name(getMSafeConfig, "getMSafeConfig");
|
|
1504
1694
|
|
|
1505
1695
|
// src/globals/MSafeGlobals.ts
|
|
1506
1696
|
var MSafeGlobals = class _MSafeGlobals {
|
|
1697
|
+
static {
|
|
1698
|
+
__name(this, "MSafeGlobals");
|
|
1699
|
+
}
|
|
1507
1700
|
backend;
|
|
1508
1701
|
suiClient;
|
|
1509
1702
|
config;
|
|
@@ -1545,11 +1738,15 @@ var MSafeGlobals = class _MSafeGlobals {
|
|
|
1545
1738
|
|
|
1546
1739
|
// src/core/MSafeClient.ts
|
|
1547
1740
|
var MSafeClient = class _MSafeClient {
|
|
1548
|
-
|
|
1549
|
-
this
|
|
1741
|
+
static {
|
|
1742
|
+
__name(this, "MSafeClient");
|
|
1550
1743
|
}
|
|
1744
|
+
globals;
|
|
1551
1745
|
_creationHelper;
|
|
1552
1746
|
_publicKeyHelper;
|
|
1747
|
+
constructor(globals) {
|
|
1748
|
+
this.globals = globals;
|
|
1749
|
+
}
|
|
1553
1750
|
static async New(env, options) {
|
|
1554
1751
|
const globals = await MSafeGlobals.New(env, options);
|
|
1555
1752
|
return new _MSafeClient(globals);
|
|
@@ -1584,7 +1781,10 @@ var MSafeClient = class _MSafeClient {
|
|
|
1584
1781
|
return this.globals.backend.getUserInfo();
|
|
1585
1782
|
}
|
|
1586
1783
|
async ownedMSafe(pagination) {
|
|
1587
|
-
return this.globals.backend.getOwnedMSafeByStatus({
|
|
1784
|
+
return this.globals.backend.getOwnedMSafeByStatus({
|
|
1785
|
+
status: UserMSafeStatus2.active,
|
|
1786
|
+
pagination
|
|
1787
|
+
});
|
|
1588
1788
|
}
|
|
1589
1789
|
async createAccount(info) {
|
|
1590
1790
|
return this.creationHelper.submitMSafeCreation(info);
|
|
@@ -1634,26 +1834,38 @@ var MSafeClient = class _MSafeClient {
|
|
|
1634
1834
|
};
|
|
1635
1835
|
|
|
1636
1836
|
// src/backend/types/notification.ts
|
|
1637
|
-
var InfoTypeKey
|
|
1837
|
+
var InfoTypeKey;
|
|
1838
|
+
(function(InfoTypeKey2) {
|
|
1638
1839
|
InfoTypeKey2["receive"] = "info_type_receive";
|
|
1639
1840
|
InfoTypeKey2["send"] = "info_type_send";
|
|
1640
1841
|
InfoTypeKey2["invitation"] = "info_type_invitation";
|
|
1641
1842
|
InfoTypeKey2["awaitApproval"] = "info_type_await_approval";
|
|
1642
|
-
|
|
1643
|
-
})(InfoTypeKey || {});
|
|
1843
|
+
})(InfoTypeKey || (InfoTypeKey = {}));
|
|
1644
1844
|
var NotificationSubscribeDto = class {
|
|
1845
|
+
static {
|
|
1846
|
+
__name(this, "NotificationSubscribeDto");
|
|
1847
|
+
}
|
|
1645
1848
|
email;
|
|
1646
1849
|
};
|
|
1647
1850
|
var NotificationUpdateDto = class {
|
|
1851
|
+
static {
|
|
1852
|
+
__name(this, "NotificationUpdateDto");
|
|
1853
|
+
}
|
|
1648
1854
|
email;
|
|
1649
1855
|
infoTypes;
|
|
1650
1856
|
msafeEnabled;
|
|
1651
1857
|
};
|
|
1652
1858
|
var InfoTypeEnabledDto = class {
|
|
1859
|
+
static {
|
|
1860
|
+
__name(this, "InfoTypeEnabledDto");
|
|
1861
|
+
}
|
|
1653
1862
|
infoType;
|
|
1654
1863
|
enabled;
|
|
1655
1864
|
};
|
|
1656
1865
|
var MSafeEnabledDto = class {
|
|
1866
|
+
static {
|
|
1867
|
+
__name(this, "MSafeEnabledDto");
|
|
1868
|
+
}
|
|
1657
1869
|
msafeAddress;
|
|
1658
1870
|
enabled;
|
|
1659
1871
|
};
|