@aeternity/aepp-sdk 11.0.1 → 12.1.1

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 (444) hide show
  1. package/LICENSE +1 -1
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -22
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +2 -1
  6. package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +20765 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/AeSdk.d.ts +37 -0
  11. package/es/AeSdk.mjs +81 -0
  12. package/es/AeSdk.mjs.map +1 -0
  13. package/es/AeSdkAepp.d.ts +70 -0
  14. package/es/AeSdkAepp.mjs +176 -0
  15. package/es/AeSdkAepp.mjs.map +1 -0
  16. package/es/AeSdkBase.d.ts +213 -0
  17. package/es/AeSdkBase.mjs +314 -0
  18. package/es/AeSdkBase.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +104 -0
  20. package/es/AeSdkWallet.mjs +326 -0
  21. package/es/AeSdkWallet.mjs.map +1 -0
  22. package/es/Node.d.ts +41 -0
  23. package/es/Node.mjs +147 -0
  24. package/es/Node.mjs.map +1 -0
  25. package/es/account/Base.d.ts +68 -0
  26. package/es/account/Base.mjs +123 -0
  27. package/es/account/Base.mjs.map +1 -0
  28. package/es/account/Memory.d.ts +26 -0
  29. package/es/account/Memory.mjs +103 -0
  30. package/es/account/Memory.mjs.map +1 -0
  31. package/es/account/Rpc.d.ts +27 -0
  32. package/es/account/Rpc.mjs +80 -0
  33. package/es/account/Rpc.mjs.map +1 -0
  34. package/es/aens.d.ts +222 -0
  35. package/es/aens.mjs +338 -0
  36. package/es/aens.mjs.map +1 -0
  37. package/es/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs +73 -0
  39. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +58 -0
  42. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +146 -0
  45. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  47. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +16 -11
  48. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  51. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  52. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  54. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  55. package/es/aepp-wallet-communication/schema.d.ts +105 -46
  56. package/es/aepp-wallet-communication/schema.mjs +251 -0
  57. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  58. package/es/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs +62 -0
  60. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  61. package/es/apis/compiler/compiler.d.ts +92 -0
  62. package/es/apis/compiler/compiler.mjs +576 -0
  63. package/es/apis/compiler/compiler.mjs.map +1 -0
  64. package/es/apis/compiler/index.d.ts +2 -0
  65. package/es/apis/compiler/index.mjs +3 -0
  66. package/es/apis/compiler/index.mjs.map +1 -0
  67. package/es/apis/compiler/models/index.d.ts +248 -0
  68. package/es/apis/compiler/models/index.mjs +48 -0
  69. package/es/apis/compiler/models/index.mjs.map +1 -0
  70. package/es/apis/compiler/models/mappers.d.ts +23 -0
  71. package/es/apis/compiler/models/mappers.mjs +585 -0
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  73. package/es/apis/compiler/models/parameters.d.ts +13 -0
  74. package/es/apis/compiler/models/parameters.mjs +71 -0
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  76. package/es/apis/node/index.d.ts +2 -0
  77. package/es/apis/node/index.mjs +3 -0
  78. package/es/apis/node/index.mjs.map +1 -0
  79. package/es/apis/node/models/index.d.ts +1065 -0
  80. package/es/apis/node/models/index.mjs +2 -0
  81. package/es/apis/node/models/index.mjs.map +1 -0
  82. package/es/apis/node/models/mappers.d.ts +95 -0
  83. package/es/apis/node/models/mappers.mjs +4166 -0
  84. package/es/apis/node/models/mappers.mjs.map +1 -0
  85. package/es/apis/node/models/parameters.d.ts +17 -0
  86. package/es/apis/node/models/parameters.mjs +165 -0
  87. package/es/apis/node/models/parameters.mjs.map +1 -0
  88. package/es/apis/node/node.d.ts +215 -0
  89. package/es/apis/node/node.mjs +1165 -0
  90. package/es/apis/node/node.mjs.map +1 -0
  91. package/es/chain.d.ts +248 -0
  92. package/es/chain.mjs +560 -0
  93. package/es/chain.mjs.map +1 -0
  94. package/es/channel/handlers.d.ts +34 -0
  95. package/es/channel/handlers.mjs +164 -131
  96. package/es/channel/handlers.mjs.map +1 -1
  97. package/es/channel/index.d.ts +625 -0
  98. package/es/channel/index.mjs +897 -902
  99. package/es/channel/index.mjs.map +1 -1
  100. package/es/channel/internal.d.ts +101 -0
  101. package/es/channel/internal.mjs +136 -85
  102. package/es/channel/internal.mjs.map +1 -1
  103. package/es/contract/Compiler.d.ts +18 -0
  104. package/es/contract/Compiler.mjs +68 -0
  105. package/es/contract/Compiler.mjs.map +1 -0
  106. package/es/contract/aci.d.ts +127 -0
  107. package/es/contract/aci.mjs +225 -193
  108. package/es/contract/aci.mjs.map +1 -1
  109. package/es/contract/ga.d.ts +69 -0
  110. package/es/contract/ga.mjs +195 -0
  111. package/es/contract/ga.mjs.map +1 -0
  112. package/es/contract/methods.d.ts +71 -0
  113. package/es/contract/methods.mjs +104 -0
  114. package/es/contract/methods.mjs.map +1 -0
  115. package/es/deprecated/index.d.ts +143 -0
  116. package/es/deprecated/index.mjs +162 -0
  117. package/es/deprecated/index.mjs.map +1 -0
  118. package/es/deprecated/methods.d.ts +18 -0
  119. package/es/deprecated/methods.mjs +26 -0
  120. package/es/deprecated/methods.mjs.map +1 -0
  121. package/es/index.d.ts +35 -0
  122. package/es/index.mjs +35 -40
  123. package/es/index.mjs.map +1 -1
  124. package/es/oracle.d.ts +161 -0
  125. package/es/oracle.mjs +306 -0
  126. package/es/oracle.mjs.map +1 -0
  127. package/es/spend.d.ts +62 -0
  128. package/es/spend.mjs +111 -0
  129. package/es/spend.mjs.map +1 -0
  130. package/es/tx/builder/address.d.ts +25 -0
  131. package/es/tx/builder/address.mjs +45 -0
  132. package/es/tx/builder/address.mjs.map +1 -0
  133. package/es/tx/builder/constants.d.ts +70 -0
  134. package/es/tx/builder/constants.mjs +61 -47
  135. package/es/tx/builder/constants.mjs.map +1 -1
  136. package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
  137. package/es/tx/builder/field-types/coin-amount.mjs +26 -0
  138. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
  139. package/es/tx/builder/field-types/deposit.d.ts +15 -0
  140. package/es/tx/builder/field-types/deposit.mjs +19 -0
  141. package/es/tx/builder/field-types/deposit.mjs.map +1 -0
  142. package/es/tx/builder/field-types/fee.d.ts +25 -0
  143. package/es/tx/builder/field-types/fee.mjs +150 -0
  144. package/es/tx/builder/field-types/fee.mjs.map +1 -0
  145. package/es/tx/builder/field-types/field.d.ts +6 -0
  146. package/es/tx/builder/field-types/field.mjs +15 -0
  147. package/es/tx/builder/field-types/field.mjs.map +1 -0
  148. package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
  149. package/es/tx/builder/field-types/gas-limit.mjs +33 -0
  150. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
  151. package/es/tx/builder/field-types/gas-price.d.ts +8 -0
  152. package/es/tx/builder/field-types/gas-price.mjs +18 -0
  153. package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
  154. package/es/tx/builder/field-types/index.d.ts +70 -0
  155. package/es/tx/builder/field-types/index.mjs +25 -0
  156. package/es/tx/builder/field-types/index.mjs.map +1 -0
  157. package/es/tx/builder/field-types/name-fee.d.ts +20 -0
  158. package/es/tx/builder/field-types/name-fee.mjs +24 -0
  159. package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
  160. package/es/tx/builder/field-types/name-id.d.ts +14 -0
  161. package/es/tx/builder/field-types/name-id.mjs +19 -0
  162. package/es/tx/builder/field-types/name-id.mjs.map +1 -0
  163. package/es/tx/builder/field-types/name.d.ts +13 -0
  164. package/es/tx/builder/field-types/name.mjs +18 -0
  165. package/es/tx/builder/field-types/name.mjs.map +1 -0
  166. package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
  167. package/es/tx/builder/field-types/short-u-int.mjs +12 -0
  168. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
  169. package/es/tx/builder/field-types/u-int.d.ts +8 -0
  170. package/es/tx/builder/field-types/u-int.mjs +14 -0
  171. package/es/tx/builder/field-types/u-int.mjs.map +1 -0
  172. package/es/tx/builder/helpers.d.ts +125 -0
  173. package/es/tx/builder/helpers.mjs +94 -198
  174. package/es/tx/builder/helpers.mjs.map +1 -1
  175. package/es/tx/builder/index.d.ts +88 -0
  176. package/es/tx/builder/index.mjs +167 -358
  177. package/es/tx/builder/index.mjs.map +1 -1
  178. package/es/tx/builder/schema.d.ts +1201 -0
  179. package/es/tx/builder/schema.mjs +175 -561
  180. package/es/tx/builder/schema.mjs.map +1 -1
  181. package/es/tx/index.d.ts +64 -0
  182. package/es/tx/index.mjs +151 -265
  183. package/es/tx/index.mjs.map +1 -1
  184. package/es/tx/validator.d.ts +20 -0
  185. package/es/tx/validator.mjs +104 -124
  186. package/es/tx/validator.mjs.map +1 -1
  187. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  188. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  189. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  190. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  191. package/es/typings/bip32-path/index.d.mjs +2 -0
  192. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  193. package/es/typings/blakejs/index.d.mjs.map +1 -1
  194. package/es/typings/sha-js/index.d.mjs +2 -0
  195. package/es/typings/sha-js/index.d.mjs.map +1 -0
  196. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  197. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  198. package/es/utils/amount-formatter.d.ts +42 -0
  199. package/es/utils/amount-formatter.mjs +36 -49
  200. package/es/utils/amount-formatter.mjs.map +1 -1
  201. package/es/utils/autorest.d.ts +6 -0
  202. package/es/utils/autorest.mjs +97 -0
  203. package/es/utils/autorest.mjs.map +1 -0
  204. package/es/utils/bignumber.d.ts +13 -0
  205. package/es/utils/bignumber.mjs +11 -8
  206. package/es/utils/bignumber.mjs.map +1 -1
  207. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  208. package/es/utils/bytes.mjs +11 -15
  209. package/es/utils/bytes.mjs.map +1 -1
  210. package/es/utils/crypto.d.ts +88 -0
  211. package/es/utils/crypto.mjs +64 -98
  212. package/es/utils/crypto.mjs.map +1 -1
  213. package/es/utils/encoder-types.d.ts +61 -0
  214. package/es/utils/encoder-types.mjs +36 -0
  215. package/es/utils/encoder-types.mjs.map +1 -0
  216. package/es/utils/encoder.d.ts +25 -0
  217. package/es/utils/encoder.mjs +71 -59
  218. package/es/utils/encoder.mjs.map +1 -1
  219. package/es/{errors.d.ts → utils/errors.d.ts} +246 -59
  220. package/es/utils/errors.mjs +313 -136
  221. package/es/utils/errors.mjs.map +1 -1
  222. package/es/utils/hd-wallet.d.ts +50 -0
  223. package/es/utils/hd-wallet.mjs +86 -45
  224. package/es/utils/hd-wallet.mjs.map +1 -1
  225. package/es/utils/json-big.d.ts +5 -0
  226. package/es/utils/json-big.mjs +12 -16
  227. package/es/utils/json-big.mjs.map +1 -1
  228. package/es/utils/keystore.d.ts +51 -0
  229. package/es/utils/keystore.mjs +101 -194
  230. package/es/utils/keystore.mjs.map +1 -1
  231. package/es/{mptree.d.ts → utils/mptree.d.ts} +6 -9
  232. package/es/utils/mptree.mjs +22 -18
  233. package/es/utils/mptree.mjs.map +1 -1
  234. package/es/utils/other.d.ts +20 -0
  235. package/es/utils/other.mjs +32 -35
  236. package/es/utils/other.mjs.map +1 -1
  237. package/es/utils/semver-satisfies.d.ts +1 -0
  238. package/es/utils/semver-satisfies.mjs +2 -2
  239. package/es/utils/semver-satisfies.mjs.map +1 -1
  240. package/es/utils/string.d.ts +24 -0
  241. package/es/utils/string.mjs +8 -10
  242. package/es/utils/string.mjs.map +1 -1
  243. package/package.json +55 -43
  244. package/src/AeSdk.ts +68 -0
  245. package/src/AeSdkAepp.ts +176 -0
  246. package/src/AeSdkBase.ts +338 -0
  247. package/src/AeSdkWallet.ts +348 -0
  248. package/src/Node.ts +173 -0
  249. package/src/account/Base.ts +124 -0
  250. package/src/account/Memory.ts +98 -0
  251. package/src/account/Rpc.ts +69 -0
  252. package/src/aens.ts +407 -0
  253. package/src/aepp-wallet-communication/connection/Browser.ts +71 -0
  254. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +59 -0
  255. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +122 -0
  256. package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +18 -18
  257. package/src/aepp-wallet-communication/rpc/RpcClient.ts +143 -0
  258. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  259. package/src/aepp-wallet-communication/schema.ts +224 -0
  260. package/src/aepp-wallet-communication/wallet-detector.ts +72 -0
  261. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  262. package/src/apis/compiler/compiler.ts +585 -0
  263. package/src/apis/compiler/index.ts +2 -0
  264. package/src/apis/compiler/models/index.ts +301 -0
  265. package/src/apis/compiler/models/mappers.ts +583 -0
  266. package/src/apis/compiler/models/parameters.ts +93 -0
  267. package/src/apis/node/code-model-v4.yaml +10080 -0
  268. package/src/apis/node/index.ts +2 -0
  269. package/src/apis/node/models/index.ts +1257 -0
  270. package/src/apis/node/models/mappers.ts +4280 -0
  271. package/src/apis/node/models/parameters.ts +188 -0
  272. package/src/apis/node/node.ts +1299 -0
  273. package/src/chain.ts +502 -0
  274. package/src/channel/handlers.ts +817 -0
  275. package/src/channel/index.ts +1025 -0
  276. package/src/channel/internal.ts +361 -0
  277. package/src/contract/Compiler.ts +67 -0
  278. package/src/contract/aci.ts +538 -0
  279. package/src/contract/ga.ts +199 -0
  280. package/src/contract/methods.ts +123 -0
  281. package/src/deprecated/index.ts +172 -0
  282. package/src/deprecated/methods.ts +25 -0
  283. package/src/index.ts +56 -0
  284. package/src/oracle.ts +364 -0
  285. package/src/spend.ts +164 -0
  286. package/src/tx/builder/address.ts +50 -0
  287. package/src/tx/builder/constants.ts +126 -0
  288. package/src/tx/builder/field-types/coin-amount.ts +27 -0
  289. package/src/tx/builder/field-types/deposit.ts +21 -0
  290. package/src/tx/builder/field-types/fee.ts +143 -0
  291. package/src/tx/builder/field-types/field.ts +9 -0
  292. package/src/tx/builder/field-types/gas-limit.ts +41 -0
  293. package/src/tx/builder/field-types/gas-price.ts +16 -0
  294. package/src/tx/builder/field-types/index.ts +45 -0
  295. package/src/tx/builder/field-types/name-fee.ts +32 -0
  296. package/src/tx/builder/field-types/name-id.ts +20 -0
  297. package/src/tx/builder/field-types/name.ts +18 -0
  298. package/src/tx/builder/field-types/short-u-int.ts +11 -0
  299. package/src/tx/builder/field-types/u-int.ts +16 -0
  300. package/src/tx/builder/helpers.ts +248 -0
  301. package/src/tx/builder/index.ts +400 -0
  302. package/src/tx/builder/schema.ts +727 -0
  303. package/src/tx/index.ts +192 -0
  304. package/src/tx/validator.ts +230 -0
  305. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  306. package/src/typings/@aeternity__uuid/index.d.ts +5 -0
  307. package/src/typings/bip32-path/index.d.ts +33 -0
  308. package/src/typings/blakejs/index.d.ts +4 -32
  309. package/src/typings/sha-js/index.d.ts +5 -0
  310. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  311. package/src/utils/amount-formatter.ts +56 -69
  312. package/src/utils/autorest.ts +93 -0
  313. package/src/utils/bignumber.ts +11 -12
  314. package/src/utils/bytes.ts +29 -31
  315. package/src/utils/crypto.ts +205 -0
  316. package/src/utils/encoder-types.ts +63 -0
  317. package/src/utils/encoder.ts +116 -71
  318. package/src/utils/errors.ts +482 -366
  319. package/src/utils/hd-wallet.ts +166 -0
  320. package/src/utils/json-big.ts +27 -0
  321. package/src/utils/keystore.ts +182 -0
  322. package/src/utils/mptree.ts +64 -61
  323. package/src/utils/other.ts +34 -41
  324. package/src/utils/semver-satisfies.ts +15 -11
  325. package/src/utils/string.ts +18 -20
  326. package/es/account/base.mjs +0 -179
  327. package/es/account/base.mjs.map +0 -1
  328. package/es/account/memory.mjs +0 -99
  329. package/es/account/memory.mjs.map +0 -1
  330. package/es/account/multiple.mjs +0 -179
  331. package/es/account/multiple.mjs.map +0 -1
  332. package/es/ae/aens.mjs +0 -404
  333. package/es/ae/aens.mjs.map +0 -1
  334. package/es/ae/aepp.mjs +0 -45
  335. package/es/ae/aepp.mjs.map +0 -1
  336. package/es/ae/contract.mjs +0 -159
  337. package/es/ae/contract.mjs.map +0 -1
  338. package/es/ae/index.mjs +0 -207
  339. package/es/ae/index.mjs.map +0 -1
  340. package/es/ae/oracle.mjs +0 -339
  341. package/es/ae/oracle.mjs.map +0 -1
  342. package/es/ae/universal.mjs +0 -45
  343. package/es/ae/universal.mjs.map +0 -1
  344. package/es/ae/wallet.mjs +0 -50
  345. package/es/ae/wallet.mjs.map +0 -1
  346. package/es/amount-formatter.d.ts +0 -58
  347. package/es/bignumber.d.ts +0 -18
  348. package/es/chain/index.mjs +0 -272
  349. package/es/chain/index.mjs.map +0 -1
  350. package/es/chain/node.mjs +0 -442
  351. package/es/chain/node.mjs.map +0 -1
  352. package/es/contract/compiler.mjs +0 -115
  353. package/es/contract/compiler.mjs.map +0 -1
  354. package/es/contract/ga/helpers.mjs +0 -30
  355. package/es/contract/ga/helpers.mjs.map +0 -1
  356. package/es/contract/ga/index.mjs +0 -178
  357. package/es/contract/ga/index.mjs.map +0 -1
  358. package/es/crypto-ts.d.ts +0 -9
  359. package/es/encoder.d.ts +0 -26
  360. package/es/node-pool/index.mjs +0 -188
  361. package/es/node-pool/index.mjs.map +0 -1
  362. package/es/node.mjs +0 -133
  363. package/es/node.mjs.map +0 -1
  364. package/es/other.d.ts +0 -31
  365. package/es/semver-satisfies.d.ts +0 -1
  366. package/es/string.d.ts +0 -26
  367. package/es/tx/builder/field-types.mjs +0 -74
  368. package/es/tx/builder/field-types.mjs.map +0 -1
  369. package/es/tx/tx-object.mjs +0 -283
  370. package/es/tx/tx-object.mjs.map +0 -1
  371. package/es/tx/tx.mjs +0 -938
  372. package/es/tx/tx.mjs.map +0 -1
  373. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
  374. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
  375. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
  376. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
  377. package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
  378. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
  379. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
  380. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
  381. package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
  382. package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
  383. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
  384. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
  385. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
  386. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
  387. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
  388. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
  389. package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
  390. package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
  391. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
  392. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
  393. package/es/utils/async-init.mjs +0 -64
  394. package/es/utils/async-init.mjs.map +0 -1
  395. package/es/utils/crypto-ts.mjs.map +0 -1
  396. package/es/utils/swagger.mjs +0 -164
  397. package/es/utils/swagger.mjs.map +0 -1
  398. package/src/account/base.js +0 -153
  399. package/src/account/memory.js +0 -83
  400. package/src/account/multiple.js +0 -162
  401. package/src/ae/aens.js +0 -361
  402. package/src/ae/aepp.js +0 -45
  403. package/src/ae/contract.js +0 -148
  404. package/src/ae/index.js +0 -168
  405. package/src/ae/oracle.js +0 -311
  406. package/src/ae/universal.js +0 -47
  407. package/src/ae/wallet.js +0 -50
  408. package/src/chain/index.js +0 -269
  409. package/src/chain/node.js +0 -320
  410. package/src/channel/handlers.js +0 -673
  411. package/src/channel/index.js +0 -903
  412. package/src/channel/internal.js +0 -236
  413. package/src/contract/aci.js +0 -376
  414. package/src/contract/compiler.js +0 -100
  415. package/src/contract/ga/helpers.js +0 -19
  416. package/src/contract/ga/index.js +0 -150
  417. package/src/index.js +0 -89
  418. package/src/node-pool/index.js +0 -172
  419. package/src/node.js +0 -116
  420. package/src/tx/builder/constants.js +0 -100
  421. package/src/tx/builder/field-types.js +0 -61
  422. package/src/tx/builder/helpers.js +0 -334
  423. package/src/tx/builder/index.js +0 -465
  424. package/src/tx/builder/schema.js +0 -1100
  425. package/src/tx/index.js +0 -301
  426. package/src/tx/tx-object.js +0 -187
  427. package/src/tx/tx.js +0 -631
  428. package/src/tx/validator.js +0 -181
  429. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
  430. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
  431. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  432. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
  433. package/src/utils/aepp-wallet-communication/helpers.js +0 -60
  434. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
  435. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
  436. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
  437. package/src/utils/aepp-wallet-communication/schema.ts +0 -80
  438. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
  439. package/src/utils/async-init.js +0 -45
  440. package/src/utils/crypto.js +0 -219
  441. package/src/utils/hd-wallet.js +0 -100
  442. package/src/utils/json-big.js +0 -26
  443. package/src/utils/keystore.js +0 -219
  444. package/src/utils/swagger.js +0 -156
