@aeternity/aepp-sdk 10.0.0 → 11.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 (238) hide show
  1. package/README.md +15 -14
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +7 -27
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +1 -1
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +1 -1
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/account/{base.js → base.mjs} +20 -10
  10. package/es/account/base.mjs.map +1 -0
  11. package/es/account/{memory.js → memory.mjs} +29 -14
  12. package/es/account/memory.mjs.map +1 -0
  13. package/es/account/{multiple.js → multiple.mjs} +10 -9
  14. package/es/account/multiple.mjs.map +1 -0
  15. package/es/ae/{aens.js → aens.mjs} +18 -22
  16. package/es/ae/aens.mjs.map +1 -0
  17. package/es/ae/{aepp.js → aepp.mjs} +9 -9
  18. package/es/ae/aepp.mjs.map +1 -0
  19. package/es/ae/contract.mjs +159 -0
  20. package/es/ae/contract.mjs.map +1 -0
  21. package/es/ae/{index.js → index.mjs} +8 -7
  22. package/es/ae/index.mjs.map +1 -0
  23. package/es/ae/{oracle.js → oracle.mjs} +33 -16
  24. package/es/ae/oracle.mjs.map +1 -0
  25. package/es/ae/{universal.js → universal.mjs} +10 -10
  26. package/es/ae/universal.mjs.map +1 -0
  27. package/es/ae/{wallet.js → wallet.mjs} +10 -10
  28. package/es/ae/wallet.mjs.map +1 -0
  29. package/es/aepp-wallet-communication/schema.d.ts +74 -0
  30. package/es/bignumber.d.ts +1 -7
  31. package/es/chain/{index.js → index.mjs} +20 -4
  32. package/es/chain/index.mjs.map +1 -0
  33. package/es/chain/{node.js → node.mjs} +121 -73
  34. package/es/chain/node.mjs.map +1 -0
  35. package/es/channel/{handlers.js → handlers.mjs} +18 -20
  36. package/es/channel/handlers.mjs.map +1 -0
  37. package/es/channel/{index.js → index.mjs} +7 -7
  38. package/es/channel/index.mjs.map +1 -0
  39. package/es/channel/{internal.js → internal.mjs} +49 -32
  40. package/es/channel/internal.mjs.map +1 -0
  41. package/es/contract/aci.mjs +477 -0
  42. package/es/contract/aci.mjs.map +1 -0
  43. package/es/contract/compiler.mjs +115 -0
  44. package/es/contract/compiler.mjs.map +1 -0
  45. package/es/contract/ga/helpers.mjs +30 -0
  46. package/es/contract/ga/helpers.mjs.map +1 -0
  47. package/es/contract/ga/{index.js → index.mjs} +36 -28
  48. package/es/contract/ga/index.mjs.map +1 -0
  49. package/es/errors.d.ts +284 -0
  50. package/es/index.mjs +57 -0
  51. package/es/index.mjs.map +1 -0
  52. package/es/node-pool/{index.js → index.mjs} +11 -10
  53. package/es/node-pool/index.mjs.map +1 -0
  54. package/es/{node.js → node.mjs} +9 -8
  55. package/es/node.mjs.map +1 -0
  56. package/es/tx/builder/field-types.mjs +74 -0
  57. package/es/tx/builder/field-types.mjs.map +1 -0
  58. package/es/tx/builder/{helpers.js → helpers.mjs} +114 -56
  59. package/es/tx/builder/helpers.mjs.map +1 -0
  60. package/es/tx/builder/{index.js → index.mjs} +79 -68
  61. package/es/tx/builder/index.mjs.map +1 -0
  62. package/es/tx/builder/{schema.js → schema.mjs} +11 -65
  63. package/es/tx/builder/schema.mjs.map +1 -0
  64. package/es/tx/{index.js → index.mjs} +5 -2
  65. package/es/tx/index.mjs.map +1 -0
  66. package/es/tx/{tx-object.js → tx-object.mjs} +22 -15
  67. package/es/tx/tx-object.mjs.map +1 -0
  68. package/es/tx/{tx.js → tx.mjs} +15 -14
  69. package/es/tx/tx.mjs.map +1 -0
  70. package/es/tx/{validator.js → validator.mjs} +72 -33
  71. package/es/tx/validator.mjs.map +1 -0
  72. package/es/typings/blakejs/index.d.mjs +2 -0
  73. package/es/typings/blakejs/{index.d.js.map → index.d.mjs.map} +1 -1
  74. package/es/utils/aepp-wallet-communication/connection/{browser-runtime.js → browser-runtime.mjs} +7 -6
  75. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +1 -0
  76. package/es/utils/aepp-wallet-communication/connection/{browser-window-message.js → browser-window-message.mjs} +10 -11
  77. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +1 -0
  78. package/es/utils/aepp-wallet-communication/connection/{index.js → index.mjs} +5 -2
  79. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +1 -0
  80. package/es/utils/aepp-wallet-communication/{content-script-bridge.js → content-script-bridge.mjs} +6 -5
  81. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +1 -0
  82. package/es/utils/aepp-wallet-communication/{helpers.js → helpers.mjs} +3 -14
  83. package/es/utils/aepp-wallet-communication/helpers.mjs.map +1 -0
  84. package/es/utils/aepp-wallet-communication/rpc/{aepp-rpc.js → aepp-rpc.mjs} +113 -67
  85. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -0
  86. package/es/utils/aepp-wallet-communication/rpc/{rpc-client.js → rpc-client.mjs} +14 -9
  87. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +1 -0
  88. package/es/utils/aepp-wallet-communication/rpc/{wallet-rpc.js → wallet-rpc.mjs} +71 -63
  89. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +1 -0
  90. package/es/utils/aepp-wallet-communication/schema.mjs +102 -0
  91. package/es/utils/aepp-wallet-communication/schema.mjs.map +1 -0
  92. package/es/utils/aepp-wallet-communication/{wallet-detector.js → wallet-detector.mjs} +6 -5
  93. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  94. package/es/utils/{amount-formatter.js → amount-formatter.mjs} +14 -7
  95. package/es/utils/amount-formatter.mjs.map +1 -0
  96. package/es/utils/{async-init.js → async-init.mjs} +8 -11
  97. package/es/utils/async-init.mjs.map +1 -0
  98. package/es/utils/{bignumber.js → bignumber.mjs} +2 -9
  99. package/es/utils/bignumber.mjs.map +1 -0
  100. package/es/utils/{bytes.js → bytes.mjs} +16 -8
  101. package/es/utils/bytes.mjs.map +1 -0
  102. package/es/utils/{crypto-ts.js → crypto-ts.mjs} +11 -3
  103. package/es/utils/crypto-ts.mjs.map +1 -0
  104. package/es/utils/{crypto.js → crypto.mjs} +40 -105
  105. package/es/utils/crypto.mjs.map +1 -0
  106. package/es/utils/errors.mjs +689 -0
  107. package/es/utils/errors.mjs.map +1 -0
  108. package/es/utils/{hd-wallet.js → hd-wallet.mjs} +33 -34
  109. package/es/utils/hd-wallet.mjs.map +1 -0
  110. package/es/utils/{json-big.js → json-big.mjs} +1 -1
  111. package/es/utils/{json-big.js.map → json-big.mjs.map} +1 -1
  112. package/es/utils/{keystore.js → keystore.mjs} +63 -51
  113. package/es/utils/keystore.mjs.map +1 -0
  114. package/es/utils/{mptree.js → mptree.mjs} +21 -12
  115. package/es/utils/mptree.mjs.map +1 -0
  116. package/es/utils/{other.js → other.mjs} +2 -2
  117. package/es/utils/other.mjs.map +1 -0
  118. package/es/utils/{semver-satisfies.js → semver-satisfies.mjs} +1 -1
  119. package/es/utils/{semver-satisfies.js.map → semver-satisfies.mjs.map} +1 -1
  120. package/es/utils/{string.js → string.mjs} +1 -1
  121. package/es/utils/{string.js.map → string.mjs.map} +1 -1
  122. package/es/utils/{swagger.js → swagger.mjs} +46 -14
  123. package/es/utils/swagger.mjs.map +1 -0
  124. package/package.json +46 -55
  125. package/src/account/memory.js +13 -8
  126. package/src/account/multiple.js +12 -4
  127. package/src/ae/aens.js +12 -17
  128. package/src/ae/aepp.js +2 -2
  129. package/src/ae/contract.js +15 -152
  130. package/src/ae/index.js +2 -1
  131. package/src/ae/oracle.js +25 -10
  132. package/src/ae/universal.js +2 -2
  133. package/src/ae/wallet.js +2 -2
  134. package/src/chain/index.js +21 -2
  135. package/src/chain/node.js +80 -53
  136. package/src/channel/handlers.js +20 -17
  137. package/src/channel/internal.js +30 -24
  138. package/src/contract/{aci/index.js → aci.js} +152 -93
  139. package/src/contract/compiler.js +22 -117
  140. package/src/contract/ga/helpers.js +7 -5
  141. package/src/contract/ga/index.js +27 -24
  142. package/src/index.js +7 -8
  143. package/src/node-pool/index.js +9 -8
  144. package/src/node.js +5 -7
  145. package/src/tx/builder/field-types.js +61 -0
  146. package/src/tx/builder/helpers.js +113 -58
  147. package/src/tx/builder/index.js +39 -34
  148. package/src/tx/builder/schema.js +11 -25
  149. package/src/tx/tx-object.js +10 -9
  150. package/src/tx/tx.js +17 -8
  151. package/src/tx/validator.js +25 -5
  152. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +8 -3
  153. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +10 -6
  154. package/src/utils/aepp-wallet-communication/content-script-bridge.js +5 -4
  155. package/src/utils/aepp-wallet-communication/helpers.js +2 -12
  156. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +81 -55
  157. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +15 -6
  158. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +60 -49
  159. package/src/utils/aepp-wallet-communication/schema.ts +80 -0
  160. package/src/utils/aepp-wallet-communication/wallet-detector.js +3 -2
  161. package/src/utils/amount-formatter.ts +4 -3
  162. package/src/utils/async-init.js +10 -6
  163. package/src/utils/bignumber.ts +1 -9
  164. package/src/utils/bytes.ts +3 -2
  165. package/src/utils/crypto-ts.ts +2 -2
  166. package/src/utils/crypto.js +9 -92
  167. package/src/utils/errors.ts +683 -0
  168. package/src/utils/hd-wallet.js +11 -26
  169. package/src/utils/keystore.js +47 -51
  170. package/src/utils/mptree.ts +12 -6
  171. package/src/utils/swagger.js +67 -44
  172. package/CHANGELOG.md +0 -1603
  173. package/es/account/base.js.map +0 -1
  174. package/es/account/memory.js.map +0 -1
  175. package/es/account/multiple.js.map +0 -1
  176. package/es/ae/aens.js.map +0 -1
  177. package/es/ae/aepp.js.map +0 -1
  178. package/es/ae/contract.js +0 -312
  179. package/es/ae/contract.js.map +0 -1
  180. package/es/ae/index.js.map +0 -1
  181. package/es/ae/oracle.js.map +0 -1
  182. package/es/ae/universal.js.map +0 -1
  183. package/es/ae/wallet.js.map +0 -1
  184. package/es/chain/index.js.map +0 -1
  185. package/es/chain/node.js.map +0 -1
  186. package/es/channel/handlers.js.map +0 -1
  187. package/es/channel/index.js.map +0 -1
  188. package/es/channel/internal.js.map +0 -1
  189. package/es/contract/aci/helpers.js +0 -298
  190. package/es/contract/aci/helpers.js.map +0 -1
  191. package/es/contract/aci/index.js +0 -361
  192. package/es/contract/aci/index.js.map +0 -1
  193. package/es/contract/aci/transformation.js +0 -66
  194. package/es/contract/aci/transformation.js.map +0 -1
  195. package/es/contract/compiler.js +0 -244
  196. package/es/contract/compiler.js.map +0 -1
  197. package/es/contract/ga/helpers.js +0 -22
  198. package/es/contract/ga/helpers.js.map +0 -1
  199. package/es/contract/ga/index.js.map +0 -1
  200. package/es/contract/index.js +0 -162
  201. package/es/contract/index.js.map +0 -1
  202. package/es/index.js +0 -57
  203. package/es/index.js.map +0 -1
  204. package/es/node-pool/index.js.map +0 -1
  205. package/es/node.js.map +0 -1
  206. package/es/tx/builder/helpers.js.map +0 -1
  207. package/es/tx/builder/index.js.map +0 -1
  208. package/es/tx/builder/schema.js.map +0 -1
  209. package/es/tx/index.js.map +0 -1
  210. package/es/tx/tx-object.js.map +0 -1
  211. package/es/tx/tx.js.map +0 -1
  212. package/es/tx/validator.js.map +0 -1
  213. package/es/typings/blakejs/index.d.js +0 -2
  214. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
  215. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
  216. package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
  217. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
  218. package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
  219. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
  220. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
  221. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
  222. package/es/utils/aepp-wallet-communication/schema.js +0 -107
  223. package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
  224. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
  225. package/es/utils/amount-formatter.js.map +0 -1
  226. package/es/utils/async-init.js.map +0 -1
  227. package/es/utils/bignumber.js.map +0 -1
  228. package/es/utils/bytes.js.map +0 -1
  229. package/es/utils/crypto-ts.js.map +0 -1
  230. package/es/utils/crypto.js.map +0 -1
  231. package/es/utils/hd-wallet.js.map +0 -1
  232. package/es/utils/keystore.js.map +0 -1
  233. package/es/utils/mptree.js.map +0 -1
  234. package/es/utils/other.js.map +0 -1
  235. package/es/utils/swagger.js.map +0 -1
  236. package/src/contract/aci/transformation.js +0 -72
  237. package/src/contract/index.js +0 -163
  238. package/src/utils/aepp-wallet-communication/schema.js +0 -108
