@aeternity/aepp-sdk 12.1.3 → 13.0.0-alpha.0

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 (475) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.map +1 -1
  3. package/dist/aepp-sdk.browser.js +1 -1
  4. package/dist/aepp-sdk.browser.js.map +1 -1
  5. package/dist/aepp-sdk.js +6580 -8859
  6. package/dist/aepp-sdk.js.map +1 -1
  7. package/es/AeSdk.d.ts +7 -3
  8. package/es/AeSdk.mjs +17 -22
  9. package/es/AeSdk.mjs.map +1 -1
  10. package/es/AeSdkAepp.d.ts +6 -5
  11. package/es/AeSdkAepp.mjs +7 -30
  12. package/es/AeSdkAepp.mjs.map +1 -1
  13. package/es/AeSdkBase.d.ts +18 -140
  14. package/es/AeSdkBase.mjs +27 -185
  15. package/es/AeSdkBase.mjs.map +1 -1
  16. package/es/AeSdkMethods.d.ts +124 -0
  17. package/es/AeSdkMethods.mjs +122 -0
  18. package/es/AeSdkMethods.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +7 -21
  20. package/es/AeSdkWallet.mjs +38 -86
  21. package/es/AeSdkWallet.mjs.map +1 -1
  22. package/es/Node.d.ts +7 -12
  23. package/es/Node.mjs +34 -47
  24. package/es/Node.mjs.map +1 -1
  25. package/es/account/Base.d.ts +24 -40
  26. package/es/account/Base.mjs +1 -101
  27. package/es/account/Base.mjs.map +1 -1
  28. package/es/account/Generalized.d.ts +16 -0
  29. package/es/account/Generalized.mjs +111 -0
  30. package/es/account/Generalized.mjs.map +1 -0
  31. package/es/account/Ledger.d.ts +28 -0
  32. package/es/account/Ledger.mjs +101 -0
  33. package/es/account/Ledger.mjs.map +1 -0
  34. package/es/account/LedgerFactory.d.ts +39 -0
  35. package/es/account/LedgerFactory.mjs +81 -0
  36. package/es/account/LedgerFactory.mjs.map +1 -0
  37. package/es/account/Memory.d.ts +13 -17
  38. package/es/account/Memory.mjs +43 -65
  39. package/es/account/Memory.mjs.map +1 -1
  40. package/es/account/Rpc.d.ts +6 -8
  41. package/es/account/Rpc.mjs +14 -32
  42. package/es/account/Rpc.mjs.map +1 -1
  43. package/es/aens.d.ts +3 -3
  44. package/es/aens.mjs +42 -41
  45. package/es/aens.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
  47. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  48. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +3 -7
  49. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
  51. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
  52. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  53. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  54. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
  55. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -41
  56. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  57. package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
  58. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/schema.mjs +14 -68
  60. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  62. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  63. package/es/apis/compiler/compiler.d.ts +23 -29
  64. package/es/apis/compiler/compiler.mjs +128 -189
  65. package/es/apis/compiler/compiler.mjs.map +1 -1
  66. package/es/apis/compiler/index.mjs.map +1 -1
  67. package/es/apis/compiler/models/index.d.ts +82 -135
  68. package/es/apis/compiler/models/index.mjs +1 -47
  69. package/es/apis/compiler/models/index.mjs.map +1 -1
  70. package/es/apis/compiler/models/mappers.d.ts +8 -8
  71. package/es/apis/compiler/models/mappers.mjs +165 -183
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  73. package/es/apis/compiler/models/parameters.d.ts +0 -1
  74. package/es/apis/compiler/models/parameters.mjs +5 -9
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  76. package/es/apis/node/index.mjs.map +1 -1
  77. package/es/apis/node/models/index.d.ts +48 -48
  78. package/es/apis/node/models/mappers.mjs +12 -6
  79. package/es/apis/node/models/mappers.mjs.map +1 -1
  80. package/es/apis/node/models/parameters.mjs.map +1 -1
  81. package/es/apis/node/node.mjs +43 -84
  82. package/es/apis/node/node.mjs.map +1 -1
  83. package/es/chain.d.ts +1 -1
  84. package/es/chain.mjs +33 -58
  85. package/es/chain.mjs.map +1 -1
  86. package/es/channel/Base.d.ts +195 -0
  87. package/es/channel/Base.mjs +290 -0
  88. package/es/channel/Base.mjs.map +1 -0
  89. package/es/channel/Contract.d.ts +247 -0
  90. package/es/channel/Contract.mjs +420 -0
  91. package/es/channel/Contract.mjs.map +1 -0
  92. package/es/channel/Spend.d.ts +217 -0
  93. package/es/channel/Spend.mjs +383 -0
  94. package/es/channel/Spend.mjs.map +1 -0
  95. package/es/channel/handlers.d.ts +8 -21
  96. package/es/channel/handlers.mjs +141 -891
  97. package/es/channel/handlers.mjs.map +1 -1
  98. package/es/channel/internal.d.ts +27 -21
  99. package/es/channel/internal.mjs +98 -190
  100. package/es/channel/internal.mjs.map +1 -1
  101. package/es/contract/{Compiler.d.ts → CompilerHttp.d.ts} +3 -3
  102. package/es/contract/{Compiler.mjs → CompilerHttp.mjs} +8 -13
  103. package/es/contract/CompilerHttp.mjs.map +1 -0
  104. package/es/contract/Contract.d.ts +235 -0
  105. package/es/contract/Contract.mjs +534 -0
  106. package/es/contract/Contract.mjs.map +1 -0
  107. package/es/contract/ga.d.ts +7 -33
  108. package/es/contract/ga.mjs +20 -112
  109. package/es/contract/ga.mjs.map +1 -1
  110. package/es/index.d.ts +9 -6
  111. package/es/index.mjs +8 -6
  112. package/es/index.mjs.map +1 -1
  113. package/es/oracle.d.ts +5 -5
  114. package/es/oracle.mjs +33 -39
  115. package/es/oracle.mjs.map +1 -1
  116. package/es/spend.d.ts +3 -3
  117. package/es/spend.mjs +17 -20
  118. package/es/spend.mjs.map +1 -1
  119. package/es/tx/builder/constants.d.ts +2 -1
  120. package/es/tx/builder/constants.mjs +12 -12
  121. package/es/tx/builder/constants.mjs.map +1 -1
  122. package/es/tx/builder/field-types/address.d.ts +15 -0
  123. package/es/tx/builder/field-types/address.mjs +42 -0
  124. package/es/tx/builder/field-types/address.mjs.map +1 -0
  125. package/es/tx/builder/field-types/addresses.d.ts +6 -0
  126. package/es/tx/builder/field-types/addresses.mjs +13 -0
  127. package/es/tx/builder/field-types/addresses.mjs.map +1 -0
  128. package/es/tx/builder/field-types/coin-amount.d.ts +1 -2
  129. package/es/tx/builder/field-types/coin-amount.mjs +4 -12
  130. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  131. package/es/tx/builder/field-types/deposit.d.ts +0 -1
  132. package/es/tx/builder/field-types/deposit.mjs +2 -4
  133. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  134. package/es/tx/builder/field-types/enumeration.d.ts +5 -0
  135. package/es/tx/builder/field-types/enumeration.mjs +21 -0
  136. package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
  137. package/es/tx/builder/field-types/fee.d.ts +1 -9
  138. package/es/tx/builder/field-types/fee.mjs +9 -25
  139. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  140. package/es/tx/builder/field-types/field.mjs +0 -2
  141. package/es/tx/builder/field-types/field.mjs.map +1 -1
  142. package/es/tx/builder/field-types/gas-limit.mjs +4 -9
  143. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  144. package/es/tx/builder/field-types/gas-price.d.ts +1 -2
  145. package/es/tx/builder/field-types/gas-price.mjs +3 -7
  146. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  147. package/es/tx/builder/field-types/index.d.ts +23 -11
  148. package/es/tx/builder/field-types/index.mjs +10 -3
  149. package/es/tx/builder/field-types/index.mjs.map +1 -1
  150. package/es/tx/builder/field-types/name-fee.d.ts +0 -1
  151. package/es/tx/builder/field-types/name-fee.mjs +3 -5
  152. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  153. package/es/tx/builder/field-types/name-id.d.ts +1 -4
  154. package/es/tx/builder/field-types/name-id.mjs +4 -10
  155. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  156. package/es/tx/builder/field-types/name.mjs +0 -2
  157. package/es/tx/builder/field-types/name.mjs.map +1 -1
  158. package/es/tx/builder/field-types/pointers.d.ts +23 -0
  159. package/es/tx/builder/field-types/pointers.mjs +36 -0
  160. package/es/tx/builder/field-types/pointers.mjs.map +1 -0
  161. package/es/tx/builder/field-types/short-u-int.mjs +0 -2
  162. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  163. package/es/tx/builder/field-types/u-int.d.ts +1 -1
  164. package/es/tx/builder/field-types/u-int.mjs +3 -4
  165. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  166. package/es/tx/builder/helpers.d.ts +2 -32
  167. package/es/tx/builder/helpers.mjs +19 -71
  168. package/es/tx/builder/helpers.mjs.map +1 -1
  169. package/es/tx/builder/index.d.ts +1 -21
  170. package/es/tx/builder/index.mjs +29 -148
  171. package/es/tx/builder/index.mjs.map +1 -1
  172. package/es/tx/builder/schema.d.ts +336 -176
  173. package/es/tx/builder/schema.mjs +71 -78
  174. package/es/tx/builder/schema.mjs.map +1 -1
  175. package/es/tx/index.d.ts +3 -33
  176. package/es/tx/index.mjs +26 -43
  177. package/es/tx/index.mjs.map +1 -1
  178. package/es/tx/validator.d.ts +2 -2
  179. package/es/tx/validator.mjs +86 -59
  180. package/es/tx/validator.mjs.map +1 -1
  181. package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
  182. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
  183. package/es/utils/amount-formatter.mjs +4 -10
  184. package/es/utils/amount-formatter.mjs.map +1 -1
  185. package/es/utils/autorest.d.ts +1 -0
  186. package/es/utils/autorest.mjs +17 -19
  187. package/es/utils/autorest.mjs.map +1 -1
  188. package/es/utils/bignumber.mjs +4 -7
  189. package/es/utils/bignumber.mjs.map +1 -1
  190. package/es/utils/bytes.d.ts +0 -17
  191. package/es/utils/bytes.mjs +6 -35
  192. package/es/utils/bytes.mjs.map +1 -1
  193. package/es/utils/crypto.d.ts +15 -8
  194. package/es/utils/crypto.mjs +40 -40
  195. package/es/utils/crypto.mjs.map +1 -1
  196. package/es/utils/encoder-types.d.ts +28 -28
  197. package/es/utils/encoder-types.mjs +0 -1
  198. package/es/utils/encoder-types.mjs.map +1 -1
  199. package/es/utils/encoder.d.ts +0 -1
  200. package/es/utils/encoder.mjs +7 -15
  201. package/es/utils/encoder.mjs.map +1 -1
  202. package/es/utils/errors.d.ts +12 -6
  203. package/es/utils/errors.mjs +87 -163
  204. package/es/utils/errors.mjs.map +1 -1
  205. package/es/utils/hd-wallet.d.ts +27 -19
  206. package/es/utils/hd-wallet.mjs +42 -26
  207. package/es/utils/hd-wallet.mjs.map +1 -1
  208. package/es/utils/json-big.mjs +0 -8
  209. package/es/utils/json-big.mjs.map +1 -1
  210. package/es/utils/keystore.d.ts +2 -0
  211. package/es/utils/keystore.mjs +37 -36
  212. package/es/utils/keystore.mjs.map +1 -1
  213. package/es/utils/mptree.d.ts +1 -1
  214. package/es/utils/mptree.mjs +4 -26
  215. package/es/utils/mptree.mjs.map +1 -1
  216. package/es/utils/other.d.ts +3 -1
  217. package/es/utils/other.mjs +11 -7
  218. package/es/utils/other.mjs.map +1 -1
  219. package/es/utils/semver-satisfies.mjs +0 -3
  220. package/es/utils/semver-satisfies.mjs.map +1 -1
  221. package/es/utils/string.d.ts +0 -12
  222. package/es/utils/string.mjs +1 -21
  223. package/es/utils/string.mjs.map +1 -1
  224. package/package.json +86 -47
  225. package/src/AeSdk.ts +15 -11
  226. package/src/AeSdkAepp.ts +9 -7
  227. package/src/AeSdkBase.ts +28 -202
  228. package/src/AeSdkMethods.ts +170 -0
  229. package/src/AeSdkWallet.ts +16 -47
  230. package/src/Node.ts +11 -15
  231. package/src/account/Base.ts +29 -75
  232. package/src/account/Generalized.ts +98 -0
  233. package/src/account/Ledger.ts +131 -0
  234. package/src/account/LedgerFactory.ts +86 -0
  235. package/src/account/Memory.ts +46 -60
  236. package/src/account/Rpc.ts +17 -26
  237. package/src/aens.ts +10 -9
  238. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +5 -4
  239. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
  240. package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
  241. package/src/aepp-wallet-communication/rpc/types.ts +11 -1
  242. package/src/aepp-wallet-communication/schema.ts +18 -18
  243. package/src/apis/compiler/code-model-v4.yaml +681 -888
  244. package/src/apis/compiler/compiler.ts +113 -154
  245. package/src/apis/compiler/models/index.ts +80 -140
  246. package/src/apis/compiler/models/mappers.ts +165 -183
  247. package/src/apis/compiler/models/parameters.ts +6 -12
  248. package/src/chain.ts +6 -3
  249. package/src/channel/Base.ts +327 -0
  250. package/src/channel/Contract.ts +487 -0
  251. package/src/channel/Spend.ts +403 -0
  252. package/src/channel/handlers.ts +154 -573
  253. package/src/channel/internal.ts +113 -142
  254. package/src/contract/{Compiler.ts → CompilerHttp.ts} +5 -5
  255. package/src/contract/Contract.ts +620 -0
  256. package/src/contract/ga.ts +18 -104
  257. package/src/index.ts +9 -8
  258. package/src/oracle.ts +7 -7
  259. package/src/spend.ts +5 -13
  260. package/src/tx/builder/constants.ts +1 -0
  261. package/src/tx/builder/field-types/address.ts +52 -0
  262. package/src/tx/builder/field-types/addresses.ts +18 -0
  263. package/src/tx/builder/field-types/coin-amount.ts +2 -8
  264. package/src/tx/builder/field-types/enumeration.ts +21 -0
  265. package/src/tx/builder/field-types/fee.ts +1 -3
  266. package/src/tx/builder/field-types/gas-limit.ts +2 -2
  267. package/src/tx/builder/field-types/gas-price.ts +0 -2
  268. package/src/tx/builder/field-types/index.ts +16 -6
  269. package/src/tx/builder/field-types/name-fee.ts +1 -1
  270. package/src/tx/builder/field-types/name-id.ts +7 -10
  271. package/src/tx/builder/field-types/pointers.ts +41 -0
  272. package/src/tx/builder/field-types/u-int.ts +3 -2
  273. package/src/tx/builder/helpers.ts +10 -60
  274. package/src/tx/builder/index.ts +6 -65
  275. package/src/tx/builder/schema.ts +89 -100
  276. package/src/tx/index.ts +19 -15
  277. package/src/tx/validator.ts +36 -18
  278. package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
  279. package/src/utils/autorest.ts +16 -1
  280. package/src/utils/bytes.ts +5 -33
  281. package/src/utils/crypto.ts +23 -16
  282. package/src/utils/encoder.ts +0 -1
  283. package/src/utils/errors.ts +18 -12
  284. package/src/utils/hd-wallet.ts +30 -9
  285. package/src/utils/keystore.ts +24 -21
  286. package/src/utils/other.ts +16 -1
  287. package/src/utils/string.ts +0 -20
  288. package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
  289. package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
  290. package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
  291. package/types-legacy/ts4.2/AeSdkMethods.d.ts +141 -0
  292. package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
  293. package/types-legacy/ts4.2/Node.d.ts +78 -0
  294. package/types-legacy/ts4.2/account/Base.d.ts +52 -0
  295. package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
  296. package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
  297. package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
  298. package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
  299. package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
  300. package/types-legacy/ts4.2/aens.d.ts +222 -0
  301. package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  302. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  303. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  304. package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  305. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  306. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
  307. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
  308. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  309. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
  310. package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
  311. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
  312. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
  313. package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
  314. package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
  315. package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
  316. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
  317. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
  318. package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
  319. package/types-legacy/ts4.2/chain.d.ts +248 -0
  320. package/types-legacy/ts4.2/channel/Base.d.ts +194 -0
  321. package/types-legacy/ts4.2/channel/Contract.d.ts +247 -0
  322. package/types-legacy/ts4.2/channel/Spend.d.ts +217 -0
  323. package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
  324. package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
  325. package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +18 -0
  326. package/types-legacy/ts4.2/contract/Contract.d.ts +237 -0
  327. package/types-legacy/ts4.2/contract/ga.d.ts +43 -0
  328. package/types-legacy/ts4.2/globals.d.ts +16 -0
  329. package/types-legacy/ts4.2/index.d.ts +39 -0
  330. package/types-legacy/ts4.2/oracle.d.ts +161 -0
  331. package/types-legacy/ts4.2/spend.d.ts +62 -0
  332. package/types-legacy/ts4.2/tx/builder/constants.d.ts +71 -0
  333. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +22 -0
  334. package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +6 -0
  335. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
  336. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
  337. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -0
  338. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +17 -0
  339. package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
  340. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +12 -0
  341. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
  342. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +85 -0
  343. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +19 -0
  344. package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
  345. package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
  346. package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
  347. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
  348. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +8 -0
  349. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
  350. package/types-legacy/ts4.2/tx/builder/index.d.ts +68 -0
  351. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2963 -0
  352. package/types-legacy/ts4.2/tx/index.d.ts +34 -0
  353. package/types-legacy/ts4.2/tx/validator.d.ts +20 -0
  354. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
  355. package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
  356. package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
  357. package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
  358. package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
  359. package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
  360. package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
  361. package/types-legacy/ts4.2/utils/errors.d.ts +480 -0
  362. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
  363. package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
  364. package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
  365. package/types-legacy/ts4.2/utils/mptree.d.ts +32 -0
  366. package/types-legacy/ts4.2/utils/other.d.ts +31 -0
  367. package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
  368. package/types-legacy/ts4.2/utils/string.d.ts +12 -0
  369. package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
  370. package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
  371. package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
  372. package/types-legacy/ts4.5/AeSdkMethods.d.ts +141 -0
  373. package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
  374. package/types-legacy/ts4.5/Node.d.ts +78 -0
  375. package/types-legacy/ts4.5/account/Base.d.ts +52 -0
  376. package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
  377. package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
  378. package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
  379. package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
  380. package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
  381. package/types-legacy/ts4.5/aens.d.ts +222 -0
  382. package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  383. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  384. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  385. package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  386. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  387. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
  388. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
  389. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  390. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
  391. package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
  392. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
  393. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
  394. package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
  395. package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
  396. package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
  397. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
  398. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
  399. package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
  400. package/types-legacy/ts4.5/chain.d.ts +248 -0
  401. package/types-legacy/ts4.5/channel/Base.d.ts +194 -0
  402. package/types-legacy/ts4.5/channel/Contract.d.ts +247 -0
  403. package/types-legacy/ts4.5/channel/Spend.d.ts +217 -0
  404. package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
  405. package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
  406. package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +18 -0
  407. package/types-legacy/ts4.5/contract/Contract.d.ts +237 -0
  408. package/types-legacy/ts4.5/contract/ga.d.ts +43 -0
  409. package/types-legacy/ts4.5/index.d.ts +38 -0
  410. package/types-legacy/ts4.5/oracle.d.ts +161 -0
  411. package/types-legacy/ts4.5/spend.d.ts +62 -0
  412. package/types-legacy/ts4.5/tx/builder/constants.d.ts +71 -0
  413. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +22 -0
  414. package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +6 -0
  415. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
  416. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
  417. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -0
  418. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +17 -0
  419. package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
  420. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +12 -0
  421. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
  422. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +85 -0
  423. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +19 -0
  424. package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
  425. package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
  426. package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
  427. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
  428. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +8 -0
  429. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
  430. package/types-legacy/ts4.5/tx/builder/index.d.ts +68 -0
  431. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2963 -0
  432. package/types-legacy/ts4.5/tx/index.d.ts +34 -0
  433. package/types-legacy/ts4.5/tx/validator.d.ts +20 -0
  434. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
  435. package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
  436. package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
  437. package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
  438. package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
  439. package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
  440. package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
  441. package/types-legacy/ts4.5/utils/errors.d.ts +480 -0
  442. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
  443. package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
  444. package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
  445. package/types-legacy/ts4.5/utils/mptree.d.ts +32 -0
  446. package/types-legacy/ts4.5/utils/other.d.ts +31 -0
  447. package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
  448. package/types-legacy/ts4.5/utils/string.d.ts +12 -0
  449. package/es/channel/index.d.ts +0 -625
  450. package/es/channel/index.mjs +0 -975
  451. package/es/channel/index.mjs.map +0 -1
  452. package/es/contract/Compiler.mjs.map +0 -1
  453. package/es/contract/aci.d.ts +0 -127
  454. package/es/contract/aci.mjs +0 -508
  455. package/es/contract/aci.mjs.map +0 -1
  456. package/es/contract/methods.d.ts +0 -71
  457. package/es/contract/methods.mjs +0 -104
  458. package/es/contract/methods.mjs.map +0 -1
  459. package/es/deprecated/index.d.ts +0 -143
  460. package/es/deprecated/index.mjs +0 -162
  461. package/es/deprecated/index.mjs.map +0 -1
  462. package/es/deprecated/methods.d.ts +0 -18
  463. package/es/deprecated/methods.mjs +0 -26
  464. package/es/deprecated/methods.mjs.map +0 -1
  465. package/es/tx/builder/address.d.ts +0 -25
  466. package/es/tx/builder/address.mjs +0 -45
  467. package/es/tx/builder/address.mjs.map +0 -1
  468. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
  469. package/src/channel/index.ts +0 -1025
  470. package/src/contract/aci.ts +0 -537
  471. package/src/contract/methods.ts +0 -123
  472. package/src/deprecated/index.ts +0 -172
  473. package/src/deprecated/methods.ts +0 -25
  474. package/src/tx/builder/address.ts +0 -50
  475. package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
