@aptos-labs/ts-sdk 0.0.2 → 0.0.3

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.
Files changed (51) hide show
  1. package/README.md +32 -24
  2. package/dist/browser/index.global.js +25 -25
  3. package/dist/browser/index.global.js.map +1 -1
  4. package/dist/cjs/index.d.ts +665 -157
  5. package/dist/cjs/index.js +1291 -652
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/esm/index.d.ts +665 -157
  8. package/dist/esm/index.mjs +1224 -650
  9. package/dist/esm/index.mjs.map +1 -1
  10. package/dist/types/index.d.ts +20 -19
  11. package/dist/types/index.js +4 -2
  12. package/dist/types/index.js.map +1 -1
  13. package/package.json +1 -1
  14. package/src/api/account.ts +2 -2
  15. package/src/api/coin.ts +5 -5
  16. package/src/api/digitalAsset.ts +5 -5
  17. package/src/api/event.ts +2 -2
  18. package/src/api/faucet.ts +7 -3
  19. package/src/api/transactionSubmission.ts +24 -24
  20. package/src/bcs/serializable/fixedBytes.ts +1 -1
  21. package/src/bcs/serializable/moveStructs.ts +16 -36
  22. package/src/core/account.ts +12 -8
  23. package/src/core/accountAddress.ts +4 -2
  24. package/src/core/authenticationKey.ts +24 -2
  25. package/src/core/crypto/anyPublicKey.ts +14 -18
  26. package/src/core/crypto/ed25519.ts +6 -0
  27. package/src/core/crypto/index.ts +1 -0
  28. package/src/core/crypto/multiKey.ts +122 -0
  29. package/src/core/crypto/secp256k1.ts +2 -0
  30. package/src/index.ts +1 -2
  31. package/src/internal/account.ts +5 -5
  32. package/src/internal/coin.ts +8 -8
  33. package/src/internal/digitalAsset.ts +7 -7
  34. package/src/internal/event.ts +2 -2
  35. package/src/internal/faucet.ts +9 -5
  36. package/src/internal/transactionSubmission.ts +40 -15
  37. package/src/transactions/authenticator/account.ts +39 -0
  38. package/src/transactions/authenticator/index.ts +5 -0
  39. package/src/transactions/authenticator/transaction.ts +6 -6
  40. package/src/transactions/index.ts +9 -0
  41. package/src/transactions/instances/index.ts +1 -0
  42. package/src/transactions/instances/transactionPayload.ts +13 -8
  43. package/src/transactions/transactionBuilder/helpers.ts +99 -0
  44. package/src/transactions/transactionBuilder/index.ts +6 -0
  45. package/src/transactions/transactionBuilder/remoteAbi.ts +339 -0
  46. package/src/transactions/{transaction_builder/transaction_builder.ts → transactionBuilder/transactionBuilder.ts} +149 -68
  47. package/src/transactions/typeTag/index.ts +385 -0
  48. package/src/transactions/typeTag/parser.ts +21 -8
  49. package/src/transactions/types.ts +87 -46
  50. package/src/types/index.ts +18 -16
  51. package/src/transactions/typeTag/typeTag.ts +0 -487
package/README.md CHANGED
@@ -56,6 +56,38 @@ const aptos = new Aptos(config);
56
56
  const modules = await aptos.getAccountModules({ accountAddress: "0x123" });
57
57
  ```
58
58
 
59
+ ### Keys management (default to Ed25519)
60
+
61
+ > Note: We introduce a Single Sender authentication (as introduced in [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263)). Generating an account defaults to Single Sender unified authentication with the option to use the Legacy Ed25519
62
+
63
+ ---
64
+
65
+ #### Generate new keys
66
+
67
+ ```ts
68
+ const account = Account.generate(); // defaults to Single Sender Ed25519
69
+ const account = Account.generate({ scheme: SingingSchemeInput.Secp256k1 }); // Single Sender Secp256k1
70
+ const account = Account.generate({ legacy: true }); // use Legacy Ed25519
71
+ ```
72
+
73
+ #### Derive from private key
74
+
75
+ ```ts
76
+ const aptos = new Aptos();
77
+ // This functions resolves the provided private key type and derives the public key from it
78
+ // to support key rotation and differentiation between Legacy Ed25519 and Unified authentications
79
+ // Read more https://github.com/aptos-labs/aptos-ts-sdk/blob/main/src/api/account.ts#L364
80
+ const account = await aptos.deriveAccountFromPrivateKey({ privateKey: privateKey });
81
+ ```
82
+
83
+ #### Derive from path
84
+
85
+ ```ts
86
+ const path = "m/44'/637'/0'/0'/1";
87
+ const mnemonic = "various float stumble...";
88
+ const account = Account.fromDerivationPath({ path, mnemonic });
89
+ ```
90
+
59
91
  ### Submit transaction
60
92
 
61
93
  ---
@@ -93,30 +125,6 @@ const transaction = await aptos.transferCoinTransaction({
93
125
  const pendingTransaction = await aptos.signAndSubmitTransaction({ signer: alice, transaction });
94
126
  ```
95
127
 
96
- ### Keys management (default to Ed25519)
97
-
98
- ---
99
-
100
- #### Generate new keys
101
-
102
- ```ts
103
- const account = Account.generate();
104
- ```
105
-
106
- #### Derive from private key
107
-
108
- ```ts
109
- const account = Account.fromPrivateKey("0x123");
110
- ```
111
-
112
- #### Derive from path
113
-
114
- ```ts
115
- const path = "m/44'/637'/0'/0'/1";
116
- const mnemonic = "various float stumble...";
117
- const account = Account.fromDerivationPath({ path, mnemonic });
118
- ```
119
-
120
128
  ## Documentation and examples
121
129
 
122
130
  - For in-depth examples, check out the [examples](./examples) folder with ready-made `package.json` files to get you going quickly!