@@ -0,0 +1,125 @@
1
+ /// <reference types="node" />
2
+ import BigNumber from 'bignumber.js';
3
+ import { Encoded } from '../../utils/encoder';
4
+ import { AensName } from './constants';
5
+ import { NamePointer } from '../../apis/node';
6
+ /**
7
+ * JavaScript-based Transaction builder helper function's
8
+ */
9
+ /**
10
+ * Build a contract public key
11
+ * @category contract
12
+ * @param ownerId - The public key of the owner account
13
+ * @param nonce - the nonce of the transaction
14
+ * @returns Contract public key
15
+ */
16
+ export declare function buildContractId(ownerId: Encoded.AccountAddress, nonce: number | BigNumber): Encoded.ContractAddress;
17
+ /**
18
+ * Build a oracle query id
19
+ * @category oracle
20
+ * @param senderId - The public key of the sender account
21
+ * @param nonce - the nonce of the transaction
22
+ * @param oracleId - The oracle public key
23
+ * @returns Contract public key
24
+ */
25
+ export declare function oracleQueryId(senderId: Encoded.AccountAddress, nonce: number | BigNumber | string, oracleId: Encoded.OracleAddress): Encoded.OracleQueryId;
26
+ /**
27
+ * Format the salt into a 64-byte hex string
28
+ * @category transaction builder
29
+ * @param salt - Random number
30
+ * @returns Zero-padded hex string of salt
31
+ */
32
+ export declare function formatSalt(salt: number): Buffer;
33
+ /**
34
+ * Encode an AENS name
35
+ * @category AENS
36
+ * @param name - Name to encode
37
+ * @returns `nm_` prefixed encoded AENS name
38
+ */
39
+ export declare function produceNameId(name: AensName): Encoded.Name;
40
+ /**
41
+ * Generate the commitment hash by hashing the formatted salt and
42
+ * name, base 58 encoding the result and prepending 'cm_'
43
+ * @category transaction builder
44
+ * @param name - Name to be registered
45
+ * @param salt - Random salt
46
+ * @returns Commitment hash
47
+ */
48
+ export declare function commitmentHash(name: AensName, salt?: number): Encoded.Commitment;
49
+ /**
50
+ * Utility function to convert int to bytes
51
+ * @category transaction builder
52
+ * @param val - Value
53
+ * @returns Buffer Buffer from number(BigEndian)
54
+ */
55
+ export declare function writeInt(val: number | string | BigNumber): Buffer;
56
+ /**
57
+ * Utility function to convert bytes to int
58
+ * @category transaction builder
59
+ * @param buf - Value
60
+ * @returns Buffer Buffer from number(BigEndian)
61
+ */
62
+ export declare function readInt(buf?: Buffer): string;
63
+ /**
64
+ * Helper function to build pointers for name update TX
65
+ * @category transaction builder
66
+ * @param pointers - Array of pointers
67
+ * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`
68
+ * @returns Serialized pointers array
69
+ */
70
+ export declare function buildPointers(pointers: NamePointer[]): Buffer[][];
71
+ /**
72
+ * Helper function to read pointers from name update TX
73
+ * @category transaction builder
74
+ * @param pointers - Array of pointers
75
+ * @returns Deserialize pointer array
76
+ */
77
+ export declare function readPointers(pointers: Array<[key: string, id: Buffer]>): NamePointer[];
78
+ /**
79
+ * Is AENS name valid
80
+ * @category AENS
81
+ * @param name - AENS name
82
+ */
83
+ export declare function isNameValid(name: string): name is AensName;
84
+ declare const encodingToPointerKey: readonly [readonly [Encoded.Encoding.AccountAddress, "account_pubkey"], readonly [Encoded.Encoding.OracleAddress, "oracle_pubkey"], readonly [Encoded.Encoding.ContractAddress, "contract_pubkey"], readonly [Encoded.Encoding.Channel, "channel"]];
85
+ /**
86
+ * @category AENS
87
+ * @param identifier - account/oracle/contract address, or channel
88
+ * @returns default AENS pointer key
89
+ */
90
+ export declare function getDefaultPointerKey(identifier: Encoded.Generic<typeof encodingToPointerKey[number][0]>): typeof encodingToPointerKey[number][1];
91
+ /**
92
+ * Get the minimum AENS name fee
93
+ * @category AENS
94
+ * @param name - the AENS name to get the fee for
95
+ * @returns the minimum fee for the AENS name auction
96
+ */
97
+ export declare function getMinimumNameFee(name: AensName): BigNumber;
98
+ /**
99
+ * Compute bid fee for AENS auction
100
+ * @category AENS
101
+ * @param name - the AENS name to get the fee for
102
+ * @param options - Options
103
+ * @param options.startFee - Auction start fee
104
+ * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)
105
+ * @returns Bid fee
106
+ */
107
+ export declare function computeBidFee(name: AensName, { startFee, increment }?: {
108
+ startFee?: number | string | BigNumber;
109
+ increment?: number;
110
+ }): BigNumber;
111
+ /**
112
+ * Compute auction end height
113
+ * @category AENS
114
+ * @param name - Name to compute auction end for
115
+ * @param claimHeight - Auction starting height
116
+ * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}
117
+ * @returns Auction end height
118
+ */
119
+ export declare function computeAuctionEndBlock(name: AensName, claimHeight: number): number;
120
+ /**
121
+ * Is name accept going to auction
122
+ * @category AENS
123
+ */
124
+ export declare function isAuctionName(name: AensName): boolean;
125
+ export {};
@@ -3,66 +3,55 @@ const {
3
3
  Buffer: _Buffer
4
4
  } = _buffer;
