@aeternity/aepp-sdk 12.1.3 → 13.0.0-alpha.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 (565) hide show
  1. package/bin/aesophia_cli +0 -0
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +1 -1
  5. package/dist/aepp-sdk.browser.js.map +1 -1
  6. package/dist/aepp-sdk.js +12031 -11231
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdk.d.ts +7 -3
  9. package/es/AeSdk.mjs +17 -22
  10. package/es/AeSdk.mjs.map +1 -1
  11. package/es/AeSdkAepp.d.ts +6 -5
  12. package/es/AeSdkAepp.mjs +7 -30
  13. package/es/AeSdkAepp.mjs.map +1 -1
  14. package/es/AeSdkBase.d.ts +18 -140
  15. package/es/AeSdkBase.mjs +30 -184
  16. package/es/AeSdkBase.mjs.map +1 -1
  17. package/es/AeSdkMethods.d.ts +123 -0
  18. package/es/AeSdkMethods.mjs +122 -0
  19. package/es/AeSdkMethods.mjs.map +1 -0
  20. package/es/AeSdkWallet.d.ts +7 -21
  21. package/es/AeSdkWallet.mjs +38 -86
  22. package/es/AeSdkWallet.mjs.map +1 -1
  23. package/es/Node.d.ts +11 -15
  24. package/es/Node.mjs +35 -48
  25. package/es/Node.mjs.map +1 -1
  26. package/es/account/Base.d.ts +24 -40
  27. package/es/account/Base.mjs +1 -101
  28. package/es/account/Base.mjs.map +1 -1
  29. package/es/account/Generalized.d.ts +16 -0
  30. package/es/account/Generalized.mjs +113 -0
  31. package/es/account/Generalized.mjs.map +1 -0
  32. package/es/account/Ledger.d.ts +28 -0
  33. package/es/account/Ledger.mjs +102 -0
  34. package/es/account/Ledger.mjs.map +1 -0
  35. package/es/account/LedgerFactory.d.ts +39 -0
  36. package/es/account/LedgerFactory.mjs +81 -0
  37. package/es/account/LedgerFactory.mjs.map +1 -0
  38. package/es/account/Memory.d.ts +13 -17
  39. package/es/account/Memory.mjs +43 -64
  40. package/es/account/Memory.mjs.map +1 -1
  41. package/es/account/Rpc.d.ts +6 -8
  42. package/es/account/Rpc.mjs +14 -32
  43. package/es/account/Rpc.mjs.map +1 -1
  44. package/es/aens.d.ts +4 -4
  45. package/es/aens.mjs +46 -41
  46. package/es/aens.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
  48. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  50. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +22 -11
  51. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
  53. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
  54. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  55. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  56. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
  57. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -42
  58. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
  60. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/schema.mjs +14 -68
  62. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  63. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  64. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  65. package/es/apis/compiler/compiler.d.ts +23 -29
  66. package/es/apis/compiler/compiler.mjs +128 -189
  67. package/es/apis/compiler/compiler.mjs.map +1 -1
  68. package/es/apis/compiler/index.mjs.map +1 -1
  69. package/es/apis/compiler/models/index.d.ts +82 -135
  70. package/es/apis/compiler/models/index.mjs +1 -47
  71. package/es/apis/compiler/models/index.mjs.map +1 -1
  72. package/es/apis/compiler/models/mappers.d.ts +8 -8
  73. package/es/apis/compiler/models/mappers.mjs +165 -183
  74. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  75. package/es/apis/compiler/models/parameters.d.ts +0 -1
  76. package/es/apis/compiler/models/parameters.mjs +5 -9
  77. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  78. package/es/apis/node/index.mjs.map +1 -1
  79. package/es/apis/node/models/index.d.ts +48 -48
  80. package/es/apis/node/models/mappers.mjs +12 -6
  81. package/es/apis/node/models/mappers.mjs.map +1 -1
  82. package/es/apis/node/models/parameters.mjs.map +1 -1
  83. package/es/apis/node/node.mjs +43 -84
  84. package/es/apis/node/node.mjs.map +1 -1
  85. package/es/chain.d.ts +10 -2
  86. package/es/chain.mjs +37 -59
  87. package/es/chain.mjs.map +1 -1
  88. package/es/channel/Base.d.ts +200 -0
  89. package/es/channel/Base.mjs +293 -0
  90. package/es/channel/Base.mjs.map +1 -0
  91. package/es/channel/Contract.d.ts +248 -0
  92. package/es/channel/Contract.mjs +420 -0
  93. package/es/channel/Contract.mjs.map +1 -0
  94. package/es/channel/Spend.d.ts +219 -0
  95. package/es/channel/Spend.mjs +385 -0
  96. package/es/channel/Spend.mjs.map +1 -0
  97. package/es/channel/handlers.d.ts +8 -21
  98. package/es/channel/handlers.mjs +151 -899
  99. package/es/channel/handlers.mjs.map +1 -1
  100. package/es/channel/internal.d.ts +27 -21
  101. package/es/channel/internal.mjs +101 -191
  102. package/es/channel/internal.mjs.map +1 -1
  103. package/es/contract/Contract.d.ts +210 -0
  104. package/es/contract/Contract.mjs +551 -0
  105. package/es/contract/Contract.mjs.map +1 -0
  106. package/es/contract/compiler/Base.d.ts +81 -0
  107. package/es/contract/compiler/Base.mjs +5 -0
  108. package/es/contract/compiler/Base.mjs.map +1 -0
  109. package/es/contract/compiler/Cli.d.ts +23 -0
  110. package/es/contract/compiler/Cli.mjs +155 -0
  111. package/es/contract/compiler/Cli.mjs.map +1 -0
  112. package/es/contract/compiler/Http.d.ts +32 -0
  113. package/es/contract/compiler/Http.mjs +118 -0
  114. package/es/contract/compiler/Http.mjs.map +1 -0
  115. package/es/contract/compiler/HttpNode.d.ts +17 -0
  116. package/es/contract/compiler/HttpNode.mjs +26 -0
  117. package/es/contract/compiler/HttpNode.mjs.map +1 -0
  118. package/es/contract/compiler/getFileSystem.d.ts +6 -0
  119. package/es/contract/compiler/getFileSystem.mjs +40 -0
  120. package/es/contract/compiler/getFileSystem.mjs.map +1 -0
  121. package/es/contract/ga.d.ts +9 -34
  122. package/es/contract/ga.mjs +29 -112
  123. package/es/contract/ga.mjs.map +1 -1
  124. package/es/index-browser.d.ts +39 -0
  125. package/es/index-browser.mjs +55 -0
  126. package/es/index-browser.mjs.map +1 -0
  127. package/es/index.d.ts +4 -35
  128. package/es/index.mjs +4 -51
  129. package/es/index.mjs.map +1 -1
  130. package/es/oracle.d.ts +5 -5
  131. package/es/oracle.mjs +34 -40
  132. package/es/oracle.mjs.map +1 -1
  133. package/es/spend.d.ts +3 -3
  134. package/es/spend.mjs +18 -23
  135. package/es/spend.mjs.map +1 -1
  136. package/es/tx/builder/constants.d.ts +30 -2
  137. package/es/tx/builder/constants.mjs +43 -14
  138. package/es/tx/builder/constants.mjs.map +1 -1
  139. package/es/tx/builder/field-types/abi-version.d.ts +10 -0
  140. package/es/tx/builder/field-types/abi-version.mjs +20 -0
  141. package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
  142. package/es/tx/builder/field-types/address.d.ts +14 -0
  143. package/es/tx/builder/field-types/address.mjs +51 -0
  144. package/es/tx/builder/field-types/address.mjs.map +1 -0
  145. package/es/tx/builder/field-types/array.d.ts +7 -0
  146. package/es/tx/builder/field-types/array.mjs +11 -0
  147. package/es/tx/builder/field-types/array.mjs.map +1 -0
  148. package/es/tx/builder/field-types/boolean.d.ts +6 -0
  149. package/es/tx/builder/field-types/boolean.mjs +13 -0
  150. package/es/tx/builder/field-types/boolean.mjs.map +1 -0
  151. package/es/tx/builder/field-types/coin-amount.d.ts +2 -3
  152. package/es/tx/builder/field-types/coin-amount.mjs +4 -12
  153. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  154. package/es/tx/builder/field-types/ct-version.d.ts +30 -0
  155. package/es/tx/builder/field-types/ct-version.mjs +48 -0
  156. package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
  157. package/es/tx/builder/field-types/deposit.d.ts +1 -2
  158. package/es/tx/builder/field-types/deposit.mjs +2 -4
  159. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  160. package/es/tx/builder/field-types/encoded.d.ts +6 -0
  161. package/es/tx/builder/field-types/encoded.mjs +21 -0
  162. package/es/tx/builder/field-types/encoded.mjs.map +1 -0
  163. package/es/tx/builder/field-types/entry.d.ts +11 -0
  164. package/es/tx/builder/field-types/entry.mjs +31 -0
  165. package/es/tx/builder/field-types/entry.mjs.map +1 -0
  166. package/es/tx/builder/field-types/enumeration.d.ts +7 -0
  167. package/es/tx/builder/field-types/enumeration.mjs +30 -0
  168. package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
  169. package/es/tx/builder/field-types/fee.d.ts +10 -15
  170. package/es/tx/builder/field-types/fee.mjs +31 -43
  171. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  172. package/es/tx/builder/field-types/field.mjs +0 -2
  173. package/es/tx/builder/field-types/field.mjs.map +1 -1
  174. package/es/tx/builder/field-types/gas-limit.d.ts +5 -2
  175. package/es/tx/builder/field-types/gas-limit.mjs +12 -14
  176. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  177. package/es/tx/builder/field-types/gas-price.d.ts +1 -2
  178. package/es/tx/builder/field-types/gas-price.mjs +3 -7
  179. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  180. package/es/tx/builder/field-types/index.d.ts +80 -30
  181. package/es/tx/builder/field-types/index.mjs +34 -9
  182. package/es/tx/builder/field-types/index.mjs.map +1 -1
  183. package/es/tx/builder/field-types/mptree.d.ts +37 -0
  184. package/es/tx/builder/field-types/mptree.mjs +268 -0
  185. package/es/tx/builder/field-types/mptree.mjs.map +1 -0
  186. package/es/tx/builder/field-types/name-fee.d.ts +1 -3
  187. package/es/tx/builder/field-types/name-fee.mjs +3 -5
  188. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  189. package/es/tx/builder/field-types/name-id.d.ts +1 -4
  190. package/es/tx/builder/field-types/name-id.mjs +5 -10
  191. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  192. package/es/tx/builder/field-types/name.mjs +0 -2
  193. package/es/tx/builder/field-types/name.mjs.map +1 -1
  194. package/es/tx/builder/field-types/pointers.d.ts +23 -0
  195. package/es/tx/builder/field-types/pointers.mjs +36 -0
  196. package/es/tx/builder/field-types/pointers.mjs.map +1 -0
  197. package/es/tx/builder/field-types/raw.d.ts +6 -0
  198. package/es/tx/builder/field-types/raw.mjs +13 -0
  199. package/es/tx/builder/field-types/raw.mjs.map +1 -0
  200. package/es/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  201. package/es/tx/builder/field-types/short-u-int-const.mjs +16 -0
  202. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
  203. package/es/tx/builder/field-types/short-u-int.mjs +0 -2
  204. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  205. package/es/tx/builder/field-types/string.d.ts +6 -0
  206. package/es/tx/builder/field-types/string.mjs +10 -0
  207. package/es/tx/builder/field-types/string.mjs.map +1 -0
  208. package/es/tx/builder/field-types/u-int.d.ts +1 -2
  209. package/es/tx/builder/field-types/u-int.mjs +3 -4
  210. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  211. package/es/tx/builder/helpers.d.ts +2 -32
  212. package/es/tx/builder/helpers.mjs +19 -71
  213. package/es/tx/builder/helpers.mjs.map +1 -1
  214. package/es/tx/builder/index.d.ts +11 -49
  215. package/es/tx/builder/index.mjs +57 -337
  216. package/es/tx/builder/index.mjs.map +1 -1
  217. package/es/tx/builder/schema.d.ts +2367 -667
  218. package/es/tx/builder/schema.mjs +70 -145
  219. package/es/tx/builder/schema.mjs.map +1 -1
  220. package/es/tx/index.d.ts +4 -49
  221. package/es/tx/index.mjs +38 -112
  222. package/es/tx/index.mjs.map +1 -1
  223. package/es/tx/validator.d.ts +4 -6
  224. package/es/tx/validator.mjs +104 -90
  225. package/es/tx/validator.mjs.map +1 -1
  226. package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
  227. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
  228. package/es/utils/amount-formatter.mjs +4 -10
  229. package/es/utils/amount-formatter.mjs.map +1 -1
  230. package/es/utils/autorest.d.ts +1 -0
  231. package/es/utils/autorest.mjs +17 -19
  232. package/es/utils/autorest.mjs.map +1 -1
  233. package/es/utils/bignumber.mjs +4 -7
  234. package/es/utils/bignumber.mjs.map +1 -1
  235. package/es/utils/bytes.d.ts +0 -17
  236. package/es/utils/bytes.mjs +6 -35
  237. package/es/utils/bytes.mjs.map +1 -1
  238. package/es/utils/crypto.d.ts +15 -8
  239. package/es/utils/crypto.mjs +40 -40
  240. package/es/utils/crypto.mjs.map +1 -1
  241. package/es/utils/encoder-types.d.ts +28 -28
  242. package/es/utils/encoder-types.mjs +0 -1
  243. package/es/utils/encoder-types.mjs.map +1 -1
  244. package/es/utils/encoder.d.ts +0 -1
  245. package/es/utils/encoder.mjs +7 -15
  246. package/es/utils/encoder.mjs.map +1 -1
  247. package/es/utils/errors.d.ts +15 -14
  248. package/es/utils/errors.mjs +86 -172
  249. package/es/utils/errors.mjs.map +1 -1
  250. package/es/utils/hd-wallet.d.ts +27 -19
  251. package/es/utils/hd-wallet.mjs +42 -26
  252. package/es/utils/hd-wallet.mjs.map +1 -1
  253. package/es/utils/json-big.mjs +0 -8
  254. package/es/utils/json-big.mjs.map +1 -1
  255. package/es/utils/keystore.d.ts +2 -0
  256. package/es/utils/keystore.mjs +37 -36
  257. package/es/utils/keystore.mjs.map +1 -1
  258. package/es/utils/other.d.ts +4 -2
  259. package/es/utils/other.mjs +11 -7
  260. package/es/utils/other.mjs.map +1 -1
  261. package/es/utils/semver-satisfies.mjs +0 -3
  262. package/es/utils/semver-satisfies.mjs.map +1 -1
  263. package/es/utils/string.d.ts +0 -12
  264. package/es/utils/string.mjs +1 -21
  265. package/es/utils/string.mjs.map +1 -1
  266. package/package.json +98 -51
  267. package/src/AeSdk.ts +15 -11
  268. package/src/AeSdkAepp.ts +9 -7
  269. package/src/AeSdkBase.ts +31 -202
  270. package/src/AeSdkMethods.ts +169 -0
  271. package/src/AeSdkWallet.ts +16 -47
  272. package/src/Node.ts +17 -18
  273. package/src/account/Base.ts +29 -75
  274. package/src/account/Generalized.ts +98 -0
  275. package/src/account/Ledger.ts +131 -0
  276. package/src/account/LedgerFactory.ts +86 -0
  277. package/src/account/Memory.ts +46 -60
  278. package/src/account/Rpc.ts +17 -26
  279. package/src/aens.ts +13 -11
  280. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +21 -9
  281. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
  282. package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -4
  283. package/src/aepp-wallet-communication/rpc/types.ts +11 -1
  284. package/src/aepp-wallet-communication/schema.ts +18 -18
  285. package/src/apis/compiler/code-model-v4.yaml +681 -888
  286. package/src/apis/compiler/compiler.ts +113 -154
  287. package/src/apis/compiler/models/index.ts +80 -140
  288. package/src/apis/compiler/models/mappers.ts +165 -183
  289. package/src/apis/compiler/models/parameters.ts +6 -12
  290. package/src/chain.ts +11 -6
  291. package/src/channel/Base.ts +335 -0
  292. package/src/channel/Contract.ts +488 -0
  293. package/src/channel/Spend.ts +408 -0
  294. package/src/channel/handlers.ts +164 -582
  295. package/src/channel/internal.ts +114 -143
  296. package/src/contract/Contract.ts +610 -0
  297. package/src/contract/compiler/Base.ts +94 -0
  298. package/src/contract/compiler/Cli.ts +134 -0
  299. package/src/contract/compiler/Http.ts +124 -0
  300. package/src/contract/compiler/HttpNode.ts +26 -0
  301. package/src/contract/compiler/getFileSystem.ts +42 -0
  302. package/src/contract/ga.ts +23 -106
  303. package/src/index-browser.ts +58 -0
  304. package/src/index.ts +4 -55
  305. package/src/oracle.ts +8 -8
  306. package/src/spend.ts +6 -14
  307. package/src/tx/builder/constants.ts +33 -3
  308. package/src/tx/builder/field-types/abi-version.ts +21 -0
  309. package/src/tx/builder/field-types/address.ts +62 -0
  310. package/src/tx/builder/field-types/array.ts +19 -0
  311. package/src/tx/builder/field-types/boolean.ts +9 -0
  312. package/src/tx/builder/field-types/coin-amount.ts +4 -9
  313. package/src/tx/builder/field-types/ct-version.ts +50 -0
  314. package/src/tx/builder/field-types/deposit.ts +1 -1
  315. package/src/tx/builder/field-types/encoded.ts +27 -0
  316. package/src/tx/builder/field-types/entry.ts +31 -0
  317. package/src/tx/builder/field-types/enumeration.ts +32 -0
  318. package/src/tx/builder/field-types/fee.ts +39 -21
  319. package/src/tx/builder/field-types/gas-limit.ts +13 -8
  320. package/src/tx/builder/field-types/gas-price.ts +0 -2
  321. package/src/tx/builder/field-types/index.ts +54 -15
  322. package/src/tx/builder/field-types/mptree.ts +242 -0
  323. package/src/tx/builder/field-types/name-fee.ts +2 -3
  324. package/src/tx/builder/field-types/name-id.ts +7 -10
  325. package/src/tx/builder/field-types/pointers.ts +41 -0
  326. package/src/tx/builder/field-types/raw.ts +9 -0
  327. package/src/tx/builder/field-types/short-u-int-const.ts +20 -0
  328. package/src/tx/builder/field-types/string.ts +11 -0
  329. package/src/tx/builder/field-types/u-int.ts +4 -5
  330. package/src/tx/builder/helpers.ts +10 -60
  331. package/src/tx/builder/index.ts +65 -308
  332. package/src/tx/builder/schema.ts +280 -341
  333. package/src/tx/index.ts +40 -103
  334. package/src/tx/validator.ts +91 -96
  335. package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
  336. package/src/utils/autorest.ts +16 -1
  337. package/src/utils/bytes.ts +6 -34
  338. package/src/utils/crypto.ts +23 -16
  339. package/src/utils/encoder.ts +0 -1
  340. package/src/utils/errors.ts +22 -25
  341. package/src/utils/hd-wallet.ts +30 -9
  342. package/src/utils/keystore.ts +24 -21
  343. package/src/utils/other.ts +16 -1
  344. package/src/utils/string.ts +0 -20
  345. package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
  346. package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
  347. package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
  348. package/types-legacy/ts4.2/AeSdkMethods.d.ts +140 -0
  349. package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
  350. package/types-legacy/ts4.2/Node.d.ts +78 -0
  351. package/types-legacy/ts4.2/account/Base.d.ts +52 -0
  352. package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
  353. package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
  354. package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
  355. package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
  356. package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
  357. package/types-legacy/ts4.2/aens.d.ts +222 -0
  358. package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  359. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
  360. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  361. package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  362. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  363. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
  364. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
  365. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  366. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
  367. package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
  368. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
  369. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
  370. package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
  371. package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
  372. package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
  373. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
  374. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
  375. package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
  376. package/types-legacy/ts4.2/chain.d.ts +256 -0
  377. package/types-legacy/ts4.2/channel/Base.d.ts +199 -0
  378. package/types-legacy/ts4.2/channel/Contract.d.ts +248 -0
  379. package/types-legacy/ts4.2/channel/Spend.d.ts +219 -0
  380. package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
  381. package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
  382. package/types-legacy/ts4.2/contract/Contract.d.ts +212 -0
  383. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +81 -0
  384. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
  385. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
  386. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
  387. package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
  388. package/types-legacy/ts4.2/contract/ga.d.ts +44 -0
  389. package/types-legacy/ts4.2/globals.d.ts +16 -0
  390. package/types-legacy/ts4.2/index-browser.d.ts +39 -0
  391. package/types-legacy/ts4.2/index.d.ts +5 -0
  392. package/types-legacy/ts4.2/oracle.d.ts +161 -0
  393. package/types-legacy/ts4.2/spend.d.ts +62 -0
  394. package/types-legacy/ts4.2/tx/builder/constants.d.ts +98 -0
  395. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +10 -0
  396. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +21 -0
  397. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
  398. package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
  399. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
  400. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +42 -0
  401. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
  402. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
  403. package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
  404. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +7 -0
  405. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +20 -0
  406. package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
  407. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +15 -0
  408. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
  409. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +129 -0
  410. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +43 -0
  411. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +18 -0
  412. package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
  413. package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
  414. package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
  415. package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
  416. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  417. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
  418. package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
  419. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +7 -0
  420. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
  421. package/types-legacy/ts4.2/tx/builder/index.d.ts +50 -0
  422. package/types-legacy/ts4.2/tx/builder/schema.d.ts +4675 -0
  423. package/types-legacy/ts4.2/tx/index.d.ts +19 -0
  424. package/types-legacy/ts4.2/tx/validator.d.ts +18 -0
  425. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
  426. package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
  427. package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
  428. package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
  429. package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
  430. package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
  431. package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
  432. package/types-legacy/ts4.2/utils/errors.d.ts +475 -0
  433. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
  434. package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
  435. package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
  436. package/types-legacy/ts4.2/utils/other.d.ts +31 -0
  437. package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
  438. package/types-legacy/ts4.2/utils/string.d.ts +12 -0
  439. package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
  440. package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
  441. package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
  442. package/types-legacy/ts4.5/AeSdkMethods.d.ts +140 -0
  443. package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
  444. package/types-legacy/ts4.5/Node.d.ts +78 -0
  445. package/types-legacy/ts4.5/account/Base.d.ts +52 -0
  446. package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
  447. package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
  448. package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
  449. package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
  450. package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
  451. package/types-legacy/ts4.5/aens.d.ts +222 -0
  452. package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  453. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
  454. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  455. package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  456. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  457. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
  458. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
  459. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  460. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
  461. package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
  462. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
  463. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
  464. package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
  465. package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
  466. package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
  467. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
  468. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
  469. package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
  470. package/types-legacy/ts4.5/chain.d.ts +256 -0
  471. package/types-legacy/ts4.5/channel/Base.d.ts +199 -0
  472. package/types-legacy/ts4.5/channel/Contract.d.ts +248 -0
  473. package/types-legacy/ts4.5/channel/Spend.d.ts +219 -0
  474. package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
  475. package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
  476. package/types-legacy/ts4.5/contract/Contract.d.ts +212 -0
  477. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +81 -0
  478. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
  479. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
  480. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
  481. package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
  482. package/types-legacy/ts4.5/contract/ga.d.ts +44 -0
  483. package/types-legacy/ts4.5/index-browser.d.ts +39 -0
  484. package/types-legacy/ts4.5/index.d.ts +4 -0
  485. package/types-legacy/ts4.5/oracle.d.ts +161 -0
  486. package/types-legacy/ts4.5/spend.d.ts +62 -0
  487. package/types-legacy/ts4.5/tx/builder/constants.d.ts +98 -0
  488. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +10 -0
  489. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +21 -0
  490. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
  491. package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
  492. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
  493. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +42 -0
  494. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
  495. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
  496. package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
  497. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +7 -0
  498. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +20 -0
  499. package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
  500. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +15 -0
  501. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
  502. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +129 -0
  503. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +43 -0
  504. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +18 -0
  505. package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
  506. package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
  507. package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
  508. package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
  509. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  510. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
  511. package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
  512. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +7 -0
  513. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
  514. package/types-legacy/ts4.5/tx/builder/index.d.ts +50 -0
  515. package/types-legacy/ts4.5/tx/builder/schema.d.ts +4675 -0
  516. package/types-legacy/ts4.5/tx/index.d.ts +19 -0
  517. package/types-legacy/ts4.5/tx/validator.d.ts +18 -0
  518. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
  519. package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
  520. package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
  521. package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
  522. package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
  523. package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
  524. package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
  525. package/types-legacy/ts4.5/utils/errors.d.ts +475 -0
  526. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
  527. package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
  528. package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
  529. package/types-legacy/ts4.5/utils/other.d.ts +31 -0
  530. package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
  531. package/types-legacy/ts4.5/utils/string.d.ts +12 -0
  532. package/es/channel/index.d.ts +0 -625
  533. package/es/channel/index.mjs +0 -975
  534. package/es/channel/index.mjs.map +0 -1
  535. package/es/contract/Compiler.d.ts +0 -18
  536. package/es/contract/Compiler.mjs +0 -68
  537. package/es/contract/Compiler.mjs.map +0 -1
  538. package/es/contract/aci.d.ts +0 -127
  539. package/es/contract/aci.mjs +0 -508
  540. package/es/contract/aci.mjs.map +0 -1
  541. package/es/contract/methods.d.ts +0 -71
  542. package/es/contract/methods.mjs +0 -104
  543. package/es/contract/methods.mjs.map +0 -1
  544. package/es/deprecated/index.d.ts +0 -143
  545. package/es/deprecated/index.mjs +0 -162
  546. package/es/deprecated/index.mjs.map +0 -1
  547. package/es/deprecated/methods.d.ts +0 -18
  548. package/es/deprecated/methods.mjs +0 -26
  549. package/es/deprecated/methods.mjs.map +0 -1
  550. package/es/tx/builder/address.d.ts +0 -25
  551. package/es/tx/builder/address.mjs +0 -45
  552. package/es/tx/builder/address.mjs.map +0 -1
  553. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
  554. package/es/utils/mptree.d.ts +0 -26
  555. package/es/utils/mptree.mjs +0 -165
  556. package/es/utils/mptree.mjs.map +0 -1
  557. package/src/channel/index.ts +0 -1025
  558. package/src/contract/Compiler.ts +0 -67
  559. package/src/contract/aci.ts +0 -537
  560. package/src/contract/methods.ts +0 -123
  561. package/src/deprecated/index.ts +0 -172
  562. package/src/deprecated/methods.ts +0 -25
  563. package/src/tx/builder/address.ts +0 -50
  564. package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
  565. package/src/utils/mptree.ts +0 -145
