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