@@ -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,OAAD,EAAU,WAAV,EAAuB,MAAvB,CAAP,CAAb,CANK,CAFL;AAULC,IAAAA,KAAK,EAAEZ,GAAG,CAACY,KAAJ,GAAYZ,GAAG,CAACY,KAAJ,CAAUC,OAAtB,GAAgC;AAVlC,GAAP;AAYD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA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AG,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,EAI1B,SAJ0B,EAK1B,MAL0B,EAM1B,MAN0B,EAO1B,KAP0B,EAQ1B,QAR0B,EAS1B,QAT0B,EAU1B,QAV0B,EAW1B,aAX0B,EAY1B,MAZ0B,EAa1B,WAb0B,EAc1B,OAd0B,EAe1B,SAf0B,EAgB1BC,MAhB0B,CAgBnB,CAACC,GAAD,EAAMC,IAAN,MAAgB,EAAE,GAAGD,GAAL;AAAU,GAACC,IAAD,GAAQA;AAAlB,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A+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,2BAA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AACpD,WAAKX,oBAAL;;AACA,YAAMiC,GAAG,GAAG,MAAM,KAAKrC,YAAL,CAAkBsC,gBAAlB,CAAmC;AACnDhB,QAAAA,QADmD;AAEnDV,QAAAA,MAFmD;AAGnDG,QAAAA,OAAO,EAAE,KAAKV,uBAAL,CAA6BU,OAA7B;AAH0C,OAAnC,CAAlB;AAKA,aAAO,OAAOsB,GAAP,KAAe,QAAf,GAA0B,IAA1B,GAAiCA,GAAxC;AACD,KA7HM;;AA8HPE,IAAAA,gBAAgB,CAAEjB,QAAF,EAAYP,OAAZ,EAAqB;AACnC,WAAKX,oBAAL;;AACA,aAAO,KAAKJ,YAAL,CAAkBwC,oBAAlB,CACL;AAAElB,QAAAA,QAAF;AAAYP,QAAAA,OAAO,EAAE,KAAKV,uBAAL,CAA6BU,OAA7B;AAArB,OADK,CAAP;AAGD,KAnIM;;AAoIP0B,IAAAA,0BAA0B,CAAEnB,QAAF,EAAYP,OAAZ,EAAqB;AAC7C,WAAKX,oBAAL;;AACA,aAAO,KAAKJ,YAAL,CAAkBQ,kBAAlB,CAAqC;AAC1Cc,QAAAA,QAD0C;AAE1CP,QAAAA,OAAO,EAAE,KAAKV,uBAAL,CAA6BU,OAA7B;AAFiC,OAArC,CAAP;AAID;;AA1IM,GALoC;AAiJ7C2B,EAAAA,KAAK,EAAE;AACL7C,IAAAA,eAAe,EAAE;AADZ;AAjJsC,CAAhC,CAAf;AAsJA,MAAMK,mBAAmB,GAAG,OAA5B;AACA,MAAMC,mBAAmB,GAAG,OAA5B","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 +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,MAAI,M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,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"}
@@ -1,162 +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
- * Contract Base module
20
- * @module @aeternity/aepp-sdk/es/contract
21
- * @export Contract
22
- * @example import ContractBase from '@aeternity/aepp-sdk/es/contract'
23
- */
24
- import stampit from '@stamp/it';
25
- import { required } from '@stamp/required';
26
- /**
27
- * Basic Contract Stamp
28
- *
29
- * This stamp include api call's related to contract functionality.
30
- * Attempting to create instances from the Stamp without overwriting all
31
- * abstract methods using composition will result in an exception.
32
- * @function
33
- * @alias module:@aeternity/aepp-sdk/es/contract
34
- * @rtype Stamp
35
- * @param {Object} [options={}] - Initializer object
36
- * @return {Object} Contract instance
37
- */
38
-
39
- const ContractBase = stampit(required({
40
- methods: {
41
- contractEncodeCallDataAPI: required,
42
- compileContractAPI: required,
43
- contractGetACI: required,
44
- setCompilerUrl: required,
45
- getCompilerVersion: required,
46
- contractDecodeCallResultAPI: required,
47
- validateByteCodeAPI: required,
48
- getFateAssembler: required,
49
- getBytecodeCompilerVersion: required
50
- }
51
- }));
52
- /**
53
- * Get contract ACI
54
- * @function contractGetACI
55
- * @instance
56
- * @abstract
57
- * @category async
58
- * @rtype (source: String, options: Array) => aciObject: Promise[Object]
59
- * @param {String} source - Contract source code
60
- * @param {Object} [options={}] Options
61
- * @param {Object} [options.filesystem] Contract external namespaces map
62
- * @return {Object} - Contract aci object
63
- */
64
-
65
- /**
66
- * Encode contract data
67
- * @function contractEncodeCallDataAPI
68
- * @instance
69
- * @abstract
70
- * @category async
71
- * @rtype (source: String, name: String, args: Array, options: Array) => callData: Promise[String]
72
- * @param {String} source - Contract source code
73
- * @param {String} name - Function name
74
- * @param {Array} args - Function argument's
75
- * @param {Object} [options={}] Options
76
- * @param {Object} [options.filesystem] Contract external namespaces map
77
- * @return {String} - Contract encoded data
78
- */
79
-
80
- /**
81
- * Decode contract call result data
82
- * @function contractDecodeCallResultAPI
83
- * @instance
84
- * @abstract
85
- * @category async
86
- * @rtype (
87
- * source: String, fn: String, callValue: String, callResult: String, options: Array
88
- * ) => decodedResult: Promise[String]
89
- * @param {String} source - Contract source
90
- * @param {String} fn - Fn name
91
- * @param {String} callValue - result data (cb_das...)
92
- * @param {String} callResult - contract call result status('ok', 'revert', ...)
93
- * @param {Object} [options={}] Options
94
- * @param {Object} [options.filesystem] Contract external namespaces map
95
- * @return {String} - Decoded contract call result
96
- */
97
-
98
- /**
99
- * Decode call data by source
100
- * @function contractDecodeCallDataBySourceAPI
101
- * @instance
102
- * @abstract
103
- * @category async
104
- * @rtype (
105
- * source: String, function: String, callData: String, options: Array
106
- * ) => decodedResult: Promise[String]
107
- * @param {String} source - contract source
108
- * @param {String} function - function name
109
- * @param {String} callData - Encoded contract call data
110
- * @param {Object} [options={}] Options
111
- * @param {Object} [options.filesystem] Contract external namespaces map
112
- * @return {String} - Decoded contract call data
113
- */
114
-
115
- /**
116
- * Decode call data by bytecode
117
- * @function contractDecodeCallDataByCodeAPI
118
- * @instance
119
- * @abstract
120
- * @category async
121
- * @rtype (code: String, callData: String) => decodedResult: Promise[String]
122
- * @param {String} code - contract byte code
123
- * @param {String} callData - Encoded contract call data
124
- * @return {String} - Decoded contract call data
125
- */
126
-
127
- /**
128
- * Compile contract
129
- * @function compileContractAPI
130
- * @instance
131
- * @abstract
132
- * @category async
133
- * @rtype (code: String, options?: Object) => compiledContract: Object
134
- * @param {String} code - Contract source code
135
- * @param {Object} [options={}] Options
136
- * @param {Object} [options.filesystem] Contract external namespaces map
137
- * @return {Object} Object which contain bytecode of contract
138
- */
139
-
140
- /**
141
- * Set compiler url
142
- * @function setCompilerUrl
143
- * @instance
144
- * @abstract
145
- * @category async
146
- * @rtype (url: String) => void
147
- * @param {String} url - Compiler url
148
- * @return {void}
149
- */
150
-
151
- /**
152
- * Get Compiler Version
153
- * @function getCompilerVersion
154
- * @instance
155
- * @abstract
156
- * @category async
157
- * @rtype () => String
158
- * @return {String} Compiler version
159
- */
160
-
161
- export default ContractBase;
162
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/contract/index.js"],"names":["stampit","required","ContractBase","methods","contractEncodeCallDataAPI","compileContractAPI","contractGetACI","setCompilerUrl","getCompilerVersion","contractDecodeCallResultAPI","validateByteCodeAPI","getFateAssembler","getBytecodeCompilerVersion"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,OAAP,MAAoB,WAApB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAGF,OAAO,CAACC,QAAQ,CAAC;AACpCE,EAAAA,OAAO,EAAE;AACPC,IAAAA,yBAAyB,EAAEH,QADpB;AAEPI,IAAAA,kBAAkB,EAAEJ,QAFb;AAGPK,IAAAA,cAAc,EAAEL,QAHT;AAIPM,IAAAA,cAAc,EAAEN,QAJT;AAKPO,IAAAA,kBAAkB,EAAEP,QALb;AAMPQ,IAAAA,2BAA2B,EAAER,QANtB;AAOPS,IAAAA,mBAAmB,EAAET,QAPd;AAQPU,IAAAA,gBAAgB,EAAEV,QARX;AASPW,IAAAA,0BAA0B,EAAEX;AATrB;AAD2B,CAAD,CAAT,CAA5B;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAeC,YAAf","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 * Contract Base module\n * @module @aeternity/aepp-sdk/es/contract\n * @export Contract\n * @example import ContractBase from '@aeternity/aepp-sdk/es/contract'\n */\n\nimport stampit from '@stamp/it'\nimport { required } from '@stamp/required'\n\n/**\n * Basic Contract Stamp\n *\n * This stamp include api call's related to contract functionality.\n * Attempting to create instances from the Stamp without overwriting all\n * abstract methods using composition will result in an exception.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/contract\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} Contract instance\n */\nconst ContractBase = stampit(required({\n methods: {\n contractEncodeCallDataAPI: required,\n compileContractAPI: required,\n contractGetACI: required,\n setCompilerUrl: required,\n getCompilerVersion: required,\n contractDecodeCallResultAPI: required,\n validateByteCodeAPI: required,\n getFateAssembler: required,\n getBytecodeCompilerVersion: required\n }\n}))\n\n/**\n * Get contract ACI\n * @function contractGetACI\n * @instance\n * @abstract\n * @category async\n * @rtype (source: String, options: Array) => aciObject: Promise[Object]\n * @param {String} source - Contract source code\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {Object} - Contract aci object\n */\n\n/**\n * Encode contract data\n * @function contractEncodeCallDataAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (source: String, name: String, args: Array, options: Array) => callData: Promise[String]\n * @param {String} source - Contract source code\n * @param {String} name - Function name\n * @param {Array} args - Function argument's\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {String} - Contract encoded data\n */\n\n/**\n * Decode contract call result data\n * @function contractDecodeCallResultAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (\n * source: String, fn: String, callValue: String, callResult: String, options: Array\n * ) => decodedResult: Promise[String]\n * @param {String} source - Contract source\n * @param {String} fn - Fn name\n * @param {String} callValue - result data (cb_das...)\n * @param {String} callResult - contract call result status('ok', 'revert', ...)\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {String} - Decoded contract call result\n */\n\n/**\n * Decode call data by source\n * @function contractDecodeCallDataBySourceAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (\n * source: String, function: String, callData: String, options: Array\n * ) => decodedResult: Promise[String]\n * @param {String} source - contract source\n * @param {String} function - function name\n * @param {String} callData - Encoded contract call data\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {String} - Decoded contract call data\n */\n\n/**\n * Decode call data by bytecode\n * @function contractDecodeCallDataByCodeAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (code: String, callData: String) => decodedResult: Promise[String]\n * @param {String} code - contract byte code\n * @param {String} callData - Encoded contract call data\n * @return {String} - Decoded contract call data\n */\n\n/**\n * Compile contract\n * @function compileContractAPI\n * @instance\n * @abstract\n * @category async\n * @rtype (code: String, options?: Object) => compiledContract: Object\n * @param {String} code - Contract source code\n * @param {Object} [options={}] Options\n * @param {Object} [options.filesystem] Contract external namespaces map\n * @return {Object} Object which contain bytecode of contract\n */\n\n/**\n * Set compiler url\n * @function setCompilerUrl\n * @instance\n * @abstract\n * @category async\n * @rtype (url: String) => void\n * @param {String} url - Compiler url\n * @return {void}\n */\n\n/**\n * Get Compiler Version\n * @function getCompilerVersion\n * @instance\n * @abstract\n * @category async\n * @rtype () => String\n * @return {String} Compiler version\n */\n\nexport default ContractBase\n"],"file":"index.js"}