@msafe/sui-app-store 0.0.3 → 0.0.4
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.cjs +23 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -14
- package/dist/index.global.js +4 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +27 -25
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -24,39 +24,38 @@ __export(src_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
|
|
27
|
-
// src/app/
|
|
27
|
+
// src/app/msafe.ts
|
|
28
28
|
var import_sui3_utils = require("@msafe/sui3-utils");
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
txSubType: "CoinTransfer",
|
|
35
|
-
data: {
|
|
36
|
-
recipient: input.account.address,
|
|
37
|
-
amount: "10000",
|
|
38
|
-
coinType: "0x2::sui::SUI"
|
|
39
|
-
}
|
|
40
|
-
};
|
|
29
|
+
var MSafeCoreWallet = class {
|
|
30
|
+
async deserialize(input) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
"MSafe core transaction intention should be build from API"
|
|
33
|
+
);
|
|
41
34
|
}
|
|
42
35
|
async build(input) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
52
|
}
|
|
53
|
-
throw new Error("Method not implemented.");
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
// src/index.ts
|
|
58
57
|
var MSafeApps = class {
|
|
59
|
-
|
|
58
|
+
msafeCore = new MSafeCoreWallet();
|
|
60
59
|
};
|
|
61
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
62
61
|
0 && (module.exports = {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/app/
|
|
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":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { TransactionType } from '@msafe/sui3-utils';
|
|
1
|
+
import { TransactionType, CoinTransferIntention, ObjectTransferIntention } from '@msafe/sui3-utils';
|
|
2
|
+
import { SuiClient } from '@mysten/sui.js/client';
|
|
2
3
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
3
4
|
import { SuiSignTransactionBlockInput, WalletAccount } from '@mysten/wallet-standard';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
coinType: string;
|
|
8
|
-
amount: string;
|
|
9
|
-
}
|
|
10
|
-
declare class ExampleWallet implements MSafeWalletApi {
|
|
11
|
-
deserilize(input: SuiSignTransactionBlockInput): Promise<TransactionIntention<keyof TransactionIntentions>>;
|
|
6
|
+
declare class MSafeCoreWallet implements MSafeWalletApi {
|
|
7
|
+
deserialize(input: SuiSignTransactionBlockInput): Promise<TransactionIntention<keyof TransactionIntentions>>;
|
|
12
8
|
build(input: {
|
|
13
9
|
transactionIntention: TransactionIntention<keyof TransactionIntentions>;
|
|
14
|
-
|
|
10
|
+
context: MSafeWalletContext;
|
|
15
11
|
}): Promise<TransactionBlock>;
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
interface MSafeWalletApi {
|
|
19
15
|
/**
|
|
20
|
-
*
|
|
16
|
+
* Deserialize transaction block data to human readable data structure.
|
|
21
17
|
* @param input transaction block input
|
|
22
18
|
*/
|
|
23
|
-
|
|
19
|
+
deserialize(input: SuiSignTransactionBlockInput): Promise<TransactionIntention<keyof TransactionIntentions>>;
|
|
24
20
|
build(input: {
|
|
25
21
|
transactionIntention: TransactionIntention<keyof TransactionIntentions>;
|
|
26
|
-
|
|
22
|
+
context: MSafeWalletContext;
|
|
27
23
|
}): Promise<TransactionBlock>;
|
|
28
24
|
}
|
|
25
|
+
interface MSafeWalletContext {
|
|
26
|
+
suiClient: SuiClient;
|
|
27
|
+
account: WalletAccount;
|
|
28
|
+
}
|
|
29
29
|
interface TransactionIntention<T extends keyof TransactionIntentions> {
|
|
30
30
|
txType: TransactionType;
|
|
31
31
|
txSubType: T;
|
|
@@ -37,9 +37,10 @@ interface TransactionIntention<T extends keyof TransactionIntentions> {
|
|
|
37
37
|
*/
|
|
38
38
|
interface TransactionIntentions {
|
|
39
39
|
CoinTransfer: CoinTransferIntention;
|
|
40
|
+
ObjectTransfer: ObjectTransferIntention;
|
|
40
41
|
}
|
|
41
42
|
declare class MSafeApps {
|
|
42
|
-
|
|
43
|
+
msafeCore: MSafeCoreWallet;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export { MSafeApps, MSafeWalletApi, TransactionIntention, TransactionIntentions };
|
|
46
|
+
export { MSafeApps, MSafeWalletApi, MSafeWalletContext, TransactionIntention, TransactionIntentions };
|