5
5
  import BigNumber from 'bignumber.js';
6
- import _bs from 'bs58';
7
- const {
8
- encode: bs58Encode,
9
- decode: bs58Decode
10
- } = _bs;
11
- import { hash, salt } from "../../utils/crypto.mjs";
12
- import { encode, decode } from "../../utils/encoder.mjs";
6
+ import { genSalt, hash } from "../../utils/crypto.mjs";
7
+ import { decode, encode, Encoding } from "../../utils/encoder.mjs";
13
8
  import { toBytes } from "../../utils/bytes.mjs";
14
- import { ID_TAG_PREFIX, PREFIX_ID_TAG, NAME_BID_RANGES, NAME_FEE_BID_INCREMENT, NAME_BID_TIMEOUTS, NAME_MAX_LENGTH_FEE, POINTER_KEY_BY_PREFIX } from "./constants.mjs";
9
+ import { concatBuffers } from "../../utils/other.mjs";
10
+ import { NAME_BID_RANGES, NAME_BID_TIMEOUT_BLOCKS, NAME_FEE_BID_INCREMENT, NAME_MAX_LENGTH_FEE } from "./constants.mjs";
15
11
  import { ceil } from "../../utils/bignumber.mjs";
16
- import { TagNotFoundError, PrefixNotFoundError, InvalidNameError, IllegalBidFeeError, NoDefaultAensPointerError, ArgumentError } from "../../utils/errors.mjs";
12
+ import { ArgumentError, IllegalBidFeeError } from "../../utils/errors.mjs";
13
+ import { readId, writeId } from "./address.mjs";
17
14
  /**
18
15
  * JavaScript-based Transaction builder helper function's
19
- * @module @aeternity/aepp-sdk/es/tx/builder/helpers
20
- * @export TxBuilderHelper
21
- * @example import { TxBuilderHelper } from '@aeternity/aepp-sdk'
22
16
  */
