@aeternity/aepp-sdk 12.0.0 → 12.1.2

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 (283) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -15
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +2 -1
  5. package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +20765 -1
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdk.d.ts +7 -7
  10. package/es/AeSdk.mjs.map +1 -1
  11. package/es/AeSdkAepp.d.ts +4 -3
  12. package/es/AeSdkAepp.mjs +2 -1
  13. package/es/AeSdkAepp.mjs.map +1 -1
  14. package/es/AeSdkBase.d.ts +22 -21
  15. package/es/AeSdkBase.mjs +25 -21
  16. package/es/AeSdkBase.mjs.map +1 -1
  17. package/es/AeSdkWallet.d.ts +4 -3
  18. package/es/AeSdkWallet.mjs +5 -1
  19. package/es/AeSdkWallet.mjs.map +1 -1
  20. package/es/Node.d.ts +7 -10
  21. package/es/Node.mjs +63 -57
  22. package/es/Node.mjs.map +1 -1
  23. package/es/account/Base.d.ts +7 -4
  24. package/es/account/Base.mjs +3 -3
  25. package/es/account/Base.mjs.map +1 -1
  26. package/es/account/Memory.d.ts +5 -4
  27. package/es/account/Memory.mjs +24 -2
  28. package/es/account/Memory.mjs.map +1 -1
  29. package/es/account/Rpc.d.ts +6 -6
  30. package/es/account/Rpc.mjs +3 -2
  31. package/es/account/Rpc.mjs.map +1 -1
  32. package/es/aens.d.ts +27 -14
  33. package/es/aens.mjs +27 -21
  34. package/es/aens.mjs.map +1 -1
  35. package/es/aepp-wallet-communication/connection/Browser.d.ts +2 -1
  36. package/es/aepp-wallet-communication/connection/Browser.mjs +5 -2
  37. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  38. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  41. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -0
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +5 -1
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  44. package/es/aepp-wallet-communication/connection-proxy.d.ts +1 -0
  45. package/es/aepp-wallet-communication/connection-proxy.mjs +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +1 -0
  48. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -5
  49. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/rpc/types.d.ts +8 -8
  51. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/schema.d.ts +17 -2
  53. package/es/aepp-wallet-communication/schema.mjs +54 -17
  54. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  55. package/es/aepp-wallet-communication/wallet-detector.d.ts +2 -1
  56. package/es/aepp-wallet-communication/wallet-detector.mjs +2 -3
  57. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  58. package/es/apis/node/models/index.d.ts +6 -2
  59. package/es/apis/node/models/index.mjs.map +1 -1
  60. package/es/apis/node/models/mappers.mjs +4 -2
  61. package/es/apis/node/models/mappers.mjs.map +1 -1
  62. package/es/chain.d.ts +92 -64
  63. package/es/chain.mjs +190 -154
  64. package/es/chain.mjs.map +1 -1
  65. package/es/channel/handlers.d.ts +3 -3
  66. package/es/channel/handlers.mjs +42 -44
  67. package/es/channel/handlers.mjs.map +1 -1
  68. package/es/channel/index.d.ts +43 -52
  69. package/es/channel/index.mjs +46 -49
  70. package/es/channel/index.mjs.map +1 -1
  71. package/es/channel/internal.d.ts +16 -15
  72. package/es/channel/internal.mjs +67 -62
  73. package/es/channel/internal.mjs.map +1 -1
  74. package/es/contract/Compiler.d.ts +1 -0
  75. package/es/contract/Compiler.mjs +5 -4
  76. package/es/contract/Compiler.mjs.map +1 -1
  77. package/es/contract/aci.d.ts +17 -15
  78. package/es/contract/aci.mjs +58 -45
  79. package/es/contract/aci.mjs.map +1 -1
  80. package/es/contract/ga.d.ts +16 -15
  81. package/es/contract/ga.mjs +12 -7
  82. package/es/contract/ga.mjs.map +1 -1
  83. package/es/contract/methods.d.ts +9 -6
  84. package/es/contract/methods.mjs +9 -6
  85. package/es/contract/methods.mjs.map +1 -1
  86. package/es/deprecated/index.d.ts +143 -0
  87. package/es/deprecated/index.mjs +162 -0
  88. package/es/deprecated/index.mjs.map +1 -0
  89. package/es/deprecated/methods.d.ts +18 -0
  90. package/es/deprecated/methods.mjs +26 -0
  91. package/es/deprecated/methods.mjs.map +1 -0
  92. package/es/index.d.ts +4 -1
  93. package/es/index.mjs +4 -1
  94. package/es/index.mjs.map +1 -1
  95. package/es/oracle.d.ts +69 -62
  96. package/es/oracle.mjs +121 -103
  97. package/es/oracle.mjs.map +1 -1
  98. package/es/spend.d.ts +16 -15
  99. package/es/spend.mjs +19 -30
  100. package/es/spend.mjs.map +1 -1
  101. package/es/tx/builder/address.d.ts +25 -0
  102. package/es/tx/builder/address.mjs +45 -0
  103. package/es/tx/builder/address.mjs.map +1 -0
  104. package/es/tx/builder/constants.d.ts +55 -26
  105. package/es/tx/builder/constants.mjs +60 -38
  106. package/es/tx/builder/constants.mjs.map +1 -1
  107. package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
  108. package/es/tx/builder/field-types/coin-amount.mjs +26 -0
  109. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
  110. package/es/tx/builder/field-types/deposit.d.ts +15 -0
  111. package/es/tx/builder/field-types/deposit.mjs +19 -0
  112. package/es/tx/builder/field-types/deposit.mjs.map +1 -0
  113. package/es/tx/builder/field-types/fee.d.ts +25 -0
  114. package/es/tx/{min-fee.mjs → builder/field-types/fee.mjs} +62 -60
  115. package/es/tx/builder/field-types/fee.mjs.map +1 -0
  116. package/es/tx/builder/field-types/field.d.ts +6 -0
  117. package/es/tx/builder/field-types/field.mjs +15 -0
  118. package/es/tx/builder/field-types/field.mjs.map +1 -0
  119. package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
  120. package/es/tx/builder/field-types/gas-limit.mjs +33 -0
  121. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
  122. package/es/tx/builder/field-types/gas-price.d.ts +8 -0
  123. package/es/tx/builder/field-types/gas-price.mjs +18 -0
  124. package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
  125. package/es/tx/builder/field-types/index.d.ts +70 -0
  126. package/es/tx/builder/field-types/index.mjs +25 -0
  127. package/es/tx/builder/field-types/index.mjs.map +1 -0
  128. package/es/tx/builder/field-types/name-fee.d.ts +20 -0
  129. package/es/tx/builder/field-types/name-fee.mjs +24 -0
  130. package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
  131. package/es/tx/builder/field-types/name-id.d.ts +14 -0
  132. package/es/tx/builder/field-types/name-id.mjs +19 -0
  133. package/es/tx/builder/field-types/name-id.mjs.map +1 -0
  134. package/es/tx/builder/field-types/name.d.ts +13 -0
  135. package/es/tx/builder/field-types/name.mjs +18 -0
  136. package/es/tx/builder/field-types/name.mjs.map +1 -0
  137. package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
  138. package/es/tx/builder/field-types/short-u-int.mjs +12 -0
  139. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
  140. package/es/tx/builder/field-types/u-int.d.ts +8 -0
  141. package/es/tx/builder/field-types/u-int.mjs +14 -0
  142. package/es/tx/builder/field-types/u-int.mjs.map +1 -0
  143. package/es/tx/builder/helpers.d.ts +27 -33
  144. package/es/tx/builder/helpers.mjs +41 -47
  145. package/es/tx/builder/helpers.mjs.map +1 -1
  146. package/es/tx/builder/index.d.ts +25 -12
  147. package/es/tx/builder/index.mjs +74 -83
  148. package/es/tx/builder/index.mjs.map +1 -1
  149. package/es/tx/builder/schema.d.ts +995 -144
  150. package/es/tx/builder/schema.mjs +121 -170
  151. package/es/tx/builder/schema.mjs.map +1 -1
  152. package/es/tx/index.d.ts +28 -27
  153. package/es/tx/index.mjs +97 -117
  154. package/es/tx/index.mjs.map +1 -1
  155. package/es/tx/validator.d.ts +4 -3
  156. package/es/tx/validator.mjs +79 -92
  157. package/es/tx/validator.mjs.map +1 -1
  158. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -1
  159. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -1
  160. package/es/typings/bip32-path/index.d.mjs.map +1 -1
  161. package/es/typings/blakejs/index.d.mjs.map +1 -1
  162. package/es/typings/sha-js/index.d.mjs +2 -0
  163. package/es/typings/sha-js/index.d.mjs.map +1 -0
  164. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -1
  165. package/es/utils/amount-formatter.d.ts +9 -9
  166. package/es/utils/amount-formatter.mjs +17 -17
  167. package/es/utils/amount-formatter.mjs.map +1 -1
  168. package/es/utils/autorest.mjs +7 -7
  169. package/es/utils/autorest.mjs.map +1 -1
  170. package/es/utils/bignumber.mjs +2 -1
  171. package/es/utils/bignumber.mjs.map +1 -1
  172. package/es/utils/bytes.mjs +1 -1
  173. package/es/utils/bytes.mjs.map +1 -1
  174. package/es/utils/crypto.d.ts +8 -23
  175. package/es/utils/crypto.mjs +15 -41
  176. package/es/utils/crypto.mjs.map +1 -1
  177. package/es/utils/encoder-types.d.ts +61 -0
  178. package/es/utils/encoder-types.mjs +36 -0
  179. package/es/utils/encoder-types.mjs.map +1 -0
  180. package/es/utils/encoder.d.ts +6 -7
  181. package/es/utils/encoder.mjs +42 -26
  182. package/es/utils/encoder.mjs.map +1 -1
  183. package/es/utils/errors.d.ts +1 -11
  184. package/es/utils/errors.mjs +4 -20
  185. package/es/utils/errors.mjs.map +1 -1
  186. package/es/utils/hd-wallet.d.ts +18 -2
  187. package/es/utils/hd-wallet.mjs +64 -34
  188. package/es/utils/hd-wallet.mjs.map +1 -1
  189. package/es/utils/json-big.mjs +2 -2
  190. package/es/utils/json-big.mjs.map +1 -1
  191. package/es/utils/keystore.mjs +4 -2
  192. package/es/utils/keystore.mjs.map +1 -1
  193. package/es/utils/mptree.d.ts +2 -2
  194. package/es/utils/mptree.mjs +11 -6
  195. package/es/utils/mptree.mjs.map +1 -1
  196. package/es/utils/other.d.ts +8 -2
  197. package/es/utils/other.mjs +15 -3
  198. package/es/utils/other.mjs.map +1 -1
  199. package/es/utils/semver-satisfies.d.ts +1 -1
  200. package/es/utils/semver-satisfies.mjs +2 -2
  201. package/es/utils/semver-satisfies.mjs.map +1 -1
  202. package/es/utils/string.mjs.map +1 -1
  203. package/package.json +36 -34
  204. package/src/AeSdk.ts +30 -27
  205. package/src/AeSdkAepp.ts +93 -84
  206. package/src/AeSdkBase.ts +148 -130
  207. package/src/AeSdkWallet.ts +172 -156
  208. package/src/Node.ts +108 -102
  209. package/src/account/Base.ts +42 -32
  210. package/src/account/Memory.ts +45 -30
  211. package/src/account/Rpc.ts +32 -30
  212. package/src/aens.ts +124 -108
  213. package/src/aepp-wallet-communication/connection/Browser.ts +18 -15
  214. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +22 -21
  215. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +63 -52
  216. package/src/aepp-wallet-communication/connection-proxy.ts +8 -7
  217. package/src/aepp-wallet-communication/rpc/RpcClient.ts +67 -61
  218. package/src/aepp-wallet-communication/rpc/types.ts +32 -32
  219. package/src/aepp-wallet-communication/schema.ts +117 -74
  220. package/src/aepp-wallet-communication/wallet-detector.ts +29 -28
  221. package/src/apis/node/code-model-v4.yaml +54 -20
  222. package/src/apis/node/models/index.ts +6 -2
  223. package/src/apis/node/models/mappers.ts +4 -2
  224. package/src/chain.ts +286 -228
  225. package/src/channel/handlers.ts +424 -372
  226. package/src/channel/index.ts +285 -251
  227. package/src/channel/internal.ts +248 -232
  228. package/src/contract/Compiler.ts +22 -21
  229. package/src/contract/aci.ts +267 -258
  230. package/src/contract/ga.ts +93 -72
  231. package/src/contract/methods.ts +32 -27
  232. package/src/deprecated/index.ts +172 -0
  233. package/src/deprecated/methods.ts +25 -0
  234. package/src/index.ts +37 -32
  235. package/src/oracle.ts +211 -189
  236. package/src/spend.ts +82 -70
  237. package/src/tx/builder/address.ts +50 -0
  238. package/src/tx/builder/constants.ts +82 -52
  239. package/src/tx/builder/field-types/coin-amount.ts +27 -0
  240. package/src/tx/builder/field-types/deposit.ts +21 -0
  241. package/src/tx/builder/field-types/fee.ts +143 -0
  242. package/src/tx/builder/field-types/field.ts +9 -0
  243. package/src/tx/builder/field-types/gas-limit.ts +41 -0
  244. package/src/tx/builder/field-types/gas-price.ts +16 -0
  245. package/src/tx/builder/field-types/index.ts +45 -0
  246. package/src/tx/builder/field-types/name-fee.ts +32 -0
  247. package/src/tx/builder/field-types/name-id.ts +20 -0
  248. package/src/tx/builder/field-types/name.ts +18 -0
  249. package/src/tx/builder/field-types/short-u-int.ts +11 -0
  250. package/src/tx/builder/field-types/u-int.ts +16 -0
  251. package/src/tx/builder/helpers.ts +112 -117
  252. package/src/tx/builder/index.ts +203 -197
  253. package/src/tx/builder/schema.ts +421 -465
  254. package/src/tx/index.ts +128 -135
  255. package/src/tx/validator.ts +165 -161
  256. package/src/typings/@aeternity__argon2-browser/index.d.ts +1 -1
  257. package/src/typings/@aeternity__uuid/index.d.ts +3 -1
  258. package/src/typings/bip32-path/index.d.ts +6 -6
  259. package/src/typings/blakejs/index.d.ts +4 -32
  260. package/src/typings/sha-js/index.d.ts +5 -0
  261. package/src/typings/tweetnacl-auth/index.d.ts +2 -2
  262. package/src/utils/amount-formatter.ts +41 -41
  263. package/src/utils/autorest.ts +57 -54
  264. package/src/utils/bignumber.ts +7 -6
  265. package/src/utils/bytes.ts +19 -19
  266. package/src/utils/crypto.ts +82 -94
  267. package/src/utils/encoder-types.ts +63 -0
  268. package/src/utils/encoder.ts +104 -56
  269. package/src/utils/errors.ts +246 -264
  270. package/src/utils/hd-wallet.ts +114 -82
  271. package/src/utils/json-big.ts +16 -15
  272. package/src/utils/keystore.ts +65 -62
  273. package/src/utils/mptree.ts +59 -56
  274. package/src/utils/other.ts +26 -18
  275. package/src/utils/semver-satisfies.ts +15 -11
  276. package/src/utils/string.ts +10 -10
  277. package/es/tx/builder/field-types.d.ts +0 -62
  278. package/es/tx/builder/field-types.mjs +0 -126
  279. package/es/tx/builder/field-types.mjs.map +0 -1
  280. package/es/tx/min-fee.d.ts +0 -20
  281. package/es/tx/min-fee.mjs.map +0 -1
  282. package/src/tx/builder/field-types.ts +0 -111
  283. package/src/tx/min-fee.ts +0 -136
