@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 CHANGED
@@ -24,39 +24,38 @@ __export(src_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(src_exports);
26
26
 
27
- // src/app/example.ts
27
+ // src/app/msafe.ts
28
28
  var import_sui3_utils = require("@msafe/sui3-utils");
29
- var import_transactions = require("@mysten/sui.js/transactions");
30
- var ExampleWallet = class {
31
- async deserilize(input) {
32
- return {
33
- txType: import_sui3_utils.TransactionType.Assets,
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
- if (input.transactionIntention.txSubType === "CoinTransfer") {
44
- const intention = input.transactionIntention.data;
45
- const block = new import_transactions.TransactionBlock();
46
- const [coin] = block.splitCoins(block.gas, [
47
- block.pure(intention.amount)
48
- ]);
49
- block.transferObjects([coin], block.pure(intention.recipient));
50
- block.setSender(input.account.address);
51
- return block;
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
- example = new ExampleWallet();
58
+ msafeCore = new MSafeCoreWallet();
60
59
  };
61
60
  // Annotate the CommonJS export names for ESM import in node:
62
61
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/app/example.ts"],"sourcesContent":["import { TransactionType } from \"@msafe/sui3-utils\";\nimport { TransactionBlock } from \"@mysten/sui.js/transactions\";\nimport {\n SuiSignTransactionBlockInput,\n WalletAccount,\n} from \"@mysten/wallet-standard\";\nimport { CoinTransferIntention, ExampleWallet } from \"./app/example\";\n\nexport interface MSafeWalletApi {\n /**\n * Deserilize transaction block data to human readable data struccture.\n * @param input transaction block input\n */\n deserilize(\n input: SuiSignTransactionBlockInput\n ): Promise<TransactionIntention<keyof TransactionIntentions>>;\n\n build(input: {\n transactionIntention: TransactionIntention<keyof TransactionIntentions>;\n account: WalletAccount;\n }): Promise<TransactionBlock>;\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}\n\nexport class MSafeApps {\n public example = new ExampleWallet();\n}\n","import { TransactionType } from \"@msafe/sui3-utils\";\nimport { TransactionBlock } from \"@mysten/sui.js/transactions\";\nimport {\n SuiSignTransactionBlockInput,\n WalletAccount,\n} from \"@mysten/wallet-standard\";\nimport {\n MSafeWalletApi,\n TransactionIntention,\n TransactionIntentions,\n} from \"..\";\n\nexport interface CoinTransferIntention {\n recipient: string;\n coinType: string;\n amount: string;\n}\n\nexport class ExampleWallet implements MSafeWalletApi {\n async deserilize(\n input: SuiSignTransactionBlockInput\n ): Promise<TransactionIntention<keyof TransactionIntentions>> {\n return {\n txType: TransactionType.Assets,\n txSubType: \"CoinTransfer\",\n data: {\n recipient: input.account.address,\n amount: \"10000\",\n coinType: \"0x2::sui::SUI\",\n },\n };\n }\n async build(input: {\n transactionIntention: TransactionIntention<keyof TransactionIntentions>;\n account: WalletAccount;\n }): Promise<TransactionBlock> {\n if (input.transactionIntention.txSubType === \"CoinTransfer\") {\n const intention = input.transactionIntention\n .data as CoinTransferIntention;\n const block = new TransactionBlock();\n const [coin] = block.splitCoins(block.gas, [\n block.pure(intention.amount),\n ]);\n block.transferObjects([coin], block.pure(intention.recipient));\n block.setSender(input.account.address);\n return block;\n }\n throw new Error(\"Method not implemented.\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,wBAAgC;AAChC,0BAAiC;AAiB1B,IAAM,gBAAN,MAA8C;AAAA,EACnD,MAAM,WACJ,OAC4D;AAC5D,WAAO;AAAA,MACL,QAAQ,kCAAgB;AAAA,MACxB,WAAW;AAAA,MACX,MAAM;AAAA,QACJ,WAAW,MAAM,QAAQ;AAAA,QACzB,QAAQ;AAAA,QACR,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM,MAAM,OAGkB;AAC5B,QAAI,MAAM,qBAAqB,cAAc,gBAAgB;AAC3D,YAAM,YAAY,MAAM,qBACrB;AACH,YAAM,QAAQ,IAAI,qCAAiB;AACnC,YAAM,CAAC,IAAI,IAAI,MAAM,WAAW,MAAM,KAAK;AAAA,QACzC,MAAM,KAAK,UAAU,MAAM;AAAA,MAC7B,CAAC;AACD,YAAM,gBAAgB,CAAC,IAAI,GAAG,MAAM,KAAK,UAAU,SAAS,CAAC;AAC7D,YAAM,UAAU,MAAM,QAAQ,OAAO;AACrC,aAAO;AAAA,IACT;AACA,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AACF;;;ADZO,IAAM,YAAN,MAAgB;AAAA,EACd,UAAU,IAAI,cAAc;AACrC;","names":[]}
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
- interface CoinTransferIntention {
6
- recipient: string;
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
- account: WalletAccount;
10
+ context: MSafeWalletContext;
15
11
  }): Promise<TransactionBlock>;
16
12
  }
17
13
 
18
14
  interface MSafeWalletApi {
19
15
  /**
20
- * Deserilize transaction block data to human readable data struccture.
16
+ * Deserialize transaction block data to human readable data structure.
21
17
  * @param input transaction block input
22
18
  */
23
- deserilize(input: SuiSignTransactionBlockInput): Promise<TransactionIntention<keyof TransactionIntentions>>;
19
+ deserialize(input: SuiSignTransactionBlockInput): Promise<TransactionIntention<keyof TransactionIntentions>>;
24
20
  build(input: {
25
21
  transactionIntention: TransactionIntention<keyof TransactionIntentions>;
26
- account: WalletAccount;
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
- example: ExampleWallet;
43
+ msafeCore: MSafeCoreWallet;
43
44
  }
44
45
 
45
- export { MSafeApps, MSafeWalletApi, TransactionIntention, TransactionIntentions };
46
+ export { MSafeApps, MSafeWalletApi, MSafeWalletContext, TransactionIntention, TransactionIntentions };