23
17
 
24
- export const createSalt = salt;
25
- export { encode, decode };
26
18
  /**
27
19
  * Build a contract public key
28
- * @function
29
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
30
- * @param {string} ownerId The public key of the owner account
31
- * @param {number} nonce the nonce of the transaction
32
- * @return {string} Contract public key
20
+ * @category contract
21
+ * @param ownerId - The public key of the owner account
22
+ * @param nonce - the nonce of the transaction
23
+ * @returns Contract public key
33
24
  */
34
25
 
35
26
  export function buildContractId(ownerId, nonce) {
36
- const ownerIdAndNonce = _Buffer.from([...decode(ownerId, 'ak'), ...toBytes(nonce)]);
27
+ const ownerIdAndNonce = _Buffer.from([...decode(ownerId), ...toBytes(nonce)]);
37
28
 
38
29
  const b2bHash = hash(ownerIdAndNonce);
39
- return encode(b2bHash, 'ct');
30
+ return encode(b2bHash, Encoding.ContractAddress);
40
31
  }
41
32
  /**
42
33
  * Build a oracle query id
43
- * @function
44
- * @function* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
45
- * @param {String} senderId The public key of the sender account
46
- * @param {Number} nonce the nonce of the transaction
47
- * @param {Number} oracleId The oracle public key
48
- * @return {string} Contract public key
34
+ * @category oracle
35
+ * @param senderId - The public key of the sender account
36
+ * @param nonce - the nonce of the transaction
37
+ * @param oracleId - The oracle public key
38
+ * @returns Contract public key
49
39
  */
50
40
 
51
41
  export function oracleQueryId(senderId, nonce, oracleId) {
52
42
  function _int32(val) {
53
43
  const nonceBE = toBytes(val, true);
54
- return _Buffer.concat([_Buffer.alloc(32 - nonceBE.length), nonceBE]);
44
+ return concatBuffers([_Buffer.alloc(32 - nonceBE.length), nonceBE]);
55
45
  }
56
46
 
57
- const b2bHash = hash(_Buffer.from([...decode(senderId, 'ak'), ..._int32(nonce), ...decode(oracleId, 'ok')]));
58
- return encode(b2bHash, 'oq');
47
+ const b2bHash = hash(_Buffer.from([...decode(senderId), ..._int32(nonce), ...decode(oracleId)]));
48
+ return encode(b2bHash, Encoding.OracleQueryId);
59
49
  }
60
50
  /**
61
51
  * Format the salt into a 64-byte hex string
62
- * @function
63
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
64
- * @param {number} salt
65
- * @return {string} Zero-padded hex string of salt
52
+ * @category transaction builder
53
+ * @param salt - Random number
54
+ * @returns Zero-padded hex string of salt
66
55
  */
67
56
 
