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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (565) hide show
  1. package/bin/aesophia_cli +0 -0
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +1 -1
  5. package/dist/aepp-sdk.browser.js.map +1 -1
  6. package/dist/aepp-sdk.js +12031 -11231
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdk.d.ts +7 -3
  9. package/es/AeSdk.mjs +17 -22
  10. package/es/AeSdk.mjs.map +1 -1
  11. package/es/AeSdkAepp.d.ts +6 -5
  12. package/es/AeSdkAepp.mjs +7 -30
  13. package/es/AeSdkAepp.mjs.map +1 -1
  14. package/es/AeSdkBase.d.ts +18 -140
  15. package/es/AeSdkBase.mjs +30 -184
  16. package/es/AeSdkBase.mjs.map +1 -1
  17. package/es/AeSdkMethods.d.ts +123 -0
  18. package/es/AeSdkMethods.mjs +122 -0
  19. package/es/AeSdkMethods.mjs.map +1 -0
  20. package/es/AeSdkWallet.d.ts +7 -21
  21. package/es/AeSdkWallet.mjs +38 -86
  22. package/es/AeSdkWallet.mjs.map +1 -1
  23. package/es/Node.d.ts +11 -15
  24. package/es/Node.mjs +35 -48
  25. package/es/Node.mjs.map +1 -1
  26. package/es/account/Base.d.ts +24 -40
  27. package/es/account/Base.mjs +1 -101
  28. package/es/account/Base.mjs.map +1 -1
  29. package/es/account/Generalized.d.ts +16 -0
  30. package/es/account/Generalized.mjs +113 -0
  31. package/es/account/Generalized.mjs.map +1 -0
  32. package/es/account/Ledger.d.ts +28 -0
  33. package/es/account/Ledger.mjs +102 -0
  34. package/es/account/Ledger.mjs.map +1 -0
  35. package/es/account/LedgerFactory.d.ts +39 -0
  36. package/es/account/LedgerFactory.mjs +81 -0
  37. package/es/account/LedgerFactory.mjs.map +1 -0
  38. package/es/account/Memory.d.ts +13 -17
  39. package/es/account/Memory.mjs +43 -64
  40. package/es/account/Memory.mjs.map +1 -1
  41. package/es/account/Rpc.d.ts +6 -8
  42. package/es/account/Rpc.mjs +14 -32
  43. package/es/account/Rpc.mjs.map +1 -1
  44. package/es/aens.d.ts +4 -4
  45. package/es/aens.mjs +46 -41
  46. package/es/aens.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
  48. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  50. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +22 -11
  51. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
  53. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
  54. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  55. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  56. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
  57. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -42
  58. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
  60. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/schema.mjs +14 -68
  62. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  63. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  64. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  65. package/es/apis/compiler/compiler.d.ts +23 -29
  66. package/es/apis/compiler/compiler.mjs +128 -189
  67. package/es/apis/compiler/compiler.mjs.map +1 -1
  68. package/es/apis/compiler/index.mjs.map +1 -1
  69. package/es/apis/compiler/models/index.d.ts +82 -135
  70. package/es/apis/compiler/models/index.mjs +1 -47
  71. package/es/apis/compiler/models/index.mjs.map +1 -1
  72. package/es/apis/compiler/models/mappers.d.ts +8 -8
  73. package/es/apis/compiler/models/mappers.mjs +165 -183
  74. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  75. package/es/apis/compiler/models/parameters.d.ts +0 -1
  76. package/es/apis/compiler/models/parameters.mjs +5 -9
  77. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  78. package/es/apis/node/index.mjs.map +1 -1
  79. package/es/apis/node/models/index.d.ts +48 -48
  80. package/es/apis/node/models/mappers.mjs +12 -6
  81. package/es/apis/node/models/mappers.mjs.map +1 -1
  82. package/es/apis/node/models/parameters.mjs.map +1 -1
  83. package/es/apis/node/node.mjs +43 -84
  84. package/es/apis/node/node.mjs.map +1 -1
  85. package/es/chain.d.ts +10 -2
  86. package/es/chain.mjs +37 -59
  87. package/es/chain.mjs.map +1 -1
  88. package/es/channel/Base.d.ts +200 -0
  89. package/es/channel/Base.mjs +293 -0
  90. package/es/channel/Base.mjs.map +1 -0
  91. package/es/channel/Contract.d.ts +248 -0
  92. package/es/channel/Contract.mjs +420 -0
  93. package/es/channel/Contract.mjs.map +1 -0
  94. package/es/channel/Spend.d.ts +219 -0
  95. package/es/channel/Spend.mjs +385 -0
  96. package/es/channel/Spend.mjs.map +1 -0
  97. package/es/channel/handlers.d.ts +8 -21
  98. package/es/channel/handlers.mjs +151 -899
  99. package/es/channel/handlers.mjs.map +1 -1
  100. package/es/channel/internal.d.ts +27 -21
  101. package/es/channel/internal.mjs +101 -191
  102. package/es/channel/internal.mjs.map +1 -1
  103. package/es/contract/Contract.d.ts +210 -0
  104. package/es/contract/Contract.mjs +551 -0
  105. package/es/contract/Contract.mjs.map +1 -0
  106. package/es/contract/compiler/Base.d.ts +81 -0
  107. package/es/contract/compiler/Base.mjs +5 -0
  108. package/es/contract/compiler/Base.mjs.map +1 -0
  109. package/es/contract/compiler/Cli.d.ts +23 -0
  110. package/es/contract/compiler/Cli.mjs +155 -0
  111. package/es/contract/compiler/Cli.mjs.map +1 -0
  112. package/es/contract/compiler/Http.d.ts +32 -0
  113. package/es/contract/compiler/Http.mjs +118 -0
  114. package/es/contract/compiler/Http.mjs.map +1 -0
  115. package/es/contract/compiler/HttpNode.d.ts +17 -0
  116. package/es/contract/compiler/HttpNode.mjs +26 -0
  117. package/es/contract/compiler/HttpNode.mjs.map +1 -0
  118. package/es/contract/compiler/getFileSystem.d.ts +6 -0
  119. package/es/contract/compiler/getFileSystem.mjs +40 -0
  120. package/es/contract/compiler/getFileSystem.mjs.map +1 -0
  121. package/es/contract/ga.d.ts +9 -34
  122. package/es/contract/ga.mjs +29 -112
  123. package/es/contract/ga.mjs.map +1 -1
  124. package/es/index-browser.d.ts +39 -0
  125. package/es/index-browser.mjs +55 -0
  126. package/es/index-browser.mjs.map +1 -0
  127. package/es/index.d.ts +4 -35
  128. package/es/index.mjs +4 -51
  129. package/es/index.mjs.map +1 -1
  130. package/es/oracle.d.ts +5 -5
  131. package/es/oracle.mjs +34 -40
  132. package/es/oracle.mjs.map +1 -1
  133. package/es/spend.d.ts +3 -3
  134. package/es/spend.mjs +18 -23
  135. package/es/spend.mjs.map +1 -1
  136. package/es/tx/builder/constants.d.ts +30 -2
  137. package/es/tx/builder/constants.mjs +43 -14
  138. package/es/tx/builder/constants.mjs.map +1 -1
  139. package/es/tx/builder/field-types/abi-version.d.ts +10 -0
  140. package/es/tx/builder/field-types/abi-version.mjs +20 -0
  141. package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
  142. package/es/tx/builder/field-types/address.d.ts +14 -0
  143. package/es/tx/builder/field-types/address.mjs +51 -0
  144. package/es/tx/builder/field-types/address.mjs.map +1 -0
  145. package/es/tx/builder/field-types/array.d.ts +7 -0
  146. package/es/tx/builder/field-types/array.mjs +11 -0
  147. package/es/tx/builder/field-types/array.mjs.map +1 -0
  148. package/es/tx/builder/field-types/boolean.d.ts +6 -0
  149. package/es/tx/builder/field-types/boolean.mjs +13 -0
  150. package/es/tx/builder/field-types/boolean.mjs.map +1 -0
  151. package/es/tx/builder/field-types/coin-amount.d.ts +2 -3
  152. package/es/tx/builder/field-types/coin-amount.mjs +4 -12
  153. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  154. package/es/tx/builder/field-types/ct-version.d.ts +30 -0
  155. package/es/tx/builder/field-types/ct-version.mjs +48 -0
  156. package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
  157. package/es/tx/builder/field-types/deposit.d.ts +1 -2
  158. package/es/tx/builder/field-types/deposit.mjs +2 -4
  159. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  160. package/es/tx/builder/field-types/encoded.d.ts +6 -0
  161. package/es/tx/builder/field-types/encoded.mjs +21 -0
  162. package/es/tx/builder/field-types/encoded.mjs.map +1 -0
  163. package/es/tx/builder/field-types/entry.d.ts +11 -0
  164. package/es/tx/builder/field-types/entry.mjs +31 -0
  165. package/es/tx/builder/field-types/entry.mjs.map +1 -0
  166. package/es/tx/builder/field-types/enumeration.d.ts +7 -0
  167. package/es/tx/builder/field-types/enumeration.mjs +30 -0
  168. package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
  169. package/es/tx/builder/field-types/fee.d.ts +10 -15
  170. package/es/tx/builder/field-types/fee.mjs +31 -43
  171. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  172. package/es/tx/builder/field-types/field.mjs +0 -2
  173. package/es/tx/builder/field-types/field.mjs.map +1 -1
  174. package/es/tx/builder/field-types/gas-limit.d.ts +5 -2
  175. package/es/tx/builder/field-types/gas-limit.mjs +12 -14
  176. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  177. package/es/tx/builder/field-types/gas-price.d.ts +1 -2
  178. package/es/tx/builder/field-types/gas-price.mjs +3 -7
  179. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  180. package/es/tx/builder/field-types/index.d.ts +80 -30
  181. package/es/tx/builder/field-types/index.mjs +34 -9
  182. package/es/tx/builder/field-types/index.mjs.map +1 -1
  183. package/es/tx/builder/field-types/mptree.d.ts +37 -0
  184. package/es/tx/builder/field-types/mptree.mjs +268 -0
  185. package/es/tx/builder/field-types/mptree.mjs.map +1 -0
  186. package/es/tx/builder/field-types/name-fee.d.ts +1 -3
  187. package/es/tx/builder/field-types/name-fee.mjs +3 -5
  188. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  189. package/es/tx/builder/field-types/name-id.d.ts +1 -4
  190. package/es/tx/builder/field-types/name-id.mjs +5 -10
  191. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  192. package/es/tx/builder/field-types/name.mjs +0 -2
  193. package/es/tx/builder/field-types/name.mjs.map +1 -1
  194. package/es/tx/builder/field-types/pointers.d.ts +23 -0
  195. package/es/tx/builder/field-types/pointers.mjs +36 -0
  196. package/es/tx/builder/field-types/pointers.mjs.map +1 -0
  197. package/es/tx/builder/field-types/raw.d.ts +6 -0
  198. package/es/tx/builder/field-types/raw.mjs +13 -0
  199. package/es/tx/builder/field-types/raw.mjs.map +1 -0
  200. package/es/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  201. package/es/tx/builder/field-types/short-u-int-const.mjs +16 -0
  202. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
  203. package/es/tx/builder/field-types/short-u-int.mjs +0 -2
  204. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  205. package/es/tx/builder/field-types/string.d.ts +6 -0
  206. package/es/tx/builder/field-types/string.mjs +10 -0
  207. package/es/tx/builder/field-types/string.mjs.map +1 -0
  208. package/es/tx/builder/field-types/u-int.d.ts +1 -2
  209. package/es/tx/builder/field-types/u-int.mjs +3 -4
  210. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  211. package/es/tx/builder/helpers.d.ts +2 -32
  212. package/es/tx/builder/helpers.mjs +19 -71
  213. package/es/tx/builder/helpers.mjs.map +1 -1
  214. package/es/tx/builder/index.d.ts +11 -49
  215. package/es/tx/builder/index.mjs +57 -337
  216. package/es/tx/builder/index.mjs.map +1 -1
  217. package/es/tx/builder/schema.d.ts +2367 -667
  218. package/es/tx/builder/schema.mjs +70 -145
  219. package/es/tx/builder/schema.mjs.map +1 -1
  220. package/es/tx/index.d.ts +4 -49
  221. package/es/tx/index.mjs +38 -112
  222. package/es/tx/index.mjs.map +1 -1
  223. package/es/tx/validator.d.ts +4 -6
  224. package/es/tx/validator.mjs +104 -90
  225. package/es/tx/validator.mjs.map +1 -1
  226. package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
  227. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
  228. package/es/utils/amount-formatter.mjs +4 -10
  229. package/es/utils/amount-formatter.mjs.map +1 -1
  230. package/es/utils/autorest.d.ts +1 -0
  231. package/es/utils/autorest.mjs +17 -19
  232. package/es/utils/autorest.mjs.map +1 -1
  233. package/es/utils/bignumber.mjs +4 -7
  234. package/es/utils/bignumber.mjs.map +1 -1
  235. package/es/utils/bytes.d.ts +0 -17
  236. package/es/utils/bytes.mjs +6 -35
  237. package/es/utils/bytes.mjs.map +1 -1
  238. package/es/utils/crypto.d.ts +15 -8
  239. package/es/utils/crypto.mjs +40 -40
  240. package/es/utils/crypto.mjs.map +1 -1
  241. package/es/utils/encoder-types.d.ts +28 -28
  242. package/es/utils/encoder-types.mjs +0 -1
  243. package/es/utils/encoder-types.mjs.map +1 -1
  244. package/es/utils/encoder.d.ts +0 -1
  245. package/es/utils/encoder.mjs +7 -15
  246. package/es/utils/encoder.mjs.map +1 -1
  247. package/es/utils/errors.d.ts +15 -14
  248. package/es/utils/errors.mjs +86 -172
  249. package/es/utils/errors.mjs.map +1 -1
  250. package/es/utils/hd-wallet.d.ts +27 -19
  251. package/es/utils/hd-wallet.mjs +42 -26
  252. package/es/utils/hd-wallet.mjs.map +1 -1
  253. package/es/utils/json-big.mjs +0 -8
  254. package/es/utils/json-big.mjs.map +1 -1
  255. package/es/utils/keystore.d.ts +2 -0
  256. package/es/utils/keystore.mjs +37 -36
  257. package/es/utils/keystore.mjs.map +1 -1
  258. package/es/utils/other.d.ts +4 -2
  259. package/es/utils/other.mjs +11 -7
  260. package/es/utils/other.mjs.map +1 -1
  261. package/es/utils/semver-satisfies.mjs +0 -3
  262. package/es/utils/semver-satisfies.mjs.map +1 -1
  263. package/es/utils/string.d.ts +0 -12
  264. package/es/utils/string.mjs +1 -21
  265. package/es/utils/string.mjs.map +1 -1
  266. package/package.json +98 -51
  267. package/src/AeSdk.ts +15 -11
  268. package/src/AeSdkAepp.ts +9 -7
  269. package/src/AeSdkBase.ts +31 -202
  270. package/src/AeSdkMethods.ts +169 -0
  271. package/src/AeSdkWallet.ts +16 -47
  272. package/src/Node.ts +17 -18
  273. package/src/account/Base.ts +29 -75
  274. package/src/account/Generalized.ts +98 -0
  275. package/src/account/Ledger.ts +131 -0
  276. package/src/account/LedgerFactory.ts +86 -0
  277. package/src/account/Memory.ts +46 -60
  278. package/src/account/Rpc.ts +17 -26
  279. package/src/aens.ts +13 -11
  280. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +21 -9
  281. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
  282. package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -4
  283. package/src/aepp-wallet-communication/rpc/types.ts +11 -1
  284. package/src/aepp-wallet-communication/schema.ts +18 -18
  285. package/src/apis/compiler/code-model-v4.yaml +681 -888
  286. package/src/apis/compiler/compiler.ts +113 -154
  287. package/src/apis/compiler/models/index.ts +80 -140
  288. package/src/apis/compiler/models/mappers.ts +165 -183
  289. package/src/apis/compiler/models/parameters.ts +6 -12
  290. package/src/chain.ts +11 -6
  291. package/src/channel/Base.ts +335 -0
  292. package/src/channel/Contract.ts +488 -0
  293. package/src/channel/Spend.ts +408 -0
  294. package/src/channel/handlers.ts +164 -582
  295. package/src/channel/internal.ts +114 -143
  296. package/src/contract/Contract.ts +610 -0
  297. package/src/contract/compiler/Base.ts +94 -0
  298. package/src/contract/compiler/Cli.ts +134 -0
  299. package/src/contract/compiler/Http.ts +124 -0
  300. package/src/contract/compiler/HttpNode.ts +26 -0
  301. package/src/contract/compiler/getFileSystem.ts +42 -0
  302. package/src/contract/ga.ts +23 -106
  303. package/src/index-browser.ts +58 -0
  304. package/src/index.ts +4 -55
  305. package/src/oracle.ts +8 -8
  306. package/src/spend.ts +6 -14
  307. package/src/tx/builder/constants.ts +33 -3
  308. package/src/tx/builder/field-types/abi-version.ts +21 -0
  309. package/src/tx/builder/field-types/address.ts +62 -0
  310. package/src/tx/builder/field-types/array.ts +19 -0
  311. package/src/tx/builder/field-types/boolean.ts +9 -0
  312. package/src/tx/builder/field-types/coin-amount.ts +4 -9
  313. package/src/tx/builder/field-types/ct-version.ts +50 -0
  314. package/src/tx/builder/field-types/deposit.ts +1 -1
  315. package/src/tx/builder/field-types/encoded.ts +27 -0
  316. package/src/tx/builder/field-types/entry.ts +31 -0
  317. package/src/tx/builder/field-types/enumeration.ts +32 -0
  318. package/src/tx/builder/field-types/fee.ts +39 -21
  319. package/src/tx/builder/field-types/gas-limit.ts +13 -8
  320. package/src/tx/builder/field-types/gas-price.ts +0 -2
  321. package/src/tx/builder/field-types/index.ts +54 -15
  322. package/src/tx/builder/field-types/mptree.ts +242 -0
  323. package/src/tx/builder/field-types/name-fee.ts +2 -3
  324. package/src/tx/builder/field-types/name-id.ts +7 -10
  325. package/src/tx/builder/field-types/pointers.ts +41 -0
  326. package/src/tx/builder/field-types/raw.ts +9 -0
  327. package/src/tx/builder/field-types/short-u-int-const.ts +20 -0
  328. package/src/tx/builder/field-types/string.ts +11 -0
  329. package/src/tx/builder/field-types/u-int.ts +4 -5
  330. package/src/tx/builder/helpers.ts +10 -60
  331. package/src/tx/builder/index.ts +65 -308
  332. package/src/tx/builder/schema.ts +280 -341
  333. package/src/tx/index.ts +40 -103
  334. package/src/tx/validator.ts +91 -96
  335. package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
  336. package/src/utils/autorest.ts +16 -1
  337. package/src/utils/bytes.ts +6 -34
  338. package/src/utils/crypto.ts +23 -16
  339. package/src/utils/encoder.ts +0 -1
  340. package/src/utils/errors.ts +22 -25
  341. package/src/utils/hd-wallet.ts +30 -9
  342. package/src/utils/keystore.ts +24 -21
  343. package/src/utils/other.ts +16 -1
  344. package/src/utils/string.ts +0 -20
  345. package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
  346. package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
  347. package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
  348. package/types-legacy/ts4.2/AeSdkMethods.d.ts +140 -0
  349. package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
  350. package/types-legacy/ts4.2/Node.d.ts +78 -0
  351. package/types-legacy/ts4.2/account/Base.d.ts +52 -0
  352. package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
  353. package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
  354. package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
  355. package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
  356. package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
  357. package/types-legacy/ts4.2/aens.d.ts +222 -0
  358. package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  359. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
  360. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  361. package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  362. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  363. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
  364. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
  365. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  366. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
  367. package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
  368. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
  369. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
  370. package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
  371. package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
  372. package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
  373. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
  374. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
  375. package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
  376. package/types-legacy/ts4.2/chain.d.ts +256 -0
  377. package/types-legacy/ts4.2/channel/Base.d.ts +199 -0
  378. package/types-legacy/ts4.2/channel/Contract.d.ts +248 -0
  379. package/types-legacy/ts4.2/channel/Spend.d.ts +219 -0
  380. package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
  381. package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
  382. package/types-legacy/ts4.2/contract/Contract.d.ts +212 -0
  383. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +81 -0
  384. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
  385. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
  386. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
  387. package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
  388. package/types-legacy/ts4.2/contract/ga.d.ts +44 -0
  389. package/types-legacy/ts4.2/globals.d.ts +16 -0
  390. package/types-legacy/ts4.2/index-browser.d.ts +39 -0
  391. package/types-legacy/ts4.2/index.d.ts +5 -0
  392. package/types-legacy/ts4.2/oracle.d.ts +161 -0
  393. package/types-legacy/ts4.2/spend.d.ts +62 -0
  394. package/types-legacy/ts4.2/tx/builder/constants.d.ts +98 -0
  395. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +10 -0
  396. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +21 -0
  397. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
  398. package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
  399. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
  400. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +42 -0
  401. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
  402. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
  403. package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
  404. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +7 -0
  405. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +20 -0
  406. package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
  407. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +15 -0
  408. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
  409. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +129 -0
  410. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +43 -0
  411. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +18 -0
  412. package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
  413. package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
  414. package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
  415. package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
  416. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  417. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
  418. package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
  419. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +7 -0
  420. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
  421. package/types-legacy/ts4.2/tx/builder/index.d.ts +50 -0
  422. package/types-legacy/ts4.2/tx/builder/schema.d.ts +4675 -0
  423. package/types-legacy/ts4.2/tx/index.d.ts +19 -0
  424. package/types-legacy/ts4.2/tx/validator.d.ts +18 -0
  425. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
  426. package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
  427. package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
  428. package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
  429. package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
  430. package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
  431. package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
  432. package/types-legacy/ts4.2/utils/errors.d.ts +475 -0
  433. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
  434. package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
  435. package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
  436. package/types-legacy/ts4.2/utils/other.d.ts +31 -0
  437. package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
  438. package/types-legacy/ts4.2/utils/string.d.ts +12 -0
  439. package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
  440. package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
  441. package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
  442. package/types-legacy/ts4.5/AeSdkMethods.d.ts +140 -0
  443. package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
  444. package/types-legacy/ts4.5/Node.d.ts +78 -0
  445. package/types-legacy/ts4.5/account/Base.d.ts +52 -0
  446. package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
  447. package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
  448. package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
  449. package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
  450. package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
  451. package/types-legacy/ts4.5/aens.d.ts +222 -0
  452. package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  453. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
  454. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  455. package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  456. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  457. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
  458. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
  459. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  460. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
  461. package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
  462. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
  463. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
  464. package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
  465. package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
  466. package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
  467. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
  468. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
  469. package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
  470. package/types-legacy/ts4.5/chain.d.ts +256 -0
  471. package/types-legacy/ts4.5/channel/Base.d.ts +199 -0
  472. package/types-legacy/ts4.5/channel/Contract.d.ts +248 -0
  473. package/types-legacy/ts4.5/channel/Spend.d.ts +219 -0
  474. package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
  475. package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
  476. package/types-legacy/ts4.5/contract/Contract.d.ts +212 -0
  477. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +81 -0
  478. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
  479. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
  480. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
  481. package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
  482. package/types-legacy/ts4.5/contract/ga.d.ts +44 -0
  483. package/types-legacy/ts4.5/index-browser.d.ts +39 -0
  484. package/types-legacy/ts4.5/index.d.ts +4 -0
  485. package/types-legacy/ts4.5/oracle.d.ts +161 -0
  486. package/types-legacy/ts4.5/spend.d.ts +62 -0
  487. package/types-legacy/ts4.5/tx/builder/constants.d.ts +98 -0
  488. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +10 -0
  489. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +21 -0
  490. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
  491. package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
  492. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
  493. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +42 -0
  494. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
  495. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
  496. package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
  497. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +7 -0
  498. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +20 -0
  499. package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
  500. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +15 -0
  501. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
  502. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +129 -0
  503. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +43 -0
  504. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +18 -0
  505. package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
  506. package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
  507. package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
  508. package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
  509. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  510. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
  511. package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
  512. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +7 -0
  513. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
  514. package/types-legacy/ts4.5/tx/builder/index.d.ts +50 -0
  515. package/types-legacy/ts4.5/tx/builder/schema.d.ts +4675 -0
  516. package/types-legacy/ts4.5/tx/index.d.ts +19 -0
  517. package/types-legacy/ts4.5/tx/validator.d.ts +18 -0
  518. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
  519. package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
  520. package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
  521. package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
  522. package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
  523. package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
  524. package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
  525. package/types-legacy/ts4.5/utils/errors.d.ts +475 -0
  526. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
  527. package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
  528. package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
  529. package/types-legacy/ts4.5/utils/other.d.ts +31 -0
  530. package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
  531. package/types-legacy/ts4.5/utils/string.d.ts +12 -0
  532. package/es/channel/index.d.ts +0 -625
  533. package/es/channel/index.mjs +0 -975
  534. package/es/channel/index.mjs.map +0 -1
  535. package/es/contract/Compiler.d.ts +0 -18
  536. package/es/contract/Compiler.mjs +0 -68
  537. package/es/contract/Compiler.mjs.map +0 -1
  538. package/es/contract/aci.d.ts +0 -127
  539. package/es/contract/aci.mjs +0 -508
  540. package/es/contract/aci.mjs.map +0 -1
  541. package/es/contract/methods.d.ts +0 -71
  542. package/es/contract/methods.mjs +0 -104
  543. package/es/contract/methods.mjs.map +0 -1
  544. package/es/deprecated/index.d.ts +0 -143
  545. package/es/deprecated/index.mjs +0 -162
  546. package/es/deprecated/index.mjs.map +0 -1
  547. package/es/deprecated/methods.d.ts +0 -18
  548. package/es/deprecated/methods.mjs +0 -26
  549. package/es/deprecated/methods.mjs.map +0 -1
  550. package/es/tx/builder/address.d.ts +0 -25
  551. package/es/tx/builder/address.mjs +0 -45
  552. package/es/tx/builder/address.mjs.map +0 -1
  553. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
  554. package/es/utils/mptree.d.ts +0 -26
  555. package/es/utils/mptree.mjs +0 -165
  556. package/es/utils/mptree.mjs.map +0 -1
  557. package/src/channel/index.ts +0 -1025
  558. package/src/contract/Compiler.ts +0 -67
  559. package/src/contract/aci.ts +0 -537
  560. package/src/contract/methods.ts +0 -123
  561. package/src/deprecated/index.ts +0 -172
  562. package/src/deprecated/methods.ts +0 -25
  563. package/src/tx/builder/address.ts +0 -50
  564. package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
  565. package/src/utils/mptree.ts +0 -145