@@ -0,0 +1,101 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import AccountBase from "./Base.mjs";
6
+ import { ArgumentError, NotImplementedError } from "../utils/errors.mjs";
7
+ import { decode } from "../utils/encoder.mjs";
8
+ import { buildTx } from "../tx/builder/index.mjs";
9
+ import { Tag } from "../tx/builder/constants.mjs";
10
+ export const CLA = 0xe0;
11
+ export const GET_ADDRESS = 0x02;
12
+ export const SIGN_TRANSACTION = 0x04;
13
+ export const GET_APP_CONFIGURATION = 0x06;
14
+ export const SIGN_PERSONAL_MESSAGE = 0x08;
15
+
16
+ /**
17
+ * Ledger wallet account class
18
+ */
19
+ export default class AccountLedger extends AccountBase {
20
+ /**
21
+ * @param transport - Connection to Ledger to use
22
+ * @param index - Index of account
23
+ * @param address - Address of account
24
+ */
25
+ constructor(transport, index, address) {
26
+ super();
27
+ this.transport = transport;
28
+ this.index = index;
29
+ this.address = address;
30
+ const scrambleKey = 'w0w';
31
+ transport.decorateAppAPIMethods(this, ['signTransaction', 'signMessage'], scrambleKey);
32
+ }
33
+
34
+ // eslint-disable-next-line class-methods-use-this
35
+ async sign() {
36
+ throw new NotImplementedError('RAW signing using Ledger HW');
37
+ }
38
+ async signTransaction(tx) {
39
+ let {
40
+ innerTx,
41
+ networkId
42
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
+ if (innerTx != null) throw new NotImplementedError('innerTx option in AccountLedger');
44
+ if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
45
+ const rawTx = decode(tx);
46
+ let offset = 0;
47
+ const headerLength = 4 + 1 + 4;
48
+ const networkIdBuffer = _Buffer.from(networkId);
49
+ const toSend = [];
50
+ while (offset !== rawTx.length) {
51
+ const maxChunkSize = offset === 0 ? 150 - headerLength - networkIdBuffer.length : 150;
52
+ const chunkSize = offset + maxChunkSize > rawTx.length ? rawTx.length - offset : maxChunkSize;
53
+ const buffer = _Buffer.alloc(offset === 0 ? headerLength + networkIdBuffer.length + chunkSize : chunkSize);
54
+ if (offset === 0) {
55
+ let bufferOffset = buffer.writeUInt32BE(this.index, 0);
56
+ bufferOffset = buffer.writeUInt32BE(rawTx.length, bufferOffset);
57
+ bufferOffset = buffer.writeUInt8(networkIdBuffer.length, bufferOffset);
58
+ bufferOffset += networkIdBuffer.copy(buffer, bufferOffset, 0, networkIdBuffer.length);
59
+ rawTx.copy(buffer, bufferOffset, 0, 150 - bufferOffset);
60
+ } else {
61
+ rawTx.copy(buffer, 0, offset, offset + chunkSize);
62
+ }
63
+ toSend.push(buffer);
64
+ offset += chunkSize;
65
+ }
66
+ const response = await toSend.reduce(async (previous, data, i) => {
67
+ await previous;
68
+ return this.transport.send(CLA, SIGN_TRANSACTION, i === 0 ? 0x00 : 0x80, 0x00, data);
69
+ }, Promise.resolve(_Buffer.alloc(0)));
70
+ const signatures = [response.subarray(0, 64)];
71
+ return buildTx({
72
+ encodedTx: rawTx,
73
+ signatures
74
+ }, Tag.SignedTx).tx;
75
+ }
76
+ async signMessage(messageStr) {
77
+ let offset = 0;
78
+ const message = _Buffer.from(messageStr);
79
+ const toSend = [];
80
+ while (offset !== message.length) {
81
+ const maxChunkSize = offset === 0 ? 150 - 4 - 4 : 150;
82
+ const chunkSize = offset + maxChunkSize > message.length ? message.length - offset : maxChunkSize;
83
+ const buffer = _Buffer.alloc(offset === 0 ? 4 + 4 + chunkSize : chunkSize);
84
+ if (offset === 0) {
85
+ buffer.writeUInt32BE(this.index, 0);
86
+ buffer.writeUInt32BE(message.length, 4);
87
+ message.copy(buffer, 4 + 4, offset, offset + chunkSize);
88
+ } else {
89
+ message.copy(buffer, 0, offset, offset + chunkSize);
90
+ }
91
+ toSend.push(buffer);
92
+ offset += chunkSize;
93
+ }
94
+ const response = await toSend.reduce(async (previous, data, i) => {
95
+ await previous;
96
+ return this.transport.send(CLA, SIGN_PERSONAL_MESSAGE, i === 0 ? 0x00 : 0x80, 0x00, data);
97
+ }, Promise.resolve(_Buffer.alloc(0)));
98
+ return response.subarray(0, 64);
99
+ }
100
+ }
101
+ //# sourceMappingURL=Ledger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ledger.mjs","names":["AccountBase","ArgumentError","NotImplementedError","decode","buildTx","Tag","CLA","GET_ADDRESS","SIGN_TRANSACTION","GET_APP_CONFIGURATION","SIGN_PERSONAL_MESSAGE","AccountLedger","constructor","transport","index","address","scrambleKey","decorateAppAPIMethods","sign","signTransaction","tx","innerTx","networkId","rawTx","offset","headerLength","networkIdBuffer","from","toSend","length","maxChunkSize","chunkSize","buffer","alloc","bufferOffset","writeUInt32BE","writeUInt8","copy","push","response","reduce","previous","data","i","send","Promise","resolve","signatures","subarray","encodedTx","SignedTx","signMessage","messageStr","message"],"sources":["../../src/account/Ledger.ts"],"sourcesContent":["import type Transport from '@ledgerhq/hw-transport';\nimport AccountBase from './Base';\nimport { ArgumentError, NotImplementedError } from '../utils/errors';\nimport { decode, Encoded } from '../utils/encoder';\nimport { buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\nexport const CLA = 0xe0;\nexport const GET_ADDRESS = 0x02;\nexport const SIGN_TRANSACTION = 0x04;\nexport const GET_APP_CONFIGURATION = 0x06;\nexport const SIGN_PERSONAL_MESSAGE = 0x08;\n\n/**\n * Ledger wallet account class\n */\nexport default class AccountLedger extends AccountBase {\n readonly transport: Transport;\n\n override readonly address: Encoded.AccountAddress;\n\n readonly index: number;\n\n /**\n * @param transport - Connection to Ledger to use\n * @param index - Index of account\n * @param address - Address of account\n */\n constructor(transport: Transport, index: number, address: Encoded.AccountAddress) {\n super();\n this.transport = transport;\n this.index = index;\n this.address = address;\n const scrambleKey = 'w0w';\n transport.decorateAppAPIMethods(this, ['signTransaction', 'signMessage'], scrambleKey);\n }\n\n // eslint-disable-next-line class-methods-use-this\n override async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using Ledger HW');\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: { innerTx?: boolean; networkId?: string } = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountLedger');\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n\n const rawTx = decode(tx);\n let offset = 0;\n const headerLength = 4 + 1 + 4;\n const networkIdBuffer = Buffer.from(networkId);\n const toSend = [];\n while (offset !== rawTx.length) {\n const maxChunkSize = offset === 0 ? 150 - headerLength - networkIdBuffer.length : 150;\n const chunkSize = offset + maxChunkSize > rawTx.length\n ? rawTx.length - offset : maxChunkSize;\n const buffer = Buffer.alloc(\n offset === 0 ? headerLength + networkIdBuffer.length + chunkSize : chunkSize,\n );\n if (offset === 0) {\n let bufferOffset = buffer.writeUInt32BE(this.index, 0);\n bufferOffset = buffer.writeUInt32BE(rawTx.length, bufferOffset);\n bufferOffset = buffer.writeUInt8(networkIdBuffer.length, bufferOffset);\n bufferOffset += networkIdBuffer.copy(\n buffer,\n bufferOffset,\n 0,\n networkIdBuffer.length,\n );\n rawTx.copy(buffer, bufferOffset, 0, 150 - bufferOffset);\n } else {\n rawTx.copy(buffer, 0, offset, offset + chunkSize);\n }\n toSend.push(buffer);\n offset += chunkSize;\n }\n const response = await toSend.reduce(\n async (previous, data, i) => {\n await previous;\n return this.transport.send(\n CLA,\n SIGN_TRANSACTION,\n i === 0 ? 0x00 : 0x80,\n 0x00,\n data,\n );\n },\n Promise.resolve(Buffer.alloc(0)),\n );\n const signatures = [response.subarray(0, 64)];\n\n return buildTx({ encodedTx: rawTx, signatures }, Tag.SignedTx).tx;\n }\n\n override async signMessage(messageStr: string): Promise<Uint8Array> {\n let offset = 0;\n const message = Buffer.from(messageStr);\n const toSend = [];\n while (offset !== message.length) {\n const maxChunkSize = offset === 0 ? 150 - 4 - 4 : 150;\n const chunkSize = offset + maxChunkSize > message.length\n ? message.length - offset : maxChunkSize;\n const buffer = Buffer.alloc(offset === 0 ? 4 + 4 + chunkSize : chunkSize);\n if (offset === 0) {\n buffer.writeUInt32BE(this.index, 0);\n buffer.writeUInt32BE(message.length, 4);\n message.copy(buffer, 4 + 4, offset, offset + chunkSize);\n } else {\n message.copy(buffer, 0, offset, offset + chunkSize);\n }\n toSend.push(buffer);\n offset += chunkSize;\n }\n const response = await toSend.reduce(\n async (previous, data, i) => {\n await previous;\n return this.transport.send(\n CLA,\n SIGN_PERSONAL_MESSAGE,\n i === 0 ? 0x00 : 0x80,\n 0x00,\n data,\n );\n },\n Promise.resolve(Buffer.alloc(0)),\n );\n return response.subarray(0, 64);\n }\n}\n"],"mappings":";;;;OACOA,WAAW;AAAA,SACTC,aAAa,EAAEC,mBAAmB;AAAA,SAClCC,MAAM;AAAA,SACNC,OAAO;AAAA,SACPC,GAAG;AAEZ,OAAO,MAAMC,GAAG,GAAG,IAAI;AACvB,OAAO,MAAMC,WAAW,GAAG,IAAI;AAC/B,OAAO,MAAMC,gBAAgB,GAAG,IAAI;AACpC,OAAO,MAAMC,qBAAqB,GAAG,IAAI;AACzC,OAAO,MAAMC,qBAAqB,GAAG,IAAI;;AAEzC;AACA;AACA;AACA,eAAe,MAAMC,aAAa,SAASX,WAAW,CAAC;EAOrD;AACF;AACA;AACA;AACA;EACEY,WAAW,CAACC,SAAoB,EAAEC,KAAa,EAAEC,OAA+B,EAAE;IAChF,KAAK,EAAE;IACP,IAAI,CAACF,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,OAAO,GAAGA,OAAO;IACtB,MAAMC,WAAW,GAAG,KAAK;IACzBH,SAAS,CAACI,qBAAqB,CAAC,IAAI,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC,EAAED,WAAW,CAAC;EACxF;;EAEA;EACA,MAAeE,IAAI,GAAwB;IACzC,MAAM,IAAIhB,mBAAmB,CAAC,6BAA6B,CAAC;EAC9D;EAEA,MAAeiB,eAAe,CAC5BC,EAAuB,EAEO;IAAA,IAD9B;MAAEC,OAAO;MAAEC;IAAqD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AAGM,YAAY,GAAGuB,OAAO,CAACxB,MAAM,GACpDwB,OAAO,CAACxB,MAAM,GAAGL,MAAM,GAAGM,YAAY;MAC1C,MAAME,MAAM,GAAG,QAAOC,KAAK,CAACT,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAGO,SAAS,GAAGA,SAAS,CAAC;MACzE,IAAIP,MAAM,KAAK,CAAC,EAAE;QAChBQ,MAAM,CAACG,aAAa,CAAC,IAAI,CAACrB,KAAK,EAAE,CAAC,CAAC;QACnCkB,MAAM,CAACG,aAAa,CAACkB,OAAO,CAACxB,MAAM,EAAE,CAAC,CAAC;QACvCwB,OAAO,CAAChB,IAAI,CAACL,MAAM,EAAE,CAAC,GAAG,CAAC,EAAER,MAAM,EAAEA,MAAM,GAAGO,SAAS,CAAC;MACzD,CAAC,MAAM;QACLsB,OAAO,CAAChB,IAAI,CAACL,MAAM,EAAE,CAAC,EAAER,MAAM,EAAEA,MAAM,GAAGO,SAAS,CAAC;MACrD;MACAH,MAAM,CAACU,IAAI,CAACN,MAAM,CAAC;MACnBR,MAAM,IAAIO,SAAS;IACrB;IACA,MAAMQ,QAAQ,GAAG,MAAMX,MAAM,CAACY,MAAM,CAClC,OAAOC,QAAQ,EAAEC,IAAI,EAAEC,CAAC,KAAK;MAC3B,MAAMF,QAAQ;MACd,OAAO,IAAI,CAAC5B,SAAS,CAAC+B,IAAI,CACxBtC,GAAG,EACHI,qBAAqB,EACrBiC,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,EACrB,IAAI,EACJD,IAAI,CACL;IACH,CAAC,EACDG,OAAO,CAACC,OAAO,CAAC,QAAOb,KAAK,CAAC,CAAC,CAAC,CAAC,CACjC;IACD,OAAOM,QAAQ,CAACS,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;EACjC;AACF"}
@@ -0,0 +1,39 @@
1
+ import type Transport from '@ledgerhq/hw-transport';
2
+ import AccountLedger from './Ledger';
3
+ import { Encoded } from '../utils/encoder';
4
+ import Node from '../Node';
5
+ /**
6
+ * A factory class that generates instances of AccountLedger based on provided transport.
7
+ */
8
+ export default class AccountLedgerFactory {
9
+ readonly transport: Transport;
10
+ private readonly versionCheckPromise;
11
+ /**
12
+ * @param transport - Connection to Ledger to use
13
+ */
14
+ constructor(transport: Transport);
15
+ /**
16
+ * @returns the version of app installed on Ledger wallet
17
+ */
18
+ getAppConfiguration(): Promise<{
19
+ version: string;
20
+ }>;
21
+ /**
22
+ * Get `ak_`-prefixed address for a given account index.
23
+ * @param accountIndex - Index of account
24
+ * @param verify - Ask user to confirm address by showing it on the device screen
25
+ */
26
+ getAddress(accountIndex: number, verify?: boolean): Promise<Encoded.AccountAddress>;
27
+ /**
28
+ * Get an instance of AccountLedger for a given account index.
29
+ * @param accountIndex - Index of account
30
+ */
31
+ initialize(accountIndex: number): Promise<AccountLedger>;
32
+ /**
33
+ * Discovers accounts on Ledger that already have been used (has any on-chain transactions).
34
+ * It returns an empty array if none of accounts been used.
35
+ * If a used account is preceded by an unused account then it would be ignored.
36
+ * @param node - Instance of Node to get account information from
37
+ */
38
+ discover(node: Node): Promise<AccountLedger[]>;
39
+ }
@@ -0,0 +1,81 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import AccountLedger, { CLA, GET_ADDRESS, GET_APP_CONFIGURATION } from "./Ledger.mjs";
6
+ import { UnsupportedVersionError } from "../utils/errors.mjs";
7
+ import semverSatisfies from "../utils/semver-satisfies.mjs";
8
+ /**
9
+ * A factory class that generates instances of AccountLedger based on provided transport.
10
+ */
11
+ export default class AccountLedgerFactory {
12
+ /**
13
+ * @param transport - Connection to Ledger to use
14
+ */
15
+ constructor(transport) {
16
+ this.transport = transport;
17
+ this.versionCheckPromise = this.getAppConfiguration().then(_ref => {
18
+ let {
19
+ version
20
+ } = _ref;
21
+ const args = [version, '0.4.4', '0.5.0'];
22
+ if (!semverSatisfies(...args)) throw new UnsupportedVersionError('app on ledger', ...args);
23
+ });
24
+ const scrambleKey = 'w0w';
25
+ transport.decorateAppAPIMethods(this, ['getAddress', 'getAppConfiguration'], scrambleKey);
26
+ }
27
+
28
+ /**
29
+ * @returns the version of app installed on Ledger wallet
30
+ */
31
+ async getAppConfiguration() {
32
+ await this.versionCheckPromise;
33
+ const response = await this.transport.send(CLA, GET_APP_CONFIGURATION, 0x00, 0x00);
34
+ return {
35
+ version: [response[1], response[2], response[3]].join('.')
36
+ };
37
+ }
38
+
39
+ /**
40
+ * Get `ak_`-prefixed address for a given account index.
41
+ * @param accountIndex - Index of account
42
+ * @param verify - Ask user to confirm address by showing it on the device screen
43
+ */
44
+ async getAddress(accountIndex) {
45
+ let verify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
46
+ await this.versionCheckPromise;
47
+ const buffer = _Buffer.alloc(4);
48
+ buffer.writeUInt32BE(accountIndex, 0);
49
+ const response = await this.transport.send(CLA, GET_ADDRESS, verify ? 0x01 : 0x00, 0x00, buffer);
50
+ const addressLength = response[0];
51
+ return response.subarray(1, 1 + addressLength).toString('ascii');
52
+ }
53
+
54
+ /**
55
+ * Get an instance of AccountLedger for a given account index.
56
+ * @param accountIndex - Index of account
57
+ */
58
+ async initialize(accountIndex) {
59
+ await this.versionCheckPromise;
60
+ return new AccountLedger(this.transport, accountIndex, await this.getAddress(accountIndex));
61
+ }
62
+
63
+ /**
64
+ * Discovers accounts on Ledger that already have been used (has any on-chain transactions).
65
+ * It returns an empty array if none of accounts been used.
66
+ * If a used account is preceded by an unused account then it would be ignored.
67
+ * @param node - Instance of Node to get account information from
68
+ */
69
+ async discover(node) {
70
+ let index = 0;
71
+ const result = [];
72
+ let account;
73
+ do {
74
+ if (account != null) result.push(account);
75
+ account = await this.initialize(index);
76
+ index += 1;
77
+ } while (await node.getAccountByPubkey(account.address).then(() => true, () => false));
78
+ return result;
79
+ }
80
+ }
81
+ //# sourceMappingURL=LedgerFactory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LedgerFactory.mjs","names":["AccountLedger","CLA","GET_ADDRESS","GET_APP_CONFIGURATION","UnsupportedVersionError","semverSatisfies","AccountLedgerFactory","constructor","transport","versionCheckPromise","getAppConfiguration","then","version","args","scrambleKey","decorateAppAPIMethods","response","send","join","getAddress","accountIndex","verify","buffer","alloc","writeUInt32BE","addressLength","subarray","toString","initialize","discover","node","index","result","account","push","getAccountByPubkey","address"],"sources":["../../src/account/LedgerFactory.ts"],"sourcesContent":["import type Transport from '@ledgerhq/hw-transport';\nimport AccountLedger, { CLA, GET_ADDRESS, GET_APP_CONFIGURATION } from './Ledger';\nimport { UnsupportedVersionError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport semverSatisfies from '../utils/semver-satisfies';\nimport Node from '../Node';\n\n/**\n * A factory class that generates instances of AccountLedger based on provided transport.\n */\nexport default class AccountLedgerFactory {\n readonly transport: Transport;\n\n private readonly versionCheckPromise: Promise<void>;\n\n /**\n * @param transport - Connection to Ledger to use\n */\n constructor(transport: Transport) {\n this.transport = transport;\n this.versionCheckPromise = this.getAppConfiguration().then(({ version }) => {\n const args = [version, '0.4.4', '0.5.0'] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError('app on ledger', ...args);\n });\n const scrambleKey = 'w0w';\n transport.decorateAppAPIMethods(this, ['getAddress', 'getAppConfiguration'], scrambleKey);\n }\n\n /**\n * @returns the version of app installed on Ledger wallet\n */\n async getAppConfiguration(): Promise<{ version: string }> {\n await this.versionCheckPromise;\n const response = await this.transport.send(CLA, GET_APP_CONFIGURATION, 0x00, 0x00);\n return {\n version: [response[1], response[2], response[3]].join('.'),\n };\n }\n\n /**\n * Get `ak_`-prefixed address for a given account index.\n * @param accountIndex - Index of account\n * @param verify - Ask user to confirm address by showing it on the device screen\n */\n async getAddress(accountIndex: number, verify = false): Promise<Encoded.AccountAddress> {\n await this.versionCheckPromise;\n const buffer = Buffer.alloc(4);\n buffer.writeUInt32BE(accountIndex, 0);\n const response = await this.transport.send(\n CLA,\n GET_ADDRESS,\n verify ? 0x01 : 0x00,\n 0x00,\n buffer,\n );\n const addressLength = response[0];\n return response.subarray(1, 1 + addressLength).toString('ascii') as Encoded.AccountAddress;\n }\n\n /**\n * Get an instance of AccountLedger for a given account index.\n * @param accountIndex - Index of account\n */\n async initialize(accountIndex: number): Promise<AccountLedger> {\n await this.versionCheckPromise;\n return new AccountLedger(this.transport, accountIndex, await this.getAddress(accountIndex));\n }\n\n /**\n * Discovers accounts on Ledger that already have been used (has any on-chain transactions).\n * It returns an empty array if none of accounts been used.\n * If a used account is preceded by an unused account then it would be ignored.\n * @param node - Instance of Node to get account information from\n */\n async discover(node: Node): Promise<AccountLedger[]> {\n let index = 0;\n const result = [];\n let account;\n do {\n if (account != null) result.push(account);\n account = await this.initialize(index);\n index += 1;\n } while (await node.getAccountByPubkey(account.address).then(() => true, () => false));\n return result;\n }\n}\n"],"mappings":";;;;OACOA,aAAa,IAAIC,GAAG,EAAEC,WAAW,EAAEC,qBAAqB;AAAA,SACtDC,uBAAuB;AAAA,OAEzBC,eAAe;AAGtB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,CAAC;EAKxC;AACF;AACA;EACEC,WAAW,CAACC,SAAoB,EAAE;IAChC,IAAI,CAACA,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,mBAAmB,GAAG,IAAI,CAACC,mBAAmB,EAAE,CAACC,IAAI,CAAC,QAAiB;MAAA,IAAhB;QAAEC;MAAQ,CAAC;MACrE,MAAMC,IAAI,GAAG,CAACD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAU;MACjD,IAAI,CAACP,eAAe,CAAC,GAAGQ,IAAI,CAAC,EAAE,MAAM,IAAIT,uBAAuB,CAAC,eAAe,EAAE,GAAGS,IAAI,CAAC;IAC5F,CAAC,CAAC;IACF,MAAMC,WAAW,GAAG,KAAK;IACzBN,SAAS,CAACO,qBAAqB,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,qBAAqB,CAAC,EAAED,WA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AACC,IAAU,EAA4B;IACnD,IAAIC,KAAK,GAAG,CAAC;IACb,MAAMC,MAAM,GAAG,EAAE;IACjB,IAAIC,OAAO;IACX,GAAG;MACD,IAAIA,OAAO,IAAI,IAAI,EAAED,MAAM,CAACE,IAAI,CAACD,OAAO,CAAC;MACzCA,OAAO,GAAG,MAAM,IAAI,CAACL,UAAU,CAACG,KAAK,CAAC;MACtCA,KAAK,IAAI,CAAC;IACZ,CAAC,QAAQ,MAAMD,IAAI,CAACK,kBAAkB,CAACF,OAAO,CAACG,OAAO,CAAC,CAACzB,IAAI,CAAC,MAAM,IAAI,EAAE,MAAM,KAAK,CAAC;IACrF,OAAOqB,MAAM;EACf;AACF"}
@@ -1,26 +1,22 @@
1
1
  import AccountBase from './Base';
2
2
  import { Encoded } from '../utils/encoder';
3
- export interface Keypair {
4
- publicKey: Encoded.AccountAddress;
5
- secretKey: string | Uint8Array;
6
- }
7
3
  /**
8
4
  * In-memory account class
9
5
  */
10
6
  export default class AccountMemory extends AccountBase {
11
- isGa: boolean;
7
+ readonly address: Encoded.AccountAddress;
8
+ /**
9
+ * @param secretKey - Secret key
10
+ */
11
+ constructor(secretKey: string | Uint8Array);
12
12
  /**
13
- * @param options - Options
14
- * @param options.keypair - Key pair to use
15
- * @param options.keypair.publicKey - Public key
16
- * @param options.keypair.secretKey - Private key
17
- * @param options.gaId - Address of generalized account
13
+ * Generates a new AccountMemory using a random secret key
18
14
  */
19
- constructor({ keypair, gaId, ...options }: {
20
- keypair?: Keypair;
21
- gaId?: Encoded.AccountAddress;
22
- } & ConstructorParameters<typeof AccountBase>[0]);
23
- sign(data: string | Uint8Array): Promise<Uint8Array>;
24
- signTransaction(tx: Encoded.Transaction, options?: Parameters<AccountBase['signTransaction']>[1]): Promise<Encoded.Transaction>;
25
- address(): Promise<Encoded.AccountAddress>;
15
+ static generate(): AccountMemory;
16
+ sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
17
+ signTransaction(tx: Encoded.Transaction, { innerTx, networkId, ...options }?: {
18
+ innerTx?: boolean;
19
+ networkId?: string;
20
+ }): Promise<Encoded.Transaction>;
21
+ signMessage(message: string, options?: any): Promise<Uint8Array>;
26
22
  }
@@ -2,10 +2,9 @@ import _buffer from "buffer";
2
2
  const {
3
3
  Buffer: _Buffer
4
4
  } = _buffer;
5
-
6
5
  /*
7
6
  * ISC License (ISC)
8
- * Copyright (c) 2018 aeternity developers
7
+ * Copyright (c) 2022 aeternity developers
9
8
  *
10
9
  * Permission to use, copy, modify, and/or distribute this software for any
11
10
  * purpose with or without fee is hereby granted, provided that the above
@@ -20,84 +19,63 @@ const {
20
19
  * PERFORMANCE OF THIS SOFTWARE.
21
20
  */
22
21
  import AccountBase from "./Base.mjs";
23
- import { sign, isValidKeypair } from "../utils/crypto.mjs";
24
- import { isHex } from "../utils/string.mjs";
25
- import { ArgumentError, InvalidKeypairError, MissingParamError } from "../utils/errors.mjs";
26
- import { decode } from "../utils/encoder.mjs";
27
- import { createMetaTx } from "../contract/ga.mjs";
28
- const secrets = new WeakMap();
22
+ import { generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash } from "../utils/crypto.mjs";
23
+ import { ArgumentError } from "../utils/errors.mjs";
24
+ import { decode, encode, Encoding } from "../utils/encoder.mjs";
25
+ import { concatBuffers } from "../utils/other.mjs";
26
+ import { buildTx } from "../tx/builder/index.mjs";
27
+ import { Tag } from "../tx/builder/constants.mjs";
28
+ const secretKeys = new WeakMap();
29
29
 
30
30
  /**
31
31
  * In-memory account class
32
32
  */
33
33
  export default class AccountMemory extends AccountBase {
34
34
  /**
35
- * @param options - Options
36
- * @param options.keypair - Key pair to use
37
- * @param options.keypair.publicKey - Public key
38
- * @param options.keypair.secretKey - Private key
39
- * @param options.gaId - Address of generalized account
35
+ * @param secretKey - Secret key
40
36
  */
41
- constructor(_ref) {
42
- let {
43
- keypair,
44
- gaId,
45
- ...options
46
- } = _ref;
47
- super(options);
48
- this.isGa = gaId != null;
49
-
50
- if (this.isGa && gaId != null) {
51
- decode(gaId);
52
- secrets.set(this, {
53
- publicKey: gaId
54
- });
55
- return;
37
+ constructor(secretKey) {
38
+ super();
39
+ secretKey = typeof secretKey === 'string' ? _Buffer.from(secretKey, 'hex') : secretKey;
40
+ if (secretKey.length !== 64) {
41
+ throw new ArgumentError('secretKey', '64 bytes', secretKey.length);
56
42
  }
57
-
58
- if (keypair == null) throw new MissingParamError('Either gaId or keypair is required');
59
- if (!_Buffer.isBuffer(keypair.secretKey) && typeof keypair.secretKey === 'string' && !isHex(keypair.secretKey)) throw new InvalidKeypairError('Secret key must be hex string or Buffer');
60
- const secretKey = typeof keypair.secretKey === 'string' ? _Buffer.from(keypair.secretKey, 'hex') : keypair.secretKey;
61
-
62
- if (!isValidKeypair(secretKey, decode(keypair.publicKey))) {
63
- throw new InvalidKeypairError('Invalid Key Pair');
64
- }
65
-
66
- secrets.set(this, {
67
- secretKey,
68
- publicKey: keypair.publicKey
69
- });
43
+ secretKeys.set(this, secretKey);
44
+ this.address = encode(generateKeyPairFromSecret(secretKeys.get(this)).publicKey, Encoding.AccountAddress);
70
45
  }
71
46
 
72
- async sign(data) {
73
- if (this.isGa) throw new InvalidKeypairError('You are trying to sign data using generalized account without keypair');
74
- return sign(data, secrets.get(this).secretKey);
47
+ /**
48
+ * Generates a new AccountMemory using a random secret key
49
+ */
50
+ static generate() {
51
+ return new AccountMemory(generateKeyPair().secretKey);
75
52
  }
76
53
 
54
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
55
+ async sign(data, options) {
56
+ return sign(data, secretKeys.get(this));
57
+ }
77
58
  async signTransaction(tx) {
78
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
79
- if (!this.isGa || options.innerTx === true) return super.signTransaction(tx, options);
80
- const {
81
- authData,
82
- authFun,
83
- onCompiler,
84
- onNode
85
- } = options;
86
-
87
- if (authFun == null || authData == null || onCompiler == null || onNode == null) {
88
- throw new ArgumentError('authData, authFun, onCompiler, onNode', 'provided', null);
59
+ let {
60
+ innerTx,
61
+ networkId,
62
+ ...options
63
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
64
+ if (networkId == null) {
65
+ throw new ArgumentError('networkId', 'provided', networkId);
89
66
  }
90
-
91
- return createMetaTx(tx, authData, authFun, {
92
- onCompiler,
93
- onNode,
94
- onAccount: this
95
- });
67
+ const prefixes = [networkId];
68
+ if (innerTx === true) prefixes.push('inner_tx');
69
+ const rlpBinaryTx = decode(tx);
70
+ const txWithNetworkId = concatBuffers([_Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
71
+ const signatures = [await this.sign(txWithNetworkId, options)];
72
+ return buildTx({
73
+ encodedTx: rlpBinaryTx,
74
+ signatures
75
+ }, Tag.SignedTx).tx;
96
76
  }
97
-
98
- async address() {
99
- return secrets.get(this).publicKey;
77
+ async signMessage(message, options) {
78
+ return this.sign(messageToHash(message), options);
100
79
  }
101
-
102
80
  }
103
81
  //# sourceMappingURL=Memory.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Memory.mjs","names":["AccountBase","sign","isValidKeypair","isHex","ArgumentError","InvalidKeypairError","MissingParamError","decode","createMetaTx","secrets","WeakMap","AccountMemory","constructor","keypair","gaId","options","isGa","set","publicKey","isBuffer","secretKey","from","data","get","signTransaction","tx","innerTx","authData","authFun","onCompiler","onNode","onAccount","address"],"sources":["../../src/account/Memory.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 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 { sign, isValidKeypair } from '../utils/crypto';\nimport { isHex } from '../utils/string';\nimport { ArgumentError, InvalidKeypairError, MissingParamError } from '../utils/errors';\nimport { decode, Encoded } from '../utils/encoder';\nimport { createMetaTx } from '../contract/ga';\n\nconst secrets = new WeakMap();\n\nexport interface Keypair {\n publicKey: Encoded.AccountAddress;\n secretKey: string | Uint8Array;\n}\n\n/**\n * In-memory account class\n */\nexport default class AccountMemory extends AccountBase {\n isGa: boolean;\n\n /**\n * @param options - Options\n * @param options.keypair - Key pair to use\n * @param options.keypair.publicKey - Public key\n * @param options.keypair.secretKey - Private key\n * @param options.gaId - Address of generalized account\n */\n constructor(\n { keypair, gaId, ...options }: { keypair?: Keypair; gaId?: Encoded.AccountAddress }\n & ConstructorParameters<typeof AccountBase>[0],\n ) {\n super(options);\n\n this.isGa = gaId != null;\n if (this.isGa && gaId != null) {\n decode(gaId);\n secrets.set(this, { publicKey: gaId });\n return;\n }\n\n if (keypair == null) throw new MissingParamError('Either gaId or keypair is required');\n\n if (\n !Buffer.isBuffer(keypair.secretKey)\n && typeof keypair.secretKey === 'string' && !isHex(keypair.secretKey)\n ) throw new InvalidKeypairError('Secret key must be hex string or Buffer');\n const secretKey = typeof keypair.secretKey === 'string'\n ? Buffer.from(keypair.secretKey, 'hex')\n : keypair.secretKey;\n if (!isValidKeypair(secretKey, decode(keypair.publicKey))) {\n throw new InvalidKeypairError('Invalid Key Pair');\n }\n\n secrets.set(this, {\n secretKey,\n publicKey: keypair.publicKey,\n });\n }\n\n async sign(data: string | Uint8Array): Promise<Uint8Array> {\n if (this.isGa) throw new InvalidKeypairError('You are trying to sign data using generalized account without keypair');\n return sign(data, secrets.get(this).secretKey);\n }\n\n async signTransaction(\n tx: Encoded.Transaction,\n options: Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n if (!this.isGa || options.innerTx === true) return super.signTransaction(tx, options);\n const {\n authData, authFun, onCompiler, onNode,\n } = options;\n if (authFun == null || authData == null || onCompiler == null || onNode == null) {\n throw new ArgumentError('authData, authFun, onCompiler, onNode', 'provided', null);\n }\n return createMetaTx(tx, authData, authFun, { onCompiler, onNode, onAccount: this });\n }\n\n async address(): Promise<Encoded.AccountAddress> {\n return secrets.get(this).publicKey;\n }\n}\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;OACOA,W;SACEC,I,EAAMC,c;SACNC,K;SACAC,a,EAAeC,mB,EAAqBC,iB;SACpCC,M;SACAC,Y;AAET,MAAMC,OAAO,GAAG,IAAIC,OAAJ,EAAhB;;AAOA;AACA;AACA;AACA,eAAe,MAAMC,aAAN,SAA4BX,WAA5B,CAAwC;EAGrD;AACF;AACA;AACA;AACA;AACA;AACA;EACEY,WAAW,OAGT;IAAA,IAFA;MAAEC,OAAF;MAAWC,IAAX;MAAiB,GAAGC;IAApB,CAEA;IACA,MAAMA,OAAN;IAEA,KAAKC,IAAL,GAAYF,IAAI,IAAI,IAApB;;IACA,IAAI,KAAKE,IAAL,IAAaF,IAAI,IAAI,IAAzB,EAA+B;MAC7BP,MAAM,CAACO,IAAD,CAAN;MACAL,OAAO,CAACQ,GAAR,CAAY,IAAZ,EAAkB;QAAEC,SAAS,EAAEJ;MAAb,CAAlB;MACA;IACD;;IAED,IAAID,OAAO,IAAI,IAAf,EAAqB,MAAM,IAAIP,iBAAJ,CAAsB,oCAAtB,CAAN;IAErB,IACE,CAAC,QAAOa,QAAP,CAAgBN,OAAO,CAACO,SAAxB,CAAD,IACG,OAAOP,OAAO,CAACO,SAAf,KAA6B,QADhC,IAC4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AAOI,YAAY,CAACiB,EAAD,EAAKE,QAAL,EAAeC,OAAf,EAAwB;MAAEC,UAAF;MAAcC,MAAd;MAAsBC,SAAS,EAAE;IAAjC,CAAxB,CAAnB;EACD;;EAEY,MAAPC,OAAO,GAAoC;IAC/C,OAAOvB,OAAO,CAACc,GAAR,CAAY,IAAZ,EAAkBL,SAAzB;EACD;;AA/DoD"}
1
+ {"version":3,"file":"Memory.mjs","names":["AccountBase","generateKeyPairFromSecret","sign","generateKeyPair","hash","messageToHash","ArgumentError","decode","encode","Encoding","concatBuffers","buildTx","Tag","secretKeys","WeakMap","AccountMemory","constructor","secretKey","from","length","set","address","get","publicKey","AccountAddress","generate","data","options","signTransaction","tx","innerTx","networkId","prefixes","push","rlpBinaryTx","txWithNetworkId","join","signatures","encodedTx","SignedTx","signMessage","message"],"sources":["../../src/account/Memory.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 generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash,\n} from '../utils/crypto';\nimport { ArgumentError } from '../utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../utils/encoder';\nimport { concatBuffers } from '../utils/other';\nimport { buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\n\nconst secretKeys = new WeakMap();\n\n/**\n * In-memory account class\n */\nexport default class AccountMemory extends AccountBase {\n override readonly address: Encoded.AccountAddress;\n\n /**\n * @param secretKey - Secret key\n */\n constructor(secretKey: string | Uint8Array) {\n super();\n secretKey = typeof secretKey === 'string' ? Buffer.from(secretKey, 'hex') : secretKey;\n if (secretKey.length !== 64) {\n throw new ArgumentError('secretKey', '64 bytes', secretKey.length);\n }\n secretKeys.set(this, secretKey);\n this.address = encode(\n generateKeyPairFromSecret(secretKeys.get(this)).publicKey,\n Encoding.AccountAddress,\n );\n }\n\n /**\n * Generates a new AccountMemory using a random secret key\n */\n static generate(): AccountMemory {\n return new AccountMemory(generateKeyPair().secretKey);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override async sign(data: string | Uint8Array, options?: any): Promise<Uint8Array> {\n return sign(data, secretKeys.get(this));\n }\n\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId, ...options }: { innerTx?: boolean; networkId?: string } = {},\n ): Promise<Encoded.Transaction> {\n if (networkId == null) {\n throw new ArgumentError('networkId', 'provided', networkId);\n }\n const prefixes = [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 override async signMessage(message: string, options?: any): Promise<Uint8Array> {\n return this.sign(messageToHash(message), options);\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,yBAAyB,EAAEC,IAAI,EAAEC,eAAe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AC,WAAW,EAAE,UAAU,EAAEyB,SAAS,CAAC;IAC7D;IACA,MAAMC,QAAQ,GAAG,CAACD,SAAS,CAAC;IAC5B,IAAID,OAAO,KAAK,IAAI,EAAEE,QAAQ,CAACC,IAAI,CAAC,UAAU,CAAC;IAC/C,MAAMC,WAAW,GAAG3B,MAAM,CAACsB,EAAE,CAAC;IAC9B,MAAMM,eAAe,GAAGzB,aAAa,CAAC,CAAC,QAAOQ,IAAI,CAACc,QAAQ,CAACI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAEhC,IAAI,CAAC8B,WAAW,CAAC,CAAC,CAAC;IAE3F,MAAMG,UAAU,GAAG,CAAC,MAAM,IAAI,CAACnC,IAAI,CAACiC,eAAe,EAAER,OAAO,CAAC,CAAC;IAC9D,OAAOhB,OAAO,CAAC;MAAE2B,SAAS,EAAEJ,WAAW;MAAEG;IAAW,CAAC,EAAEzB,GAAG,CAAC2B,QAAQ,CAAC,CAACV,EAAE;EACzE;EAEA,MAAeW,WAAW,CAACC,OAAe,EAAEd,OAAa,EAAuB;IAC9E,OAAO,IAAI,CAACzB,IAAI,CAACG,aAAa,CAACoC,OAAO,CAAC,EAAEd,OAAO,CAAC;EACnD;AACF"}
@@ -1,5 +1,7 @@
1
1
  import AccountBase from './Base';
2
2
  import { Encoded } from '../utils/encoder';
3
+ import RpcClient from '../aepp-wallet-communication/rpc/RpcClient';
4
+ import { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';
3
5
  /**
4
6
  * Account provided by wallet
5
7
  * @param params - Params
@@ -8,14 +10,10 @@ import { Encoded } from '../utils/encoder';
8
10
  * @returns AccountRpc instance
9
11
  */
10
12
  export default class AccountRpc extends AccountBase {
11
- _rpcClient: any;
12
- _address: Encoded.AccountAddress;
13
- constructor({ rpcClient, address, ...options }: {
14
- rpcClient: any;
15
- address: Encoded.AccountAddress;
16
- } & ConstructorParameters<typeof AccountBase>[0]);
13
+ _rpcClient: RpcClient<WalletApi, AeppApi>;
14
+ readonly address: Encoded.AccountAddress;
15
+ constructor(rpcClient: RpcClient<WalletApi, AeppApi>, address: Encoded.AccountAddress);
17
16
  sign(): Promise<Uint8Array>;
18
- address(): Promise<Encoded.AccountAddress>;
19
17
  /**
20
18
  * @returns Signed transaction
21
19
  */
@@ -23,5 +21,5 @@ export default class AccountRpc extends AccountBase {
23
21
  /**
24
22
  * @returns Signed message
25
23
  */
26
- signMessage(message: string, { returnHex }?: Parameters<AccountBase['signMessage']>[1]): Promise<string | Uint8Array>;
24
+ signMessage(message: string): Promise<Uint8Array>;
27
25
  }
@@ -4,8 +4,7 @@ const {
4
4
  } = _buffer;
5
5
  import AccountBase from "./Base.mjs";
6
6
  import { METHODS } from "../aepp-wallet-communication/schema.mjs";
7
- import { NotImplementedError } from "../utils/errors.mjs";
8
-
7
+ import { ArgumentError, NotImplementedError, UnsupportedProtocolError } from "../utils/errors.mjs";
9
8
  /**
10
9
  * Account provided by wallet
11
10
  * @param params - Params
@@ -14,67 +13,50 @@ import { NotImplementedError } from "../utils/errors.mjs";
14
13
  * @returns AccountRpc instance
15
14
  */
16
15
  export default class AccountRpc extends AccountBase {
17
- constructor(_ref) {
18
- let {
19
- rpcClient,
20
- address,
21
- ...options
22
- } = _ref;
23
- super(options);
16
+ constructor(rpcClient, address) {
17
+ super();
24
18
  this._rpcClient = rpcClient;
25
- this._address = address;
26
- } // eslint-disable-next-line class-methods-use-this
27
-
19
+ this.address = address;
20
+ }
28
21
 
22
+ // eslint-disable-next-line class-methods-use-this
29
23
  async sign() {
30
24
  throw new NotImplementedError('RAW signing using wallet');
31
25
  }
32
26
 
33
- async address() {
34
- return this._address;
35
- }
36
27
  /**
37
28
  * @returns Signed transaction
38
29
  */
39
-
40
-
41
30
  async signTransaction(tx) {
42
31
  let {
43
32
  innerTx,
44
33
  networkId
45
34
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
46
35
  if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');
36
+ if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
47
37
  const res = await this._rpcClient.request(METHODS.sign, {
48
- onAccount: this._address,
38
+ onAccount: this.address,
49
39
  tx,
50
40
  returnSigned: true,
51
-
52
- /**
53
- * @deprecated Wallet provided networkId will be used (current network)
54
- * required to maintain backward compatibility with wallets using SDK v11.0.1 and below
55
- * @see {@link https://github.com/aeternity/aepp-sdk-js/commit/153fd89a52c4eab39fcd659b356b36d32129c1ba}
56
- */
57
41
  networkId
58
42
  });
43
+ if (res.signedTransaction == null) {
44
+ throw new UnsupportedProtocolError('signedTransaction is missed in wallet response');
45
+ }
59
46
  return res.signedTransaction;
60
47
  }
48
+
61
49
  /**
62
50
  * @returns Signed message
63
51
  */
64
-
65
-
66
52
  async signMessage(message) {
67
- let {
68
- returnHex = false
69
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
70
53
  const {
71
54
  signature
72
55
  } = await this._rpcClient.request(METHODS.signMessage, {
73
- onAccount: this._address,
56
+ onAccount: this.address,
74
57
  message
75
58
  });
76
- return returnHex ? signature : _Buffer.from(signature, 'hex');
59
+ return _Buffer.from(signature, 'hex');
77
60
  }
78
-
79
61
  }
80
62
  //# sourceMappingURL=Rpc.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Rpc.mjs","names":["AccountBase","METHODS","NotImplementedError","AccountRpc","constructor","rpcClient","address","options","_rpcClient","_address","sign","signTransaction","tx","innerTx","networkId","res","request","onAccount","returnSigned","signedTransaction","signMessage","message","returnHex","signature","from"],"sources":["../../src/account/Rpc.ts"],"sourcesContent":["import AccountBase from './Base';\nimport { METHODS } from '../aepp-wallet-communication/schema';\nimport { NotImplementedError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\n\n/**\n * Account provided by wallet\n * @param params - Params\n * @param params.rpcClient - RpcClient instance\n * @param params.address - RPC account address\n * @returns AccountRpc instance\n */\nexport default class AccountRpc extends AccountBase {\n _rpcClient: any;\n\n _address: Encoded.AccountAddress;\n\n constructor(\n { rpcClient, address, ...options }: { rpcClient: any; address: Encoded.AccountAddress }\n & ConstructorParameters<typeof AccountBase>[0],\n ) {\n super(options);\n this._rpcClient = rpcClient;\n this._address = address;\n }\n\n // eslint-disable-next-line class-methods-use-this\n async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using wallet');\n }\n\n async address(): Promise<Encoded.AccountAddress> {\n return this._address;\n }\n\n /**\n * @returns Signed transaction\n */\n async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');\n const res = await this._rpcClient.request(METHODS.sign, {\n onAccount: this._address,\n tx,\n returnSigned: true,\n /**\n * @deprecated Wallet provided networkId will be used (current network)\n * required to maintain backward compatibility with wallets using SDK v11.0.1 and below\n * @see {@link https://github.com/aeternity/aepp-sdk-js/commit/153fd89a52c4eab39fcd659b356b36d32129c1ba}\n */\n networkId,\n });\n return res.signedTransaction;\n }\n\n /**\n * @returns Signed message\n */\n async signMessage(\n message: string,\n { returnHex = false }: Parameters<AccountBase['signMessage']>[1] = {},\n ): Promise<string | Uint8Array> {\n const { signature } = await this._rpcClient\n .request(METHODS.signMessage, { onAccount: this._address, message });\n return returnHex ? signature : Buffer.from(signature, 'hex');\n }\n}\n"],"mappings":";;;;OAAOA,W;SACEC,O;SACAC,mB;;AAGT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,UAAN,SAAyBH,WAAzB,CAAqC;EAKlDI,WAAW,OAGT;IAAA,IAFA;MAAEC,SAAF;MAAaC,OAAb;MAAsB,GAAGC;IAAzB,CAEA;IACA,MAAMA,OAAN;IACA,KAAKC,UAAL,GAAkBH,SAAlB;IACA,KAAKI,QAAL,GAAgBH,OAAhB;EACD,CAZiD,CAclD;;;EACU,MAAJI,IAAI,GAAwB;IAChC,MAAM,IAAIR,mBAAJ,CAAwB,0BAAxB,CAAN;EACD;;EAEY,MAAPI,OAAO,GAAoC;IAC/C,OAAO,KAAKG,QAAZ;EACD;EAED;AACF;AACA;;;EACuB,MAAfE,eAAe,CACnBC,EADmB,EAGW;IAAA,IAD9B;MAAEC,OAAF;MAAWC;IAAX,CAC8B,uEAD0C,EAC1C;IAC9B,IAAID,OAAO,IAAI,IAAf,EAAqB,MAAM,IAAIX,mBAAJ,CAAwB,8BAAxB,CAAN;IACrB,MAAMa,GAAG,GAAG,MAAM,KAAKP,UAAL,CAAgBQ,OAAhB,CAAwBf,OAAO,CAACS,IAAhC,EAAsC;MACtDO,SAAS,EAAE,KAAKR,QADsC;MAEtDG,EAFsD;MAGtDM,YAAY,EAAE,IAHwC;;MAItD;AACN;AACA;AACA;AACA;MACMJ;IATsD,CAAtC,CAAlB;IAWA,OAAOC,GAAG,CAACI,iBAAX;EACD;EAED;AACF;AACA;;;EACmB,MAAXC,WAAW,CACfC,OADe,EAGe;IAAA,IAD9B;MAAEC,SAAS,GAAG;IAAd,CAC8B,uEADqC,EACrC;IAC9B,MAAM;MAAEC;IAAF,IAAgB,MAAM,KAAKf,UAAL,CACzBQ,OADyB,CACjBf,OAAO,CAACmB,WADS,EACI;MAAEH,SAAS,EAAE,KAAKR,QAAlB;MAA4BY;IAA5B,CADJ,CAA5B;IAEA,OAAOC,SAAS,GAAGC,SAAH,GAAe,QAAOC,IAAP,CAAYD,SAAZ,EAAuB,KAAvB,CAA/B;EACD;;AAvDiD"}
1
+ {"version":3,"file":"Rpc.mjs","names":["AccountBase","METHODS","ArgumentError","NotImplementedError","UnsupportedProtocolError","AccountRpc","constructor","rpcClient","address","_rpcClient","sign","signTransaction","tx","innerTx","networkId","res","request","onAccount","returnSigned","signedTransaction","signMessage","message","signature","from"],"sources":["../../src/account/Rpc.ts"],"sourcesContent":["import AccountBase from './Base';\nimport { METHODS } from '../aepp-wallet-communication/schema';\nimport { ArgumentError, NotImplementedError, UnsupportedProtocolError } from '../utils/errors';\nimport { Encoded } from '../utils/encoder';\nimport RpcClient from '../aepp-wallet-communication/rpc/RpcClient';\nimport { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';\n\n/**\n * Account provided by wallet\n * @param params - Params\n * @param params.rpcClient - RpcClient instance\n * @param params.address - RPC account address\n * @returns AccountRpc instance\n */\nexport default class AccountRpc extends AccountBase {\n _rpcClient: RpcClient<WalletApi, AeppApi>;\n\n override readonly address: Encoded.AccountAddress;\n\n constructor(rpcClient: RpcClient<WalletApi, AeppApi>, address: Encoded.AccountAddress) {\n super();\n this._rpcClient = rpcClient;\n this.address = address;\n }\n\n // eslint-disable-next-line class-methods-use-this\n async sign(): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using wallet');\n }\n\n /**\n * @returns Signed transaction\n */\n override async signTransaction(\n tx: Encoded.Transaction,\n { innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {},\n ): Promise<Encoded.Transaction> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');\n if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);\n const res = await this._rpcClient.request(METHODS.sign, {\n onAccount: this.address,\n tx,\n returnSigned: true,\n networkId,\n });\n if (res.signedTransaction == null) {\n throw new UnsupportedProtocolError('signedTransaction is missed in wallet response');\n }\n return res.signedTransaction;\n }\n\n /**\n * @returns Signed message\n */\n override async signMessage(message: string): Promise<Uint8Array> {\n const { signature } = await this._rpcClient\n .request(METHODS.signMessage, { onAccount: this.address, message });\n return Buffer.from(signature, 'hex');\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SACTC,OAAO;AAAA,SACPC,aAAa,EAAEC,mBAAmB,EAAEC,wBAAwB;AAKrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,UAAU,SAASL,WAAW,CAAC;EAKlDM,WAAW,CAACC,SAAwC,EAAEC,OAA+B,EAAE;IACrF,KAAK,EAAE;IACP,IAAI,CAACC,UAAU,GAAGF,SAAS;IAC3B,IAAI,CAACC,OAAO,GAAG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