@@ -2,47 +2,67 @@ import _buffer from "buffer";
2
2
  const {
3
3
  Buffer: _Buffer
4
4
  } = _buffer;
5
- import _bs from 'bs58';
5
+ import _bs from 'bs58'; // js extension is required for mjs build, not importing the whole package to reduce bundle size
6
+ // eslint-disable-next-line import/extensions
7
+
6
8
  const {
7
9
  encode: bs58Encode,
8
10
  decode: bs58Decode
9
11
  } = _bs;
10
- import _shaJs from 'sha.js';
11
- const {
12
- sha256: Sha256
13
- } = _shaJs;
12
+ import Sha256 from 'sha.js/sha256.js';
14
13
  import { DecodeError, ArgumentError, InvalidChecksumError, PayloadLengthError } from "./errors.mjs";
15
- import { concatBuffers } from "./other.mjs";
14
+ import { concatBuffers, isKeyOfObject } from "./other.mjs";
15
+ import * as Encoded from "./encoder-types.mjs";
16
+ import { Encoding } from "./encoder-types.mjs";
17
+ export { Encoded, Encoding };
16
18
  /**
17
19
  * Calculate SHA256 hash of `input`
18
20
  * @param input - Data to hash
19
21
  * @returns Hash
22
+ * @deprecated use `SubtleCrypto.digest` or `sha.js` package instead
20
23
  */
21
24
 
22
25
  export function sha256hash(input) {
23
26
  return new Sha256().update(input).digest();
24
- } // based on https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md
27
+ }
28
+ /**
29
+ * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L177-L202}
30
+ */
25
31
 
