@msafe/sui-app-store 0.0.17 → 0.0.19

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