@msafe/sui-app-store 0.0.17 → 0.0.18

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.js CHANGED
@@ -37,9 +37,6 @@ 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
40
  // src/apps/msafe-core/intention.ts
44
41
  var import_sort_keys_recursive = __toESM(require("sort-keys-recursive"));
45
42
  var CoreBaseIntention = class {
@@ -54,39 +51,6 @@ var CoreBaseIntention = class {
54
51
  }
55
52
  };
56
53
 
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
-
90
54
  // src/apps/mpay/config/dev.json
91
55
  var dev_exports = {};
92
56
  __export(dev_exports, {
@@ -392,10 +356,10 @@ var import_utils5 = require("@mysten/sui.js/utils");
392
356
  var import_luxon = require("luxon");
393
357
 
394
358
  // src/apps/mpay/builder/MPayBuilder.ts
395
- var import_transactions5 = require("@mysten/sui.js/transactions");
359
+ var import_transactions3 = require("@mysten/sui.js/transactions");
396
360
 
397
361
  // src/apps/mpay/builder/CreateStreamHelper.ts
398
- var import_transactions3 = require("@mysten/sui.js/transactions");
362
+ var import_transactions = require("@mysten/sui.js/transactions");
399
363
  var import_utils3 = require("@mysten/sui.js/utils");
400
364
 
401
365
  // src/apps/mpay/builder/const.ts
@@ -599,7 +563,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
599
563
  };
600
564
  }
601
565
  async buildCreateStreamTransactionBlock(info) {
602
- const txb = new import_transactions3.TransactionBlock();
566
+ const txb = new import_transactions.TransactionBlock();
603
567
  const paymentWithFee = this.calculateFeesInternal(info);
604
568
  const coinReqs = this.getCreateStreamCoinRequests(info, paymentWithFee);
605
569
  const coinResp = await this.wallet.requestCoins(coinReqs);
@@ -716,7 +680,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
716
680
  return streamAmount * FEE_NUMERATOR / FEE_DENOMINATOR;
717
681
  }
