@aeternity/aepp-sdk 8.2.1 → 10.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 (159) hide show
  1. package/CHANGELOG.md +216 -337
  2. package/README.md +16 -9
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
  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/account/base.js +36 -120
  11. package/es/account/base.js.map +1 -1
  12. package/es/account/memory.js +17 -19
  13. package/es/account/memory.js.map +1 -1
  14. package/es/account/multiple.js +79 -156
  15. package/es/account/multiple.js.map +1 -1
  16. package/es/ae/aens.js +205 -626
  17. package/es/ae/aens.js.map +1 -1
  18. package/es/ae/contract.js +114 -918
  19. package/es/ae/contract.js.map +1 -1
  20. package/es/ae/index.js +90 -250
  21. package/es/ae/index.js.map +1 -1
  22. package/es/ae/oracle.js +136 -504
  23. package/es/ae/oracle.js.map +1 -1
  24. package/es/ae/universal.js.map +1 -1
  25. package/es/chain/index.js +12 -27
  26. package/es/chain/index.js.map +1 -1
  27. package/es/chain/node.js +289 -1020
  28. package/es/chain/node.js.map +1 -1
  29. package/es/channel/handlers.js +597 -1086
  30. package/es/channel/handlers.js.map +1 -1
  31. package/es/channel/index.js +238 -465
  32. package/es/channel/index.js.map +1 -1
  33. package/es/channel/internal.js +129 -301
  34. package/es/channel/internal.js.map +1 -1
  35. package/es/contract/aci/index.js +328 -495
  36. package/es/contract/aci/index.js.map +1 -1
  37. package/es/contract/aci/transformation.js +35 -711
  38. package/es/contract/aci/transformation.js.map +1 -1
  39. package/es/contract/compiler.js +131 -203
  40. package/es/contract/compiler.js.map +1 -1
  41. package/es/contract/ga/helpers.js +17 -122
  42. package/es/contract/ga/helpers.js.map +1 -1
  43. package/es/contract/ga/index.js +108 -249
  44. package/es/contract/ga/index.js.map +1 -1
  45. package/es/contract/index.js +7 -3
  46. package/es/contract/index.js.map +1 -1
  47. package/es/index.js +3 -3
  48. package/es/index.js.map +1 -1
  49. package/es/node-pool/index.js +57 -74
  50. package/es/node-pool/index.js.map +1 -1
  51. package/es/node.js +65 -161
  52. package/es/node.js.map +1 -1
  53. package/es/other.d.ts +1 -1
  54. package/es/tx/builder/helpers.js +62 -115
  55. package/es/tx/builder/helpers.js.map +1 -1
  56. package/es/tx/builder/index.js +218 -309
  57. package/es/tx/builder/index.js.map +1 -1
  58. package/es/tx/builder/schema.js +586 -573
  59. package/es/tx/builder/schema.js.map +1 -1
  60. package/es/tx/index.js +102 -13
  61. package/es/tx/index.js.map +1 -1
  62. package/es/tx/tx-object.js +114 -138
  63. package/es/tx/tx-object.js.map +1 -1
  64. package/es/tx/tx.js +810 -1586
  65. package/es/tx/tx.js.map +1 -1
  66. package/es/tx/validator.js +191 -426
  67. package/es/tx/validator.js.map +1 -1
  68. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +20 -23
  69. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
  70. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +53 -80
  71. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
  72. package/es/utils/aepp-wallet-communication/connection/index.js +2 -1
  73. package/es/utils/aepp-wallet-communication/connection/index.js.map +1 -1
  74. package/es/utils/aepp-wallet-communication/content-script-bridge.js +24 -19
  75. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
  76. package/es/utils/aepp-wallet-communication/helpers.js +60 -105
  77. package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
  78. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +191 -514
  79. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
  80. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +78 -93
  81. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
  82. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +381 -613
  83. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
  84. package/es/utils/aepp-wallet-communication/schema.js +43 -39
  85. package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
  86. package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
  87. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
  88. package/es/utils/amount-formatter.js +41 -61
  89. package/es/utils/amount-formatter.js.map +1 -1
  90. package/es/utils/async-init.js +28 -64
  91. package/es/utils/async-init.js.map +1 -1
  92. package/es/utils/bignumber.js +3 -11
  93. package/es/utils/bignumber.js.map +1 -1
  94. package/es/utils/bytes.js +5 -9
  95. package/es/utils/bytes.js.map +1 -1
  96. package/es/utils/crypto.js +41 -106
  97. package/es/utils/crypto.js.map +1 -1
  98. package/es/utils/hd-wallet.js +45 -81
  99. package/es/utils/hd-wallet.js.map +1 -1
  100. package/es/utils/json-big.js +16 -49
  101. package/es/utils/json-big.js.map +1 -1
  102. package/es/utils/keystore.js +81 -246
  103. package/es/utils/keystore.js.map +1 -1
  104. package/es/utils/mptree.js +88 -134
  105. package/es/utils/mptree.js.map +1 -1
  106. package/es/utils/other.js +10 -60
  107. package/es/utils/other.js.map +1 -1
  108. package/es/utils/semver-satisfies.js +9 -28
  109. package/es/utils/semver-satisfies.js.map +1 -1
  110. package/es/utils/string.js +4 -13
  111. package/es/utils/string.js.map +1 -1
  112. package/es/utils/swagger.js +87 -224
  113. package/es/utils/swagger.js.map +1 -1
  114. package/package.json +51 -44
  115. package/src/account/base.js +11 -10
  116. package/src/account/multiple.js +24 -18
  117. package/src/ae/aens.js +64 -61
  118. package/src/ae/contract.js +71 -248
  119. package/src/ae/index.js +34 -9
  120. package/src/ae/oracle.js +30 -22
  121. package/src/ae/universal.js +3 -1
  122. package/src/chain/index.js +10 -16
  123. package/src/chain/node.js +38 -38
  124. package/src/channel/handlers.js +10 -4
  125. package/src/channel/index.js +44 -20
  126. package/src/contract/aci/index.js +234 -112
  127. package/src/contract/aci/transformation.js +30 -422
  128. package/src/contract/compiler.js +50 -5
  129. package/src/contract/ga/helpers.js +6 -14
  130. package/src/contract/ga/index.js +28 -28
  131. package/src/contract/index.js +6 -2
  132. package/src/index.js +4 -4
  133. package/src/node-pool/index.js +24 -13
  134. package/src/node.js +29 -30
  135. package/src/tx/builder/helpers.js +31 -56
  136. package/src/tx/builder/index.js +67 -28
  137. package/src/tx/builder/schema.js +79 -121
  138. package/src/tx/index.js +101 -12
  139. package/src/tx/tx-object.js +25 -8
  140. package/src/tx/tx.js +229 -150
  141. package/src/tx/validator.js +134 -202
  142. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
  143. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +25 -7
  144. package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
  145. package/src/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
  146. package/src/utils/aepp-wallet-communication/helpers.js +4 -2
  147. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +33 -12
  148. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
  149. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +59 -29
  150. package/src/utils/aepp-wallet-communication/schema.js +1 -3
  151. package/src/utils/aepp-wallet-communication/wallet-detector.js +4 -1
  152. package/src/utils/amount-formatter.ts +1 -1
  153. package/src/utils/bignumber.ts +2 -1
  154. package/src/utils/crypto.js +4 -68
  155. package/src/utils/keystore.js +10 -2
  156. package/src/utils/other.ts +1 -1
  157. package/src/utils/semver-satisfies.ts +1 -1
  158. package/src/utils/swagger.js +22 -10
  159. package/src/contract/aci/helpers.js +0 -140
