@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.global.js +9 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +104 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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
|
|
@@ -538,8 +502,9 @@ function isSameTarget(target1, target2) {
|
|
|
538
502
|
var GAS_OBJECT_SPEC = "txn.gas";
|
|
539
503
|
|
|
540
504
|
// src/apps/mpay/utils/random.ts
|
|
505
|
+
import { nanoid } from "nanoid";
|
|
541
506
|
function generateGroupId() {
|
|
542
|
-
return
|
|
507
|
+
return nanoid();
|
|
543
508
|
}
|
|
544
509
|
|
|
545
510
|
// src/apps/mpay/builder/CreateStreamHelper.ts
|
|
@@ -568,7 +533,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
568
533
|
};
|
|
569
534
|
}
|
|
570
535
|
async buildCreateStreamTransactionBlock(info) {
|
|
571
|
-
const txb = new
|
|
536
|
+
const txb = new TransactionBlock();
|
|
572
537
|
const paymentWithFee = this.calculateFeesInternal(info);
|
|
573
538
|
const coinReqs = this.getCreateStreamCoinRequests(info, paymentWithFee);
|
|
574
539
|
const coinResp = await this.wallet.requestCoins(coinReqs);
|
|
@@ -685,7 +650,7 @@ var CreateStreamHelper = class _CreateStreamHelper {
|
|
|
685
650
|
return streamAmount * FEE_NUMERATOR / FEE_DENOMINATOR;
|
|
686
651
|
}
|
|
687
652
|
async getStreamFeeRemote(streamAmount) {
|
|
688
|
-
const txb = this.feeContract.streamingFee(new
|
|
653
|
+
const txb = this.feeContract.streamingFee(new TransactionBlock(), streamAmount);
|
|
689
654
|
const res = await this.globals.suiClient.devInspectTransactionBlock({
|
|
690
655
|
sender: await this.globals.walletAddress(),
|
|
691
656
|
transactionBlock: txb
|
|
@@ -953,7 +918,7 @@ var MPayBuilder = class {
|
|
|
953
918
|
return new CreateStreamHelper(this.globals, this.feeContract, this.streamContract);
|
|
954
919
|
}
|
|
955
920
|
setAutoClaim(streamId, enabled, coinType) {
|
|
956
|
-
const txb = new
|
|
921
|
+
const txb = new TransactionBlock3();
|
|
957
922
|
return this.streamContract.setAutoClaim(txb, {
|
|
958
923
|
streamId,
|
|
959
924
|
enabled,
|
|
@@ -961,21 +926,21 @@ var MPayBuilder = class {
|
|
|
961
926
|
});
|
|
962
927
|
}
|
|
963
928
|
claimStream(streamId, coinType) {
|
|
964
|
-
const txb = new
|
|
929
|
+
const txb = new TransactionBlock3();
|
|
965
930
|
return this.streamContract.claimStream(txb, {
|
|
966
931
|
streamId,
|
|
967
932
|
coinType
|
|
968
933
|
});
|
|
969
934
|
}
|
|
970
935
|
claimStreamByProxy(streamId, coinType) {
|
|
971
|
-
const txb = new
|
|
936
|
+
const txb = new TransactionBlock3();
|
|
972
937
|
return this.streamContract.claimStreamByProxy(txb, {
|
|
973
938
|
streamId,
|
|
974
939
|
coinType
|
|
975
940
|
});
|
|
976
941
|
}
|
|
977
942
|
cancelStream(streamId, coinType) {
|
|
978
|
-
const txb = new
|
|
943
|
+
const txb = new TransactionBlock3();
|
|
979
944
|
this.streamContract.cancelStream(txb, {
|
|
980
945
|
streamId,
|
|
981
946
|
coinType
|
|
@@ -1142,7 +1107,7 @@ import { normalizeStructTag as normalizeStructTag5, normalizeSuiAddress as norma
|
|
|
1142
1107
|
import { DateTime as DateTime4 } from "luxon";
|
|
1143
1108
|
|
|
1144
1109
|
// src/apps/mpay/stream/Stream.ts
|
|
1145
|
-
import { TransactionBlock as
|
|
1110
|
+
import { TransactionBlock as TransactionBlock4 } from "@mysten/sui.js/transactions";
|
|
1146
1111
|
import { normalizeStructTag as normalizeStructTag4, parseStructTag } from "@mysten/sui.js/utils";
|
|
1147
1112
|
import { DateTime as DateTime3 } from "luxon";
|
|
1148
1113
|
|
|
@@ -1286,7 +1251,7 @@ var Stream = class _Stream {
|
|
|
1286
1251
|
if (await this.globals.walletAddress() !== this.creator) {
|
|
1287
1252
|
throw new NotCreatorError();
|
|
1288
1253
|
}
|
|
1289
|
-
const txb = new
|
|
1254
|
+
const txb = new TransactionBlock4();
|
|
1290
1255
|
this.streamContract.cancelStream(txb, {
|
|
1291
1256
|
streamId: this.streamId,
|
|
1292
1257
|
coinType: this.coinType
|
|
@@ -1297,7 +1262,7 @@ var Stream = class _Stream {
|
|
|
1297
1262
|
if (await this.globals.walletAddress() !== this.recipient) {
|
|
1298
1263
|
throw new NotRecipientError();
|
|
1299
1264
|
}
|
|
1300
|
-
const txb = new
|
|
1265
|
+
const txb = new TransactionBlock4();
|
|
1301
1266
|
this.streamContract.claimStream(txb, {
|
|
1302
1267
|
streamId: this.streamId,
|
|
1303
1268
|
coinType: this.coinType
|
|
@@ -1308,7 +1273,7 @@ var Stream = class _Stream {
|
|
|
1308
1273
|
if (await this.globals.walletAddress() !== this.recipient) {
|
|
1309
1274
|
throw new NotRecipientError();
|
|
1310
1275
|
}
|
|
1311
|
-
const txb = new
|
|
1276
|
+
const txb = new TransactionBlock4();
|
|
1312
1277
|
this.streamContract.setAutoClaim(txb, {
|
|
1313
1278
|
streamId: this.streamId,
|
|
1314
1279
|
coinType: this.coinType,
|
|
@@ -1317,7 +1282,7 @@ var Stream = class _Stream {
|
|
|
1317
1282
|
return txb;
|
|
1318
1283
|
}
|
|
1319
1284
|
async claimByProxy() {
|
|
1320
|
-
const txb = new
|
|
1285
|
+
const txb = new TransactionBlock4();
|
|
1321
1286
|
this.streamContract.claimStreamByProxy(txb, {
|
|
1322
1287
|
streamId: this.streamId,
|
|
1323
1288
|
coinType: this.coinType
|
|
@@ -2216,6 +2181,69 @@ var MPayClient = class {
|
|
|
2216
2181
|
}
|
|
2217
2182
|
};
|
|
2218
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
|
+
|
|
2219
2247
|
// src/apps/mpay/create-stream.ts
|
|
2220
2248
|
var CreateStreamIntention = class _CreateStreamIntention extends CoreBaseIntention {
|
|
2221
2249
|
constructor(data) {
|
|
@@ -2595,7 +2623,6 @@ var DecodeHelper = class {
|
|
|
2595
2623
|
};
|
|
2596
2624
|
|
|
2597
2625
|
// src/apps/mpay/set-auto-claim-stream.ts
|
|
2598
|
-
import { TransactionBlock as TransactionBlock7 } from "@mysten/sui.js/transactions";
|
|
2599
2626
|
var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends CoreBaseIntention {
|
|
2600
2627
|
constructor(data) {
|
|
2601
2628
|
super(data);
|
|
@@ -2603,8 +2630,13 @@ var SetAutoClaimStreamIntention = class _SetAutoClaimStreamIntention extends Cor
|
|
|
2603
2630
|
}
|
|
2604
2631
|
txType;
|
|
2605
2632
|
txSubType;
|
|
2606
|
-
async build() {
|
|
2607
|
-
|
|
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;
|
|
2608
2640
|
}
|
|
2609
2641
|
static fromData(data) {
|
|
2610
2642
|
return new _SetAutoClaimStreamIntention(data);
|
|
@@ -2619,18 +2651,17 @@ var MPayAppHelper = class {
|
|
|
2619
2651
|
const globals = Globals.new(chain === "sui:mainnet" ? "prod" /* prod */ : "dev" /* dev */);
|
|
2620
2652
|
const decoder = new DecodeHelper(globals, transactionBlock);
|
|
2621
2653
|
const result = decoder.decode();
|
|
2622
|
-
console.log("\u{1F680} ~ MPayHelper ~ deserialize ~ input:", input, result);
|
|
2623
2654
|
if (result.type === "CreateStream" /* CREATE_STREAM */) {
|
|
2624
2655
|
return {
|
|
2625
2656
|
txType: TransactionType.Other,
|
|
2626
|
-
txSubType:
|
|
2657
|
+
txSubType: result.type,
|
|
2627
2658
|
intentionData: result.info
|
|
2628
2659
|
};
|
|
2629
2660
|
}
|
|
2630
2661
|
if (result.type === "Claim" /* CLAIM */) {
|
|
2631
2662
|
return {
|
|
2632
2663
|
txType: TransactionType.Other,
|
|
2633
|
-
txSubType:
|
|
2664
|
+
txSubType: result.type,
|
|
2634
2665
|
intentionData: {
|
|
2635
2666
|
streamId: result.streamId
|
|
2636
2667
|
}
|
|
@@ -2639,7 +2670,7 @@ var MPayAppHelper = class {
|
|
|
2639
2670
|
if (result.type === "ClaimByProxy" /* CLAIM_BY_PROXY */) {
|
|
2640
2671
|
return {
|
|
2641
2672
|
txType: TransactionType.Other,
|
|
2642
|
-
txSubType:
|
|
2673
|
+
txSubType: result.type,
|
|
2643
2674
|
intentionData: {
|
|
2644
2675
|
streamId: result.streamId
|
|
2645
2676
|
}
|
|
@@ -2648,7 +2679,7 @@ var MPayAppHelper = class {
|
|
|
2648
2679
|
if (result.type === "SetAutoClaim" /* SET_AUTO_CLAIM */) {
|
|
2649
2680
|
return {
|
|
2650
2681
|
txType: TransactionType.Other,
|
|
2651
|
-
txSubType:
|
|
2682
|
+
txSubType: result.type,
|
|
2652
2683
|
intentionData: {
|
|
2653
2684
|
streamId: result.streamId,
|
|
2654
2685
|
enabled: result.enabled
|
|
@@ -2658,7 +2689,7 @@ var MPayAppHelper = class {
|
|
|
2658
2689
|
if (result.type === "Cancel" /* CANCEL */) {
|
|
2659
2690
|
return {
|
|
2660
2691
|
txType: TransactionType.Other,
|
|
2661
|
-
txSubType:
|
|
2692
|
+
txSubType: result.type,
|
|
2662
2693
|
intentionData: {
|
|
2663
2694
|
streamId: result.streamId
|
|
2664
2695
|
}
|
|
@@ -2670,16 +2701,19 @@ var MPayAppHelper = class {
|
|
|
2670
2701
|
const { network, intentionData, suiClient, account } = input;
|
|
2671
2702
|
let intention;
|
|
2672
2703
|
switch (input.txSubType) {
|
|
2673
|
-
case
|
|
2704
|
+
case "CreateStream" /* CREATE_STREAM */:
|
|
2674
2705
|
intention = CreateStreamIntention.fromData(intentionData);
|
|
2675
2706
|
break;
|
|
2676
|
-
case
|
|
2707
|
+
case "Claim" /* CLAIM */:
|
|
2677
2708
|
intention = ClaimStreamIntention.fromData(intentionData);
|
|
2678
2709
|
break;
|
|
2679
|
-
case
|
|
2710
|
+
case "ClaimByProxy" /* CLAIM_BY_PROXY */:
|
|
2711
|
+
intention = ClaimByProxyStreamIntention.fromData(intentionData);
|
|
2712
|
+
break;
|
|
2713
|
+
case "SetAutoClaim" /* SET_AUTO_CLAIM */:
|
|
2680
2714
|
intention = SetAutoClaimStreamIntention.fromData(intentionData);
|
|
2681
2715
|
break;
|
|
2682
|
-
case
|
|
2716
|
+
case "Cancel" /* CANCEL */:
|
|
2683
2717
|
intention = CancelStreamIntention.fromData(intentionData);
|
|
2684
2718
|
break;
|
|
2685
2719
|
default:
|
|
@@ -2730,7 +2764,7 @@ var ObjectTransferIntention = class _ObjectTransferIntention extends CoreBaseInt
|
|
|
2730
2764
|
|
|
2731
2765
|
// src/apps/msafe-core/plain-payload.ts
|
|
2732
2766
|
import { isSameAddress } from "@msafe/sui3-utils";
|
|
2733
|
-
import { TransactionBlock as
|
|
2767
|
+
import { TransactionBlock as TransactionBlock5 } from "@mysten/sui.js/transactions";
|
|
2734
2768
|
var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntention {
|
|
2735
2769
|
constructor(data) {
|
|
2736
2770
|
super(data);
|
|
@@ -2740,7 +2774,7 @@ var PlainPayloadIntention = class _PlainPayloadIntention extends CoreBaseIntenti
|
|
|
2740
2774
|
txSubType;
|
|
2741
2775
|
async build(input) {
|
|
2742
2776
|
const { account } = input;
|
|
2743
|
-
const tb =
|
|
2777
|
+
const tb = TransactionBlock5.from(this.data.content);
|
|
2744
2778
|
if (!isSameAddress(tb.blockData.sender, account.address)) {
|
|
2745
2779
|
throw new Error("Invalid sender address");
|
|
2746
2780
|
}
|
|
@@ -2797,7 +2831,7 @@ var MSafeApps = class {
|
|
|
2797
2831
|
|
|
2798
2832
|
// src/apps/plain-transaction/helper.ts
|
|
2799
2833
|
import { TransactionSubTypes as TransactionSubTypes2, TransactionType as TransactionType6 } from "@msafe/sui3-utils";
|
|
2800
|
-
import { TransactionBlock as
|
|
2834
|
+
import { TransactionBlock as TransactionBlock6 } from "@mysten/sui.js/transactions";
|
|
2801
2835
|
import { fromHEX, toHEX } from "@mysten/sui.js/utils";
|
|
2802
2836
|
import sortKeys2 from "sort-keys-recursive";
|
|
2803
2837
|
var PlainTransactionApplication = "msafe-plain-tx";
|
|
@@ -2817,7 +2851,7 @@ var PlainTransactionHelper = class {
|
|
|
2817
2851
|
};
|
|
2818
2852
|
}
|
|
2819
2853
|
async build(input) {
|
|
2820
|
-
return
|
|
2854
|
+
return TransactionBlock6.from(fromHEX(input.intentionData.content));
|
|
2821
2855
|
}
|
|
2822
2856
|
};
|
|
2823
2857
|
|