@aeternity/aepp-sdk 10.0.0 → 12.0.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 (424) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -14
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +13 -40
  5. package/dist/aepp-sdk.browser-script.js.map +1 -1
  6. package/dist/aepp-sdk.browser.js +1 -1
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +1 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/AeSdk.d.ts +37 -0
  11. package/es/AeSdk.mjs +81 -0
  12. package/es/AeSdk.mjs.map +1 -0
  13. package/es/AeSdkAepp.d.ts +69 -0
  14. package/es/AeSdkAepp.mjs +175 -0
  15. package/es/AeSdkAepp.mjs.map +1 -0
  16. package/es/AeSdkBase.d.ts +212 -0
  17. package/es/AeSdkBase.mjs +310 -0
  18. package/es/AeSdkBase.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +103 -0
  20. package/es/AeSdkWallet.mjs +322 -0
  21. package/es/AeSdkWallet.mjs.map +1 -0
  22. package/es/Node.d.ts +44 -0
  23. package/es/Node.mjs +141 -0
  24. package/es/Node.mjs.map +1 -0
  25. package/es/account/Base.d.ts +65 -0
  26. package/es/account/Base.mjs +123 -0
  27. package/es/account/Base.mjs.map +1 -0
  28. package/es/account/Memory.d.ts +25 -0
  29. package/es/account/Memory.mjs +81 -0
  30. package/es/account/Memory.mjs.map +1 -0
  31. package/es/account/Rpc.d.ts +27 -0
  32. package/es/account/Rpc.mjs +79 -0
  33. package/es/account/Rpc.mjs.map +1 -0
  34. package/es/aens.d.ts +209 -0
  35. package/es/aens.mjs +332 -0
  36. package/es/aens.mjs.map +1 -0
  37. package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
  39. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
  42. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
  45. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
  47. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
  48. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  51. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  52. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  54. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  55. package/es/aepp-wallet-communication/schema.d.ts +118 -0
  56. package/es/aepp-wallet-communication/schema.mjs +214 -0
  57. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  58. package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs +63 -0
  60. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  61. package/es/apis/compiler/compiler.d.ts +92 -0
  62. package/es/apis/compiler/compiler.mjs +576 -0
  63. package/es/apis/compiler/compiler.mjs.map +1 -0
  64. package/es/apis/compiler/index.d.ts +2 -0
  65. package/es/apis/compiler/index.mjs +3 -0
  66. package/es/apis/compiler/index.mjs.map +1 -0
  67. package/es/apis/compiler/models/index.d.ts +248 -0
  68. package/es/apis/compiler/models/index.mjs +48 -0
  69. package/es/apis/compiler/models/index.mjs.map +1 -0
  70. package/es/apis/compiler/models/mappers.d.ts +23 -0
  71. package/es/apis/compiler/models/mappers.mjs +585 -0
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  73. package/es/apis/compiler/models/parameters.d.ts +13 -0
  74. package/es/apis/compiler/models/parameters.mjs +71 -0
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  76. package/es/apis/node/index.d.ts +2 -0
  77. package/es/apis/node/index.mjs +3 -0
  78. package/es/apis/node/index.mjs.map +1 -0
  79. package/es/apis/node/models/index.d.ts +1061 -0
  80. package/es/apis/node/models/index.mjs +2 -0
  81. package/es/apis/node/models/index.mjs.map +1 -0
  82. package/es/apis/node/models/mappers.d.ts +95 -0
  83. package/es/apis/node/models/mappers.mjs +4164 -0
  84. package/es/apis/node/models/mappers.mjs.map +1 -0
  85. package/es/apis/node/models/parameters.d.ts +17 -0
  86. package/es/apis/node/models/parameters.mjs +165 -0
  87. package/es/apis/node/models/parameters.mjs.map +1 -0
  88. package/es/apis/node/node.d.ts +215 -0
  89. package/es/apis/node/node.mjs +1165 -0
  90. package/es/apis/node/node.mjs.map +1 -0
  91. package/es/chain.d.ts +220 -0
  92. package/es/chain.mjs +524 -0
  93. package/es/chain.mjs.map +1 -0
  94. package/es/channel/handlers.d.ts +34 -0
  95. package/es/channel/{handlers.js → handlers.mjs} +163 -130
  96. package/es/channel/handlers.mjs.map +1 -0
  97. package/es/channel/index.d.ts +634 -0
  98. package/es/channel/index.mjs +978 -0
  99. package/es/channel/index.mjs.map +1 -0
  100. package/es/channel/internal.d.ts +100 -0
  101. package/es/channel/internal.mjs +328 -0
  102. package/es/channel/internal.mjs.map +1 -0
  103. package/es/contract/Compiler.d.ts +17 -0
  104. package/es/contract/Compiler.mjs +67 -0
  105. package/es/contract/Compiler.mjs.map +1 -0
  106. package/es/contract/aci.d.ts +125 -0
  107. package/es/contract/aci.mjs +496 -0
  108. package/es/contract/aci.mjs.map +1 -0
  109. package/es/contract/ga.d.ts +68 -0
  110. package/es/contract/ga.mjs +190 -0
  111. package/es/contract/ga.mjs.map +1 -0
  112. package/es/contract/methods.d.ts +68 -0
  113. package/es/contract/methods.mjs +101 -0
  114. package/es/contract/methods.mjs.map +1 -0
  115. package/es/index.d.ts +32 -0
  116. package/es/index.mjs +49 -0
  117. package/es/index.mjs.map +1 -0
  118. package/es/oracle.d.ts +154 -0
  119. package/es/oracle.mjs +288 -0
  120. package/es/oracle.mjs.map +1 -0
  121. package/es/spend.d.ts +61 -0
  122. package/es/spend.mjs +122 -0
  123. package/es/spend.mjs.map +1 -0
  124. package/es/tx/builder/constants.d.ts +41 -0
  125. package/es/tx/builder/constants.mjs +100 -0
  126. package/es/tx/builder/constants.mjs.map +1 -0
  127. package/es/tx/builder/field-types.d.ts +62 -0
  128. package/es/tx/builder/field-types.mjs +126 -0
  129. package/es/tx/builder/field-types.mjs.map +1 -0
  130. package/es/tx/builder/helpers.d.ts +131 -0
  131. package/es/tx/builder/helpers.mjs +223 -0
  132. package/es/tx/builder/helpers.mjs.map +1 -0
  133. package/es/tx/builder/index.d.ts +75 -0
  134. package/es/tx/builder/index.mjs +424 -0
  135. package/es/tx/builder/index.mjs.map +1 -0
  136. package/es/tx/builder/schema.d.ts +350 -0
  137. package/es/tx/builder/schema.mjs +320 -0
  138. package/es/tx/builder/schema.mjs.map +1 -0
  139. package/es/tx/index.d.ts +63 -0
  140. package/es/tx/index.mjs +209 -0
  141. package/es/tx/index.mjs.map +1 -0
  142. package/es/tx/min-fee.d.ts +20 -0
  143. package/es/tx/min-fee.mjs +148 -0
  144. package/es/tx/min-fee.mjs.map +1 -0
  145. package/es/tx/validator.d.ts +19 -0
  146. package/es/tx/validator.mjs +240 -0
  147. package/es/tx/validator.mjs.map +1 -0
  148. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  149. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  150. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  151. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  152. package/es/typings/bip32-path/index.d.mjs +2 -0
  153. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  154. package/es/typings/blakejs/index.d.mjs +2 -0
  155. package/es/typings/blakejs/index.d.mjs.map +1 -0
  156. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  157. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  158. package/es/utils/amount-formatter.d.ts +42 -0
  159. package/es/utils/{amount-formatter.js → amount-formatter.mjs} +38 -44
  160. package/es/utils/amount-formatter.mjs.map +1 -0
  161. package/es/utils/autorest.d.ts +6 -0
  162. package/es/utils/autorest.mjs +97 -0
  163. package/es/utils/autorest.mjs.map +1 -0
  164. package/es/utils/bignumber.d.ts +13 -0
  165. package/es/utils/bignumber.mjs +23 -0
  166. package/es/utils/bignumber.mjs.map +1 -0
  167. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  168. package/es/utils/{bytes.js → bytes.mjs} +26 -22
  169. package/es/utils/bytes.mjs.map +1 -0
  170. package/es/utils/crypto.d.ts +103 -0
  171. package/es/utils/crypto.mjs +221 -0
  172. package/es/utils/crypto.mjs.map +1 -0
  173. package/es/utils/encoder.d.ts +26 -0
  174. package/es/utils/encoder.mjs +102 -0
  175. package/es/utils/encoder.mjs.map +1 -0
  176. package/es/utils/errors.d.ts +481 -0
  177. package/es/utils/errors.mjs +882 -0
  178. package/es/utils/errors.mjs.map +1 -0
  179. package/es/utils/hd-wallet.d.ts +34 -0
  180. package/es/utils/hd-wallet.mjs +122 -0
  181. package/es/utils/hd-wallet.mjs.map +1 -0
  182. package/es/utils/json-big.d.ts +5 -0
  183. package/es/utils/json-big.mjs +41 -0
  184. package/es/utils/json-big.mjs.map +1 -0
  185. package/es/utils/keystore.d.ts +51 -0
  186. package/es/utils/keystore.mjs +145 -0
  187. package/es/utils/keystore.mjs.map +1 -0
  188. package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
  189. package/es/utils/{mptree.js → mptree.mjs} +33 -25
  190. package/es/utils/mptree.mjs.map +1 -0
  191. package/es/utils/other.d.ts +14 -0
  192. package/es/utils/other.mjs +28 -0
  193. package/es/utils/other.mjs.map +1 -0
  194. package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
  195. package/es/utils/{semver-satisfies.js → semver-satisfies.mjs} +1 -1
  196. package/es/utils/semver-satisfies.mjs.map +1 -0
  197. package/es/utils/string.d.ts +24 -0
  198. package/es/utils/{string.js → string.mjs} +9 -11
  199. package/es/utils/string.mjs.map +1 -0
  200. package/package.json +67 -64
  201. package/src/AeSdk.ts +65 -0
  202. package/src/AeSdkAepp.ts +167 -0
  203. package/src/AeSdkBase.ts +320 -0
  204. package/src/AeSdkWallet.ts +332 -0
  205. package/src/Node.ts +167 -0
  206. package/src/account/Base.ts +114 -0
  207. package/src/account/Memory.ts +83 -0
  208. package/src/account/Rpc.ts +67 -0
  209. package/src/aens.ts +391 -0
  210. package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
  211. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
  212. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
  213. package/{es/utils/crypto-ts.js → src/aepp-wallet-communication/connection-proxy.ts} +16 -9
  214. package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
  215. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  216. package/src/aepp-wallet-communication/schema.ts +181 -0
  217. package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
  218. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  219. package/src/apis/compiler/compiler.ts +585 -0
  220. package/src/apis/compiler/index.ts +2 -0
  221. package/src/apis/compiler/models/index.ts +301 -0
  222. package/src/apis/compiler/models/mappers.ts +583 -0
  223. package/src/apis/compiler/models/parameters.ts +93 -0
  224. package/src/apis/node/code-model-v4.yaml +10046 -0
  225. package/src/apis/node/index.ts +2 -0
  226. package/src/apis/node/models/index.ts +1253 -0
  227. package/src/apis/node/models/mappers.ts +4278 -0
  228. package/src/apis/node/models/parameters.ts +188 -0
  229. package/src/apis/node/node.ts +1299 -0
  230. package/src/chain.ts +444 -0
  231. package/src/channel/{handlers.js → handlers.ts} +238 -143
  232. package/src/channel/index.ts +991 -0
  233. package/src/channel/internal.ts +345 -0
  234. package/src/contract/Compiler.ts +66 -0
  235. package/src/contract/aci.ts +529 -0
  236. package/src/contract/ga.ts +178 -0
  237. package/src/contract/methods.ts +118 -0
  238. package/src/index.ts +51 -0
  239. package/src/oracle.ts +342 -0
  240. package/src/spend.ts +152 -0
  241. package/src/tx/builder/constants.ts +96 -0
  242. package/src/tx/builder/field-types.ts +111 -0
  243. package/src/tx/builder/helpers.ts +253 -0
  244. package/src/tx/builder/index.ts +394 -0
  245. package/src/tx/builder/schema.ts +771 -0
  246. package/src/tx/index.ts +199 -0
  247. package/src/tx/min-fee.ts +136 -0
  248. package/src/tx/validator.ts +226 -0
  249. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  250. package/src/typings/@aeternity__uuid/index.d.ts +3 -0
  251. package/src/typings/bip32-path/index.d.ts +33 -0
  252. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  253. package/src/utils/amount-formatter.ts +29 -41
  254. package/src/utils/autorest.ts +90 -0
  255. package/src/utils/bignumber.ts +9 -19
  256. package/src/utils/bytes.ts +15 -16
  257. package/src/utils/crypto.ts +217 -0
  258. package/src/utils/encoder.ts +98 -0
  259. package/src/utils/errors.ts +817 -0
  260. package/src/utils/hd-wallet.ts +134 -0
  261. package/src/utils/json-big.ts +26 -0
  262. package/src/utils/keystore.ts +179 -0
  263. package/src/utils/mptree.ts +26 -20
  264. package/src/utils/other.ts +28 -43
  265. package/src/utils/string.ts +8 -10
  266. package/CHANGELOG.md +0 -1603
  267. package/es/account/base.js +0 -169
  268. package/es/account/base.js.map +0 -1
  269. package/es/account/memory.js +0 -84
  270. package/es/account/memory.js.map +0 -1
  271. package/es/account/multiple.js +0 -178
  272. package/es/account/multiple.js.map +0 -1
  273. package/es/ae/aens.js +0 -408
  274. package/es/ae/aens.js.map +0 -1
  275. package/es/ae/aepp.js +0 -45
  276. package/es/ae/aepp.js.map +0 -1
  277. package/es/ae/contract.js +0 -312
  278. package/es/ae/contract.js.map +0 -1
  279. package/es/ae/index.js +0 -206
  280. package/es/ae/index.js.map +0 -1
  281. package/es/ae/oracle.js +0 -322
  282. package/es/ae/oracle.js.map +0 -1
  283. package/es/ae/universal.js +0 -45
  284. package/es/ae/universal.js.map +0 -1
  285. package/es/ae/wallet.js +0 -50
  286. package/es/ae/wallet.js.map +0 -1
  287. package/es/amount-formatter.d.ts +0 -58
  288. package/es/bignumber.d.ts +0 -24
  289. package/es/chain/index.js +0 -256
  290. package/es/chain/index.js.map +0 -1
  291. package/es/chain/node.js +0 -394
  292. package/es/chain/node.js.map +0 -1
  293. package/es/channel/handlers.js.map +0 -1
  294. package/es/channel/index.js +0 -980
  295. package/es/channel/index.js.map +0 -1
  296. package/es/channel/internal.js +0 -266
  297. package/es/channel/internal.js.map +0 -1
  298. package/es/contract/aci/helpers.js +0 -298
  299. package/es/contract/aci/helpers.js.map +0 -1
  300. package/es/contract/aci/index.js +0 -361
  301. package/es/contract/aci/index.js.map +0 -1
  302. package/es/contract/aci/transformation.js +0 -66
  303. package/es/contract/aci/transformation.js.map +0 -1
  304. package/es/contract/compiler.js +0 -244
  305. package/es/contract/compiler.js.map +0 -1
  306. package/es/contract/ga/helpers.js +0 -22
  307. package/es/contract/ga/helpers.js.map +0 -1
  308. package/es/contract/ga/index.js +0 -170
  309. package/es/contract/ga/index.js.map +0 -1
  310. package/es/contract/index.js +0 -162
  311. package/es/contract/index.js.map +0 -1
  312. package/es/crypto-ts.d.ts +0 -9
  313. package/es/index.js +0 -57
  314. package/es/index.js.map +0 -1
  315. package/es/node-pool/index.js +0 -187
  316. package/es/node-pool/index.js.map +0 -1
  317. package/es/node.js +0 -132
  318. package/es/node.js.map +0 -1
  319. package/es/other.d.ts +0 -31
  320. package/es/string.d.ts +0 -26
  321. package/es/tx/builder/helpers.js +0 -305
  322. package/es/tx/builder/helpers.js.map +0 -1
  323. package/es/tx/builder/index.js +0 -595
  324. package/es/tx/builder/index.js.map +0 -1
  325. package/es/tx/builder/schema.js +0 -814
  326. package/es/tx/builder/schema.js.map +0 -1
  327. package/es/tx/index.js +0 -300
  328. package/es/tx/index.js.map +0 -1
  329. package/es/tx/tx-object.js +0 -276
  330. package/es/tx/tx-object.js.map +0 -1
  331. package/es/tx/tx.js +0 -937
  332. package/es/tx/tx.js.map +0 -1
  333. package/es/tx/validator.js +0 -208
  334. package/es/tx/validator.js.map +0 -1
  335. package/es/typings/blakejs/index.d.js +0 -2
  336. package/es/typings/blakejs/index.d.js.map +0 -1
  337. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -131
  338. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
  339. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -184
  340. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
  341. package/es/utils/aepp-wallet-communication/connection/index.js +0 -84
  342. package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
  343. package/es/utils/aepp-wallet-communication/content-script-bridge.js +0 -97
  344. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
  345. package/es/utils/aepp-wallet-communication/helpers.js +0 -103
  346. package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
  347. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -329
  348. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
  349. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -270
  350. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
  351. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -533
  352. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
  353. package/es/utils/aepp-wallet-communication/schema.js +0 -107
  354. package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
  355. package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -109
  356. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
  357. package/es/utils/amount-formatter.js.map +0 -1
  358. package/es/utils/async-init.js +0 -67
  359. package/es/utils/async-init.js.map +0 -1
  360. package/es/utils/bignumber.js +0 -28
  361. package/es/utils/bignumber.js.map +0 -1
  362. package/es/utils/bytes.js.map +0 -1
  363. package/es/utils/crypto-ts.js.map +0 -1
  364. package/es/utils/crypto.js +0 -304
  365. package/es/utils/crypto.js.map +0 -1
  366. package/es/utils/hd-wallet.js +0 -112
  367. package/es/utils/hd-wallet.js.map +0 -1
  368. package/es/utils/json-big.js +0 -45
  369. package/es/utils/json-big.js.map +0 -1
  370. package/es/utils/keystore.js +0 -228
  371. package/es/utils/keystore.js.map +0 -1
  372. package/es/utils/mptree.js.map +0 -1
  373. package/es/utils/other.js +0 -43
  374. package/es/utils/other.js.map +0 -1
  375. package/es/utils/semver-satisfies.js.map +0 -1
  376. package/es/utils/string.js.map +0 -1
  377. package/es/utils/swagger.js +0 -132
  378. package/es/utils/swagger.js.map +0 -1
  379. package/src/account/base.js +0 -153
  380. package/src/account/memory.js +0 -78
  381. package/src/account/multiple.js +0 -154
  382. package/src/ae/aens.js +0 -366
  383. package/src/ae/aepp.js +0 -45
  384. package/src/ae/contract.js +0 -285
  385. package/src/ae/index.js +0 -167
  386. package/src/ae/oracle.js +0 -296
  387. package/src/ae/universal.js +0 -47
  388. package/src/ae/wallet.js +0 -50
  389. package/src/chain/index.js +0 -250
  390. package/src/chain/node.js +0 -293
  391. package/src/channel/index.js +0 -898
  392. package/src/channel/internal.js +0 -231
  393. package/src/contract/aci/index.js +0 -317
  394. package/src/contract/aci/transformation.js +0 -72
  395. package/src/contract/compiler.js +0 -195
  396. package/src/contract/ga/helpers.js +0 -17
  397. package/src/contract/ga/index.js +0 -147
  398. package/src/contract/index.js +0 -163
  399. package/src/index.js +0 -90
  400. package/src/node-pool/index.js +0 -171
  401. package/src/node.js +0 -118
  402. package/src/tx/builder/helpers.js +0 -325
  403. package/src/tx/builder/index.js +0 -460
  404. package/src/tx/builder/schema.js +0 -1211
  405. package/src/tx/index.js +0 -301
  406. package/src/tx/tx-object.js +0 -186
  407. package/src/tx/tx.js +0 -622
  408. package/src/tx/validator.js +0 -161
  409. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -114
  410. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -161
  411. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  412. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -85
  413. package/src/utils/aepp-wallet-communication/helpers.js +0 -70
  414. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -268
  415. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -223
  416. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -390
  417. package/src/utils/aepp-wallet-communication/schema.js +0 -108
  418. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -91
  419. package/src/utils/async-init.js +0 -41
  420. package/src/utils/crypto.js +0 -312
  421. package/src/utils/hd-wallet.js +0 -115
  422. package/src/utils/json-big.js +0 -26
  423. package/src/utils/keystore.js +0 -223
  424. package/src/utils/swagger.js +0 -133
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/contract/aci/index.js"],"names":["BigNumber","Encoder","Calldata","decodeEvents","DRY_RUN_ACCOUNT","DEPOSIT","TxObject","decode","getFunctionACI","aci","name","external","fn","functions","find","f","Error","bindings","state","type_defs","map","event","variant","getContractInstance","source","bytecode","contractAddress","filesystem","validateBytecode","otherOptions","contractGetACI","resolveName","resolveByNode","contract","getContract","catch","active","instance","interface","calldata","encoded_aci","external_encoded_aci","externalAci","a","namespace","deployInfo","address","options","Ae","defaults","callStatic","compilerVersion","onChanBytecode","getContractByteCode","isValid","validateByteCodeAPI","compile","contractCompile","sendAndProcess","tx","txData","send","result","hash","rawTx","waitMined","txInfo","getTxInfo","handleCallError","returnType","returnValue","message","decodeFateString","toString","deploy","params","opt","deposit","call","ownerId","contractId","contractCreateTx","callData","encode","code","Object","freeze","owner","transaction","args","contractCall","contractCallStatic","createdAt","Date","fnACI","amount","gt","prototype","hasOwnProperty","payable","callerId","error","pub","res","top","getKeyBlock","txOpt","nonce","getAccount","contractCallTx","callObj","dryRunOther","txDryRun","decodedResult","returns","decodedEvents","log","events","eventsACI","eventsSchema","e","keys","types","methods","fromEntries","arguments","aciArgs","stateful","genHandler","length","pop","assign","get"],"mappings":";;;;AAyBA,OAAOA,SAAP,MAAsB,cAAtB;AACA,SAASC,OAAO,IAAIC,QAApB,QAAoC,0BAApC;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,eAAT,EAA0BC,OAA1B,QAAyC,yBAAzC;AACA,OAAOC,QAAP,MAAqB,oBAArB;AACA,SAASC,MAAT,QAAuB,0BAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,cAAT,CAAyBC,GAAzB,EAA8BC,IAA9B,EAAoCC,QAApC,EAA8C;AAC5C,QAAMC,EAAE,GAAGH,GAAG,CAACI,SAAJ,CAAcC,IAAd,CAAmBC,CAAC,IAAIA,CAAC,CAACL,IAAF,KAAWA,IAAnC,CAAX;AACA,MAAI,CAACE,EAAD,IAAOF,IAAI,KAAK,MAApB,EAA4B,MAAM,IAAIM,KAAJ,CAAW,YAAWN,IAAK,4BAA3B,CAAN;AAE5B,SAAO,EACL,GAAGE,EADE;AAELK,IAAAA,QAAQ,EAAE,CACR;AACEC,MAAAA,KAAK,EAAET,GAAG,CAACS,KADb;AAEEC,MAAAA,SAAS,EAAEV,GAAG,CAACU,SAFjB;AAGET,MAAAA,IAAI,EAAED,GAAG,CAACC;AAHZ,KADQ,EAMR,GAAGC,QAAQ,CAACS,GAAT,CAAa,MAAO,CAAC,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B,aAAOV,QAAQ,CAACyC,IAAT,CAAcpE,IAAd,EAAoB+E,IAApB,EAA0B;AAAEvC,QAAAA,UAAF;AAAc,WAAGH;AAAjB,OAA1B,CAAP;AACD,KALD;;AAMA,WAAO,CACLrC,IADK,EAEL2E,MAAM,CAAC8C,MAAP,CACEH,UAAU,CAACtH,IAAI,KAAK,MAAT,GAAkB,KAAlB,GAA0B,CAACqH,QAA5B,CADZ,EAEE;AACEK,MAAAA,GAAG,EAAEJ,UAAU,CAAC,IAAD,CADjB;AAEEnE,MAAAA,IAAI,EAAEmE,UAAU,CAAC,KAAD,CAFlB;AAGE7H,MAAAA,YAAY,EAAEkH,MAAM,IAAIhF,QAAQ,CAAClC,YAAT,CAAsBkH,MAAtB;AAH1B,KAFF,CAFK,CAAP;AAWD,GAnBmC,CAAnB,CAAnB;AAsBA,SAAOhF,QAAP;AACD","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * ContractACI module\n *\n * @module @aeternity/aepp-sdk/es/contract/aci\n * @export getContractInstance\n */\n\nimport * as R from 'ramda'\nimport BigNumber from 'bignumber.js'\nimport { Encoder as Calldata } from '@aeternity/aepp-calldata'\nimport { decodeEvents } from './transformation'\nimport { DRY_RUN_ACCOUNT, DEPOSIT } from '../../tx/builder/schema'\nimport TxObject from '../../tx/tx-object'\nimport { decode } from '../../tx/builder/helpers'\n\n/**\n * Get function schema from contract ACI object\n * @param {Object} aci Contract ACI object\n * @param {String} name Function name\n * @param external\n * @return {Object} function ACI\n */\nfunction getFunctionACI (aci, name, external) {\n const fn = aci.functions.find(f => f.name === name)\n if (!fn && name !== 'init') throw new Error(`Function ${name} doesn't exist in contract`)\n\n return {\n ...fn,\n bindings: [\n {\n state: aci.state,\n type_defs: aci.type_defs,\n name: aci.name\n },\n ...external.map(R.pick(['state', 'type_defs', 'name']))\n ],\n event: aci.event ? aci.event.variant : []\n }\n}\n\n/**\n * Generate contract ACI object with predefined js methods for contract usage - can be used for\n * creating a reference to already deployed contracts\n * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @param {Object} [options={}] Options object\n * @param {String} [options.source] Contract source code\n * @param {String} [options.bytecode] Contract bytecode\n * @param {Object} [options.aci] Contract ACI\n * @param {String} [options.contractAddress] Contract address\n * @param {Object} [options.filesystem] Contact source external namespaces map\n * @param {Boolean} [options.validateBytecode] Compare source code with on-chain version\n * @return {ContractInstance} JS Contract API\n * @example\n * const contractIns = await client.getContractInstance({ source })\n * await contractIns.deploy([321]) or await contractIns.methods.init(321)\n * const callResult = await contractIns.call('setState', [123]) or\n * await contractIns.methods.setState.send(123, options)\n * const staticCallResult = await contractIns.call('setState', [123], { callStatic: true }) or\n * await contractIns.methods.setState.get(123, options)\n * Also you can call contract like: await contractIns.methods.setState(123, options)\n * Then sdk decide to make on-chain or static call(dry-run API) transaction based on function is\n * stateful or not\n */\nexport default async function getContractInstance ({\n source,\n bytecode,\n aci,\n contractAddress,\n filesystem = {},\n validateBytecode,\n ...otherOptions\n} = {}) {\n aci = aci || (source && await this.contractGetACI(source, { filesystem }))\n if (!aci) throw new Error('Either ACI or source code is required')\n contractAddress = contractAddress && await this.resolveName(\n contractAddress, 'contract_pubkey', { resolveByNode: true }\n )\n if (!contractAddress && !source && !bytecode) throw new Error('Can\\'t create instance by ACI without address')\n\n if (contractAddress) {\n const contract = await this.getContract(contractAddress).catch(() => null)\n if (!contract) throw new Error(`Contract with address ${contractAddress} not found on-chain`)\n if (!contract.active) throw new Error(`Contract with address ${contractAddress} not active`)\n }\n\n const instance = {\n interface: R.defaultTo(null, R.prop('interface', aci)),\n aci: R.defaultTo(null, R.path(['encoded_aci', 'contract'], aci)),\n calldata: new Calldata([aci.encoded_aci, ...aci.external_encoded_aci]),\n externalAci: (aci.external_encoded_aci ?? []).map(a => a.contract || a.namespace),\n source,\n bytecode,\n deployInfo: { address: contractAddress },\n options: {\n ...this.Ae.defaults,\n callStatic: false,\n filesystem,\n ...otherOptions\n },\n compilerVersion: this.compilerVersion\n }\n\n if (validateBytecode) {\n if (!contractAddress) throw new Error('Can\\'t validate bytecode without contract address')\n const onChanBytecode = (await this.getContractByteCode(contractAddress)).bytecode\n const isValid = (source && await this\n .validateByteCodeAPI(onChanBytecode, source, instance.options).catch(() => false)) ||\n bytecode === onChanBytecode\n if (!isValid) throw new Error(`Contract ${source ? 'source' : 'bytecode'} do not correspond to the bytecode deployed on the chain`)\n }\n\n /**\n * Compile contract\n * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @rtype () => ContractInstance: Object\n * @return {String} bytecode bytecode\n */\n instance.compile = async (options = {}) => {\n if (instance.bytecode) throw new Error('Contract already compiled')\n if (!instance.source) throw new Error('Can\\'t compile without source code')\n const { bytecode } = await this.contractCompile(\n instance.source, { ...instance.options, ...options }\n )\n instance.bytecode = bytecode\n return instance.bytecode\n }\n\n const sendAndProcess = async (tx, options) => {\n const txData = await this.send(tx, options)\n const result = {\n hash: txData.hash, tx: TxObject({ tx: txData.rawTx }), txData, rawTx: txData.rawTx\n }\n if (options.waitMined === false) return result\n const txInfo = await this.getTxInfo(txData.hash)\n await handleCallError(txInfo)\n return { ...result, result: txInfo }\n }\n\n const handleCallError = ({ returnType, returnValue }) => {\n let message\n // TODO: ensure that it works correctly https://github.com/aeternity/aepp-calldata-js/issues/88\n switch (returnType) {\n case 'ok': return\n case 'revert':\n message = instance.calldata.decodeFateString(returnValue)\n break\n case 'error':\n message = decode(returnValue).toString()\n break\n default: throw new Error(`Unknown returnType: ${returnType}`)\n }\n throw new Error(`Invocation failed${message ? `: \"${message}\"` : ''}`)\n }\n\n /**\n * Deploy contract\n * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @rtype (init: Array, options: Object) => ContractInstance: Object\n * @param {Array} params Contract init function arguments array\n * @param {Object} [options] options\n * @return {Object} deploy info\n */\n instance.deploy = async (params = [], options) => {\n const opt = { ...instance.options, ...options, deposit: DEPOSIT }\n if (!instance.bytecode) await instance.compile(opt)\n if (opt.callStatic) return instance.call('init', params, opt)\n if (instance.deployInfo.address) throw new Error('Contract already deployed')\n\n const ownerId = await this.address(opt)\n const { tx, contractId } = await this.contractCreateTx({\n ...opt,\n callData: instance.calldata.encode(instance.aci.name, 'init', params),\n code: instance.bytecode,\n ownerId\n })\n const { hash, rawTx, result, txData } = await sendAndProcess(tx, opt)\n instance.deployInfo = Object.freeze({\n result,\n owner: ownerId,\n transaction: hash,\n rawTx,\n txData,\n address: contractId,\n call: (name, args, options) =>\n this.contractCall(instance.source, contractId, name, args, { ...opt, ...options }),\n callStatic: (name, args, options) =>\n this.contractCallStatic(instance.source, contractId, name, args, { ...opt, ...options }),\n createdAt: new Date()\n })\n return instance.deployInfo\n }\n\n /**\n * Call contract function\n * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @rtype (init: Array, options: Object = { callStatic: false }) => CallResult: Object\n * @param {String} fn Function name\n * @param {Array} params Array of function arguments\n * @param {Object} [options={}] Array of function arguments\n * @param {Boolean} [options.callStatic=false] Static function call\n * @return {Object} CallResult\n */\n instance.call = async (fn, params = [], options = {}) => {\n const opt = { ...instance.options, ...options }\n const fnACI = getFunctionACI(instance.aci, fn, instance.externalAci)\n const contractId = instance.deployInfo.address\n\n if (!fn) throw new Error('Function name is required')\n if (fn === 'init' && !opt.callStatic) throw new Error('\"init\" can be called only via dryRun')\n if (!contractId && fn !== 'init') throw new Error('You need to deploy contract before calling!')\n if (\n BigNumber(opt.amount).gt(0) &&\n (Object.prototype.hasOwnProperty.call(fnACI, 'payable') && !fnACI.payable)\n ) throw new Error(`You try to pay \"${opt.amount}\" to function \"${fn}\" which is not payable. Only payable function can accept tokens`)\n\n const callerId = await this.address(opt).catch(error => {\n if (opt.callStatic) return DRY_RUN_ACCOUNT.pub\n else throw error\n })\n const callData = instance.calldata.encode(instance.aci.name, fn, params)\n\n let res\n if (opt.callStatic) {\n if (typeof opt.top === 'number') {\n opt.top = (await this.getKeyBlock(opt.top)).hash\n }\n const txOpt = {\n ...opt,\n callData,\n nonce: opt.top && (await this.getAccount(callerId, { hash: opt.top })).nonce + 1\n }\n const tx = fn === 'init'\n ? (await this.contractCreateTx({ ...txOpt, code: instance.bytecode, ownerId: callerId })).tx\n : await this.contractCallTx({ ...txOpt, callerId, contractId })\n\n const { callObj, ...dryRunOther } = await this.txDryRun(tx, callerId, opt)\n await handleCallError(callObj)\n res = { ...dryRunOther, tx: TxObject({ tx }), result: callObj }\n } else {\n const tx = await this.contractCallTx({ ...opt, callerId, contractId, callData })\n res = await sendAndProcess(tx, opt)\n }\n if (opt.waitMined || opt.callStatic) {\n res.decodedResult = fnACI.returns && fnACI.returns !== 'unit' && fn !== 'init' &&\n instance.calldata.decode(instance.aci.name, fn, res.result.returnValue)\n res.decodedEvents = instance.decodeEvents(res.result.log)\n }\n return res\n }\n\n /**\n * Decode Events\n * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @rtype (events: Array) => DecodedEvents: Array\n * @param {Array} events Array of encoded events(callRes.result.log)\n * @return {Object} DecodedEvents\n */\n instance.decodeEvents = (events) => {\n const eventsACI = instance.aci.event ? instance.aci.event.variant : []\n const eventsSchema = eventsACI.map(e => {\n const name = Object.keys(e)[0]\n return { name, types: e[name] }\n })\n\n return decodeEvents(events, eventsSchema)\n }\n\n /**\n * Generate proto function based on contract function using Contract ACI schema\n * All function can be called like:\n * 'await contract.methods.testFunction()' -> then sdk will decide to use dry-run or send tx\n * on-chain base on if function stateful or not.\n * Also you can manually do that:\n * `await contract.methods.testFunction.get()` -> use call-static(dry-run)\n * `await contract.methods.testFunction.send()` -> send tx on-chain\n */\n instance.methods = Object.fromEntries(instance.aci.functions\n .map(({ name, arguments: aciArgs, stateful }) => {\n const genHandler = callStatic => (...args) => {\n const options = args.length === aciArgs.length + 1 ? args.pop() : {}\n if (typeof options !== 'object') throw new Error(`Options should be an object: ${options}`)\n if (name === 'init') return instance.deploy(args, { callStatic, ...options })\n return instance.call(name, args, { callStatic, ...options })\n }\n return [\n name,\n Object.assign(\n genHandler(name === 'init' ? false : !stateful),\n {\n get: genHandler(true),\n send: genHandler(false),\n decodeEvents: events => instance.decodeEvents(events)\n }\n )\n ]\n })\n )\n\n return instance\n}\n"],"file":"index.js"}
@@ -1,66 +0,0 @@
1
- import { toBytes } from '../../utils/bytes';
2
- import { decode } from '../../tx/builder/helpers';
3
- import { parseBigNumber } from '../../utils/bignumber';
4
- import { addressFromDecimal, hash } from '../../utils/crypto';
5
- export const SOPHIA_TYPES = ['int', 'string', 'tuple', 'address', 'bool', 'list', 'map', 'record', 'option', 'oracle', 'oracleQuery', 'hash', 'signature', 'bytes', 'variant'].reduce((acc, type) => ({ ...acc,
6
- [type]: type
7
- }), {
8
- ChainTtl: 'Chain.ttl'
9
- });
10
- /**
11
- * Decode events fields
12
- * @param {Object[]} events Array of events with encoded fields
13
- * @param {Array} schemas Smart contract event ACI schemas
14
- * @return {Object}
15
- */
16
-
17
- export const decodeEvents = function (events) {
18
- let schemas = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
19
- return events.reduce((acc, event) => {
20
- const [nameHash, ...params] = event.topics;
21
- const schema = schemas.find(s => hash(s.name).equals(toBytes(nameHash, true)));
22
- if (!schema) return acc;
23
- const stringCount = schema.types.filter(t => t === SOPHIA_TYPES.string).length;
24
- if (stringCount > 1) throw new Error(`Event schema contains more than one string: ${schema.types}`);
25
- const topicsCount = schema.types.length - stringCount;
26
-
27
- if (topicsCount !== params.length) {
28
- throw new Error(`Schema defines ${topicsCount} types, but ${params.length} topics present`);
29
- }
30
-
31
- acc.push({ ...event,
32
- name: schema.name,
33
- decoded: schema.types.map(type => decodeEventField(type === SOPHIA_TYPES.string ? event.data : params.shift(), type))
34
- });
35
- return acc;
36
- }, []);
37
- };
38
- /**
39
- * Transform Event based on type
40
- * @param {String|Number} field Event data
41
- * @param {String} type Event type from schema
42
- * @return {*}
43
- */
44
-
45
- function decodeEventField(field, type) {
46
- switch (type) {
47
- case SOPHIA_TYPES.int:
48
- return parseBigNumber(field);
49
-
50
- case SOPHIA_TYPES.bool:
51
- return !!field;
52
-
53
- case SOPHIA_TYPES.hash:
54
- return toBytes(field, true).toString('hex');
55
-
56
- case SOPHIA_TYPES.address:
57
- return addressFromDecimal(field);
58
-
59
- case SOPHIA_TYPES.string:
60
- return decode(field).toString('utf-8');
61
-
62
- default:
63
- return toBytes(field, true);
64
- }
65
- }
66
- //# sourceMappingURL=transformation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/contract/aci/transformation.js"],"names":["toBytes","decode","parseBigNumber","addressFromDecimal","hash","SOPHIA_TYPES","reduce","acc","type","ChainTtl","decodeEvents","events","schemas","event","nameHash","params","topics","schema","find","s","name","equals","stringCount","types","filter","t","string","length","Error","topicsCount","push","decoded","map","decodeEventField","data","shift","field","int","bool","toString","address"],"mappings":"AAAA,SAASA,OAAT,QAAwB,mBAAxB;AACA,SAASC,MAAT,QAAuB,0BAAvB;AACA,SAASC,cAAT,QAA+B,uBAA/B;AACA,SAASC,kBAAT,EAA6BC,IAA7B,QAAyC,oBAAzC;AAEA,OAAO,MAAMC,YAAY,GAAG,CAC1B,KAD0B,EAE1B,QAF0B,EAG1B,OAH0B,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AY,eAAcd,MAAM,CAACY,MAAO,iBAApE,CAAN;AACD;;AAEDpB,IAAAA,GAAG,CAACuB,IAAJ,CAAS,EACP,GAAGjB,KADI;AAEPO,MAAAA,IAAI,EAAEH,MAAM,CAACG,IAFN;AAGPW,MAAAA,OAAO,EAAEd,MAAM,CAACM,KAAP,CAAaS,GAAb,CAAkBxB,IAAD,IACxByB,gBAAgB,CAACzB,IAAI,KAAKH,YAAY,CAACqB,MAAtB,GAA+Bb,KAAK,CAACqB,IAArC,GAA4CnB,MAAM,CAACoB,KAAP,EAA7C,EAA6D3B,IAA7D,CADT;AAHF,KAAT;AAOA,WAAOD,GAAP;AACD,GAnBqD,EAmBnD,EAnBmD,CAA1B;AAAA,CAArB;AAqBP;AACA;AACA;AACA;AACA;AACA;;AACA,SAAS0B,gBAAT,CAA2BG,KAA3B,EAAkC5B,IAAlC,EAAwC;AACtC,UAAQA,IAAR;AACE,SAAKH,YAAY,CAACgC,GAAlB;AACE,aAAOnC,cAAc,CAACkC,KAAD,CAArB;;AACF,SAAK/B,YAAY,CAACiC,IAAlB;AACE,aAAO,CAAC,CAACF,KAAT;;AACF,SAAK/B,YAAY,CAACD,IAAlB;AACE,aAAOJ,OAAO,CAACoC,KAAD,EAAQ,IAAR,CAAP,CAAqBG,QAArB,CAA8B,KAA9B,CAAP;;AACF,SAAKlC,YAAY,CAACmC,OAAlB;AACE,aAAOrC,kBAAkB,CAACiC,KAAD,CAAzB;;AACF,SAAK/B,YAAY,CAACqB,MAAlB;AACE,aAAOzB,MAAM,CAACmC,KAAD,CAAN,CAAcG,QAAd,CAAuB,OAAvB,CAAP;;AACF;AACE,aAAOvC,OAAO,CAACoC,KAAD,EAAQ,IAAR,CAAd;AAZJ;AAcD","sourcesContent":["import { toBytes } from '../../utils/bytes'\nimport { decode } from '../../tx/builder/helpers'\nimport { parseBigNumber } from '../../utils/bignumber'\nimport { addressFromDecimal, hash } from '../../utils/crypto'\n\nexport const SOPHIA_TYPES = [\n 'int',\n 'string',\n 'tuple',\n 'address',\n 'bool',\n 'list',\n 'map',\n 'record',\n 'option',\n 'oracle',\n 'oracleQuery',\n 'hash',\n 'signature',\n 'bytes',\n 'variant'\n].reduce((acc, type) => ({ ...acc, [type]: type }), { ChainTtl: 'Chain.ttl' })\n\n/**\n * Decode events fields\n * @param {Object[]} events Array of events with encoded fields\n * @param {Array} schemas Smart contract event ACI schemas\n * @return {Object}\n */\nexport const decodeEvents = (events, schemas = []) => events.reduce((acc, event) => {\n const [nameHash, ...params] = event.topics\n const schema = schemas.find((s) => hash(s.name).equals(toBytes(nameHash, true)))\n if (!schema) return acc\n const stringCount = schema.types.filter(t => t === SOPHIA_TYPES.string).length\n if (stringCount > 1) throw new Error(`Event schema contains more than one string: ${schema.types}`)\n const topicsCount = schema.types.length - stringCount\n if (topicsCount !== params.length) {\n throw new Error(`Schema defines ${topicsCount} types, but ${params.length} topics present`)\n }\n\n acc.push({\n ...event,\n name: schema.name,\n decoded: schema.types.map((type) =>\n decodeEventField(type === SOPHIA_TYPES.string ? event.data : params.shift(), type))\n })\n\n return acc\n}, [])\n\n/**\n * Transform Event based on type\n * @param {String|Number} field Event data\n * @param {String} type Event type from schema\n * @return {*}\n */\nfunction decodeEventField (field, type) {\n switch (type) {\n case SOPHIA_TYPES.int:\n return parseBigNumber(field)\n case SOPHIA_TYPES.bool:\n return !!field\n case SOPHIA_TYPES.hash:\n return toBytes(field, true).toString('hex')\n case SOPHIA_TYPES.address:\n return addressFromDecimal(field)\n case SOPHIA_TYPES.string:\n return decode(field).toString('utf-8')\n default:\n return toBytes(field, true)\n }\n}\n"],"file":"transformation.js"}
@@ -1,244 +0,0 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2018 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
- /**
19
- * ContractCompilerAPI module
20
- *
21
- * This is the complement to {@link module:@aeternity/aepp-sdk/es/contract}.
22
- * @module @aeternity/aepp-sdk/es/contract/compiler
23
- * @export ContractCompilerAPI
24
- * @example import { ContractCompilerAPI } from '@aeternity/aepp-sdk'
25
- */
26
- import ContractBase from './index';
27
- import semverSatisfies from '../utils/semver-satisfies';
28
- import AsyncInit from '../utils/async-init';
29
- import genSwaggerClient from '../utils/swagger';
30
- /**
31
- * Contract Compiler Stamp
32
- *
33
- * This stamp include api call's related to contract compiler functionality.
34
- * @function
35
- * @alias module:@aeternity/aepp-sdk/es/contract/compiler
36
- * @rtype Stamp
37
- * @param {Object} [options={}] - Initializer object
38
- * @param {String} [options.compilerUrl] compilerUrl - Url for compiler API
39
- * @return {Object} Contract compiler instance
40
- * @example ContractCompilerAPI({ compilerUrl: 'COMPILER_URL' })
41
- */
42
-
43
- export default AsyncInit.compose(ContractBase, {
44
- async init(_ref) {
45
- let {
46
- compilerUrl,
47
- ignoreVersion
48
- } = _ref;
49
- if (!compilerUrl) return;
50
- await this.setCompilerUrl(compilerUrl, {
51
- ignoreVersion
52
- });
53
- },
54
-
55
- methods: {
56
- async setCompilerUrl(compilerUrl) {
57
- let {
58
- ignoreVersion = false
59
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
60
- if (!compilerUrl) throw new Error('"compilerUrl" required');
61
- compilerUrl = compilerUrl.replace(/\/$/, '');
62
- const client = await genSwaggerClient(`${compilerUrl}/api`, {
63
- disableBigNumbers: true,
64
- disableCaseConversion: true,
65
- responseInterceptor: response => {
66
- if (response.ok) return;
67
- let message = `${new URL(response.url).pathname.slice(1)} error`;
68
-
69
- if (response.body.reason) {
70
- message += ': ' + response.body.reason + (response.body.parameter ? ` in ${response.body.parameter}` : '') + ( // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78
71
- response.body.info ? ` (${JSON.stringify(response.body.info)})` : '');
72
- }
73
-
74
- if (Array.isArray(response.body)) {
75
- message += ':\n' + response.body.map(e => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context ? `(${e.context})` : ''}`).map(e => e.trim()) // TODO: remove after fixing https://github.com/aeternity/aesophia_http/issues/80
76
- .join('\n');
77
- }
78
-
79
- response.statusText = message;
80
- return response;
81
- }
82
- });
83
- this.compilerVersion = client.spec.info.version;
84
- this._compilerApi = client.api;
85
- if (ignoreVersion) return;
86
-
87
- if (!semverSatisfies(this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION)) {
88
- throw new Error(`Unsupported compiler version ${this.compilerVersion}. ` + `Supported: >= ${COMPILER_GE_VERSION} < ${COMPILER_LT_VERSION}`);
89
- }
90
- },
91
-
92
- _ensureCompilerReady() {
93
- if (!this._compilerApi) throw new Error('Compiler is not ready');
94
- },
95
-
96
- _prepareCompilerOptions() {
97
- let {
98
- filesystem = {}
99
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
100
- return {
101
- file_system: filesystem
102
- };
103
- },
104
-
105
- getCompilerVersion() {
106
- this._ensureCompilerReady();
107
-
108
- return Promise.resolve(this.compilerVersion);
109
- },
110
-
111
- /**
112
- * Encode call data for contract call
113
- * @function
114
- * @category async
115
- * @param {String} source Contract source code
116
- * @param {String} name Name of function to call
117
- * @param {Array} args Argument's for call
118
- * @param {Object} [options={}] Options
119
- * @param {Object} [options.filesystem={}] Contract external namespaces map
120
- * @return {Promise<String>}
121
- */
122
- async contractEncodeCallDataAPI(source, name) {
123
- let args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
124
- let options = arguments.length > 3 ? arguments[3] : undefined;
125
-
126
- this._ensureCompilerReady();
127
-
128
- const {
129
- calldata
130
- } = await this._compilerApi.encodeCalldata({
131
- source,
132
- function: name,
133
- arguments: args,
134
- options: this._prepareCompilerOptions(options)
135
- });
136
- return calldata;
137
- },
138
-
139
- async compileContractAPI(code, options) {
140
- this._ensureCompilerReady();
141
-
142
- const {
143
- bytecode
144
- } = await this._compilerApi.compileContract({
145
- code,
146
- options: this._prepareCompilerOptions(options)
147
- });
148
- return bytecode;
149
- },
150
-
151
- contractGetACI(code, options) {
152
- this._ensureCompilerReady();
153
-
154
- return this._compilerApi.generateACI({
155
- code,
156
- options: this._prepareCompilerOptions(options)
157
- });
158
- },
159
-
160
- contractDecodeCallDataByCodeAPI(bytecode, calldata) {
161
- this._ensureCompilerReady();
162
-
163
- return this._compilerApi.decodeCalldataBytecode({
164
- bytecode,
165
- calldata
166
- });
167
- },
168
-
169
- contractDecodeCallDataBySourceAPI(source, fn, callData, options) {
170
- this._ensureCompilerReady();
171
-
172
- return this._compilerApi.decodeCalldataSource({
173
- function: fn,
174
- source,
175
- calldata: callData,
176
- options: this._prepareCompilerOptions(options)
177
- });
178
- },
179
-
180
- /**
181
- * Decode contract call result data
182
- * @function
183
- * @category async
184
- * @param {String} source - source code
185
- * @param {String } fn - function name
186
- * @param {String} callValue - result call data
187
- * @param {String} callResult - result status
188
- * @param {Object} [options={}] Options
189
- * @param {Object} [options.filesystem={}] Contract external namespaces map
190
- * @return {Promise<String>} Result object
191
- * @example
192
- * const decodedData = await sdk.contractDecodeCallResultAPI(
193
- * SourceCode ,'functionName', 'cb_asdasdasd...', 'ok|revert'
194
- * )
195
- */
196
- contractDecodeCallResultAPI(source, fn, callValue, callResult, options) {
197
- this._ensureCompilerReady();
198
-
199
- return this._compilerApi.decodeCallResult({
200
- function: fn,
201
- source,
202
- 'call-result': callResult,
203
- 'call-value': callValue,
204
- options: this._prepareCompilerOptions(options)
205
- });
206
- },
207
-
208
- async validateByteCodeAPI(bytecode, source, options) {
209
- this._ensureCompilerReady();
210
-
211
- const res = await this._compilerApi.validateByteCode({
212
- bytecode,
213
- source,
214
- options: this._prepareCompilerOptions(options)
215
- });
216
- return typeof res === 'object' ? true : res;
217
- },
218
-
219
- getFateAssembler(bytecode, options) {
220
- this._ensureCompilerReady();
221
-
222
- return this._compilerApi.getFateAssemblerCode({
223
- bytecode,
224
- options: this._prepareCompilerOptions(options)
225
- });
226
- },
227
-
228
- getBytecodeCompilerVersion(bytecode, options) {
229
- this._ensureCompilerReady();
230
-
231
- return this._compilerApi.getCompilerVersion({
232
- bytecode,
233
- options: this._prepareCompilerOptions(options)
234
- });
235
- }
236
-
237
- },
238
- props: {
239
- compilerVersion: null
240
- }
241
- });
242
- const COMPILER_GE_VERSION = '6.0.0';
243
- const COMPILER_LT_VERSION = '7.0.0';
244
- //# sourceMappingURL=compiler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/contract/compiler.js"],"names":["ContractBase","semverSatisfies","AsyncInit","genSwaggerClient","compose","init","compilerUrl","ignoreVersion","setCompilerUrl","methods","Error","replace","client","disableBigNumbers","disableCaseConversion","responseInterceptor","response","ok","message","URL","url","pathname","slice","body","reason","parameter","info","JSON","stringify","Array","isArray","map","e","type","pos","line","col","context","trim","join","statusText","compilerVersion","spec","version","_compilerApi","api","COMPILER_GE_VERSION","COMPILER_LT_VERSION","_ensureCompilerReady","_prepareCompilerOptions","filesystem","file_system","getCompilerVersion","Promise","resolve","contractEncodeCallDataAPI","source","name","args","options","calldata","encodeCalldata","function","arguments","compileContractAPI","code","bytecode","compileContract","contractGetACI","generateACI","contractDecodeCallDataByCodeAPI","decodeCalldataBytecode","contractDecodeCallDataBySourceAPI","fn","callData","decodeCalldataSource","contractDecodeCallResultAPI","callValue","callResult","decodeCallResult","validateByteCodeAPI","res","validateByteCode","getFateAssembler","getFateAssemblerCode","getBytecodeCompilerVersion","props"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,YAAP,MAAyB,SAAzB;AACA,OAAOC,eAAP,MAA4B,2BAA5B;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,gBAAP,MAA6B,kBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeD,SAAS,CAACE,OAAV,CAAkBJ,YAAlB,EAAgC;AAC7C,QAAMK,IAAN,OAA4C;AAAA,QAAhC;AAAEC,MAAAA,WAAF;AAAeC,MAAAA;AAAf,KAAgC;AAC1C,QAAI,CAACD,WAAL,EAAkB;AAClB,UAAM,KAAKE,cAAL,CAAoBF,WAApB,EAAiC;AAAEC,MAAAA;AAAF,KAAjC,CAAN;AACD,GAJ4C;;AAK7CE,EAAAA,OAAO,EAAE;AACP,UAAMD,cAAN,CAAsBF,WAAtB,EAAmE;AAAA,UAAhC;AAAEC,QAAAA,aAAa,GAAG;AAAlB,OAAgC,uEAAJ,EAAI;AACjE,UAAI,CAACD,WAAL,EAAkB,MAAM,IAAII,KAAJ,CAAU,wBAAV,CAAN;AAClBJ,MAAAA,WAAW,GAAGA,WAAW,CAACK,OAAZ,CAAoB,KAApB,EAA2B,EAA3B,CAAd;AACA,YAAMC,MAAM,GAAG,MAAMT,gBAAgB,CAAE,GAAEG,WAAY,MAAhB,EAAuB;AAC1DO,QAAAA,iBAAiB,EAAE,IADuC;AAE1DC,QAAAA,qBAAqB,EAAE,IAFmC;AAG1DC,QAAAA,mBAAmB,EAAEC,QAAQ,IAAI;AAC/B,cAAIA,QAAQ,CAACC,EAAb,EAAiB;AACjB,cAAIC,OAAO,G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B","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * ContractCompilerAPI module\n *\n * This is the complement to {@link module:@aeternity/aepp-sdk/es/contract}.\n * @module @aeternity/aepp-sdk/es/contract/compiler\n * @export ContractCompilerAPI\n * @example import { ContractCompilerAPI } from '@aeternity/aepp-sdk'\n */\n\nimport ContractBase from './index'\nimport semverSatisfies from '../utils/semver-satisfies'\nimport AsyncInit from '../utils/async-init'\nimport genSwaggerClient from '../utils/swagger'\n\n/**\n * Contract Compiler Stamp\n *\n * This stamp include api call's related to contract compiler functionality.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/contract/compiler\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @param {String} [options.compilerUrl] compilerUrl - Url for compiler API\n * @return {Object} Contract compiler instance\n * @example ContractCompilerAPI({ compilerUrl: 'COMPILER_URL' })\n */\nexport default AsyncInit.compose(ContractBase, {\n async init ({ compilerUrl, ignoreVersion }) {\n if (!compilerUrl) return\n await this.setCompilerUrl(compilerUrl, { ignoreVersion })\n },\n methods: {\n async setCompilerUrl (compilerUrl, { ignoreVersion = false } = {}) {\n if (!compilerUrl) throw new Error('\"compilerUrl\" required')\n compilerUrl = compilerUrl.replace(/\\/$/, '')\n const client = await genSwaggerClient(`${compilerUrl}/api`, {\n disableBigNumbers: true,\n disableCaseConversion: true,\n responseInterceptor: response => {\n if (response.ok) return\n let message = `${new URL(response.url).pathname.slice(1)} error`\n if (response.body.reason) {\n message += ': ' + response.body.reason +\n (response.body.parameter ? ` in ${response.body.parameter}` : '') +\n // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78\n (response.body.info ? ` (${JSON.stringify(response.body.info)})` : '')\n }\n if (Array.isArray(response.body)) {\n message += ':\\n' + response.body\n .map(e => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context ? `(${e.context})` : ''}`)\n .map(e => e.trim()) // TODO: remove after fixing https://github.com/aeternity/aesophia_http/issues/80\n .join('\\n')\n }\n response.statusText = message\n return response\n }\n })\n this.compilerVersion = client.spec.info.version\n this._compilerApi = client.api\n\n if (ignoreVersion) return\n if (!semverSatisfies(this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION)) {\n throw new Error(`Unsupported compiler version ${this.compilerVersion}. ` +\n `Supported: >= ${COMPILER_GE_VERSION} < ${COMPILER_LT_VERSION}`)\n }\n },\n _ensureCompilerReady () {\n if (!this._compilerApi) throw new Error('Compiler is not ready')\n },\n _prepareCompilerOptions ({ filesystem = {} } = {}) {\n return { file_system: filesystem }\n },\n getCompilerVersion () {\n this._ensureCompilerReady()\n return Promise.resolve(this.compilerVersion)\n },\n /**\n * Encode call data for contract call\n * @function\n * @category async\n * @param {String} source Contract source code\n * @param {String} name Name of function to call\n * @param {Array} args Argument's for call\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem={}] Contract external namespaces map\n * @return {Promise<String>}\n */\n async contractEncodeCallDataAPI (source, name, args = [], options) {\n this._ensureCompilerReady()\n const { calldata } = await this._compilerApi.encodeCalldata({\n source,\n function: name,\n arguments: args,\n options: this._prepareCompilerOptions(options)\n })\n return calldata\n },\n async compileContractAPI (code, options) {\n this._ensureCompilerReady()\n const { bytecode } = await this._compilerApi.compileContract({\n code,\n options: this._prepareCompilerOptions(options)\n })\n return bytecode\n },\n contractGetACI (code, options) {\n this._ensureCompilerReady()\n return this._compilerApi.generateACI({ code, options: this._prepareCompilerOptions(options) })\n },\n contractDecodeCallDataByCodeAPI (bytecode, calldata) {\n this._ensureCompilerReady()\n return this._compilerApi.decodeCalldataBytecode({ bytecode, calldata })\n },\n contractDecodeCallDataBySourceAPI (source, fn, callData, options) {\n this._ensureCompilerReady()\n return this._compilerApi.decodeCalldataSource({\n function: fn,\n source,\n calldata: callData,\n options: this._prepareCompilerOptions(options)\n })\n },\n /**\n * Decode contract call result data\n * @function\n * @category async\n * @param {String} source - source code\n * @param {String } fn - function name\n * @param {String} callValue - result call data\n * @param {String} callResult - result status\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem={}] Contract external namespaces map\n * @return {Promise<String>} Result object\n * @example\n * const decodedData = await sdk.contractDecodeCallResultAPI(\n * SourceCode ,'functionName', 'cb_asdasdasd...', 'ok|revert'\n * )\n */\n contractDecodeCallResultAPI (source, fn, callValue, callResult, options) {\n this._ensureCompilerReady()\n return this._compilerApi.decodeCallResult({\n function: fn,\n source,\n 'call-result': callResult,\n 'call-value': callValue,\n options: this._prepareCompilerOptions(options)\n })\n },\n async validateByteCodeAPI (bytecode, source, options) {\n this._ensureCompilerReady()\n const res = await this._compilerApi.validateByteCode({\n bytecode,\n source,\n options: this._prepareCompilerOptions(options)\n })\n return typeof res === 'object' ? true : res\n },\n getFateAssembler (bytecode, options) {\n this._ensureCompilerReady()\n return this._compilerApi.getFateAssemblerCode(\n { bytecode, options: this._prepareCompilerOptions(options) }\n )\n },\n getBytecodeCompilerVersion (bytecode, options) {\n this._ensureCompilerReady()\n return this._compilerApi.getCompilerVersion({\n bytecode,\n options: this._prepareCompilerOptions(options)\n })\n }\n },\n props: {\n compilerVersion: null\n }\n})\n\nconst COMPILER_GE_VERSION = '6.0.0'\nconst COMPILER_LT_VERSION = '7.0.0'\n"],"file":"compiler.js"}
@@ -1,22 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- import { MAX_AUTH_FUN_GAS } from '../../tx/builder/schema';
3
- export const prepareGaParams = ins => async (authData, authFnName) => {
4
- if (typeof authData !== 'object') throw new Error('AuthData must be an object');
5
- if (authData.gas && BigNumber(authData.gas).gt(MAX_AUTH_FUN_GAS)) throw new Error(`the maximum gas value for ga authFun is ${MAX_AUTH_FUN_GAS}, got ${authData.gas}`);
6
- const gas = authData.gas || MAX_AUTH_FUN_GAS;
7
-
8
- if (authData.callData) {
9
- if (authData.callData.split('_')[0] !== 'cb') throw new Error('Auth data must be a string with "cb" prefix.');
10
- return {
11
- authCallData: authData.callData,
12
- gas
13
- };
14
- }
15
-
16
- if (!authData.source || !authData.args) throw new Error('Auth data must contain source code and arguments.');
17
- return {
18
- authCallData: await ins.contractEncodeCallDataAPI(authData.source, authFnName, authData.args),
19
- gas
20
- };
21
- };
22
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/contract/ga/helpers.js"],"names":["BigNumber","MAX_AUTH_FUN_GAS","prepareGaParams","ins","authData","authFnName","Error","gas","gt","callData","split","authCallData","source","args","contractEncodeCallDataAPI"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,cAAtB;AACA,SAASC,gBAAT,QAAiC,yBAAjC;AAEA,OAAO,MAAMC,eAAe,GAAIC,GAAD,IAAS,OAAOC,QAAP,EAAiBC,UAAjB,KAAgC;AACtE,MAAI,OAAOD,QAAP,KAAoB,QAAxB,EAAkC,MAAM,IAAIE,KAAJ,CAAU,4BAAV,CAAN;AAClC,MAAIF,QAAQ,CAACG,GAAT,IAAgBP,SAAS,CAACI,QAAQ,CAACG,GAAV,CAAT,CAAwBC,EAAxB,CAA2BP,gBAA3B,CAApB,EAAkE,MAAM,IAAIK,KAAJ,CAAW,2CAA0CL,gBAAiB,SAAQG,QAAQ,CAACG,GAAI,EAA3F,CAAN;AAClE,QAAMA,GAAG,GAAGH,QAAQ,CAACG,GAAT,IAAgBN,gBAA5B;;AACA,MAAIG,QAAQ,CAACK,QAAb,EAAuB;AACrB,QAAIL,QAAQ,CAACK,QAAT,CAAkBC,KAAlB,CAAwB,GAAxB,EAA6B,CAA7B,MAAoC,IAAxC,EAA8C,MAAM,IAAIJ,KAAJ,CAAU,8CAAV,CAAN;AAC9C,WAAO;AAAEK,MAAAA,YAAY,EAAEP,QAAQ,CAACK,QAAzB;AAAmCF,MAAAA;AAAnC,KAAP;AACD;;AACD,MAAI,CAACH,QAAQ,CAACQ,MAAV,IAAoB,CAACR,QAAQ,CAACS,IAAlC,EAAwC,MAAM,IAAIP,KAAJ,CAAU,mDAAV,CAAN;AACxC,SAAO;AACLK,IAAAA,YAAY,EAAE,MAAMR,GAAG,CAACW,yBAAJ,CAA8BV,QAAQ,CAACQ,MAAvC,EAA+CP,UAA/C,EAA2DD,QAAQ,CAACS,IAApE,CADf;AAELN,IAAAA;AAFK,GAAP;AAID,CAbM","sourcesContent":["import BigNumber from 'bignumber.js'\nimport { MAX_AUTH_FUN_GAS } from '../../tx/builder/schema'\n\nexport const prepareGaParams = (ins) => async (authData, authFnName) => {\n if (typeof authData !== 'object') throw new Error('AuthData must be an object')\n if (authData.gas && BigNumber(authData.gas).gt(MAX_AUTH_FUN_GAS)) throw new Error(`the maximum gas value for ga authFun is ${MAX_AUTH_FUN_GAS}, got ${authData.gas}`)\n const gas = authData.gas || MAX_AUTH_FUN_GAS\n if (authData.callData) {\n if (authData.callData.split('_')[0] !== 'cb') throw new Error('Auth data must be a string with \"cb\" prefix.')\n return { authCallData: authData.callData, gas }\n }\n if (!authData.source || !authData.args) throw new Error('Auth data must contain source code and arguments.')\n return {\n authCallData: await ins.contractEncodeCallDataAPI(authData.source, authFnName, authData.args),\n gas\n }\n}\n"],"file":"helpers.js"}
@@ -1,170 +0,0 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2018 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
- /**
19
- * Generalize Account module - routines to use generalize account
20
- *
21
- * @module @aeternity/aepp-sdk/es/contract/ga
22
- * @export GeneralizeAccount
23
- * @example import { GeneralizeAccount } from '@aeternity/aepp-sdk'
24
- */
25
- import { ContractAPI } from '../../ae/contract';
26
- import { TX_TYPE } from '../../tx/builder/schema';
27
- import { buildTx, unpackTx } from '../../tx/builder';
28
- import { prepareGaParams } from './helpers';
29
- import { hash } from '../../utils/crypto';
30
- /**
31
- * GeneralizeAccount Stamp
32
- *
33
- * Provide Generalize Account implementation
34
- * {@link module:@aeternity/aepp-sdk/es/contract/ga} clients.
35
- * @function
36
- * @alias module:@aeternity/aepp-sdk/es/contract/ga
37
- * @rtype Stamp
38
- * @param {Object} [options={}] - Initializer object
39
- * @return {Object} GeneralizeAccount instance
40
- * @example
41
- * const authContract = ``
42
- * await client.createGeneralizeAccount(authFnName, authContract, [...authFnArguments]
43
- * // Make spend using GA
44
- * const callData = 'cb_...' // encoded call data for auth contract
45
- * await client.spend(10000, receiverPub, { authData: { callData } })
46
- * // or
47
- * await client.spend(10000, receiverPub, {
48
- * authData: { source: authContract, args: [...authContractArgs] }
49
- * }) // sdk will prepare callData itself
50
- */
51
-
52
- export const GeneralizeAccount = ContractAPI.compose({
53
- methods: {
54
- createGeneralizeAccount,
55
- createMetaTx,
56
- isGA
57
- }
58
- });
59
- export default GeneralizeAccount;
60
- /**
61
- * @alias module:@aeternity/aepp-sdk/es/contract/ga
62
- * @function
63
- * Check if account is GA account
64
- * @param {String} address - Account address
65
- * @return {Boolean}
66
- */
67
-
68
- async function isGA(address) {
69
- const {
70
- contractId
71
- } = await this.getAccount(address);
72
- return !!contractId;
73
- }
74
- /**
75
- * Convert current account to GA account
76
- * @alias module:@aeternity/aepp-sdk/es/contract/ga
77
- * @function
78
- * @param {String} authFnName - Authorization function name
79
- * @param {String} source - Auth contract source code
80
- * @param {Array} [args] - init arguments
81
- * @param {Object} [options] - Options
82
- * @return {Promise<Readonly<{
83
- * result: *, owner: *, createdAt: Date, address, rawTx: *, transaction: *
84
- * }>>}
85
- */
86
-
87
-
88
- async function createGeneralizeAccount(authFnName, source) {
89
- let args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
90
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
91
- const opt = { ...this.Ae.defaults,
92
- ...options
93
- };
94
- const ownerId = await this.address(opt);
95
- if (await this.isGA(ownerId)) throw new Error(`Account ${ownerId} is already GA`);
96
- const {
97
- tx,
98
- contractId
99
- } = await this.gaAttachTx({ ...opt,
100
- ownerId,
101
- code: (await this.contractCompile(source)).bytecode,
102
- callData: await this.contractEncodeCallDataAPI(source, 'init', args),
103
- authFun: hash(authFnName)
104
- });
105
- const {
106
- hash: transaction,
107
- rawTx
108
- } = await this.send(tx, opt);
109
- return Object.freeze({
110
- owner: ownerId,
111
- transaction,
112
- rawTx,
113
- gaContractId: contractId
114
- });
115
- }
116
-
117
- const wrapInEmptySignedTx = tx => buildTx({
118
- encodedTx: tx,
119
- signatures: []
120
- }, TX_TYPE.signed);
121
- /**
122
- * Create a metaTx transaction
123
- * @alias module:@aeternity/aepp-sdk/es/contract/ga
124
- * @function
125
- * @param {String} rawTransaction Inner transaction
126
- * @param {Object} authData Object with gaMeta params
127
- * @param {String} authFnName - Authorization function name
128
- * @param {Object} options - Options
129
- * @return {String}
130
- */
131
-
132
-
133
- async function createMetaTx(rawTransaction, authData, authFnName) {
134
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
135
- if (!authData) throw new Error('authData is required'); // Check if authData is callData or if it's an object prepare a callData from source and args
136
-
137
- const {
138
- authCallData,
139
- gas
140
- } = await prepareGaParams(this)(authData, authFnName);
141
- const opt = { ...this.Ae.defaults,
142
- ...options
143
- };
144
- const {
145
- abiVersion
146
- } = await this.getVmVersion(TX_TYPE.contractCall);
147
- const wrappedTx = wrapInEmptySignedTx(unpackTx(rawTransaction));
148
- const params = { ...opt,
149
- tx: { ...wrappedTx,
150
- tx: wrappedTx.txObject
151
- },
152
- gaId: await this.address(opt),
153
- abiVersion: abiVersion,
154
- authData: authCallData,
155
- gas,
156
- vsn: 2
157
- };
158
- const {
159
- fee
160
- } = await this.prepareTxParams(TX_TYPE.gaMeta, params);
161
- const {
162
- rlpEncoded: metaTxRlp
163
- } = buildTx({ ...params,
164
- fee: `${fee}`
165
- }, TX_TYPE.gaMeta, {
166
- vsn: 2
167
- });
168
- return wrapInEmptySignedTx(metaTxRlp).tx;
169
- }
170
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/contract/ga/index.js"],"names":["ContractAPI","TX_TYPE","buildTx","unpackTx","prepareGaParams","hash","GeneralizeAccount","compose","methods","createGeneralizeAccount","createMetaTx","isGA","address","contractId","getAccount","authFnName","source","args","options","opt","Ae","defaults","ownerId","Error","tx","gaAttachTx","code","contractCompile","bytecode","callData","contractEncodeCallDataAPI","authFun","transaction","rawTx","send","Object","freeze","owner","gaContractId","wrapInEmptySignedTx","encodedTx","signatures","signed","rawTransaction","authData","authCallData","gas","abiVersion","getVmVersion","contractCall","wrappedTx","params","txObject","gaId","vsn","fee","prepareTxParams","gaMeta","rlpEncoded","metaTxRlp"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,OAAT,QAAwB,yBAAxB;AACA,SAASC,OAAT,EAAkBC,QAAlB,QAAkC,kBAAlC;AACA,SAASC,eAAT,QAAgC,WAAhC;AACA,SAASC,IAAT,QAAqB,oBAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,iBAAiB,GAAGN,WAAW,CAACO,OAAZ,CAAoB;AACnDC,EAAAA,OAAO,EAAE;AACPC,IAAAA,uBADO;AAEPC,IAAAA,YAFO;AAGPC,IAAAA;AAHO;AAD0C,CAApB,CAA1B;AAOP,eAAeL,iBAAf;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeK,IAAf,CAAqBC,OAArB,EAA8B;AAC5B,QAAM;AAAEC,IAAAA;AAAF,MAAiB,MAAM,KAAKC,UAAL,CAAgBF,OAAhB,CAA7B;AACA,SAAO,CAAC,CAACC,UAAT;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAeJ,uBAAf,CAAwCM,UAAxC,EAAoDC,MAApD,EAAqF;AAAA,MAAzBC,IAAyB,uEAAlB,EAAkB;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACnF,QAAMC,GAAG,GAAG,EAAE,GAAG,KAAKC,EAAL,CAAQC,QAAb;AAAuB,OAAGH;AAA1B,GAAZ;AACA,QAAMI,OAAO,GAAG,MAAM,KAAKV,OAAL,CAAaO,GAAb,CAAtB;AAEA,MA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AEsB,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAwB,MAAM1C,eAAe,CAAC,IAAD,CAAf,CAAsBwC,QAAtB,EAAgC7B,UAAhC,CAApC;AACA,QAAMI,GAAG,GAAG,EAAE,GAAG,KAAKC,EAAL,CAAQC,QAAb;AAAuB,OAAGH;AAA1B,GAAZ;AACA,QAAM;AAAE6B,IAAAA;AAAF,MAAiB,MAAM,KAAKC,YAAL,CAAkB/C,OAAO,CAACgD,YAA1B,CAA7B;AACA,QAAMC,SAAS,GAAGX,mBAAmB,CAACpC,QAAQ,CAACwC,cAAD,CAAT,CAArC;AACA,QAAMQ,MAAM,GAAG,EACb,GAAGhC,GADU;AAEbK,IAAAA,EAAE,EAAE,EACF,GAAG0B,SADD;AAEF1B,MAAAA,EAAE,EAAE0B,SAAS,CAACE;AAFZ,KAFS;AAMbC,IAAAA,IAAI,EAAE,MAAM,KAAKzC,OAAL,CAAaO,GAAb,CANC;AAOb4B,IAAAA,UAAU,EAAEA,UAPC;AAQbH,IAAAA,QAAQ,EAAEC,YARG;AASbC,IAAAA,GATa;AAUbQ,IAAAA,GAAG,EAAE;AAVQ,GAAf;AAYA,QAAM;AAAEC,IAAAA;AAAF,MAAU,MAAM,KAAKC,eAAL,CAAqBvD,OAAO,CAACwD,MAA7B,EAAqCN,MAArC,CAAtB;AACA,QAAM;AAAEO,IAAAA,UAAU,EAAEC;AAAd,MAA4BzD,OAAO,CACvC,EAAE,GAAGiD,MAAL;AAAaI,IAAAA,GAAG,EAAG,GAAEA,GAAI;AAAzB,GADuC,EAEvCtD,OAAO,CAACwD,MAF+B,EAGvC;AAAEH,IAAAA,GAAG,EAAE;AAAP,GAHuC,CAAzC;AAKA,SAAOf,mBAAmB,CAACoB,SAAD,CAAnB,CAA+BnC,EAAtC;AACD","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Generalize Account module - routines to use generalize account\n *\n * @module @aeternity/aepp-sdk/es/contract/ga\n * @export GeneralizeAccount\n * @example import { GeneralizeAccount } from '@aeternity/aepp-sdk'\n */\nimport { ContractAPI } from '../../ae/contract'\nimport { TX_TYPE } from '../../tx/builder/schema'\nimport { buildTx, unpackTx } from '../../tx/builder'\nimport { prepareGaParams } from './helpers'\nimport { hash } from '../../utils/crypto'\n\n/**\n * GeneralizeAccount Stamp\n *\n * Provide Generalize Account implementation\n * {@link module:@aeternity/aepp-sdk/es/contract/ga} clients.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/contract/ga\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} GeneralizeAccount instance\n * @example\n * const authContract = ``\n * await client.createGeneralizeAccount(authFnName, authContract, [...authFnArguments]\n * // Make spend using GA\n * const callData = 'cb_...' // encoded call data for auth contract\n * await client.spend(10000, receiverPub, { authData: { callData } })\n * // or\n * await client.spend(10000, receiverPub, {\n * authData: { source: authContract, args: [...authContractArgs] }\n * }) // sdk will prepare callData itself\n */\nexport const GeneralizeAccount = ContractAPI.compose({\n methods: {\n createGeneralizeAccount,\n createMetaTx,\n isGA\n }\n})\nexport default GeneralizeAccount\n\n/**\n * @alias module:@aeternity/aepp-sdk/es/contract/ga\n * @function\n * Check if account is GA account\n * @param {String} address - Account address\n * @return {Boolean}\n */\nasync function isGA (address) {\n const { contractId } = await this.getAccount(address)\n return !!contractId\n}\n\n/**\n * Convert current account to GA account\n * @alias module:@aeternity/aepp-sdk/es/contract/ga\n * @function\n * @param {String} authFnName - Authorization function name\n * @param {String} source - Auth contract source code\n * @param {Array} [args] - init arguments\n * @param {Object} [options] - Options\n * @return {Promise<Readonly<{\n * result: *, owner: *, createdAt: Date, address, rawTx: *, transaction: *\n * }>>}\n */\nasync function createGeneralizeAccount (authFnName, source, args = [], options = {}) {\n const opt = { ...this.Ae.defaults, ...options }\n const ownerId = await this.address(opt)\n\n if (await this.isGA(ownerId)) throw new Error(`Account ${ownerId} is already GA`)\n\n const { tx, contractId } = await this.gaAttachTx({\n ...opt,\n ownerId,\n code: (await this.contractCompile(source)).bytecode,\n callData: await this.contractEncodeCallDataAPI(source, 'init', args),\n authFun: hash(authFnName)\n })\n\n const { hash: transaction, rawTx } = await this.send(tx, opt)\n\n return Object.freeze({\n owner: ownerId,\n transaction,\n rawTx,\n gaContractId: contractId\n })\n}\n\nconst wrapInEmptySignedTx = (tx) => buildTx({ encodedTx: tx, signatures: [] }, TX_TYPE.signed)\n\n/**\n * Create a metaTx transaction\n * @alias module:@aeternity/aepp-sdk/es/contract/ga\n * @function\n * @param {String} rawTransaction Inner transaction\n * @param {Object} authData Object with gaMeta params\n * @param {String} authFnName - Authorization function name\n * @param {Object} options - Options\n * @return {String}\n */\nasync function createMetaTx (rawTransaction, authData, authFnName, options = {}) {\n if (!authData) throw new Error('authData is required')\n // Check if authData is callData or if it's an object prepare a callData from source and args\n const { authCallData, gas } = await prepareGaParams(this)(authData, authFnName)\n const opt = { ...this.Ae.defaults, ...options }\n const { abiVersion } = await this.getVmVersion(TX_TYPE.contractCall)\n const wrappedTx = wrapInEmptySignedTx(unpackTx(rawTransaction))\n const params = {\n ...opt,\n tx: {\n ...wrappedTx,\n tx: wrappedTx.txObject\n },\n gaId: await this.address(opt),\n abiVersion: abiVersion,\n authData: authCallData,\n gas,\n vsn: 2\n }\n const { fee } = await this.prepareTxParams(TX_TYPE.gaMeta, params)\n const { rlpEncoded: metaTxRlp } = buildTx(\n { ...params, fee: `${fee}` },\n TX_TYPE.gaMeta,\n { vsn: 2 }\n )\n return wrapInEmptySignedTx(metaTxRlp).tx\n}\n"],"file":"index.js"}