26
- const base64Types = ['ba', 'cb', 'or', 'ov', 'pi', 'ss', 'cs', 'ck', 'cv', 'st', 'tx'];
27
- const base58Types = ['ak', 'bf', 'bs', 'bx', 'ch', 'cm', 'ct', 'kh', 'mh', 'nm', 'ok', 'oq', 'pp', 'sg', 'th'];
28
- // TODO: add all types with a fixed length
29
- const typesLength = {
30
- ak: 32,
31
- ct: 32,
32
- ok: 32
32
+ const base64Types = [Encoding.ContractBytearray, Encoding.ContractStoreKey, Encoding.ContractStoreValue, Encoding.Transaction, Encoding.OracleQuery, Encoding.OracleResponse, Encoding.State, Encoding.Poi, Encoding.StateTrees, Encoding.CallStateTree, Encoding.Bytearray];
33
+ const base58Types = [Encoding.KeyBlockHash, Encoding.MicroBlockHash, Encoding.BlockPofHash, Encoding.BlockTxHash, Encoding.BlockStateHash, Encoding.Channel, Encoding.ContractAddress, Encoding.TxHash, Encoding.OracleAddress, Encoding.OracleQueryId, Encoding.AccountAddress, Encoding.Signature, Encoding.Commitment, Encoding.PeerPubkey, Encoding.Name];
34
+ /**
35
+ * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L261-L286}
36
+ */
37
+
38
+ const byteSizeForType = {
39
+ [Encoding.KeyBlockHash]: 32,
40
+ [Encoding.MicroBlockHash]: 32,
41
+ [Encoding.BlockPofHash]: 32,
42
+ [Encoding.BlockTxHash]: 32,
43
+ [Encoding.BlockStateHash]: 32,
44
+ [Encoding.Channel]: 32,
45
+ [Encoding.ContractAddress]: 32,
46
+ [Encoding.TxHash]: 32,
47
+ [Encoding.OracleAddress]: 32,
48
+ [Encoding.OracleQueryId]: 32,
49
+ [Encoding.AccountAddress]: 32,
50
+ [Encoding.Signature]: 64,
51
+ [Encoding.Commitment]: 32,
52
+ [Encoding.PeerPubkey]: 32,
53
+ [Encoding.State]: 32
33
54
  };
34
55
 
35
56
  function ensureValidLength(data, type) {
36
- const reqLen = typesLength[type];
57
+ if (!isKeyOfObject(type, byteSizeForType)) return;
58
+ const reqLen = byteSizeForType[type];
37
59
  if (reqLen == null || data.length === reqLen) return;
38
60
  throw new PayloadLengthError(`Payload should be ${reqLen} bytes, got ${data.length} instead`);
39
61
  }
40
62
 
41
63
  const getChecksum = payload => sha256hash(sha256hash(payload)).slice(0, 4);
42
64
 
43
- const addChecksum = payload => {
44
- return concatBuffers([payload, getChecksum(payload)]);
45
- };
65
+ const addChecksum = payload => concatBuffers([payload, getChecksum(payload)]);
46
66
 
47
67
  function getPayload(buffer) {
48
68
  const payload = buffer.slice(0, -4);
@@ -78,10 +98,8 @@ export function decode(data) {
78
98
  const [prefix, encodedPayload, extra] = data.split('_');
79
99
  if (encodedPayload == null) throw new DecodeError(`Encoded string missing payload: ${data}`);
80
100
  if (extra != null) throw new DecodeError(`Encoded string have extra parts: ${data}`);
81
- const [type, {
82
- decode
83
- }] = parseType(prefix);
84
- const payload = decode(encodedPayload);
101
+ const [type, encoder] = parseType(prefix);
102
+ const payload = encoder.decode(encodedPayload);
85
103
  ensureValidLength(payload, type);
86
104
  return payload;
87
105
  }
@@ -93,10 +111,8 @@ export function decode(data) {
93
111
  */
94
112
 
95
113
  export function encode(data, type) {
96
- const [, {
97
- encode
98
- }] = parseType(type);
114
+ const [, encoder] = parseType(type);
99
115
  ensureValidLength(data, type);
100
- return `${type}_${encode(data)}`;
116
+ return `${type}_${encoder.encode(data)}`;
101
117
  }
102
118
  //# sourceMappingURL=encoder.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"encoder.mjs","names":["DecodeError","ArgumentError","InvalidChecksumError","PayloadLengthError","concatBuffers","sha256hash","input","Sha256","update","digest","base64Types","base58Types","typesLength","ak","ct","ok","ensureValidLength","data","type","reqLen","length","getChecksum","payload","slice","addChecksum","getPayload","buffer","equals","base64","encode","toString","decode","string","from","base58","bs58Encode","bs58Decode","parseType","maybeType","base64Type","find","t","base58Type","join","prefix","encodedPayload","extra","split"],"sources":["../../src/utils/encoder.ts"],"sourcesContent":["import { encode as bs58Encode, decode as bs58Decode } from 'bs58'\nimport { sha256 as Sha256 } from 'sha.js'\nimport {\n DecodeError,\n ArgumentError,\n InvalidChecksumError,\n PayloadLengthError\n} from './errors'\nimport { concatBuffers } from './other'\n\n/**\n * Calculate SHA256 hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function sha256hash (input: Uint8Array | string): Buffer {\n return new Sha256().update(input).digest()\n}\n\n// based on https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md\nconst base64Types = ['ba', 'cb', 'or', 'ov', 'pi', 'ss', 'cs', 'ck', 'cv', 'st', 'tx'] as const\nconst base58Types = ['ak', 'bf', 'bs', 'bx', 'ch', 'cm', 'ct', 'kh', 'mh', 'nm', 'ok', 'oq', 'pp', 'sg', 'th'] as const\n\nexport type EncodingType = typeof base64Types[number] | typeof base58Types[number]\nexport type EncodedData<Type extends EncodingType> = `${Type}_${string}`\n// TODO: add all types with a fixed length\nconst typesLength: { [name in EncodingType]?: number } = {\n ak: 32,\n ct: 32,\n ok: 32\n} as const\n\nfunction ensureValidLength (data: Uint8Array, type: EncodingType): void {\n const reqLen = typesLength[type]\n if (reqLen == null || data.length === reqLen) return\n throw new PayloadLengthError(`Payload should be ${reqLen} bytes, got ${data.length} instead`)\n}\n\nconst getChecksum = (payload: Uint8Array): Buffer =>\n sha256hash(sha256hash(payload)).slice(0, 4)\n\nconst addChecksum = (payload: Uint8Array): Buffer => {\n return concatBuffers([payload, getChecksum(payload)])\n}\n\nfunction getPayload (buffer: Buffer): Buffer {\n const payload = buffer.slice(0, -4)\n if (!getChecksum(payload).equals(buffer.slice(-4))) throw new InvalidChecksumError()\n return payload\n}\n\nconst base64 = {\n encode: (buffer: Uint8Array) => addChecksum(buffer).toString('base64'),\n decode: (string: string) => getPayload(Buffer.from(string, 'base64'))\n}\n\nconst base58 = {\n encode: (buffer: Uint8Array) => bs58Encode(addChecksum(buffer)),\n decode: (string: string) => getPayload(Buffer.from(bs58Decode(string)))\n}\n\nconst parseType = (maybeType: unknown): [EncodingType, typeof base64] => {\n const base64Type = base64Types.find(t => t === maybeType)\n if (base64Type != null) return [base64Type, base64]\n const base58Type = base58Types.find(t => t === maybeType)\n if (base58Type != null) return [base58Type, base58]\n throw new ArgumentError('prefix', `one of ${[...base58Types, ...base64Types].join(', ')}`, maybeType)\n}\n\n/**\n * Decode data using the default encoding/decoding algorithm\n * @param data - An Base58/64check encoded and prefixed string\n * (ex tx_..., sg_..., ak_....)\n * @returns Decoded data\n */\nexport function decode (data: EncodedData<EncodingType>): Buffer {\n const [prefix, encodedPayload, extra] = data.split('_')\n if (encodedPayload == null) throw new DecodeError(`Encoded string missing payload: ${data}`)\n if (extra != null) throw new DecodeError(`Encoded string have extra parts: ${data}`)\n const [type, { decode }] = parseType(prefix)\n const payload = decode(encodedPayload)\n ensureValidLength(payload, type)\n return payload\n}\n\n/**\n * Encode data using the default encoding/decoding algorithm\n * @param data - An decoded data\n * @param type - Prefix of Transaction\n * @returns Encoded string Base58check or Base64check data\n */\nexport function encode<Type extends EncodingType> (\n data: Uint8Array, type: Type\n): EncodedData<Type> {\n const [, { encode }] = parseType(type)\n ensureValidLength(data, type)\n return `${type}_${encode(data)}`\n}\n"],"mappings":";;;;AAAA,gBAA2D,MAA3D;;;;;AACA,mBAAiC,QAAjC;;;;SAEEA,W,EACAC,a,EACAC,oB,EACAC,kB;SAEOC,a;AAET;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,UAAT,CAAqBC,KAArB,EAAyD;EAC9D,OAAO,IAAIC,MAAJ,GAAaC,MAAb,CAAoBF,KAApB,EAA2BG,MAA3B,EAAP;AACD,C,CAED;;AACA,MAAMC,WAAW,G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MAAM,CAAC2B,MAAD,EAASC,cAAT,EAAyBC,KAAzB,IAAkC7B,IAAI,CAAC8B,KAAL,CAAW,GAAX,CAAxC;EACA,IAAIF,cAAc,IAAI,IAAtB,EAA4B,MAAM,IAAI7C,WAAJ,CAAiB,mCAAkCiB,IAAK,EAAxD,CAAN;EAC5B,IAAI6B,KAAK,IAAI,IAAb,EAAmB,MAAM,IAAI9C,WAAJ,CAAiB,oCAAmCiB,IAAK,EAAzD,CAAN;EACnB,MAAM,CAACC,IAAD,EAAO;IAAEa;EAAF,CAAP,IAAqBM,SAAS,CAACO,MAAD,CAApC;EACA,MAAMtB,OAAO,GAAGS,MAAM,CAACc,cAAD,CAAtB;EACA7B,iBAAiB,CAACM,OAAD,EAAUJ,IAAV,CAAjB;EACA,OAAOI,OAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,MAAT,CACLZ,IADK,EACaC,IADb,EAEc;EACnB,MAAM,GAAG;IAAEW;EAAF,CAAH,IAAiBQ,SAAS,CAACnB,IAAD,CAAhC;EACAF,iBAAiB,CAACC,IAAD,EAAOC,IAAP,CAAjB;EACA,OAAQ,GAAEA,IAAK,IAAGW,MAAM,CAACZ,IAAD,CAAO,EAA/B;AACD"}
1
+ {"version":3,"file":"encoder.mjs","names":["Sha256","DecodeError","ArgumentError","InvalidChecksumError","PayloadLengthError","concatBuffers","isKeyOfObject","Encoded","Encoding","sha256hash","input","update","digest","base64Types","ContractBytearray","ContractStoreKey","ContractStoreValue","Transaction","OracleQuery","OracleResponse","State","Poi","StateTrees","CallStateTree","Bytearray","base58Types","KeyBlockHash","MicroBlockHash","BlockPofHash","BlockTxHash","BlockStateHash","Channel","ContractAddress","TxHash","OracleAddress","OracleQueryId","AccountAddress","Signature","Commitment","PeerPubkey","Name","byteSizeForType","ensureValidLength","data","type","reqLen","length","getChecksum","payload","slice","addChecksum","getPayload","buffer","equals","base64","encode","toString","decode","string","from","base58","bs58Encode","bs58Decode","parseType","maybeType","base64Type","find","t","base58Type","join","prefix","encodedPayload","extra","split","encoder"],"sources":["../../src/utils/encoder.ts"],"sourcesContent":["import { encode as bs58Encode, decode as bs58Decode } from 'bs58';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport Sha256 from 'sha.js/sha256.js';\nimport {\n DecodeError,\n ArgumentError,\n InvalidChecksumError,\n PayloadLengthError,\n} from './errors';\nimport { concatBuffers, isKeyOfObject } from './other';\nimport * as Encoded from './encoder-types';\nimport { Encoding } from './encoder-types';\n\nexport { Encoded, Encoding };\n\n/**\n * Calculate SHA256 hash of `input`\n * @param input - Data to hash\n * @returns Hash\n * @deprecated use `SubtleCrypto.digest` or `sha.js` package instead\n */\nexport function sha256hash(input: Uint8Array | string): Buffer {\n return new Sha256().update(input).digest();\n}\n\n/**\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L177-L202}\n */\nconst base64Types = [\n Encoding.ContractBytearray,\n Encoding.ContractStoreKey,\n Encoding.ContractStoreValue,\n Encoding.Transaction,\n Encoding.OracleQuery,\n Encoding.OracleResponse,\n Encoding.State,\n Encoding.Poi,\n Encoding.StateTrees,\n Encoding.CallStateTree,\n Encoding.Bytearray,\n] as const;\nconst base58Types = [\n Encoding.KeyBlockHash,\n Encoding.MicroBlockHash,\n Encoding.BlockPofHash,\n Encoding.BlockTxHash,\n Encoding.BlockStateHash,\n Encoding.Channel,\n Encoding.ContractAddress,\n Encoding.TxHash,\n Encoding.OracleAddress,\n Encoding.OracleQueryId,\n Encoding.AccountAddress,\n Encoding.Signature,\n Encoding.Commitment,\n Encoding.PeerPubkey,\n Encoding.Name,\n] as const;\n\n/**\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L261-L286}\n */\nconst byteSizeForType = {\n [Encoding.KeyBlockHash]: 32,\n [Encoding.MicroBlockHash]: 32,\n [Encoding.BlockPofHash]: 32,\n [Encoding.BlockTxHash]: 32,\n [Encoding.BlockStateHash]: 32,\n [Encoding.Channel]: 32,\n [Encoding.ContractAddress]: 32,\n [Encoding.TxHash]: 32,\n [Encoding.OracleAddress]: 32,\n [Encoding.OracleQueryId]: 32,\n [Encoding.AccountAddress]: 32,\n [Encoding.Signature]: 64,\n [Encoding.Commitment]: 32,\n [Encoding.PeerPubkey]: 32,\n [Encoding.State]: 32,\n} as const;\n\nfunction ensureValidLength(data: Uint8Array, type: Encoding): void {\n if (!isKeyOfObject(type, byteSizeForType)) return;\n const reqLen = byteSizeForType[type];\n if (reqLen == null || data.length === reqLen) return;\n throw new PayloadLengthError(`Payload should be ${reqLen} bytes, got ${data.length} instead`);\n}\n\nconst getChecksum = (payload: Uint8Array): Buffer => sha256hash(sha256hash(payload)).slice(0, 4);\n\nconst addChecksum = (payload: Uint8Array): Buffer => concatBuffers([payload, getChecksum(payload)]);\n\nfunction getPayload(buffer: Buffer): Buffer {\n const payload = buffer.slice(0, -4);\n if (!getChecksum(payload).equals(buffer.slice(-4))) throw new InvalidChecksumError();\n return payload;\n}\n\nconst base64 = {\n encode: (buffer: Uint8Array) => addChecksum(buffer).toString('base64'),\n decode: (string: string) => getPayload(Buffer.from(string, 'base64')),\n};\n\nconst base58 = {\n encode: (buffer: Uint8Array) => bs58Encode(addChecksum(buffer)),\n decode: (string: string) => getPayload(Buffer.from(bs58Decode(string))),\n};\n\nconst parseType = (maybeType: unknown): [Encoding, typeof base64] => {\n const base64Type = base64Types.find((t) => t === maybeType);\n if (base64Type != null) return [base64Type, base64];\n const base58Type = base58Types.find((t) => t === maybeType);\n if (base58Type != null) return [base58Type, base58];\n throw new ArgumentError('prefix', `one of ${[...base58Types, ...base64Types].join(', ')}`, maybeType);\n};\n\n/**\n * Decode data using the default encoding/decoding algorithm\n * @param data - An Base58/64check encoded and prefixed string\n * (ex tx_..., sg_..., ak_....)\n * @returns Decoded data\n */\nexport function decode(data: Encoded.Any): Buffer {\n const [prefix, encodedPayload, extra] = data.split('_');\n if (encodedPayload == null) throw new DecodeError(`Encoded string missing payload: ${data}`);\n if (extra != null) throw new DecodeError(`Encoded string have extra parts: ${data}`);\n const [type, encoder] = parseType(prefix);\n const payload = encoder.decode(encodedPayload);\n ensureValidLength(payload, type);\n return payload;\n}\n\n/**\n * Encode data using the default encoding/decoding algorithm\n * @param data - An decoded data\n * @param type - Prefix of Transaction\n * @returns Encoded string Base58check or Base64check data\n */\nexport function encode<Type extends Encoding>(\n data: Uint8Array,\n type: Type,\n): Encoded.Generic<Type> {\n const [, encoder] = parseType(type);\n ensureValidLength(data, type);\n return `${type}_${encoder.encode(data)}`;\n}\n"],"mappings":";;;;AAAA,gBAA2D,MAA3D,C,CACA;AACA;;;;;;AACA,OAAOA,MAAP,MAAmB,kBAAnB;SAEEC,W,EACAC,a,EACAC,oB,EACAC,kB;SAEOC,a,EAAeC,a;OACjB,KAAKC,O;SACHC,Q;AAET,SAASD,OAAT,EAAkBC,QAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,UAAT,CAAoBC,KAApB,EAAwD;EAC7D,OAAO,IAAIV,MAAJ,GAAaW,MAAb,CAAoBD,KAApB,EAA2BE,MAA3B,EAAP;AACD;AAED;AACA;AACA;;AACA,MAAMC,WAAW,GAAG,CAClBL,QAAQ,CAACM,iBADS,EAElBN,QAAQ,CAACO,gBAFS,EAGlBP,QAAQ,CAACQ,kBAHS,EAIlBR,QAAQ,CAACS,WAJS,EAKlBT,QAAQ,CAACU,WALS,EAMlBV,QAAQ,CAACW,cANS,EAOlBX,QAAQ,CAACY,KAPS,EAQlBZ,QAAQ,CAACa,GARS,EASlBb,QAAQ,CAACc,UATS,EAUlBd,QAAQ,CAACe,aAVS,EAWlBf,QAAQ,CAACgB,SAXS,CAApB;AAaA,MAAMC,WAAW,GAAG,CAClBjB,QAAQ,CAACkB,YADS,EAElBlB,QAAQ,CAACmB,cAFS,EAGlBnB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AAO,SAASO,MAAT,CACLZ,IADK,EAELC,IAFK,EAGkB;EACvB,MAAM,GAAG8B,OAAH,IAAcX,SAAS,CAACnB,IAAD,CAA7B;EACAF,iBAAiB,CAACC,IAAD,EAAOC,IAAP,CAAjB;EACA,OAAQ,GAAEA,IAAK,IAAG8B,OAAO,CAACnB,MAAR,CAAeZ,IAAf,CAAqB,EAAvC;AACD"}
@@ -1,6 +1,4 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { ValidatorResult } from '../tx/validator';
3
- import { EncodedData } from './encoder';
4
2
  /**
5
3
  * aepp-sdk originated error
6
4
  * @category exception
@@ -108,7 +106,7 @@ export declare class NoSerializerFoundError extends BaseError {
108
106
  * @category exception
109
107
  */
110
108
  export declare class RequestTimedOutError extends BaseError {
111
- constructor(requestTime: number, currentHeight?: number, height?: number);
109
+ constructor(height: number);
112
110
  }
113
111
  /**
114
112
  * @category exception
@@ -405,14 +403,6 @@ export declare class IllegalBidFeeError extends TransactionError {
405
403
  export declare class InvalidSignatureError extends TransactionError {
406
404
  constructor(message: string);
407
405
  }
408
- /**
409
- * @category exception
410
- */
411
- export declare class InvalidTxError extends TransactionError {
412
- validation: ValidatorResult[];
413
- transaction: EncodedData<'tx'>;
414
- constructor(message: string, validation: ValidatorResult[], transaction: EncodedData<'tx'>);
415
- }
416
406
  /**
417
407
  * @category exception
418
408
  */
@@ -1,3 +1,5 @@
1
+ // eslint-disable-next-line max-classes-per-file
2
+
1
3
  /**
2
4
  * aepp-sdk originated error
3
5
  * @category exception
@@ -190,13 +192,8 @@ export class NoSerializerFoundError extends BaseError {
190
192
  */
191
193
 
192
194
  export class RequestTimedOutError extends BaseError {
193
- constructor(requestTime, currentHeight, height) {
194
- if (currentHeight !== undefined && height !== undefined) {
195
- super(`Giving up after ${requestTime}ms, current height: ${currentHeight}, desired height: ${height}`);
196
- } else {
197
- super(`Giving up after ${requestTime} ms`);
198
- }
199
-
195
+ constructor(height) {
196
+ super(`Giving up at height ${height}`);
200
197
  this.name = 'RequestTimedOutError';
201
198
  }
202
199
 
@@ -749,19 +746,6 @@ export class InvalidSignatureError extends TransactionError {
749
746
  * @category exception
750
747
  */
751
748
 
752
- export class InvalidTxError extends TransactionError {
753
- constructor(message, validation, transaction) {
754
- super(message);
755
- this.name = 'InvalidTxError';
756
- this.validation = validation;
757
- this.transaction = transaction;
758
- }
759
-
760
- }
761
- /**
762
- * @category exception
763
- */
764
-
765
749
  export class InvalidTxParamsError extends TransactionError {
766
750
  constructor(message) {
767
751
  super(message);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":["BaseError","Error","constructor","message","name","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","argumentName","requirement","argumentValue","String","IllegalArgumentError","ArgumentCountMismatchError","functionName","requiredCount","providedCount","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","requestTime","currentHeight","height","undefined","TxTimedOutError","blocks","th","join","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","dependency","version","geVersion","ltVersion","InternalError","UnexpectedTsError","InvalidKeypairError","UnavailableAccountError","address","AensPointerContextError","nameOrId","prefix","InsufficientNameFeeError","nameFee","minNameFee","toString","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","id","UnAuthorizedAccountError","onAccount","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","source","DuplicateContractError","InactiveContractError","contractAddress","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","transaction","NoSuchContractFunctionError","NotPayableFunctionError","amount","fn","MissingEventDefinitionError","eventNameHash","eventAddress","AmbiguousEventDefinitionError","matchedEvents","map","InvalidChecksumError","InvalidPasswordError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","nodeLength","UnknownPathNibbleError","nibble","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","InvalidTxError","validation","InvalidTxParamsError","PrefixNotFoundError","tag","SchemaNotFoundError","schemaName","key","TagNotFoundError","TxNotInChainError","txHash","UnknownTxError","UnsupportedABIversionError","UnsupportedVMversionError","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["import BigNumber from 'bignumber.js'\nimport { ValidatorResult } from '../tx/validator'\nimport { EncodedData } from './encoder'\n\n/**\n * aepp-sdk originated error\n * @category exception\n */\nexport abstract class BaseError extends Error {\n constructor (message: string) {\n super(message)\n this.name = 'BaseError'\n }\n}\n\n/**\n * @category exception\n */\nexport class AccountError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'AccountError'\n }\n}\n\n/**\n * @category exception\n */\nexport class AensError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'AensError'\n }\n}\n\n/**\n * @category exception\n */\nexport class AeppError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'AeppError'\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'ChannelError'\n }\n}\n\n/**\n * @category exception\n */\nexport class CompilerError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'CompilerError'\n }\n}\n\n/**\n * @category exception\n */\nexport class ContractError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'ContractError'\n }\n}\n\n/**\n * @category exception\n */\nexport class CryptographyError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'CryptographyError'\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'NodeError'\n }\n}\n\n/**\n * @category exception\n */\nexport class TransactionError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'TransactionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class WalletError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'WalletError'\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentError extends BaseError {\n constructor (argumentName: string, requirement: string, argumentValue: any) {\n super(`${argumentName} should be ${requirement}, got ${String(argumentValue)} instead`)\n this.name = 'ArgumentError'\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalArgumentError extends CryptographyError {\n constructor (message: string) {\n super(message)\n this.name = 'IllegalArgumentError'\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentCountMismatchError extends BaseError {\n constructor (functionName: string, requiredCount: number, providedCount: number) {\n super(`${functionName} expects ${requiredCount} arguments, got ${providedCount} instead`)\n this.name = 'ArgumentCountMismatchError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientBalanceError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'InsufficientBalanceError'\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingParamError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'MissingParamError'\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSerializerFoundError extends BaseError {\n constructor () {\n super('Byte serialization not supported')\n this.name = 'NoSerializerFoundError'\n }\n}\n\n/**\n * @category exception\n */\nexport class RequestTimedOutError extends BaseError {\n constructor (requestTime: number, currentHeight?: number, height?: number) {\n if (currentHeight !== undefined && height !== undefined) {\n super(`Giving up after ${requestTime}ms, current height: ${currentHeight}, desired height: ${height}`)\n } else {\n super(`Giving up after ${requestTime} ms`)\n }\n this.name = 'RequestTimedOutError'\n }\n}\n\n/**\n * @category exception\n */\nexport class TxTimedOutError extends BaseError {\n constructor (blocks: number, th: string) {\n super([\n `Giving up after ${blocks} blocks mined`,\n `transaction hash: ${th}`\n ].join(', '))\n this.name = 'TxTimedOutError'\n }\n}\n\n/**\n * @category exception\n */\nexport class TypeError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'TypeError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedPlatformError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'UnsupportedPlatformError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedProtocolError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'UnsupportedProtocolError'\n }\n}\n\n/**\n * @category exception\n */\nexport class NotImplementedError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'NotImplementedError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedVersionError extends BaseError {\n constructor (dependency: string, version: string, geVersion: string, ltVersion: string) {\n super(`Unsupported ${dependency} version ${version}. Supported: >= ${geVersion} < ${ltVersion}`)\n this.name = 'UnsupportedVersionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InternalError extends BaseError {\n constructor (message: string) {\n super(message)\n this.name = 'InternalError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedTsError extends InternalError {\n constructor (message: string = 'Expected to not happen, required for TS') {\n super(message)\n this.name = 'UnexpectedTsError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidKeypairError extends AccountError {\n constructor (message: string) {\n super(message)\n this.name = 'InvalidKeypairError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnavailableAccountError extends AccountError {\n constructor (address: string) {\n super(`Account for ${address} not available`)\n this.name = 'UnavailableAccountError'\n }\n}\n\n/**\n * @category exception\n */\nexport class AensPointerContextError extends AensError {\n constructor (nameOrId: string, prefix: string) {\n super(`Name ${nameOrId} don't have pointers for ${prefix}`)\n this.name = 'AensPointerContextError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientNameFeeError extends AensError {\n constructor (nameFee: BigNumber, minNameFee: BigNumber) {\n super(`the provided fee ${nameFee.toString()} is not enough to execute the claim, required: ${minNameFee.toString()}`)\n this.name = 'InsufficientNameFeeError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAensNameError extends AensError {\n constructor (message: string) {\n super(message)\n this.name = 'InvalidAensNameError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidRpcMessageError extends AeppError {\n constructor (message: string) {\n super(`Received invalid message: ${message}`)\n this.name = 'InvalidRpcMessageError'\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingCallbackError extends AeppError {\n constructor (id: number) {\n super(`Can't find callback for this messageId ${id}`)\n this.name = 'MissingCallbackError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnAuthorizedAccountError extends AeppError {\n constructor (onAccount: string) {\n super(`You do not have access to account ${onAccount}`)\n this.name = 'UnAuthorizedAccountError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownRpcClientError extends AeppError {\n constructor (id: string) {\n super(`RpcClient with id ${id} do not exist`)\n this.name = 'UnknownRpcClientError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsubscribedAccountError extends AeppError {\n constructor () {\n super('You are not subscribed for an account.')\n this.name = 'UnsubscribedAccountError'\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelCallError extends ChannelError {\n constructor (message: string) {\n super(message)\n this.name = 'ChannelCallError'\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelConnectionError extends ChannelError {\n constructor (message: string) {\n super(message)\n this.name = 'ChannelConnectionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelPingTimedOutError extends ChannelError {\n constructor () {\n super('Server pong timed out')\n this.name = 'ChannelPingTimedOutError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedChannelMessageError extends ChannelError {\n constructor (message: string) {\n super(message)\n this.name = 'UnexpectedChannelMessageError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownChannelStateError extends ChannelError {\n constructor () {\n super('State Channels FSM entered unknown state')\n this.name = 'UnknownChannelStateError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAuthDataError extends CompilerError {\n constructor (message: string) {\n super(message)\n this.name = 'InvalidAuthDataError'\n }\n}\n\n/**\n * @category exception\n */\nexport class BytecodeMismatchError extends ContractError {\n constructor (source: string) {\n super(`Contract ${source} do not correspond to the bytecode deployed on the chain`)\n this.name = 'BytecodeMismatchError'\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateContractError extends ContractError {\n constructor () {\n super('Contract already deployed')\n this.name = 'DuplicateContractError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InactiveContractError extends ContractError {\n constructor (contractAddress: string) {\n super(`Contract with address ${contractAddress} not active`)\n this.name = 'InactiveContractError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidMethodInvocationError extends ContractError {\n constructor (message: string) {\n super(message)\n this.name = 'InvalidMethodInvocationError'\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractAddressError extends ContractError {\n constructor (message: string) {\n super(message)\n this.name = 'MissingContractAddressError'\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractDefError extends ContractError {\n constructor () {\n super('Either ACI or source code is required')\n this.name = 'MissingContractDefError'\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingFunctionNameError extends ContractError {\n constructor () {\n super('Function name is required')\n this.name = 'MissingFunctionNameError'\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeInvocationError extends ContractError {\n transaction: string\n\n constructor (message: string, transaction: string) {\n super(`Invocation failed${message == null ? '' : `: \"${message}\"`}`)\n this.name = 'NodeInvocationError'\n this.transaction = transaction\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSuchContractFunctionError extends ContractError {\n constructor (name: string) {\n super(`Function ${name} doesn't exist in contract`)\n this.name = 'NoSuchContractFunctionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class NotPayableFunctionError extends ContractError {\n constructor (amount: string, fn: string) {\n super(\n `You try to pay \"${amount}\" to function \"${fn}\" which is not payable. ` +\n 'Only payable function can accept coins')\n this.name = 'NotPayableFunctionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingEventDefinitionError extends ContractError {\n constructor (eventNameHash: string, eventAddress: string) {\n super(\n `Can't find definition of ${eventNameHash} event emitted by ${eventAddress}` +\n ' (use omitUnknown option to ignore events like this)'\n )\n this.name = 'MissingEventDefinitionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class AmbiguousEventDefinitionError extends ContractError {\n constructor (eventAddress: string, matchedEvents: Array<[string, string]>) {\n super(\n `Found multiple definitions of \"${matchedEvents[0][1]}\" event emitted by ${eventAddress}` +\n ` in ${matchedEvents.map(([name]) => `\"${name}\"`).join(', ')} contracts` +\n ' (use contractAddressToName option to specify contract name corresponding to address)'\n )\n this.name = 'AmbiguousEventDefinitionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidChecksumError extends CryptographyError {\n constructor () {\n super('Invalid checksum')\n this.name = 'InvalidChecksumError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidPasswordError extends CryptographyError {\n constructor () {\n super('Invalid password or nonce')\n this.name = 'InvalidPasswordError'\n }\n}\n\n/**\n * @category exception\n */\nexport class MerkleTreeHashMismatchError extends CryptographyError {\n constructor () {\n super('Node hash is not equal to provided one')\n this.name = 'MerkleTreeHashMismatchError'\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingNodeInTreeError extends CryptographyError {\n constructor (message: string) {\n super(message)\n this.name = 'MissingNodeInTreeError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownNodeLengthError extends CryptographyError {\n constructor (nodeLength: number) {\n super(`Unknown node length: ${nodeLength}`)\n this.name = 'UnknownNodeLengthError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownPathNibbleError extends CryptographyError {\n constructor (nibble: number) {\n super(`Unknown path nibble: ${nibble}`)\n this.name = 'UnknownPathNibbleError'\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateNodeError extends NodeError {\n constructor (name: string) {\n super(`Node with name ${name} already exist`)\n this.name = 'DuplicateNodeError'\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeNotFoundError extends NodeError {\n constructor (message: string) {\n super(message)\n this.name = 'NodeNotFoundError'\n }\n}\n\n/**\n * @category exception\n */\nexport class DecodeError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'DecodeError'\n }\n}\n\n/**\n * @category exception\n */\nexport class PayloadLengthError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'PayloadLengthError'\n }\n}\n\n/**\n * @category exception\n */\nexport class DryRunError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'DryRunError'\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalBidFeeError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'IllegalBidFeeError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidSignatureError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidTxError extends TransactionError {\n validation: ValidatorResult[]\n transaction: EncodedData<'tx'>\n constructor (message: string, validation: ValidatorResult[], transaction: EncodedData<'tx'>) {\n super(message)\n this.name = 'InvalidTxError'\n this.validation = validation\n this.transaction = transaction\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidTxParamsError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'InvalidTxParamsError'\n }\n}\n\n/**\n * @category exception\n */\nexport class PrefixNotFoundError extends TransactionError {\n constructor (tag: number) {\n super(`Prefix for id-tag ${tag} not found.`)\n this.name = 'PrefixNotFoundError'\n }\n}\n\n/**\n * @category exception\n */\nexport class SchemaNotFoundError extends TransactionError {\n constructor (schemaName: string, key: string, version: number) {\n super(`Transaction ${schemaName} not implemented for ${key} version ${version}`)\n this.name = 'SchemaNotFoundError'\n }\n}\n\n/**\n * @category exception\n */\nexport class TagNotFoundError extends TransactionError {\n constructor (prefix: string) {\n super(`Id tag for prefix ${prefix} not found.`)\n this.name = 'DecodeError'\n }\n}\n\n/**\n * @category exception\n */\nexport class TxNotInChainError extends TransactionError {\n constructor (txHash: string) {\n super(`Transaction ${txHash} is removed from chain`)\n this.name = 'TxNotInChainError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownTxError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'UnknownTxError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedABIversionError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'UnsupportedABIversionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedVMversionError extends TransactionError {\n constructor (message: string) {\n super(message)\n this.name = 'UnsupportedVMversionError'\n }\n}\n\n/**\n * @category exception\n */\nexport class AlreadyConnectedError extends WalletError {\n constructor (message: string) {\n super(message)\n this.name = 'AlreadyConnectedError'\n }\n}\n\n/**\n * @category exception\n */\nexport class NoWalletConnectedError extends WalletError {\n constructor (message: string) {\n super(message)\n this.name = 'NoWalletConnectedError'\n }\n}\n\n/**\n * @category exception\n */\nexport class RpcConnectionError extends WalletError {\n constructor (message: string) {\n super(message)\n this.name = 'RpcConnectionError'\n }\n}\n"],"mappings":"AAIA;AACA;AACA;AACA;AACA,OAAO,MAAeA,SAAf,SAAiCC,KAAjC,CAAuC;EAC5CC,WAAW,CAAEC,OAAF,EAAmB;IAC5B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,WAAZ;EACD;;AAJ2C;AAO9C;AACA;AACA;;AACA,OAAO,MAAMC,YAAN,SAA2BL,SAA3B,CAAqC;EAC1CE,WAAW,CAAEC,OAAF,EAAmB;IAC5B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,cAAZ;EACD;;AAJyC;AAO5C;AACA;AACA;;AACA,OAAO,MAAME,SAAN,SAAwBN,SAAxB,CAAkC;EACvCE,WAAW,CAAEC,OAAF,EAAmB;IAC5B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,WAAZ;EACD;;AAJsC;AAOzC;AACA;AACA;;AACA,OAAO,MAAMG,SAAN,SAAwBP,SAAxB,CAAkC;EACvCE,WAAW,CAAEC,OAAF,EAAmB;IAC5B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,WAAZ;EACD;;AAJsC;AAOzC;AACA;AACA;;AACA,OAAO,MAAMI,YAAN,SAA2BR,SAA3B,C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D;;AAJ6D;AAOhE;AACA;AACA;;AACA,OAAO,MAAMsH,qBAAN,SAAoC5G,WAApC,CAAgD;EACrDZ,WAAW,CAAEC,OAAF,EAAmB;IAC5B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,uBAAZ;EACD;;AAJoD;AAOvD;AACA;AACA;;AACA,OAAO,MAAMuH,sBAAN,SAAqC7G,WAArC,CAAiD;EACtDZ,WAAW,CAAEC,OAAF,EAAmB;IAC5B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,wBAAZ;EACD;;AAJqD;AAOxD;AACA;AACA;;AACA,OAAO,MAAMwH,kBAAN,SAAiC9G,WAAjC,CAA6C;EAClDZ,WAAW,CAAEC,OAAF,EAAmB;IAC5B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,oBAAZ;EACD;;AAJiD"}
1
+ {"version":3,"file":"errors.mjs","names":["BaseError","Error","constructor","message","name","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","argumentName","requirement","argumentValue","String","IllegalArgumentError","ArgumentCountMismatchError","functionName","requiredCount","providedCount","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","height","TxTimedOutError","blocks","th","join","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","dependency","version","geVersion","ltVersion","InternalError","UnexpectedTsError","InvalidKeypairError","UnavailableAccountError","address","AensPointerContextError","nameOrId","prefix","InsufficientNameFeeError","nameFee","minNameFee","toString","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","id","UnAuthorizedAccountError","onAccount","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","source","DuplicateContractError","InactiveContractError","contractAddress","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","transaction","NoSuchContractFunctionError","NotPayableFunctionError","amount","fn","MissingEventDefinitionError","eventNameHash","eventAddress","AmbiguousEventDefinitionError","matchedEvents","map","InvalidChecksumError","InvalidPasswordError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","nodeLength","UnknownPathNibbleError","nibble","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","InvalidTxParamsError","PrefixNotFoundError","tag","SchemaNotFoundError","schemaName","key","TagNotFoundError","TxNotInChainError","txHash","UnknownTxError","UnsupportedABIversionError","UnsupportedVMversionError","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\n\n/**\n * aepp-sdk originated error\n * @category exception\n */\nexport abstract class BaseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'BaseError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AccountError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AensError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AeppError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AeppError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CompilerError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CompilerError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ContractError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CryptographyError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CryptographyError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TransactionError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TransactionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class WalletError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'WalletError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentError extends BaseError {\n constructor(argumentName: string, requirement: string, argumentValue: any) {\n super(`${argumentName} should be ${requirement}, got ${String(argumentValue)} instead`);\n this.name = 'ArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalArgumentError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentCountMismatchError extends BaseError {\n constructor(functionName: string, requiredCount: number, providedCount: number) {\n super(`${functionName} expects ${requiredCount} arguments, got ${providedCount} instead`);\n this.name = 'ArgumentCountMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientBalanceError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InsufficientBalanceError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingParamError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingParamError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSerializerFoundError extends BaseError {\n constructor() {\n super('Byte serialization not supported');\n this.name = 'NoSerializerFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RequestTimedOutError extends BaseError {\n constructor(height: number) {\n super(`Giving up at height ${height}`);\n this.name = 'RequestTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxTimedOutError extends BaseError {\n constructor(blocks: number, th: string) {\n super([\n `Giving up after ${blocks} blocks mined`,\n `transaction hash: ${th}`,\n ].join(', '));\n this.name = 'TxTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TypeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TypeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedPlatformError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedPlatformError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedProtocolError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedProtocolError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotImplementedError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NotImplementedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedVersionError extends BaseError {\n constructor(dependency: string, version: string, geVersion: string, ltVersion: string) {\n super(`Unsupported ${dependency} version ${version}. Supported: >= ${geVersion} < ${ltVersion}`);\n this.name = 'UnsupportedVersionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InternalError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InternalError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedTsError extends InternalError {\n constructor(message = 'Expected to not happen, required for TS') {\n super(message);\n this.name = 'UnexpectedTsError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidKeypairError extends AccountError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidKeypairError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnavailableAccountError extends AccountError {\n constructor(address: string) {\n super(`Account for ${address} not available`);\n this.name = 'UnavailableAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensPointerContextError extends AensError {\n constructor(nameOrId: string, prefix: string) {\n super(`Name ${nameOrId} don't have pointers for ${prefix}`);\n this.name = 'AensPointerContextError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientNameFeeError extends AensError {\n constructor(nameFee: BigNumber, minNameFee: BigNumber) {\n super(`the provided fee ${nameFee.toString()} is not enough to execute the claim, required: ${minNameFee.toString()}`);\n this.name = 'InsufficientNameFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAensNameError extends AensError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAensNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidRpcMessageError extends AeppError {\n constructor(message: string) {\n super(`Received invalid message: ${message}`);\n this.name = 'InvalidRpcMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingCallbackError extends AeppError {\n constructor(id: number) {\n super(`Can't find callback for this messageId ${id}`);\n this.name = 'MissingCallbackError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnAuthorizedAccountError extends AeppError {\n constructor(onAccount: string) {\n super(`You do not have access to account ${onAccount}`);\n this.name = 'UnAuthorizedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownRpcClientError extends AeppError {\n constructor(id: string) {\n super(`RpcClient with id ${id} do not exist`);\n this.name = 'UnknownRpcClientError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsubscribedAccountError extends AeppError {\n constructor() {\n super('You are not subscribed for an account.');\n this.name = 'UnsubscribedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelCallError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelCallError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelConnectionError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelConnectionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelPingTimedOutError extends ChannelError {\n constructor() {\n super('Server pong timed out');\n this.name = 'ChannelPingTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedChannelMessageError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'UnexpectedChannelMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownChannelStateError extends ChannelError {\n constructor() {\n super('State Channels FSM entered unknown state');\n this.name = 'UnknownChannelStateError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAuthDataError extends CompilerError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAuthDataError';\n }\n}\n\n/**\n * @category exception\n */\nexport class BytecodeMismatchError extends ContractError {\n constructor(source: string) {\n super(`Contract ${source} do not correspond to the bytecode deployed on the chain`);\n this.name = 'BytecodeMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateContractError extends ContractError {\n constructor() {\n super('Contract already deployed');\n this.name = 'DuplicateContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InactiveContractError extends ContractError {\n constructor(contractAddress: string) {\n super(`Contract with address ${contractAddress} not active`);\n this.name = 'InactiveContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidMethodInvocationError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidMethodInvocationError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractAddressError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingContractAddressError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractDefError extends ContractError {\n constructor() {\n super('Either ACI or source code is required');\n this.name = 'MissingContractDefError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingFunctionNameError extends ContractError {\n constructor() {\n super('Function name is required');\n this.name = 'MissingFunctionNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeInvocationError extends ContractError {\n transaction: string;\n\n constructor(message: string, transaction: string) {\n super(`Invocation failed${message == null ? '' : `: \"${message}\"`}`);\n this.name = 'NodeInvocationError';\n this.transaction = transaction;\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSuchContractFunctionError extends ContractError {\n constructor(name: string) {\n super(`Function ${name} doesn't exist in contract`);\n this.name = 'NoSuchContractFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotPayableFunctionError extends ContractError {\n constructor(amount: string, fn: string) {\n super(\n `You try to pay \"${amount}\" to function \"${fn}\" which is not payable. `\n + 'Only payable function can accept coins',\n );\n this.name = 'NotPayableFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingEventDefinitionError extends ContractError {\n constructor(eventNameHash: string, eventAddress: string) {\n super(\n `Can't find definition of ${eventNameHash} event emitted by ${eventAddress}`\n + ' (use omitUnknown option to ignore events like this)',\n );\n this.name = 'MissingEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AmbiguousEventDefinitionError extends ContractError {\n constructor(eventAddress: string, matchedEvents: Array<[string, string]>) {\n super(\n `Found multiple definitions of \"${matchedEvents[0][1]}\" event emitted by ${eventAddress}`\n + ` in ${matchedEvents.map(([name]) => `\"${name}\"`).join(', ')} contracts`\n + ' (use contractAddressToName option to specify contract name corresponding to address)',\n );\n this.name = 'AmbiguousEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidChecksumError extends CryptographyError {\n constructor() {\n super('Invalid checksum');\n this.name = 'InvalidChecksumError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidPasswordError extends CryptographyError {\n constructor() {\n super('Invalid password or nonce');\n this.name = 'InvalidPasswordError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MerkleTreeHashMismatchError extends CryptographyError {\n constructor() {\n super('Node hash is not equal to provided one');\n this.name = 'MerkleTreeHashMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingNodeInTreeError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingNodeInTreeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownNodeLengthError extends CryptographyError {\n constructor(nodeLength: number) {\n super(`Unknown node length: ${nodeLength}`);\n this.name = 'UnknownNodeLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownPathNibbleError extends CryptographyError {\n constructor(nibble: number) {\n super(`Unknown path nibble: ${nibble}`);\n this.name = 'UnknownPathNibbleError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateNodeError extends NodeError {\n constructor(name: string) {\n super(`Node with name ${name} already exist`);\n this.name = 'DuplicateNodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeNotFoundError extends NodeError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DecodeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PayloadLengthError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'PayloadLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DryRunError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DryRunError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalBidFeeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalBidFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidSignatureError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidSignatureError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidTxParamsError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidTxParamsError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PrefixNotFoundError extends TransactionError {\n constructor(tag: number) {\n super(`Prefix for id-tag ${tag} not found.`);\n this.name = 'PrefixNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class SchemaNotFoundError extends TransactionError {\n constructor(schemaName: string, key: string, version: number) {\n super(`Transaction ${schemaName} not implemented for ${key} version ${version}`);\n this.name = 'SchemaNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TagNotFoundError extends TransactionError {\n constructor(prefix: string) {\n super(`Id tag for prefix ${prefix} not found.`);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxNotInChainError extends TransactionError {\n constructor(txHash: string) {\n super(`Transaction ${txHash} is removed from chain`);\n this.name = 'TxNotInChainError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownTxError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'UnknownTxError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedABIversionError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedABIversionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedVMversionError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedVMversionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AlreadyConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoWalletConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'NoWalletConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RpcConnectionError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'RpcConnectionError';\n }\n}\n"],"mappings":"AAAA;;AAGA;AACA;AACA;AACA;AACA,OAAO,MAAeA,SAAf,SAAiCC,KAAjC,CAAuC;EAC5CC,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,WAAZ;EACD;;AAJ2C;AAO9C;AACA;AACA;;AACA,OAAO,MAAMC,YAAN,SAA2BL,SAA3B,CAAqC;EAC1CE,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,cAAZ;EACD;;AAJyC;AAO5C;AACA;AACA;;AACA,OAAO,MAAME,SAAN,SAAwBN,SAAxB,CAAkC;EACvCE,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,WAAZ;EACD;;AAJsC;AAOzC;AACA;AACA;;AACA,OAAO,MAAMG,SAAN,SAAwBP,SAAxB,CAAkC;EACvCE,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,WAAZ;EACD;;AAJsC;AAOzC;AACA;AACA;;AACA,OAAO,MAAMI,YAAN,SAA2BR,SAA3B,CAAqC;EAC1CE,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,cAAZ;EACD;;AAJyC;AAO5C;AACA;AACA;;AACA,OAAO,MAAMK,aAAN,SAA4BT,SAA5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AAcA,MAAO,wBAA5B;IACA,KAAK7G,IAAL,GAAY,mBAAZ;EACD;;AAJqD;AAOxD;AACA;AACA;;AACA,OAAO,MAAM8G,cAAN,SAA6BrG,gBAA7B,CAA8C;EACnDX,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,gBAAZ;EACD;;AAJkD;AAOrD;AACA;AACA;;AACA,OAAO,MAAM+G,0BAAN,SAAyCtG,gBAAzC,CAA0D;EAC/DX,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,4BAAZ;EACD;;AAJ8D;AAOjE;AACA;AACA;;AACA,OAAO,MAAMgH,yBAAN,SAAwCvG,gBAAxC,CAAyD;EAC9DX,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,2BAAZ;EACD;;AAJ6D;AAOhE;AACA;AACA;;AACA,OAAO,MAAMiH,qBAAN,SAAoCvG,WAApC,CAAgD;EACrDZ,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,uBAAZ;EACD;;AAJoD;AAOvD;AACA;AACA;;AACA,OAAO,MAAMkH,sBAAN,SAAqCxG,WAArC,CAAiD;EACtDZ,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,wBAAZ;EACD;;AAJqD;AAOxD;AACA;AACA;;AACA,OAAO,MAAMmH,kBAAN,SAAiCzG,WAAjC,CAA6C;EAClDZ,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,oBAAZ;EACD;;AAJiD"}
@@ -1,5 +1,21 @@
1
1
  import nacl from 'tweetnacl';
2
2
  import { CryptographyError } from './errors';
3
+ /**
4
+ * Encrypt given data using `password`
5
+ * @param password - Password to encrypt with
6
+ * @param binaryData - Data to encrypt
7
+ * @returns Encrypted data
8
+ * @deprecated use 'sha.js' and 'aes-js' packages directly instead
9
+ */
10
+ export declare function encryptKey(password: string, binaryData: Uint8Array): Uint8Array;
11
+ /**
12
+ * Decrypt given data using `password`
13
+ * @param password - Password to decrypt with
14
+ * @param encrypted - Data to decrypt
15
+ * @returns Decrypted data
16
+ * @deprecated use 'sha.js' and 'aes-js' packages directly instead
17
+ */
18
+ export declare function decryptKey(password: string, encrypted: Uint8Array): Uint8Array;
3
19
  /**
4
20
  * @category exception
5
21
  */
@@ -21,11 +37,11 @@ interface Account {
21
37
  declare type Dec<N extends number> = [-1, 0, 1, 2, 3, 4][N];
22
38
  declare type Bip32PathT<MaxLen extends number, H extends 'H' | 'h' | '\''> = MaxLen extends -1 ? `${number}${H}` : Bip32PathT<Dec<MaxLen>, H> | `${Bip32PathT<Dec<MaxLen>, H>}/${number}${H}`;
23
39
  declare type Bip32Path<MaxLen extends number> = '' | Bip32PathT<MaxLen, 'H'> | Bip32PathT<MaxLen, 'h'> | Bip32PathT<MaxLen, '\''>;
40
+ export declare function deriveChild({ secretKey, chainCode }: KeyTreeNode, index: number): KeyTreeNode;
24
41
  export declare function derivePathFromKey(path: Bip32Path<5>, key: KeyTreeNode): KeyTreeNode;
42
+ export declare function getMasterKeyFromSeed(seed: Uint8Array): KeyTreeNode;
25
43
  export declare function derivePathFromSeed(path: 'm' | `m/${Bip32Path<5>}`, seed: Uint8Array): KeyTreeNode;
26
44
  export declare function getKeyPair(secretKey: Uint8Array): nacl.SignKeyPair;
27
- export declare function getMasterKeyFromSeed(seed: Uint8Array): KeyTreeNode;
28
- export declare function deriveChild({ secretKey, chainCode }: KeyTreeNode, index: number): KeyTreeNode;
29
45
  export declare function generateSaveHDWalletFromSeed(seed: Uint8Array, password: string): HDWallet;
30
46
  export declare function getSaveHDWalletAccounts(saveHDWallet: HDWallet, password: string, accountCount: number): Account[];
31
47
  export declare const getHdWalletAccountFromSeed: (seed: Uint8Array, accountIdx: number) => Account & {
@@ -12,11 +12,41 @@ import _bip32Path from 'bip32-path';
12
12
  const {
13
13
  fromString
14
14
  } = _bip32Path;
15
- import { decryptKey, encryptKey } from "./crypto.mjs";
16
- import { encode } from "./encoder.mjs";
15
+ import aesjs from 'aes-js';
16
+ import { sha256hash, encode, Encoding } from "./encoder.mjs";
17
17
  import { CryptographyError } from "./errors.mjs";
18
18
  import { bytesToHex } from "./bytes.mjs";
19
19
  import { concatBuffers } from "./other.mjs";
20
+ const Ecb = aesjs.ModeOfOperation.ecb; // TODO: at least don't export `encryptKey` and `decryptKey`
21
+
22
+ /**
23
+ * Encrypt given data using `password`
24
+ * @param password - Password to encrypt with
25
+ * @param binaryData - Data to encrypt
26
+ * @returns Encrypted data
27
+ * @deprecated use 'sha.js' and 'aes-js' packages directly instead
28
+ */
29
+
30
+ export function encryptKey(password, binaryData) {
31
+ const hashedPasswordBytes = sha256hash(password);
32
+ const aesEcb = new Ecb(hashedPasswordBytes);
33
+ return aesEcb.encrypt(binaryData);
34
+ }
35
+ /**
36
+ * Decrypt given data using `password`
37
+ * @param password - Password to decrypt with
38
+ * @param encrypted - Data to decrypt
39
+ * @returns Decrypted data
40
+ * @deprecated use 'sha.js' and 'aes-js' packages directly instead
41
+ */
42
+
43
+ export function decryptKey(password, encrypted) {
44
+ const encryptedBytes = _Buffer.from(encrypted);
45
+
46
+ const hashedPasswordBytes = sha256hash(password);
47
+ const aesEcb = new Ecb(hashedPasswordBytes);
48
+ return aesEcb.decrypt(encryptedBytes);
49
+ }
20
50
  /**
21
51
  * @category exception
22
52
  */
@@ -32,6 +62,28 @@ export class DerivationError extends CryptographyError {
32
62
  const ED25519_CURVE = _Buffer.from('ed25519 seed');
33
63
 
34
64
  const HARDENED_OFFSET = 0x80000000;
65
+ export function deriveChild(_ref, index) {
66
+ let {
67
+ secretKey,
68
+ chainCode
69
+ } = _ref;
70
+
71
+ if (index < HARDENED_OFFSET) {
72
+ throw new DerivationError(`Segment ${index} is not hardened`);
73
+ }
74
+
75
+ const indexBuffer = _Buffer.allocUnsafe(4);
76
+
77
+ indexBuffer.writeUInt32BE(index, 0);
78
+ const data = concatBuffers([_Buffer.alloc(1, 0), secretKey, indexBuffer]);
79
+ const I = hmac(data, chainCode);
80
+ const IL = I.slice(0, 32);
81
+ const IR = I.slice(32);
82
+ return {
83
+ secretKey: IL,
84
+ chainCode: IR
85
+ };
86
+ }
35
87
  export function derivePathFromKey(path, key) {
36
88
  const segments = path === '' ? [] : fromString(path).toPathArray();
37
89
  segments.forEach((segment, i) => {
@@ -41,6 +93,15 @@ export function derivePathFromKey(path, key) {
41
93
  });
42
94
  return segments.reduce((parentKey, segment) => deriveChild(parentKey, segment), key);
43
95
  }
96
+ export function getMasterKeyFromSeed(seed) {
97
+ const I = hmac(seed, ED25519_CURVE);
98
+ const IL = I.slice(0, 32);
99
+ const IR = I.slice(32);
100
+ return {
101
+ secretKey: IL,
102
+ chainCode: IR
103
+ };
104
+ }
44
105
  export function derivePathFromSeed(path, seed) {
45
106
  var _context;
46
107
 
@@ -59,44 +120,13 @@ function formatAccount(keys) {
59
120
  } = keys;
60
121
  return {
61
122
  secretKey: bytesToHex(secretKey),
62
- publicKey: encode(publicKey, 'ak')
123
+ publicKey: encode(publicKey, Encoding.AccountAddress)
63
124
  };
64
125
  }
65
126
 
66
127
  export function getKeyPair(secretKey) {
67
128
  return nacl.sign.keyPair.fromSeed(secretKey);
68
129
  }
69
- export function getMasterKeyFromSeed(seed) {
70
- const I = hmac(seed, ED25519_CURVE);
71
- const IL = I.slice(0, 32);
72
- const IR = I.slice(32);
73
- return {
74
- secretKey: IL,
75
- chainCode: IR
76
- };
77
- }
78
- export function deriveChild(_ref, index) {
79
- let {
80
- secretKey,
81
- chainCode
82
- } = _ref;
83
-
84
- if (index < HARDENED_OFFSET) {
85
- throw new DerivationError(`Segment ${index} is not hardened`);
86
- }
87
-
88
- const indexBuffer = _Buffer.allocUnsafe(4);
89
-
90
- indexBuffer.writeUInt32BE(index, 0);
91
- const data = concatBuffers([_Buffer.alloc(1, 0), secretKey, indexBuffer]);
92
- const I = hmac(data, chainCode);
93
- const IL = I.slice(0, 32);
94
- const IR = I.slice(32);
95
- return {
96
- secretKey: IL,
97
- chainCode: IR
98
- };
99
- }
100
130
  export function generateSaveHDWalletFromSeed(seed, password) {
101
131
  const walletKey = derivePathFromSeed('m/44h/457h', seed);
102
132
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"hd-wallet.mjs","names":["nacl","decryptKey","encryptKey","encode","CryptographyError","bytesToHex","concatBuffers","DerivationError","constructor","message","name","ED25519_CURVE","from","HARDENED_OFFSET","derivePathFromKey","path","key","segments","fromString","toPathArray","forEach","segment","i","reduce","parentKey","deriveChild","derivePathFromSeed","seed","slice","masterKey","getMasterKeyFromSeed","formatAccount","keys","secretKey","publicKey","getKeyPair","sign","keyPair","fromSeed","I","hmac","IL","IR","chainCode","index","indexBuffer","allocUnsafe","writeUInt32BE","data","alloc","generateSaveHDWalletFromSeed","password","walletKey","getSaveHDWalletAccounts","saveHDWallet","accountCount","Array","fill","undefined","map","_","idx","getHdWalletAccountFromSeed","accountIdx","derived"],"sources":["../../src/utils/hd-wallet.ts"],"sourcesContent":["import nacl from 'tweetnacl'\nimport { full as hmac } from 'tweetnacl-auth'\nimport { fromString } from 'bip32-path'\nimport { decryptKey, encryptKey } from './crypto'\nimport { encode } from './encoder'\nimport { CryptographyError } from './errors'\nimport { bytesToHex } from './bytes'\nimport { concatBuffers } from './other'\n\n/**\n * @category exception\n */\nexport class DerivationError extends CryptographyError {\n constructor (message: string) {\n super(message)\n this.name = 'DerivationError'\n }\n}\n\nconst ED25519_CURVE = Buffer.from('ed25519 seed')\nconst HARDENED_OFFSET = 0x80000000\n\ninterface KeyTreeNode {\n secretKey: Uint8Array\n chainCode: Uint8Array\n}\n\ninterface HDWallet {\n secretKey: string\n chainCode: string\n}\n\ninterface Account {\n secretKey: string\n publicKey: string\n}\n\ntype Dec<N extends number> = [-1, 0, 1, 2, 3, 4][N]\ntype Bip32PathT<MaxLen extends number, H extends 'H' | 'h' | '\\''> = MaxLen extends -1\n ? `${number}${H}`\n : Bip32PathT<Dec<MaxLen>, H> | `${Bip32PathT<Dec<MaxLen>, H>}/${number}${H}`\ntype Bip32Path<MaxLen extends number> =\n '' | Bip32PathT<MaxLen, 'H'> | Bip32PathT<MaxLen, 'h'> | Bip32PathT<MaxLen, '\\''>\n\nexport function derivePathFromKey (path: Bip32Path<5>, key: KeyTreeNode): KeyTreeNode {\n const segments = path === '' ? [] : fromString(path).toPathArray()\n segments.forEach((segment, i) => {\n if (segment < HARDENED_OFFSET) {\n throw new DerivationError(`Segment #${i + 1} is not hardened`)\n }\n })\n\n return segments.reduce((parentKey, segment) => deriveChild(parentKey, segment), key)\n}\n\nexport function derivePathFromSeed (path: 'm' | `m/${Bip32Path<5>}`, seed: Uint8Array): KeyTreeNode {\n if (!['m', 'm/'].includes(path.slice(0, 2))) {\n throw new DerivationError('Root element is required')\n }\n const masterKey = getMasterKeyFromSeed(seed)\n return derivePathFromKey(path.slice(2) as Bip32Path<5>, masterKey)\n}\n\nfunction formatAccount (keys: nacl.SignKeyPair): Account {\n const { secretKey, publicKey } = keys\n return {\n secretKey: bytesToHex(secretKey),\n publicKey: encode(publicKey, 'ak')\n }\n}\n\nexport function getKeyPair (secretKey: Uint8Array): nacl.SignKeyPair {\n return nacl.sign.keyPair.fromSeed(secretKey)\n}\n\nexport function getMasterKeyFromSeed (seed: Uint8Array): KeyTreeNode {\n const I = hmac(seed, ED25519_CURVE)\n const IL = I.slice(0, 32)\n const IR = I.slice(32)\n return {\n secretKey: IL,\n chainCode: IR\n }\n}\n\nexport function deriveChild ({ secretKey, chainCode }: KeyTreeNode, index: number): KeyTreeNode {\n if (index < HARDENED_OFFSET) {\n throw new DerivationError(`Segment ${index} is not hardened`)\n }\n const indexBuffer = Buffer.allocUnsafe(4)\n indexBuffer.writeUInt32BE(index, 0)\n\n const data = concatBuffers([Buffer.alloc(1, 0), secretKey, indexBuffer])\n\n const I = hmac(data, chainCode)\n const IL = I.slice(0, 32)\n const IR = I.slice(32)\n return {\n secretKey: IL,\n chainCode: IR\n }\n}\n\nexport function generateSaveHDWalletFromSeed (seed: Uint8Array, password: string): HDWallet {\n const walletKey = derivePathFromSeed('m/44h/457h', seed)\n return {\n secretKey: bytesToHex(encryptKey(password, walletKey.secretKey)),\n chainCode: bytesToHex(encryptKey(password, walletKey.chainCode))\n }\n}\n\nexport function getSaveHDWalletAccounts (\n saveHDWallet: HDWallet, password: string, accountCount: number\n): Account[] {\n const walletKey = {\n secretKey: decryptKey(password, Buffer.from(saveHDWallet.secretKey, 'hex')),\n chainCode: decryptKey(password, Buffer.from(saveHDWallet.chainCode, 'hex'))\n }\n return (new Array(accountCount)).fill(undefined)\n .map((_, idx) =>\n formatAccount(getKeyPair(derivePathFromKey(`${idx}h/0h/0h`, walletKey).secretKey)))\n}\n\nexport const getHdWalletAccountFromSeed = (\n seed: Uint8Array, accountIdx: number\n): Account & { idx: number } => {\n const walletKey = derivePathFromSeed('m/44h/457h', seed)\n const derived = derivePathFromKey(`${accountIdx}h/0h/0h`, walletKey)\n const keyPair = getKeyPair(derived.secretKey)\n return {\n ...formatAccount(keyPair),\n idx: accountIdx\n }\n}\n"],"mappings":";;;;;AAAA,OAAOA,IAAP,MAAiB,WAAjB;AACA,2BAA6B,gBAA7B;;;;AACA,uBAA2B,YAA3B;;;;SACSC,U,EAAYC,U;SACZC,M;SACAC,iB;SACAC,U;SACAC,a;AAET;AACA;AACA;;AACA,OAAO,MAAMC,eAAN,SAA8BH,iBAA9B,CAAgD;EACrDI,WAAW,CAAEC,OAAF,EAAmB;IAC5B,MAAMA,OAAN;IACA,KAAKC,IAAL,GAAY,iBAAZ;EACD;;AAJoD;;AAOvD,MAAMC,aAAa,GAAG,QAAOC,IAAP,CAAY,cAAZ,CAAtB;;AACA,MAAMC,eAAe,GAAG,UAAxB;AAwBA,OAAO,SAASC,iBAAT,CAA4BC,IAA5B,EAAgDC,GAAhD,EAA+E;EAC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ArB,CAAX,CADhB;IAELU,SAAS,EAAEtC,UAAU,CAACH,UAAU,CAACiD,QAAD,EAAWC,SAAS,CAACT,SAArB,CAAX;EAFhB,CAAP;AAID;AAED,OAAO,SAASU,uBAAT,CACLC,YADK,EACmBH,QADnB,EACqCI,YADrC,EAEM;EACX,MAAMH,SAAS,GAAG;IAChBnB,SAAS,EAAEhC,UAAU,CAACkD,QAAD,EAAW,QAAOvC,IAAP,CAAY0C,YAAY,CAACrB,SAAzB,EAAoC,KAApC,CAAX,CADL;IAEhBU,SAAS,EAAE1C,UAAU,CAACkD,QAAD,EAAW,QAAOvC,IAAP,CAAY0C,YAAY,CAACX,SAAzB,EAAoC,KAApC,CAAX;EAFL,CAAlB;EAIA,OAAQ,IAAIa,KAAJ,CAAUD,YAAV,CAAD,CAA0BE,IAA1B,CAA+BC,SAA/B,EACJC,GADI,CACA,CAACC,CAAD,EAAIC,GAAJ,KACH9B,aAAa,CAACI,UAAU,CAACrB,iBAAiB,CAAE,GAAE+C,GAAI,SAAR,EAAkBT,SAAlB,CAAjB,CAA8CnB,SAA/C,CAAX,CAFV,CAAP;AAGD;AAED,OAAO,MAAM6B,0BAA0B,GAAG,CACxCnC,IADwC,EACtBoC,UADsB,KAEV;EAC9B,MAAMX,SAAS,GAAG1B,kBAAkB,CAAC,YAAD,EAAeC,IAAf,CAApC;EACA,MAAMqC,OAAO,GAAGlD,iBAAiB,CAAE,GAAEiD,UAAW,SAAf,EAAyBX,SAAzB,CAAjC;EACA,MAAMf,OAAO,GAAGF,UAAU,CAAC6B,OAAO,CAAC/B,SAAT,CAA1B;EACA,OAAO,EACL,GAAGF,aAAa,CAACM,OAAD,CADX;IAELwB,GAAG,EAAEE;EAFA,CAAP;AAID,CAVM"}
1
+ {"version":3,"file":"hd-wallet.mjs","names":["nacl","aesjs","sha256hash","encode","Encoding","CryptographyError","bytesToHex","concatBuffers","Ecb","ModeOfOperation","ecb","encryptKey","password","binaryData","hashedPasswordBytes","aesEcb","encrypt","decryptKey","encrypted","encryptedBytes","from","decrypt","DerivationError","constructor","message","name","ED25519_CURVE","HARDENED_OFFSET","deriveChild","index","secretKey","chainCode","indexBuffer","allocUnsafe","writeUInt32BE","data","alloc","I","hmac","IL","slice","IR","derivePathFromKey","path","key","segments","fromString","toPathArray","forEach","segment","i","reduce","parentKey","getMasterKeyFromSeed","seed","derivePathFromSeed","masterKey","formatAccount","keys","publicKey","AccountAddress","getKeyPair","sign","keyPair","fromSeed","generateSaveHDWalletFromSeed","walletKey","getSaveHDWalletAccounts","saveHDWallet","accountCount","Array","fill","undefined","map","_","idx","getHdWalletAccountFromSeed","accountIdx","derived"],"sources":["../../src/utils/hd-wallet.ts"],"sourcesContent":["import nacl from 'tweetnacl';\nimport { full as hmac } from 'tweetnacl-auth';\nimport { fromString } from 'bip32-path';\nimport aesjs from 'aes-js';\nimport { sha256hash, encode, Encoding } from './encoder';\nimport { CryptographyError } from './errors';\nimport { bytesToHex } from './bytes';\nimport { concatBuffers } from './other';\n\nconst Ecb = aesjs.ModeOfOperation.ecb;\n\n// TODO: at least don't export `encryptKey` and `decryptKey`\n/**\n * Encrypt given data using `password`\n * @param password - Password to encrypt with\n * @param binaryData - Data to encrypt\n * @returns Encrypted data\n * @deprecated use 'sha.js' and 'aes-js' packages directly instead\n */\nexport function encryptKey(password: string, binaryData: Uint8Array): Uint8Array {\n const hashedPasswordBytes = sha256hash(password);\n const aesEcb = new Ecb(hashedPasswordBytes);\n return aesEcb.encrypt(binaryData);\n}\n\n/**\n * Decrypt given data using `password`\n * @param password - Password to decrypt with\n * @param encrypted - Data to decrypt\n * @returns Decrypted data\n * @deprecated use 'sha.js' and 'aes-js' packages directly instead\n */\nexport function decryptKey(password: string, encrypted: Uint8Array): Uint8Array {\n const encryptedBytes = Buffer.from(encrypted);\n const hashedPasswordBytes = sha256hash(password);\n const aesEcb = new Ecb(hashedPasswordBytes);\n return aesEcb.decrypt(encryptedBytes);\n}\n\n/**\n * @category exception\n */\nexport class DerivationError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'DerivationError';\n }\n}\n\nconst ED25519_CURVE = Buffer.from('ed25519 seed');\nconst HARDENED_OFFSET = 0x80000000;\n\ninterface KeyTreeNode {\n secretKey: Uint8Array;\n chainCode: Uint8Array;\n}\n\ninterface HDWallet {\n secretKey: string;\n chainCode: string;\n}\n\ninterface Account {\n secretKey: string;\n publicKey: string;\n}\n\ntype Dec<N extends number> = [-1, 0, 1, 2, 3, 4][N];\ntype Bip32PathT<MaxLen extends number, H extends 'H' | 'h' | '\\''> = MaxLen extends -1\n ? `${number}${H}`\n : Bip32PathT<Dec<MaxLen>, H> | `${Bip32PathT<Dec<MaxLen>, H>}/${number}${H}`;\ntype Bip32Path<MaxLen extends number> =\n '' | Bip32PathT<MaxLen, 'H'> | Bip32PathT<MaxLen, 'h'> | Bip32PathT<MaxLen, '\\''>;\n\nexport function deriveChild({ secretKey, chainCode }: KeyTreeNode, index: number): KeyTreeNode {\n if (index < HARDENED_OFFSET) {\n throw new DerivationError(`Segment ${index} is not hardened`);\n }\n const indexBuffer = Buffer.allocUnsafe(4);\n indexBuffer.writeUInt32BE(index, 0);\n\n const data = concatBuffers([Buffer.alloc(1, 0), secretKey, indexBuffer]);\n\n const I = hmac(data, chainCode);\n const IL = I.slice(0, 32);\n const IR = I.slice(32);\n return {\n secretKey: IL,\n chainCode: IR,\n };\n}\n\nexport function derivePathFromKey(path: Bip32Path<5>, key: KeyTreeNode): KeyTreeNode {\n const segments = path === '' ? [] : fromString(path).toPathArray();\n segments.forEach((segment, i) => {\n if (segment < HARDENED_OFFSET) {\n throw new DerivationError(`Segment #${i + 1} is not hardened`);\n }\n });\n\n return segments.reduce((parentKey, segment) => deriveChild(parentKey, segment), key);\n}\n\nexport function getMasterKeyFromSeed(seed: Uint8Array): KeyTreeNode {\n const I = hmac(seed, ED25519_CURVE);\n const IL = I.slice(0, 32);\n const IR = I.slice(32);\n return {\n secretKey: IL,\n chainCode: IR,\n };\n}\n\nexport function derivePathFromSeed(path: 'm' | `m/${Bip32Path<5>}`, seed: Uint8Array): KeyTreeNode {\n if (!['m', 'm/'].includes(path.slice(0, 2))) {\n throw new DerivationError('Root element is required');\n }\n const masterKey = getMasterKeyFromSeed(seed);\n return derivePathFromKey(path.slice(2) as Bip32Path<5>, masterKey);\n}\n\nfunction formatAccount(keys: nacl.SignKeyPair): Account {\n const { secretKey, publicKey } = keys;\n return {\n secretKey: bytesToHex(secretKey),\n publicKey: encode(publicKey, Encoding.AccountAddress),\n };\n}\n\nexport function getKeyPair(secretKey: Uint8Array): nacl.SignKeyPair {\n return nacl.sign.keyPair.fromSeed(secretKey);\n}\n\nexport function generateSaveHDWalletFromSeed(seed: Uint8Array, password: string): HDWallet {\n const walletKey = derivePathFromSeed('m/44h/457h', seed);\n return {\n secretKey: bytesToHex(encryptKey(password, walletKey.secretKey)),\n chainCode: bytesToHex(encryptKey(password, walletKey.chainCode)),\n };\n}\n\nexport function getSaveHDWalletAccounts(\n saveHDWallet: HDWallet,\n password: string,\n accountCount: number,\n): Account[] {\n const walletKey = {\n secretKey: decryptKey(password, Buffer.from(saveHDWallet.secretKey, 'hex')),\n chainCode: decryptKey(password, Buffer.from(saveHDWallet.chainCode, 'hex')),\n };\n return (new Array(accountCount)).fill(undefined)\n .map((_, idx) => formatAccount(getKeyPair(derivePathFromKey(`${idx}h/0h/0h`, walletKey).secretKey)));\n}\n\nexport const getHdWalletAccountFromSeed = (\n seed: Uint8Array,\n accountIdx: number,\n): Account & { idx: number } => {\n const walletKey = derivePathFromSeed('m/44h/457h', seed);\n const derived = derivePathFromKey(`${accountIdx}h/0h/0h`, walletKey);\n const keyPair = getKeyPair(derived.secretKey);\n return {\n ...formatAccount(keyPair),\n idx: accountIdx,\n };\n};\n"],"mappings":";;;;;AAAA,OAAOA,IAAP,MAAiB,WAAjB;AACA,2BAA6B,gBAA7B;;;;AACA,uBAA2B,YAA3B;;;;AACA,OAAOC,KAAP,MAAkB,QAAlB;SACSC,U,EAAY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EAIM;EACX,MAAMH,SAAS,GAAG;IAChBpC,SAAS,EAAEb,UAAU,CAACL,QAAD,EAAW,QAAOQ,IAAP,CAAYgD,YAAY,CAACtC,SAAzB,EAAoC,KAApC,CAAX,CADL;IAEhBC,SAAS,EAAEd,UAAU,CAACL,QAAD,EAAW,QAAOQ,IAAP,CAAYgD,YAAY,CAACrC,SAAzB,EAAoC,KAApC,CAAX;EAFL,CAAlB;EAIA,OAAQ,IAAIuC,KAAJ,CAAUD,YAAV,CAAD,CAA0BE,IAA1B,CAA+BC,SAA/B,EACJC,GADI,CACA,CAACC,CAAD,EAAIC,GAAJ,KAAYlB,aAAa,CAACI,UAAU,CAACnB,iBAAiB,CAAE,GAAEiC,GAAI,SAAR,EAAkBT,SAAlB,CAAjB,CAA8CpC,SAA/C,CAAX,CADzB,CAAP;AAED;AAED,OAAO,MAAM8C,0BAA0B,GAAG,CACxCtB,IADwC,EAExCuB,UAFwC,KAGV;EAC9B,MAAMX,SAAS,GAAGX,kBAAkB,CAAC,YAAD,EAAeD,IAAf,CAApC;EACA,MAAMwB,OAAO,GAAGpC,iBAAiB,CAAE,GAAEmC,UAAW,SAAf,EAAyBX,SAAzB,CAAjC;EACA,MAAMH,OAAO,GAAGF,UAAU,CAACiB,OAAO,CAAChD,SAAT,CAA1B;EACA,OAAO,EACL,GAAG2B,aAAa,CAACM,OAAD,CADX;IAELY,GAAG,EAAEE;EAFA,CAAP;AAID,CAXM"}
@@ -8,8 +8,8 @@ const jsonBig = JsonBig({
8
8
  const convertValuesToBigNumbers = value => {
9
9
  if (typeof value === 'object' && value !== null && value.constructor === Object) {
10
10
  return mapObject(value, _ref => {
11
- let [key, value] = _ref;
12
- return [key, convertValuesToBigNumbers(value)];
11
+ let [k, v] = _ref;
12
+ return [k, convertValuesToBigNumbers(v)];
13
13
  });
14
14
  }
15
15