@aeternity/aepp-sdk 13.0.0-alpha.1 → 13.0.0-beta.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 (388) 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 +1792 -1525
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdk.mjs.map +1 -1
  9. package/es/AeSdkAepp.mjs.map +1 -1
  10. package/es/AeSdkBase.mjs.map +1 -1
  11. package/es/AeSdkMethods.d.ts +11 -12
  12. package/es/AeSdkMethods.mjs +6 -8
  13. package/es/AeSdkMethods.mjs.map +1 -1
  14. package/es/AeSdkWallet.mjs +1 -1
  15. package/es/AeSdkWallet.mjs.map +1 -1
  16. package/es/Node.d.ts +5 -1
  17. package/es/Node.mjs +11 -5
  18. package/es/Node.mjs.map +1 -1
  19. package/es/account/Base.d.ts +11 -6
  20. package/es/account/Base.mjs +0 -17
  21. package/es/account/Base.mjs.map +1 -1
  22. package/es/account/Generalized.mjs +11 -24
  23. package/es/account/Generalized.mjs.map +1 -1
  24. package/es/account/Ledger.mjs.map +1 -1
  25. package/es/account/LedgerFactory.mjs.map +1 -1
  26. package/es/account/Memory.d.ts +2 -1
  27. package/es/account/Memory.mjs +9 -21
  28. package/es/account/Memory.mjs.map +1 -1
  29. package/es/account/Rpc.mjs.map +1 -1
  30. package/es/aens.d.ts +12 -14
  31. package/es/aens.mjs +17 -31
  32. package/es/aens.mjs.map +1 -1
  33. package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
  34. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  35. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +0 -16
  36. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  37. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
  38. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  39. package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
  40. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  41. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -5
  42. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  43. package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
  44. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  45. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
  47. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  48. package/es/apis/compiler/compiler.d.ts +1 -1
  49. package/es/apis/compiler/compiler.mjs +4 -20
  50. package/es/apis/compiler/compiler.mjs.map +1 -1
  51. package/es/apis/compiler/models/index.d.ts +3 -2
  52. package/es/apis/compiler/models/index.mjs.map +1 -1
  53. package/es/apis/compiler/models/mappers.d.ts +1 -1
  54. package/es/apis/compiler/models/mappers.mjs +19 -2
  55. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  56. package/es/apis/node/models/index.d.ts +15 -15
  57. package/es/apis/node/models/index.mjs.map +1 -1
  58. package/es/apis/node/models/mappers.d.ts +1 -1
  59. package/es/apis/node/models/mappers.mjs +2 -1
  60. package/es/apis/node/models/mappers.mjs.map +1 -1
  61. package/es/apis/node/models/parameters.d.ts +2 -2
  62. package/es/apis/node/models/parameters.mjs +2 -2
  63. package/es/apis/node/models/parameters.mjs.map +1 -1
  64. package/es/apis/node/node.mjs +3 -19
  65. package/es/apis/node/node.mjs.map +1 -1
  66. package/es/chain.d.ts +8 -8
  67. package/es/chain.mjs +19 -22
  68. package/es/chain.mjs.map +1 -1
  69. package/es/channel/Base.d.ts +25 -12
  70. package/es/channel/Base.mjs +23 -26
  71. package/es/channel/Base.mjs.map +1 -1
  72. package/es/channel/Contract.mjs +8 -21
  73. package/es/channel/Contract.mjs.map +1 -1
  74. package/es/channel/Spend.d.ts +4 -2
  75. package/es/channel/Spend.mjs +0 -16
  76. package/es/channel/Spend.mjs.map +1 -1
  77. package/es/channel/handlers.mjs +6 -18
  78. package/es/channel/handlers.mjs.map +1 -1
  79. package/es/channel/internal.d.ts +19 -2
  80. package/es/channel/internal.mjs +19 -19
  81. package/es/channel/internal.mjs.map +1 -1
  82. package/es/contract/Contract.d.ts +30 -85
  83. package/es/contract/Contract.mjs +174 -211
  84. package/es/contract/Contract.mjs.map +1 -1
  85. package/es/contract/compiler/Base.d.ts +7 -14
  86. package/es/contract/compiler/Base.mjs.map +1 -1
  87. package/es/contract/compiler/Cli.mjs +5 -11
  88. package/es/contract/compiler/Cli.mjs.map +1 -1
  89. package/es/contract/compiler/Http.mjs +6 -30
  90. package/es/contract/compiler/Http.mjs.map +1 -1
  91. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  92. package/es/contract/compiler/getFileSystem.mjs.map +1 -1
  93. package/es/contract/delegation-signature.d.ts +43 -0
  94. package/es/contract/delegation-signature.mjs +45 -0
  95. package/es/contract/delegation-signature.mjs.map +1 -0
  96. package/es/contract/ga.d.ts +23 -7
  97. package/es/contract/ga.mjs +52 -27
  98. package/es/contract/ga.mjs.map +1 -1
  99. package/es/index-browser.d.ts +4 -3
  100. package/es/index-browser.mjs +6 -20
  101. package/es/index-browser.mjs.map +1 -1
  102. package/es/oracle.d.ts +12 -17
  103. package/es/oracle.mjs +28 -48
  104. package/es/oracle.mjs.map +1 -1
  105. package/es/spend.d.ts +19 -27
  106. package/es/spend.mjs +20 -43
  107. package/es/spend.mjs.map +1 -1
  108. package/es/tx/builder/SchemaTypes.d.ts +37 -0
  109. package/es/tx/builder/SchemaTypes.mjs +2 -0
  110. package/es/tx/builder/SchemaTypes.mjs.map +1 -0
  111. package/es/tx/builder/constants.d.ts +4 -2
  112. package/es/tx/builder/constants.mjs +2 -0
  113. package/es/tx/builder/constants.mjs.map +1 -1
  114. package/es/tx/builder/field-types/abi-version.d.ts +11 -2
  115. package/es/tx/builder/field-types/abi-version.mjs +24 -4
  116. package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
  117. package/es/tx/builder/field-types/address.mjs.map +1 -1
  118. package/es/tx/builder/field-types/array.d.ts +1 -1
  119. package/es/tx/builder/field-types/array.mjs.map +1 -1
  120. package/es/tx/builder/field-types/boolean.mjs.map +1 -1
  121. package/es/tx/builder/field-types/coin-amount.d.ts +3 -4
  122. package/es/tx/builder/field-types/coin-amount.mjs +4 -5
  123. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  124. package/es/tx/builder/field-types/ct-version.d.ts +22 -3
  125. package/es/tx/builder/field-types/ct-version.mjs +32 -4
  126. package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
  127. package/es/tx/builder/field-types/deposit.d.ts +2 -1
  128. package/es/tx/builder/field-types/deposit.mjs +3 -2
  129. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  130. package/es/tx/builder/field-types/encoded.d.ts +1 -1
  131. package/es/tx/builder/field-types/encoded.mjs.map +1 -1
  132. package/es/tx/builder/field-types/entry.mjs +3 -0
  133. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  134. package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
  135. package/es/tx/builder/field-types/fee.d.ts +3 -1
  136. package/es/tx/builder/field-types/fee.mjs +5 -1
  137. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  138. package/es/tx/builder/field-types/field.mjs.map +1 -1
  139. package/es/tx/builder/field-types/gas-limit.d.ts +3 -2
  140. package/es/tx/builder/field-types/gas-limit.mjs +4 -2
  141. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  142. package/es/tx/builder/field-types/gas-price.d.ts +3 -1
  143. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  144. package/es/tx/builder/field-types/index.d.ts +52 -13
  145. package/es/tx/builder/field-types/index.mjs +10 -2
  146. package/es/tx/builder/field-types/index.mjs.map +1 -1
  147. package/es/tx/builder/field-types/map.d.ts +13 -0
  148. package/es/tx/builder/field-types/map.mjs +49 -0
  149. package/es/tx/builder/field-types/map.mjs.map +1 -0
  150. package/es/tx/builder/field-types/mptree.d.ts +7 -2
  151. package/es/tx/builder/field-types/mptree.mjs +5 -7
  152. package/es/tx/builder/field-types/mptree.mjs.map +1 -1
  153. package/es/tx/builder/field-types/name-fee.d.ts +1 -1
  154. package/es/tx/builder/field-types/name-fee.mjs +2 -2
  155. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  156. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  157. package/es/tx/builder/field-types/name.mjs.map +1 -1
  158. package/es/tx/builder/field-types/nonce.d.ts +14 -0
  159. package/es/tx/builder/field-types/nonce.mjs +29 -0
  160. package/es/tx/builder/field-types/nonce.mjs.map +1 -0
  161. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  162. package/es/tx/builder/field-types/raw.mjs.map +1 -1
  163. package/es/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  164. package/es/tx/builder/field-types/short-u-int-const.mjs +12 -8
  165. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -1
  166. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  167. package/es/tx/builder/field-types/string.mjs.map +1 -1
  168. package/es/tx/builder/field-types/ttl.d.ts +11 -0
  169. package/es/tx/builder/field-types/ttl.mjs +21 -0
  170. package/es/tx/builder/field-types/ttl.mjs.map +1 -0
  171. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  172. package/es/tx/builder/field-types/wrapped.d.ts +14 -0
  173. package/es/tx/builder/field-types/wrapped.mjs +22 -0
  174. package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
  175. package/es/tx/builder/helpers.mjs.map +1 -1
  176. package/es/tx/builder/index.d.ts +20 -20
  177. package/es/tx/builder/index.mjs +54 -64
  178. package/es/tx/builder/index.mjs.map +1 -1
  179. package/es/tx/builder/schema.d.ts +2735 -2865
  180. package/es/tx/builder/schema.generated.d.ts +2011 -0
  181. package/es/tx/builder/schema.generated.mjs +2 -0
  182. package/es/tx/builder/schema.generated.mjs.map +1 -0
  183. package/es/tx/builder/schema.mjs +459 -155
  184. package/es/tx/builder/schema.mjs.map +1 -1
  185. package/es/tx/execution-cost.d.ts +35 -0
  186. package/es/tx/execution-cost.mjs +123 -0
  187. package/es/tx/execution-cost.mjs.map +1 -0
  188. package/es/tx/transaction-signer.d.ts +6 -0
  189. package/es/tx/transaction-signer.mjs +27 -0
  190. package/es/tx/transaction-signer.mjs.map +1 -0
  191. package/es/tx/validator.mjs +60 -109
  192. package/es/tx/validator.mjs.map +1 -1
  193. package/es/utils/amount-formatter.mjs +0 -16
  194. package/es/utils/amount-formatter.mjs.map +1 -1
  195. package/es/utils/autorest.d.ts +3 -2
  196. package/es/utils/autorest.mjs +43 -11
  197. package/es/utils/autorest.mjs.map +1 -1
  198. package/es/utils/bytes.mjs +0 -16
  199. package/es/utils/bytes.mjs.map +1 -1
  200. package/es/utils/crypto.mjs +0 -16
  201. package/es/utils/crypto.mjs.map +1 -1
  202. package/es/utils/encoder.mjs.map +1 -1
  203. package/es/utils/errors.d.ts +14 -31
  204. package/es/utils/errors.mjs +2 -32
  205. package/es/utils/errors.mjs.map +1 -1
  206. package/es/utils/hd-wallet.mjs.map +1 -1
  207. package/es/utils/json-big.mjs.map +1 -1
  208. package/es/utils/keystore.mjs.map +1 -1
  209. package/es/utils/other.d.ts +1 -1
  210. package/es/utils/other.mjs.map +1 -1
  211. package/es/utils/semver-satisfies.mjs.map +1 -1
  212. package/es/utils/string.mjs +0 -17
  213. package/es/utils/string.mjs.map +1 -1
  214. package/package.json +34 -30
  215. package/src/AeSdkMethods.ts +11 -16
  216. package/src/AeSdkWallet.ts +1 -1
  217. package/src/Node.ts +17 -6
  218. package/src/account/Base.ts +11 -22
  219. package/src/account/Generalized.ts +8 -23
  220. package/src/account/Memory.ts +14 -21
  221. package/src/aens.ts +31 -47
  222. package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
  223. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +0 -17
  224. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
  225. package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
  226. package/src/aepp-wallet-communication/rpc/types.ts +6 -2
  227. package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
  228. package/src/apis/compiler/compiler.ts +3 -27
  229. package/src/apis/compiler/models/index.ts +3 -2
  230. package/src/apis/compiler/models/mappers.ts +15 -2
  231. package/src/apis/node/models/index.ts +16 -15
  232. package/src/apis/node/models/mappers.ts +2 -1
  233. package/src/apis/node/models/parameters.ts +2 -2
  234. package/src/apis/node/node.ts +3 -27
  235. package/src/chain.ts +28 -27
  236. package/src/channel/Base.ts +33 -33
  237. package/src/channel/Contract.ts +8 -23
  238. package/src/channel/Spend.ts +2 -17
  239. package/src/channel/handlers.ts +5 -18
  240. package/src/channel/internal.ts +40 -22
  241. package/src/contract/Contract.ts +133 -163
  242. package/src/contract/compiler/Base.ts +7 -14
  243. package/src/contract/compiler/Cli.ts +5 -11
  244. package/src/contract/compiler/Http.ts +6 -25
  245. package/src/contract/delegation-signature.ts +56 -0
  246. package/src/contract/ga.ts +53 -32
  247. package/src/index-browser.ts +12 -20
  248. package/src/oracle.ts +46 -56
  249. package/src/spend.ts +33 -67
  250. package/src/tx/builder/SchemaTypes.ts +79 -0
  251. package/src/tx/builder/constants.ts +2 -0
  252. package/src/tx/builder/field-types/abi-version.ts +29 -6
  253. package/src/tx/builder/field-types/array.ts +1 -1
  254. package/src/tx/builder/field-types/coin-amount.ts +6 -4
  255. package/src/tx/builder/field-types/ct-version.ts +37 -4
  256. package/src/tx/builder/field-types/deposit.ts +3 -1
  257. package/src/tx/builder/field-types/encoded.ts +1 -1
  258. package/src/tx/builder/field-types/entry.ts +8 -3
  259. package/src/tx/builder/field-types/fee.ts +6 -4
  260. package/src/tx/builder/field-types/gas-limit.ts +2 -2
  261. package/src/tx/builder/field-types/index.ts +15 -1
  262. package/src/tx/builder/field-types/map.ts +45 -0
  263. package/src/tx/builder/field-types/mptree.ts +4 -3
  264. package/src/tx/builder/field-types/name-fee.ts +2 -1
  265. package/src/tx/builder/field-types/nonce.ts +40 -0
  266. package/src/tx/builder/field-types/short-u-int-const.ts +18 -8
  267. package/src/tx/builder/field-types/ttl.ts +24 -0
  268. package/src/tx/builder/field-types/wrapped.ts +32 -0
  269. package/src/tx/builder/index.ts +57 -71
  270. package/src/tx/builder/schema.generated.ts +2013 -0
  271. package/src/tx/builder/schema.ts +544 -624
  272. package/src/tx/execution-cost.ts +146 -0
  273. package/src/tx/transaction-signer.ts +27 -0
  274. package/src/tx/validator.ts +60 -91
  275. package/src/utils/amount-formatter.ts +0 -16
  276. package/src/utils/autorest.ts +52 -11
  277. package/src/utils/bytes.ts +0 -16
  278. package/src/utils/crypto.ts +0 -16
  279. package/src/utils/errors.ts +15 -44
  280. package/src/utils/string.ts +0 -17
  281. package/types-legacy/ts4.2/AeSdkMethods.d.ts +11 -12
  282. package/types-legacy/ts4.2/Node.d.ts +5 -1
  283. package/types-legacy/ts4.2/account/Base.d.ts +11 -6
  284. package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
  285. package/types-legacy/ts4.2/aens.d.ts +12 -14
  286. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
  287. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
  288. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
  289. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
  290. package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
  291. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
  292. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  293. package/types-legacy/ts4.2/chain.d.ts +8 -8
  294. package/types-legacy/ts4.2/channel/Base.d.ts +25 -12
  295. package/types-legacy/ts4.2/channel/Spend.d.ts +4 -2
  296. package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
  297. package/types-legacy/ts4.2/contract/Contract.d.ts +29 -84
  298. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +7 -14
  299. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
  300. package/types-legacy/ts4.2/contract/ga.d.ts +23 -7
  301. package/types-legacy/ts4.2/index-browser.d.ts +4 -3
  302. package/types-legacy/ts4.2/oracle.d.ts +12 -17
  303. package/types-legacy/ts4.2/spend.d.ts +19 -27
  304. package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
  305. package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -2
  306. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +11 -2
  307. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +1 -1
  308. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +3 -4
  309. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +33 -3
  310. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +2 -1
  311. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +1 -1
  312. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +3 -1
  313. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +3 -2
  314. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
  315. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +52 -13
  316. package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
  317. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +7 -2
  318. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
  319. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
  320. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  321. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
  322. package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
  323. package/types-legacy/ts4.2/tx/builder/index.d.ts +23 -20
  324. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2962 -4629
  325. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
  326. package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
  327. package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
  328. package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
  329. package/types-legacy/ts4.2/utils/errors.d.ts +14 -31
  330. package/types-legacy/ts4.2/utils/other.d.ts +1 -1
  331. package/types-legacy/ts4.5/AeSdkMethods.d.ts +11 -12
  332. package/types-legacy/ts4.5/Node.d.ts +5 -1
  333. package/types-legacy/ts4.5/account/Base.d.ts +11 -6
  334. package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
  335. package/types-legacy/ts4.5/aens.d.ts +12 -14
  336. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
  337. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
  338. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
  339. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
  340. package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
  341. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
  342. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  343. package/types-legacy/ts4.5/chain.d.ts +8 -8
  344. package/types-legacy/ts4.5/channel/Base.d.ts +25 -12
  345. package/types-legacy/ts4.5/channel/Spend.d.ts +4 -2
  346. package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
  347. package/types-legacy/ts4.5/contract/Contract.d.ts +29 -84
  348. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +7 -14
  349. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
  350. package/types-legacy/ts4.5/contract/ga.d.ts +23 -7
  351. package/types-legacy/ts4.5/index-browser.d.ts +4 -3
  352. package/types-legacy/ts4.5/oracle.d.ts +12 -17
  353. package/types-legacy/ts4.5/spend.d.ts +19 -27
  354. package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
  355. package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -2
  356. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +11 -2
  357. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +1 -1
  358. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +3 -4
  359. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +33 -3
  360. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +2 -1
  361. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +1 -1
  362. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +3 -1
  363. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +3 -2
  364. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
  365. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +52 -13
  366. package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
  367. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +7 -2
  368. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
  369. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
  370. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  371. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
  372. package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
  373. package/types-legacy/ts4.5/tx/builder/index.d.ts +23 -20
  374. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2962 -4629
  375. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
  376. package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
  377. package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
  378. package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
  379. package/types-legacy/ts4.5/utils/errors.d.ts +14 -31
  380. package/types-legacy/ts4.5/utils/other.d.ts +1 -1
  381. package/es/tx/index.d.ts +0 -19
  382. package/es/tx/index.mjs +0 -115
  383. package/es/tx/index.mjs.map +0 -1
  384. package/src/apis/compiler/code-model-v4.yaml +0 -2442
  385. package/src/apis/node/code-model-v4.yaml +0 -10080
  386. package/src/tx/index.ts +0 -129
  387. package/types-legacy/ts4.2/tx/index.d.ts +0 -19
  388. package/types-legacy/ts4.5/tx/index.d.ts +0 -19