68
57
  export function formatSalt(salt) {
@@ -70,108 +59,32 @@ export function formatSalt(salt) {
70
59
  }
71
60
  /**
72
61
  * Encode an AENS name
73
- * @function
74
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
75
- * @param {String} name Name to encode
76
- * @return {String} `nm_` prefixed encoded AENS name
62
+ * @category AENS
63
+ * @param name - Name to encode
64
+ * @returns `nm_` prefixed encoded AENS name
77
65
  */
78
66
 
79
67
  export function produceNameId(name) {
80
- ensureNameValid(name);
81
- return encode(hash(name.toLowerCase()), 'nm');
68
+ return encode(hash(name.toLowerCase()), Encoding.Name);
82
69
  }
83
70
  /**
84
71
  * Generate the commitment hash by hashing the formatted salt and
85
72
  * name, base 58 encoding the result and prepending 'cm_'
86
- *
87
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
88
- * @function commitmentHash
89
- * @category async
90
- * @rtype (name: String, salt?: String) => hash: Promise[String]
91
- * @param {String} name - Name to be registered
92
- * @param {Number} salt Random salt
93
- * @return {String} Commitment hash
73
+ * @category transaction builder
74
+ * @param name - Name to be registered
75
+ * @param salt - Random salt
76
+ * @returns Commitment hash
94
77
  */
95
78
 
96
79
  export function commitmentHash(name) {
97
- let salt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createSalt();
98
- ensureNameValid(name);
99
- return encode(hash(_Buffer.concat([_Buffer.from(name.toLowerCase()), formatSalt(salt)])), 'cm');
100
- } // based on https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md
101
-
102
- const base64Types = ['ba', 'cb', 'or', 'ov', 'pi', 'ss', 'cs', 'ck', 'cv', 'st', 'tx'];
103
- const base58Types = ['ak', 'bf', 'bs', 'bx', 'ch', 'cm', 'ct', 'kh', 'mh', 'nm', 'ok', 'oq', 'pp', 'sg', 'th']; // TODO: add all types with a fixed length
104
-
105
- const typesLength = {
106
- ak: 32,
107
- ct: 32,
108
- ok: 32
109
- };
110
-
111
- function ensureValidLength(data, type) {
112
- if (!typesLength[type]) return;
113
- if (data.length === typesLength[type]) return;
114
- throw new PayloadLengthError(`Payload should be ${typesLength[type]} bytes, got ${data.length} instead`);
115
- }
116
-
117
- const getChecksum = payload => sha256hash(sha256hash(payload)).slice(0, 4);
118
-
119
- const addChecksum = input => {
120
- const payload = _Buffer.from(input);
121
-
122
- return _Buffer.concat([payload, getChecksum(payload)]);
123
- };
124
-
125
- function getPayload(buffer) {
126
- const payload = buffer.slice(0, -4);
127
- if (!getChecksum(payload).equals(buffer.slice(-4))) throw new InvalidChecksumError();
128
- return payload;
129
- }
130
-
131
- const base64 = {
132
- encode: buffer => addChecksum(buffer).toString('base64'),
133
- decode: string => getPayload(_Buffer.from(string, 'base64'))
134
- };
135
- const base58 = {
136
- encode: buffer => bs58.encode(addChecksum(buffer)),
137
- decode: string => getPayload(bs58.decode(string))
138
- };
139
- /**
140
- * Utility function to create and _id type
141
- * @function
142
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
143
- * @param {string} hashId Encoded hash
144
- * @return {Buffer} Buffer Buffer with ID tag and decoded HASh
145
- */
146
-
147
- export function writeId(hashId) {
148
- if (typeof hashId !== 'string') throw new ArgumentError('hashId', 'a string', hashId);
149
- const prefix = hashId.slice(0, 2);
150
- const idTag = PREFIX_ID_TAG[prefix];
151
- if (!idTag) throw new TagNotFoundError(prefix);
152
- return _Buffer.from([...toBytes(idTag), ...decode(hashId, prefix)]);
153
- }
154
- /**
155
- * Utility function to read and _id type
156
- * @function
157
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
158
- * @param {Buffer} buf Data
159
- * @return {String} Encoided hash string with prefix
160
- */
161
-
162
- export function readId(buf) {
163
- const tag = _Buffer.from(buf).readUIntBE(0, 1);
164
-
165
- const prefix = ID_TAG_PREFIX[tag];
166
- if (!prefix) throw new PrefixNotFoundError(tag);
167
- return encode(buf.slice(1, buf.length), prefix);
80
+ let salt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : genSalt();
81
+ return encode(hash(concatBuffers([_Buffer.from(name.toLowerCase()), formatSalt(salt)])), Encoding.Commitment);
168
82
  }
169
83
  /**
170
84
  * Utility function to convert int to bytes
171
- * @function
172
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
173
- * @param {Number|String|BigNumber} val Value
174
- * @return {Buffer} Buffer Buffer from number(BigEndian)
85
+ * @category transaction builder
86
+ * @param val - Value
87
+ * @returns Buffer Buffer from number(BigEndian)
175
88
  */
176
89
 
177
90
  export function writeInt(val) {
@@ -179,10 +92,9 @@ export function writeInt(val) {
179
92
  }
180
93
  /**
181
94
  * Utility function to convert bytes to int
182
- * @function
183
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
184
- * @param {Buffer} buf Value
185
- * @return {String} Buffer Buffer from number(BigEndian)
95
+ * @category transaction builder
96
+ * @param buf - Value
97
+ * @returns Buffer Buffer from number(BigEndian)
186
98
  */
187
99
 
188
100
  export function readInt() {
@@ -191,11 +103,10 @@ export function readInt() {
191
103
  }
192
104
  /**
193
105
  * Helper function to build pointers for name update TX
194
- * @function
195
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
196
- * @param {Array} pointers - Array of pointers
197
- * ([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])
198
- * @return {Array} Serialized pointers array
106
+ * @category transaction builder
107
+ * @param pointers - Array of pointers
108
+ * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`
109
+ * @returns Serialized pointers array
199
110
  */
200
111
 
201
112
  export function buildPointers(pointers) {
@@ -203,119 +114,104 @@ export function buildPointers(pointers) {
203
114
  }
204
115
  /**
205
116
  * Helper function to read pointers from name update TX
206
- * @function
207
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
208
- * @param {Array} pointers - Array of pointers
209
- * ([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])
210
- * @return {Array} Deserialize pointer array
117
+ * @category transaction builder
118
+ * @param pointers - Array of pointers
119
+ * @returns Deserialize pointer array
211
120
  */
212
121
 
213
122
  export function readPointers(pointers) {
214
123
  return pointers.map(_ref => {
215
124
  let [key, id] = _ref;
216
- return Object.assign({
125
+ return {
217
126
  key: key.toString(),
218
127
  id: readId(id)
219
- });
128
+ };
220
129
  });
221
130
  }
222
131
  const AENS_SUFFIX = '.chain';
223
- /**
224
- * Ensure that AENS name is valid
225
- * @function
226
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
227
- * @param {string} name
228
- * @return void
229
- * @throws Error
230
- */
231
-
232
- export function ensureNameValid(name) {
233
- if (!name || typeof name !== 'string') throw new InvalidNameError('Name must be a string');
234
- if (!name.endsWith(AENS_SUFFIX)) throw new InvalidNameError(`Name should end with ${AENS_SUFFIX}: ${name}`);
235
- }
236
132
  /**
237
133
  * Is AENS name valid
238
- * @function
239
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
240
- * @param {string} name
241
- * @return Boolean
134
+ * @category AENS
135
+ * @param name - AENS name
242
136
  */
243
137
 
244
138
  export function isNameValid(name) {
245
- try {
246
- ensureNameValid(name);
247
- return true;
248
- } catch (error) {
249
- return false;
250
- }
139
+ // TODO: probably there are stronger requirements
140
+ return name.endsWith(AENS_SUFFIX);
251
141
  }
142
+ const encodingToPointerKey = [[Encoding.AccountAddress, 'account_pubkey'], [Encoding.OracleAddress, 'oracle_pubkey'], [Encoding.ContractAddress, 'contract_pubkey'], [Encoding.Channel, 'channel']];
252
143
  /**
144
+ * @category AENS
253
145
  * @param identifier - account/oracle/contract address, or channel
254
- * @returns {String} default AENS pointer key
255
- * @throws exception when default key not defined
146
+ * @returns default AENS pointer key
256
147
  */
257
148
 
258
149
  export function getDefaultPointerKey(identifier) {
150
+ var _encodingToPointerKey;
151
+
259
152
  decode(identifier);
260
- const prefix = identifier.substr(0, 2);
261
- return POINTER_KEY_BY_PREFIX[prefix] || (() => {
262
- throw new NoDefaultAensPointerError(prefix);
263
- })();
153
+ const encoding = identifier.substring(0, 2);
154
+ const result = (_encodingToPointerKey = encodingToPointerKey.find(_ref2 => {
155
+ let [e] = _ref2;
156
+ return e === encoding;
157
+ })) === null || _encodingToPointerKey === void 0 ? void 0 : _encodingToPointerKey[1];
158
+ if (result != null) return result;
159
+ throw new ArgumentError('identifier', `prefixed with one of ${encodingToPointerKey.map(_ref3 => {
160
+ let [e] = _ref3;
161
+ return `${e}_`;
162
+ }).join(', ')}`, identifier);
264
163
  }
265
164
  /**
266
165
  * Get the minimum AENS name fee
267
- * @function
268
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
269
- * @param {String} name the AENS name to get the fee for
270
- * @return {String} the minimum fee for the AENS name auction
166
+ * @category AENS
167
+ * @param name - the AENS name to get the fee for
168
+ * @returns the minimum fee for the AENS name auction
271
169
  */
272
170
 
273
171
  export function getMinimumNameFee(name) {
274
- ensureNameValid(name);
275
172
  const nameLength = name.length - AENS_SUFFIX.length;
276
173
  return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)];
277
174
  }
278
175
  /**
279
176
  * Compute bid fee for AENS auction
280
- * @function
281
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
282
- * @param {String} name the AENS name to get the fee for
283
- * @param {Number|String} startFee Auction start fee
284
- * @param {Number} [increment=0.5] Bid multiplier(In percentage, must be between 0 and 1)
285
- * @return {String} Bid fee
286
- */
287
-
288
- export function computeBidFee(name, startFee) {
289
- let increment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : NAME_FEE_BID_INCREMENT;
177
+ * @category AENS
178
+ * @param name - the AENS name to get the fee for
179
+ * @param options - Options
180
+ * @param options.startFee - Auction start fee
181
+ * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)
182
+ * @returns Bid fee
183
+ */
184
+
185
+ export function computeBidFee(name) {
186
+ let {
187
+ startFee,
188
+ increment = NAME_FEE_BID_INCREMENT
189
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
290
190
  if (!(Number(increment) === increment && increment % 1 !== 0)) throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`);
291
- if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);
292
- return ceil(BigNumber(startFee !== null && startFee !== void 0 ? startFee : getMinimumNameFee(name)).times(BigNumber(NAME_FEE_BID_INCREMENT).plus(1)));
191
+ if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`); // FIXME: increment should be used somehow here
192
+
193
+ return ceil(new BigNumber(startFee !== null && startFee !== void 0 ? startFee : getMinimumNameFee(name)).times(new BigNumber(NAME_FEE_BID_INCREMENT).plus(1)));
293
194
  }
294
195
  /**
295
196
  * Compute auction end height
296
- * @function
297
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
298
- * @param {String} name
299
- * @param {Number|String} claimHeight Auction starting height
300
- * @return {String} Auction end height
197
+ * @category AENS
198
+ * @param name - Name to compute auction end for
199
+ * @param claimHeight - Auction starting height
200
+ * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}
201
+ * @returns Auction end height
301
202
  */
302
203
 
303
204
  export function computeAuctionEndBlock(name, claimHeight) {
304
- ensureNameValid(name);
305
205
  const length = name.length - AENS_SUFFIX.length;
306
- const h = length <= 4 && NAME_BID_TIMEOUTS[4] || length <= 8 && NAME_BID_TIMEOUTS[8] || length <= 12 && NAME_BID_TIMEOUTS[12] || NAME_BID_TIMEOUTS[13];
307
- return h.plus(claimHeight).toString(10);
206
+ const h = length <= 4 && 62 * NAME_BID_TIMEOUT_BLOCKS || length <= 8 && 31 * NAME_BID_TIMEOUT_BLOCKS || length <= 12 && NAME_BID_TIMEOUT_BLOCKS || 0;
207
+ return h + claimHeight;
308
208
  }
309
209
  /**
310
210
  * Is name accept going to auction
311
- * @function
312
- * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
313
- * @param {String} name
314
- * @return {Boolean}
211
+ * @category AENS
315
212
  */
316
213
 
317
214
  export function isAuctionName(name) {
318
- ensureNameValid(name);
319
215
  return name.length < 13 + AENS_SUFFIX.length;
320
216
  }
321
217
  //# sourceMappingURL=helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/tx/builder/helpers.js"],"names":["BigNumber","hash","salt","encode","decode","toBytes","ID_TAG_PREFIX","PREFIX_ID_TAG","NAME_BID_RANGES","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUTS","NAME_MAX_LENGTH_FEE","POINTER_KEY_BY_PREFIX","ceil","TagNotFoundError","PrefixNotFoundError","InvalidNameError","IllegalBidFeeError","NoDefaultAensPointerError","ArgumentError","createSalt","buildContractId","ownerId","nonce","ownerIdAndNonce","from","b2bHash","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","concat","alloc","length","formatSalt","toString","padStart","produceNameId","name","ensureNameValid","toLowerCase","commitmentHash","base64Types","base58Types","typesLength","ak","ct","ok","ensureValidLength","data","type","PayloadLengthError","getChecksum","payload","sha256hash","slice","addChecksum","input","getPayload","buffer","equals","InvalidChecksumError","base64","string","base58","bs58","writeId","hashId","prefix","idTag","readId","buf","tag","readUIntBE","writeInt","readInt","buildPointers","pointers","map","p","key","id","readPointers","Object","assign","AENS_SUFFIX","endsWith","isNameValid","error","getDefaultPointerKey","identifier","substr","getMinimumNameFee","nameLength","Math","min","computeBidFee","startFee","increment","Number","times","plus","computeAuctionEndBlock","claimHeight","h","isAuctionName"],"mappings":";;;;AAAA,OAAOA,SAAP,MAAsB,cAAtB;AACA,gBAA2D,MAA3D;;;;;SACSC,I,EAAMC,I;SACNC,M,EAAQC,M;SACRC,O;SAEPC,a,EACAC,a,EACAC,e,EACAC,sB,EACAC,iB,EACAC,mB,EACAC,qB;SAEOC,I;SAEPC,gB,EACAC,mB,EACAC,gB,EACAC,kB,EACAC,yB,EACAC,a;AAGF;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,UAAU,GAAGlB,IAAnB;AAEP,SAASC,MAAT,EAAiBC,MAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASiB,eAAT,C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Tb,SAAS,CAACmG,QAAD,aAACA,QAAD,cAACA,QAAD,GAAaL,iBAAiB,CAACtD,IAAD,CAA9B,CAAT,CAA+C8D,KAA/C,CAAqDtG,SAAS,CAACS,sBAAD,CAAT,CAAkC8F,IAAlC,CAAuC,CAAvC,CAArD,CADS,CAAX;AAGD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiChE,IAAjC,EAAuCiE,WAAvC,EAAoD;AACzDhE,EAAAA,eAAe,CAACD,IAAD,CAAf;AACA,QAAML,MAAM,GAAGK,IAAI,CAACL,MAAL,GAAcoD,WAAW,CAACpD,MAAzC;AACA,QAAMuE,CAAC,GAAIvE,MAAM,IAAI,CAAV,IAAezB,iBAAiB,CAAC,CAAD,CAAjC,IACPyB,MAAM,IAAI,CAAV,IAAezB,iBAAiB,CAAC,CAAD,CADzB,IAEPyB,MAAM,IAAI,EAAV,IAAgBzB,iBAAiB,CAAC,EAAD,CAF1B,IAGRA,iBAAiB,CAAC,EAAD,CAHnB;AAIA,SAAOgG,CAAC,CAACH,IAAF,CAAOE,WAAP,EAAoBpE,QAApB,CAA6B,EAA7B,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASsE,aAAT,CAAwBnE,IAAxB,EAA8B;AACnCC,EAAAA,eAAe,CAACD,IAAD,CAAf;AACA,SAAOA,IAAI,CAACL,MAAL,GAAc,KAAKoD,WAAW,CAACpD,MAAtC;AACD","sourcesContent":["import BigNumber from 'bignumber.js'\nimport { encode as bs58Encode, decode as bs58Decode } from 'bs58'\nimport { hash, salt } from '../../utils/crypto'\nimport { encode, decode } from '../../utils/encoder'\nimport { toBytes } from '../../utils/bytes'\nimport {\n ID_TAG_PREFIX,\n PREFIX_ID_TAG,\n NAME_BID_RANGES,\n NAME_FEE_BID_INCREMENT,\n NAME_BID_TIMEOUTS,\n NAME_MAX_LENGTH_FEE,\n POINTER_KEY_BY_PREFIX\n} from './constants'\nimport { ceil } from '../../utils/bignumber'\nimport {\n TagNotFoundError,\n PrefixNotFoundError,\n InvalidNameError,\n IllegalBidFeeError,\n NoDefaultAensPointerError,\n ArgumentError\n} from '../../utils/errors'\n\n/**\n * JavaScript-based Transaction builder helper function's\n * @module @aeternity/aepp-sdk/es/tx/builder/helpers\n * @export TxBuilderHelper\n * @example import { TxBuilderHelper } from '@aeternity/aepp-sdk'\n */\n\nexport const createSalt = salt\n\nexport { encode, decode }\n\n/**\n * Build a contract public key\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} ownerId The public key of the owner account\n * @param {number} nonce the nonce of the transaction\n * @return {string} Contract public key\n */\nexport function buildContractId (ownerId, nonce) {\n const ownerIdAndNonce = Buffer.from([...decode(ownerId, 'ak'), ...toBytes(nonce)])\n const b2bHash = hash(ownerIdAndNonce)\n return encode(b2bHash, 'ct')\n}\n\n/**\n * Build a oracle query id\n * @function\n * @function* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} senderId The public key of the sender account\n * @param {Number} nonce the nonce of the transaction\n * @param {Number} oracleId The oracle public key\n * @return {string} Contract public key\n */\nexport function oracleQueryId (senderId, nonce, oracleId) {\n function _int32 (val) {\n const nonceBE = toBytes(val, true)\n return Buffer.concat([Buffer.alloc(32 - nonceBE.length), nonceBE])\n }\n\n const b2bHash = hash(Buffer.from([...decode(senderId, 'ak'), ..._int32(nonce), ...decode(oracleId, 'ok')]))\n return encode(b2bHash, 'oq')\n}\n\n/**\n * Format the salt into a 64-byte hex string\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {number} salt\n * @return {string} Zero-padded hex string of salt\n */\nexport function formatSalt (salt) {\n return Buffer.from(salt.toString(16).padStart(64, '0'), 'hex')\n}\n\n/**\n * Encode an AENS name\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} name Name to encode\n * @return {String} `nm_` prefixed encoded AENS name\n */\nexport function produceNameId (name) {\n ensureNameValid(name)\n return encode(hash(name.toLowerCase()), 'nm')\n}\n\n/**\n * Generate the commitment hash by hashing the formatted salt and\n * name, base 58 encoding the result and prepending 'cm_'\n *\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @function commitmentHash\n * @category async\n * @rtype (name: String, salt?: String) => hash: Promise[String]\n * @param {String} name - Name to be registered\n * @param {Number} salt Random salt\n * @return {String} Commitment hash\n */\nexport function commitmentHash (name, salt = createSalt()) {\n ensureNameValid(name)\n return encode(hash(Buffer.concat([Buffer.from(name.toLowerCase()), formatSalt(salt)])), 'cm')\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']\nconst base58Types = ['ak', 'bf', 'bs', 'bx', 'ch', 'cm', 'ct', 'kh', 'mh', 'nm', 'ok', 'oq', 'pp', 'sg', 'th']\n// TODO: add all types with a fixed length\nconst typesLength = {\n ak: 32,\n ct: 32,\n ok: 32\n}\n\nfunction ensureValidLength (data, type) {\n if (!typesLength[type]) return\n if (data.length === typesLength[type]) return\n throw new PayloadLengthError(`Payload should be ${typesLength[type]} bytes, got ${data.length} instead`)\n}\n\nconst getChecksum = payload => sha256hash(sha256hash(payload)).slice(0, 4)\n\nconst addChecksum = (input) => {\n const payload = Buffer.from(input)\n return Buffer.concat([payload, getChecksum(payload)])\n}\n\nfunction getPayload (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 => addChecksum(buffer).toString('base64'),\n decode: string => getPayload(Buffer.from(string, 'base64'))\n}\n\nconst base58 = {\n encode: buffer => bs58.encode(addChecksum(buffer)),\n decode: string => getPayload(bs58.decode(string))\n}\n\n/**\n * Utility function to create and _id type\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} hashId Encoded hash\n * @return {Buffer} Buffer Buffer with ID tag and decoded HASh\n */\nexport function writeId (hashId) {\n if (typeof hashId !== 'string') throw new ArgumentError('hashId', 'a string', hashId)\n const prefix = hashId.slice(0, 2)\n const idTag = PREFIX_ID_TAG[prefix]\n if (!idTag) throw new TagNotFoundError(prefix)\n return Buffer.from([...toBytes(idTag), ...decode(hashId, prefix)])\n}\n\n/**\n * Utility function to read and _id type\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Buffer} buf Data\n * @return {String} Encoided hash string with prefix\n */\nexport function readId (buf) {\n const tag = Buffer.from(buf).readUIntBE(0, 1)\n const prefix = ID_TAG_PREFIX[tag]\n if (!prefix) throw new PrefixNotFoundError(tag)\n return encode(buf.slice(1, buf.length), prefix)\n}\n\n/**\n * Utility function to convert int to bytes\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Number|String|BigNumber} val Value\n * @return {Buffer} Buffer Buffer from number(BigEndian)\n */\nexport function writeInt (val) {\n return toBytes(val, true)\n}\n\n/**\n * Utility function to convert bytes to int\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Buffer} buf Value\n * @return {String} Buffer Buffer from number(BigEndian)\n */\nexport function readInt (buf = Buffer.from([])) {\n return new BigNumber(Buffer.from(buf).toString('hex'), 16).toString(10)\n}\n\n/**\n * Helper function to build pointers for name update TX\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Array} pointers - Array of pointers\n * ([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])\n * @return {Array} Serialized pointers array\n */\nexport function buildPointers (pointers) {\n return pointers.map(\n p => [\n toBytes(p.key),\n writeId(p.id)\n ]\n )\n}\n\n/**\n * Helper function to read pointers from name update TX\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {Array} pointers - Array of pointers\n * ([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])\n * @return {Array} Deserialize pointer array\n */\nexport function readPointers (pointers) {\n return pointers.map(\n ([key, id]) => Object.assign({\n key: key.toString(),\n id: readId(id)\n })\n )\n}\n\nconst AENS_SUFFIX = '.chain'\n\n/**\n * Ensure that AENS name is valid\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} name\n * @return void\n * @throws Error\n */\nexport function ensureNameValid (name) {\n if (!name || typeof name !== 'string') throw new InvalidNameError('Name must be a string')\n if (!name.endsWith(AENS_SUFFIX)) throw new InvalidNameError(`Name should end with ${AENS_SUFFIX}: ${name}`)\n}\n\n/**\n * Is AENS name valid\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {string} name\n * @return Boolean\n */\nexport function isNameValid (name) {\n try {\n ensureNameValid(name)\n return true\n } catch (error) {\n return false\n }\n}\n\n/**\n * @param identifier - account/oracle/contract address, or channel\n * @returns {String} default AENS pointer key\n * @throws exception when default key not defined\n */\nexport function getDefaultPointerKey (identifier) {\n decode(identifier)\n const prefix = identifier.substr(0, 2)\n return POINTER_KEY_BY_PREFIX[prefix] ||\n (() => { throw new NoDefaultAensPointerError(prefix) })()\n}\n\n/**\n * Get the minimum AENS name fee\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} name the AENS name to get the fee for\n * @return {String} the minimum fee for the AENS name auction\n */\nexport function getMinimumNameFee (name) {\n ensureNameValid(name)\n const nameLength = name.length - AENS_SUFFIX.length\n return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)]\n}\n\n/**\n * Compute bid fee for AENS auction\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} name the AENS name to get the fee for\n * @param {Number|String} startFee Auction start fee\n * @param {Number} [increment=0.5] Bid multiplier(In percentage, must be between 0 and 1)\n * @return {String} Bid fee\n */\nexport function computeBidFee (name, startFee, increment = NAME_FEE_BID_INCREMENT) {\n if (!(Number(increment) === increment && increment % 1 !== 0)) throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`)\n if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`)\n return ceil(\n BigNumber(startFee ?? getMinimumNameFee(name)).times(BigNumber(NAME_FEE_BID_INCREMENT).plus(1))\n )\n}\n\n/**\n * Compute auction end height\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} name\n * @param {Number|String} claimHeight Auction starting height\n * @return {String} Auction end height\n */\nexport function computeAuctionEndBlock (name, claimHeight) {\n ensureNameValid(name)\n const length = name.length - AENS_SUFFIX.length\n const h = (length <= 4 && NAME_BID_TIMEOUTS[4]) ||\n (length <= 8 && NAME_BID_TIMEOUTS[8]) ||\n (length <= 12 && NAME_BID_TIMEOUTS[12]) ||\n NAME_BID_TIMEOUTS[13]\n return h.plus(claimHeight).toString(10)\n}\n\n/**\n * Is name accept going to auction\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers\n * @param {String} name\n * @return {Boolean}\n */\nexport function isAuctionName (name) {\n ensureNameValid(name)\n return name.length < 13 + AENS_SUFFIX.length\n}\n"],"file":"helpers.mjs"}
1
+ {"version":3,"file":"helpers.mjs","names":["BigNumber","genSalt","hash","decode","encode","Encoding","toBytes","concatBuffers","NAME_BID_RANGES","NAME_BID_TIMEOUT_BLOCKS","NAME_FEE_BID_INCREMENT","NAME_MAX_LENGTH_FEE","ceil","ArgumentError","IllegalBidFeeError","readId","writeId","buildContractId","ownerId","nonce","ownerIdAndNonce","from","b2bHash","ContractAddress","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","alloc","length","OracleQueryId","formatSalt","salt","toString","padStart","produceNameId","name","toLowerCase","Name","commitmentHash","Commitment","writeInt","readInt","buf","buildPointers","pointers","map","p","key","id","readPointers","AENS_SUFFIX","isNameValid","endsWith","encodingToPointerKey","AccountAddress","OracleAddress","Channel","getDefaultPointerKey","identifier","encoding","substring","result","find","e","join","getMinimumNameFee","nameLength","Math","min","computeBidFee","startFee","increment","Number","times","plus","computeAuctionEndBlock","claimHeight","h","isAuctionName"],"sources":["../../../src/tx/builder/helpers.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { genSalt, hash } from '../../utils/crypto';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { toBytes } from '../../utils/bytes';\nimport { concatBuffers } from '../../utils/other';\nimport {\n AensName,\n NAME_BID_RANGES,\n NAME_BID_TIMEOUT_BLOCKS,\n NAME_FEE_BID_INCREMENT,\n NAME_MAX_LENGTH_FEE,\n} from './constants';\nimport { ceil } from '../../utils/bignumber';\nimport { ArgumentError, IllegalBidFeeError } from '../../utils/errors';\nimport { NamePointer } from '../../apis/node';\nimport { readId, writeId } from './address';\n\n/**\n * JavaScript-based Transaction builder helper function's\n */\n\n/**\n * Build a contract public key\n * @category contract\n * @param ownerId - The public key of the owner account\n * @param nonce - the nonce of the transaction\n * @returns Contract public key\n */\nexport function buildContractId(\n ownerId: Encoded.AccountAddress,\n nonce: number | BigNumber,\n): Encoded.ContractAddress {\n const ownerIdAndNonce = Buffer.from([...decode(ownerId), ...toBytes(nonce)]);\n const b2bHash = hash(ownerIdAndNonce);\n return encode(b2bHash, Encoding.ContractAddress);\n}\n\n/**\n * Build a oracle query id\n * @category oracle\n * @param senderId - The public key of the sender account\n * @param nonce - the nonce of the transaction\n * @param oracleId - The oracle public key\n * @returns Contract public key\n */\nexport function oracleQueryId(\n senderId: Encoded.AccountAddress,\n nonce: number | BigNumber | string,\n oracleId: Encoded.OracleAddress,\n): Encoded.OracleQueryId {\n function _int32(val: number | string | BigNumber): Buffer {\n const nonceBE = toBytes(val, true);\n return concatBuffers([Buffer.alloc(32 - nonceBE.length), nonceBE]);\n }\n\n const b2bHash = hash(\n Buffer.from([...decode(senderId), ..._int32(nonce), ...decode(oracleId)]),\n );\n return encode(b2bHash, Encoding.OracleQueryId);\n}\n\n/**\n * Format the salt into a 64-byte hex string\n * @category transaction builder\n * @param salt - Random number\n * @returns Zero-padded hex string of salt\n */\nexport function formatSalt(salt: number): Buffer {\n return Buffer.from(salt.toString(16).padStart(64, '0'), 'hex');\n}\n\n/**\n * Encode an AENS name\n * @category AENS\n * @param name - Name to encode\n * @returns `nm_` prefixed encoded AENS name\n */\nexport function produceNameId(name: AensName): Encoded.Name {\n return encode(hash(name.toLowerCase()), Encoding.Name);\n}\n\n/**\n * Generate the commitment hash by hashing the formatted salt and\n * name, base 58 encoding the result and prepending 'cm_'\n * @category transaction builder\n * @param name - Name to be registered\n * @param salt - Random salt\n * @returns Commitment hash\n */\nexport function commitmentHash(\n name: AensName,\n salt: number = genSalt(),\n): Encoded.Commitment {\n return encode(\n hash(concatBuffers([Buffer.from(name.toLowerCase()), formatSalt(salt)])),\n Encoding.Commitment,\n );\n}\n\n/**\n * Utility function to convert int to bytes\n * @category transaction builder\n * @param val - Value\n * @returns Buffer Buffer from number(BigEndian)\n */\nexport function writeInt(val: number | string | BigNumber): Buffer {\n return toBytes(val, true);\n}\n\n/**\n * Utility function to convert bytes to int\n * @category transaction builder\n * @param buf - Value\n * @returns Buffer Buffer from number(BigEndian)\n */\nexport function readInt(buf: Buffer = Buffer.from([])): string {\n return new BigNumber(Buffer.from(buf).toString('hex'), 16).toString(10);\n}\n\n/**\n * Helper function to build pointers for name update TX\n * @category transaction builder\n * @param pointers - Array of pointers\n * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`\n * @returns Serialized pointers array\n */\nexport function buildPointers(pointers: NamePointer[]): Buffer[][] {\n return pointers.map(\n (p) => [\n toBytes(p.key),\n writeId(p.id as Parameters<typeof writeId>[0]),\n ],\n );\n}\n\n/**\n * Helper function to read pointers from name update TX\n * @category transaction builder\n * @param pointers - Array of pointers\n * @returns Deserialize pointer array\n */\nexport function readPointers(pointers: Array<[key: string, id: Buffer]>): NamePointer[] {\n return pointers.map(\n ([key, id]) => ({\n key: key.toString(),\n id: readId(id),\n }),\n );\n}\n\nconst AENS_SUFFIX = '.chain';\n\n/**\n * Is AENS name valid\n * @category AENS\n * @param name - AENS name\n */\nexport function isNameValid(name: string): name is AensName {\n // TODO: probably there are stronger requirements\n return name.endsWith(AENS_SUFFIX);\n}\n\nconst encodingToPointerKey = [\n [Encoding.AccountAddress, 'account_pubkey'],\n [Encoding.OracleAddress, 'oracle_pubkey'],\n [Encoding.ContractAddress, 'contract_pubkey'],\n [Encoding.Channel, 'channel'],\n] as const;\n\n/**\n * @category AENS\n * @param identifier - account/oracle/contract address, or channel\n * @returns default AENS pointer key\n */\nexport function getDefaultPointerKey(\n identifier: Encoded.Generic<typeof encodingToPointerKey[number][0]>,\n): typeof encodingToPointerKey[number][1] {\n decode(identifier);\n const encoding = identifier.substring(0, 2);\n const result = encodingToPointerKey.find(([e]) => e === encoding)?.[1];\n if (result != null) return result;\n throw new ArgumentError(\n 'identifier',\n `prefixed with one of ${encodingToPointerKey.map(([e]) => `${e}_`).join(', ')}`,\n identifier,\n );\n}\n\n/**\n * Get the minimum AENS name fee\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @returns the minimum fee for the AENS name auction\n */\nexport function getMinimumNameFee(name: AensName): BigNumber {\n const nameLength = name.length - AENS_SUFFIX.length;\n return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)];\n}\n\n/**\n * Compute bid fee for AENS auction\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @param options - Options\n * @param options.startFee - Auction start fee\n * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)\n * @returns Bid fee\n */\nexport function computeBidFee(\n name: AensName,\n { startFee, increment = NAME_FEE_BID_INCREMENT }:\n { startFee?: number | string | BigNumber; increment?: number } = {},\n): BigNumber {\n if (!(Number(increment) === increment && increment % 1 !== 0)) throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`);\n if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);\n // FIXME: increment should be used somehow here\n return ceil(\n new BigNumber(startFee ?? getMinimumNameFee(name))\n .times(new BigNumber(NAME_FEE_BID_INCREMENT).plus(1)),\n );\n}\n\n/**\n * Compute auction end height\n * @category AENS\n * @param name - Name to compute auction end for\n * @param claimHeight - Auction starting height\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}\n * @returns Auction end height\n */\nexport function computeAuctionEndBlock(name: AensName, claimHeight: number): number {\n const length = name.length - AENS_SUFFIX.length;\n const h = (length <= 4 && 62 * NAME_BID_TIMEOUT_BLOCKS)\n || (length <= 8 && 31 * NAME_BID_TIMEOUT_BLOCKS)\n || (length <= 12 && NAME_BID_TIMEOUT_BLOCKS)\n || 0;\n return h + claimHeight;\n}\n\n/**\n * Is name accept going to auction\n * @category AENS\n */\nexport function isAuctionName(name: AensName): boolean {\n return name.length < 13 + AENS_SUFFIX.length;\n}\n"],"mappings":";;;;AAAA,OAAOA,SAAP,MAAsB,cAAtB;SACSC,O,EAASC,I;SAEhBC,M,EAAQC,M,EAAiBC,Q;SAElBC,O;SACAC,a;SAGPC,e,EACAC,uB,EACAC,sB,EACAC,mB;SAEOC,I;SACAC,a,EAAeC,kB;SAEfC,M,EAAQC,O;AAEjB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CACLC,OADK,EAELC,KAFK,EAGoB;EACzB,MAAMC,eAAe,GAAG,QAAOC,IAAP,CAAY,CAAC,GAAGlB,MAAM,CAACe,OAAD,CAAV,EAAqB,GAAGZ,OAAO,CAACa,KAAD,CAA/B,CAAZ,CAAxB;;EACA,MAAMG,OAAO,GAAGpB,IAAI,CAACkB,eAAD,CAApB;EACA,OAAOhB,MAAM,CAACkB,OAAD,EAAUjB,QAAQ,CAACkB,eAAnB,CAAb;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