@msafe/sui-app-store 0.0.4 → 0.0.6
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.d.mts +42 -0
- package/dist/index.d.ts +31 -35
- package/dist/index.global.js +4 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +132 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +16 -8
- package/dist/index.cjs +0 -64
- package/dist/index.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,40 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
appHelpers: () => appHelpers
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
|
|
37
|
+
// src/apps/msafe-core/coin-transfer.ts
|
|
38
|
+
var import_sui3_utils = require("@msafe/sui3-utils");
|
|
39
|
+
|
|
40
|
+
// src/apps/msafe-core/intention.ts
|
|
41
|
+
var import_sort_keys_recursive = __toESM(require("sort-keys-recursive"));
|
|
42
|
+
var CoreBaseIntention = class {
|
|
43
|
+
constructor(data) {
|
|
44
|
+
this.data = data;
|
|
45
|
+
}
|
|
46
|
+
get application() {
|
|
47
|
+
return "msafe-core";
|
|
48
|
+
}
|
|
49
|
+
serialize() {
|
|
50
|
+
return JSON.stringify((0, import_sort_keys_recursive.default)(this.data));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/apps/msafe-core/coin-transfer.ts
|
|
55
|
+
var CoinTransferIntention = class _CoinTransferIntention extends CoreBaseIntention {
|
|
56
|
+
constructor(data) {
|
|
57
|
+
super(data);
|
|
58
|
+
this.data = data;
|
|
59
|
+
}
|
|
60
|
+
txType;
|
|
61
|
+
txSubType;
|
|
62
|
+
async build(input) {
|
|
63
|
+
const { suiClient, account } = input;
|
|
64
|
+
return (0, import_sui3_utils.buildCoinTransferTxb)(suiClient, this.data, account.address);
|
|
65
|
+
}
|
|
66
|
+
static fromData(data) {
|
|
67
|
+
return new _CoinTransferIntention(data);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/apps/msafe-core/object-transfer.ts
|
|
72
|
+
var import_sui3_utils2 = require("@msafe/sui3-utils");
|
|
73
|
+
var ObjectTransferIntention = class _ObjectTransferIntention extends CoreBaseIntention {
|
|
74
|
+
constructor(data) {
|
|
75
|
+
super(data);
|
|
76
|
+
this.data = data;
|
|
11
77
|
}
|
|
78
|
+
txType;
|
|
79
|
+
txSubType;
|
|
12
80
|
async build(input) {
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
81
|
+
const { suiClient, account } = input;
|
|
82
|
+
return (0, import_sui3_utils2.buildObjectTransferTxb)(suiClient, this.data, account.address);
|
|
83
|
+
}
|
|
84
|
+
static fromData(data) {
|
|
85
|
+
return new _ObjectTransferIntention(data);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/apps/msafe-core/helper.ts
|
|
90
|
+
var CoreHelper = class {
|
|
91
|
+
application;
|
|
92
|
+
constructor() {
|
|
93
|
+
this.application = "msafe-core";
|
|
94
|
+
}
|
|
95
|
+
deserialize() {
|
|
96
|
+
throw new Error("MSafe core transaction intention should be build from API");
|
|
97
|
+
}
|
|
98
|
+
async build(input) {
|
|
99
|
+
const { suiClient, account } = input;
|
|
100
|
+
let intention;
|
|
101
|
+
switch (input.txSubType) {
|
|
102
|
+
case "coin-transfer":
|
|
103
|
+
intention = CoinTransferIntention.fromData(input.intentionData);
|
|
104
|
+
break;
|
|
105
|
+
case "object-transfer":
|
|
106
|
+
intention = ObjectTransferIntention.fromData(input.intentionData);
|
|
107
|
+
break;
|
|
27
108
|
default:
|
|
28
|
-
throw new Error("
|
|
109
|
+
throw new Error("not implemented");
|
|
29
110
|
}
|
|
111
|
+
return intention.build({ suiClient, account });
|
|
30
112
|
}
|
|
31
113
|
};
|
|
32
114
|
|
|
33
|
-
// src/
|
|
115
|
+
// src/apps/registry.ts
|
|
34
116
|
var MSafeApps = class {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
117
|
+
apps;
|
|
118
|
+
constructor(apps) {
|
|
119
|
+
this.apps = new Map(apps.map((app) => [app.application, app]));
|
|
120
|
+
}
|
|
121
|
+
getAppHelper(appName) {
|
|
122
|
+
const app = this.apps.get(appName);
|
|
123
|
+
if (!app) {
|
|
124
|
+
throw new Error(`${appName} not registered`);
|
|
125
|
+
}
|
|
126
|
+
return app;
|
|
127
|
+
}
|
|
128
|
+
deserialize(appName, input) {
|
|
129
|
+
return this.getAppHelper(appName).deserialize(input);
|
|
130
|
+
}
|
|
131
|
+
build(appName, input) {
|
|
132
|
+
return this.getAppHelper(appName).build(input);
|
|
133
|
+
}
|
|
39
134
|
};
|
|
135
|
+
|
|
136
|
+
// src/index.ts
|
|
137
|
+
var appHelpers = new MSafeApps([new CoreHelper()]);
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
appHelpers
|
|
141
|
+
});
|
|
40
142
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/apps/msafe-core/coin-transfer.ts","../src/apps/msafe-core/intention.ts","../src/apps/msafe-core/object-transfer.ts","../src/apps/msafe-core/helper.ts","../src/apps/registry.ts"],"sourcesContent":["import { CoreHelper } from '@/apps/msafe-core/helper';\nimport { MSafeApps } from '@/apps/registry';\n\nexport const appHelpers = new MSafeApps([new CoreHelper()]);\n","import { TransactionType, buildCoinTransferTxb } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { WalletAccount } from '@mysten/wallet-standard';\n\nimport { CoreBaseIntention } from '@/apps/msafe-core/intention';\n\nexport interface CoinTransferIntentionData {\n recipient: string;\n coinType: string;\n amount: string;\n}\n\nexport class CoinTransferIntention extends CoreBaseIntention<CoinTransferIntentionData> {\n txType: TransactionType.Assets;\n\n txSubType: 'coin-transfer';\n\n constructor(public readonly data: CoinTransferIntentionData) {\n super(data);\n }\n\n async build(input: { suiClient: SuiClient; account: WalletAccount }): Promise<TransactionBlock> {\n const { suiClient, account } = input;\n return buildCoinTransferTxb(suiClient, this.data, account.address);\n }\n\n static fromData(data: CoinTransferIntentionData) {\n return new CoinTransferIntention(data);\n }\n}\n","import { TransactionType } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { WalletAccount } from '@mysten/wallet-standard';\nimport sortKeys from 'sort-keys-recursive';\n\nimport { TransactionIntention } from '@/apps/interface';\n\nexport abstract class CoreBaseIntention<D> implements TransactionIntention<D> {\n abstract txType: TransactionType;\n\n abstract txSubType: string;\n\n protected constructor(public readonly data: D) {}\n\n get application() {\n return 'msafe-core';\n }\n\n serialize() {\n return JSON.stringify(sortKeys(this.data));\n }\n\n abstract build(input: { suiClient: SuiClient; account: WalletAccount }): Promise<TransactionBlock>;\n}\n","import { TransactionType, buildObjectTransferTxb } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { WalletAccount } from '@mysten/wallet-standard';\n\nimport { CoreBaseIntention } from '@/apps/msafe-core/intention';\n\nexport interface ObjectTransferIntentionData {\n receiver: string;\n objectType: string;\n objectId: string;\n}\n\nexport class ObjectTransferIntention extends CoreBaseIntention<ObjectTransferIntentionData> {\n txType: TransactionType.Assets;\n\n txSubType: 'object-transfer';\n\n constructor(public readonly data: ObjectTransferIntentionData) {\n super(data);\n }\n\n async build(input: { suiClient: SuiClient; account: WalletAccount }): Promise<TransactionBlock> {\n const { suiClient, account } = input;\n return buildObjectTransferTxb(suiClient, this.data, account.address);\n }\n\n static fromData(data: ObjectTransferIntentionData) {\n return new ObjectTransferIntention(data);\n }\n}\n","import { TransactionType } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { WalletAccount } from '@mysten/wallet-standard';\n\nimport { MSafeAppHelper } from '@/apps/interface';\nimport { CoinTransferIntention, CoinTransferIntentionData } from '@/apps/msafe-core/coin-transfer';\n\nimport { ObjectTransferIntention, ObjectTransferIntentionData } from './object-transfer';\n\nexport type CoreIntention = CoinTransferIntention | ObjectTransferIntention;\n\nexport type CoreIntentionData = CoinTransferIntentionData | ObjectTransferIntentionData;\n\nexport class CoreHelper implements MSafeAppHelper<CoreIntention, CoreIntentionData> {\n application: string;\n\n constructor() {\n this.application = 'msafe-core';\n }\n\n deserialize(): CoreIntention {\n throw new Error('MSafe core transaction intention should be build from API');\n }\n\n async build(input: {\n intentionData: CoreIntentionData;\n txType: TransactionType;\n txSubType: string;\n suiClient: SuiClient;\n account: WalletAccount;\n }): Promise<TransactionBlock> {\n const { suiClient, account } = input;\n let intention: CoreIntention;\n switch (input.txSubType) {\n case 'coin-transfer':\n intention = CoinTransferIntention.fromData(input.intentionData as CoinTransferIntentionData);\n break;\n case 'object-transfer':\n intention = ObjectTransferIntention.fromData(input.intentionData as ObjectTransferIntentionData);\n break;\n default:\n throw new Error('not implemented');\n }\n return intention.build({ suiClient, account });\n }\n}\n","import { TransactionType } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { SuiSignTransactionBlockInput, WalletAccount } from '@mysten/wallet-standard';\n\nimport { MSafeAppHelper } from '@/apps/interface';\n\nexport class MSafeApps {\n apps: Map<string, MSafeAppHelper<any, any>>;\n\n constructor(apps: MSafeAppHelper<any, any>[]) {\n this.apps = new Map(apps.map((app) => [app.application, app]));\n }\n\n getAppHelper(appName: string): MSafeAppHelper<any, any> {\n const app = this.apps.get(appName);\n if (!app) {\n throw new Error(`${appName} not registered`);\n }\n return app;\n }\n\n deserialize(appName: string, input: SuiSignTransactionBlockInput) {\n return this.getAppHelper(appName).deserialize(input);\n }\n\n build(\n appName: string,\n input: {\n intentionData: any;\n txType: TransactionType;\n txSubType: string;\n suiClient: SuiClient;\n account: WalletAccount;\n },\n ) {\n return this.getAppHelper(appName).build(input);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,wBAAsD;;;ACItD,iCAAqB;AAId,IAAe,oBAAf,MAAuE;AAAA,EAKlE,YAA4B,MAAS;AAAT;AAAA,EAAU;AAAA,EAEhD,IAAI,cAAc;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,YAAY;AACV,WAAO,KAAK,cAAU,2BAAAA,SAAS,KAAK,IAAI,CAAC;AAAA,EAC3C;AAGF;;;ADXO,IAAM,wBAAN,MAAM,+BAA8B,kBAA6C;AAAA,EAKtF,YAA4B,MAAiC;AAC3D,UAAM,IAAI;AADgB;AAAA,EAE5B;AAAA,EANA;AAAA,EAEA;AAAA,EAMA,MAAM,MAAM,OAAoF;AAC9F,UAAM,EAAE,WAAW,QAAQ,IAAI;AAC/B,eAAO,wCAAqB,WAAW,KAAK,MAAM,QAAQ,OAAO;AAAA,EACnE;AAAA,EAEA,OAAO,SAAS,MAAiC;AAC/C,WAAO,IAAI,uBAAsB,IAAI;AAAA,EACvC;AACF;;;AE9BA,IAAAC,qBAAwD;AAajD,IAAM,0BAAN,MAAM,iCAAgC,kBAA+C;AAAA,EAK1F,YAA4B,MAAmC;AAC7D,UAAM,IAAI;AADgB;AAAA,EAE5B;AAAA,EANA;AAAA,EAEA;AAAA,EAMA,MAAM,MAAM,OAAoF;AAC9F,UAAM,EAAE,WAAW,QAA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,IAAI,WAAW,CAAC,CAAC;","names":["sortKeys","import_sui3_utils"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/apps/msafe-core/coin-transfer.ts
|
|
2
|
+
import { buildCoinTransferTxb } from "@msafe/sui3-utils";
|
|
3
|
+
|
|
4
|
+
// src/apps/msafe-core/intention.ts
|
|
5
|
+
import sortKeys from "sort-keys-recursive";
|
|
6
|
+
var CoreBaseIntention = class {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
this.data = data;
|
|
9
|
+
}
|
|
10
|
+
get application() {
|
|
11
|
+
return "msafe-core";
|
|
12
|
+
}
|
|
13
|
+
serialize() {
|
|
14
|
+
return JSON.stringify(sortKeys(this.data));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/apps/msafe-core/coin-transfer.ts
|
|
19
|
+
var CoinTransferIntention = class _CoinTransferIntention extends CoreBaseIntention {
|
|
20
|
+
constructor(data) {
|
|
21
|
+
super(data);
|
|
22
|
+
this.data = data;
|
|
23
|
+
}
|
|
24
|
+
txType;
|
|
25
|
+
txSubType;
|
|
26
|
+
async build(input) {
|
|
27
|
+
const { suiClient, account } = input;
|
|
28
|
+
return buildCoinTransferTxb(suiClient, this.data, account.address);
|
|
29
|
+
}
|
|
30
|
+
static fromData(data) {
|
|
31
|
+
return new _CoinTransferIntention(data);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/apps/msafe-core/object-transfer.ts
|
|
36
|
+
import { buildObjectTransferTxb } from "@msafe/sui3-utils";
|
|
37
|
+
var ObjectTransferIntention = class _ObjectTransferIntention extends CoreBaseIntention {
|
|
38
|
+
constructor(data) {
|
|
39
|
+
super(data);
|
|
40
|
+
this.data = data;
|
|
41
|
+
}
|
|
42
|
+
txType;
|
|
43
|
+
txSubType;
|
|
44
|
+
async build(input) {
|
|
45
|
+
const { suiClient, account } = input;
|
|
46
|
+
return buildObjectTransferTxb(suiClient, this.data, account.address);
|
|
47
|
+
}
|
|
48
|
+
static fromData(data) {
|
|
49
|
+
return new _ObjectTransferIntention(data);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/apps/msafe-core/helper.ts
|
|
54
|
+
var CoreHelper = class {
|
|
55
|
+
application;
|
|
56
|
+
constructor() {
|
|
57
|
+
this.application = "msafe-core";
|
|
58
|
+
}
|
|
59
|
+
deserialize() {
|
|
60
|
+
throw new Error("MSafe core transaction intention should be build from API");
|
|
61
|
+
}
|
|
62
|
+
async build(input) {
|
|
63
|
+
const { suiClient, account } = input;
|
|
64
|
+
let intention;
|
|
65
|
+
switch (input.txSubType) {
|
|
66
|
+
case "coin-transfer":
|
|
67
|
+
intention = CoinTransferIntention.fromData(input.intentionData);
|
|
68
|
+
break;
|
|
69
|
+
case "object-transfer":
|
|
70
|
+
intention = ObjectTransferIntention.fromData(input.intentionData);
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
throw new Error("not implemented");
|
|
74
|
+
}
|
|
75
|
+
return intention.build({ suiClient, account });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/apps/registry.ts
|
|
80
|
+
var MSafeApps = class {
|
|
81
|
+
apps;
|
|
82
|
+
constructor(apps) {
|
|
83
|
+
this.apps = new Map(apps.map((app) => [app.application, app]));
|
|
84
|
+
}
|
|
85
|
+
getAppHelper(appName) {
|
|
86
|
+
const app = this.apps.get(appName);
|
|
87
|
+
if (!app) {
|
|
88
|
+
throw new Error(`${appName} not registered`);
|
|
89
|
+
}
|
|
90
|
+
return app;
|
|
91
|
+
}
|
|
92
|
+
deserialize(appName, input) {
|
|
93
|
+
return this.getAppHelper(appName).deserialize(input);
|
|
94
|
+
}
|
|
95
|
+
build(appName, input) {
|
|
96
|
+
return this.getAppHelper(appName).build(input);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/index.ts
|
|
101
|
+
var appHelpers = new MSafeApps([new CoreHelper()]);
|
|
102
|
+
export {
|
|
103
|
+
appHelpers
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/apps/msafe-core/coin-transfer.ts","../src/apps/msafe-core/intention.ts","../src/apps/msafe-core/object-transfer.ts","../src/apps/msafe-core/helper.ts","../src/apps/registry.ts","../src/index.ts"],"sourcesContent":["import { TransactionType, buildCoinTransferTxb } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { WalletAccount } from '@mysten/wallet-standard';\n\nimport { CoreBaseIntention } from '@/apps/msafe-core/intention';\n\nexport interface CoinTransferIntentionData {\n recipient: string;\n coinType: string;\n amount: string;\n}\n\nexport class CoinTransferIntention extends CoreBaseIntention<CoinTransferIntentionData> {\n txType: TransactionType.Assets;\n\n txSubType: 'coin-transfer';\n\n constructor(public readonly data: CoinTransferIntentionData) {\n super(data);\n }\n\n async build(input: { suiClient: SuiClient; account: WalletAccount }): Promise<TransactionBlock> {\n const { suiClient, account } = input;\n return buildCoinTransferTxb(suiClient, this.data, account.address);\n }\n\n static fromData(data: CoinTransferIntentionData) {\n return new CoinTransferIntention(data);\n }\n}\n","import { TransactionType } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { WalletAccount } from '@mysten/wallet-standard';\nimport sortKeys from 'sort-keys-recursive';\n\nimport { TransactionIntention } from '@/apps/interface';\n\nexport abstract class CoreBaseIntention<D> implements TransactionIntention<D> {\n abstract txType: TransactionType;\n\n abstract txSubType: string;\n\n protected constructor(public readonly data: D) {}\n\n get application() {\n return 'msafe-core';\n }\n\n serialize() {\n return JSON.stringify(sortKeys(this.data));\n }\n\n abstract build(input: { suiClient: SuiClient; account: WalletAccount }): Promise<TransactionBlock>;\n}\n","import { TransactionType, buildObjectTransferTxb } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { WalletAccount } from '@mysten/wallet-standard';\n\nimport { CoreBaseIntention } from '@/apps/msafe-core/intention';\n\nexport interface ObjectTransferIntentionData {\n receiver: string;\n objectType: string;\n objectId: string;\n}\n\nexport class ObjectTransferIntention extends CoreBaseIntention<ObjectTransferIntentionData> {\n txType: TransactionType.Assets;\n\n txSubType: 'object-transfer';\n\n constructor(public readonly data: ObjectTransferIntentionData) {\n super(data);\n }\n\n async build(input: { suiClient: SuiClient; account: WalletAccount }): Promise<TransactionBlock> {\n const { suiClient, account } = input;\n return buildObjectTransferTxb(suiClient, this.data, account.address);\n }\n\n static fromData(data: ObjectTransferIntentionData) {\n return new ObjectTransferIntention(data);\n }\n}\n","import { TransactionType } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { WalletAccount } from '@mysten/wallet-standard';\n\nimport { MSafeAppHelper } from '@/apps/interface';\nimport { CoinTransferIntention, CoinTransferIntentionData } from '@/apps/msafe-core/coin-transfer';\n\nimport { ObjectTransferIntention, ObjectTransferIntentionData } from './object-transfer';\n\nexport type CoreIntention = CoinTransferIntention | ObjectTransferIntention;\n\nexport type CoreIntentionData = CoinTransferIntentionData | ObjectTransferIntentionData;\n\nexport class CoreHelper implements MSafeAppHelper<CoreIntention, CoreIntentionData> {\n application: string;\n\n constructor() {\n this.application = 'msafe-core';\n }\n\n deserialize(): CoreIntention {\n throw new Error('MSafe core transaction intention should be build from API');\n }\n\n async build(input: {\n intentionData: CoreIntentionData;\n txType: TransactionType;\n txSubType: string;\n suiClient: SuiClient;\n account: WalletAccount;\n }): Promise<TransactionBlock> {\n const { suiClient, account } = input;\n let intention: CoreIntention;\n switch (input.txSubType) {\n case 'coin-transfer':\n intention = CoinTransferIntention.fromData(input.intentionData as CoinTransferIntentionData);\n break;\n case 'object-transfer':\n intention = ObjectTransferIntention.fromData(input.intentionData as ObjectTransferIntentionData);\n break;\n default:\n throw new Error('not implemented');\n }\n return intention.build({ suiClient, account });\n }\n}\n","import { TransactionType } from '@msafe/sui3-utils';\nimport { SuiClient } from '@mysten/sui.js/client';\nimport { SuiSignTransactionBlockInput, WalletAccount } from '@mysten/wallet-standard';\n\nimport { MSafeAppHelper } from '@/apps/interface';\n\nexport class MSafeApps {\n apps: Map<string, MSafeAppHelper<any, any>>;\n\n constructor(apps: MSafeAppHelper<any, any>[]) {\n this.apps = new Map(apps.map((app) => [app.application, app]));\n }\n\n getAppHelper(appName: string): MSafeAppHelper<any, any> {\n const app = this.apps.get(appName);\n if (!app) {\n throw new Error(`${appName} not registered`);\n }\n return app;\n }\n\n deserialize(appName: string, input: SuiSignTransactionBlockInput) {\n return this.getAppHelper(appName).deserialize(input);\n }\n\n build(\n appName: string,\n input: {\n intentionData: any;\n txType: TransactionType;\n txSubType: string;\n suiClient: SuiClient;\n account: WalletAccount;\n },\n ) {\n return this.getAppHelper(appName).build(input);\n }\n}\n","import { CoreHelper } from '@/apps/msafe-core/helper';\nimport { MSafeApps } from '@/apps/registry';\n\nexport const appHelpers = new MSafeApps([new CoreHelper()]);\n"],"mappings":";AAAA,SAA0B,4BAA4B;;;ACItD,OAAO,cAAc;AAId,IAAe,oBAAf,MAAuE;AAAA,EAKlE,YAA4B,MAAS;AAAT;AAAA,EAAU;AAAA,EAEhD,IAAI,cAAc;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,YAAY;AACV,WAAO,KAAK,UAAU,SAAS,KAAK,IAAI,CAAC;AAAA,EAC3C;AAGF;;;ADXO,IAAM,wBAAN,MAAM,+BAA8B,kBAA6C;AAAA,EAKtF,YAA4B,MAAiC;AAC3D,UAAM,IAAI;AADgB;AAAA,EAE5B;AAAA,EANA;AAAA,EAEA;AAAA,EAMA,MAAM,MAAM,OAAoF;AAC9F,UAAM,EAAE,WA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AAa,SAA2C;AACtD,UAAM,MAAM,KAAK,KAAK,IAAI,OAAO;AACjC,QAAI,CAAC,KAAK;AACR,YAAM,IAAI,MAAM,GAAG,OAAO,iBAAiB;AAAA,IAC7C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,SAAiB,OAAqC;AAChE,WAAO,KAAK,aAAa,OAAO,EAAE,YAAY,KAAK;AAAA,EACrD;AAAA,EAEA,MACE,SACA,OAOA;AACA,WAAO,KAAK,aAAa,OAAO,EAAE,MAAM,KAAK;AAAA,EAC/C;AACF;;;AClCO,IAAM,aAAa,IAAI,UAAU,CAAC,IAAI,WAAW,CAAC,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@msafe/sui-app-store",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "MSafe Sui app store repository",
|
|
5
5
|
"author": "Momentum Safe",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"type": "
|
|
7
|
+
"type": "commonjs",
|
|
8
8
|
"private": false,
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"module": "./dist/index.cjs",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
},
|
|
40
40
|
"keywords": [
|
|
41
41
|
"MSafe",
|
|
42
|
-
"MSafe Iframe",
|
|
43
42
|
"MSafe SDK",
|
|
44
43
|
"MSafe wallet",
|
|
45
44
|
"MSafe Sui"
|
|
46
45
|
],
|
|
47
46
|
"dependencies": {
|
|
48
|
-
"buffer": "^6.0.3"
|
|
47
|
+
"buffer": "^6.0.3",
|
|
48
|
+
"sort-keys-recursive": "^2.1.10"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@msafe/sui3-utils": "^3.1.18",
|
|
@@ -54,12 +54,20 @@
|
|
|
54
54
|
"@types/jest": "^29.2.1",
|
|
55
55
|
"@typescript-eslint/eslint-plugin": "^5.41.0",
|
|
56
56
|
"@typescript-eslint/parser": "^5.41.0",
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-
|
|
59
|
-
"
|
|
57
|
+
"eslint": "^8.42.0",
|
|
58
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
59
|
+
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
60
|
+
"eslint-config-prettier": "^9.1.0",
|
|
61
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
|
62
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
63
|
+
"eslint-plugin-import": "^2.29.1",
|
|
64
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
65
|
+
"eslint-plugin-unused-imports": "^3.0.0",
|
|
66
|
+
"jest": "^29.5.0",
|
|
67
|
+
"prettier": "^3.2.4",
|
|
60
68
|
"ts-jest": "^29.0.3",
|
|
61
69
|
"ts-node": "^10.9.2",
|
|
62
|
-
"tsup": "^
|
|
70
|
+
"tsup": "^8.0.1",
|
|
63
71
|
"typescript": "^4.8.4"
|
|
64
72
|
},
|
|
65
73
|
"peerDependencies": {
|
package/dist/index.cjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
MSafeApps: () => MSafeApps
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
|
|
27
|
-
// src/app/msafe.ts
|
|
28
|
-
var import_sui3_utils = require("@msafe/sui3-utils");
|
|
29
|
-
var MSafeCoreWallet = class {
|
|
30
|
-
async deserialize(input) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
"MSafe core transaction intention should be build from API"
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
async build(input) {
|
|
36
|
-
const { transactionIntention, context } = input;
|
|
37
|
-
switch (transactionIntention.txSubType) {
|
|
38
|
-
case "CoinTransfer":
|
|
39
|
-
return (0, import_sui3_utils.buildCoinTransferTxb)(
|
|
40
|
-
context.suiClient,
|
|
41
|
-
transactionIntention.data,
|
|
42
|
-
context.account.address
|
|
43
|
-
);
|
|
44
|
-
case "ObjectTransfer":
|
|
45
|
-
return (0, import_sui3_utils.buildObjectTransferTxb)(
|
|
46
|
-
context.suiClient,
|
|
47
|
-
transactionIntention.data,
|
|
48
|
-
context.account.address
|
|
49
|
-
);
|
|
50
|
-
default:
|
|
51
|
-
throw new Error("Unsupported transaction type");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/index.ts
|
|
57
|
-
var MSafeApps = class {
|
|
58
|
-
msafeCore = new MSafeCoreWallet();
|
|
59
|
-
};
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
MSafeApps
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/app/msafe.ts"],"sourcesContent":["import {\n CoinTransferIntention,\n ObjectTransferIntention,\n TransactionType,\n} from \"@msafe/sui3-utils\";\nimport { SuiClient } from \"@mysten/sui.js/client\";\nimport { TransactionBlock } from \"@mysten/sui.js/transactions\";\nimport {\n SuiSignTransactionBlockInput,\n WalletAccount,\n} from \"@mysten/wallet-standard\";\nimport { MSafeCoreWallet } from \"./app/msafe\";\n\nexport interface MSafeWalletApi {\n /**\n * Deserialize transaction block data to human readable data structure.\n * @param input transaction block input\n */\n deserialize(\n input: SuiSignTransactionBlockInput\n ): Promise<TransactionIntention<keyof TransactionIntentions>>;\n\n build(input: {\n transactionIntention: TransactionIntention<keyof TransactionIntentions>;\n context: MSafeWalletContext;\n }): Promise<TransactionBlock>;\n}\n\nexport interface MSafeWalletContext {\n suiClient: SuiClient;\n account: WalletAccount;\n}\n\nexport interface TransactionIntention<T extends keyof TransactionIntentions> {\n txType: TransactionType;\n txSubType: T;\n data: TransactionIntentions[T];\n}\n\n/**\n * Support transaction intention data structure.\n * App need to add your transaction intention types here\n */\nexport interface TransactionIntentions {\n CoinTransfer: CoinTransferIntention;\n ObjectTransfer: ObjectTransferIntention;\n}\n\nexport class MSafeApps {\n public msafeCore = new MSafeCoreWallet();\n}\n","import {\n MSafeWalletApi,\n MSafeWalletContext,\n TransactionIntention,\n TransactionIntentions,\n} from \"@/index\";\nimport {\n CoinTransferIntention,\n ObjectTransferIntention,\n buildCoinTransferTxb,\n buildObjectTransferTxb,\n} from \"@msafe/sui3-utils\";\nimport { TransactionBlock } from \"@mysten/sui.js/transactions\";\nimport { SuiSignTransactionBlockInput } from \"@mysten/wallet-standard\";\n\nexport class MSafeCoreWallet implements MSafeWalletApi {\n async deserialize(\n input: SuiSignTransactionBlockInput\n ): Promise<TransactionIntention<keyof TransactionIntentions>> {\n throw new Error(\n \"MSafe core transaction intention should be build from API\"\n );\n }\n async build(input: {\n transactionIntention: TransactionIntention<keyof TransactionIntentions>;\n context: MSafeWalletContext;\n }): Promise<TransactionBlock> {\n const { transactionIntention, context } = input;\n switch (transactionIntention.txSubType) {\n case \"CoinTransfer\":\n return buildCoinTransferTxb(\n context.suiClient,\n transactionIntention.data as CoinTransferIntention,\n context.account.address\n );\n case \"ObjectTransfer\":\n return buildObjectTransferTxb(\n context.suiClient,\n transactionIntention.data as ObjectTransferIntention,\n context.account.address\n );\n default:\n throw new Error(\"Unsupported transaction type\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,wBAKO;AAIA,IAAM,kBAAN,MAAgD;AAAA,EACrD,MAAM,YACJ,OAC4D;AAC5D,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM,MAAM,OAGkB;AAC5B,UAAM,EAAE,sBAAsB,QAAQ,IAAI;AAC1C,YAAQ,qBAAqB,WAAW;AAAA,MACtC,KAAK;AACH,mBAAO;AAAA,UACL,QAAQ;AAAA,UACR,qBAAqB;AAAA,UACrB,QAAQ,QAAQ;AAAA,QAClB;AAAA,MACF,KAAK;AACH,mBAAO;AAAA,UACL,QAAQ;AAAA,UACR,qBAAqB;AAAA,UACrB,QAAQ,QAAQ;AAAA,QAClB;AAAA,MACF;AACE,cAAM,IAAI,MAAM,8BAA8B;AAAA,IAClD;AAAA,EACF;AACF;;;ADGO,IAAM,YAAN,MAAgB;AAAA,EACd,YAAY,IAAI,gBAAgB;AACzC;","names":[]}
|