718
682
  async getStreamFeeRemote(streamAmount) {
719
- const txb = this.feeContract.streamingFee(new import_transactions3.TransactionBlock(), streamAmount);
683
+ const txb = this.feeContract.streamingFee(new import_transactions.TransactionBlock(), streamAmount);
720
684
  const res = await this.globals.suiClient.devInspectTransactionBlock({
721
685
  sender: await this.globals.walletAddress(),
722
686
  transactionBlock: txb
@@ -730,7 +694,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
730
694
  };
731
695
 
732
696
  // src/apps/mpay/contract/BaseContract.ts
733
- var import_transactions4 = require("@mysten/sui.js/transactions");
697
+ var import_transactions2 = require("@mysten/sui.js/transactions");
734
698
 
735
699
  // src/apps/mpay/const.ts
736
700
  var CLOCK_ID = "0x0000000000000000000000000000000000000000000000000000000000000006";
@@ -745,7 +709,7 @@ var BaseContract = class {
745
709
  addContractCall(txb, input) {
746
710
  const target = `${this.config.contractId}::${this.moduleName}::${input.method}`;
747
711
  txb.add(
748
- import_transactions4.Transactions.MoveCall({
712
+ import_transactions2.Transactions.MoveCall({
749
713
  target,
750
714
  arguments: input.arguments.map((arg) => {
751
715
  if (arg instanceof ObjectVector) {
@@ -766,7 +730,7 @@ var BaseContract = class {
766
730
  }
767
731
  addTransactionBlock(txb, target, callArgs = [], typeArgs = []) {
768
732
  txb.add(
769
- import_transactions4.Transactions.MoveCall({
733
+ import_transactions2.Transactions.MoveCall({
770
734
  target,
771
735
  arguments: callArgs.map((arg) => {
772
736
  if (arg instanceof ObjectVector) {
@@ -984,7 +948,7 @@ var MPayBuilder = class {
984
948
  return new CreateStreamHelper(this.globals, this.feeContract, this.streamContract);
985
949
  }
986
950
  setAutoClaim(streamId, enabled, coinType) {
987
- const txb = new import_transactions5.TransactionBlock();
951
+ const txb = new import_transactions3.TransactionBlock();
988
952
  return this.streamContract.setAutoClaim(txb, {
989
953
  streamId,
990
954
  enabled,
@@ -992,21 +956,21 @@ var MPayBuilder = class {
992
956
  });
993
957
  }
994
958
  claimStream(streamId, coinType) {
995
- const txb = new import_transactions5.TransactionBlock();
959
+ const txb = new import_transactions3.TransactionBlock();
996
960
  return this.streamContract.claimStream(txb, {
997
961
  streamId,
998
962
  coinType
999
963
  });
1000
964
  }
1001
965
  claimStreamByProxy(streamId, coinType) {
1002
- const txb = new import_transactions5.TransactionBlock();
966
+ const txb = new import_transactions3.TransactionBlock();
1003
967
  return this.streamContract.claimStreamByProxy(txb, {
1004
968
  streamId,
1005
969
  coinType
1006
970
  });
1007
971
  }
1008
972
  cancelStream(streamId, coinType) {
1009
- const txb = new import_transactions5.TransactionBlock();
973
+ const txb = new import_transactions3.TransactionBlock();
1010
974
  this.streamContract.cancelStream(txb, {
1011
975
  streamId,
1012
976
  coinType
@@ -1173,7 +1137,7 @@ var import_utils8 = require("@mysten/sui.js/utils");
1173
1137
  var import_luxon4 = require("luxon");
1174
1138
 
1175
1139
  // src/apps/mpay/stream/Stream.ts
1176
- var import_transactions6 = require("@mysten/sui.js/transactions");
1140
+ var import_transactions4 = require("@mysten/sui.js/transactions");
1177
1141
  var import_utils6 = require("@mysten/sui.js/utils");
1178
1142
  var import_luxon3 = require("luxon");
1179
1143
 
@@ -1317,7 +1281,7 @@ var Stream = class _Stream {
1317
1281
  if (await this.globals.walletAddress() !== this.creator) {
1318
1282
  throw new NotCreatorError();
1319
1283
  }
1320
- const txb = new import_transactions6.TransactionBlock();
1284
+ const txb = new import_transactions4.TransactionBlock();
1321
1285
  this.streamContract.cancelStream(txb, {
1322
1286
  streamId: this.streamId,
1323
1287
  coinType: this.coinType
@@ -1328,7 +1292,7 @@ var Stream = class _Stream {
1328
1292
  if (await this.globals.walletAddress() !== this.recipient) {
1329
1293
  throw new NotRecipientError();
1330
1294
  }
1331
- const txb = new import_transactions6.TransactionBlock();
1295
+ const txb = new import_transactions4.TransactionBlock();
1332
1296
  this.streamContract.claimStream(txb, {
1333
1297
  streamId: this.streamId,
1334
1298
  coinType: this.coinType
@@ -1339,7 +1303,7 @@ var Stream = class _Stream {
1339
1303
  if (await this.globals.walletAddress() !== this.recipient) {
1340
1304
  throw new NotRecipientError();
1341
1305
  }
1342
- const txb = new import_transactions6.TransactionBlock();
1306
+ const txb = new import_transactions4.TransactionBlock();
1343
1307
  this.streamContract.setAutoClaim(txb, {
1344
1308
  streamId: this.streamId,
1345
1309
  coinType: this.coinType,
@@ -1348,7 +1312,7 @@ var Stream = class _Stream {
1348
1312
  return txb;
1349
1313
  }
1350
1314
  async claimByProxy() {
1351
- const txb = new import_transactions6.TransactionBlock();
1315
+ const txb = new import_transactions4.TransactionBlock();
1352
1316
  this.streamContract.claimStreamByProxy(txb, {
1353
1317
  streamId: this.streamId,
1354
1318
  coinType: this.coinType
@@ -2247,6 +2211,69 @@ var MPayClient = class {
2247
2211
  }
2248
2212
  };
2249
2213
 
2214
+ // src/apps/mpay/cancel-stream.ts
2215
+ var CancelStreamIntention = class _CancelStreamIntention extends CoreBaseIntention {
2216
+ constructor(data) {
2217
+ super(data);
2218
+ this.data = data;
2219
+ }
2220
+ txType;
2221
+ txSubType;
2222
+ async build(input) {
2223
+ const { network, account } = input;
2224
+ const mpayClient = new MPayClient(network === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
2225
+ mpayClient.connectSingleWallet(new MSafeSingleWallet(account));
2226
+ const stream = await mpayClient.getStream(this.data.streamId);
2227
+ const txb = await stream.cancel();
2228
+ return txb;
2229
+ }
2230
+ static fromData(data) {
2231
+ return new _CancelStreamIntention(data);
2232
+ }
2233
+ };
2234
+
2235
+ // src/apps/mpay/claim-by-proxy-stream.ts
2236
+ var ClaimByProxyStreamIntention = class _ClaimByProxyStreamIntention extends CoreBaseIntention {
2237
+ constructor(data) {
2238
+ super(data);
2239
+ this.data = data;
2240
+ }
2241
+ txType;
2242
+ txSubType;
2243
+ async build(input) {
2244
+ const { network, account } = input;
2245
+ const mpayClient = new MPayClient(network === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
2246
+ mpayClient.connectSingleWallet(new MSafeSingleWallet(account));
2247
+ const stream = await mpayClient.getStream(this.data.streamId);
2248
+ const txb = await stream.claimByProxy();
2249
+ return txb;
2250
+ }
2251
+ static fromData(data) {
2252
+ return new _ClaimByProxyStreamIntention(data);
2253
+ }
2254
+ };
2255
+
2256
+ // src/apps/mpay/claim-stream.ts
2257
+ var ClaimStreamIntention = class _ClaimStreamIntention extends CoreBaseIntention {
2258
+ constructor(data) {
2259
+ super(data);
2260
+ this.data = data;
2261
+ }
2262
+ txType;
2263
+ txSubType;
2264
+ async build(input) {
2265
+ const { network, account } = input;
2266
+ const mpayClient = new MPayClient(network === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
2267
+ mpayClient.connectSingleWallet(new MSafeSingleWallet(account));
2268
+ const stream = await mpayClient.getStream(this.data.streamId);
2269
+ const txb = await stream.claim();
2270
+ return txb;
2271
+ }
2272
+ static fromData(data) {
2273
+ return new _ClaimStreamIntention(data);
2274
+ }
2275
+ };
2276
+
2250
2277
  // src/apps/mpay/create-stream.ts
2251
2278
  var CreateStreamIntention = class _CreateStreamIntention extends CoreBaseIntention {
2252
2279
  constructor(data) {
@@ -2626,7 +2653,6 @@ var DecodeHelper = class {
2626
2653
  };
2627
2654
 
2628
2655
  // src/apps/mpay/set-auto-claim-stream.ts
2629
- var import_transactions7 = require("@mysten/sui.js/transactions");
2630
2656
  var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends CoreBaseIntention {
2631
2657
  constructor(data) {
2632
2658
  super(data);
@@ -2634,8 +2660,13 @@ var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends Cor
2634
2660
  }
2635
2661
  txType;
2636
2662
  txSubType;
2637
- async build() {
2638
- return new import_transactions7.TransactionBlock();
2663
+ async build(input) {
2664
+ const { network, account } = input;
2665
+ const mpayClient = new MPayClient(network === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
2666
+ mpayClient.connectSingleWallet(new MSafeSingleWallet(account));
2667
+ const stream = await mpayClient.getStream(this.data.streamId);
2668
+ const txb = await stream.setAutoClaim(true);
2669
+ return txb;
2639
2670
  }
2640
2671
  static fromData(data) {
2641
2672
  return new _SetAutoClaimStreamIntention(data);
@@ -2650,18 +2681,17 @@ var MPayAppHelper = class {
2650
2681
  const globals = Globals.new(chain === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
2651
2682
  const decoder = new DecodeHelper(globals, transactionBlock);
2652
2683
  const result = decoder.decode();
2653
- console.log("\u{1F680} ~ MPayHelper ~ deserialize ~ input:", input, result);
2654
2684
  if (result.type === "CreateStream" /* CREATE_STREAM */) {
2655
2685
  return {
2656
2686
  txType: import_sui3_utils.TransactionType.Other,
2657
- txSubType: import_sui3_utils.StreamEventType.Create,
2687
+ txSubType: result.type,
2658
2688
  intentionData: result.info
2659
2689
  };
2660
2690
  }
2661
2691
  if (result.type === "Claim" /* CLAIM */) {
2662
2692
  return {
2663
2693
  txType: import_sui3_utils.TransactionType.Other,
2664
- txSubType: import_sui3_utils.StreamEventType.Claim,
2694
+ txSubType: result.type,
2665
2695
  intentionData: {
2666
2696
  streamId: result.streamId
2667
2697
  }
@@ -2670,7 +2700,7 @@ var MPayAppHelper = class {
2670
2700
  if (result.type === "ClaimByProxy" /* CLAIM_BY_PROXY */) {
2671
2701
  return {
2672
2702
  txType: import_sui3_utils.TransactionType.Other,
2673
- txSubType: import_sui3_utils.StreamEventType.SetAutoClaim,
2703
+ txSubType: result.type,
2674
2704
  intentionData: {
2675
2705
  streamId: result.streamId
2676
2706
  }
@@ -2679,7 +2709,7 @@ var MPayAppHelper = class {
2679
2709
  if (result.type === "SetAutoClaim" /* SET_AUTO_CLAIM */) {
2680
2710
  return {
2681
2711
  txType: import_sui3_utils.TransactionType.Other,
2682
- txSubType: import_sui3_utils.StreamEventType.SetAutoClaim,
2712
+ txSubType: result.type,
2683
2713
  intentionData: {
2684
2714
  streamId: result.streamId,
2685
2715
  enabled: result.enabled
@@ -2689,7 +2719,7 @@ var MPayAppHelper = class {
2689
2719
  if (result.type === "Cancel" /* CANCEL */) {
2690
2720
  return {
2691
2721
  txType: import_sui3_utils.TransactionType.Other,
2692
- txSubType: import_sui3_utils.StreamEventType.Cancel,
2722
+ txSubType: result.type,
2693
2723
  intentionData: {
2694
2724
  streamId: result.streamId
2695
2725
  }
@@ -2701,16 +2731,19 @@ var MPayAppHelper = class {
2701
2731
  const { network, intentionData, suiClient, account } = input;
2702
2732
  let intention;
2703
2733
  switch (input.txSubType) {
2704
- case import_sui3_utils.StreamEventType.Create:
2734
+ case "CreateStream" /* CREATE_STREAM */:
2705
2735
  intention = CreateStreamIntention.fromData(intentionData);
2706
2736
  break;
2707
- case import_sui3_utils.StreamEventType.Claim:
2737
+ case "Claim" /* CLAIM */:
2708
2738
  intention = ClaimStreamIntention.fromData(intentionData);
2709
2739
  break;
2710
- case import_sui3_utils.StreamEventType.SetAutoClaim:
2740
+ case "ClaimByProxy" /* CLAIM_BY_PROXY */:
2741
+ intention = ClaimByProxyStreamIntention.fromData(intentionData);
2742
+ break;
2743
+ case "SetAutoClaim" /* SET_AUTO_CLAIM */:
2711
2744
  intention = SetAutoClaimStreamIntention.fromData(intentionData);
2712
2745
  break;
2713
- case import_sui3_utils.StreamEventType.Cancel:
2746
+ case "Cancel" /* CANCEL */:
2714
2747
  intention = CancelStreamIntention.fromData(intentionData);
2715
2748
  break;
2716
2749
  default:
@@ -2761,7 +2794,7 @@ var ObjectTransferIntention = class _ObjectTransferIntention extends CoreBaseInt
2761
2794
 
2762
2795
  // src/apps/msafe-core/plain-payload.ts
2763
2796
  var import_sui3_utils4 = require("@msafe/sui3-utils");
2764
- var import_transactions8 = require("@mysten/sui.js/transactions");
2797
+ var import_transactions5 = require("@mysten/sui.js/transactions");
2765
2798
  var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntention {
2766
2799
  constructor(data) {
2767
2800
  super(data);
@@ -2771,7 +2804,7 @@ var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntenti
2771
2804
  txSubType;
2772
2805
  async build(input) {
2773
2806
  const { account } = input;
2774
- const tb = import_transactions8.TransactionBlock.from(this.data.content);
2807
+ const tb = import_transactions5.TransactionBlock.from(this.data.content);
2775
2808
  if (!(0, import_sui3_utils4.isSameAddress)(tb.blockData.sender, account.address)) {
2776
2809
  throw new Error("Invalid sender address");
2777
2810
  }
@@ -2828,7 +2861,7 @@ var MSafeApps = class {
2828
2861
 
2829
2862
  // src/apps/plain-transaction/helper.ts
2830
2863
  var import_sui3_utils6 = require("@msafe/sui3-utils");
2831
- var import_transactions9 = require("@mysten/sui.js/transactions");
2864
+ var import_transactions6 = require("@mysten/sui.js/transactions");
2832
2865
  var import_utils15 = require("@mysten/sui.js/utils");
2833
2866
  var import_sort_keys_recursive2 = __toESM(require("sort-keys-recursive"));
2834
2867
  var PlainTransactionApplication = "msafe-plain-tx";
@@ -2848,7 +2881,7 @@ var PlainTransactionHelper = class {
2848
2881
  };
2849
2882
  }
2850
2883
  async build(input) {
2851
- return import_transactions9.TransactionBlock.from((0, import_utils15.fromHEX)(input.intentionData.content));
2884
+ return import_transactions6.TransactionBlock.from((0, import_utils15.fromHEX)(input.intentionData.content));
2852
2885
  }
2853
2886
  };
2854
2887