package/es/Node.mjs CHANGED
@@ -1,75 +1,47 @@
1
+ import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
2
+ import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
3
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
1
4
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
2
-
3
5
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
4
-
5
6
  function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
6
-
7
7
  // eslint-disable-next-line max-classes-per-file
8
8
  import BigNumber from 'bignumber.js';
9
9
  import { genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy, genVersionCheckPolicy } from "./utils/autorest.mjs";
10
10
  import { Node as NodeApi } from "./apis/node/index.mjs";
11
11
  import { mapObject } from "./utils/other.mjs";
12
- import { MissingParamError } from "./utils/errors.mjs";
13
- /**
14
- * Obtain networkId from account or node
15
- */
16
-
17
- export async function getNetworkId() {
18
- var _ref, _await$this$api$getSt, _this$api;
19
-
20
- let {
21
- networkId
22
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
- const res = (_ref = networkId !== null && networkId !== void 0 ? networkId : this.networkId) !== null && _ref !== void 0 ? _ref : (_await$this$api$getSt = await ((_this$api = this.api) === null || _this$api === void 0 ? void 0 : _this$api.getStatus())) === null || _await$this$api$getSt === void 0 ? void 0 : _await$this$api$getSt.networkId;
24
- if (res != null) return res;
25
- throw new MissingParamError('networkId is not provided');
26
- }
27
12
  const bigIntPropertyNames = ['balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount', 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal', 'responderAmountFinal', 'gasPrice', 'deposit'];
28
- const numberPropertyNames = ['time', 'gas', 'gasUsed', 'nameSalt', 'nonce', 'nextNonce', 'height', 'blockHeight', 'top', 'topBlockHeight', 'ttl', 'nameTtl', 'clientTtl', 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight', 'version', 'solutions', 'round'];
29
-
13
+ const numberPropertyNames = ['time', 'gas', 'gasUsed', 'nameSalt', 'nonce', 'nextNonce', 'height', 'blockHeight', 'topBlockHeight', 'ttl', 'nameTtl', 'clientTtl', 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight', 'version', 'solutions', 'round'];
30
14
  var _mapData = /*#__PURE__*/new WeakSet();
31
-
32
15
  var _encodeArg = /*#__PURE__*/new WeakSet();
33
-
34
16
  var _decodeRes = /*#__PURE__*/new WeakSet();
35
-
36
17
  class NodeTransformed extends NodeApi {
37
18
  constructor() {
38
19
  super(...arguments);
39
-
40
20
  _classPrivateMethodInitSpec(this, _decodeRes);
41
-
42
21
  _classPrivateMethodInitSpec(this, _encodeArg);
43
-
44
22
  _classPrivateMethodInitSpec(this, _mapData);
45
23
  }
46
-
47
24
  async sendOperationRequest(operationArguments, operationSpec) {
48
- const args = mapObject(operationArguments, _ref2 => {
49
- let [key, value] = _ref2;
25
+ const args = mapObject(operationArguments, _ref => {
26
+ let [key, value] = _ref;
50
27
  return [key, _classPrivateMethodGet(this, _encodeArg, _encodeArg2).call(this, value)];
51
28
  });
52
29
  return _classPrivateMethodGet(this, _decodeRes, _decodeRes2).call(this, await super.sendOperationRequest(args, operationSpec));
53
30
  }
54
-
55
31
  }
56
-
57
32
  function _mapData2(data, transform) {
58
33
  if (Array.isArray(data)) return data.map(d => _classPrivateMethodGet(this, _mapData, _mapData2).call(this, d, transform));
59
-
60
34
  if (data != null && typeof data === 'object') {
61
- return mapObject(data, _ref5 => {
62
- let [key, value] = _ref5;
35
+ return mapObject(data, _ref6 => {
36
+ let [key, value] = _ref6;
63
37
  if (value == null) return [key, value];
64
38
  if (bigIntPropertyNames.some(k => k === key)) return [key, transform.bigInt(value)];
65
39
  if (numberPropertyNames.some(k => k === key)) return [key, transform.number(value)];
66
40
  return [key, _classPrivateMethodGet(this, _mapData, _mapData2).call(this, value, transform)];
67
41
  });
68
42
  }
69
-
70
43
  return data;
71
44
  }
72
-
73
45
  function _encodeArg2(data) {
74
46
  return _classPrivateMethodGet(this, _mapData, _mapData2).call(this, data, {
75
47
  bigInt: value => {
@@ -79,14 +51,13 @@ function _encodeArg2(data) {
79
51
  number: value => value.toString()
80
52
  });
81
53
  }
82
-
83
54
  function _decodeRes2(data) {
84
55
  return _classPrivateMethodGet(this, _mapData, _mapData2).call(this, data, {
85
56
  bigInt: value => BigInt(value),
86
57
  number: value => +value
87
58
  });
88
59
  }
89
-
60
+ var _networkIdPromise = /*#__PURE__*/new WeakMap();
90
61
  export default class Node extends NodeTransformed {
91
62
  /**
92
63
  * @param url - Url for node API
@@ -104,21 +75,38 @@ export default class Node extends NodeTransformed {
104
75
  additionalPolicies: [genRequestQueuesPolicy(), genCombineGetRequestsPolicy(), genErrorFormatterPolicy(body => ` ${body.reason}`)],
105
76
  ...options
106
77
  });
107
- this.url = url;
108
-
78
+ _classPrivateFieldInitSpec(this, _networkIdPromise, {
79
+ writable: true,
80
+ value: void 0
81
+ });
109
82
  if (!ignoreVersion) {
110
- const versionPromise = this.getStatus().then(_ref3 => {
83
+ const statusPromise = this.getStatus();
84
+ const versionPromise = statusPromise.then(_ref2 => {
111
85
  let {
112
86
  nodeVersion
113
- } = _ref3;
87
+ } = _ref2;
114
88
  return nodeVersion;
115
89
  });
90
+ _classPrivateFieldSet(this, _networkIdPromise, statusPromise.then(_ref3 => {
91
+ let {
92
+ networkId
93
+ } = _ref3;
94
+ return networkId;
95
+ }));
116
96
  this.pipeline.addPolicy(genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'));
117
97
  }
118
-
119
98
  this.intAsString = true;
120
99
  }
121
-
100
+ async getNetworkId() {
101
+ var _classPrivateFieldGet2;
102
+ (_classPrivateFieldGet2 = _classPrivateFieldGet(this, _networkIdPromise)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : _classPrivateFieldSet(this, _networkIdPromise, this.getStatus().then(_ref4 => {
103
+ let {
104
+ networkId
105
+ } = _ref4;
106
+ return networkId;
107
+ }));
108
+ return _classPrivateFieldGet(this, _networkIdPromise);
109
+ }
122
110
  async getNodeInfo() {
123
111
  const {
124
112
  nodeVersion: version,
@@ -126,22 +114,21 @@ export default class Node extends NodeTransformed {
126
114
  protocols,
127
115
  topBlockHeight
128
116
  } = await this.getStatus();
129
- const consensusProtocolVersion = protocols.filter(_ref4 => {
117
+ const consensusProtocolVersion = protocols.filter(_ref5 => {
130
118
  let {
131
119
  effectiveAtHeight
132
- } = _ref4;
120
+ } = _ref5;
133
121
  return topBlockHeight >= effectiveAtHeight;
134
122
  }).reduce((acc, p) => p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc, {
135
123
  effectiveAtHeight: -1,
136
124
  version: 0
137
125
  }).version;
138
126
  return {
139
- url: this.url,
127
+ url: this.$host,
140
128
  nodeNetworkId,
141
129
  version,
142
130
  consensusProtocolVersion
143
131
  };
144
132
  }
145
-
146
133
  }
147
134
  //# sourceMappingURL=Node.mjs.map
package/es/Node.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Node.mjs","names":["BigNumber","genRequestQueuesPolicy","genCombineGetRequestsPolicy","genErrorFormatterPolicy","genVersionCheckPolicy","Node","NodeApi","mapObject","MissingParamError","getNetworkId","networkId","res","api","getStatus","bigIntPropertyNames","numberPropertyNames","NodeTransformed","sendOperationRequest","operationArguments","operationSpec","args","key","value","data","transform","Array","isArray","map","d","some","k","bigInt","number","toFixed","toString","BigInt","constructor","url","ignoreVersion","options","allowInsecureConnection","additionalPolicies","body","reason","versionPromise","then","nodeVersion","pipeline","addPolicy","intAsString","getNodeInfo","version","nodeNetworkId","protocols","topBlockHeight","consensusProtocolVersion","filter","effectiveAtHeight","reduce","acc","p"],"sources":["../src/Node.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { OperationArguments, OperationSpec } from '@azure/core-client';\nimport {\n genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,\n genVersionCheckPolicy,\n} from './utils/autorest';\nimport { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';\nimport { mapObject } from './utils/other';\nimport { Encoded } from './utils/encoder';\nimport { MissingParamError } from './utils/errors';\n\n/**\n * Obtain networkId from account or node\n */\nexport async function getNetworkId({ networkId }: { networkId?: string } = {}): Promise<string> {\n const res = networkId ?? this.networkId ?? (await this.api?.getStatus())?.networkId;\n if (res != null) return res;\n throw new MissingParamError('networkId is not provided');\n}\n\nconst bigIntPropertyNames = [\n 'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',\n 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal',\n 'responderAmountFinal', 'gasPrice', 'deposit',\n] as const;\n\nconst numberPropertyNames = [\n 'time', 'gas', 'gasUsed', 'nameSalt',\n 'nonce', 'nextNonce', 'height', 'blockHeight', 'top', 'topBlockHeight',\n 'ttl', 'nameTtl', 'clientTtl',\n 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',\n 'version', 'solutions', 'round',\n] as const;\n\nclass NodeTransformed extends NodeApi {\n async sendOperationRequest(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<any> {\n const args = mapObject(\n operationArguments,\n ([key, value]) => [key, this.#encodeArg(value)],\n ) as OperationArguments;\n return this.#decodeRes(await super.sendOperationRequest(args, operationSpec));\n }\n\n #mapData(data: any, transform: {\n bigInt: (v: any) => any;\n number: (v: any) => any;\n }): unknown {\n if (Array.isArray(data)) return data.map((d) => this.#mapData(d, transform));\n if (data != null && typeof data === 'object') {\n return mapObject(data, ([key, value]) => {\n if (value == null) return [key, value];\n if (bigIntPropertyNames.some((k) => k === key)) return [key, transform.bigInt(value)];\n if (numberPropertyNames.some((k) => k === key)) return [key, transform.number(value)];\n return [key, this.#mapData(value, transform)];\n });\n }\n return data;\n }\n\n #encodeArg(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => {\n if (value instanceof BigNumber) return value.toFixed();\n return value.toString();\n },\n number: (value) => value.toString(),\n });\n }\n\n #decodeRes(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => BigInt(value),\n number: (value) => +value,\n });\n }\n}\n\ntype BigIntPropertyNames = typeof bigIntPropertyNames[number];\ntype NumberPropertyNames = typeof numberPropertyNames[number];\ntype PreserveOptional<NewType, OrigType> =\n OrigType extends undefined ? NewType | undefined : NewType;\nexport type TransformNodeType<Type> =\n Type extends (...args: infer Args) => infer Ret\n ? (...args: TransformNodeType<Args>) => TransformNodeType<Ret>\n : Type extends [infer Item, ...infer Rest]\n ? [TransformNodeType<Item>, ...TransformNodeType<Rest>]\n : Type extends Array<infer Item>\n ? Array<TransformNodeType<Item>>\n : Type extends Promise<infer T>\n ? Promise<TransformNodeType<T>>\n : Type extends { [P in any]: any }\n ? {\n [Property in keyof Type]:\n Property extends BigIntPropertyNames\n ? PreserveOptional<bigint, Type[Property]>\n : Property extends NumberPropertyNames\n ? PreserveOptional<number, Type[Property]>\n : Property extends 'txHash'\n ? PreserveOptional<Encoded.TxHash, Type[Property]>\n : TransformNodeType<Type[Property]>\n }\n : Type;\ntype NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {\n [Name in keyof InstanceType<typeof NodeApi>]:\n Name extends 'pipeline' | 'sendRequest' | 'sendOperationRequest'\n ? NodeApi[Name] : TransformNodeType<NodeApi[Name]>\n};\n\nexport interface NodeInfo {\n url: string;\n nodeNetworkId: string;\n version: string;\n consensusProtocolVersion: number;\n}\n\nexport default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {\n url: string;\n\n /**\n * @param url - Url for node API\n * @param options - Options\n * @param options.ignoreVersion - Don't check node version\n */\n constructor(\n url: string,\n { ignoreVersion = false, ...options }: NodeOptionalParams & { ignoreVersion?: boolean } = {},\n ) {\n // eslint-disable-next-line constructor-super\n super(url, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genRequestQueuesPolicy(),\n genCombineGetRequestsPolicy(),\n genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),\n ],\n ...options,\n });\n this.url = url;\n if (!ignoreVersion) {\n const versionPromise = this.getStatus().then(({ nodeVersion }) => nodeVersion);\n this.pipeline.addPolicy(\n genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'),\n );\n }\n this.intAsString = true;\n }\n\n async getNodeInfo(): Promise<NodeInfo> {\n const {\n nodeVersion: version,\n networkId: nodeNetworkId,\n protocols,\n topBlockHeight,\n } = await this.getStatus();\n const consensusProtocolVersion = protocols\n .filter(({ effectiveAtHeight }) => topBlockHeight >= effectiveAtHeight)\n .reduce(\n (acc, p) => (p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc),\n { effectiveAtHeight: -1, version: 0 },\n )\n .version;\n return {\n url: this.url,\n nodeNetworkId,\n version,\n consensusProtocolVersion,\n };\n }\n}\n"],"mappings":";;;;;;AAAA;AACA,OAAOA,SAAP,MAAsB,cAAtB;SAGEC,sB,EAAwBC,2B,EAA6BC,uB,EACrDC,qB;SAEOC,IAAI,IAAIC,O;SACRC,S;SAEAC,iB;AAET;AACA;AACA;;AACA,OAAO,eAAeC,YAAf,GAAyF;EAAA;;EAAA,IAA7D;IAAEC;EAAF,CAA6D,uEAArB,EAAqB;EAC9F,MAAMC,GAAG,WAAGD,SAAH,aAAGA,SAAH,cAAGA,SAAH,GAAgB,KAAKA,SAArB,gEAAmC,oBAAM,KAAKE,GAAX,8CAAM,UAAUC,SAAV,EAAN,CAAnC,0DAAkC,sBAA+BH,SAA1E;EACA,IAAIC,GAAG,IAAI,IAAX,EAAiB,OAAOA,GAAP;EACjB,MAAM,IAAIH,iBAAJ,CAAsB,2BAAtB,CAAN;AACD;AAED,MAAMM,mBAAmB,GAAG,CAC1B,SAD0B,EACf,UADe,EACH,KADG,EACI,QADJ,EACc,SADd,EACyB,eADzB,EAE1B,iBAF0B,EAEP,iBAFO,EAEY,gBAFZ,EAE8B,sBAF9B,EAG1B,sBAH0B,EAGF,UAHE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,EAFT,EAGlBC,uBAAuB,CAAEuC,IAAD,IAAuB,IAAGA,IAAI,CAACC,MAAO,EAAvC,CAHL,CAFX;MAOT,GAAGJ;IAPM,CAAX;IASA,KAAKF,GAAL,GAAWA,GAAX;;IACA,IAAI,CAACC,aAAL,EAAoB;MAClB,MAAMM,cAAc,GAAG,KAAK/B,SAAL,GAAiBgC,IAAjB,CAAsB;QAAA,IAAC;UAAEC;QAAF,CAAD;QAAA,OAAqBA,WAArB;MAAA,CAAtB,CAAvB;MACA,KAAKC,QAAL,CAAcC,SAAd,CACE5C,qBAAqB,CAAC,MAAD,EAAS,YAAT,EAAuBwC,cAAvB,EAAuC,OAAvC,EAAgD,OAAhD,CADvB;IAGD;;IACD,KAAKK,WAAL,GAAmB,IAAnB;EACD;;EAEgB,MAAXC,WAAW,GAAsB;IACrC,MAAM;MACJJ,WAAW,EAAEK,OADT;MAEJzC,SAAS,EAAE0C,aAFP;MAGJC,SAHI;MAIJC;IAJI,IAKF,MAAM,KAAKzC,SAAL,EALV;IAMA,MAAM0C,wBAAwB,GAAGF,SAAS,CACvCG,MAD8B,CACvB;MAAA,IAAC;QAAEC;MAAF,CAAD;MAAA,OAA2BH,cAAc,IAAIG,iBAA7C;IAAA,CADuB,EAE9BC,MAF8B,CAG7B,CAACC,GAAD,EAAMC,CAAN,KAAaA,CAAC,CAACH,iBAAF,GAAsBE,GAAG,CAACF,iBAA1B,GAA8CG,CAA9C,GAAkDD,GAHlC,EAI7B;MAAEF,iBAAiB,EAAE,CAAC,CAAtB;MAAyBN,OAAO,EAAE;IAAlC,CAJ6B,EAM9BA,OANH;IAOA,OAAO;MACLd,GAAG,EAAE,KAAKA,GADL;MAELe,aAFK;MAGLD,OAHK;MAILI;IAJK,CAAP;EAMD;;AApDkF"}
1
+ {"version":3,"file":"Node.mjs","names":["BigNumber","genRequestQueuesPolicy","genCombineGetRequestsPolicy","genErrorFormatterPolicy","genVersionCheckPolicy","Node","NodeApi","mapObject","bigIntPropertyNames","numberPropertyNames","NodeTransformed","sendOperationRequest","operationArguments","operationSpec","args","key","value","data","transform","Array","isArray","map","d","some","k","bigInt","number","toFixed","toString","BigInt","constructor","url","ignoreVersion","options","allowInsecureConnection","additionalPolicies","body","reason","statusPromise","getStatus","versionPromise","then","nodeVersion","networkId","pipeline","addPolicy","intAsString","getNetworkId","getNodeInfo","version","nodeNetworkId","protocols","topBlockHeight","consensusProtocolVersion","filter","effectiveAtHeight","reduce","acc","p","$host"],"sources":["../src/Node.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { OperationArguments, OperationSpec } from '@azure/core-client';\nimport {\n genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,\n genVersionCheckPolicy,\n} from './utils/autorest';\nimport { Node as NodeApi, NodeOptionalParams, ErrorModel } from './apis/node';\nimport { mapObject } from './utils/other';\nimport { Encoded } from './utils/encoder';\nimport { ConsensusProtocolVersion } from './tx/builder/constants';\n\nconst bigIntPropertyNames = [\n 'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',\n 'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal',\n 'responderAmountFinal', 'gasPrice', 'deposit',\n] as const;\n\nconst numberPropertyNames = [\n 'time', 'gas', 'gasUsed', 'nameSalt',\n 'nonce', 'nextNonce', 'height', 'blockHeight', 'topBlockHeight',\n 'ttl', 'nameTtl', 'clientTtl',\n 'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',\n 'version', 'solutions', 'round',\n] as const;\n\nclass NodeTransformed extends NodeApi {\n override async sendOperationRequest(\n operationArguments: OperationArguments,\n operationSpec: OperationSpec,\n ): Promise<any> {\n const args = mapObject(\n operationArguments,\n ([key, value]) => [key, this.#encodeArg(value)],\n ) as OperationArguments;\n return this.#decodeRes(await super.sendOperationRequest(args, operationSpec));\n }\n\n #mapData(data: any, transform: {\n bigInt: (v: any) => any;\n number: (v: any) => any;\n }): unknown {\n if (Array.isArray(data)) return data.map((d) => this.#mapData(d, transform));\n if (data != null && typeof data === 'object') {\n return mapObject(data, ([key, value]) => {\n if (value == null) return [key, value];\n if (bigIntPropertyNames.some((k) => k === key)) return [key, transform.bigInt(value)];\n if (numberPropertyNames.some((k) => k === key)) return [key, transform.number(value)];\n return [key, this.#mapData(value, transform)];\n });\n }\n return data;\n }\n\n #encodeArg(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => {\n if (value instanceof BigNumber) return value.toFixed();\n return value.toString();\n },\n number: (value) => value.toString(),\n });\n }\n\n #decodeRes(data: any): any {\n return this.#mapData(data, {\n bigInt: (value) => BigInt(value),\n number: (value) => +value,\n });\n }\n}\n\ntype BigIntPropertyNames = typeof bigIntPropertyNames[number];\ntype NumberPropertyNames = typeof numberPropertyNames[number];\ntype PreserveOptional<NewType, OrigType> =\n OrigType extends undefined ? NewType | undefined : NewType;\nexport type TransformNodeType<Type> =\n Type extends (...args: infer Args) => infer Ret\n ? (...args: TransformNodeType<Args>) => TransformNodeType<Ret>\n : Type extends [infer Item, ...infer Rest]\n ? [TransformNodeType<Item>, ...TransformNodeType<Rest>]\n : Type extends Array<infer Item>\n ? Array<TransformNodeType<Item>>\n : Type extends Promise<infer T>\n ? Promise<TransformNodeType<T>>\n : Type extends { [P in any]: any }\n ? {\n [Property in keyof Type]:\n Property extends BigIntPropertyNames\n ? PreserveOptional<bigint, Type[Property]>\n : Property extends NumberPropertyNames\n ? PreserveOptional<number, Type[Property]>\n : Property extends 'txHash'\n ? PreserveOptional<Encoded.TxHash, Type[Property]>\n : Property extends 'bytecode'\n ? PreserveOptional<Encoded.ContractBytearray, Type[Property]>\n : TransformNodeType<Type[Property]>\n }\n : Type;\ntype NodeTransformedApi = new (...args: ConstructorParameters<typeof NodeApi>) => {\n [Name in keyof InstanceType<typeof NodeApi>]:\n Name extends 'pipeline' | 'sendRequest' | 'sendOperationRequest'\n ? NodeApi[Name] : TransformNodeType<NodeApi[Name]>\n};\n\nexport interface NodeInfo {\n url: string;\n nodeNetworkId: string;\n version: string;\n consensusProtocolVersion: ConsensusProtocolVersion;\n}\n\nexport default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {\n #networkIdPromise?: Promise<string>;\n\n /**\n * @param url - Url for node API\n * @param options - Options\n * @param options.ignoreVersion - Don't check node version\n */\n constructor(\n url: string,\n { ignoreVersion = false, ...options }: NodeOptionalParams & { ignoreVersion?: boolean } = {},\n ) {\n // eslint-disable-next-line constructor-super\n super(url, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genRequestQueuesPolicy(),\n genCombineGetRequestsPolicy(),\n genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),\n ],\n ...options,\n });\n if (!ignoreVersion) {\n const statusPromise = this.getStatus();\n const versionPromise = statusPromise.then(({ nodeVersion }) => nodeVersion);\n this.#networkIdPromise = statusPromise.then(({ networkId }) => networkId);\n this.pipeline.addPolicy(\n genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'),\n );\n }\n this.intAsString = true;\n }\n\n async getNetworkId(): Promise<string> {\n this.#networkIdPromise ??= this.getStatus().then(({ networkId }) => networkId);\n return this.#networkIdPromise;\n }\n\n async getNodeInfo(): Promise<NodeInfo> {\n const {\n nodeVersion: version,\n networkId: nodeNetworkId,\n protocols,\n topBlockHeight,\n } = await this.getStatus();\n const consensusProtocolVersion = protocols\n .filter(({ effectiveAtHeight }) => topBlockHeight >= effectiveAtHeight)\n .reduce(\n (acc, p) => (p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc),\n { effectiveAtHeight: -1, version: 0 },\n )\n .version;\n return {\n url: this.$host,\n nodeNetworkId,\n version,\n consensusProtocolVersion,\n };\n }\n}\n"],"mappings":";;;;;;AAAA;AACA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAGnCC,sBAAsB,EAAEC,2BAA2B,EAAEC,uBAAuB,EAC5EC,qBAAqB;AAAA,SAEdC,IAAI,IAAIC,OAAO;AAAA,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AC;MAAA,OAAKH,cAAc,IAAIG,iBAAiB;IAAA,EAAC,CACtEC,MAAM,CACL,CAACC,GAAG,EAAEC,CAAC,KAAMA,CAAC,CAACH,iBAAiB,GAAGE,GAAG,CAACF,iBAAiB,GAAGG,CAAC,GAAGD,GAAI,EACnE;MAAEF,iBAAiB,EAAE,CAAC,CAAC;MAAEN,OAAO,EAAE;IAAE,CAAC,CACtC,CACAA,OAAO;IACV,OAAO;MACLlB,GAAG,EAAE,IAAI,CAAC4B,KAAK;MACfT,aAAa;MACbD,OAAO;MACPI;IACF,CAAC;EACH;AACF"}
@@ -1,58 +1,43 @@
1
1
  import { Encoded } from '../utils/encoder';
2
- import { getNetworkId } from '../Node';
3
- import type { createMetaTx } from '../contract/ga';
4
- /**
5
- * Check is provided object looks like an instance of AccountBase
6
- * @param acc - Object to check
7
- */
8
- export declare const isAccountBase: (acc: AccountBase | any) => boolean;
2
+ import Node from '../Node';
3
+ import CompilerBase from '../contract/compiler/Base';
9
4
  /**
10
5
  * Account is one of the three basic building blocks of an
11
6
  * {@link AeSdk} and provides access to a signing key pair.
12
7
  */
13
8
  export default abstract class AccountBase {
14
- networkId?: string;
15
- /**
16
- * @param options - Options
17
- * @param options.networkId - Using for signing transactions
18
- */
19
- constructor({ networkId }?: {
20
- networkId?: string;
21
- });
22
9
  /**
23
10
  * Sign encoded transaction
24
11
  * @param tx - Transaction to sign
25
- * @param opt - Options
26
- * @param opt.innerTx - Sign as inner transaction for PayingFor
12
+ * @param options - Options
13
+ * @param options.innerTx - Sign as inner transaction for PayingFor
14
+ * @param options.authData - Object with gaMeta params
27
15
  * @returns Signed transaction
28
16
  */
29
- signTransaction(tx: Encoded.Transaction, { innerTx, networkId, ...options }?: {
17
+ abstract signTransaction(tx: Encoded.Transaction, options: {
30
18
  innerTx?: boolean;
31
19
  networkId?: string;
32
- authData?: Parameters<typeof createMetaTx>[1];
33
- authFun?: Parameters<typeof createMetaTx>[2];
34
- } & Omit<Partial<Parameters<typeof createMetaTx>[3]>, 'onAccount'>): Promise<Encoded.Transaction>;
35
- /**
36
- * Get network Id
37
- * @returns Network Id
38
- */
39
- readonly getNetworkId: typeof getNetworkId;
20
+ authData?: {
21
+ gasLimit?: number;
22
+ callData?: Encoded.ContractBytearray;
23
+ sourceCode?: string;
24
+ args?: any[];
25
+ };
26
+ onNode?: Node;
27
+ onCompiler?: CompilerBase;
28
+ aeppOrigin?: string;
29
+ aeppRpcClientId?: string;
30
+ }): Promise<Encoded.Transaction>;
40
31
  /**
41
32
  * Sign message
42
33
  * @param message - Message to sign
43
- * @param opt - Options
44
- * @returns Signature as hex string of Uint8Array
45
- */
46
- signMessage(message: string, { returnHex, ...options }?: {
47
- returnHex?: boolean;
48
- }): Promise<string | Uint8Array>;
49
- /**
50
- * Verify message
51
- * @param message - Message to verify
52
- * @param signature - Signature
53
34
  * @param options - Options
35
+ * @returns Signature as hex string of Uint8Array
54
36
  */
55
- verifyMessage(message: string, signature: string | Uint8Array, options?: object): Promise<boolean>;
37
+ abstract signMessage(message: string, options?: {
38
+ aeppOrigin?: string;
39
+ aeppRpcClientId?: string;
40
+ }): Promise<Uint8Array>;
56
41
  /**
57
42
  * Sign data blob
58
43
  * @param data - Data blob to sign
@@ -61,8 +46,7 @@ export default abstract class AccountBase {
61
46
  */
62
47
  abstract sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
63
48
  /**
64
- * Obtain account address
65
- * @returns Public account address
49
+ * Account address
66
50
  */
67
- abstract address(opt?: object): Promise<Encoded.AccountAddress>;
51
+ readonly address: Encoded.AccountAddress;
68
52
  }
@@ -1,9 +1,3 @@
1
- import _buffer from "buffer";
2
- const {
3
- Buffer: _Buffer
4
- } = _buffer;
5
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
6
-
7
1
  /*
8
2
  * ISC License (ISC)
9
3
  * Copyright (c) 2022 aeternity developers
@@ -20,104 +14,10 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
20
14
  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
15
  * PERFORMANCE OF THIS SOFTWARE.
22
16
  */
23
- import { messageToHash, verifyMessage as verifyMessageCrypto, hash } from "../utils/crypto.mjs";
24
- import { buildTx } from "../tx/builder/index.mjs";
25
- import { decode } from "../utils/encoder.mjs";
26
- import { Tag } from "../tx/builder/constants.mjs";
27
- import { getNetworkId } from "../Node.mjs";
28
- import { concatBuffers } from "../utils/other.mjs";
29
17
 
30
- /**
31
- * Check is provided object looks like an instance of AccountBase
32
- * @param acc - Object to check
33
- */
34
- export const isAccountBase = acc => !['sign', 'address', 'signTransaction', 'signMessage'].some(f => typeof acc[f] !== 'function');
35
18
  /**
36
19
  * Account is one of the three basic building blocks of an
37
20
  * {@link AeSdk} and provides access to a signing key pair.
38
21
  */
39
-
40
- export default class AccountBase {
41
- /**
42
- * @param options - Options
43
- * @param options.networkId - Using for signing transactions
44
- */
45
- constructor() {
46
- var _this$networkId;
47
-
48
- let {
49
- networkId
50
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
51
-
52
- _defineProperty(this, "getNetworkId", getNetworkId);
53
-
54
- (_this$networkId = this.networkId) !== null && _this$networkId !== void 0 ? _this$networkId : this.networkId = networkId;
55
- }
56
- /**
57
- * Sign encoded transaction
58
- * @param tx - Transaction to sign
59
- * @param opt - Options
60
- * @param opt.innerTx - Sign as inner transaction for PayingFor
61
- * @returns Signed transaction
62
- */
63
-
64
-
65
- async signTransaction(tx) {
66
- let {
67
- innerTx,
68
- networkId,
69
- ...options
70
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
71
- const prefixes = [await this.getNetworkId({
72
- networkId
73
- })];
74
- if (innerTx === true) prefixes.push('inner_tx');
75
- const rlpBinaryTx = decode(tx);
76
- const txWithNetworkId = concatBuffers([_Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
77
- const signatures = [await this.sign(txWithNetworkId, options)];
78
- return buildTx({
79
- encodedTx: rlpBinaryTx,
80
- signatures
81
- }, Tag.SignedTx).tx;
82
- }
83
- /**
84
- * Get network Id
85
- * @returns Network Id
86
- */
87
-
88
-
89
- /**
90
- * Sign message
91
- * @param message - Message to sign
92
- * @param opt - Options
93
- * @returns Signature as hex string of Uint8Array
94
- */
95
- async signMessage(message) {
96
- let {
97
- returnHex = false,
98
- ...options
99
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
100
- const sig = await this.sign(messageToHash(message), options);
101
- return returnHex ? _Buffer.from(sig).toString('hex') : sig;
102
- }
103
- /**
104
- * Verify message
105
- * @param message - Message to verify
106
- * @param signature - Signature
107
- * @param options - Options
108
- */
109
-
110
-
111
- async verifyMessage(message, signature, options) {
112
- return verifyMessageCrypto(message, typeof signature === 'string' ? _Buffer.from(signature, 'hex') : signature, decode(await this.address(options)));
113
- }
114
- /**
115
- * Sign data blob
116
- * @param data - Data blob to sign
117
- * @param options - Options
118
- * @returns Signed data blob
119
- */
120
-
121
-
122
- }
22
+ export default class AccountBase {}
123
23
  //# sourceMappingURL=Base.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Base.mjs","names":["messageToHash","verifyMessage","verifyMessageCrypto","hash","buildTx","decode","Tag","getNetworkId","concatBuffers","isAccountBase","acc","some","f","AccountBase","constructor","networkId","signTransaction","tx","innerTx","options","prefixes","push","rlpBinaryTx","txWithNetworkId","from","join","signatures","sign","encodedTx","SignedTx","signMessage","message","returnHex","sig","toString","signature","address"],"sources":["../../src/account/Base.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport { messageToHash, verifyMessage as verifyMessageCrypto, hash } from '../utils/crypto';\nimport { buildTx } from '../tx/builder';\nimport { decode, Encoded } from '../utils/encoder';\nimport { Tag } from '../tx/builder/constants';\nimport { getNetworkId } from '../Node';\nimport { concatBuffers } from '../utils/other';\nimport type { createMetaTx } from '../contract/ga';\n\n/**\n * Check is provided object looks like an instance of AccountBase\n * @param acc - Object to check\n */\nexport const isAccountBase = (acc: AccountBase | any): boolean => (\n !['sign', 'address', 'signTransaction', 'signMessage'].some((f) => typeof acc[f] !== 'function')\n);\n\n/**\n * Account is one of the three basic building blocks of an\n * {@link AeSdk} and provides access to a signing key pair.\n */\nexport default abstract class AccountBase {\n networkId?: string;\n\n /**\n * @param options - Options\n * @param options.networkId - Using for signing transactions\n */\n constructor({ networkId }: { networkId?: string } = {}) {\n this.networkId ??= networkId;\n }\n\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param opt - Options\n * @param opt.innerTx - Sign as inner transaction for PayingFor\n * @returns Signed transaction\n */\n async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId, ...options }: {\n innerTx?: boolean;\n networkId?: string;\n authData?: Parameters<typeof createMetaTx>[1];\n authFun?: Parameters<typeof createMetaTx>[2];\n } & Omit<Partial<Parameters<typeof createMetaTx>[3]>, 'onAccount'> = {},\n ): Promise<Encoded.Transaction> {\n const prefixes = [await this.getNetworkId({ networkId })];\n if (innerTx === true) prefixes.push('inner_tx');\n const rlpBinaryTx = decode(tx);\n const txWithNetworkId = concatBuffers([Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);\n\n const signatures = [await this.sign(txWithNetworkId, options)];\n return buildTx({ encodedTx: rlpBinaryTx, signatures }, Tag.SignedTx).tx;\n }\n\n /**\n * Get network Id\n * @returns Network Id\n */\n readonly getNetworkId = getNetworkId;\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param opt - Options\n * @returns Signature as hex string of Uint8Array\n */\n async signMessage(\n message: string,\n { returnHex = false, ...options }: { returnHex?: boolean } = {},\n ): Promise<string | Uint8Array> {\n const sig = await this.sign(messageToHash(message), options);\n return returnHex ? Buffer.from(sig).toString('hex') : sig;\n }\n\n /**\n * Verify message\n * @param message - Message to verify\n * @param signature - Signature\n * @param options - Options\n */\n async verifyMessage(\n message: string,\n signature: string | Uint8Array,\n options?: object,\n ): Promise<boolean> {\n return verifyMessageCrypto(\n message,\n typeof signature === 'string' ? Buffer.from(signature, 'hex') : signature,\n decode(await this.address(options)),\n );\n }\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signed data blob\n */\n abstract sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;\n\n /**\n * Obtain account address\n * @returns Public account address\n */\n abstract address(opt?: object): Promise<Encoded.AccountAddress>;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;SACSA,a,EAAeC,aAAa,IAAIC,mB,EAAqBC,I;SACrDC,O;SACAC,M;SACAC,G;SACAC,Y;SACAC,a;;AAGT;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAIC,GAAD,IAC3B,CAAC,CAAC,MAAD,EAAS,SAAT,EAAoB,iBAApB,EAAuC,aAAvC,EAAsDC,IAAtD,CAA4DC,CAAD,IAAO,OAAOF,GAAG,CAACE,CAAD,CAAV,KAAkB,UAApF,CADI;AAIP;AACA;AACA;AACA;;AACA,eAAe,MAAeC,WAAf,CAA2B;EAGxC;AACF;AACA;AACA;EACEC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,GAAZ,EAAiBC,QAAjB,CAA0B,KAA1B,CAAH,GAAsCD,GAAtD;EACD;EAED;AACF;AACA;AACA;AACA;AACA;;;EACqB,MAAbhC,aAAa,CACjB8B,OADiB,EAEjBI,SAFiB,EAGjBhB,OAHiB,EAIC;IAClB,OAAOjB,mBAAmB,CACxB6B,OADwB,EAExB,OAAOI,SAAP,KAAqB,QAArB,GAAgC,QAAOX,IAAP,CAAYW,SAAZ,EAAuB,KAAvB,CAAhC,GAAgEA,SAFxC,EAGxB9B,MAAM,CAAC,MAAM,KAAK+B,OAAL,CAAajB,OAAb,CAAP,CAHkB,CAA1B;EAKD;EAED;AACF;AACA;AACA;AACA;AACA;;;AA/E0C"}
1
+ {"version":3,"file":"Base.mjs","names":["AccountBase"],"sources":["../../src/account/Base.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport { Encoded } from '../utils/encoder';\nimport Node from '../Node';\nimport CompilerBase from '../contract/compiler/Base';\n\n/**\n * Account is one of the three basic building blocks of an\n * {@link AeSdk} and provides access to a signing key pair.\n */\nexport default abstract class AccountBase {\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param options - Options\n * @param options.innerTx - Sign as inner transaction for PayingFor\n * @param options.authData - Object with gaMeta params\n * @returns Signed transaction\n */\n abstract signTransaction(\n tx: Encoded.Transaction,\n options: {\n innerTx?: boolean;\n networkId?: string;\n authData?: {\n gasLimit?: number;\n callData?: Encoded.ContractBytearray;\n sourceCode?: string;\n args?: any[];\n };\n onNode?: Node;\n onCompiler?: CompilerBase;\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Encoded.Transaction>;\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param options - Options\n * @returns Signature as hex string of Uint8Array\n */\n abstract signMessage(\n message: string,\n options?: {\n aeppOrigin?: string;\n aeppRpcClientId?: string;\n },\n ): Promise<Uint8Array>;\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signed data blob\n */\n abstract sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;\n\n /**\n * Account address\n */\n readonly address: Encoded.AccountAddress;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA,eAAe,MAAeA,WAAW,CAAC"}
@@ -0,0 +1,16 @@
1
+ import AccountBase from './Base';
2
+ import { Encoded } from '../utils/encoder';
3
+ /**
4
+ * Generalized account class
5
+ */
6
+ export default class AccountGeneralized extends AccountBase {
7
+ #private;
8
+ readonly address: Encoded.AccountAddress;
9
+ /**
10
+ * @param address - Address of generalized account
11
+ */
12
+ constructor(address: Encoded.AccountAddress);
13
+ sign(): Promise<Uint8Array>;
14
+ signMessage(): Promise<Uint8Array>;
15
+ signTransaction(tx: Encoded.Transaction, { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1]): Promise<Encoded.Transaction>;
16
+ }
@@ -0,0 +1,113 @@
1
+ import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
2
+ import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
3
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
4
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
5
+ /*
6
+ * ISC License (ISC)
7
+ * Copyright (c) 2022 aeternity developers
8
+ *
9
+ * Permission to use, copy, modify, and/or distribute this software for any
10
+ * purpose with or without fee is hereby granted, provided that the above
11
+ * copyright notice and this permission notice appear in all copies.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ * PERFORMANCE OF THIS SOFTWARE.
20
+ */
21
+ import AccountBase from "./Base.mjs";
22
+ import { ArgumentError, InternalError, InvalidAuthDataError, NotImplementedError } from "../utils/errors.mjs";
23
+ import { decode } from "../utils/encoder.mjs";
24
+ import { getAccount } from "../chain.mjs";
25
+ import Contract from "../contract/Contract.mjs";
26
+ import { _buildTx } from "../tx/index.mjs";
27
+ import { Tag } from "../tx/builder/constants.mjs";
28
+ import { buildTx } from "../tx/builder/index.mjs";
29
+ /**
30
+ * Generalized account class
31
+ */
32
+ var _authFun = /*#__PURE__*/new WeakMap();
33
+ export default class AccountGeneralized extends AccountBase {
34
+ /**
35
+ * @param address - Address of generalized account
36
+ */
37
+ constructor(address) {
38
+ super();
39
+ _classPrivateFieldInitSpec(this, _authFun, {
40
+ writable: true,
41
+ value: void 0
42
+ });
43
+ decode(address);
44
+ this.address = address;
45
+ }
46
+
47
+ // eslint-disable-next-line class-methods-use-this
48
+ async sign() {
49
+ throw new NotImplementedError('Can\'t sign using generalized account');
50
+ }
51
+
52
+ // eslint-disable-next-line class-methods-use-this
53
+ async signMessage() {
54
+ throw new NotImplementedError('Can\'t sign using generalized account');
55
+ }
56
+ async signTransaction(tx, _ref) {
57
+ let {
58
+ authData,
59
+ onCompiler,
60
+ onNode
61
+ } = _ref;
62
+ if (authData == null || onCompiler == null || onNode == null) {
63
+ throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);
64
+ }
65
+ const {
66
+ callData,
67
+ sourceCode,
68
+ args,
69
+ gasLimit
70
+ } = authData;
71
+ const authCallData = callData !== null && callData !== void 0 ? callData : await (async () => {
72
+ if (_classPrivateFieldGet(this, _authFun) == null) {
73
+ const account = await getAccount(this.address, {
74
+ onNode
75
+ });
76
+ if (account.kind !== 'generalized') {
77
+ throw new ArgumentError('account kind', 'generalized', account.kind);
78
+ }
79
+ _classPrivateFieldSet(this, _authFun, account.authFun);
80
+ }
81
+ if (_classPrivateFieldGet(this, _authFun) == null) {
82
+ throw new InternalError('Account in generalised, but authFun not provided');
83
+ }
84
+ if (sourceCode == null || args == null) {
85
+ throw new InvalidAuthDataError('Auth data must contain source code and arguments.');
86
+ }
87
+ const contract = await Contract.initialize({
88
+ onCompiler,
89
+ onNode,
90
+ sourceCode
91
+ });
92
+ return contract._calldata.encode(contract._name, _classPrivateFieldGet(this, _authFun), args);
93
+ })();
94
+ const gaMetaTx = await _buildTx(Tag.GaMetaTx, {
95
+ tx: decode(buildTx({
96
+ tag: Tag.SignedTx,
97
+ encodedTx: decode(tx),
98
+ signatures: []
99
+ })),
100
+ gaId: this.address,
101
+ authData: authCallData,
102
+ gasLimit,
103
+ nonce: 0,
104
+ onNode
105
+ });
106
+ return buildTx({
107
+ tag: Tag.SignedTx,
108
+ encodedTx: decode(gaMetaTx),
109
+ signatures: []
110
+ });
111
+ }
112
+ }
113
+ //# sourceMappingURL=Generalized.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Generalized.mjs","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","_buildTx","Tag","buildTx","AccountGeneralized","constructor","address","sign","signMessage","signTransaction","tx","authData","onCompiler","onNode","callData","sourceCode","args","gasLimit","authCallData","account","kind","authFun","contract","initialize","_calldata","encode","_name","gaMetaTx","GaMetaTx","tag","SignedTx","encodedTx","signatures","gaId","nonce"],"sources":["../../src/account/Generalized.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport AccountBase from './Base';\nimport {\n ArgumentError,\n InternalError,\n InvalidAuthDataError,\n NotImplementedError,\n} from '../utils/errors';\nimport { decode, Encoded } from '../utils/encoder';\nimport { getAccount } from '../chain';\nimport Contract from '../contract/Contract';\nimport { _buildTx } from '../tx';\nimport { Tag } from '../tx/builder/constants';\nimport { buildTx } from '../tx/builder';\n\n/**\n * Generalized account class\n */\nexport default class AccountGeneralized extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n #authFun?: string;\n\n /**\n * @param address - Address of generalized account\n */\n constructor(address: Encoded.AccountAddress) {\n super();\n decode(address);\n this.address = address;\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('Can\\'t sign using generalized account');\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async signMessage(): Promise<Uint8Array> {\n throw new NotImplementedError('Can\\'t sign using generalized account');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1],\n ): Promise<Encoded.Transaction> {\n if (authData == null || onCompiler == null || onNode == null) {\n throw new ArgumentError('authData, onCompiler, onNode', 'provided', null);\n }\n const {\n callData, sourceCode, args, gasLimit,\n } = authData;\n\n const authCallData = callData ?? await (async () => {\n if (this.#authFun == null) {\n const account = await getAccount(this.address, { onNode });\n if (account.kind !== 'generalized') {\n throw new ArgumentError('account kind', 'generalized', account.kind);\n }\n this.#authFun = account.authFun;\n }\n if (this.#authFun == null) {\n throw new InternalError('Account in generalised, but authFun not provided');\n }\n\n if (sourceCode == null || args == null) {\n throw new InvalidAuthDataError('Auth data must contain source code and arguments.');\n }\n const contract = await Contract.initialize({ onCompiler, onNode, sourceCode });\n return contract._calldata.encode(contract._name, this.#authFun, args);\n })();\n\n const gaMetaTx = await _buildTx(Tag.GaMetaTx, {\n tx: decode(buildTx({ tag: Tag.SignedTx, encodedTx: decode(tx), signatures: [] })),\n gaId: this.address,\n authData: authCallData,\n gasLimit,\n nonce: 0,\n onNode,\n });\n return buildTx({ tag: Tag.SignedTx, encodedTx: decode(gaMetaTx), signatures: [] });\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAfA,OAgBOA,WAAW;AAAA,SAEhBC,aAAa,EACbC,aAAa,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B,OAAO,CAACC,IAAI,CAAC;QACtE;QACA,0BAAI,YAAYD,OAAO,CAACE,OAAO;MACjC;MACA,IAAI,0BAAI,eAAa,IAAI,EAAE;QACzB,MAAM,IAAI1B,aAAa,CAAC,kDAAkD,CAAC;MAC7E;MAEA,IAAIoB,UAAU,IAAI,IAAI,IAAIC,IAAI,IAAI,IAAI,EAAE;QACtC,MAAM,IAAIpB,oBAAoB,CAAC,mDAAmD,CAAC;MACrF;MACA,MAAM0B,QAAQ,GAAG,MAAMtB,QAAQ,CAACuB,UAAU,CAAC;QAAEX,UAAU;QAAEC,MAAM;QAAEE;MAAW,CAAC,CAAC;MAC9E,OAAOO,QAAQ,CAACE,SAAS,CAACC,MAAM,CAACH,QAAQ,CAACI,KAAK,wBAAE,IAAI,aAAWV,IAAI,CAAC;IACvE,CAAC,GAAG;IAEJ,MAAMW,QAAQ,GAAG,MAAM1B,QAAQ,CAACC,GAAG,CAAC0B,QAAQ,EAAE;MAC5ClB,EAAE,EAAEZ,MAAM,CAACK,OAAO,CAAC;QAAE0B,GAAG,EAAE3B,GAAG,CAAC4B,QAAQ;QAAEC,SAAS,EAAEjC,MAAM,CAACY,EAAE,CAAC;QAAEsB,UAAU,EAAE;MAAG,CAAC,CAAC,CAAC;MACjFC,IAAI,EAAE,IAAI,CAAC3B,OAAO;MAClBK,QAAQ,EAAEO,YAAY;MACtBD,QAAQ;MACRiB,KAAK,EAAE,CAAC;MACRrB;IACF,CAAC,CAAC;IACF,OAAOV,OAAO,CAAC;MAAE0B,GAAG,EAAE3B,GAAG,CAAC4B,QAAQ;MAAEC,SAAS,EAAEjC,MAAM,CAAC6B,QAAQ,CAAC;MAAEK,UAAU,EAAE;IAAG,CAAC,CAAC;EACpF;AACF"}
@@ -0,0 +1,28 @@
1
+ import type Transport from '@ledgerhq/hw-transport';
2
+ import AccountBase from './Base';
3
+ import { Encoded } from '../utils/encoder';
4
+ export declare const CLA = 224;
5
+ export declare const GET_ADDRESS = 2;
6
+ export declare const SIGN_TRANSACTION = 4;
7
+ export declare const GET_APP_CONFIGURATION = 6;
8
+ export declare const SIGN_PERSONAL_MESSAGE = 8;
9
+ /**
10
+ * Ledger wallet account class
11
+ */
12
+ export default class AccountLedger extends AccountBase {
13
+ readonly transport: Transport;
14
+ readonly address: Encoded.AccountAddress;
15
+ readonly index: number;
16
+ /**
17
+ * @param transport - Connection to Ledger to use
18
+ * @param index - Index of account
19
+ * @param address - Address of account
20
+ */
21
+ constructor(transport: Transport, index: number, address: Encoded.AccountAddress);
22
+ sign(): Promise<Uint8Array>;
23
+ signTransaction(tx: Encoded.Transaction, { innerTx, networkId }?: {
24
+ innerTx?: boolean;
25
+ networkId?: string;
26
+ }): Promise<Encoded.Transaction>;
27
+ signMessage(messageStr: string): Promise<Uint8Array>;
28
+ }