@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.global.js +9 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +102 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,10 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/apps/mpay/helper.ts
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
// src/apps/mpay/cancel-stream.ts
|
|
11
|
-
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
8
|
+
import { TransactionType } from "@msafe/sui3-utils";
|
|
12
9
|
|
|
13
10
|
// src/apps/msafe-core/intention.ts
|
|
14
11
|
import sortKeys from "sort-keys-recursive";
|
|
@@ -24,39 +21,6 @@ var CoreBaseIntention = class {
|
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
23
|
|
|
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
|
-
|
|
60
24
|
// src/apps/mpay/config/dev.json
|
|
61
25
|
var dev_exports = {};
|
|
62
26
|
__export(dev_exports, {
|
|
@@ -362,10 +326,10 @@ import { normalizeStructTag as normalizeStructTag3, SUI_TYPE_ARG as SUI_TYPE_ARG
|
|
|
362
326
|
import { Duration } from "luxon";
|
|
363
327
|
|
|
364
328
|
// src/apps/mpay/builder/MPayBuilder.ts
|
|
365
|
-
import { TransactionBlock as
|
|
329
|
+
import { TransactionBlock as TransactionBlock3 } from "@mysten/sui.js/transactions";
|
|
366
330
|
|
|
367
331
|
// src/apps/mpay/builder/CreateStreamHelper.ts
|
|
368
|
-
import { TransactionBlock
|
|
332
|
+
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
369
333
|
import { normalizeStructTag as normalizeStructTag2, SUI_TYPE_ARG } from "@mysten/sui.js/utils";
|
|
370
334
|
|
|
371
335
|
// src/apps/mpay/builder/const.ts
|
|
@@ -569,7 +533,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
569
533
|
};
|
|
570
534
|
}
|
|
571
535
|
async buildCreateStreamTransactionBlock(info) {
|
|
572
|
-
const txb = new
|
|
536
|
+
const txb = new TransactionBlock();
|
|
573
537
|
const paymentWithFee = this.calculateFeesInternal(info);
|
|
574
538
|
const coinReqs = this.getCreateStreamCoinRequests(info, paymentWithFee);
|
|
575
539
|
const coinResp = await this.wallet.requestCoins(coinReqs);
|
|
@@ -686,7 +650,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
686
650
|
return streamAmount * FEE_NUMERATOR / FEE_DENOMINATOR;
|
|
687
651
|
}
|
|
688
652
|
async getStreamFeeRemote(streamAmount) {
|
|
689
|
-
const txb = this.feeContract.streamingFee(new
|
|
653
|
+
const txb = this.feeContract.streamingFee(new TransactionBlock(), streamAmount);
|
|
690
654
|
const res = await this.globals.suiClient.devInspectTransactionBlock({
|
|
691
655
|
sender: await this.globals.walletAddress(),
|
|
692
656
|
transactionBlock: txb
|
|
@@ -954,7 +918,7 @@ var MPayBuilder = class {
|
|
|
954
918
|
return new CreateStreamHelper(this.globals, this.feeContract, this.streamContract);
|
|
955
919
|
}
|
|
956
920
|
setAutoClaim(streamId, enabled, coinType) {
|
|
957
|
-
const txb = new
|
|
921
|
+
const txb = new TransactionBlock3();
|
|
958
922
|
return this.streamContract.setAutoClaim(txb, {
|
|
959
923
|
streamId,
|
|
960
924
|
enabled,
|
|
@@ -962,21 +926,21 @@ var MPayBuilder = class {
|
|
|
962
926
|
});
|
|
963
927
|
}
|
|
964
928
|
claimStream(streamId, coinType) {
|
|
965
|
-
const txb = new
|
|
929
|
+
const txb = new TransactionBlock3();
|
|
966
930
|
return this.streamContract.claimStream(txb, {
|
|
967
931
|
streamId,
|
|
968
932
|
coinType
|
|
969
933
|
});
|
|
970
934
|
}
|
|
971
935
|
claimStreamByProxy(streamId, coinType) {
|
|
972
|
-
const txb = new
|
|
936
|
+
const txb = new TransactionBlock3();
|
|
973
937
|
return this.streamContract.claimStreamByProxy(txb, {
|
|
974
938
|
streamId,
|
|
975
939
|
coinType
|
|
976
940
|
});
|
|
977
941
|
}
|
|
978
942
|
cancelStream(streamId, coinType) {
|
|
979
|
-
const txb = new
|
|
943
|
+
const txb = new TransactionBlock3();
|
|
980
944
|
this.streamContract.cancelStream(txb, {
|
|
981
945
|
streamId,
|
|
982
946
|
coinType
|
|
@@ -1143,7 +1107,7 @@ import { normalizeStructTag as normalizeStructTag5, normalizeSuiAddress as norma
|
|
|
1143
1107
|
import { DateTime as DateTime4 } from "luxon";
|
|
1144
1108
|
|
|
1145
1109
|
// src/apps/mpay/stream/Stream.ts
|
|
1146
|
-
import { TransactionBlock as
|
|
1110
|
+
import { TransactionBlock as TransactionBlock4 } from "@mysten/sui.js/transactions";
|
|
1147
1111
|
import { normalizeStructTag as normalizeStructTag4, parseStructTag } from "@mysten/sui.js/utils";
|
|
1148
1112
|
import { DateTime as DateTime3 } from "luxon";
|
|
1149
1113
|
|
|
@@ -1287,7 +1251,7 @@ var Stream = class _Stream {
|
|
|
1287
1251
|
if (await this.globals.walletAddress() !== this.creator) {
|
|
1288
1252
|
throw new NotCreatorError();
|
|
1289
1253
|
}
|
|
1290
|
-
const txb = new
|
|
1254
|
+
const txb = new TransactionBlock4();
|
|
1291
1255
|
this.streamContract.cancelStream(txb, {
|
|
1292
1256
|
streamId: this.streamId,
|
|
1293
1257
|
coinType: this.coinType
|
|
@@ -1298,7 +1262,7 @@ var Stream = class _Stream {
|
|
|
1298
1262
|
if (await this.globals.walletAddress() !== this.recipient) {
|
|
1299
1263
|
throw new NotRecipientError();
|
|
1300
1264
|
}
|
|
1301
|
-
const txb = new
|
|
1265
|
+
const txb = new TransactionBlock4();
|
|
1302
1266
|
this.streamContract.claimStream(txb, {
|
|
1303
1267
|
streamId: this.streamId,
|
|
1304
1268
|
coinType: this.coinType
|
|
@@ -1309,7 +1273,7 @@ var Stream = class _Stream {
|
|
|
1309
1273
|
if (await this.globals.walletAddress() !== this.recipient) {
|
|
1310
1274
|
throw new NotRecipientError();
|
|
1311
1275
|
}
|
|
1312
|
-
const txb = new
|
|
1276
|
+
const txb = new TransactionBlock4();
|
|
1313
1277
|
this.streamContract.setAutoClaim(txb, {
|
|
1314
1278
|
streamId: this.streamId,
|
|
1315
1279
|
coinType: this.coinType,
|
|
@@ -1318,7 +1282,7 @@ var Stream = class _Stream {
|
|
|
1318
1282
|
return txb;
|
|
1319
1283
|
}
|
|
1320
1284
|
async claimByProxy() {
|
|
1321
|
-
const txb = new
|
|
1285
|
+
const txb = new TransactionBlock4();
|
|
1322
1286
|
this.streamContract.claimStreamByProxy(txb, {
|
|
1323
1287
|
streamId: this.streamId,
|
|
1324
1288
|
coinType: this.coinType
|
|
@@ -2217,6 +2181,69 @@ var MPayClient = class {
|
|
|
2217
2181
|
}
|
|
2218
2182
|
};
|
|
2219
2183
|
|
|
2184
|
+
// src/apps/mpay/cancel-stream.ts
|
|
2185
|
+
var CancelStreamIntention = class _CancelStreamIntention extends CoreBaseIntention {
|
|
2186
|
+
constructor(data) {
|
|
2187
|
+
super(data);
|
|
2188
|
+
this.data = data;
|
|
2189
|
+
}
|
|
2190
|
+
txType;
|
|
2191
|
+
txSubType;
|
|
2192
|
+
async build(input) {
|
|
2193
|
+
const { network, account } = input;
|
|
2194
|
+
const mpayClient = new MPayClient(network === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
|
|
2195
|
+
mpayClient.connectSingleWallet(new MSafeSingleWallet(account));
|
|
2196
|
+
const stream = await mpayClient.getStream(this.data.streamId);
|
|
2197
|
+
const txb = await stream.cancel();
|
|
2198
|
+
return txb;
|
|
2199
|
+
}
|
|
2200
|
+
static fromData(data) {
|
|
2201
|
+
return new _CancelStreamIntention(data);
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2204
|
+
|
|
2205
|
+
// src/apps/mpay/claim-by-proxy-stream.ts
|
|
2206
|
+
var ClaimByProxyStreamIntention = class _ClaimByProxyStreamIntention extends CoreBaseIntention {
|
|
2207
|
+
constructor(data) {
|
|
2208
|
+
super(data);
|
|
2209
|
+
this.data = data;
|
|
2210
|
+
}
|
|
2211
|
+
txType;
|
|
2212
|
+
txSubType;
|
|
2213
|
+
async build(input) {
|
|
2214
|
+
const { network, account } = input;
|
|
2215
|
+
const mpayClient = new MPayClient(network === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
|
|
2216
|
+
mpayClient.connectSingleWallet(new MSafeSingleWallet(account));
|
|
2217
|
+
const stream = await mpayClient.getStream(this.data.streamId);
|
|
2218
|
+
const txb = await stream.claimByProxy();
|
|
2219
|
+
return txb;
|
|
2220
|
+
}
|
|
2221
|
+
static fromData(data) {
|
|
2222
|
+
return new _ClaimByProxyStreamIntention(data);
|
|
2223
|
+
}
|
|
2224
|
+
};
|
|
2225
|
+
|
|
2226
|
+
// src/apps/mpay/claim-stream.ts
|
|
2227
|
+
var ClaimStreamIntention = class _ClaimStreamIntention extends CoreBaseIntention {
|
|
2228
|
+
constructor(data) {
|
|
2229
|
+
super(data);
|
|
2230
|
+
this.data = data;
|
|
2231
|
+
}
|
|
2232
|
+
txType;
|
|
2233
|
+
txSubType;
|
|
2234
|
+
async build(input) {
|
|
2235
|
+
const { network, account } = input;
|
|
2236
|
+
const mpayClient = new MPayClient(network === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
|
|
2237
|
+
mpayClient.connectSingleWallet(new MSafeSingleWallet(account));
|
|
2238
|
+
const stream = await mpayClient.getStream(this.data.streamId);
|
|
2239
|
+
const txb = await stream.claim();
|
|
2240
|
+
return txb;
|
|
2241
|
+
}
|
|
2242
|
+
static fromData(data) {
|
|
2243
|
+
return new _ClaimStreamIntention(data);
|
|
2244
|
+
}
|
|
2245
|
+
};
|
|
2246
|
+
|
|
2220
2247
|
// src/apps/mpay/create-stream.ts
|
|
2221
2248
|
var CreateStreamIntention = class _CreateStreamIntention extends CoreBaseIntention {
|
|
2222
2249
|
constructor(data) {
|
|
@@ -2596,7 +2623,6 @@ var DecodeHelper = class {
|
|
|
2596
2623
|
};
|
|
2597
2624
|
|
|
2598
2625
|
// src/apps/mpay/set-auto-claim-stream.ts
|
|
2599
|
-
import { TransactionBlock as TransactionBlock7 } from "@mysten/sui.js/transactions";
|
|
2600
2626
|
var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends CoreBaseIntention {
|
|
2601
2627
|
constructor(data) {
|
|
2602
2628
|
super(data);
|
|
@@ -2604,8 +2630,13 @@ var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends Cor
|
|
|
2604
2630
|
}
|
|
2605
2631
|
txType;
|
|
2606
2632
|
txSubType;
|
|
2607
|
-
async build() {
|
|
2608
|
-
|
|
2633
|
+
async build(input) {
|
|
2634
|
+
const { network, account } = input;
|
|
2635
|
+
const mpayClient = new MPayClient(network === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
|
|
2636
|
+
mpayClient.connectSingleWallet(new MSafeSingleWallet(account));
|
|
2637
|
+
const stream = await mpayClient.getStream(this.data.streamId);
|
|
2638
|
+
const txb = await stream.setAutoClaim(true);
|
|
2639
|
+
return txb;
|
|
2609
2640
|
}
|
|
2610
2641
|
static fromData(data) {
|
|
2611
2642
|
return new _SetAutoClaimStreamIntention(data);
|
|
@@ -2620,18 +2651,17 @@ var MPayAppHelper = class {
|
|
|
2620
2651
|
const globals = Globals.new(chain === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
|
|
2621
2652
|
const decoder = new DecodeHelper(globals, transactionBlock);
|
|
2622
2653
|
const result = decoder.decode();
|
|
2623
|
-
console.log("\u{1F680} ~ MPayHelper ~ deserialize ~ input:", input, result);
|
|
2624
2654
|
if (result.type === "CreateStream" /* CREATE_STREAM */) {
|
|
2625
2655
|
return {
|
|
2626
2656
|
txType: TransactionType.Other,
|
|
2627
|
-
txSubType:
|
|
2657
|
+
txSubType: result.type,
|
|
2628
2658
|
intentionData: result.info
|
|
2629
2659
|
};
|
|
2630
2660
|
}
|
|
2631
2661
|
if (result.type === "Claim" /* CLAIM */) {
|
|
2632
2662
|
return {
|
|
2633
2663
|
txType: TransactionType.Other,
|
|
2634
|
-
txSubType:
|
|
2664
|
+
txSubType: result.type,
|
|
2635
2665
|
intentionData: {
|
|
2636
2666
|
streamId: result.streamId
|
|
2637
2667
|
}
|
|
@@ -2640,7 +2670,7 @@ var MPayAppHelper = class {
|
|
|
2640
2670
|
if (result.type === "ClaimByProxy" /* CLAIM_BY_PROXY */) {
|
|
2641
2671
|
return {
|
|
2642
2672
|
txType: TransactionType.Other,
|
|
2643
|
-
txSubType:
|
|
2673
|
+
txSubType: result.type,
|
|
2644
2674
|
intentionData: {
|
|
2645
2675
|
streamId: result.streamId
|
|
2646
2676
|
}
|
|
@@ -2649,7 +2679,7 @@ var MPayAppHelper = class {
|
|
|
2649
2679
|
if (result.type === "SetAutoClaim" /* SET_AUTO_CLAIM */) {
|
|
2650
2680
|
return {
|
|
2651
2681
|
txType: TransactionType.Other,
|
|
2652
|
-
txSubType:
|
|
2682
|
+
txSubType: result.type,
|
|
2653
2683
|
intentionData: {
|
|
2654
2684
|
streamId: result.streamId,
|
|
2655
2685
|
enabled: result.enabled
|
|
@@ -2659,7 +2689,7 @@ var MPayAppHelper = class {
|
|
|
2659
2689
|
if (result.type === "Cancel" /* CANCEL */) {
|
|
2660
2690
|
return {
|
|
2661
2691
|
txType: TransactionType.Other,
|
|
2662
|
-
txSubType:
|
|
2692
|
+
txSubType: result.type,
|
|
2663
2693
|
intentionData: {
|
|
2664
2694
|
streamId: result.streamId
|
|
2665
2695
|
}
|
|
@@ -2671,16 +2701,19 @@ var MPayAppHelper = class {
|
|
|
2671
2701
|
const { network, intentionData, suiClient, account } = input;
|
|
2672
2702
|
let intention;
|
|
2673
2703
|
switch (input.txSubType) {
|
|
2674
|
-
case
|
|
2704
|
+
case "CreateStream" /* CREATE_STREAM */:
|
|
2675
2705
|
intention = CreateStreamIntention.fromData(intentionData);
|
|
2676
2706
|
break;
|
|
2677
|
-
case
|
|
2707
|
+
case "Claim" /* CLAIM */:
|
|
2678
2708
|
intention = ClaimStreamIntention.fromData(intentionData);
|
|
2679
2709
|
break;
|
|
2680
|
-
case
|
|
2710
|
+
case "ClaimByProxy" /* CLAIM_BY_PROXY */:
|
|
2711
|
+
intention = ClaimByProxyStreamIntention.fromData(intentionData);
|
|
2712
|
+
break;
|
|
2713
|
+
case "SetAutoClaim" /* SET_AUTO_CLAIM */:
|
|
2681
2714
|
intention = SetAutoClaimStreamIntention.fromData(intentionData);
|
|
2682
2715
|
break;
|
|
2683
|
-
case
|
|
2716
|
+
case "Cancel" /* CANCEL */:
|
|
2684
2717
|
intention = CancelStreamIntention.fromData(intentionData);
|
|
2685
2718
|
break;
|
|
2686
2719
|
default:
|
|
@@ -2731,7 +2764,7 @@ var ObjectTransferIntention = class _ObjectTransferIntention extends CoreBaseInt
|
|
|
2731
2764
|
|
|
2732
2765
|
// src/apps/msafe-core/plain-payload.ts
|
|
2733
2766
|
import { isSameAddress } from "@msafe/sui3-utils";
|
|
2734
|
-
import { TransactionBlock as
|
|
2767
|
+
import { TransactionBlock as TransactionBlock5 } from "@mysten/sui.js/transactions";
|
|
2735
2768
|
var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntention {
|
|
2736
2769
|
constructor(data) {
|
|
2737
2770
|
super(data);
|
|
@@ -2741,7 +2774,7 @@ var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntenti
|
|
|
2741
2774
|
txSubType;
|
|
2742
2775
|
async build(input) {
|
|
2743
2776
|
const { account } = input;
|
|
2744
|
-
const tb =
|
|
2777
|
+
const tb = TransactionBlock5.from(this.data.content);
|
|
2745
2778
|
if (!isSameAddress(tb.blockData.sender, account.address)) {
|
|
2746
2779
|
throw new Error("Invalid sender address");
|
|
2747
2780
|
}
|
|
@@ -2798,7 +2831,7 @@ var MSafeApps = class {
|
|
|
2798
2831
|
|
|
2799
2832
|
// src/apps/plain-transaction/helper.ts
|
|
2800
2833
|
import { TransactionSubTypes as TransactionSubTypes2, TransactionType as TransactionType6 } from "@msafe/sui3-utils";
|
|
2801
|
-
import { TransactionBlock as
|
|
2834
|
+
import { TransactionBlock as TransactionBlock6 } from "@mysten/sui.js/transactions";
|
|
2802
2835
|
import { fromHEX, toHEX } from "@mysten/sui.js/utils";
|
|
2803
2836
|
import sortKeys2 from "sort-keys-recursive";
|
|
2804
2837
|
var PlainTransactionApplication = "msafe-plain-tx";
|
|
@@ -2818,7 +2851,7 @@ var PlainTransactionHelper = class {
|
|
|
2818
2851
|
};
|
|
2819
2852
|
}
|
|
2820
2853
|
async build(input) {
|
|
2821
|
-
return
|
|
2854
|
+
return TransactionBlock6.from(fromHEX(input.intentionData.content));
|
|
2822
2855
|
}
|
|
2823
2856
|
};
|
|
2824
2857
|
|