@@ -36,7 +36,7 @@ import { required } from '@stamp/required';
36
36
  * @return {Object} Contract instance
37
37
  */
38
38
 
39
- var ContractBase = stampit(required({
39
+ const ContractBase = stampit(required({
40
40
  methods: {
41
41
  contractEncodeCallDataAPI: required,
42
42
  compileContractAPI: required,
@@ -83,7 +83,9 @@ var ContractBase = stampit(required({
83
83
  * @instance
84
84
  * @abstract
85
85
  * @category async
86
- * @rtype (source: String, fn: String, callValue: String, callResult: String, options: Array) => decodedResult: Promise[String]
86
+ * @rtype (
87
+ * source: String, fn: String, callValue: String, callResult: String, options: Array
88
+ * ) => decodedResult: Promise[String]
87
89
  * @param {String} source - Contract source
88
90
  * @param {String} fn - Fn name
89
91
  * @param {String} callValue - result data (cb_das...)
@@ -99,7 +101,9 @@ var ContractBase = stampit(required({
99
101
  * @instance
100
102
  * @abstract
101
103
  * @category async
102
- * @rtype (source: String, function: String, callData: String, options: Array) => decodedResult: Promise[String]
104
+ * @rtype (
105
+ * source: String, function: String, callData: String, options: Array
106
+ * ) => decodedResult: Promise[String]
103
107
  * @param {String} source - contract source
104
108
  * @param {String} function - function name
105
109
  * @param {String} callData - Encoded contract call data
@@ -1 +1 @@
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,IAAMC,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;;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;;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 (source: String, fn: String, callValue: String, callResult: String, options: Array) => 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 (source: String, function: String, callData: String, options: Array) => 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"}
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"}
package/es/index.js CHANGED
@@ -20,7 +20,6 @@ import * as Bytes from './utils/bytes';
20
20
  import * as TxBuilder from './tx/builder';
21
21
  import * as TxBuilderHelper from './tx/builder/helpers';
22
22
  import * as SCHEMA from './tx/builder/schema';
23
- import * as ACIHelpers from './contract/aci/helpers';
24
23
  import * as ACITransformation from './contract/aci/transformation';
25
24
  import * as AmountFormatter from './utils/amount-formatter';
26
25
  import HdWallet from './utils/hd-wallet';
@@ -31,7 +30,7 @@ import Node from './node';
31
30
  import NodePool from './node-pool';
32
31
  import Tx from './tx';
33
32
  import Transaction from './tx/tx';
34
- import TransactionValidator from './tx/validator';
33
+ import verifyTransaction from './tx/validator';
35
34
  import AccountBase from './account/base';
36
35
  import AccountMultiple from './account/multiple';
37
36
  import MemoryAccount from './account/memory';
@@ -53,5 +52,6 @@ export { _AeppWalletSchema as AeppWalletSchema };
53
52
  export { default as WalletDetector } from './utils/aepp-wallet-communication/wallet-detector';
54
53
  export { default as BrowserRuntimeConnection } from './utils/aepp-wallet-communication/connection/browser-runtime';
55
54
  export { default as BrowserWindowMessageConnection } from './utils/aepp-wallet-communication/connection/browser-window-message';
56
- export { AmountFormatter, AccountBase, AccountMultiple, Ae, Aens, Bytes, Contract, ContractCompilerAPI, ACIHelpers, ACITransformation, ChainNode, RpcAepp, RpcWallet, Channel, Crypto, Keystore, Chain, GeneralizeAccount, HdWallet, MemoryAccount, Node, NodePool, Oracle, genSwaggerClient, Transaction, TransactionValidator, Tx, TxBuilder, TxBuilderHelper, Universal, SCHEMA };
55
+ export const getDefaultPointerKey = TxBuilderHelper.getDefaultPointerKey;
56
+ export { AmountFormatter, AccountBase, AccountMultiple, Ae, Aens, Bytes, Contract, ContractCompilerAPI, ACITransformation, ChainNode, RpcAepp, RpcWallet, Channel, Crypto, Keystore, Chain, GeneralizeAccount, HdWallet, MemoryAccount, Node, NodePool, Oracle, genSwaggerClient, Transaction, verifyTransaction, Tx, TxBuilder, TxBuilderHelper, Universal, SCHEMA };
57
57
  //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["Crypto","Keystore","Bytes","TxBuilder","TxBuilderHelper","SCHEMA","ACIHelpers","ACITransformation","AmountFormatter","HdWallet","Ae","Chain","ChainNode","Node","NodePool","Tx","Transaction","TransactionValidator","AccountBase","AccountMultiple","MemoryAccount","Aens","Contract","GeneralizeAccount","ContractCompilerAPI","RpcAepp","RpcWallet","Oracle","genSwaggerClient","Channel","Universal","default","ContentScriptBridge","AeppWalletHelpers","AeppWalletSchema","WalletDetector","BrowserRuntimeConnection","BrowserWindowMessageConnection"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,KAAKA,MAAZ,MAAwB,gBAAxB;AACA,OAAO,KAAKC,QAAZ,MAA0B,kBAA1B;AACA,OAAO,KAAKC,KAAZ,MAAuB,eAAvB;AACA,OAAO,KAAKC,SAAZ,MAA2B,cAA3B;AACA,OAAO,KAAKC,eAAZ,MAAiC,sBAAjC;AACA,OAAO,KAAKC,MAAZ,MAAwB,qBAAxB;AACA,OAAO,KAAKC,UAAZ,MAA4B,wBAA5B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,+BAAnC;AACA,OAAO,KAAKC,eAAZ,MAAiC,0BAAjC;AACA,OAAOC,QAAP,MAAqB,mBAArB;AAEA,OAAOC,EAAP,MAAe,MAAf;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,EAAP,MAAe,MAAf;AACA,OAAOC,WAAP,MAAwB,SAAxB;AACA,OAAOC,oBAAP,MAAiC,gBAAjC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,IAAP,MAAiB,WAAjB;AACA,OAAOC,QAAP,MAAqB,eAArB;AACA,OAAOC,iBAAP,MAA8B,eAA9B;AACA,OAAOC,mBAAP,MAAgC,qBAAhC;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,MAAP,MAAmB,aAAnB;AACA,OAAOC,gBAAP,MAA6B,iBAA7B;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,SAAP,MAAsB,gBAAtB;AAEA,SAASC,OAAO,IAAIC,mBAApB,QAA+C,yDAA/C;oCACmC,2C;+BAAvBC,iB;mCACsB,0C;8BAAtBC,gB;AACZ,SAASH,OAAO,IAAII,cAApB,QAA0C,mDAA1C;AACA,SAASJ,OAAO,IAAIK,wBAApB,QAAoD,8DAApD;AACA,SAASL,OAAO,IAAIM,8BAApB,QAA0D,qEAA1D;AAEA,SACE7B,eADF,EAEEU,WAFF,EAGEC,eAHF,EAIET,EAJF,EAKEW,IALF,EAMEnB,KANF,EAOEoB,QAPF,EAQEE,mBARF,EASElB,UATF,EAUEC,iBAVF,EAWEK,SAXF,EAYEa,OAZF,EAaEC,SAbF,EAcEG,OAdF,EAeE7B,MAfF,EAgBEC,QAhBF,EAiBEU,KAjBF,EAkBEY,iBAlBF,EAmBEd,QAnBF,EAoBEW,aApBF,EAqBEP,IArBF,EAsBEC,QAtBF,EAuBEa,MAvBF,EAwBEC,gBAxBF,EAyBEZ,WAzBF,EA0BEC,oBA1BF,EA2BEF,EA3BF,EA4BEZ,SA5BF,EA6BEC,eA7BF,EA8BE0B,SA9BF,EA+BEzB,MA/BF","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\nimport * as Crypto from './utils/crypto'\nimport * as Keystore from './utils/keystore'\nimport * as Bytes from './utils/bytes'\nimport * as TxBuilder from './tx/builder'\nimport * as TxBuilderHelper from './tx/builder/helpers'\nimport * as SCHEMA from './tx/builder/schema'\nimport * as ACIHelpers from './contract/aci/helpers'\nimport * as ACITransformation from './contract/aci/transformation'\nimport * as AmountFormatter from './utils/amount-formatter'\nimport HdWallet from './utils/hd-wallet'\n\nimport Ae from './ae'\nimport Chain from './chain'\nimport ChainNode from './chain/node'\nimport Node from './node'\nimport NodePool from './node-pool'\nimport Tx from './tx'\nimport Transaction from './tx/tx'\nimport TransactionValidator from './tx/validator'\nimport AccountBase from './account/base'\nimport AccountMultiple from './account/multiple'\nimport MemoryAccount from './account/memory'\nimport Aens from './ae/aens'\nimport Contract from './ae/contract'\nimport GeneralizeAccount from './contract/ga'\nimport ContractCompilerAPI from './contract/compiler'\nimport RpcAepp from './ae/aepp'\nimport RpcWallet from './ae/wallet'\nimport Oracle from './ae/oracle'\nimport genSwaggerClient from './utils/swagger'\nimport Channel from './channel'\nimport Universal from './ae/universal'\n\nexport { default as ContentScriptBridge } from './utils/aepp-wallet-communication/content-script-bridge'\nexport * as AeppWalletHelpers from './utils/aepp-wallet-communication/helpers'\nexport * as AeppWalletSchema from './utils/aepp-wallet-communication/schema'\nexport { default as WalletDetector } from './utils/aepp-wallet-communication/wallet-detector'\nexport { default as BrowserRuntimeConnection } from './utils/aepp-wallet-communication/connection/browser-runtime'\nexport { default as BrowserWindowMessageConnection } from './utils/aepp-wallet-communication/connection/browser-window-message'\n\nexport {\n AmountFormatter,\n AccountBase,\n AccountMultiple,\n Ae,\n Aens,\n Bytes,\n Contract,\n ContractCompilerAPI,\n ACIHelpers,\n ACITransformation,\n ChainNode,\n RpcAepp,\n RpcWallet,\n Channel,\n Crypto,\n Keystore,\n Chain,\n GeneralizeAccount,\n HdWallet,\n MemoryAccount,\n Node,\n NodePool,\n Oracle,\n genSwaggerClient,\n Transaction,\n TransactionValidator,\n Tx,\n TxBuilder,\n TxBuilderHelper,\n Universal,\n SCHEMA\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["Crypto","Keystore","Bytes","TxBuilder","TxBuilderHelper","SCHEMA","ACITransformation","AmountFormatter","HdWallet","Ae","Chain","ChainNode","Node","NodePool","Tx","Transaction","verifyTransaction","AccountBase","AccountMultiple","MemoryAccount","Aens","Contract","GeneralizeAccount","ContractCompilerAPI","RpcAepp","RpcWallet","Oracle","genSwaggerClient","Channel","Universal","default","ContentScriptBridge","AeppWalletHelpers","AeppWalletSchema","WalletDetector","BrowserRuntimeConnection","BrowserWindowMessageConnection","getDefaultPointerKey"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,KAAKA,MAAZ,MAAwB,gBAAxB;AACA,OAAO,KAAKC,QAAZ,MAA0B,kBAA1B;AACA,OAAO,KAAKC,KAAZ,MAAuB,eAAvB;AACA,OAAO,KAAKC,SAAZ,MAA2B,cAA3B;AACA,OAAO,KAAKC,eAAZ,MAAiC,sBAAjC;AACA,OAAO,KAAKC,MAAZ,MAAwB,qBAAxB;AACA,OAAO,KAAKC,iBAAZ,MAAmC,+BAAnC;AACA,OAAO,KAAKC,eAAZ,MAAiC,0BAAjC;AACA,OAAOC,QAAP,MAAqB,mBAArB;AAEA,OAAOC,EAAP,MAAe,MAAf;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BEC,QArBF,EAsBEa,MAtBF,EAuBEC,gBAvBF,EAwBEZ,WAxBF,EAyBEC,iBAzBF,EA0BEF,EA1BF,EA2BEX,SA3BF,EA4BEC,eA5BF,EA6BEyB,SA7BF,EA8BExB,MA9BF","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\nimport * as Crypto from './utils/crypto'\nimport * as Keystore from './utils/keystore'\nimport * as Bytes from './utils/bytes'\nimport * as TxBuilder from './tx/builder'\nimport * as TxBuilderHelper from './tx/builder/helpers'\nimport * as SCHEMA from './tx/builder/schema'\nimport * as ACITransformation from './contract/aci/transformation'\nimport * as AmountFormatter from './utils/amount-formatter'\nimport HdWallet from './utils/hd-wallet'\n\nimport Ae from './ae'\nimport Chain from './chain'\nimport ChainNode from './chain/node'\nimport Node from './node'\nimport NodePool from './node-pool'\nimport Tx from './tx'\nimport Transaction from './tx/tx'\nimport verifyTransaction from './tx/validator'\nimport AccountBase from './account/base'\nimport AccountMultiple from './account/multiple'\nimport MemoryAccount from './account/memory'\nimport Aens from './ae/aens'\nimport Contract from './ae/contract'\nimport GeneralizeAccount from './contract/ga'\nimport ContractCompilerAPI from './contract/compiler'\nimport RpcAepp from './ae/aepp'\nimport RpcWallet from './ae/wallet'\nimport Oracle from './ae/oracle'\nimport genSwaggerClient from './utils/swagger'\nimport Channel from './channel'\nimport Universal from './ae/universal'\n\nexport { default as ContentScriptBridge } from './utils/aepp-wallet-communication/content-script-bridge'\nexport * as AeppWalletHelpers from './utils/aepp-wallet-communication/helpers'\nexport * as AeppWalletSchema from './utils/aepp-wallet-communication/schema'\nexport { default as WalletDetector } from './utils/aepp-wallet-communication/wallet-detector'\nexport { default as BrowserRuntimeConnection } from './utils/aepp-wallet-communication/connection/browser-runtime'\nexport { default as BrowserWindowMessageConnection } from './utils/aepp-wallet-communication/connection/browser-window-message'\n\nexport const getDefaultPointerKey = TxBuilderHelper.getDefaultPointerKey\n\nexport {\n AmountFormatter,\n AccountBase,\n AccountMultiple,\n Ae,\n Aens,\n Bytes,\n Contract,\n ContractCompilerAPI,\n ACITransformation,\n ChainNode,\n RpcAepp,\n RpcWallet,\n Channel,\n Crypto,\n Keystore,\n Chain,\n GeneralizeAccount,\n HdWallet,\n MemoryAccount,\n Node,\n NodePool,\n Oracle,\n genSwaggerClient,\n Transaction,\n verifyTransaction,\n Tx,\n TxBuilder,\n TxBuilderHelper,\n Universal,\n SCHEMA\n}\n"],"file":"index.js"}
@@ -1,23 +1,3 @@
1
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
6
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
7
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
8
- import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
9
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
10
-
11
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
12
-
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context4; _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
14
-
15
- import _Map from "@babel/runtime-corejs3/core-js-stable/map";
16
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
17
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
18
- import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
19
- import _entriesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/entries";
20
-
21
1
  /**
22
2
  * NodePool module
23
3
  * @module @aeternity/aepp-sdk/es/node-pool
@@ -25,7 +5,6 @@ import _entriesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
25
5
  * @example import { NodePool } from '@aeternity/aepp-sdk'
26
6
  */
27
7
  import stampit from '@stamp/it';
28
- import Joi from 'joi-browser';
29
8
  import { getNetworkId } from '../node';
30
9
  /**
31
10
  * Node Pool Stamp
@@ -39,36 +18,35 @@ import { getNetworkId } from '../node';
39
18
  */
40
19
 
41
20
  export default stampit({
42
- init: function init() {
43
- var _this = this;
44
-
45
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
46
- _ref$nodes = _ref.nodes,
47
- nodes = _ref$nodes === void 0 ? [] : _ref$nodes;
48
-
49
- this.pool = new _Map();
21
+ init() {
22
+ let {
23
+ nodes = []
24
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25
+ this.pool = new Map();
50
26
  this.validateNodes(nodes);
51
-
52
- _forEachInstanceProperty(nodes).call(nodes, function (node, i) {
53
- var name = node.name,
54
- instance = node.instance;
55
-
56
- _this.addNode(name, instance, i === 0);
27
+ nodes.forEach((node, i) => {
28
+ const {
29
+ name,
30
+ instance
31
+ } = node;
32
+ this.addNode(name, instance, i === 0);
57
33
  });
58
-
59
34
  if (nodes.length) this.selectNode(nodes[0].name);
60
35
  },
36
+
61
37
  propertyDescriptors: {
62
38
  api: {
63
39
  enumerable: true,
64
40
  configurable: false,
65
- get: function get() {
41
+
42
+ get() {
66
43
  if (!this.selectedNode || !this.selectedNode.instance) {
67
44
  throw new Error('You can\'t use Node API. Node is not connected or not defined!');
68
45
  }
69
46
 
70
47
  return this.selectedNode.instance.api;
71
48
  }
49
+
72
50
  }
73
51
  },
74
52
  methods: {
@@ -82,17 +60,18 @@ export default stampit({
82
60
  * @param {Boolean} select - Select this node as current
83
61
  * @return {void}
84
62
  * @example
85
- * nodePool.addNode('testNode', awaitNode({ url, internalUrl }), true) // add and select new node with name 'testNode'
63
+ * // add and select new node with name 'testNode'
64
+ * nodePool.addNode('testNode', awaitNode({ url, internalUrl }), true)
86
65
  */
87
- addNode: function addNode(name, node) {
88
- var select = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
89
- if (this.pool.has(name)) throw new Error("Node with name ".concat(name, " already exist"));
66
+ addNode(name, node) {
67
+ let select = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
68
+ if (this.pool.has(name)) throw new Error(`Node with name ${name} already exist`);
90
69
  this.validateNodes([{
91
- name: name,
70
+ name,
92
71
  instance: node
93
72
  }]);
94
73
  this.pool.set(name, {
95
- name: name,
74
+ name,
96
75
  instance: node,
97
76
  url: node.url,
98
77
  internalUrl: node.internalUrl,
@@ -116,8 +95,8 @@ export default stampit({
116
95
  * @example
117
96
  * nodePool.selectNode('testNode')
118
97
  */
119
- selectNode: function selectNode(name) {
120
- if (!this.pool.has(name)) throw new Error("Node with name ".concat(name, " not in pool"));
98
+ selectNode(name) {
99
+ if (!this.pool.has(name)) throw new Error(`Node with name ${name} not in pool`);
121
100
  this.selectedNode = this.pool.get(name);
122
101
  },
123
102
 
@@ -130,7 +109,7 @@ export default stampit({
130
109
  * @example
131
110
  * nodePool.getNetworkId()
132
111
  */
133
- getNetworkId: getNetworkId,
112
+ getNetworkId,
134
113
 
135
114
  /**
136
115
  * Check if you have selected node
@@ -141,7 +120,7 @@ export default stampit({
141
120
  * @example
142
121
  * nodePool.isNodeConnected()
143
122
  */
144
- isNodeConnected: function isNodeConnected() {
123
+ isNodeConnected() {
145
124
  return !!this.selectedNode.instance;
146
125
  },
147
126
 
@@ -154,11 +133,12 @@ export default stampit({
154
133
  * @example
155
134
  * nodePool.getNodeInfo() // { name, version, networkId, protocol, ... }
156
135
  */
157
- getNodeInfo: function getNodeInfo() {
136
+ getNodeInfo() {
158
137
  if (!this.isNodeConnected()) throw new Error('Can not get node info. Node is not connected');
159
- return _objectSpread({
160
- name: this.selectedNode.name
161
- }, this.selectedNode.instance.getNodeInfo());
138
+ return {
139
+ name: this.selectedNode.name,
140
+ ...this.selectedNode.instance.getNodeInfo()
141
+ };
162
142
  },
163
143
 
164
144
  /**
@@ -170,32 +150,35 @@ export default stampit({
170
150
  * @example
171
151
  * nodePool.getNodesInPool()
172
152
  */
173
- getNodesInPool: function getNodesInPool() {
174
- var _context, _context2;
175
-
176
- return _mapInstanceProperty(_context = _Array$from(_entriesInstanceProperty(_context2 = this.pool).call(_context2))).call(_context, function (_ref2) {
177
- var _ref3 = _slicedToArray(_ref2, 2),
178
- name = _ref3[0],
179
- node = _ref3[1];
180
-
181
- return _objectSpread({
182
- name: name
183
- }, node.instance.getNodeInfo());
153
+ getNodesInPool() {
154
+ return Array.from(this.pool.entries()).map(_ref => {
155
+ let [name, node] = _ref;
156
+ return {
157
+ name,
158
+ ...node.instance.getNodeInfo()
159
+ };
184
160
  });
185
161
  },
186
- validateNodes: function validateNodes(nodes) {
187
- var _Joi$array$items$labe = Joi.array().items(Joi.object({
188
- name: Joi.string().required(),
189
- instance: Joi.object({
190
- api: Joi.object().required(),
191
- consensusProtocolVersion: Joi.number().required(),
192
- genesisHash: Joi.string().required()
193
- }).unknown()
194
- })).label('node').validate(nodes),
195
- error = _Joi$array$items$labe.error;
196
-
197
- if (error) throw error;
162
+
163
+ validateNodes(nodes) {
164
+ // TODO: validate it on TypeScript level instead
165
+ // (to speedup development, save runtime resources)
166
+ if (!Array.isArray(nodes)) throw new Error('"nodes" should be an array');
167
+ const notObject = nodes.map(n => typeof n).find(t => t !== 'object');
168
+ if (notObject) throw new Error(`Each node should be an object, got ${notObject} instead`);
169
+ const wrongFields = nodes.find(n => typeof n.name !== 'string' || typeof n.instance !== 'object');
170
+
171
+ if (notObject) {
172
+ throw new Error('Each node should have name (string), instance (object) ' + `fields, got ${JSON.stringify(wrongFields)} instead`);
173
+ }
174
+
175
+ const wrongInstanceFields = nodes.map(n => n.instance).find(i => typeof i.api !== 'object' || typeof i.genesisHash !== 'string' || typeof i.consensusProtocolVersion !== 'number');
176
+
177
+ if (wrongInstanceFields) {
178
+ throw new Error('Each node instance should have api (object), consensusProtocolVersion (number), ' + `genesisHash (string) fields, got ${JSON.stringify(wrongInstanceFields)} instead`);
179
+ }
198
180
  }
181
+
199
182
  },
200
183
  props: {
201
184
  selectedNode: {}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/node-pool/index.js"],"names":["stampit","Joi","getNetworkId","init","nodes","pool","validateNodes","node","i","name","instance","addNode","length","selectNode","propertyDescriptors","api","enumerable","configurable","get","selectedNode","Error","methods","select","has","set","url","internalUrl","networkId","nodeNetworkId","version","consensusProtocolVersion","isNodeConnected","getNodeInfo","getNodesInPool","array","items","object","string","required","number","genesisHash","unknown","label","validate","error","props"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,WAApB;AACA,OAAOC,GAAP,MAAgB,aAAhB;AACA,SAASC,YAAT,QAA6B,SAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeF,OAAO,CAAC;AACrBG,EAAAA,IADqB,kBACM;AAAA;;AAAA,mFAAJ,EAAI;AAAA,0BAAnBC,KAAmB;AAAA,QAAnBA,KAAmB,2BAAX,EAAW;;AACzB,SAAKC,IAAL,GAAY,UAAZ;AACA,SAAKC,aAAL,CAAmBF,KAAnB;;AAEA,6BAAAA,KAAK,MAAL,CAAAA,KAAK,EAAS,UAACG,IAAD,EAAOC,CAAP,EAAa;AACzB,UAAQC,IAAR,GAA2BF,IAA3B,CAAQE,IAAR;AAAA,UAAcC,QAAd,GAA2BH,IAA3B,CAAcG,QAAd;;AACA,MAAA,KAAI,CAACC,OAAL,CAAaF,IAAb,EAAmBC,QAAnB,EAA6BF,CAAC,KAAK,CAAnC;AACD,KAHI,CAAL;;AAIA,QAAIJ,KAAK,CAACQ,MAAV,EAAkB,KAAKC,UAAL,CAAgBT,KAAK,CAAC,CAAD,CAAL,CAASK,IAAzB;AACnB,GAVoB;AAWrBK,EAAAA,mBAAmB,EAAE;AACnBC,IAAAA,GAAG,EAAE;AACHC,MAAAA,UAAU,EAAE,IADT;AAEHC,MAAAA,YAAY,EAAE,KAFX;AAGHC,MAAAA,GAHG,iBAGI;AACL,YAAI,CAAC,KAAKC,YAAN,IAAsB,CAAC,KAAKA,YAAL,CAAkBT,QAA7C,EAAuD;AACrD,gBAAM,IAAIU,KAAJ,CAAU,gEAAV,CAAN;AACD;;AACD,eAAO,KAAKD,YAAL,CAA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WAAW,EAAEvC,GAAG,CAACoC,MAAJ,GAAaC,QAAb;AAHM,SAAX,EAIPG,OAJO;AAFD,OAAX,CADgB,EAShBC,KATgB,CASV,MATU,EASFC,QATE,CASOvC,KATP,CAAlB;AAAA,UAAQwC,KAAR,yBAAQA,KAAR;;AAUA,UAAIA,KAAJ,EAAW,MAAMA,KAAN;AACZ;AA/GM,GAvBY;AAwIrBC,EAAAA,KAAK,EAAE;AACL1B,IAAAA,YAAY,EAAE;AADT;AAxIc,CAAD,CAAtB","sourcesContent":["/**\n * NodePool module\n * @module @aeternity/aepp-sdk/es/node-pool\n * @export NodePool\n * @example import { NodePool } from '@aeternity/aepp-sdk'\n */\nimport stampit from '@stamp/it'\nimport Joi from 'joi-browser'\nimport { getNetworkId } from '../node'\n\n/**\n * Node Pool Stamp\n * This stamp allow you to make basic manipulation(add, remove, select) on list of nodes\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @param {Array} [options.nodes] - Array with Node instances\n * @return {Object} NodePool instance\n */\nexport default stampit({\n init ({ nodes = [] } = {}) {\n this.pool = new Map()\n this.validateNodes(nodes)\n\n nodes.forEach((node, i) => {\n const { name, instance } = node\n this.addNode(name, instance, i === 0)\n })\n if (nodes.length) this.selectNode(nodes[0].name)\n },\n propertyDescriptors: {\n api: {\n enumerable: true,\n configurable: false,\n get () {\n if (!this.selectedNode || !this.selectedNode.instance) {\n throw new Error('You can\\'t use Node API. Node is not connected or not defined!')\n }\n return this.selectedNode.instance.api\n }\n }\n },\n methods: {\n /**\n * Add Node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype (name: String, nodeInstance: Object, select: Boolean) => void\n * @param {String} name - Node name\n * @param {Object} node - Node instance\n * @param {Boolean} select - Select this node as current\n * @return {void}\n * @example\n * nodePool.addNode('testNode', awaitNode({ url, internalUrl }), true) // add and select new node with name 'testNode'\n */\n addNode (name, node, select = false) {\n if (this.pool.has(name)) throw new Error(`Node with name ${name} already exist`)\n\n this.validateNodes([{ name, instance: node }])\n\n this.pool.set(name, {\n name,\n instance: node,\n url: node.url,\n internalUrl: node.internalUrl,\n networkId: node.nodeNetworkId,\n version: node.version,\n consensusProtocolVersion: node.consensusProtocolVersion\n })\n if (select || !this.selectedNode) {\n this.selectNode(name)\n }\n },\n /**\n * Select Node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype (name: String) => void\n * @param {String} name - Node name\n * @return {void}\n * @example\n * nodePool.selectNode('testNode')\n */\n selectNode (name) {\n if (!this.pool.has(name)) throw new Error(`Node with name ${name} not in pool`)\n\n this.selectedNode = this.pool.get(name)\n },\n /**\n * Get NetworkId of current Node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype () => String\n * @return {String}\n * @example\n * nodePool.getNetworkId()\n */\n getNetworkId,\n /**\n * Check if you have selected node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype () => Boolean\n * @return {Boolean}\n * @example\n * nodePool.isNodeConnected()\n */\n isNodeConnected () {\n return !!this.selectedNode.instance\n },\n /**\n * Get information about node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype () => Object\n * @return {Object}\n * @example\n * nodePool.getNodeInfo() // { name, version, networkId, protocol, ... }\n */\n getNodeInfo () {\n if (!this.isNodeConnected()) throw new Error('Can not get node info. Node is not connected')\n return {\n name: this.selectedNode.name,\n ...this.selectedNode.instance.getNodeInfo()\n }\n },\n /**\n * Get array of available nodes\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype () => Object[]\n * @return {Object[]}\n * @example\n * nodePool.getNodesInPool()\n */\n getNodesInPool () {\n return Array.from(this.pool.entries()).map(([name, node]) => ({\n name,\n ...node.instance.getNodeInfo()\n }))\n },\n validateNodes (nodes) {\n const { error } = Joi.array().items(\n Joi.object({\n name: Joi.string().required(),\n instance: Joi.object({\n api: Joi.object().required(),\n consensusProtocolVersion: Joi.number().required(),\n genesisHash: Joi.string().required()\n }).unknown()\n })\n ).label('node').validate(nodes)\n if (error) throw error\n }\n },\n props: {\n selectedNode: {}\n }\n})\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/node-pool/index.js"],"names":["stampit","getNetworkId","init","nodes","pool","Map","validateNodes","forEach","node","i","name","instance","addNode","length","selectNode","propertyDescriptors","api","enumerable","configurable","get","selectedNode","Error","methods","select","has","set","url","internalUrl","networkId","nodeNetworkId","version","consensusProtocolVersion","isNodeConnected","getNodeInfo","getNodesInPool","Array","from","entries","map","isArray","notObject","n","find","t","wrongFields","JSON","stringify","wrongInstanceFields","genesisHash","props"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,WAApB;AACA,SAASC,YAAT,QAA6B,SAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeD,OAAO,CAAC;AACrBE,EAAAA,IAAI,GAAuB;AAAA,QAArB;AAAEC,MAAAA,KAAK,GAAG;AAAV,KAAqB,uEAAJ,EAAI;AACzB,SAAKC,IAAL,GAAY,IAAIC,GAAJ,EAAZ;AACA,SAAKC,aAAL,CAAmBH,KAAnB;AAEAA,IAAAA,KAAK,CAACI,OAAN,CAAc,CAACC,IAAD,EAAOC,CAAP,KAAa;AACzB,YAAM;AAAEC,QAAAA,IAAF;AAAQC,QAAAA;AAAR,UAAqBH,IAA3B;AACA,WAAKI,OAAL,CAAaF,IAAb,EAAmBC,QAAnB,EAA6BF,CAAC,KAAK,CAAnC;AACD,KAHD;AAIA,QAAIN,KAAK,CAACU,MAAV,EAAkB,KAAKC,UAAL,CAAgBX,KAAK,CAAC,CAAD,CAAL,CAASO,IAAzB;AACnB,GAVoB;;AAWrBK,EAAAA,mBAAmB,EAAE;AACnBC,IAAAA,GAAG,EAAE;AACHC,MAAAA,UAAU,EAAE,IADT;AAEHC,MAAAA,YAAY,EAAE,KAFX;;AAGHC,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,CAACmC,GAAN,CAAUG,CAAC,IAAI,OAAOA,CAAtB,EAAyBC,IAAzB,CAA8BC,CAAC,IAAIA,CAAC,KAAK,QAAzC,CAAlB;AACA,UAAIH,SAAJ,EAAe,MAAM,IAAInB,KAAJ,CAAW,sCAAqCmB,SAAU,UAA1D,CAAN;AACf,YAAMI,WAAW,GAAGzC,KAAK,CAACuC,IAAN,CAAWD,CAAC,IAAI,OAAOA,CAAC,CAAC/B,IAAT,KAAkB,QAAlB,IAA8B,OAAO+B,CAAC,CAAC9B,QAAT,KAAsB,QAApE,CAApB;;AACA,UAAI6B,SAAJ,EAAe;AACb,cAAM,IAAInB,KAAJ,CACJ,4DACC,eAAcwB,IAAI,CAACC,SAAL,CAAeF,WAAf,CAA4B,UAFvC,CAAN;AAID;;AACD,YAAMG,mBAAmB,GAAG5C,KAAK,CAC9BmC,GADyB,CACrBG,CAAC,IAAIA,CAAC,CAAC9B,QADc,EAEzB+B,IAFyB,CAEpBjC,CAAC,IAAI,OAAOA,CAAC,CAACO,GAAT,KAAiB,QAAjB,IAA6B,OAAOP,CAAC,CAACuC,WAAT,KAAyB,QAAtD,IACT,OAAOvC,CAAC,CAACsB,wBAAT,KAAsC,QAHd,CAA5B;;AAIA,UAAIgB,mBAAJ,EAAyB;AACvB,cAAM,IAAI1B,KAAJ,CACJ,qFACC,oCAAmCwB,IAAI,CAACC,SAAL,CAAeC,mBAAf,CAAoC,UAFpE,CAAN;AAID;AACF;;AA3HM,GAvBY;AAoJrBE,EAAAA,KAAK,EAAE;AACL7B,IAAAA,YAAY,EAAE;AADT;AApJc,CAAD,CAAtB","sourcesContent":["/**\n * NodePool module\n * @module @aeternity/aepp-sdk/es/node-pool\n * @export NodePool\n * @example import { NodePool } from '@aeternity/aepp-sdk'\n */\nimport stampit from '@stamp/it'\nimport { getNetworkId } from '../node'\n\n/**\n * Node Pool Stamp\n * This stamp allow you to make basic manipulation(add, remove, select) on list of nodes\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @param {Array} [options.nodes] - Array with Node instances\n * @return {Object} NodePool instance\n */\nexport default stampit({\n init ({ nodes = [] } = {}) {\n this.pool = new Map()\n this.validateNodes(nodes)\n\n nodes.forEach((node, i) => {\n const { name, instance } = node\n this.addNode(name, instance, i === 0)\n })\n if (nodes.length) this.selectNode(nodes[0].name)\n },\n propertyDescriptors: {\n api: {\n enumerable: true,\n configurable: false,\n get () {\n if (!this.selectedNode || !this.selectedNode.instance) {\n throw new Error('You can\\'t use Node API. Node is not connected or not defined!')\n }\n return this.selectedNode.instance.api\n }\n }\n },\n methods: {\n /**\n * Add Node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype (name: String, nodeInstance: Object, select: Boolean) => void\n * @param {String} name - Node name\n * @param {Object} node - Node instance\n * @param {Boolean} select - Select this node as current\n * @return {void}\n * @example\n * // add and select new node with name 'testNode'\n * nodePool.addNode('testNode', awaitNode({ url, internalUrl }), true)\n */\n addNode (name, node, select = false) {\n if (this.pool.has(name)) throw new Error(`Node with name ${name} already exist`)\n\n this.validateNodes([{ name, instance: node }])\n\n this.pool.set(name, {\n name,\n instance: node,\n url: node.url,\n internalUrl: node.internalUrl,\n networkId: node.nodeNetworkId,\n version: node.version,\n consensusProtocolVersion: node.consensusProtocolVersion\n })\n if (select || !this.selectedNode) {\n this.selectNode(name)\n }\n },\n /**\n * Select Node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype (name: String) => void\n * @param {String} name - Node name\n * @return {void}\n * @example\n * nodePool.selectNode('testNode')\n */\n selectNode (name) {\n if (!this.pool.has(name)) throw new Error(`Node with name ${name} not in pool`)\n\n this.selectedNode = this.pool.get(name)\n },\n /**\n * Get NetworkId of current Node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype () => String\n * @return {String}\n * @example\n * nodePool.getNetworkId()\n */\n getNetworkId,\n /**\n * Check if you have selected node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype () => Boolean\n * @return {Boolean}\n * @example\n * nodePool.isNodeConnected()\n */\n isNodeConnected () {\n return !!this.selectedNode.instance\n },\n /**\n * Get information about node\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype () => Object\n * @return {Object}\n * @example\n * nodePool.getNodeInfo() // { name, version, networkId, protocol, ... }\n */\n getNodeInfo () {\n if (!this.isNodeConnected()) throw new Error('Can not get node info. Node is not connected')\n return {\n name: this.selectedNode.name,\n ...this.selectedNode.instance.getNodeInfo()\n }\n },\n /**\n * Get array of available nodes\n * @function\n * @alias module:@aeternity/aepp-sdk/es/node-pool\n * @rtype () => Object[]\n * @return {Object[]}\n * @example\n * nodePool.getNodesInPool()\n */\n getNodesInPool () {\n return Array.from(this.pool.entries()).map(([name, node]) => ({\n name,\n ...node.instance.getNodeInfo()\n }))\n },\n validateNodes (nodes) {\n // TODO: validate it on TypeScript level instead\n // (to speedup development, save runtime resources)\n if (!Array.isArray(nodes)) throw new Error('\"nodes\" should be an array')\n const notObject = nodes.map(n => typeof n).find(t => t !== 'object')\n if (notObject) throw new Error(`Each node should be an object, got ${notObject} instead`)\n const wrongFields = nodes.find(n => typeof n.name !== 'string' || typeof n.instance !== 'object')\n if (notObject) {\n throw new Error(\n 'Each node should have name (string), instance (object) ' +\n `fields, got ${JSON.stringify(wrongFields)} instead`\n )\n }\n const wrongInstanceFields = nodes\n .map(n => n.instance)\n .find(i => typeof i.api !== 'object' || typeof i.genesisHash !== 'string' ||\n typeof i.consensusProtocolVersion !== 'number')\n if (wrongInstanceFields) {\n throw new Error(\n 'Each node instance should have api (object), consensusProtocolVersion (number), ' +\n `genesisHash (string) fields, got ${JSON.stringify(wrongInstanceFields)} instead`\n )\n }\n }\n },\n props: {\n selectedNode: {}\n }\n})\n"],"file":"index.js"}