@@ -1,20 +1,3 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2022 aeternity developers
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- * PERFORMANCE OF THIS SOFTWARE.
16
- */
17
-
18
1
  /**
19
2
  * Account is one of the three basic building blocks of an
20
3
  * {@link AeSdk} and provides access to a signing key pair.
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"Base.mjs","names":["AccountBase"],"sources":["../../src/account/Base.ts"],"sourcesContent":["import { Encoded } from '../utils/encoder';\nimport Node from '../Node';\nimport CompilerBase from '../contract/compiler/Base';\nimport { Int } from '../tx/builder/constants';\n\ninterface AuthData {\n fee?: Int;\n gasLimit?: number;\n gasPrice?: Int;\n callData?: Encoded.ContractBytearray;\n sourceCode?: string;\n args?: any[];\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 /**\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?: AuthData | ((tx: Encoded.Transaction) => Promise<AuthData>);\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":"AAcA;AACA;AACA;AACA;AACA,eAAe,MAAeA,WAAW,CAAC"}
@@ -2,30 +2,13 @@ import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFi
2
2
  import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
3
3
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
4
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
5
  import AccountBase from "./Base.mjs";
22
6
  import { ArgumentError, InternalError, InvalidAuthDataError, NotImplementedError } from "../utils/errors.mjs";
23
7
  import { decode } from "../utils/encoder.mjs";
24
8
  import { getAccount } from "../chain.mjs";
25
9
  import Contract from "../contract/Contract.mjs";
26
- import { _buildTx } from "../tx/index.mjs";
10
+ import { buildTxAsync, buildTx } from "../tx/builder/index.mjs";
27
11
  import { Tag } from "../tx/builder/constants.mjs";
28
- import { buildTx } from "../tx/builder/index.mjs";
29
12
  /**
30
13
  * Generalized account class
31
14
  */
