@msafe/sui-app-store 0.0.13 → 0.0.14
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 +135 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +133 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,6 +37,56 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
37
|
// src/apps/mpay/helper.ts
|
|
38
38
|
var import_sui3_utils = require("@msafe/sui3-utils");
|
|
39
39
|
|
|
40
|
+
// src/apps/mpay/cancel-stream.ts
|
|
41
|
+
var import_transactions = require("@mysten/sui.js/transactions");
|
|
42
|
+
|
|
43
|
+
// src/apps/msafe-core/intention.ts
|
|
44
|
+
var import_sort_keys_recursive = __toESM(require("sort-keys-recursive"));
|
|
45
|
+
var CoreBaseIntention = class {
|
|
46
|
+
constructor(data) {
|
|
47
|
+
this.data = data;
|
|
48
|
+
}
|
|
49
|
+
get application() {
|
|
50
|
+
return "msafe-core";
|
|
51
|
+
}
|
|
52
|
+
serialize() {
|
|
53
|
+
return JSON.stringify((0, import_sort_keys_recursive.default)(this.data));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/apps/mpay/cancel-stream.ts
|
|
58
|
+
var CancelStreamIntention = class _CancelStreamIntention extends CoreBaseIntention {
|
|
59
|
+
constructor(data) {
|
|
60
|
+
super(data);
|
|
61
|
+
this.data = data;
|
|
62
|
+
}
|
|
63
|
+
txType;
|
|
64
|
+
txSubType;
|
|
65
|
+
async build() {
|
|
66
|
+
return new import_transactions.TransactionBlock();
|
|
67
|
+
}
|
|
68
|
+
static fromData(data) {
|
|
69
|
+
return new _CancelStreamIntention(data);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/apps/mpay/claim-stream.ts
|
|
74
|
+
var import_transactions2 = require("@mysten/sui.js/transactions");
|
|
75
|
+
var ClaimStreamIntention = class _ClaimStreamIntention extends CoreBaseIntention {
|
|
76
|
+
constructor(data) {
|
|
77
|
+
super(data);
|
|
78
|
+
this.data = data;
|
|
79
|
+
}
|
|
80
|
+
txType;
|
|
81
|
+
txSubType;
|
|
82
|
+
async build() {
|
|
83
|
+
return new import_transactions2.TransactionBlock();
|
|
84
|
+
}
|
|
85
|
+
static fromData(data) {
|
|
86
|
+
return new _ClaimStreamIntention(data);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
40
90
|
// src/apps/mpay/config/dev.json
|
|
41
91
|
var dev_exports = {};
|
|
42
92
|
__export(dev_exports, {
|
|
@@ -334,20 +384,6 @@ var Globals = class _Globals {
|
|
|
334
384
|
}
|
|
335
385
|
};
|
|
336
386
|
|
|
337
|
-
// src/apps/msafe-core/intention.ts
|
|
338
|
-
var import_sort_keys_recursive = __toESM(require("sort-keys-recursive"));
|
|
339
|
-
var CoreBaseIntention = class {
|
|
340
|
-
constructor(data) {
|
|
341
|
-
this.data = data;
|
|
342
|
-
}
|
|
343
|
-
get application() {
|
|
344
|
-
return "msafe-core";
|
|
345
|
-
}
|
|
346
|
-
serialize() {
|
|
347
|
-
return JSON.stringify((0, import_sort_keys_recursive.default)(this.data));
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
|
|
351
387
|
// src/apps/mpay/stream/client.ts
|
|
352
388
|
var import_utils9 = require("@mysten/sui.js/utils");
|
|
353
389
|
|
|
@@ -356,10 +392,10 @@ var import_utils5 = require("@mysten/sui.js/utils");
|
|
|
356
392
|
var import_luxon = require("luxon");
|
|
357
393
|
|
|
358
394
|
// src/apps/mpay/builder/MPayBuilder.ts
|
|
359
|
-
var
|
|
395
|
+
var import_transactions5 = require("@mysten/sui.js/transactions");
|
|
360
396
|
|
|
361
397
|
// src/apps/mpay/builder/CreateStreamHelper.ts
|
|
362
|
-
var
|
|
398
|
+
var import_transactions3 = require("@mysten/sui.js/transactions");
|
|
363
399
|
var import_utils3 = require("@mysten/sui.js/utils");
|
|
364
400
|
|
|
365
401
|
// src/apps/mpay/builder/const.ts
|
|
@@ -562,7 +598,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
562
598
|
};
|
|
563
599
|
}
|
|
564
600
|
async buildCreateStreamTransactionBlock(info) {
|
|
565
|
-
const txb = new
|
|
601
|
+
const txb = new import_transactions3.TransactionBlock();
|
|
566
602
|
const paymentWithFee = this.calculateFeesInternal(info);
|
|
567
603
|
const coinReqs = this.getCreateStreamCoinRequests(info, paymentWithFee);
|
|
568
604
|
const coinResp = await this.wallet.requestCoins(coinReqs);
|
|
@@ -679,7 +715,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
679
715
|
return streamAmount * FEE_NUMERATOR / FEE_DENOMINATOR;
|
|
680
716
|
}
|
|
681
717
|
async getStreamFeeRemote(streamAmount) {
|
|
682
|
-
const txb = this.feeContract.streamingFee(new
|
|
718
|
+
const txb = this.feeContract.streamingFee(new import_transactions3.TransactionBlock(), streamAmount);
|
|
683
719
|
const res = await this.globals.suiClient.devInspectTransactionBlock({
|
|
684
720
|
sender: await this.globals.walletAddress(),
|
|
685
721
|
transactionBlock: txb
|
|
@@ -693,7 +729,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
693
729
|
};
|
|
694
730
|
|
|
695
731
|
// src/apps/mpay/contract/BaseContract.ts
|
|
696
|
-
var
|
|
732
|
+
var import_transactions4 = require("@mysten/sui.js/transactions");
|
|
697
733
|
|
|
698
734
|
// src/apps/mpay/const.ts
|
|
699
735
|
var CLOCK_ID = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
@@ -708,7 +744,7 @@ var BaseContract = class {
|
|
|
708
744
|
addContractCall(txb, input) {
|
|
709
745
|
const target = `${this.config.contractId}::${this.moduleName}::${input.method}`;
|
|
710
746
|
txb.add(
|
|
711
|
-
|
|
747
|
+
import_transactions4.Transactions.MoveCall({
|
|
712
748
|
target,
|
|
713
749
|
arguments: input.arguments.map((arg) => {
|
|
714
750
|
if (arg instanceof ObjectVector) {
|
|
@@ -729,7 +765,7 @@ var BaseContract = class {
|
|
|
729
765
|
}
|
|
730
766
|
addTransactionBlock(txb, target, callArgs = [], typeArgs = []) {
|
|
731
767
|
txb.add(
|
|
732
|
-
|
|
768
|
+
import_transactions4.Transactions.MoveCall({
|
|
733
769
|
target,
|
|
734
770
|
arguments: callArgs.map((arg) => {
|
|
735
771
|
if (arg instanceof ObjectVector) {
|
|
@@ -947,7 +983,7 @@ var MPayBuilder = class {
|
|
|
947
983
|
return new CreateStreamHelper(this.globals, this.feeContract, this.streamContract);
|
|
948
984
|
}
|
|
949
985
|
setAutoClaim(streamId, enabled, coinType) {
|
|
950
|
-
const txb = new
|
|
986
|
+
const txb = new import_transactions5.TransactionBlock();
|
|
951
987
|
return this.streamContract.setAutoClaim(txb, {
|
|
952
988
|
streamId,
|
|
953
989
|
enabled,
|
|
@@ -955,21 +991,21 @@ var MPayBuilder = class {
|
|
|
955
991
|
});
|
|
956
992
|
}
|
|
957
993
|
claimStream(streamId, coinType) {
|
|
958
|
-
const txb = new
|
|
994
|
+
const txb = new import_transactions5.TransactionBlock();
|
|
959
995
|
return this.streamContract.claimStream(txb, {
|
|
960
996
|
streamId,
|
|
961
997
|
coinType
|
|
962
998
|
});
|
|
963
999
|
}
|
|
964
1000
|
claimStreamByProxy(streamId, coinType) {
|
|
965
|
-
const txb = new
|
|
1001
|
+
const txb = new import_transactions5.TransactionBlock();
|
|
966
1002
|
return this.streamContract.claimStreamByProxy(txb, {
|
|
967
1003
|
streamId,
|
|
968
1004
|
coinType
|
|
969
1005
|
});
|
|
970
1006
|
}
|
|
971
1007
|
cancelStream(streamId, coinType) {
|
|
972
|
-
const txb = new
|
|
1008
|
+
const txb = new import_transactions5.TransactionBlock();
|
|
973
1009
|
this.streamContract.cancelStream(txb, {
|
|
974
1010
|
streamId,
|
|
975
1011
|
coinType
|
|
@@ -1136,7 +1172,7 @@ var import_utils8 = require("@mysten/sui.js/utils");
|
|
|
1136
1172
|
var import_luxon4 = require("luxon");
|
|
1137
1173
|
|
|
1138
1174
|
// src/apps/mpay/stream/Stream.ts
|
|
1139
|
-
var
|
|
1175
|
+
var import_transactions6 = require("@mysten/sui.js/transactions");
|
|
1140
1176
|
var import_utils6 = require("@mysten/sui.js/utils");
|
|
1141
1177
|
var import_luxon3 = require("luxon");
|
|
1142
1178
|
|
|
@@ -1280,7 +1316,7 @@ var Stream = class _Stream {
|
|
|
1280
1316
|
if (await this.globals.walletAddress() !== this.creator) {
|
|
1281
1317
|
throw new NotCreatorError();
|
|
1282
1318
|
}
|
|
1283
|
-
const txb = new
|
|
1319
|
+
const txb = new import_transactions6.TransactionBlock();
|
|
1284
1320
|
this.streamContract.cancelStream(txb, {
|
|
1285
1321
|
streamId: this.streamId,
|
|
1286
1322
|
coinType: this.coinType
|
|
@@ -1291,7 +1327,7 @@ var Stream = class _Stream {
|
|
|
1291
1327
|
if (await this.globals.walletAddress() !== this.recipient) {
|
|
1292
1328
|
throw new NotRecipientError();
|
|
1293
1329
|
}
|
|
1294
|
-
const txb = new
|
|
1330
|
+
const txb = new import_transactions6.TransactionBlock();
|
|
1295
1331
|
this.streamContract.claimStream(txb, {
|
|
1296
1332
|
streamId: this.streamId,
|
|
1297
1333
|
coinType: this.coinType
|
|
@@ -1302,7 +1338,7 @@ var Stream = class _Stream {
|
|
|
1302
1338
|
if (await this.globals.walletAddress() !== this.recipient) {
|
|
1303
1339
|
throw new NotRecipientError();
|
|
1304
1340
|
}
|
|
1305
|
-
const txb = new
|
|
1341
|
+
const txb = new import_transactions6.TransactionBlock();
|
|
1306
1342
|
this.streamContract.setAutoClaim(txb, {
|
|
1307
1343
|
streamId: this.streamId,
|
|
1308
1344
|
coinType: this.coinType,
|
|
@@ -1311,7 +1347,7 @@ var Stream = class _Stream {
|
|
|
1311
1347
|
return txb;
|
|
1312
1348
|
}
|
|
1313
1349
|
async claimByProxy() {
|
|
1314
|
-
const txb = new
|
|
1350
|
+
const txb = new import_transactions6.TransactionBlock();
|
|
1315
1351
|
this.streamContract.claimStreamByProxy(txb, {
|
|
1316
1352
|
streamId: this.streamId,
|
|
1317
1353
|
coinType: this.coinType
|
|
@@ -2472,6 +2508,23 @@ var DecodeHelper = class {
|
|
|
2472
2508
|
}
|
|
2473
2509
|
};
|
|
2474
2510
|
|
|
2511
|
+
// src/apps/mpay/set-auto-claim-stream.ts
|
|
2512
|
+
var import_transactions7 = require("@mysten/sui.js/transactions");
|
|
2513
|
+
var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends CoreBaseIntention {
|
|
2514
|
+
constructor(data) {
|
|
2515
|
+
super(data);
|
|
2516
|
+
this.data = data;
|
|
2517
|
+
}
|
|
2518
|
+
txType;
|
|
2519
|
+
txSubType;
|
|
2520
|
+
async build() {
|
|
2521
|
+
return new import_transactions7.TransactionBlock();
|
|
2522
|
+
}
|
|
2523
|
+
static fromData(data) {
|
|
2524
|
+
return new _SetAutoClaimStreamIntention(data);
|
|
2525
|
+
}
|
|
2526
|
+
};
|
|
2527
|
+
|
|
2475
2528
|
// src/apps/mpay/helper.ts
|
|
2476
2529
|
var MPayAppHelper = class {
|
|
2477
2530
|
application = "mpay";
|
|
@@ -2488,7 +2541,44 @@ var MPayAppHelper = class {
|
|
|
2488
2541
|
intentionData: result.info
|
|
2489
2542
|
};
|
|
2490
2543
|
}
|
|
2491
|
-
|
|
2544
|
+
if (result.type === "Claim" /* CLAIM */) {
|
|
2545
|
+
return {
|
|
2546
|
+
txType: import_sui3_utils.TransactionType.Other,
|
|
2547
|
+
txSubType: import_sui3_utils.StreamEventType.Claim,
|
|
2548
|
+
intentionData: {
|
|
2549
|
+
streamId: result.streamId
|
|
2550
|
+
}
|
|
2551
|
+
};
|
|
2552
|
+
}
|
|
2553
|
+
if (result.type === "ClaimByProxy" /* CLAIM_BY_PROXY */) {
|
|
2554
|
+
return {
|
|
2555
|
+
txType: import_sui3_utils.TransactionType.Other,
|
|
2556
|
+
txSubType: import_sui3_utils.StreamEventType.SetAutoClaim,
|
|
2557
|
+
intentionData: {
|
|
2558
|
+
streamId: result.streamId
|
|
2559
|
+
}
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2562
|
+
if (result.type === "SetAutoClaim" /* SET_AUTO_CLAIM */) {
|
|
2563
|
+
return {
|
|
2564
|
+
txType: import_sui3_utils.TransactionType.Other,
|
|
2565
|
+
txSubType: import_sui3_utils.StreamEventType.SetAutoClaim,
|
|
2566
|
+
intentionData: {
|
|
2567
|
+
streamId: result.streamId,
|
|
2568
|
+
enabled: result.enabled
|
|
2569
|
+
}
|
|
2570
|
+
};
|
|
2571
|
+
}
|
|
2572
|
+
if (result.type === "Cancel" /* CANCEL */) {
|
|
2573
|
+
return {
|
|
2574
|
+
txType: import_sui3_utils.TransactionType.Other,
|
|
2575
|
+
txSubType: import_sui3_utils.StreamEventType.Cancel,
|
|
2576
|
+
intentionData: {
|
|
2577
|
+
streamId: result.streamId
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
throw new Error(`Unknown transaction type: ${result}`);
|
|
2492
2582
|
}
|
|
2493
2583
|
async build(input) {
|
|
2494
2584
|
const { network, intentionData, suiClient, account } = input;
|
|
@@ -2497,6 +2587,15 @@ var MPayAppHelper = class {
|
|
|
2497
2587
|
case import_sui3_utils.StreamEventType.Create:
|
|
2498
2588
|
intention = CreateStreamIntention.fromData(intentionData);
|
|
2499
2589
|
break;
|
|
2590
|
+
case import_sui3_utils.StreamEventType.Claim:
|
|
2591
|
+
intention = ClaimStreamIntention.fromData(intentionData);
|
|
2592
|
+
break;
|
|
2593
|
+
case import_sui3_utils.StreamEventType.SetAutoClaim:
|
|
2594
|
+
intention = SetAutoClaimStreamIntention.fromData(intentionData);
|
|
2595
|
+
break;
|
|
2596
|
+
case import_sui3_utils.StreamEventType.Cancel:
|
|
2597
|
+
intention = CancelStreamIntention.fromData(intentionData);
|
|
2598
|
+
break;
|
|
2500
2599
|
default:
|
|
2501
2600
|
throw new Error("not implemented");
|
|
2502
2601
|
}
|
|
@@ -2545,7 +2644,7 @@ var ObjectTransferIntention = class _ObjectTransferIntention extends CoreBaseInt
|
|
|
2545
2644
|
|
|
2546
2645
|
// src/apps/msafe-core/plain-payload.ts
|
|
2547
2646
|
var import_sui3_utils4 = require("@msafe/sui3-utils");
|
|
2548
|
-
var
|
|
2647
|
+
var import_transactions8 = require("@mysten/sui.js/transactions");
|
|
2549
2648
|
var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntention {
|
|
2550
2649
|
constructor(data) {
|
|
2551
2650
|
super(data);
|
|
@@ -2555,7 +2654,7 @@ var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntenti
|
|
|
2555
2654
|
txSubType;
|
|
2556
2655
|
async build(input) {
|
|
2557
2656
|
const { account } = input;
|
|
2558
|
-
const tb =
|
|
2657
|
+
const tb = import_transactions8.TransactionBlock.from(this.data.content);
|
|
2559
2658
|
if (!(0, import_sui3_utils4.isSameAddress)(tb.blockData.sender, account.address)) {
|
|
2560
2659
|
throw new Error("Invalid sender address");
|
|
2561
2660
|
}
|
|
@@ -2612,11 +2711,11 @@ var MSafeApps = class {
|
|
|
2612
2711
|
|
|
2613
2712
|
// src/apps/plain-transaction/helper.ts
|
|
2614
2713
|
var import_sui3_utils6 = require("@msafe/sui3-utils");
|
|
2615
|
-
var
|
|
2714
|
+
var import_transactions9 = require("@mysten/sui.js/transactions");
|
|
2616
2715
|
var import_utils14 = require("@mysten/sui.js/utils");
|
|
2617
2716
|
var import_sort_keys_recursive2 = __toESM(require("sort-keys-recursive"));
|
|
2618
2717
|
var PlainTransactionApplication = "msafe-plain-tx";
|
|
2619
|
-
var PlainTransactionType =
|
|
2718
|
+
var PlainTransactionType = import_sui3_utils6.TransactionSubTypes.others.plain;
|
|
2620
2719
|
var PlainTransactionHelper = class {
|
|
2621
2720
|
application;
|
|
2622
2721
|
constructor() {
|
|
@@ -2632,7 +2731,7 @@ var PlainTransactionHelper = class {
|
|
|
2632
2731
|
};
|
|
2633
2732
|
}
|
|
2634
2733
|
async build(input) {
|
|
2635
|
-
return
|
|
2734
|
+
return import_transactions9.TransactionBlock.from((0, import_utils14.fromHEX)(input.intentionData.content));
|
|
2636
2735
|
}
|
|
2637
2736
|
};
|
|
2638
2737
|
|