@msafe/sui-app-store 0.0.13 → 0.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/README.md +16 -3
- package/dist/index.global.js +9 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +136 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,56 @@ var __export = (target, all) => {
|
|
|
7
7
|
// src/apps/mpay/helper.ts
|
|
8
8
|
import { StreamEventType, TransactionType } from "@msafe/sui3-utils";
|
|
9
9
|
|
|
10
|
+
// src/apps/mpay/cancel-stream.ts
|
|
11
|
+
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
12
|
+
|
|
13
|
+
// src/apps/msafe-core/intention.ts
|
|
14
|
+
import sortKeys from "sort-keys-recursive";
|
|
15
|
+
var CoreBaseIntention = class {
|
|
16
|
+
constructor(data) {
|
|
17
|
+
this.data = data;
|
|
18
|
+
}
|
|
19
|
+
get application() {
|
|
20
|
+
return "msafe-core";
|
|
21
|
+
}
|
|
22
|
+
serialize() {
|
|
23
|
+
return JSON.stringify(sortKeys(this.data));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/apps/mpay/cancel-stream.ts
|
|
28
|
+
var CancelStreamIntention = class _CancelStreamIntention extends CoreBaseIntention {
|
|
29
|
+
constructor(data) {
|
|
30
|
+
super(data);
|
|
31
|
+
this.data = data;
|
|
32
|
+
}
|
|
33
|
+
txType;
|
|
34
|
+
txSubType;
|
|
35
|
+
async build() {
|
|
36
|
+
return new TransactionBlock();
|
|
37
|
+
}
|
|
38
|
+
static fromData(data) {
|
|
39
|
+
return new _CancelStreamIntention(data);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/apps/mpay/claim-stream.ts
|
|
44
|
+
import { TransactionBlock as TransactionBlock2 } from "@mysten/sui.js/transactions";
|
|
45
|
+
var ClaimStreamIntention = class _ClaimStreamIntention extends CoreBaseIntention {
|
|
46
|
+
constructor(data) {
|
|
47
|
+
super(data);
|
|
48
|
+
this.data = data;
|
|
49
|
+
}
|
|
50
|
+
txType;
|
|
51
|
+
txSubType;
|
|
52
|
+
async build() {
|
|
53
|
+
return new TransactionBlock2();
|
|
54
|
+
}
|
|
55
|
+
static fromData(data) {
|
|
56
|
+
return new _ClaimStreamIntention(data);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
10
60
|
// src/apps/mpay/config/dev.json
|
|
11
61
|
var dev_exports = {};
|
|
12
62
|
__export(dev_exports, {
|
|
@@ -304,20 +354,6 @@ var Globals = class _Globals {
|
|
|
304
354
|
}
|
|
305
355
|
};
|
|
306
356
|
|
|
307
|
-
// src/apps/msafe-core/intention.ts
|
|
308
|
-
import sortKeys from "sort-keys-recursive";
|
|
309
|
-
var CoreBaseIntention = class {
|
|
310
|
-
constructor(data) {
|
|
311
|
-
this.data = data;
|
|
312
|
-
}
|
|
313
|
-
get application() {
|
|
314
|
-
return "msafe-core";
|
|
315
|
-
}
|
|
316
|
-
serialize() {
|
|
317
|
-
return JSON.stringify(sortKeys(this.data));
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
|
|
321
357
|
// src/apps/mpay/stream/client.ts
|
|
322
358
|
import { normalizeStructTag as normalizeStructTag6, normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui.js/utils";
|
|
323
359
|
|
|
@@ -326,10 +362,10 @@ import { normalizeStructTag as normalizeStructTag3, SUI_TYPE_ARG as SUI_TYPE_ARG
|
|
|
326
362
|
import { Duration } from "luxon";
|
|
327
363
|
|
|
328
364
|
// src/apps/mpay/builder/MPayBuilder.ts
|
|
329
|
-
import { TransactionBlock as
|
|
365
|
+
import { TransactionBlock as TransactionBlock5 } from "@mysten/sui.js/transactions";
|
|
330
366
|
|
|
331
367
|
// src/apps/mpay/builder/CreateStreamHelper.ts
|
|
332
|
-
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
368
|
+
import { TransactionBlock as TransactionBlock3 } from "@mysten/sui.js/transactions";
|
|
333
369
|
import { normalizeStructTag as normalizeStructTag2, SUI_TYPE_ARG } from "@mysten/sui.js/utils";
|
|
334
370
|
|
|
335
371
|
// src/apps/mpay/builder/const.ts
|
|
@@ -532,7 +568,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
532
568
|
};
|
|
533
569
|
}
|
|
534
570
|
async buildCreateStreamTransactionBlock(info) {
|
|
535
|
-
const txb = new
|
|
571
|
+
const txb = new TransactionBlock3();
|
|
536
572
|
const paymentWithFee = this.calculateFeesInternal(info);
|
|
537
573
|
const coinReqs = this.getCreateStreamCoinRequests(info, paymentWithFee);
|
|
538
574
|
const coinResp = await this.wallet.requestCoins(coinReqs);
|
|
@@ -640,7 +676,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
640
676
|
};
|
|
641
677
|
}
|
|
642
678
|
amountForRecipient(recipient, numEpoch) {
|
|
643
|
-
return recipient.amountPerEpoch * numEpoch + recipient.cliffAmount;
|
|
679
|
+
return BigInt(recipient.amountPerEpoch) * BigInt(numEpoch) + BigInt(recipient.cliffAmount);
|
|
644
680
|
}
|
|
645
681
|
get flatSuiFee() {
|
|
646
682
|
return FLAT_FEE_SUI;
|
|
@@ -649,7 +685,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
649
685
|
return streamAmount * FEE_NUMERATOR / FEE_DENOMINATOR;
|
|
650
686
|
}
|
|
651
687
|
async getStreamFeeRemote(streamAmount) {
|
|
652
|
-
const txb = this.feeContract.streamingFee(new
|
|
688
|
+
const txb = this.feeContract.streamingFee(new TransactionBlock3(), streamAmount);
|
|
653
689
|
const res = await this.globals.suiClient.devInspectTransactionBlock({
|
|
654
690
|
sender: await this.globals.walletAddress(),
|
|
655
691
|
transactionBlock: txb
|
|
@@ -917,7 +953,7 @@ var MPayBuilder = class {
|
|
|
917
953
|
return new CreateStreamHelper(this.globals, this.feeContract, this.streamContract);
|
|
918
954
|
}
|
|
919
955
|
setAutoClaim(streamId, enabled, coinType) {
|
|
920
|
-
const txb = new
|
|
956
|
+
const txb = new TransactionBlock5();
|
|
921
957
|
return this.streamContract.setAutoClaim(txb, {
|
|
922
958
|
streamId,
|
|
923
959
|
enabled,
|
|
@@ -925,21 +961,21 @@ var MPayBuilder = class {
|
|
|
925
961
|
});
|
|
926
962
|
}
|
|
927
963
|
claimStream(streamId, coinType) {
|
|
928
|
-
const txb = new
|
|
964
|
+
const txb = new TransactionBlock5();
|
|
929
965
|
return this.streamContract.claimStream(txb, {
|
|
930
966
|
streamId,
|
|
931
967
|
coinType
|
|
932
968
|
});
|
|
933
969
|
}
|
|
934
970
|
claimStreamByProxy(streamId, coinType) {
|
|
935
|
-
const txb = new
|
|
971
|
+
const txb = new TransactionBlock5();
|
|
936
972
|
return this.streamContract.claimStreamByProxy(txb, {
|
|
937
973
|
streamId,
|
|
938
974
|
coinType
|
|
939
975
|
});
|
|
940
976
|
}
|
|
941
977
|
cancelStream(streamId, coinType) {
|
|
942
|
-
const txb = new
|
|
978
|
+
const txb = new TransactionBlock5();
|
|
943
979
|
this.streamContract.cancelStream(txb, {
|
|
944
980
|
streamId,
|
|
945
981
|
coinType
|
|
@@ -1106,7 +1142,7 @@ import { normalizeStructTag as normalizeStructTag5, normalizeSuiAddress as norma
|
|
|
1106
1142
|
import { DateTime as DateTime4 } from "luxon";
|
|
1107
1143
|
|
|
1108
1144
|
// src/apps/mpay/stream/Stream.ts
|
|
1109
|
-
import { TransactionBlock as
|
|
1145
|
+
import { TransactionBlock as TransactionBlock6 } from "@mysten/sui.js/transactions";
|
|
1110
1146
|
import { normalizeStructTag as normalizeStructTag4, parseStructTag } from "@mysten/sui.js/utils";
|
|
1111
1147
|
import { DateTime as DateTime3 } from "luxon";
|
|
1112
1148
|
|
|
@@ -1250,7 +1286,7 @@ var Stream = class _Stream {
|
|
|
1250
1286
|
if (await this.globals.walletAddress() !== this.creator) {
|
|
1251
1287
|
throw new NotCreatorError();
|
|
1252
1288
|
}
|
|
1253
|
-
const txb = new
|
|
1289
|
+
const txb = new TransactionBlock6();
|
|
1254
1290
|
this.streamContract.cancelStream(txb, {
|
|
1255
1291
|
streamId: this.streamId,
|
|
1256
1292
|
coinType: this.coinType
|
|
@@ -1261,7 +1297,7 @@ var Stream = class _Stream {
|
|
|
1261
1297
|
if (await this.globals.walletAddress() !== this.recipient) {
|
|
1262
1298
|
throw new NotRecipientError();
|
|
1263
1299
|
}
|
|
1264
|
-
const txb = new
|
|
1300
|
+
const txb = new TransactionBlock6();
|
|
1265
1301
|
this.streamContract.claimStream(txb, {
|
|
1266
1302
|
streamId: this.streamId,
|
|
1267
1303
|
coinType: this.coinType
|
|
@@ -1272,7 +1308,7 @@ var Stream = class _Stream {
|
|
|
1272
1308
|
if (await this.globals.walletAddress() !== this.recipient) {
|
|
1273
1309
|
throw new NotRecipientError();
|
|
1274
1310
|
}
|
|
1275
|
-
const txb = new
|
|
1311
|
+
const txb = new TransactionBlock6();
|
|
1276
1312
|
this.streamContract.setAutoClaim(txb, {
|
|
1277
1313
|
streamId: this.streamId,
|
|
1278
1314
|
coinType: this.coinType,
|
|
@@ -1281,7 +1317,7 @@ var Stream = class _Stream {
|
|
|
1281
1317
|
return txb;
|
|
1282
1318
|
}
|
|
1283
1319
|
async claimByProxy() {
|
|
1284
|
-
const txb = new
|
|
1320
|
+
const txb = new TransactionBlock6();
|
|
1285
1321
|
this.streamContract.claimStreamByProxy(txb, {
|
|
1286
1322
|
streamId: this.streamId,
|
|
1287
1323
|
coinType: this.coinType
|
|
@@ -2442,6 +2478,23 @@ var DecodeHelper = class {
|
|
|
2442
2478
|
}
|
|
2443
2479
|
};
|
|
2444
2480
|
|
|
2481
|
+
// src/apps/mpay/set-auto-claim-stream.ts
|
|
2482
|
+
import { TransactionBlock as TransactionBlock7 } from "@mysten/sui.js/transactions";
|
|
2483
|
+
var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends CoreBaseIntention {
|
|
2484
|
+
constructor(data) {
|
|
2485
|
+
super(data);
|
|
2486
|
+
this.data = data;
|
|
2487
|
+
}
|
|
2488
|
+
txType;
|
|
2489
|
+
txSubType;
|
|
2490
|
+
async build() {
|
|
2491
|
+
return new TransactionBlock7();
|
|
2492
|
+
}
|
|
2493
|
+
static fromData(data) {
|
|
2494
|
+
return new _SetAutoClaimStreamIntention(data);
|
|
2495
|
+
}
|
|
2496
|
+
};
|
|
2497
|
+
|
|
2445
2498
|
// src/apps/mpay/helper.ts
|
|
2446
2499
|
var MPayAppHelper = class {
|
|
2447
2500
|
application = "mpay";
|
|
@@ -2458,7 +2511,44 @@ var MPayAppHelper = class {
|
|
|
2458
2511
|
intentionData: result.info
|
|
2459
2512
|
};
|
|
2460
2513
|
}
|
|
2461
|
-
|
|
2514
|
+
if (result.type === "Claim" /* CLAIM */) {
|
|
2515
|
+
return {
|
|
2516
|
+
txType: TransactionType.Other,
|
|
2517
|
+
txSubType: StreamEventType.Claim,
|
|
2518
|
+
intentionData: {
|
|
2519
|
+
streamId: result.streamId
|
|
2520
|
+
}
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
if (result.type === "ClaimByProxy" /* CLAIM_BY_PROXY */) {
|
|
2524
|
+
return {
|
|
2525
|
+
txType: TransactionType.Other,
|
|
2526
|
+
txSubType: StreamEventType.SetAutoClaim,
|
|
2527
|
+
intentionData: {
|
|
2528
|
+
streamId: result.streamId
|
|
2529
|
+
}
|
|
2530
|
+
};
|
|
2531
|
+
}
|
|
2532
|
+
if (result.type === "SetAutoClaim" /* SET_AUTO_CLAIM */) {
|
|
2533
|
+
return {
|
|
2534
|
+
txType: TransactionType.Other,
|
|
2535
|
+
txSubType: StreamEventType.SetAutoClaim,
|
|
2536
|
+
intentionData: {
|
|
2537
|
+
streamId: result.streamId,
|
|
2538
|
+
enabled: result.enabled
|
|
2539
|
+
}
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
if (result.type === "Cancel" /* CANCEL */) {
|
|
2543
|
+
return {
|
|
2544
|
+
txType: TransactionType.Other,
|
|
2545
|
+
txSubType: StreamEventType.Cancel,
|
|
2546
|
+
intentionData: {
|
|
2547
|
+
streamId: result.streamId
|
|
2548
|
+
}
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
throw new Error(`Unknown transaction type: ${result}`);
|
|
2462
2552
|
}
|
|
2463
2553
|
async build(input) {
|
|
2464
2554
|
const { network, intentionData, suiClient, account } = input;
|
|
@@ -2467,6 +2557,15 @@ var MPayAppHelper = class {
|
|
|
2467
2557
|
case StreamEventType.Create:
|
|
2468
2558
|
intention = CreateStreamIntention.fromData(intentionData);
|
|
2469
2559
|
break;
|
|
2560
|
+
case StreamEventType.Claim:
|
|
2561
|
+
intention = ClaimStreamIntention.fromData(intentionData);
|
|
2562
|
+
break;
|
|
2563
|
+
case StreamEventType.SetAutoClaim:
|
|
2564
|
+
intention = SetAutoClaimStreamIntention.fromData(intentionData);
|
|
2565
|
+
break;
|
|
2566
|
+
case StreamEventType.Cancel:
|
|
2567
|
+
intention = CancelStreamIntention.fromData(intentionData);
|
|
2568
|
+
break;
|
|
2470
2569
|
default:
|
|
2471
2570
|
throw new Error("not implemented");
|
|
2472
2571
|
}
|
|
@@ -2515,7 +2614,7 @@ var ObjectTransferIntention = class _ObjectTransferIntention extends CoreBaseInt
|
|
|
2515
2614
|
|
|
2516
2615
|
// src/apps/msafe-core/plain-payload.ts
|
|
2517
2616
|
import { isSameAddress } from "@msafe/sui3-utils";
|
|
2518
|
-
import { TransactionBlock as
|
|
2617
|
+
import { TransactionBlock as TransactionBlock8 } from "@mysten/sui.js/transactions";
|
|
2519
2618
|
var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntention {
|
|
2520
2619
|
constructor(data) {
|
|
2521
2620
|
super(data);
|
|
@@ -2525,7 +2624,7 @@ var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntenti
|
|
|
2525
2624
|
txSubType;
|
|
2526
2625
|
async build(input) {
|
|
2527
2626
|
const { account } = input;
|
|
2528
|
-
const tb =
|
|
2627
|
+
const tb = TransactionBlock8.from(this.data.content);
|
|
2529
2628
|
if (!isSameAddress(tb.blockData.sender, account.address)) {
|
|
2530
2629
|
throw new Error("Invalid sender address");
|
|
2531
2630
|
}
|
|
@@ -2581,12 +2680,12 @@ var MSafeApps = class {
|
|
|
2581
2680
|
};
|
|
2582
2681
|
|
|
2583
2682
|
// src/apps/plain-transaction/helper.ts
|
|
2584
|
-
import { TransactionType as TransactionType6 } from "@msafe/sui3-utils";
|
|
2585
|
-
import { TransactionBlock as
|
|
2683
|
+
import { TransactionSubTypes as TransactionSubTypes2, TransactionType as TransactionType6 } from "@msafe/sui3-utils";
|
|
2684
|
+
import { TransactionBlock as TransactionBlock9 } from "@mysten/sui.js/transactions";
|
|
2586
2685
|
import { fromHEX, toHEX } from "@mysten/sui.js/utils";
|
|
2587
2686
|
import sortKeys2 from "sort-keys-recursive";
|
|
2588
2687
|
var PlainTransactionApplication = "msafe-plain-tx";
|
|
2589
|
-
var PlainTransactionType =
|
|
2688
|
+
var PlainTransactionType = TransactionSubTypes2.others.plain;
|
|
2590
2689
|
var PlainTransactionHelper = class {
|
|
2591
2690
|
application;
|
|
2592
2691
|
constructor() {
|
|
@@ -2602,7 +2701,7 @@ var PlainTransactionHelper = class {
|
|
|
2602
2701
|
};
|
|
2603
2702
|
}
|
|
2604
2703
|
async build(input) {
|
|
2605
|
-
return
|
|
2704
|
+
return TransactionBlock9.from(fromHEX(input.intentionData.content));
|
|
2606
2705
|
}
|
|
2607
2706
|
};
|
|
2608
2707
|
|