@@ -66,8 +49,10 @@ export default class AccountGeneralized extends AccountBase {
66
49
  callData,
67
50
  sourceCode,
68
51
  args,
69
- gasLimit
70
- } = authData;
52
+ fee,
53
+ gasLimit,
54
+ gasPrice
55
+ } = typeof authData === 'function' ? await authData(tx) : authData;
71
56
  const authCallData = callData !== null && callData !== void 0 ? callData : await (async () => {
72
57
  if (_classPrivateFieldGet(this, _authFun) == null) {
73
58
  const account = await getAccount(this.address, {
@@ -91,16 +76,18 @@ export default class AccountGeneralized extends AccountBase {
91
76
  });
92
77
  return contract._calldata.encode(contract._name, _classPrivateFieldGet(this, _authFun), args);
93
78
  })();
94
- const gaMetaTx = await _buildTx(Tag.GaMetaTx, {
95
- tx: decode(buildTx({
79
+ const gaMetaTx = await buildTxAsync({
80
+ tag: Tag.GaMetaTx,
81
+ tx: {
96
82
  tag: Tag.SignedTx,
97
83
  encodedTx: decode(tx),
98
84
  signatures: []
99
- })),
85
+ },
100
86
  gaId: this.address,
101
87
  authData: authCallData,
88
+ fee,
102
89
  gasLimit,
103
- nonce: 0,
90
+ gasPrice,
104
91
  onNode
105
92
  });
106
93
  return buildTx({
@@ -1 +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,EACbC,oBAAoB,EACpBC,mBAAmB;AAAA,SAEZC,MAAM;AAAA,SACNC,UAAU;AAAA,OACZC,QAAQ;AAAA,SACNC,QAAQ;AAAA,SACRC,GAAG;AAAA,SACHC,OAAO;AAEhB;AACA;AACA;AAFA;AAGA,eAAe,MAAMC,kBAAkB,SAASX,WAAW,CAAC;EAK1D;AACF;AACA;EACEY,WAAW,CAACC,OAA+B,EAAE;IAC3C,KAAK,EAAE;IAAC;MAAA;MAAA;IAAA;IACRR,MAAM,CAACQ,OAAO,CAAC;IACf,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACA,MAAeC,IAAI,GAAwB;IACzC,MAAM,IAAIV,mBAAmB,CAAC,uCAAuC,CAAC;EACxE;;EAEA;EACA,MAAeW,WAAW,GAAwB;IAChD,MAAM,IAAIX,mBAAmB,CAAC,uCAAuC,CAAC;EACxE;EAEA,MAAeY,eAAe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C,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"}
1
+ {"version":3,"file":"Generalized.mjs","names":["AccountBase","ArgumentError","InternalError","InvalidAuthDataError","NotImplementedError","decode","getAccount","Contract","buildTxAsync","buildTx","Tag","_authFun","WeakMap","AccountGeneralized","constructor","address","_classPrivateFieldInitSpec","writable","value","sign","signMessage","signTransaction","tx","_ref","authData","onCompiler","onNode","callData","sourceCode","args","fee","gasLimit","gasPrice","authCallData","_classPrivateFieldGet","account","kind","_classPrivateFieldSet","authFun","contract","initialize","_calldata","encode","_name","gaMetaTx","tag","GaMetaTx","SignedTx","encodedTx","signatures","gaId"],"sources":["../../src/account/Generalized.ts"],"sourcesContent":["import 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 { buildTxAsync, buildTx } from '../tx/builder';\nimport { Tag } from '../tx/builder/constants';\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, fee, gasLimit, gasPrice,\n } = typeof authData === 'function' ? await authData(tx) : 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 buildTxAsync({\n tag: Tag.GaMetaTx,\n tx: { tag: Tag.SignedTx, encodedTx: decode(tx), signatures: [] },\n gaId: this.address,\n authData: authCallData,\n fee,\n gasLimit,\n gasPrice,\n onNode,\n });\n return buildTx({ tag: Tag.SignedTx, encodedTx: decode(gaMetaTx), signatures: [] });\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SAEhBC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB;AAAA,SAEZC,MAAM;AAAA,SACNC,UAAU;AAAA,OACZC,QAAQ;AAAA,SACNC,YAAY,EAAEC,OAAO;AAAA,SACrBC,GAAG;AAEZ;AACA;AACA;AAFA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ccountBase","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","tag","SignedTx","encodedTx","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({ tag: Tag.SignedTx, encodedTx: rawTx, signatures });\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,CAAC,uEAAG,CAAC,CAAC;IAEtE,IAAID,OAAO,IAAI,IAAI,EAAE,MAAM,IAAInB,mBAAmB,CAAC,iCAAiC,CAAC;IACrF,IAAIoB,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AOC,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,CAACmB,OAAO,CAACzB,MAAM,EAAE,CAAC,CAAC;QACvCyB,OAAO,CAACjB,IAAI,CAACL,MAAM,EAAE,CAAC,GAAG,CAAC,EAAER,MAAM,EAAEA,MAAM,GAAGO,SAAS,CAAC;MACzD,CAAC,MAAM;QACLuB,OAAO,CAACjB,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"}
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","arguments","length","undefined","rawTx","offset","headerLength","networkIdBuffer","_Buffer","from","toSend","maxChunkSize","chunkSize","buffer","alloc","bufferOffset","writeUInt32BE","writeUInt8","copy","push","response","reduce","previous","data","i","send","Promise","resolve","signatures","subarray","tag","SignedTx","encodedTx","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({ tag: Tag.SignedTx, encodedTx: rawTx, signatures });\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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AGO,SAAS,GAAGA,SAAS,CAAC;MACzE,IAAIP,MAAM,KAAK,CAAC,EAAE;QAChBQ,MAAM,CAACG,aAAa,CAAC,IAAI,CAACxB,KAAK,EAAE,CAAC,CAAC;QACnCqB,MAAM,CAACG,aAAa,CAACmB,OAAO,CAACjC,MAAM,EAAE,CAAC,CAAC;QACvCiC,OAAO,CAACjB,IAAI,CAACL,MAAM,EAAE,CAAC,GAAG,CAAC,EAAER,MAAM,EAAEA,MAAM,GAAGO,SAAS,CAAC;MACzD,CAAC,MAAM;QACLuB,OAAO,CAACjB,IAAI,CAACL,MAAM,EAAE,CAAC,EAAER,MAAM,EAAEA,MAAM,GAAGO,SAAS,CAAC;MACrD;MACAF,MAAM,CAACS,IAAI,CAACN,MAAM,CAAC;MACnBR,MAAM,IAAIO,SAAS;IACrB;IACA,MAAMQ,QAAQ,GAAG,MAAMV,MAAM,CAACW,MAAM,CAClC,OAAOC,QAAQ,EAAEC,IAAI,EAAEC,CAAC,KAAK;MAC3B,MAAMF,QAAQ;MACd,OAAO,IAAI,CAAC/B,SAAS,CAACkC,IAAI,CACxBzC,GAAG,EACHI,qBAAqB,EACrBoC,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,EACrB,IAAI,EACJD,IAAI,CACL;IACH,CAAC,EACDG,OAAO,CAACC,OAAO,CAACnB,OAAA,CAAOM,KAAK,CAAC,CAAC,CAAC,CAAC,CACjC;IACD,OAAOM,QAAQ,CAACS,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;EACjC;AACF"}
@@ -1 +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,WAAW,CAAC;EAC3F;;EAEA;AACF;AACA;EACE,MAAMJ,mBAAmB,GAAiC;IACxD,MAAM,IAAI,CAACD,mBAAmB;IAC9B,MAAMO,QAAQ,GAAG,MAAM,IAAI,CAACR,SAAS,CAACS,IAAI,CAAChB,GAAG,EAAEE,qBAAqB,EAAE,IAAI,EAAE,IAAI,CAAC;IAClF,OAAO;MACLS,OAAO,EAA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tCA,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
+ {"version":3,"file":"LedgerFactory.mjs","names":["AccountLedger","CLA","GET_ADDRESS","GET_APP_CONFIGURATION","UnsupportedVersionError","semverSatisfies","AccountLedgerFactory","constructor","transport","versionCheckPromise","getAppConfiguration","then","_ref","version","args","scrambleKey","decorateAppAPIMethods","response","send","join","getAddress","accountIndex","verify","arguments","length","undefined","buffer","_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,WAAWA,CAACC,SAAoB,EAAE;IAChC,IAAI,CAACA,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,mBAAmB,GAAG,IAAI,CAACC,mBAAmB,EAAE,CAACC,IAAI,CAACC,IAAA,IAAiB;MAAA,IAAhB;QAAEC;MAAQ,CAAC,GAAAD,IAAA;MACrE,MAAME,IAAI,GAAG,CAACD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAU;MACj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AAGD,aAAa,CAAC,CAACE,QAAQ,CAAC,OAAO,CAAC;EAClE;;EAEA;AACF;AACA;AACA;EACE,MAAMC,UAAUA,CAACZ,YAAoB,EAA0B;IAC7D,MAAM,IAAI,CAACZ,mBAAmB;IAC9B,OAAO,IAAIT,aAAa,CAAC,IAAI,CAACQ,SAAS,EAAEa,YAAY,EAAE,MAAM,IAAI,CAACD,UAAU,CAACC,YAAY,CAAC,CAAC;EAC7F;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,MAAMa,QAAQA,CAACC,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,CAAC9B,IAAI,CAAC,MAAM,IAAI,EAAE,MAAM,KAAK,CAAC;IACrF,OAAO0B,MAAM;EACf;AACF"}
@@ -1,5 +1,6 @@
1
1
  import AccountBase from './Base';
2
2
  import { Encoded } from '../utils/encoder';
3
+ export declare function getBufferToSign(transaction: Encoded.Transaction, networkId: string, innerTx: boolean): Uint8Array;
3
4
  /**
4
5
  * In-memory account class
5
6
  */
@@ -14,7 +15,7 @@ export default class AccountMemory extends AccountBase {
14
15
  */
15
16
  static generate(): AccountMemory;
16
17
  sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
17
- signTransaction(tx: Encoded.Transaction, { innerTx, networkId, ...options }?: {
18
+ signTransaction(transaction: Encoded.Transaction, { innerTx, networkId, ...options }?: {
18
19
  innerTx?: boolean;
19
20
  networkId?: string;
20
21
  }): Promise<Encoded.Transaction>;
@@ -2,22 +2,6 @@ import _buffer from "buffer";
2
2
  const {
3
3
  Buffer: _Buffer
4
4
  } = _buffer;
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
5
  import AccountBase from "./Base.mjs";
22
6
  import { generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash } from "../utils/crypto.mjs";
23
7
  import { ArgumentError } from "../utils/errors.mjs";
@@ -26,6 +10,12 @@ import { concatBuffers } from "../utils/other.mjs";
26
10
  import { buildTx } from "../tx/builder/index.mjs";
27
11
  import { Tag } from "../tx/builder/constants.mjs";
28
12
  const secretKeys = new WeakMap();
13
+ export function getBufferToSign(transaction, networkId, innerTx) {
14
+ const prefixes = [networkId];
15
+ if (innerTx) prefixes.push('inner_tx');
16
+ const rlpBinaryTx = decode(transaction);
17
+ return concatBuffers([_Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
18
+ }
29
19
 
30
20
  /**
31
21
  * In-memory account class
@@ -55,7 +45,7 @@ export default class AccountMemory extends AccountBase {
55
45
  async sign(data, options) {
56
46
  return sign(data, secretKeys.get(this));
57
47
  }
58
- async signTransaction(tx) {
48
+ async signTransaction(transaction) {
59
49
  let {
60
50
  innerTx,
61
51
  networkId,
@@ -64,10 +54,8 @@ export default class AccountMemory extends AccountBase {
64
54
  if (networkId == null) {
65
55
  throw new ArgumentError('networkId', 'provided', networkId);
66
56
  }
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)]);
57
+ const rlpBinaryTx = decode(transaction);
58
+ const txWithNetworkId = getBufferToSign(transaction, networkId, innerTx === true);
71
59
  const signatures = [await this.sign(txWithNetworkId, options)];
72
60
  return buildTx({
73
61
  tag: Tag.SignedTx,
@@ -1 +1 @@
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","tag","SignedTx","encodedTx","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({ tag: Tag.SignedTx, encodedTx: rlpBinaryTx, signatures });\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,EAAEC,IAAI,EAAEC,aAAa;AAAA,SAE9DC,aAAa;AAAA,SAEpBC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa;AAAA,SACbC,OAAO;AAAA,SACPC,GAAG;AAEZ,MAAMC,UAAU,GAAG,IAAIC,OAAO,EAAE;;AAEhC;AACA;AACA;AACA,eAAe,MAAMC,aAAa,SAASf,WAAW,CAAC;EAGrD;AACF;AACA;EACEgB,WAAW,CAACC,SAA8B,EAAE;IAC1C,KAAK,EAAE;IACPA,SAAS,GAAG,OAAOA,SAAS,KAAK,QAAQ,GAAG,QAAOC,IAAI,CAACD,SAAS,EAAE,KAAK,CAAC,GAAGA,SAAS;IACrF,IAAIA,SAAS,CAACE,MAAM,KAAK,EAAE,EAAE;MAC3B,MAAM,IAAIb,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEW,SAAS,CAACE,MAAM,CAAC;IACpE;IACAN,UAAU,CAACO,GAAG,CAAC,IAAI,EAAEH,SAAS,CAAC;IAC/B,IAAI,CAACI,OAAO,GAAGb,MAAM,CACnBP,yBAAyB,CAACY,UAAU,CAACS,GAAG,CAAC,IAAI,CAAC,CAAC,CAACC,SAAS,EACzDd,QAAQ,CAACe,cAAc,CACxB;EACH;;EAEA;AACF;AACA;EACE,OAAOC,QAAQ,GAAkB;IAC/B,OAAO,IAAIV,aAAa,CAACZ,eAAe,EAAE,CAACc,SAAS,CAAC;EACvD;;EAEA;EACA,MAAef,IAAI,CAACwB,IAAyB,EAAEC,OAAa,EAAuB;IACjF,OAAOzB,IAAI,CAACwB,IAAI,EAAEb,UAAU,CAACS,GAAG,CAAC,IAAI,CAAC,CAAC;EACzC;EAEA,MAAeM,eAAe,CAC5BC,EAAuB,EAEO;IAAA,IAD9B;MAAEC,OAAO;MAAEC,SAAS;MAAE,GAAGJ;IAAmD,CAAC,uEAAG,CAAC,CAAC;IAElF,IAAII,SAAS,IAAI,IAAI,EAAE;MACrB,MAAM,IAAIzB,aAAa,CAAC,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,GAAG,EAAE1B,GAAG,CAAC2B,QAAQ;MAAEC,SAAS,EAAEN,WAAW;MAAEG;IAAW,CAAC,CAAC;EAC3E;EAEA,MAAeI,WAAW,CAACC,OAAe,EAAEf,OAAa,EAAuB;IAC9E,OAAO,IAAI,CAACzB,IAAI,CAACG,aAAa,CAACqC,OAAO,CAAC,EAAEf,OAAO,CAAC;EACnD;AACF"}
1
+ {"version":3,"file":"Memory.mjs","names":["AccountBase","generateKeyPairFromSecret","sign","generateKeyPair","hash","messageToHash","ArgumentError","decode","encode","Encoding","concatBuffers","buildTx","Tag","secretKeys","WeakMap","getBufferToSign","transaction","networkId","innerTx","prefixes","push","rlpBinaryTx","_Buffer","from","join","AccountMemory","constructor","secretKey","length","set","address","get","publicKey","AccountAddress","generate","data","options","signTransaction","arguments","undefined","txWithNetworkId","signatures","tag","SignedTx","encodedTx","signMessage","message"],"sources":["../../src/account/Memory.ts"],"sourcesContent":["import 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\nexport function getBufferToSign(\n transaction: Encoded.Transaction,\n networkId: string,\n innerTx: boolean,\n): Uint8Array {\n const prefixes = [networkId];\n if (innerTx) prefixes.push('inner_tx');\n const rlpBinaryTx = decode(transaction);\n return concatBuffers([Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);\n}\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 transaction: 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 rlpBinaryTx = decode(transaction);\n const txWithNetworkId = getBufferToSign(transaction, networkId, innerTx === true);\n\n const signatures = [await this.sign(txWithNetworkId, options)];\n return buildTx({ tag: Tag.SignedTx, encodedTx: rlpBinaryTx, signatures });\n }\n\n override async signMessage(message: string, options?: any): Promise<Uint8Array> {\n return this.sign(messageToHash(message), options);\n }\n}\n"],"mappings":";;;;OAAOA,WAAW;AAAA,SAEhBC,yBAAyB,EAAEC,IAAI,EAAEC,eAAe,EAAEC,IAAI,EAAEC,aAAa;AAAA,SAE9DC,aAAa;AAAA,SAEpBC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa;AAAA,SACbC,OAAO;AAAA,SACPC,GAAG;AAEZ,MAAMC,UAAU,GAAG,IAAIC,OAAO,EAAE;AAEhC,OAAO,SAASC,eAAeA,CAC7BC,WAAgC,EAChCC,SAAiB,EACjBC,OAAgB,EACJ;EACZ,MAAMC,QAAQ,GAAG,CAACF,SAAS,CAAC;EAC5B,IAAIC,OAAO,EAAEC,QAAQ,CAACC,IAAI,CAAC,UAAU,CAAC;EACtC,MAAMC,WAAW,GAAGd,MAAM,CAACS,WAAW,CAAC;EACvC,OAAON,aAAa,CAAC,CAACY,OAAA,CAAOC,IAAI,CAACJ,QAAQ,CAACK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAEpB,IAAI,CAACiB,WAAW,CAAC,CAAC,CAAC;AAC5E;;AAEA;AACA;AACA;AACA,eAAe,MAAMI,aAAa,SAASzB,WAAW,CAAC;EAGrD;AACF;AACA;EACE0B,WAAWA,CAACC,SAA8B,EAAE;IAC1C,KAAK,EAAE;IACPA,SAAS,GAAG,OAAOA,SAAS,KAAK,QAAQ,GAAGL,OAAA,CAAOC,IAAI,CAACI,SAAS,EAAE,KAAK,CAAC,GAAGA,SAAS;IACrF,IAAIA,SAAS,CAACC,MAAM,KAAK,EAAE,EAAE;MAC3B,MAAM,IAAItB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEqB,SAAS,CAACC,MAAM,CAAC;IACpE;IACAf,UAAU,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C,IAAI,CAACG,aAAa,CAACyC,OAAO,CAAC,EAAEV,OAAO,CAAC;EACnD;AACF"}
@@ -1 +1 @@
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,GAAGA,OAAO;EACxB;;EAEA;EACA,MAAME,IAAI,GAAwB;IAChC,MAAM,IAAIP,mBAAmB,CAAC,0BAA0B,CAAC;EAC3D;;EAEA;AACF;AACA;EACE,MAAeQ,eAAe,CAC5BC,EAAuB,EAEO;IAAA,IAD9B;MAAEC,OAAO;MAAEC;IAAyD,CAAC,uEAAG,CAAC,CAAC;IAE1E,IAAID,OAAO,IAAI,IAAI,EAAE,MAAM,IAAIV,mBAAmB,CAAC,8BAA8B,CAAC;IAClF,IAAIW,SAAS,IAAI,IAAI,EAAE,MAAM,IAAIZ,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEY,SAAS,CAAC;IAClF,MAAMC,GAAG,GAAG,MAAM,IAAI,CAACN,UAAU,CAACO,OAAO,CAACf,OAAO,CAACS,IAAI,EAAE;MACtDO,SAAS,EAAE,IAAI,CAACT,OAAO;MACvBI,EAAE;MACFM,YAAY,EAAE,IAAI;MAClBJ;IACF,CAAC,CAAC;IACF,IAAIC,GAAG,CAACI,iBAAiB,IAAI,IAAI,EAAE;MACjC,MAAM,IAAIf,wBAAwB,CAAC,gDAAgD,CAAC;IACtF;IACA,OAAOW,GAAG,CAACI,iBAAiB;EAC9B;;EAEA;AACF;AACA;EACE,MAAeC,WAAW,CAACC,OAAe,EAAuB;IAC/D,MAAM;MAAEC;IAAU,CAAC,GAAG,MAAM,IAAI,CAACb,UAAU,CACxCO,OAAO,CAACf,OAAO,CAACmB,WAAW,EAAE;MAAEH,SAAS,EAAE,IAAI,CAACT,OAAO;MAAEa;IAAQ,CAAC,CAAC;IACrE,OAAO,QAAOE,IAAI,CAACD,SAAS,EAAE,KAAK,CAAC;EACtC;AACF"}
1
+ {"version":3,"file":"Rpc.mjs","names":["AccountBase","METHODS","ArgumentError","NotImplementedError","UnsupportedProtocolError","AccountRpc","constructor","rpcClient","address","_rpcClient","sign","signTransaction","tx","innerTx","networkId","arguments","length","undefined","res","request","onAccount","returnSigned","signedTransaction","signMessage","message","signature","_Buffer","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,WAAWA,CAACC,SAAwC,EAAEC,OAA+B,EAAE;IACrF,KAAK,EAAE;IACP,IAAI,CAACC,UAAU,GAAGF,SAAS;IAC3B,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACA,MAAME,IAAIA,CAAA,EAAwB;IAChC,MAAM,IAAIP,mBAAmB,CAAC,0BAA0B,CAAC;EAC3D;;EAEA;AACF;AACA;EACE,MAAeQ,eAAeA,CAC5BC,EAAuB,EAEO;IAAA,IAD9B;MAAEC,OAAO;MAAEC;IAAyD,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAE1E,IAAIF,OAAO,IAAI,IAAI,EAAE,MAAM,IAAIV,mBAAmB,CAAC,8BAA8B,CAAC;IAClF,IAAIW,SAAS,IAAI,IAAI,EAAE,MAAM,IAAIZ,aAAa,CAAC,WAAW,EAAE,UAAU,EAAEY,SAAS,CAAC;IAClF,MAAMI,GAAG,GAAG,MAAM,IAAI,CAACT,UAAU,CAACU,OAAO,CAAClB,OAAO,CAACS,IAAI,EAAE;MACtDU,SAAS,EAAE,IAAI,CAACZ,OAAO;MACvBI,EAAE;MACFS,YAAY,EAAE,IAAI;MAClBP;IACF,CAAC,CAAC;IACF,IAAII,GAAG,CAACI,iBAAiB,IAAI,IAAI,EAAE;MACjC,MAAM,IAAIlB,wBAAwB,CAAC,gDAAgD,CAAC;IACtF;IACA,OAAOc,GAAG,CAACI,iBAAiB;EAC9B;;EAEA;AACF;AACA;EACE,MAAeC,WAAWA,CAACC,OAAe,EAAuB;IAC/D,MAAM;MAAEC;IAAU,CAAC,GAAG,MAAM,IAAI,CAAChB,UAAU,CACxCU,OAAO,CAAClB,OAAO,CAACsB,WAAW,EAAE;MAAEH,SAAS,EAAE,IAAI,CAACZ,OAAO;MAAEgB;IAAQ,CAAC,CAAC;IACrE,OAAOE,OAAA,CAAOC,IAAI,CAACF,SAAS,EAAE,KAAK,CAAC;EACtC;AACF"}
package/es/aens.d.ts CHANGED
@@ -8,9 +8,8 @@
8
8
  import BigNumber from 'bignumber.js';
9
9
  import { Tag, AensName } from './tx/builder/constants';
10
10
  import { Encoded } from './utils/encoder';
11
- import { send, SendOptions } from './spend';
12
- import { getName } from './chain';
13
- import { BuildTxOptions } from './tx';
11
+ import { sendTransaction, SendTransactionOptions, getName } from './chain';
12
+ import { BuildTxOptions } from './tx/builder';
14
13
  import { TransformNodeType } from './Node';
15
14
  import { NameEntry, NamePointer } from './apis/node';
16
15
  import AccountBase from './account/Base';
@@ -39,8 +38,8 @@ interface KeyPointers {
39
38
  * await nameObject.revoke({ fee, ttl, nonce })
40
39
  * ```
41
40
  */
42
- export declare function aensRevoke(name: AensName, options: AensRevokeOptions): ReturnType<typeof send>;
43
- interface AensRevokeOptions extends BuildTxOptions<Tag.NameRevokeTx, 'nameId' | 'accountId'>, SendOptions {
41
+ export declare function aensRevoke(name: AensName, options: AensRevokeOptions): ReturnType<typeof sendTransaction>;
42
+ interface AensRevokeOptions extends BuildTxOptions<Tag.NameRevokeTx, 'nameId' | 'accountId' | 'onNode'>, SendTransactionOptions {
44
43
  }
45
44
  /**
46
45
  * Update a name
@@ -71,8 +70,8 @@ interface AensRevokeOptions extends BuildTxOptions<Tag.NameRevokeTx, 'nameId' |
71
70
  * await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })
72
71
  * ```
73
72
  */
74
- export declare function aensUpdate(name: AensName, pointers: KeyPointers, { extendPointers, ...options }: AensUpdateOptions): ReturnType<typeof send>;
75
- interface AensUpdateOptions extends BuildTxOptions<Tag.NameUpdateTx, 'nameId' | 'accountId' | 'pointers' | 'clientTtl' | 'nameTtl'>, SendOptions {
73
+ export declare function aensUpdate(name: AensName, pointers: KeyPointers, { extendPointers, ...options }: AensUpdateOptions): ReturnType<typeof sendTransaction>;
74
+ interface AensUpdateOptions extends BuildTxOptions<Tag.NameUpdateTx, 'nameId' | 'accountId' | 'pointers' | 'clientTtl' | 'nameTtl' | 'onNode'>, SendTransactionOptions {
76
75
  extendPointers?: boolean;
77
76
  clientTtl?: number;
78
77
  nameTtl?: number;
@@ -100,8 +99,8 @@ interface AensUpdateOptions extends BuildTxOptions<Tag.NameUpdateTx, 'nameId' |
100
99
  * await nameObject.transfer(recipientPub, { ttl, fee, nonce })
101
100
  * ```
102
101
  */
103
- export declare function aensTransfer(name: AensName, account: Encoded.AccountAddress, options: AensTransferOptions): ReturnType<typeof send>;
104
- interface AensTransferOptions extends BuildTxOptions<Tag.NameTransferTx, 'nameId' | 'accountId' | 'recipientId'>, SendOptions {
102
+ export declare function aensTransfer(name: AensName, account: Encoded.AccountAddress, options: AensTransferOptions): ReturnType<typeof sendTransaction>;
103
+ interface AensTransferOptions extends BuildTxOptions<Tag.NameTransferTx, 'nameId' | 'accountId' | 'recipientId' | 'onNode'>, SendTransactionOptions {
105
104
  }
106
105
  /**
107
106
  * Query the AENS name info from the node
@@ -161,10 +160,10 @@ export declare function aensQuery(name: AensName, opt: Parameters<typeof getName
161
160
  * ```
162
161
  */
163
162
  export declare function aensClaim(name: AensName, salt: number, options: AensClaimOptions): Promise<AensClaimReturnType>;
164
- type AensClaimOptionsType = BuildTxOptions<Tag.NameClaimTx, 'accountId' | 'nameSalt' | 'name'> & SendOptions & Parameters<typeof aensQuery>[1];
163
+ type AensClaimOptionsType = BuildTxOptions<Tag.NameClaimTx, 'accountId' | 'nameSalt' | 'name'> & SendTransactionOptions & Parameters<typeof aensQuery>[1];
165
164
  interface AensClaimOptions extends AensClaimOptionsType {
166
165
  }
167
- interface AensClaimReturnType extends Awaited<ReturnType<typeof send>>, Partial<Awaited<ReturnType<typeof aensQuery>>> {
166
+ interface AensClaimReturnType extends Awaited<ReturnType<typeof sendTransaction>>, Partial<Awaited<ReturnType<typeof aensQuery>>> {
168
167
  }
169
168
  /**
170
169
  * Preclaim a name. Sends a hash of the name and a random salt to the node
@@ -190,13 +189,12 @@ interface AensClaimReturnType extends Awaited<ReturnType<typeof send>>, Partial<
190
189
  * }
191
190
  * ```
192
191
  */
193
- export declare function aensPreclaim(name: AensName, options: AensPreclaimOptions): Promise<Readonly<Awaited<ReturnType<typeof send>> & {
194
- height: number;
192
+ export declare function aensPreclaim(name: AensName, options: AensPreclaimOptions): Promise<Readonly<Awaited<ReturnType<typeof sendTransaction>> & {
195
193
  salt: number;
196
194
  commitmentId: string;
197
195
  claim: (opts?: Parameters<typeof aensClaim>[2]) => ReturnType<typeof aensClaim>;
198
196
  }>>;
199
- interface AensPreclaimOptions extends BuildTxOptions<Tag.NamePreclaimTx, 'accountId' | 'commitmentId'>, SendOptions, Omit<AensClaimOptions, 'version'> {
197
+ interface AensPreclaimOptions extends BuildTxOptions<Tag.NamePreclaimTx, 'accountId' | 'commitmentId' | 'onNode'>, SendTransactionOptions, Omit<AensClaimOptions, 'version'> {
200
198
  }
201
199
  /**
202
200
  * Bid to name auction
package/es/aens.mjs CHANGED
@@ -1,19 +1,3 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2022 aeternity developers
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- * PERFORMANCE OF THIS SOFTWARE.
16
- */
17
1
  /**
18
2
  * Aens methods - routines to interact with the æternity naming system
19
3
  *
@@ -25,9 +9,8 @@ import { genSalt } from "./utils/crypto.mjs";
25
9
  import { commitmentHash, isAuctionName } from "./tx/builder/helpers.mjs";
26
10
  import { CLIENT_TTL, NAME_TTL, Tag } from "./tx/builder/constants.mjs";
27
11
  import { ArgumentError } from "./utils/errors.mjs";
28
- import { send } from "./spend.mjs";
29
- import { getName, getHeight } from "./chain.mjs";
30
- import { _buildTx } from "./tx/index.mjs";
12
+ import { sendTransaction, getName } from "./chain.mjs";
13
+ import { buildTxAsync } from "./tx/builder/index.mjs";
31
14
  /**
32
15
  * Revoke a name
33
16
  * @category AENS
@@ -50,12 +33,13 @@ import { _buildTx } from "./tx/index.mjs";
50
33
  * ```
51
34
  */
52
35
  export async function aensRevoke(name, options) {
53
- const nameRevokeTx = await _buildTx(Tag.NameRevokeTx, {
36
+ const nameRevokeTx = await buildTxAsync({
54
37
  ...options,
38
+ tag: Tag.NameRevokeTx,
55
39
  nameId: name,
56
40
  accountId: options.onAccount.address
57
41
  });
58
- return send(nameRevokeTx, options);
42
+ return sendTransaction(nameRevokeTx, options);
59
43
  }
60
44
  /**
61
45
  * Update a name
@@ -101,10 +85,11 @@ export async function aensUpdate(name, pointers, _ref) {
101
85
  }))),
102
86
  ...pointers
103
87
  };
104
- const nameUpdateTx = await _buildTx(Tag.NameUpdateTx, {
88
+ const nameUpdateTx = await buildTxAsync({
105
89
  clientTtl: CLIENT_TTL,
106
90
  nameTtl: NAME_TTL,
107
91
  ...options,
92
+ tag: Tag.NameUpdateTx,
108
93
  nameId: name,
109
94
  accountId: options.onAccount.address,
110
95
  pointers: Object.entries(allPointers).map(_ref3 => {
@@ -115,7 +100,7 @@ export async function aensUpdate(name, pointers, _ref) {
115
100
  };
116
101
  })
117
102
  });
118
- return send(nameUpdateTx, options);
103
+ return sendTransaction(nameUpdateTx, options);
119
104
  }
120
105
  /**
121
106
  * Transfer a domain to another account
@@ -141,13 +126,14 @@ export async function aensUpdate(name, pointers, _ref) {
141
126
  * ```
142
127
  */
143
128
  export async function aensTransfer(name, account, options) {
144
- const nameTransferTx = await _buildTx(Tag.NameTransferTx, {
129
+ const nameTransferTx = await buildTxAsync({
145
130
  ...options,
131
+ tag: Tag.NameTransferTx,
146
132
  nameId: name,
147
133
  accountId: options.onAccount.address,
148
134
  recipientId: account
149
135
  });
150
- return send(nameTransferTx, options);
136
+ return sendTransaction(nameTransferTx, options);
151
137
  }
152
138
  /**
153
139
  * Query the AENS name info from the node
@@ -251,13 +237,14 @@ export async function aensQuery(name, opt) {
251
237
  * ```
252
238
  */
253
239
  export async function aensClaim(name, salt, options) {
254
- const claimTx = await _buildTx(Tag.NameClaimTx, {
240
+ const claimTx = await buildTxAsync({
255
241
  ...options,
242
+ tag: Tag.NameClaimTx,
256
243
  accountId: options.onAccount.address,
257
244
  nameSalt: salt,
258
245
  name
259
246
  });
260
- const result = await send(claimTx, options);
247
+ const result = await sendTransaction(claimTx, options);
261
248
  if (!isAuctionName(name)) {
262
249
  const nameInter = result.blockHeight != null && result.blockHeight > 0 ? await aensQuery(name, options) : {};
263
250
  return Object.assign(result, nameInter);
@@ -290,16 +277,15 @@ export async function aensClaim(name, salt, options) {
290
277
  */
291
278
  export async function aensPreclaim(name, options) {
292
279
  const salt = genSalt();
293
- const height = await getHeight(options);
294
280
  const commitmentId = commitmentHash(name, salt);
295
- const preclaimTx = await _buildTx(Tag.NamePreclaimTx, {
281
+ const preclaimTx = await buildTxAsync({
296
282
  ...options,
283
+ tag: Tag.NamePreclaimTx,
297
284
  accountId: options.onAccount.address,
298
285
  commitmentId
299
286
  });
300
287
  return Object.freeze({
301
- ...(await send(preclaimTx, options)),
302
- height,
288
+ ...(await sendTransaction(preclaimTx, options)),
303
289
  salt,
304
290
  commitmentId,
305
291
  async claim(opts) {