@@ -0,0 +1,81 @@
1
+ import { Encoded } from '../../utils/encoder';
2
+ import { Aci as BaseAci } from '../../apis/compiler';
3
+ interface FunctionAci {
4
+ arguments: any[];
5
+ name: string;
6
+ payable: boolean;
7
+ returns: string;
8
+ stateful: boolean;
9
+ }
10
+ export interface Aci extends BaseAci {
11
+ encodedAci: {
12
+ contract: {
13
+ name: string;
14
+ event: any;
15
+ kind: string;
16
+ state: any;
17
+ type_defs: any[];
18
+ functions: FunctionAci[];
19
+ };
20
+ };
21
+ externalEncodedAci: any[];
22
+ }
23
+ /**
24
+ * A base class for all compiler implementations
25
+ */
26
+ export default abstract class CompilerBase {
27
+ /**
28
+ * Compile contract by contract's path
29
+ * Available only in Node.js
30
+ * @param path - Path to contract source code
31
+ * @returns ACI and bytecode
32
+ */
33
+ abstract compile(path: string): Promise<{
34
+ bytecode: Encoded.ContractBytearray;
35
+ aci: Aci;
36
+ }>;
37
+ /**
38
+ * Compile contract by contract's source code
39
+ * @param sourceCode - Contract source code as string
40
+ * @param fileSystem - A map of contract filename to the corresponding contract source code to
41
+ * include into the main contract
42
+ * @example
43
+ * ```js
44
+ * {
45
+ * 'library.aes': 'namespace TestLib =\n function sum(x: int, y: int) : int = x + y'
46
+ * }
47
+ * ```
48
+ * @returns ACI and bytecode
49
+ */
50
+ abstract compileBySourceCode(sourceCode: string, fileSystem?: Record<string, string>): Promise<{
51
+ bytecode: Encoded.ContractBytearray;
52
+ aci: Aci;
53
+ }>;
54
+ /**
55
+ * Verify that a contract bytecode is the result of compiling the given source code
56
+ * Available only in Node.js
57
+ * @param bytecode - Contract bytecode to verify
58
+ * @param path - Path to contract source code
59
+ * @returns ACI and bytecode
60
+ */
61
+ abstract validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean>;
62
+ /**
63
+ * Verify that a contract bytecode is the result of compiling the given source code
64
+ * @param bytecode - Contract bytecode to verify
65
+ * @param sourceCode - Contract source code as string
66
+ * @param fileSystem - A map of contract filename to the corresponding contract source code to
67
+ * include into the main contract
68
+ * @example
69
+ * ```js
70
+ * {
71
+ * 'library.aes': 'namespace TestLib =\n function sum(x: int, y: int) : int = x + y'
72
+ * }
73
+ * ```
74
+ */
75
+ abstract validateBySourceCode(bytecode: Encoded.ContractBytearray, sourceCode: string, fileSystem?: Record<string, string>): Promise<boolean>;
76
+ /**
77
+ * @returns Compiler version
78
+ */
79
+ abstract version(): Promise<string>;
80
+ }
81
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A base class for all compiler implementations
3
+ */
4
+ export default class CompilerBase {}
5
+ //# sourceMappingURL=Base.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Base.mjs","names":["CompilerBase"],"sources":["../../../src/contract/compiler/Base.ts"],"sourcesContent":["import { Encoded } from '../../utils/encoder';\nimport { Aci as BaseAci } from '../../apis/compiler';\n\ninterface FunctionAci {\n arguments: any[];\n name: string;\n payable: boolean;\n returns: string;\n stateful: boolean;\n}\n\nexport interface Aci extends BaseAci {\n encodedAci: {\n contract: {\n name: string;\n event: any;\n kind: string;\n state: any;\n type_defs: any[];\n functions: FunctionAci[];\n };\n };\n externalEncodedAci: any[];\n}\n\n/**\n * A base class for all compiler implementations\n */\nexport default abstract class CompilerBase {\n /**\n * Compile contract by contract's path\n * Available only in Node.js\n * @param path - Path to contract source code\n * @returns ACI and bytecode\n */\n abstract compile(path: string): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }>;\n\n /**\n * Compile contract by contract's source code\n * @param sourceCode - Contract source code as string\n * @param fileSystem - A map of contract filename to the corresponding contract source code to\n * include into the main contract\n * @example\n * ```js\n * {\n * 'library.aes': 'namespace TestLib =\\n function sum(x: int, y: int) : int = x + y'\n * }\n * ```\n * @returns ACI and bytecode\n */\n abstract compileBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }>;\n\n /**\n * Verify that a contract bytecode is the result of compiling the given source code\n * Available only in Node.js\n * @param bytecode - Contract bytecode to verify\n * @param path - Path to contract source code\n * @returns ACI and bytecode\n */\n abstract validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean>;\n\n /**\n * Verify that a contract bytecode is the result of compiling the given source code\n * @param bytecode - Contract bytecode to verify\n * @param sourceCode - Contract source code as string\n * @param fileSystem - A map of contract filename to the corresponding contract source code to\n * include into the main contract\n * @example\n * ```js\n * {\n * 'library.aes': 'namespace TestLib =\\n function sum(x: int, y: int) : int = x + y'\n * }\n * ```\n */\n abstract validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean>;\n\n /**\n * @returns Compiler version\n */\n abstract version(): Promise<string>;\n}\n"],"mappings":"AAyBA;AACA;AACA;AACA,eAAe,MAAeA,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ import CompilerBase, { Aci } from './Base';
2
+ import { Encoded } from '../../utils/encoder';
3
+ /**
4
+ * A wrapper around aesophia_cli, available only in Node.js
5
+ * Assumes that `escript` is available in PATH.
6
+ */
7
+ export default class CompilerCli extends CompilerBase {
8
+ #private;
9
+ constructor(compilerPath?: string, { ignoreVersion }?: {
10
+ ignoreVersion?: boolean;
11
+ });
12
+ compile(path: string): Promise<{
13
+ bytecode: Encoded.ContractBytearray;
14
+ aci: Aci;
15
+ }>;
16
+ compileBySourceCode(sourceCode: string, fileSystem?: Record<string, string>): Promise<{
17
+ bytecode: Encoded.ContractBytearray;
18
+ aci: Aci;
19
+ }>;
20
+ validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean>;
21
+ validateBySourceCode(bytecode: Encoded.ContractBytearray, sourceCode: string, fileSystem?: Record<string, string>): Promise<boolean>;
22
+ version(): Promise<string>;
23
+ }
@@ -0,0 +1,155 @@
1
+ import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
2
+ import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
3
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
4
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
5
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
6
+ function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
7
+ function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
8
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
9
+ import _child_process from 'child_process';
10
+ const {
11
+ execFile
12
+ } = _child_process;
13
+ import _os from 'os';
14
+ const {
15
+ tmpdir
16
+ } = _os;
17
+ import _path from 'path';
18
+ const {
19
+ resolve,
20
+ dirname,
21
+ basename
22
+ } = _path;
23
+ import _fsPromises from 'fs/promises';
24
+ const {
25
+ mkdir,
26
+ writeFile,
27
+ rm
28
+ } = _fsPromises;
29
+ import _url from 'url';
30
+ const {
31
+ fileURLToPath
32
+ } = _url;
33
+ import CompilerBase from "./Base.mjs";
34
+ import { CompilerError, InternalError, UnsupportedVersionError } from "../../utils/errors.mjs";
35
+ import semverSatisfies from "../../utils/semver-satisfies.mjs";
36
+ const getPackagePath = () => {
37
+ const path = dirname(fileURLToPath(import.meta.url));
38
+ if (basename(path) === 'dist') return resolve(path, '..');
39
+ if (basename(path) === 'compiler') return resolve(path, '../../..');
40
+ throw new InternalError('Can\'t get package path');
41
+ };
42
+
43
+ /**
44
+ * A wrapper around aesophia_cli, available only in Node.js
45
+ * Assumes that `escript` is available in PATH.
46
+ */
47
+ var _path2 = /*#__PURE__*/new WeakMap();
48
+ var _ensureCompatibleVersion = /*#__PURE__*/new WeakMap();
49
+ var _run = /*#__PURE__*/new WeakSet();
50
+ export default class CompilerCli extends CompilerBase {
51
+ constructor() {
52
+ let compilerPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : resolve(getPackagePath(), './bin/aesophia_cli');
53
+ let {
54
+ ignoreVersion
55
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
56
+ super();
57
+ _classPrivateMethodInitSpec(this, _run);
58
+ _classPrivateFieldInitSpec(this, _path2, {
59
+ writable: true,
60
+ value: void 0
61
+ });
62
+ _classPrivateFieldInitSpec(this, _ensureCompatibleVersion, {
63
+ writable: true,
64
+ value: void 0
65
+ });
66
+ _classPrivateFieldSet(this, _path2, compilerPath);
67
+ if (ignoreVersion !== true) {
68
+ _classPrivateFieldSet(this, _ensureCompatibleVersion, this.version().then(version => {
69
+ const versions = [version, '7.0.1', '8.0.0'];
70
+ if (!semverSatisfies(...versions)) throw new UnsupportedVersionError('compiler', ...versions);
71
+ }));
72
+ }
73
+ }
74
+ async compile(path) {
75
+ await _classPrivateFieldGet(this, _ensureCompatibleVersion);
76
+ let bytecode;
77
+ let aciCli;
78
+ try {
79
+ [bytecode, aciCli] = await Promise.all([_classPrivateMethodGet(this, _run, _run2).call(this, path), _classPrivateMethodGet(this, _run, _run2).call(this, '--create_json_aci', path).then(res => JSON.parse(res))]);
80
+ } catch (error) {
81
+ throw new CompilerError(error.message);
82
+ }
83
+ const aci = {
84
+ encodedAci: aciCli[0],
85
+ externalEncodedAci: aciCli.slice(1)
86
+ };
87
+ return {
88
+ bytecode: bytecode.trimEnd(),
89
+ aci: aci
90
+ };
91
+ }
92
+ async compileBySourceCode(sourceCode, fileSystem) {
93
+ const tmp = await _classStaticPrivateMethodGet(CompilerCli, CompilerCli, _saveContractToTmpDir).call(CompilerCli, sourceCode, fileSystem);
94
+ try {
95
+ return await this.compile(tmp);
96
+ } finally {
97
+ await rm(dirname(tmp), {
98
+ recursive: true
99
+ });
100
+ }
101
+ }
102
+ async validate(bytecode, path) {
103
+ await _classPrivateFieldGet(this, _ensureCompatibleVersion);
104
+ try {
105
+ return (await _classPrivateMethodGet(this, _run, _run2).call(this, path, '--validate', bytecode)).includes('Validation successful.');
106
+ } catch (error) {
107
+ return false;
108
+ }
109
+ }
110
+ async validateBySourceCode(bytecode, sourceCode, fileSystem) {
111
+ const tmp = await _classStaticPrivateMethodGet(CompilerCli, CompilerCli, _saveContractToTmpDir).call(CompilerCli, sourceCode, fileSystem);
112
+ try {
113
+ return await this.validate(bytecode, tmp);
114
+ } finally {
115
+ await rm(dirname(tmp), {
116
+ recursive: true
117
+ });
118
+ }
119
+ }
120
+ async version() {
121
+ var _verMessage$match;
122
+ const verMessage = await _classPrivateMethodGet(this, _run, _run2).call(this, '--version');
123
+ const ver = (_verMessage$match = verMessage.match(/Sophia compiler version ([\d.]+)\n/)) === null || _verMessage$match === void 0 ? void 0 : _verMessage$match[1];
124
+ if (ver == null) throw new CompilerError('Can\'t get compiler version');
125
+ return ver;
126
+ }
127
+ }
128
+ async function _run2() {
129
+ for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
130
+ parameters[_key] = arguments[_key];
131
+ }
132
+ return new Promise((pResolve, pReject) => {
133
+ execFile('escript', [_classPrivateFieldGet(this, _path2), ...parameters], (error, stdout, stderr) => {
134
+ if (error != null) pReject(error);else if (stderr !== '') pReject(new CompilerError(stderr));else pResolve(stdout);
135
+ });
136
+ });
137
+ }
138
+ async function _saveContractToTmpDir(sourceCode) {
139
+ let fileSystem = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
140
+ const randomName = () => Math.random().toString(36).slice(2);
141
+ const path = resolve(tmpdir(), `aepp-sdk-js-${randomName()}`);
142
+ await mkdir(path);
143
+ const sourceCodePath = resolve(path, `${randomName()}.aes`);
144
+ await writeFile(sourceCodePath, sourceCode);
145
+ await Promise.all(Object.entries(fileSystem).map(async _ref => {
146
+ let [name, src] = _ref;
147
+ const p = resolve(path, name);
148
+ await mkdir(dirname(p), {
149
+ recursive: true
150
+ });
151
+ return writeFile(p, src);
152
+ }));
153
+ return sourceCodePath;
154
+ }
155
+ //# sourceMappingURL=Cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cli.mjs","names":["CompilerBase","CompilerError","InternalError","UnsupportedVersionError","semverSatisfies","getPackagePath","path","dirname","fileURLToPath","import","meta","url","basename","resolve","CompilerCli","constructor","compilerPath","ignoreVersion","version","then","versions","compile","bytecode","aciCli","Promise","all","res","JSON","parse","error","message","aci","encodedAci","externalEncodedAci","slice","trimEnd","compileBySourceCode","sourceCode","fileSystem","tmp","rm","recursive","validate","includes","validateBySourceCode","verMessage","ver","match","parameters","pResolve","pReject","execFile","stdout","stderr","randomName","Math","random","toString","tmpdir","mkdir","sourceCodePath","writeFile","Object","entries","map","name","src","p"],"sources":["../../../src/contract/compiler/Cli.ts"],"sourcesContent":["import { execFile } from 'child_process';\nimport { tmpdir } from 'os';\nimport { resolve, dirname, basename } from 'path';\nimport { mkdir, writeFile, rm } from 'fs/promises';\nimport { fileURLToPath } from 'url';\nimport CompilerBase, { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport { CompilerError, InternalError, UnsupportedVersionError } from '../../utils/errors';\nimport semverSatisfies from '../../utils/semver-satisfies';\n\nconst getPackagePath = (): string => {\n const path = dirname(fileURLToPath(import.meta.url));\n if (basename(path) === 'dist') return resolve(path, '..');\n if (basename(path) === 'compiler') return resolve(path, '../../..');\n throw new InternalError('Can\\'t get package path');\n};\n\n/**\n * A wrapper around aesophia_cli, available only in Node.js\n * Assumes that `escript` is available in PATH.\n */\nexport default class CompilerCli extends CompilerBase {\n #path: string;\n\n #ensureCompatibleVersion: Promise<void>;\n\n constructor(\n compilerPath = resolve(getPackagePath(), './bin/aesophia_cli'),\n { ignoreVersion }: { ignoreVersion?: boolean } = {},\n ) {\n super();\n this.#path = compilerPath;\n if (ignoreVersion !== true) {\n this.#ensureCompatibleVersion = this.version().then((version) => {\n const versions = [version, '7.0.1', '8.0.0'] as const;\n if (!semverSatisfies(...versions)) throw new UnsupportedVersionError('compiler', ...versions);\n });\n }\n }\n\n async #run(...parameters: string[]): Promise<string> {\n return new Promise((pResolve, pReject) => {\n execFile('escript', [this.#path, ...parameters], (error, stdout, stderr) => {\n if (error != null) pReject(error);\n else if (stderr !== '') pReject(new CompilerError(stderr));\n else pResolve(stdout);\n });\n });\n }\n\n static async #saveContractToTmpDir(\n sourceCode: string,\n fileSystem: Record<string, string> = {},\n ): Promise<string> {\n const randomName = (): string => Math.random().toString(36).slice(2);\n const path = resolve(tmpdir(), `aepp-sdk-js-${randomName()}`);\n await mkdir(path);\n const sourceCodePath = resolve(path, `${randomName()}.aes`);\n await writeFile(sourceCodePath, sourceCode);\n await Promise.all(Object.entries(fileSystem)\n .map(async ([name, src]) => {\n const p = resolve(path, name);\n await mkdir(dirname(p), { recursive: true });\n return writeFile(p, src);\n }));\n return sourceCodePath;\n }\n\n async compile(path: string): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }> {\n await this.#ensureCompatibleVersion;\n let bytecode;\n let aciCli;\n try {\n [bytecode, aciCli] = await Promise.all([\n this.#run(path),\n this.#run('--create_json_aci', path).then((res) => JSON.parse(res)),\n ]);\n } catch (error) {\n throw new CompilerError(error.message);\n }\n const aci = {\n encodedAci: aciCli[0],\n externalEncodedAci: aciCli.slice(1),\n };\n return {\n bytecode: bytecode.trimEnd() as Encoded.ContractBytearray,\n aci: aci as Aci,\n };\n }\n\n async compileBySourceCode(sourceCode: string, fileSystem?: Record<string, string>): Promise<{\n bytecode: Encoded.ContractBytearray;\n aci: Aci;\n }> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.compile(tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n await this.#ensureCompatibleVersion;\n try {\n return (await this.#run(path, '--validate', bytecode)).includes('Validation successful.');\n } catch (error) {\n return false;\n }\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n const tmp = await CompilerCli.#saveContractToTmpDir(sourceCode, fileSystem);\n try {\n return await this.validate(bytecode, tmp);\n } finally {\n await rm(dirname(tmp), { recursive: true });\n }\n }\n\n async version(): Promise<string> {\n const verMessage = await this.#run('--version');\n const ver = verMessage.match(/Sophia compiler version ([\\d.]+)\\n/)?.[1];\n if (ver == null) throw new CompilerError('Can\\'t get compiler version');\n return ver;\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,32 @@
1
+ import { Compiler as CompilerApi } from '../../apis/compiler';
2
+ import CompilerBase, { Aci } from './Base';
3
+ import { Encoded } from '../../utils/encoder';
4
+ /**
5
+ * Contract Compiler over HTTP
6
+ *
7
+ * This class include api call's related to contract compiler functionality.
8
+ * @category contract
9
+ * @example CompilerHttp('COMPILER_URL')
10
+ */
11
+ export default class CompilerHttp extends CompilerBase {
12
+ readonly api: CompilerApi;
13
+ /**
14
+ * @param compilerUrl - Url for compiler API
15
+ * @param options - Options
16
+ * @param options.ignoreVersion - Don't check compiler version
17
+ */
18
+ constructor(compilerUrl: string, { ignoreVersion }?: {
19
+ ignoreVersion?: boolean;
20
+ });
21
+ compileBySourceCode(sourceCode: string, fileSystem?: Record<string, string>): Promise<{
22
+ bytecode: Encoded.ContractBytearray;
23
+ aci: Aci;
24
+ }>;
25
+ compile(path: string): Promise<{
26
+ bytecode: Encoded.ContractBytearray;
27
+ aci: Aci;
28
+ }>;
29
+ validateBySourceCode(bytecode: Encoded.ContractBytearray, sourceCode: string, fileSystem?: Record<string, string>): Promise<boolean>;
30
+ validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean>;
31
+ version(): Promise<string>;
32
+ }
@@ -0,0 +1,118 @@
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
+ import { RestError } from '@azure/core-rest-pipeline';
18
+ import { Compiler as CompilerApi } from "../../apis/compiler/index.mjs";
19
+ import { genErrorFormatterPolicy, genVersionCheckPolicy } from "../../utils/autorest.mjs";
20
+ import CompilerBase from "./Base.mjs";
21
+ import { CompilerError, NotImplementedError } from "../../utils/errors.mjs";
22
+ /**
23
+ * Contract Compiler over HTTP
24
+ *
25
+ * This class include api call's related to contract compiler functionality.
26
+ * @category contract
27
+ * @example CompilerHttp('COMPILER_URL')
28
+ */
29
+ export default class CompilerHttp extends CompilerBase {
30
+ /**
31
+ * @param compilerUrl - Url for compiler API
32
+ * @param options - Options
33
+ * @param options.ignoreVersion - Don't check compiler version
34
+ */
35
+ constructor(compilerUrl) {
36
+ let {
37
+ ignoreVersion
38
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
39
+ super();
40
+ this.api = new CompilerApi(compilerUrl, {
41
+ allowInsecureConnection: true,
42
+ additionalPolicies: [genErrorFormatterPolicy(body => {
43
+ let message = '';
44
+ if ('reason' in body) {
45
+ message += ` ${body.reason}${body.parameter != null ? ` in ${body.parameter}` : ''
46
+ // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78
47
+ }${body.info != null ? ` (${JSON.stringify(body.info)})` : ''}`;
48
+ }
49
+ if (Array.isArray(body)) {
50
+ message += `\n${body.map(e => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? `(${e.context})` : ''}`).join('\n')}`;
51
+ }
52
+ return message;
53
+ })]
54
+ });
55
+ if (ignoreVersion !== true) {
56
+ const versionPromise = this.api.apiVersion().then(_ref => {
57
+ let {
58
+ apiVersion
59
+ } = _ref;
60
+ return apiVersion;
61
+ });
62
+ this.api.pipeline.addPolicy(genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.0.1', '8.0.0'));
63
+ }
64
+ }
65
+ async compileBySourceCode(sourceCode, fileSystem) {
66
+ try {
67
+ const [bytecode, aci] = await Promise.all([this.api.compileContract({
68
+ code: sourceCode,
69
+ options: {
70
+ fileSystem
71
+ }
72
+ }).then(res => res.bytecode), this.api.generateACI({
73
+ code: sourceCode,
74
+ options: {
75
+ fileSystem
76
+ }
77
+ })]);
78
+ // TODO: should be fixed when the compiledAci interface gets updated
79
+ return {
80
+ bytecode,
81
+ aci: aci
82
+ };
83
+ } catch (error) {
84
+ if (error instanceof RestError && error.statusCode === 400) {
85
+ throw new CompilerError(error.message.replace(/^aci error:/, 'compile error:'));
86
+ }
87
+ throw error;
88
+ }
89
+ }
90
+
91
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
92
+ async compile(path) {
93
+ throw new NotImplementedError('File system access, use CompilerHttpNode instead');
94
+ }
95
+ async validateBySourceCode(bytecode, sourceCode, fileSystem) {
96
+ try {
97
+ await this.api.validateByteCode({
98
+ bytecode,
99
+ source: sourceCode,
100
+ options: {
101
+ fileSystem
102
+ }
103
+ });
104
+ return true;
105
+ } catch {
106
+ return false;
107
+ }
108
+ }
109
+
110
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
111
+ async validate(bytecode, path) {
112
+ throw new NotImplementedError('File system access, use CompilerHttpNode instead');
113
+ }
114
+ async version() {
115
+ return (await this.api.version()).version;
116
+ }
117
+ }
118
+ //# sourceMappingURL=Http.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Http.mjs","names":["RestError","Compiler","CompilerApi","genErrorFormatterPolicy","genVersionCheckPolicy","CompilerBase","CompilerError","NotImplementedError","CompilerHttp","constructor","compilerUrl","ignoreVersion","api","allowInsecureConnection","additionalPolicies","body","message","reason","parameter","info","JSON","stringify","Array","isArray","map","e","type","pos","line","col","context","join","versionPromise","apiVersion","then","pipeline","addPolicy","compileBySourceCode","sourceCode","fileSystem","bytecode","aci","Promise","all","compileContract","code","options","res","generateACI","error","statusCode","replace","compile","path","validateBySourceCode","validateByteCode","source","validate","version"],"sources":["../../../src/contract/compiler/Http.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 { RestError } from '@azure/core-rest-pipeline';\nimport {\n Compiler as CompilerApi,\n ErrorModel,\n CompilerError as CompilerErrorApi,\n} from '../../apis/compiler';\nimport { genErrorFormatterPolicy, genVersionCheckPolicy } from '../../utils/autorest';\nimport CompilerBase, { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport { CompilerError, NotImplementedError } from '../../utils/errors';\n\ntype GeneralCompilerError = ErrorModel & {\n info?: object;\n parameter?: string;\n};\n\n/**\n * Contract Compiler over HTTP\n *\n * This class include api call's related to contract compiler functionality.\n * @category contract\n * @example CompilerHttp('COMPILER_URL')\n */\nexport default class CompilerHttp extends CompilerBase {\n readonly api: CompilerApi;\n\n /**\n * @param compilerUrl - Url for compiler API\n * @param options - Options\n * @param options.ignoreVersion - Don't check compiler version\n */\n constructor(compilerUrl: string, { ignoreVersion }: { ignoreVersion?: boolean } = {}) {\n super();\n this.api = new CompilerApi(compilerUrl, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genErrorFormatterPolicy((body: GeneralCompilerError | CompilerErrorApi[]) => {\n let message = '';\n if ('reason' in body) {\n message += ` ${body.reason\n }${body.parameter != null ? ` in ${body.parameter}` : ''\n // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78\n }${body.info != null ? ` (${JSON.stringify(body.info)})` : ''}`;\n }\n if (Array.isArray(body)) {\n message += `\\n${body\n .map((e) => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? `(${e.context})` : ''}`)\n .join('\\n')}`;\n }\n return message;\n }),\n ],\n });\n if (ignoreVersion !== true) {\n const versionPromise = this.api.apiVersion().then(({ apiVersion }) => apiVersion);\n this.api.pipeline.addPolicy(\n genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.0.1', '8.0.0'),\n );\n }\n }\n\n async compileBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n try {\n const [bytecode, aci] = await Promise.all([\n this.api.compileContract({ code: sourceCode, options: { fileSystem } })\n .then((res) => res.bytecode as Encoded.ContractBytearray),\n this.api.generateACI({ code: sourceCode, options: { fileSystem } }),\n ]);\n // TODO: should be fixed when the compiledAci interface gets updated\n return { bytecode, aci: aci as Aci };\n } catch (error) {\n if (error instanceof RestError && error.statusCode === 400) {\n throw new CompilerError(error.message.replace(/^aci error:/, 'compile error:'));\n }\n throw error;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async compile(path: string): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n try {\n await this.api.validateByteCode({ bytecode, source: sourceCode, options: { fileSystem } });\n return true;\n } catch {\n return false;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async version(): Promise<string> {\n return (await this.api.version()).version;\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,17 @@
1
+ import HttpBrowser from './Http';
2
+ import { Aci } from './Base';
3
+ import { Encoded } from '../../utils/encoder';
4
+ /**
5
+ * Contract Compiler over HTTP for Nodejs
6
+ *
7
+ * Inherits CompilerHttp and implements `compile`, `validate` methods
8
+ * @category contract
9
+ * @example CompilerHttpNode('COMPILER_URL')
10
+ */
11
+ export default class CompilerHttpNode extends HttpBrowser {
12
+ compile(path: string): Promise<{
13
+ bytecode: Encoded.ContractBytearray;
14
+ aci: Aci;
15
+ }>;
16
+ validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean>;
17
+ }
@@ -0,0 +1,26 @@
1
+ import _fsPromises from 'fs/promises';
2
+ const {
3
+ readFile
4
+ } = _fsPromises;
5
+ import HttpBrowser from "./Http.mjs";
6
+ import getFileSystem from "./getFileSystem.mjs";
7
+ /**
8
+ * Contract Compiler over HTTP for Nodejs
9
+ *
10
+ * Inherits CompilerHttp and implements `compile`, `validate` methods
11
+ * @category contract
12
+ * @example CompilerHttpNode('COMPILER_URL')
13
+ */
14
+ export default class CompilerHttpNode extends HttpBrowser {
15
+ async compile(path) {
16
+ const fileSystem = await getFileSystem(path);
17
+ const sourceCode = await readFile(path, 'utf8');
18
+ return this.compileBySourceCode(sourceCode, fileSystem);
19
+ }
20
+ async validate(bytecode, path) {
21
+ const fileSystem = await getFileSystem(path);
22
+ const sourceCode = await readFile(path, 'utf8');
23
+ return this.validateBySourceCode(bytecode, sourceCode, fileSystem);
24
+ }
25
+ }
26
+ //# sourceMappingURL=HttpNode.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpNode.mjs","names":["HttpBrowser","getFileSystem","CompilerHttpNode","compile","path","fileSystem","sourceCode","readFile","compileBySourceCode","validate","bytecode","validateBySourceCode"],"sources":["../../../src/contract/compiler/HttpNode.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport HttpBrowser from './Http';\nimport { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport getFileSystem from './getFileSystem';\n\n/**\n * Contract Compiler over HTTP for Nodejs\n *\n * Inherits CompilerHttp and implements `compile`, `validate` methods\n * @category contract\n * @example CompilerHttpNode('COMPILER_URL')\n */\nexport default class CompilerHttpNode extends HttpBrowser {\n override async compile(path: string): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.compileBySourceCode(sourceCode, fileSystem);\n }\n\n override async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.validateBySourceCode(bytecode, sourceCode, fileSystem);\n }\n}\n"],"mappings":"AAAA,wBAAyB,aAAa;AAAC;EAAA;AAAA;AAAA,OAChCA,WAAW;AAAA,OAGXC,aAAa;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASF,WAAW,CAAC;EACxD,MAAeG,OAAO,CAACC,IAAY,EAA8D;IAC/F,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMC,QAAQ,CAACH,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACI,mBAAmB,CAACF,UAAU,EAAED,UAAU,CAAC;EACzD;EAEA,MAAeI,QAAQ,CAACC,QAAmC,EAAEN,IAAY,EAAoB;IAC3F,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMC,QAAQ,CAACH,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACO,oBAAoB,CAACD,QAAQ,EAAEJ,UAAU,EAAED,UAAU,CAAC;EACpE;AACF"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Reads all files included in the provided contract
3
+ * Available only in Node.js
4
+ * @param path - a path to the main contract source code
5
+ */
6
+ export default function getFileSystem(path: string): Promise<Record<string, string>>;
@@ -0,0 +1,40 @@
1
+ import _flagsInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flags";
2
+ import _fsPromises from 'fs/promises';
3
+ const {
4
+ readFile
5
+ } = _fsPromises;
6
+ import _path from 'path';
7
+ const {
8
+ dirname,
9
+ resolve,
10
+ basename
11
+ } = _path;
12
+ import { InternalError } from "../../utils/errors.mjs";
13
+ const defaultIncludes = ['List.aes', 'Option.aes', 'String.aes', 'Func.aes', 'Pair.aes', 'Triple.aes', 'BLS12_381.aes', 'Frac.aes', 'Set.aes', 'Bitwise.aes'];
14
+ const includeRegExp = /^include\s*"([\w/.-]+)"/mi;
15
+ const includesRegExp = new RegExp(includeRegExp.source, `${_flagsInstanceProperty(includeRegExp)}g`);
16
+ async function getFileSystemRec(root, relative) {
17
+ var _sourceCode$match;
18
+ const sourceCode = await readFile(resolve(root, relative), 'utf8');
19
+ const filesystem = {};
20
+ await Promise.all(((_sourceCode$match = sourceCode.match(includesRegExp)) !== null && _sourceCode$match !== void 0 ? _sourceCode$match : []).map(include => {
21
+ const m = include.match(includeRegExp);
22
+ if ((m === null || m === void 0 ? void 0 : m.length) !== 2) throw new InternalError('Unexpected match length');
23
+ return m[1];
24
+ }).filter(include => !defaultIncludes.includes(include)).map(async include => {
25
+ const includePath = resolve(root, include);
26
+ filesystem[include] = await readFile(includePath, 'utf8');
27
+ Object.assign(filesystem, await getFileSystemRec(root, include));
28
+ }));
29
+ return filesystem;
30
+ }
31
+
32
+ /**
33
+ * Reads all files included in the provided contract
34
+ * Available only in Node.js
35
+ * @param path - a path to the main contract source code
36
+ */
37
+ export default async function getFileSystem(path) {
38
+ return getFileSystemRec(dirname(path), basename(path));
39
+ }
40
+ //# sourceMappingURL=getFileSystem.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFileSystem.mjs","names":["InternalError","defaultIncludes","includeRegExp","includesRegExp","RegExp","source","getFileSystemRec","root","relative","sourceCode","readFile","resolve","filesystem","Promise","all","match","map","include","m","length","filter","includes","includePath","Object","assign","getFileSystem","path","dirname","basename"],"sources":["../../../src/contract/compiler/getFileSystem.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { dirname, resolve, basename } from 'path';\nimport { InternalError } from '../../utils/errors';\n\nconst defaultIncludes = [\n 'List.aes', 'Option.aes', 'String.aes',\n 'Func.aes', 'Pair.aes', 'Triple.aes',\n 'BLS12_381.aes', 'Frac.aes', 'Set.aes',\n 'Bitwise.aes',\n];\nconst includeRegExp = /^include\\s*\"([\\w/.-]+)\"/mi;\nconst includesRegExp = new RegExp(includeRegExp.source, `${includeRegExp.flags}g`);\n\nasync function getFileSystemRec(\n root: string,\n relative: string,\n): Promise<Record<string, string>> {\n const sourceCode = await readFile(resolve(root, relative), 'utf8');\n const filesystem: Record<string, string> = {};\n await Promise.all((sourceCode.match(includesRegExp) ?? [])\n .map((include) => {\n const m = include.match(includeRegExp);\n if (m?.length !== 2) throw new InternalError('Unexpected match length');\n return m[1];\n })\n .filter((include) => !defaultIncludes.includes(include))\n .map(async (include) => {\n const includePath = resolve(root, include);\n filesystem[include] = await readFile(includePath, 'utf8');\n Object.assign(filesystem, await getFileSystemRec(root, include));\n }));\n return filesystem;\n}\n\n/**\n * Reads all files included in the provided contract\n * Available only in Node.js\n * @param path - a path to the main contract source code\n */\nexport default async function getFileSystem(path: string): Promise<Record<string, string>> {\n return getFileSystemRec(dirname(path), basename(path));\n}\n"],"mappings":";AAAA,wBAAyB,aAAa;AAAC;EAAA;AAAA;AACvC,kBAA2C,MAAM;AAAC;EAAA;EAAA;EAAA;AAAA;AAAA,SACzCA,aAAa;AAEtB,MAAMC,eAAe,GAAG,CACtB,UAAU,EAAE,YAAY,EAAE,YAAY,EACtC,UAAU,EAAE,UAAU,EAAE,YAAY,EACpC,eAAe,EAAE,UAAU,EAAE,SAAS,EACtC,aAAa,CACd;AACD,MAAMC,aAAa,GAAG,2BAA2B;AACjD,MAAMC,cAAc,GAAG,IAAIC,MAAM,CAACF,aAAa,CAACG,MAAM,EAAG,0BAAEH,aAAa,CAAO,GAAE,CAAC;AAElF,eAAeI,gBAAgB,CAC7BC,IAAY,EACZC,QAAgB,EACiB;EAAA;EACjC,MAAMC,UAAU,GAAG,MAAMC,QAAQ,CAACC,OAAO,CAACJ,IAAI,EAAEC,QAAQ,CAAC,EAAE,MAAM,CAAC;EAClE,MAAMI,UAAkC,GAAG,CAAC,CAAC;EAC7C,MAAMC,OAAO,CAACC,GAAG,CAAC,sBAACL,UAAU,CAACM,KAAK,CAACZ,cAAc,CAAC,iEAAI,EAAE,EACtDa,GAAG,CAAEC,OAAO,IAAK;IAChB,MAAMC,CAAC,GAAGD,OAAO,CAACF,KAAK,CAACb,aAAa,CAAC;IACtC,IAAI,CAAAgB,CAAC,aAADA,CAAC,uBAADA,CAAC,CAAEC,MAAM,MAAK,CAAC,EAAE,MAAM,IAAInB,aAAa,CAAC,yBAAyB,CAAC;IACvE,OAAOkB,CAAC,CAAC,CAAC,CAAC;EACb,CAAC,CAAC,CACDE,MAAM,CAAEH,OAAO,IAAK,CAAChB,eAAe,CAACoB,QAAQ,CAACJ,OAAO,CAAC,CAAC,CACvDD,GAAG,CAAC,MAAOC,OAAO,IAAK;IACtB,MAAMK,WAAW,GAAGX,OAAO,CAACJ,IAAI,EAAEU,OAAO,CAAC;IAC1CL,UAAU,CAACK,OAAO,CAAC,GAAG,MAAMP,QAAQ,CAACY,WAAW,EAAE,MAAM,CAAC;IACzDC,MAAM,CAACC,MAAM,CAACZ,UAAU,EAAE,MAAMN,gBAAgB,CAACC,IAAI,EAAEU,OAAO,CAAC,CAAC;EAClE,CAAC,CAAC,CAAC;EACL,OAAOL,UAAU;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAea,aAAa,CAACC,IAAY,EAAmC;EACzF,OAAOpB,gBAAgB,CAACqB,OAAO,CAACD,IAAI,CAAC,EAAEE,QAAQ,CAACF,IAAI,CAAC,CAAC;AACxD"}
@@ -1,60 +1,35 @@
1
+ /**
2
+ * Generalized Account module - routines to use generalized account
3
+ */
1
4
  import { Tag } from '../tx/builder/constants';
2
5
  import { BuildTxOptions } from '../tx';
3
6
  import { Encoded } from '../utils/encoder';
4
7
  import AccountBase from '../account/Base';
8
+ import Contract from './Contract';
5
9
  import { SendOptions } from '../spend';
6
10
  import Node from '../Node';
7
- import { getAccount } from '../chain';
8
- import Compiler from './Compiler';
9
- /**
10
- * Check if account is GA
11
- * @category contract
12
- * @param address - Account address
13
- * @param options - Options
14
- * @returns if account is GA
15
- */
16
- export declare function isGA(address: Encoded.AccountAddress, options: Parameters<typeof getAccount>[1]): Promise<boolean>;
11
+ import CompilerBase from './compiler/Base';
17
12
  /**
18
13
  * Convert current account to GA
19
14
  * @category contract
20
15
  * @param authFnName - Authorization function name
21
- * @param source - Auth contract source code
16
+ * @param sourceCode - Auth contract source code
22
17
  * @param args - init arguments
23
18
  * @param options - Options
24
19
  * @returns General Account Object
25
20
  */
26
- export declare function createGeneralizedAccount(authFnName: string, source: string, args: any[], { onAccount, onCompiler, onNode, ...options }: CreateGeneralizedAccountOptions): Promise<Readonly<{
21
+ export declare function createGeneralizedAccount(authFnName: string, args: any[], { onAccount, onCompiler, onNode, bytecode, aci, sourceCodePath, sourceCode, fileSystem, ...options }: CreateGeneralizedAccountOptions): Promise<Readonly<{
27
22
  owner: Encoded.AccountAddress;
28
23
  transaction: Encoded.TxHash;
29
24
  rawTx: Encoded.Transaction;
30
25
  gaContractId: Encoded.ContractAddress;
31
26
  }>>;
32
- interface CreateGeneralizedAccountOptions extends BuildTxOptions<Tag.GaAttachTx, 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit'>, SendOptions {
27
+ interface CreateGeneralizedAccountOptions extends BuildTxOptions<Tag.GaAttachTx, 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit'>, SendOptions, Pick<Parameters<typeof Contract.initialize>[0], 'bytecode' | 'aci' | 'sourceCodePath' | 'sourceCode' | 'fileSystem'> {
33
28
  onAccount: AccountBase;
34
- onCompiler: Compiler;
29
+ onCompiler: CompilerBase;
35
30
  onNode: Node;
36
31
  gasLimit?: number;
37
32
  }
38
- /**
39
- * Create a metaTx transaction
40
- * @category contract
41
- * @param rawTransaction - Inner transaction
42
- * @param authData - Object with gaMeta params
43
- * @param authFnName - Authorization function name
44
- * @param options - Options
45
- * @param options.onAccount - Account to use
46
- * @returns Transaction string
47
- */
48
- export declare function createMetaTx(rawTransaction: Encoded.Transaction, authData: {
49
- gasLimit?: number;
50
- callData?: Encoded.ContractBytearray;
51
- source?: string;
52
- args?: any[];
53
- }, authFnName: string, { onAccount, onCompiler, onNode, ...options }: {
54
- onAccount: AccountBase;
55
- onCompiler: Compiler;
56
- onNode: Node;
57
- } & Parameters<AccountBase['address']>[0]): Promise<Encoded.Transaction>;
58
33
  /**
59
34
  * Build a transaction hash the same as `Auth.tx_hash`
60
35
  * @category contract