@msafe/sui-app-store 0.0.16 → 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
@@ -568,8 +532,9 @@ function isSameTarget(target1, target2) {
568
532
  var GAS_OBJECT_SPEC = "txn.gas";
569
533
 
570
534
  // src/apps/mpay/utils/random.ts
535
+ var import_nanoid = require("nanoid");
571
536
  function generateGroupId() {
572
- return "nanoid()";
537
+ return (0, import_nanoid.nanoid)();
573
538
  }
574
539
 
575
540
  // src/apps/mpay/builder/CreateStreamHelper.ts
@@ -598,7 +563,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
598
563
  };
599
564
  }
600
565
  async buildCreateStreamTransactionBlock(info) {
601
- const txb = new import_transactions3.TransactionBlock();
566
+ const txb = new import_transactions.TransactionBlock();
602
567
  const paymentWithFee = this.calculateFeesInternal(info);
603
568
  const coinReqs = this.getCreateStreamCoinRequests(info, paymentWithFee);
604
569
  const coinResp = await this.wallet.requestCoins(coinReqs);
@@ -715,7 +680,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
715
680
  return streamAmount * FEE_NUMERATOR / FEE_DENOMINATOR;
716
681
  }
717
682
  async getStreamFeeRemote(streamAmount) {
718
- const txb = this.feeContract.streamingFee(new import_transactions3.TransactionBlock(), streamAmount);
683
+ const txb = this.feeContract.streamingFee(new import_transactions.TransactionBlock(), streamAmount);
719
684
  const res = await this.globals.suiClient.devInspectTransactionBlock({
720
685
  sender: await this.globals.walletAddress(),
721
686
  transactionBlock: txb
@@ -729,7 +694,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
729
694
  };
730
695
 
731
696
  // src/apps/mpay/contract/BaseContract.ts
732
- var import_transactions4 = require("@mysten/sui.js/transactions");
697
+ var import_transactions2 = require("@mysten/sui.js/transactions");
733
698
 
734
699
  // src/apps/mpay/const.ts
735
700
  var CLOCK_ID = "0x0000000000000000000000000000000000000000000000000000000000000006";
@@ -744,7 +709,7 @@ var BaseContract = class {
744
709
  addContractCall(txb, input) {
745
710
  const target = `${this.config.contractId}::${this.moduleName}::${input.method}`;
746
711
  txb.add(
747
- import_transactions4.Transactions.MoveCall({
712
+ import_transactions2.Transactions.MoveCall({
748
713
  target,
749
714
  arguments: input.arguments.map((arg) => {
750
715
  if (arg instanceof ObjectVector) {
@@ -765,7 +730,7 @@ var BaseContract = class {
765
730
  }
766
731
  addTransactionBlock(txb, target, callArgs = [], typeArgs = []) {
767
732
  txb.add(
768
- import_transactions4.Transactions.MoveCall({
733
+ import_transactions2.Transactions.MoveCall({
769
734
  target,
770
735
  arguments: callArgs.map((arg) => {
771
736
  if (arg instanceof ObjectVector) {
@@ -983,7 +948,7 @@ var MPayBuilder = class {
983
948
  return new CreateStreamHelper(this.globals, this.feeContract, this.streamContract);
984
949
  }
985
950
  setAutoClaim(streamId, enabled, coinType) {
986
- const txb = new import_transactions5.TransactionBlock();
951
+ const txb = new import_transactions3.TransactionBlock();
987
952
  return this.streamContract.setAutoClaim(txb, {
988
953
  streamId,
989
954
  enabled,
@@ -991,21 +956,21 @@ var MPayBuilder = class {
991
956
  });
992
957
  }
993
958
  claimStream(streamId, coinType) {
994
- const txb = new import_transactions5.TransactionBlock();
959
+ const txb = new import_transactions3.TransactionBlock();
995
960
  return this.streamContract.claimStream(txb, {
996
961
  streamId,
997
962
  coinType
998
963
  });
999
964
  }
1000
965
  claimStreamByProxy(streamId, coinType) {
1001
- const txb = new import_transactions5.TransactionBlock();
966
+ const txb = new import_transactions3.TransactionBlock();
1002
967
  return this.streamContract.claimStreamByProxy(txb, {
1003
968
  streamId,
1004
969
  coinType
1005
970
  });
1006
971
  }
1007
972
  cancelStream(streamId, coinType) {
1008
- const txb = new import_transactions5.TransactionBlock();
973
+ const txb = new import_transactions3.TransactionBlock();
1009
974
  this.streamContract.cancelStream(txb, {
1010
975
  streamId,
1011
976
  coinType
@@ -1172,7 +1137,7 @@ var import_utils8 = require("@mysten/sui.js/utils");
1172
1137
  var import_luxon4 = require("luxon");
1173
1138
 
1174
1139
  // src/apps/mpay/stream/Stream.ts
1175
- var import_transactions6 = require("@mysten/sui.js/transactions");
1140
+ var import_transactions4 = require("@mysten/sui.js/transactions");
1176
1141
  var import_utils6 = require("@mysten/sui.js/utils");
1177
1142
  var import_luxon3 = require("luxon");
1178
1143
 
@@ -1316,7 +1281,7 @@ var Stream = class _Stream {
1316
1281
  if (await this.globals.walletAddress() !== this.creator) {
1317
1282
  throw new NotCreatorError();
1318
1283
  }
1319
- const txb = new import_transactions6.TransactionBlock();
1284
+ const txb = new import_transactions4.TransactionBlock();
1320
1285
  this.streamContract.cancelStream(txb, {
1321
1286
  streamId: this.streamId,
1322
1287
  coinType: this.coinType
@@ -1327,7 +1292,7 @@ var Stream = class _Stream {
1327
1292
  if (await this.globals.walletAddress() !== this.recipient) {
1328
1293
  throw new NotRecipientError();
1329
1294
  }
1330
- const txb = new import_transactions6.TransactionBlock();
1295
+ const txb = new import_transactions4.TransactionBlock();
1331
1296
  this.streamContract.claimStream(txb, {
1332
1297
  streamId: this.streamId,
1333
1298
  coinType: this.coinType
@@ -1338,7 +1303,7 @@ var Stream = class _Stream {
1338
1303
  if (await this.globals.walletAddress() !== this.recipient) {
1339
1304
  throw new NotRecipientError();
1340
1305
  }
1341
- const txb = new import_transactions6.TransactionBlock();
1306
+ const txb = new import_transactions4.TransactionBlock();
1342
1307
  this.streamContract.setAutoClaim(txb, {
1343
1308
  streamId: this.streamId,
1344
1309
  coinType: this.coinType,
@@ -1347,7 +1312,7 @@ var Stream = class _Stream {
1347
1312
  return txb;
1348
1313
  }
1349
1314
  async claimByProxy() {
1350
- const txb = new import_transactions6.TransactionBlock();
1315
+ const txb = new import_transactions4.TransactionBlock();
1351
1316
  this.streamContract.claimStreamByProxy(txb, {
1352
1317
  streamId: this.streamId,
1353
1318
  coinType: this.coinType
@@ -2246,6 +2211,69 @@ var MPayClient = class {
2246
2211
  }
2247
2212
  };
2248
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
+
2249
2277
  // src/apps/mpay/create-stream.ts
2250
2278
  var CreateStreamIntention = class _CreateStreamIntention extends CoreBaseIntention {
2251
2279
  constructor(data) {
@@ -2625,7 +2653,6 @@ var DecodeHelper = class {
2625
2653
  };
2626
2654
 
2627
2655
  // src/apps/mpay/set-auto-claim-stream.ts
2628
- var import_transactions7 = require("@mysten/sui.js/transactions");
2629
2656
  var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends CoreBaseIntention {
2630
2657
  constructor(data) {
2631
2658
  super(data);
@@ -2633,8 +2660,13 @@ var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends Cor
2633
2660
  }
2634
2661
  txType;
2635
2662
  txSubType;
2636
- async build() {
2637
- 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;
2638
2670
  }
2639
2671
  static fromData(data) {
2640
2672
  return new _SetAutoClaimStreamIntention(data);
@@ -2649,18 +2681,17 @@ var MPayAppHelper = class {
2649
2681
  const globals = Globals.new(chain === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
2650
2682
  const decoder = new DecodeHelper(globals, transactionBlock);
2651
2683
  const result = decoder.decode();
2652
- console.log("\u{1F680} ~ MPayHelper ~ deserialize ~ input:", input, result);
2653
2684
  if (result.type === "CreateStream" /* CREATE_STREAM */) {
2654
2685
  return {
2655
2686
  txType: import_sui3_utils.TransactionType.Other,
2656
- txSubType: import_sui3_utils.StreamEventType.Create,
2687
+ txSubType: result.type,
2657
2688
  intentionData: result.info
2658
2689
  };
2659
2690
  }
2660
2691
  if (result.type === "Claim" /* CLAIM */) {
2661
2692
  return {
2662
2693
  txType: import_sui3_utils.TransactionType.Other,
2663
- txSubType: import_sui3_utils.StreamEventType.Claim,
2694
+ txSubType: result.type,
2664
2695
  intentionData: {
2665
2696
  streamId: result.streamId
2666
2697
  }
@@ -2669,7 +2700,7 @@ var MPayAppHelper = class {
2669
2700
  if (result.type === "ClaimByProxy" /* CLAIM_BY_PROXY */) {
2670
2701
  return {
2671
2702
  txType: import_sui3_utils.TransactionType.Other,
2672
- txSubType: import_sui3_utils.StreamEventType.SetAutoClaim,
2703
+ txSubType: result.type,
2673
2704
  intentionData: {
2674
2705
  streamId: result.streamId
2675
2706
  }
@@ -2678,7 +2709,7 @@ var MPayAppHelper = class {
2678
2709
  if (result.type === "SetAutoClaim" /* SET_AUTO_CLAIM */) {
2679
2710
  return {
2680
2711
  txType: import_sui3_utils.TransactionType.Other,
2681
- txSubType: import_sui3_utils.StreamEventType.SetAutoClaim,
2712
+ txSubType: result.type,
2682
2713
  intentionData: {
2683
2714
  streamId: result.streamId,
2684
2715
  enabled: result.enabled
@@ -2688,7 +2719,7 @@ var MPayAppHelper = class {
2688
2719
  if (result.type === "Cancel" /* CANCEL */) {
2689
2720
  return {
2690
2721
  txType: import_sui3_utils.TransactionType.Other,
2691
- txSubType: import_sui3_utils.StreamEventType.Cancel,
2722
+ txSubType: result.type,
2692
2723
  intentionData: {
2693
2724
  streamId: result.streamId
2694
2725
  }
@@ -2700,16 +2731,19 @@ var MPayAppHelper = class {
2700
2731
  const { network, intentionData, suiClient, account } = input;
2701
2732
  let intention;
2702
2733
  switch (input.txSubType) {
2703
- case import_sui3_utils.StreamEventType.Create:
2734
+ case "CreateStream" /* CREATE_STREAM */:
2704
2735
  intention = CreateStreamIntention.fromData(intentionData);
2705
2736
  break;
2706
- case import_sui3_utils.StreamEventType.Claim:
2737
+ case "Claim" /* CLAIM */:
2707
2738
  intention = ClaimStreamIntention.fromData(intentionData);
2708
2739
  break;
2709
- 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 */:
2710
2744
  intention = SetAutoClaimStreamIntention.fromData(intentionData);
2711
2745
  break;
2712
- case import_sui3_utils.StreamEventType.Cancel:
2746
+ case "Cancel" /* CANCEL */:
2713
2747
  intention = CancelStreamIntention.fromData(intentionData);
2714
2748
  break;
2715
2749
  default:
@@ -2760,7 +2794,7 @@ var ObjectTransferIntention = class _ObjectTransferIntention extends CoreBaseInt
2760
2794
 
2761
2795
  // src/apps/msafe-core/plain-payload.ts
2762
2796
  var import_sui3_utils4 = require("@msafe/sui3-utils");
2763
- var import_transactions8 = require("@mysten/sui.js/transactions");
2797
+ var import_transactions5 = require("@mysten/sui.js/transactions");
2764
2798
  var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntention {
2765
2799
  constructor(data) {
2766
2800
  super(data);
@@ -2770,7 +2804,7 @@ var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntenti
2770
2804
  txSubType;
2771
2805
  async build(input) {
2772
2806
  const { account } = input;
2773
- const tb = import_transactions8.TransactionBlock.from(this.data.content);
2807
+ const tb = import_transactions5.TransactionBlock.from(this.data.content);
2774
2808
  if (!(0, import_sui3_utils4.isSameAddress)(tb.blockData.sender, account.address)) {
2775
2809
  throw new Error("Invalid sender address");
2776
2810
  }
@@ -2827,7 +2861,7 @@ var MSafeApps = class {
2827
2861
 
2828
2862
  // src/apps/plain-transaction/helper.ts
2829
2863
  var import_sui3_utils6 = require("@msafe/sui3-utils");
2830
- var import_transactions9 = require("@mysten/sui.js/transactions");
2864
+ var import_transactions6 = require("@mysten/sui.js/transactions");
2831
2865
  var import_utils15 = require("@mysten/sui.js/utils");
2832
2866
  var import_sort_keys_recursive2 = __toESM(require("sort-keys-recursive"));
2833
2867
  var PlainTransactionApplication = "msafe-plain-tx";
@@ -2847,7 +2881,7 @@ var PlainTransactionHelper = class {
2847
2881
  };
2848
2882
  }
2849
2883
  async build(input) {
2850
- 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));
2851
2885
  }
2852
2886
  };
2853
2887