@aeternity/aepp-sdk 13.0.1 → 13.2.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 (322) hide show
  1. package/README.md +4 -2
  2. package/bin/aesophia_cli +0 -0
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  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 +28490 -17706
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdkAepp.mjs.map +1 -1
  10. package/es/AeSdkBase.d.ts +21 -3
  11. package/es/AeSdkBase.mjs +51 -3
  12. package/es/AeSdkBase.mjs.map +1 -1
  13. package/es/AeSdkMethods.d.ts +9 -14
  14. package/es/AeSdkMethods.mjs +20 -49
  15. package/es/AeSdkMethods.mjs.map +1 -1
  16. package/es/AeSdkWallet.d.ts +1 -1
  17. package/es/AeSdkWallet.mjs +79 -23
  18. package/es/AeSdkWallet.mjs.map +1 -1
  19. package/es/Middleware.d.ts +38 -0
  20. package/es/Middleware.mjs +90 -0
  21. package/es/Middleware.mjs.map +1 -0
  22. package/es/MiddlewareSubscriber.d.ts +30 -0
  23. package/es/MiddlewareSubscriber.mjs +198 -0
  24. package/es/MiddlewareSubscriber.mjs.map +1 -0
  25. package/es/Node.d.ts +1 -1
  26. package/es/Node.mjs.map +1 -1
  27. package/es/account/Base.d.ts +57 -3
  28. package/es/account/Base.mjs +95 -1
  29. package/es/account/Base.mjs.map +1 -1
  30. package/es/account/Generalized.d.ts +4 -0
  31. package/es/account/Generalized.mjs +20 -0
  32. package/es/account/Generalized.mjs.map +1 -1
  33. package/es/account/Ledger.d.ts +4 -0
  34. package/es/account/Ledger.mjs +20 -0
  35. package/es/account/Ledger.mjs.map +1 -1
  36. package/es/account/LedgerFactory.mjs.map +1 -1
  37. package/es/account/Memory.d.ts +12 -0
  38. package/es/account/Memory.mjs +52 -0
  39. package/es/account/Memory.mjs.map +1 -1
  40. package/es/account/Rpc.d.ts +5 -6
  41. package/es/account/Rpc.mjs +53 -10
  42. package/es/account/Rpc.mjs.map +1 -1
  43. package/es/aens.d.ts +1 -1
  44. package/es/aens.mjs +1 -1
  45. package/es/aens.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  48. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -2
  51. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/rpc/types.d.ts +19 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  54. package/es/aepp-wallet-communication/schema.d.ts +2 -8
  55. package/es/aepp-wallet-communication/schema.mjs +21 -33
  56. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  57. package/es/aepp-wallet-communication/wallet-detector.d.ts +1 -1
  58. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  59. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  60. package/es/apis/compiler/compiler.mjs +15 -1
  61. package/es/apis/compiler/compiler.mjs.map +1 -1
  62. package/es/apis/compiler/models/index.d.ts +1 -7
  63. package/es/apis/compiler/models/index.mjs.map +1 -1
  64. package/es/apis/compiler/models/mappers.d.ts +0 -1
  65. package/es/apis/compiler/models/mappers.mjs +0 -43
  66. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  67. package/es/apis/middleware/index.d.ts +2 -0
  68. package/es/apis/middleware/index.mjs +3 -0
  69. package/es/apis/middleware/index.mjs.map +1 -0
  70. package/es/apis/middleware/middleware.d.ts +309 -0
  71. package/es/apis/middleware/middleware.mjs +1527 -0
  72. package/es/apis/middleware/middleware.mjs.map +1 -0
  73. package/es/apis/middleware/models/index.d.ts +1496 -0
  74. package/es/apis/middleware/models/index.mjs +580 -0
  75. package/es/apis/middleware/models/index.mjs.map +1 -0
  76. package/es/apis/middleware/models/mappers.d.ts +102 -0
  77. package/es/apis/middleware/models/mappers.mjs +3334 -0
  78. package/es/apis/middleware/models/mappers.mjs.map +1 -0
  79. package/es/apis/middleware/models/parameters.d.ts +43 -0
  80. package/es/apis/middleware/models/parameters.mjs +417 -0
  81. package/es/apis/middleware/models/parameters.mjs.map +1 -0
  82. package/es/apis/node/node.mjs.map +1 -1
  83. package/es/chain.d.ts +2 -1
  84. package/es/chain.mjs +5 -3
  85. package/es/chain.mjs.map +1 -1
  86. package/es/channel/Base.d.ts +1 -1
  87. package/es/channel/Base.mjs +1 -4
  88. package/es/channel/Base.mjs.map +1 -1
  89. package/es/channel/Contract.mjs.map +1 -1
  90. package/es/channel/Spend.mjs.map +1 -1
  91. package/es/channel/handlers.mjs +2 -2
  92. package/es/channel/handlers.mjs.map +1 -1
  93. package/es/channel/internal.mjs +7 -5
  94. package/es/channel/internal.mjs.map +1 -1
  95. package/es/contract/Contract.mjs +2 -2
  96. package/es/contract/Contract.mjs.map +1 -1
  97. package/es/contract/compiler/Base.d.ts +21 -0
  98. package/es/contract/compiler/Base.mjs.map +1 -1
  99. package/es/contract/compiler/Cli.d.ts +2 -0
  100. package/es/contract/compiler/Cli.mjs +24 -3
  101. package/es/contract/compiler/Cli.mjs.map +1 -1
  102. package/es/contract/compiler/Http.d.ts +2 -0
  103. package/es/contract/compiler/Http.mjs +22 -2
  104. package/es/contract/compiler/Http.mjs.map +1 -1
  105. package/es/contract/compiler/HttpNode.d.ts +1 -0
  106. package/es/contract/compiler/HttpNode.mjs +5 -0
  107. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  108. package/es/contract/delegation-signature.d.ts +2 -1
  109. package/es/contract/delegation-signature.mjs +39 -8
  110. package/es/contract/delegation-signature.mjs.map +1 -1
  111. package/es/contract/ga.mjs.map +1 -1
  112. package/es/deprecated.d.ts +14 -0
  113. package/es/deprecated.mjs +22 -0
  114. package/es/deprecated.mjs.map +1 -0
  115. package/es/index-browser.d.ts +20 -14
  116. package/es/index-browser.mjs +19 -15
  117. package/es/index-browser.mjs.map +1 -1
  118. package/es/oracle.mjs.map +1 -1
  119. package/es/spend.d.ts +2 -1
  120. package/es/spend.mjs +4 -2
  121. package/es/spend.mjs.map +1 -1
  122. package/es/tx/builder/constants.d.ts +0 -1
  123. package/es/tx/builder/constants.mjs +26 -24
  124. package/es/tx/builder/constants.mjs.map +1 -1
  125. package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
  126. package/es/tx/builder/field-types/coin-amount.d.ts +1 -1
  127. package/es/tx/builder/field-types/coin-amount.mjs +2 -1
  128. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  129. package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
  130. package/es/tx/builder/field-types/deposit.d.ts +1 -1
  131. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  132. package/es/tx/builder/field-types/entry.mjs +2 -1
  133. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  134. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  135. package/es/tx/builder/field-types/field.mjs.map +1 -1
  136. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  137. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  138. package/es/tx/builder/field-types/index.d.ts +28 -150
  139. package/es/tx/builder/field-types/index.mjs +28 -56
  140. package/es/tx/builder/field-types/index.mjs.map +1 -1
  141. package/es/tx/builder/field-types/map.mjs.map +1 -1
  142. package/es/tx/builder/field-types/mptree.mjs +3 -3
  143. package/es/tx/builder/field-types/mptree.mjs.map +1 -1
  144. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  145. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  146. package/es/tx/builder/field-types/string.mjs.map +1 -1
  147. package/es/tx/builder/field-types/ttl.mjs.map +1 -1
  148. package/es/tx/builder/field-types/u-int.mjs +1 -1
  149. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  150. package/es/tx/builder/helpers.d.ts +8 -1
  151. package/es/tx/builder/helpers.mjs +53 -9
  152. package/es/tx/builder/helpers.mjs.map +1 -1
  153. package/es/tx/builder/index.d.ts +4 -2
  154. package/es/tx/builder/index.mjs +0 -1
  155. package/es/tx/builder/index.mjs.map +1 -1
  156. package/es/tx/builder/schema.d.ts +9 -9
  157. package/es/tx/builder/schema.mjs +11 -10
  158. package/es/tx/builder/schema.mjs.map +1 -1
  159. package/es/tx/execution-cost.mjs.map +1 -1
  160. package/es/tx/transaction-signer.mjs.map +1 -1
  161. package/es/tx/validator.mjs +6 -3
  162. package/es/tx/validator.mjs.map +1 -1
  163. package/es/utils/amount-formatter.mjs +7 -7
  164. package/es/utils/amount-formatter.mjs.map +1 -1
  165. package/es/utils/autorest.mjs +6 -8
  166. package/es/utils/autorest.mjs.map +1 -1
  167. package/es/utils/bignumber.mjs.map +1 -1
  168. package/es/utils/bytes.mjs.map +1 -1
  169. package/es/utils/crypto.d.ts +1 -0
  170. package/es/utils/crypto.mjs +12 -2
  171. package/es/utils/crypto.mjs.map +1 -1
  172. package/es/utils/encoder-types.mjs +3 -3
  173. package/es/utils/encoder-types.mjs.map +1 -1
  174. package/es/utils/encoder.mjs.map +1 -1
  175. package/es/utils/errors.d.ts +2 -2
  176. package/es/utils/errors.mjs.map +1 -1
  177. package/es/utils/hd-wallet.mjs.map +1 -1
  178. package/es/utils/keystore.mjs.map +1 -1
  179. package/es/utils/other.d.ts +1 -0
  180. package/es/utils/other.mjs +5 -0
  181. package/es/utils/other.mjs.map +1 -1
  182. package/es/utils/semver-satisfies.mjs.map +1 -1
  183. package/es/utils/string.mjs.map +1 -1
  184. package/es/utils/typed-data.d.ts +45 -0
  185. package/es/utils/typed-data.mjs +70 -0
  186. package/es/utils/typed-data.mjs.map +1 -0
  187. package/package.json +56 -37
  188. package/src/AeSdkBase.ts +66 -5
  189. package/src/AeSdkMethods.ts +31 -50
  190. package/src/AeSdkWallet.ts +63 -17
  191. package/src/Middleware.ts +141 -0
  192. package/src/MiddlewareSubscriber.ts +207 -0
  193. package/src/Node.ts +1 -1
  194. package/src/account/Base.ts +102 -4
  195. package/src/account/Generalized.ts +20 -0
  196. package/src/account/Ledger.ts +20 -0
  197. package/src/account/Memory.ts +68 -1
  198. package/src/account/Rpc.ts +54 -7
  199. package/src/aens.ts +1 -1
  200. package/src/aepp-wallet-communication/rpc/RpcClient.ts +11 -3
  201. package/src/aepp-wallet-communication/rpc/types.ts +21 -0
  202. package/src/aepp-wallet-communication/schema.ts +3 -17
  203. package/src/aepp-wallet-communication/wallet-detector.ts +1 -2
  204. package/src/apis/compiler/compiler.ts +8 -1
  205. package/src/apis/compiler/models/index.ts +1 -8
  206. package/src/apis/compiler/models/mappers.ts +0 -36
  207. package/src/apis/middleware/index.ts +2 -0
  208. package/src/apis/middleware/middleware.ts +1807 -0
  209. package/src/apis/middleware/models/index.ts +1747 -0
  210. package/src/apis/middleware/models/mappers.ts +3370 -0
  211. package/src/apis/middleware/models/parameters.ts +463 -0
  212. package/src/chain.ts +4 -3
  213. package/src/channel/Base.ts +5 -5
  214. package/src/channel/internal.ts +2 -0
  215. package/src/contract/Contract.ts +2 -1
  216. package/src/contract/compiler/Base.ts +26 -0
  217. package/src/contract/compiler/Cli.ts +27 -3
  218. package/src/contract/compiler/Http.ts +21 -2
  219. package/src/contract/compiler/HttpNode.ts +6 -0
  220. package/src/contract/delegation-signature.ts +37 -11
  221. package/src/deprecated.ts +23 -0
  222. package/src/index-browser.ts +77 -15
  223. package/src/spend.ts +2 -2
  224. package/src/tx/builder/constants.ts +0 -1
  225. package/src/tx/builder/field-types/coin-amount.ts +2 -1
  226. package/src/tx/builder/field-types/entry.ts +1 -1
  227. package/src/tx/builder/field-types/index.ts +28 -58
  228. package/src/tx/builder/field-types/u-int.ts +1 -1
  229. package/src/tx/builder/helpers.ts +54 -9
  230. package/src/tx/builder/index.ts +6 -9
  231. package/src/tx/validator.ts +4 -2
  232. package/src/utils/autorest.ts +5 -10
  233. package/src/utils/crypto.ts +12 -2
  234. package/src/utils/errors.ts +2 -2
  235. package/src/utils/other.ts +5 -0
  236. package/src/utils/typed-data.ts +95 -0
  237. package/types-legacy/ts4.2/AeSdkBase.d.ts +21 -3
  238. package/types-legacy/ts4.2/AeSdkMethods.d.ts +9 -14
  239. package/types-legacy/ts4.2/AeSdkWallet.d.ts +1 -1
  240. package/types-legacy/ts4.2/Middleware.d.ts +46 -0
  241. package/types-legacy/ts4.2/MiddlewareSubscriber.d.ts +30 -0
  242. package/types-legacy/ts4.2/Node.d.ts +1 -1
  243. package/types-legacy/ts4.2/account/Base.d.ts +57 -3
  244. package/types-legacy/ts4.2/account/Generalized.d.ts +4 -0
  245. package/types-legacy/ts4.2/account/Ledger.d.ts +4 -0
  246. package/types-legacy/ts4.2/account/Memory.d.ts +12 -0
  247. package/types-legacy/ts4.2/account/Rpc.d.ts +5 -6
  248. package/types-legacy/ts4.2/aens.d.ts +1 -1
  249. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +19 -0
  250. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +2 -8
  251. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +1 -1
  252. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -7
  253. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +0 -1
  254. package/types-legacy/ts4.2/apis/middleware/index.d.ts +2 -0
  255. package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +309 -0
  256. package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +1496 -0
  257. package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +102 -0
  258. package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +43 -0
  259. package/types-legacy/ts4.2/chain.d.ts +2 -1
  260. package/types-legacy/ts4.2/channel/Base.d.ts +1 -1
  261. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +21 -0
  262. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +2 -0
  263. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +2 -0
  264. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +1 -0
  265. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +2 -1
  266. package/types-legacy/ts4.2/deprecated.d.ts +14 -0
  267. package/types-legacy/ts4.2/index-browser.d.ts +20 -14
  268. package/types-legacy/ts4.2/spend.d.ts +2 -1
  269. package/types-legacy/ts4.2/tx/builder/constants.d.ts +0 -1
  270. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +1 -1
  271. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +1 -1
  272. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +28 -153
  273. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +8 -1
  274. package/types-legacy/ts4.2/tx/builder/index.d.ts +4 -2
  275. package/types-legacy/ts4.2/tx/builder/schema.d.ts +9 -9
  276. package/types-legacy/ts4.2/utils/crypto.d.ts +1 -0
  277. package/types-legacy/ts4.2/utils/errors.d.ts +2 -2
  278. package/types-legacy/ts4.2/utils/other.d.ts +1 -0
  279. package/types-legacy/ts4.2/utils/typed-data.d.ts +60 -0
  280. package/types-legacy/ts4.5/AeSdkBase.d.ts +21 -3
  281. package/types-legacy/ts4.5/AeSdkMethods.d.ts +9 -14
  282. package/types-legacy/ts4.5/AeSdkWallet.d.ts +1 -1
  283. package/types-legacy/ts4.5/Middleware.d.ts +46 -0
  284. package/types-legacy/ts4.5/MiddlewareSubscriber.d.ts +30 -0
  285. package/types-legacy/ts4.5/Node.d.ts +1 -1
  286. package/types-legacy/ts4.5/account/Base.d.ts +57 -3
  287. package/types-legacy/ts4.5/account/Generalized.d.ts +4 -0
  288. package/types-legacy/ts4.5/account/Ledger.d.ts +4 -0
  289. package/types-legacy/ts4.5/account/Memory.d.ts +12 -0
  290. package/types-legacy/ts4.5/account/Rpc.d.ts +5 -6
  291. package/types-legacy/ts4.5/aens.d.ts +1 -1
  292. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +19 -0
  293. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +2 -8
  294. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +1 -1
  295. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -7
  296. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +0 -1
  297. package/types-legacy/ts4.5/apis/middleware/index.d.ts +2 -0
  298. package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +309 -0
  299. package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +1496 -0
  300. package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +102 -0
  301. package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +43 -0
  302. package/types-legacy/ts4.5/chain.d.ts +2 -1
  303. package/types-legacy/ts4.5/channel/Base.d.ts +1 -1
  304. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +21 -0
  305. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +2 -0
  306. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +2 -0
  307. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +1 -0
  308. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +2 -1
  309. package/types-legacy/ts4.5/deprecated.d.ts +14 -0
  310. package/types-legacy/ts4.5/index-browser.d.ts +20 -14
  311. package/types-legacy/ts4.5/spend.d.ts +2 -1
  312. package/types-legacy/ts4.5/tx/builder/constants.d.ts +0 -1
  313. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +1 -1
  314. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +1 -1
  315. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +28 -153
  316. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +8 -1
  317. package/types-legacy/ts4.5/tx/builder/index.d.ts +4 -2
  318. package/types-legacy/ts4.5/tx/builder/schema.d.ts +9 -9
  319. package/types-legacy/ts4.5/utils/crypto.d.ts +1 -0
  320. package/types-legacy/ts4.5/utils/errors.d.ts +2 -2
  321. package/types-legacy/ts4.5/utils/other.d.ts +1 -0
  322. package/types-legacy/ts4.5/utils/typed-data.d.ts +60 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Http.mjs","names":["RestError","Compiler","CompilerApi","genErrorFormatterPolicy","genVersionCheckPolicy","CompilerBase","CompilerError","NotImplementedError","CompilerHttp","constructor","compilerUrl","ignoreVersion","arguments","length","undefined","api","allowInsecureConnection","additionalPolicies","body","message","reason","parameter","info","JSON","stringify","Array","isArray","map","e","type","pos","line","col","context","join","versionPromise","apiVersion","then","_ref","error","pipeline","addPolicy","compileBySourceCode","sourceCode","fileSystem","res","compileContract","code","options","statusCode","replace","compile","path","validateBySourceCode","bytecode","validateByteCode","source","validate","version"],"sources":["../../../src/contract/compiler/Http.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\nimport {\n Compiler as CompilerApi,\n ErrorModel,\n CompilerError as CompilerErrorApi,\n} from '../../apis/compiler';\nimport { genErrorFormatterPolicy, genVersionCheckPolicy } from '../../utils/autorest';\nimport CompilerBase, { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport { CompilerError, NotImplementedError } from '../../utils/errors';\n\ntype GeneralCompilerError = ErrorModel & {\n info?: object;\n parameter?: string;\n};\n\n/**\n * Contract Compiler over HTTP\n *\n * This class include api call's related to contract compiler functionality.\n * @category contract\n * @example CompilerHttp('COMPILER_URL')\n */\nexport default class CompilerHttp extends CompilerBase {\n readonly api: CompilerApi;\n\n /**\n * @param compilerUrl - Url for compiler API\n * @param options - Options\n * @param options.ignoreVersion - Don't check compiler version\n */\n constructor(compilerUrl: string, { ignoreVersion }: { ignoreVersion?: boolean } = {}) {\n super();\n this.api = new CompilerApi(compilerUrl, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genErrorFormatterPolicy((body: GeneralCompilerError | CompilerErrorApi[]) => {\n let message = '';\n if ('reason' in body) {\n message += ` ${body.reason\n }${body.parameter != null ? ` in ${body.parameter}` : ''\n // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78\n }${body.info != null ? ` (${JSON.stringify(body.info)})` : ''}`;\n }\n if (Array.isArray(body)) {\n message += `\\n${body\n .map((e) => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? ` (${e.context})` : ''}`)\n .join('\\n')}`;\n }\n return message;\n }),\n ],\n });\n if (ignoreVersion !== true) {\n const versionPromise = this.api.apiVersion()\n .then(({ apiVersion }) => apiVersion, (error) => error);\n this.api.pipeline.addPolicy(\n genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.1.1', '8.0.0'),\n );\n }\n }\n\n async compileBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n try {\n const res = await this.api.compileContract({ code: sourceCode, options: { fileSystem } });\n // TODO: should be fixed when the compiledAci interface gets updated\n return res as { bytecode: Encoded.ContractBytearray; aci: Aci };\n } catch (error) {\n if (error instanceof RestError && error.statusCode === 400) {\n throw new CompilerError(error.message.replace(/^aci error:/, 'compile error:'));\n }\n throw error;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async compile(path: string): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n try {\n await this.api.validateByteCode({ bytecode, source: sourceCode, options: { fileSystem } });\n return true;\n } catch {\n return false;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async version(): Promise<string> {\n return (await this.api.version()).version;\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAAC,SAEpDC,QAAQ,IAAIC,WAAW;AAAA,SAIhBC,uBAAuB,EAAEC,qBAAqB;AAAA,OAChDC,YAAY;AAAA,SAEVC,aAAa,EAAEC,mBAAmB;AAO3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,YAAY,SAASH,YAAY,CAAC;EAGrD;AACF;AACA;AACA;AACA;EACEI,WAAWA,CAACC,WAAmB,EAAuD;IAAA,IAArD;MAAEC;IAA2C,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAClF,KAAK,EAAE;IACP,IAAI,CAACG,GAAG,GAAG,IAAIb,WAAW,CAACQ,WAAW,EAAE;MACtCM,uBAAuB,EAAE,IAAI;MAC7BC,kBAAkB,EAAE,CAClBd,uBAAuB,CAAEe,IAA+C,IAAK;QAC3E,IAAIC,OAAO,GAAG,EAAE;QAChB,IAAI,QAAQ,IAAID,IAAI,EAAE;UACpBC,OAAO,IAAK,IAAGD,IAAI,CAACE,MACnB,GAAEF,IAAI,CAACG,SAAS,IAAI,IAAI,GAAI,OAAMH,IAAI,CAACG,SAAU,EAAC,GAAG;UACpD;UACD,GAAEH,IAAI,CAACI,IAAI,IAAI,IAAI,GAAI,KAAIC,IAAI,CAACC,SAAS,CAACN,IAAI,CAACI,IAAI,CAAE,GAAE,GAAG,EAAG,EAAC;QACjE;QACA,IAAIG,KAAK,CAACC,OAAO,CAACR,IAAI,CAAC,EAAE;UACvBC,OAAO,IAAK,KAAID,IAAI,CACjBS,GAAG,CAAEC,CAAC,IAAM,GAAEA,CAAC,CAACC,IAAK,IAAGD,CAAC,CAACE,GAAG,CAACC,IAAK,IAAGH,CAAC,CAACE,GAAG,CAACE,GAAI,KAAIJ,CAA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C,EACnCX,UAAkB,EAClBC,UAAmC,EACjB;IAClB,IAAI;MACF,MAAM,IAAI,CAAC7B,GAAG,CAACwC,gBAAgB,CAAC;QAAED,QAAQ;QAAEE,MAAM,EAAEb,UAAU;QAAEK,OAAO,EAAE;UAAEJ;QAAW;MAAE,CAAC,CAAC;MAC1F,OAAO,IAAI;IACb,CAAC,CAAC,MAAM;MACN,OAAO,KAAK;IACd;EACF;;EAEA;EACA,MAAMa,QAAQA,CAACH,QAAmC,EAAEF,IAAY,EAAoB;IAClF,MAAM,IAAI7C,mBAAmB,CAAC,kDAAkD,CAAC;EACnF;EAEA,MAAMmD,OAAOA,CAAA,EAAoB;IAC/B,OAAO,CAAC,MAAM,IAAI,CAAC3C,GAAG,CAAC2C,OAAO,EAAE,EAAEA,OAAO;EAC3C;AACF"}
1
+ {"version":3,"file":"Http.mjs","names":["RestError","Compiler","CompilerApi","genErrorFormatterPolicy","genVersionCheckPolicy","CompilerBase","CompilerError","NotImplementedError","CompilerHttp","constructor","compilerUrl","ignoreVersion","arguments","length","undefined","api","allowInsecureConnection","additionalPolicies","body","message","reason","parameter","info","JSON","stringify","Array","isArray","map","e","type","pos","line","col","context","join","versionPromise","apiVersion","then","_ref","error","pipeline","addPolicy","compileBySourceCode","sourceCode","fileSystem","res","compileContract","code","options","statusCode","compile","path","generateAciBySourceCode","generateACI","generateAci","validateBySourceCode","bytecode","validateByteCode","source","validate","version"],"sources":["../../../src/contract/compiler/Http.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\nimport {\n Compiler as CompilerApi,\n ErrorModel,\n CompilerError as CompilerErrorApi,\n} from '../../apis/compiler';\nimport { genErrorFormatterPolicy, genVersionCheckPolicy } from '../../utils/autorest';\nimport CompilerBase, { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport { CompilerError, NotImplementedError } from '../../utils/errors';\n\ntype GeneralCompilerError = ErrorModel & {\n info?: object;\n parameter?: string;\n};\n\n/**\n * Contract Compiler over HTTP\n *\n * This class include api call's related to contract compiler functionality.\n * @category contract\n * @example CompilerHttp('COMPILER_URL')\n */\nexport default class CompilerHttp extends CompilerBase {\n readonly api: CompilerApi;\n\n /**\n * @param compilerUrl - Url for compiler API\n * @param options - Options\n * @param options.ignoreVersion - Don't check compiler version\n */\n constructor(compilerUrl: string, { ignoreVersion }: { ignoreVersion?: boolean } = {}) {\n super();\n this.api = new CompilerApi(compilerUrl, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genErrorFormatterPolicy((body: GeneralCompilerError | CompilerErrorApi[]) => {\n let message = '';\n if ('reason' in body) {\n message += ` ${body.reason\n }${body.parameter != null ? ` in ${body.parameter}` : ''\n // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78\n }${body.info != null ? ` (${JSON.stringify(body.info)})` : ''}`;\n }\n if (Array.isArray(body)) {\n message += `\\n${body\n .map((e) => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? ` (${e.context})` : ''}`)\n .join('\\n')}`;\n }\n return message;\n }),\n ],\n });\n if (ignoreVersion !== true) {\n const versionPromise = this.api.apiVersion()\n .then(({ apiVersion }) => apiVersion, (error) => error);\n this.api.pipeline.addPolicy(\n genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.3.0', '8.0.0'),\n );\n }\n }\n\n async compileBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n try {\n const res = await this.api.compileContract({ code: sourceCode, options: { fileSystem } });\n // TODO: should be fixed when the compiledAci interface gets updated\n return res as { bytecode: Encoded.ContractBytearray; aci: Aci };\n } catch (error) {\n if (error instanceof RestError && error.statusCode === 400) {\n throw new CompilerError(error.message);\n }\n throw error;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async compile(path: string): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async generateAciBySourceCode(\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<Aci> {\n try {\n return await this.api.generateACI({ code: sourceCode, options: { fileSystem } });\n } catch (error) {\n if (error instanceof RestError && error.statusCode === 400) {\n throw new CompilerError(error.message);\n }\n throw error;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async generateAci(path: string): Promise<Aci> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async validateBySourceCode(\n bytecode: Encoded.ContractBytearray,\n sourceCode: string,\n fileSystem?: Record<string, string>,\n ): Promise<boolean> {\n try {\n await this.api.validateByteCode({ bytecode, source: sourceCode, options: { fileSystem } });\n return true;\n } catch {\n return false;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n throw new NotImplementedError('File system access, use CompilerHttpNode instead');\n }\n\n async version(): Promise<string> {\n return (await this.api.version()).version;\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAAC,SAEpDC,QAAQ,IAAIC,WAAW;AAAA,SAIhBC,uBAAuB,EAAEC,qBAAqB;AAAA,OAChDC,YAAY;AAAA,SAEVC,aAAa,EAAEC,mBAAmB;AAO3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,YAAY,SAASH,YAAY,CAAC;EAGrD;AACF;AACA;AACA;AACA;EACEI,WAAWA,CAACC,WAAmB,EAAuD;IAAA,IAArD;MAAEC;IAA2C,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAClF,KAAK,CAAC,CAAC;IACP,IAAI,CAACG,GAAG,GAAG,IAAIb,WAAW,CAACQ,WAAW,EAAE;MACtCM,uBAAuB,EAAE,IAAI;MAC7BC,kBAAkB,EAAE,CAClBd,uBAAuB,CAAEe,IAA+C,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CAAC,CAAC;MAC1F,OAAO,IAAI;IACb,CAAC,CAAC,MAAM;MACN,OAAO,KAAK;IACd;EACF;;EAEA;EACA,MAAMe,QAAQA,CAACH,QAAmC,EAAEL,IAAY,EAAoB;IAClF,MAAM,IAAI5C,mBAAmB,CAAC,kDAAkD,CAAC;EACnF;EAEA,MAAMqD,OAAOA,CAAA,EAAoB;IAC/B,OAAO,CAAC,MAAM,IAAI,CAAC7C,GAAG,CAAC6C,OAAO,CAAC,CAAC,EAAEA,OAAO;EAC3C;AACF"}
@@ -13,5 +13,6 @@ export default class CompilerHttpNode extends HttpBrowser {
13
13
  bytecode: Encoded.ContractBytearray;
14
14
  aci: Aci;
15
15
  }>;
16
+ generateAci(path: string): Promise<Aci>;
16
17
  validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean>;
17
18
  }
@@ -17,6 +17,11 @@ export default class CompilerHttpNode extends HttpBrowser {
17
17
  const sourceCode = await readFile(path, 'utf8');
18
18
  return this.compileBySourceCode(sourceCode, fileSystem);
19
19
  }
20
+ async generateAci(path) {
21
+ const fileSystem = await getFileSystem(path);
22
+ const sourceCode = await readFile(path, 'utf8');
23
+ return this.generateAciBySourceCode(sourceCode, fileSystem);
24
+ }
20
25
  async validate(bytecode, path) {
21
26
  const fileSystem = await getFileSystem(path);
22
27
  const sourceCode = await readFile(path, 'utf8');
@@ -1 +1 @@
1
- {"version":3,"file":"HttpNode.mjs","names":["_fsPromises","readFile","HttpBrowser","getFileSystem","CompilerHttpNode","compile","path","fileSystem","sourceCode","compileBySourceCode","validate","bytecode","validateBySourceCode"],"sources":["../../../src/contract/compiler/HttpNode.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport HttpBrowser from './Http';\nimport { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport getFileSystem from './getFileSystem';\n\n/**\n * Contract Compiler over HTTP for Nodejs\n *\n * Inherits CompilerHttp and implements `compile`, `validate` methods\n * @category contract\n * @example CompilerHttpNode('COMPILER_URL')\n */\nexport default class CompilerHttpNode extends HttpBrowser {\n override async compile(path: string): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.compileBySourceCode(sourceCode, fileSystem);\n }\n\n override async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.validateBySourceCode(bytecode, sourceCode, fileSystem);\n }\n}\n"],"mappings":"AAAA,OAAAA,WAAA,MAAyB,aAAa;AAAC;EAAAC;AAAA,IAAAD,WAAA;AAAA,OAChCE,WAAW;AAAA,OAGXC,aAAa;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASF,WAAW,CAAC;EACxD,MAAeG,OAAOA,CAACC,IAAY,EAA8D;IAC/F,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMP,QAAQ,CAACK,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACG,mBAAmB,CAACD,UAAU,EAAED,UAAU,CAAC;EACzD;EAEA,MAAeG,QAAQA,CAACC,QAAmC,EAAEL,IAAY,EAAoB;IAC3F,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMP,QAAQ,CAACK,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACM,oBAAoB,CAACD,QAAQ,EAAEH,UAAU,EAAED,UAAU,CAAC;EACpE;AACF"}
1
+ {"version":3,"file":"HttpNode.mjs","names":["_fsPromises","readFile","HttpBrowser","getFileSystem","CompilerHttpNode","compile","path","fileSystem","sourceCode","compileBySourceCode","generateAci","generateAciBySourceCode","validate","bytecode","validateBySourceCode"],"sources":["../../../src/contract/compiler/HttpNode.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport HttpBrowser from './Http';\nimport { Aci } from './Base';\nimport { Encoded } from '../../utils/encoder';\nimport getFileSystem from './getFileSystem';\n\n/**\n * Contract Compiler over HTTP for Nodejs\n *\n * Inherits CompilerHttp and implements `compile`, `validate` methods\n * @category contract\n * @example CompilerHttpNode('COMPILER_URL')\n */\nexport default class CompilerHttpNode extends HttpBrowser {\n override async compile(path: string): Promise<{ bytecode: Encoded.ContractBytearray; aci: Aci }> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.compileBySourceCode(sourceCode, fileSystem);\n }\n\n override async generateAci(path: string): Promise<Aci> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.generateAciBySourceCode(sourceCode, fileSystem);\n }\n\n override async validate(bytecode: Encoded.ContractBytearray, path: string): Promise<boolean> {\n const fileSystem = await getFileSystem(path);\n const sourceCode = await readFile(path, 'utf8');\n return this.validateBySourceCode(bytecode, sourceCode, fileSystem);\n }\n}\n"],"mappings":"AAAA,OAAAA,WAAA,MAAyB,aAAa;AAAC;EAAAC;AAAA,IAAAD,WAAA;AAAA,OAChCE,WAAW;AAAA,OAGXC,aAAa;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASF,WAAW,CAAC;EACxD,MAAeG,OAAOA,CAACC,IAAY,EAA8D;IAC/F,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMP,QAAQ,CAACK,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACG,mBAAmB,CAACD,UAAU,EAAED,UAAU,CAAC;EACzD;EAEA,MAAeG,WAAWA,CAACJ,IAAY,EAAgB;IACrD,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMP,QAAQ,CAACK,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACK,uBAAuB,CAACH,UAAU,EAAED,UAAU,CAAC;EAC7D;EAEA,MAAeK,QAAQA,CAACC,QAAmC,EAAEP,IAAY,EAAoB;IAC3F,MAAMC,UAAU,GAAG,MAAMJ,aAAa,CAACG,IAAI,CAAC;IAC5C,MAAME,UAAU,GAAG,MAAMP,QAAQ,CAACK,IAAI,EAAE,MAAM,CAAC;IAC/C,OAAO,IAAI,CAACQ,oBAAoB,CAACD,QAAQ,EAAEL,UAAU,EAAED,UAAU,CAAC;EACpE;AACF"}
@@ -14,6 +14,7 @@ import Node from '../Node';
14
14
  * @param options.onAccount - Account to use
15
15
  * @param options.onNode - Node to use
16
16
  * @returns Signature
17
+ * @deprecated use methods `sign*DelegationToContract` of Account instance instead
17
18
  * @example
18
19
  * ```js
19
20
  * const aeSdk = new AeSdk({ ... })
@@ -36,7 +37,7 @@ import Node from '../Node';
36
37
  * .createDelegationSignature(contractAddress, [oracleQueryId], { onAccount, omitAddress: true })
37
38
  * ```
38
39
  */
39
- export default function createDelegationSignature(contractAddress: Encoded.ContractAddress, ids: Array<Encoded.Any | AensName>, options: {
40
+ export default function createDelegationSignature(contractAddress: Encoded.ContractAddress, ids: Array<Encoded.Any | AensName>, { onAccount, omitAddress, ...options }: {
40
41
  omitAddress?: boolean;
41
42
  onAccount: AccountBase;
42
43
  onNode: Node;
@@ -1,10 +1,10 @@
1
- import _buffer from "buffer";
2
- const {
3
- Buffer: _Buffer
4
- } = _buffer;
5
1
  import { decode } from "../utils/encoder.mjs";
6
- import { concatBuffers } from "../utils/other.mjs";
7
- import { isNameValid, produceNameId } from "../tx/builder/helpers.mjs";
2
+ import { ArgumentError } from "../utils/errors.mjs";
3
+ import { isNameValid } from "../tx/builder/helpers.mjs";
4
+ function ensureOracleQuery(oq) {
5
+ if (!oq.startsWith('oq_')) throw new ArgumentError('oq', 'oracle query', oq);
6
+ }
7
+
8
8
  /**
9
9
  * Helper to generate a signature to delegate
10
10
  * - pre-claim/claim/transfer/revoke of a name to a contract.
@@ -17,6 +17,7 @@ import { isNameValid, produceNameId } from "../tx/builder/helpers.mjs";
17
17
  * @param options.onAccount - Account to use
18
18
  * @param options.onNode - Node to use
19
19
  * @returns Signature
20
+ * @deprecated use methods `sign*DelegationToContract` of Account instance instead
20
21
  * @example
21
22
  * ```js
22
23
  * const aeSdk = new AeSdk({ ... })
@@ -39,7 +40,37 @@ import { isNameValid, produceNameId } from "../tx/builder/helpers.mjs";
39
40
  * .createDelegationSignature(contractAddress, [oracleQueryId], { onAccount, omitAddress: true })
40
41
  * ```
41
42
  */
42
- export default async function createDelegationSignature(contractAddress, ids, options) {
43
- return options.onAccount.sign(concatBuffers([_Buffer.from(await options.onNode.getNetworkId()), ...(options.omitAddress === true ? [] : [decode(options.onAccount.address)]), ...ids.map(e => isNameValid(e) ? produceNameId(e) : e).map(e => decode(e)), decode(contractAddress)]), options);
43
+ export default async function createDelegationSignature(contractAddress, ids, _ref) {
44
+ let {
45
+ onAccount,
46
+ omitAddress,
47
+ ...options
48
+ } = _ref;
49
+ if (ids.length > 1) throw new ArgumentError('ids', 'shorter than 2', ids);
50
+ const networkId = await options.onNode.getNetworkId();
51
+ if (ids.length === 0) {
52
+ if (omitAddress === true) {
53
+ throw new ArgumentError('omitAddress', 'equal false', omitAddress);
54
+ }
55
+ return decode(await onAccount.signDelegationToContract(contractAddress, {
56
+ networkId
57
+ }));
58
+ }
59
+ const [payload] = ids;
60
+ if (isNameValid(payload)) {
61
+ if (omitAddress === true) {
62
+ throw new ArgumentError('omitAddress', 'equal false', omitAddress);
63
+ }
64
+ return decode(await onAccount.signNameDelegationToContract(contractAddress, payload, {
65
+ networkId
66
+ }));
67
+ }
68
+ ensureOracleQuery(payload);
69
+ if (omitAddress !== true) {
70
+ throw new ArgumentError('omitAddress', 'equal true', omitAddress);
71
+ }
72
+ return decode(await onAccount.signOracleQueryDelegationToContract(contractAddress, payload, {
73
+ networkId
74
+ }));
44
75
  }
45
76
  //# sourceMappingURL=delegation-signature.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"delegation-signature.mjs","names":["decode","concatBuffers","isNameValid","produceNameId","createDelegationSignature","contractAddress","ids","options","onAccount","sign","_Buffer","from","onNode","getNetworkId","omitAddress","address","map","e"],"sources":["../../src/contract/delegation-signature.ts"],"sourcesContent":["import { decode, Encoded } from '../utils/encoder';\nimport { AensName } from '../tx/builder/constants';\nimport AccountBase from '../account/Base';\nimport { concatBuffers } from '../utils/other';\nimport { isNameValid, produceNameId } from '../tx/builder/helpers';\nimport Node from '../Node';\n\n/**\n * Helper to generate a signature to delegate\n * - pre-claim/claim/transfer/revoke of a name to a contract.\n * - register/extend/respond of an Oracle to a contract.\n * @category contract\n * @param contractAddress - Address of contract to delegate access\n * @param ids - The list of id's to prepend\n * @param options - Options\n * @param options.omitAddress - Prepend delegation signature with an account address\n * @param options.onAccount - Account to use\n * @param options.onNode - Node to use\n * @returns Signature\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contractAddress = 'ct_asd2ks...'\n * const aensName = 'example.chain'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Preclaim signature\n * const preclaimSig = await aeSdk.createDelegationSignature(contractAddress, [], { onAccount })\n * // Claim, transfer and revoke signature\n * const aensDelegationSig = await aeSdk\n * .createDelegationSignature(contractAddress, [aensName], { onAccount })\n *\n * const oracleQueryId = 'oq_...'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Oracle register and extend signature\n * const oracleDelegationSig = await aeSdk\n * .createDelegationSignature(contractAddress, [], { onAccount })\n * // Oracle respond signature\n * const respondSig = await aeSdk\n * .createDelegationSignature(contractAddress, [oracleQueryId], { onAccount, omitAddress: true })\n * ```\n */\nexport default async function createDelegationSignature(\n contractAddress: Encoded.ContractAddress,\n ids: Array<Encoded.Any | AensName>,\n options: { omitAddress?: boolean; onAccount: AccountBase; onNode: Node },\n): Promise<Uint8Array> {\n return options.onAccount.sign(\n concatBuffers([\n Buffer.from(await options.onNode.getNetworkId()),\n ...options.omitAddress === true ? [] : [decode(options.onAccount.address)],\n ...ids.map((e) => (isNameValid(e) ? produceNameId(e) : e)).map((e) => decode(e)),\n decode(contractAddress),\n ]),\n options,\n );\n}\n"],"mappings":";;;;SAASA,MAAM;AAAA,SAGNC,aAAa;AAAA,SACbC,WAAW,EAAEC,aAAa;AAGnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,yBAAyBA,CACrDC,eAAwC,EACxCC,GAAkC,EAClCC,OAAwE,EACnD;EACrB,OAAOA,OAAO,CAACC,SAAS,CAACC,IAAI,CAC3BR,aAAa,CAAC,CACZS,OAAA,CAAOC,IAAI,CAAC,MAAMJ,OAAO,CAACK,MAAM,CAACC,YAAY,EAAE,CAAC,EAChD,IAAGN,OAAO,CAACO,WAAW,KAAK,IAAI,GAAG,EAAE,GAAG,CAACd,MAAM,CAACO,OAAO,CAACC,SAAS,CAACO,OAAO,CAAC,CAAC,GAC1E,GAAGT,GAAG,CAACU,GAAG,CAAEC,CAAC,IAAMf,WAAW,CAACe,CAAC,CAAC,GAAGd,aAAa,CAACc,CAAC,CAAC,GAAGA,CAAE,CAAC,CAACD,GAAG,CAAEC,CAAC,IAAKjB,MAAM,CAACiB,CAAC,CAAC,CAAC,EAChFjB,MAAM,CAACK,eAAe,CAAC,CACxB,CAAC,EACFE,OAAO,CACR;AACH"}
1
+ {"version":3,"file":"delegation-signature.mjs","names":["decode","ArgumentError","isNameValid","ensureOracleQuery","oq","startsWith","createDelegationSignature","contractAddress","ids","_ref","onAccount","omitAddress","options","length","networkId","onNode","getNetworkId","signDelegationToContract","payload","signNameDelegationToContract","signOracleQueryDelegationToContract"],"sources":["../../src/contract/delegation-signature.ts"],"sourcesContent":["import { decode, Encoded } from '../utils/encoder';\nimport { ArgumentError } from '../utils/errors';\nimport { AensName } from '../tx/builder/constants';\nimport AccountBase from '../account/Base';\nimport { isNameValid } from '../tx/builder/helpers';\nimport Node from '../Node';\n\nfunction ensureOracleQuery(oq: string): asserts oq is Encoded.OracleQueryId {\n if (!oq.startsWith('oq_')) throw new ArgumentError('oq', 'oracle query', oq);\n}\n\n/**\n * Helper to generate a signature to delegate\n * - pre-claim/claim/transfer/revoke of a name to a contract.\n * - register/extend/respond of an Oracle to a contract.\n * @category contract\n * @param contractAddress - Address of contract to delegate access\n * @param ids - The list of id's to prepend\n * @param options - Options\n * @param options.omitAddress - Prepend delegation signature with an account address\n * @param options.onAccount - Account to use\n * @param options.onNode - Node to use\n * @returns Signature\n * @deprecated use methods `sign*DelegationToContract` of Account instance instead\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contractAddress = 'ct_asd2ks...'\n * const aensName = 'example.chain'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Preclaim signature\n * const preclaimSig = await aeSdk.createDelegationSignature(contractAddress, [], { onAccount })\n * // Claim, transfer and revoke signature\n * const aensDelegationSig = await aeSdk\n * .createDelegationSignature(contractAddress, [aensName], { onAccount })\n *\n * const oracleQueryId = 'oq_...'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Oracle register and extend signature\n * const oracleDelegationSig = await aeSdk\n * .createDelegationSignature(contractAddress, [], { onAccount })\n * // Oracle respond signature\n * const respondSig = await aeSdk\n * .createDelegationSignature(contractAddress, [oracleQueryId], { onAccount, omitAddress: true })\n * ```\n */\nexport default async function createDelegationSignature(\n contractAddress: Encoded.ContractAddress,\n ids: Array<Encoded.Any | AensName>,\n { onAccount, omitAddress, ...options }: {\n omitAddress?: boolean;\n onAccount: AccountBase;\n onNode: Node;\n },\n): Promise<Uint8Array> {\n if (ids.length > 1) throw new ArgumentError('ids', 'shorter than 2', ids);\n const networkId = await options.onNode.getNetworkId();\n if (ids.length === 0) {\n if (omitAddress === true) {\n throw new ArgumentError('omitAddress', 'equal false', omitAddress);\n }\n return decode(await onAccount.signDelegationToContract(contractAddress, { networkId }));\n }\n\n const [payload] = ids;\n if (isNameValid(payload)) {\n if (omitAddress === true) {\n throw new ArgumentError('omitAddress', 'equal false', omitAddress);\n }\n return decode(\n await onAccount.signNameDelegationToContract(contractAddress, payload, { networkId }),\n );\n }\n\n ensureOracleQuery(payload);\n if (omitAddress !== true) {\n throw new ArgumentError('omitAddress', 'equal true', omitAddress);\n }\n return decode(\n await onAccount.signOracleQueryDelegationToContract(contractAddress, payload, { networkId }),\n );\n}\n"],"mappings":"SAASA,MAAM;AAAA,SACNC,aAAa;AAAA,SAGbC,WAAW;AAGpB,SAASC,iBAAiBA,CAACC,EAAU,EAAuC;EAC1E,IAAI,CAACA,EAAE,CAACC,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,IAAIJ,aAAa,CAAC,IAAI,EAAE,cAAc,EAAEG,EAAE,CAAC;AAC9E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeE,yBAAyBA,CACrDC,eAAwC,EACxCC,GAAkC,EAAAC,IAAA,EAMb;EAAA,IALrB;IAAEC,SAAS;IAAEC,WAAW;IAAE,GAAGC;EAI7B,CAAC,GAAAH,IAAA;EAED,IAAID,GAAG,CAACK,MAAM,GAAG,CAAC,EAAE,MAAM,IAAIZ,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAEO,GAAG,CAAC;EACzE,MAAMM,SAAS,GAAG,MAAMF,OAAO,CAACG,MAAM,CAACC,YAAY,CAAC,CAAC;EACrD,IAAIR,GAAG,CAACK,MAAM,KAAK,CAAC,EAAE;IACpB,IAAIF,WAAW,KAAK,IAAI,EAAE;MACxB,MAAM,IAAIV,aAAa,CAAC,aAAa,EAAE,aAAa,EAAEU,WAAW,CAAC;IACpE;IACA,OAAOX,MAAM,CAAC,MAAMU,SAAS,CAACO,wBAAwB,CAACV,eAAe,EAAE;MAAEO;IAAU,CAAC,CAAC,CAAC;EACzF;EAEA,MAAM,CAACI,OAAO,CAAC,GAAGV,GAAG;EACrB,IAAIN,WAAW,CAACgB,OAAO,CAAC,EAAE;IACxB,IAAIP,WAAW,KAAK,IAAI,EAAE;MACxB,MAAM,IAAIV,aAAa,CAAC,aAAa,EAAE,aAAa,EAAEU,WAAW,CAAC;IACpE;IACA,OAAOX,MAAM,CACX,MAAMU,SAAS,CAACS,4BAA4B,CAACZ,eAAe,EAAEW,OAAO,EAAE;MAAEJ;IAAU,CAAC,CACtF,CAAC;EACH;EAEAX,iBAAiB,CAACe,OAAO,CAAC;EAC1B,IAAIP,WAAW,KAAK,IAAI,EAAE;IACxB,MAAM,IAAIV,aAAa,CAAC,aAAa,EAAE,YAAY,EAAEU,WAAW,CAAC;EACnE;EACA,OAAOX,MAAM,CACX,MAAMU,SAAS,CAACU,mCAAmC,CAACb,eAAe,EAAEW,OAAO,EAAE;IAAEJ;EAAU,CAAC,CAC7F,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"ga.mjs","names":["ConsensusProtocolVersion","Tag","buildContractIdByContractTx","buildTx","buildTxAsync","unpackTx","hash","decode","encode","Encoding","ArgumentError","IllegalArgumentError","concatBuffers","Contract","sendTransaction","getAccount","createGeneralizedAccount","authFnName","args","_ref","_options$gasLimit","onAccount","onCompiler","onNode","bytecode","aci","sourceCodePath","sourceCode","fileSystem","options","ownerId","address","kind","contract","initialize","tx","tag","GaAttachTx","code","$compile","gasLimit","_estimateGas","callData","_calldata","_name","authFun","contractId","transaction","rawTx","Object","freeze","owner","gaContractId","buildAuthTxHash","_ref2","fee","gasPrice","nodeNetworkId","consensusProtocolVersion","getNodeInfo","payload","_Buffer","from","Ceres","GaMetaTxAuthData","txHash","TxHash","buildAuthTxHashByGaMetaTx","_ref3","txParams","SignedTx","encodedTx","GaMetaTx"],"sources":["../../src/contract/ga.ts"],"sourcesContent":["/**\n * Generalized Account module - routines to use generalized account\n */\n\nimport { ConsensusProtocolVersion, Int, Tag } from '../tx/builder/constants';\nimport {\n buildContractIdByContractTx, buildTx, buildTxAsync, BuildTxOptions, unpackTx,\n} from '../tx/builder';\nimport { hash } from '../utils/crypto';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../utils/encoder';\nimport { ArgumentError, IllegalArgumentError } from '../utils/errors';\nimport { concatBuffers } from '../utils/other';\nimport AccountBase from '../account/Base';\nimport Contract from './Contract';\nimport Node from '../Node';\nimport { sendTransaction, SendTransactionOptions, getAccount } from '../chain';\nimport CompilerBase from './compiler/Base';\n\n/**\n * Convert current account to GA\n * @category contract\n * @param authFnName - Authorization function name\n * @param sourceCode - Auth contract source code\n * @param args - init arguments\n * @param options - Options\n * @returns General Account Object\n */\nexport async function createGeneralizedAccount(\n authFnName: string,\n args: any[],\n {\n onAccount, onCompiler, onNode, bytecode, aci, sourceCodePath, sourceCode, fileSystem, ...options\n }: CreateGeneralizedAccountOptions,\n): Promise<Readonly<{\n owner: Encoded.AccountAddress;\n transaction: Encoded.TxHash;\n rawTx: Encoded.Transaction;\n gaContractId: Encoded.ContractAddress;\n }>> {\n const ownerId = onAccount.address;\n if ((await getAccount(ownerId, { onNode })).kind === 'generalized') {\n throw new IllegalArgumentError(`Account ${ownerId} is already GA`);\n }\n\n const contract = await Contract.initialize<{ init: (...a: any[]) => void }>({\n onAccount, onCompiler, onNode, bytecode, aci, sourceCodePath, sourceCode, fileSystem,\n });\n\n const tx = await buildTxAsync({\n ...options,\n tag: Tag.GaAttachTx,\n onNode,\n code: await contract.$compile(),\n gasLimit: options.gasLimit ?? await contract._estimateGas('init', args, options),\n ownerId,\n callData: contract._calldata.encode(contract._name, 'init', args),\n authFun: hash(authFnName),\n });\n const contractId = buildContractIdByContractTx(tx);\n const { hash: transaction, rawTx } = await sendTransaction(tx, {\n onNode, onAccount, onCompiler, ...options,\n });\n\n return Object.freeze({\n owner: ownerId,\n transaction,\n rawTx,\n gaContractId: contractId,\n });\n}\n\ninterface CreateGeneralizedAccountOptions extends\n BuildTxOptions<Tag.GaAttachTx, 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit'>,\n SendTransactionOptions,\n Pick<\n Parameters<typeof Contract.initialize>[0],\n 'bytecode' | 'aci' | 'sourceCodePath' | 'sourceCode' | 'fileSystem'\n > {\n onAccount: AccountBase;\n onCompiler: CompilerBase;\n onNode: Node;\n gasLimit?: number;\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx payload\n * @category contract\n * @param transaction - tx-encoded transaction\n * @param options - Options\n * @param options.fee - GaMetaTx fee, required in Ceres\n * @param options.gasPrice - GaMetaTx gasPrice, required in Ceres\n * @param options.onNode - Node to use\n * @returns Transaction hash\n */\nexport async function buildAuthTxHash(\n transaction: Encoded.Transaction,\n { fee, gasPrice, onNode }: { fee?: Int; gasPrice?: Int; onNode: Node },\n): Promise<Buffer> {\n const { nodeNetworkId, consensusProtocolVersion } = await onNode.getNodeInfo();\n let payload = hash(concatBuffers([Buffer.from(nodeNetworkId), decode(transaction)]));\n if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {\n if (fee == null) throw new ArgumentError('fee', 'provided (in Ceres)', fee);\n if (gasPrice == null) throw new ArgumentError('gasPrice', 'provided (in Ceres)', gasPrice);\n payload = hash(decode(buildTx({\n tag: Tag.GaMetaTxAuthData,\n fee,\n gasPrice,\n txHash: encode(payload, Encoding.TxHash),\n })));\n }\n return payload;\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx\n * @category contract\n * @param transaction - tx-encoded signed GaMeta transaction\n * @param options - Options\n * @param options.onNode - Node to use\n * @returns Transaction hash\n */\nexport async function buildAuthTxHashByGaMetaTx(\n transaction: Encoded.Transaction,\n { onNode }: { onNode: Node },\n): Promise<Buffer> {\n const txParams = unpackTx(transaction, Tag.SignedTx);\n if (txParams.encodedTx.tag !== Tag.GaMetaTx) {\n throw new ArgumentError('transaction', 'to include GaMetaTx', Tag[txParams.encodedTx.tag]);\n }\n return buildAuthTxHash(buildTx(txParams.encodedTx.tx.encodedTx), {\n fee: txParams.encodedTx.fee,\n gasPrice: txParams.encodedTx.gasPrice,\n onNode,\n });\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AAFA,SAISA,wBAAwB,EAAOC,GAAG;AAAA,SAEzCC,2BAA2B,EAAEC,OAAO,EAAEC,YAAY,EAAkBC,QAAQ;AAAA,SAErEC,IAAI;AAAA,SAEXC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa,EAAEC,oBAAoB;AAAA,SACnCC,aAAa;AAAA,OAEfC,QAAQ;AAAA,SAENC,eAAe,EAA0BC,UAAU;AAG5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,UAAkB,EAClBC,IAAW,EAAAC,IAAA,EASP;EAAA,IAAAC,iBAAA;EAAA,IARJ;IACEC,SAAS;IAAEC,UAAU;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,GAAG;IAAEC,cAAc;IAAEC,UAAU;IAAEC,UAAU;IAAE,GAAGC;EAC1D,CAAC,GAAAV,IAAA;EAOlC,MAAMW,OAAO,GAAGT,SAAS,CAACU,OAAO;EACjC,IAAI,CAAC,MAAMhB,UAAU,CAACe,OAAO,EAAE;IAAEP;EAAO,CAAC,CAAC,EAAES,IAAI,KAAK,aAAa,EAAE;IAClE,MAAM,IAAIrB,oBAAoB,CAAE,WAAUmB,OAAQ,gBAAe,CAAC;EACpE;EAEA,MAAMG,QAAQ,GAAG,MAAMpB,QAAQ,CAACqB,UAAU,CAAkC;IAC1Eb,SAAS;IAAEC,UAAU;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,GAAG;IAAEC,cAAc;IAAEC,UAAU;IAAEC;EAC5E,CAAC,CAAC;EAE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AAS,CAACf,QAAQ;IACrCjC;EACF,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"ga.mjs","names":["ConsensusProtocolVersion","Tag","buildContractIdByContractTx","buildTx","buildTxAsync","unpackTx","hash","decode","encode","Encoding","ArgumentError","IllegalArgumentError","concatBuffers","Contract","sendTransaction","getAccount","createGeneralizedAccount","authFnName","args","_ref","_options$gasLimit","onAccount","onCompiler","onNode","bytecode","aci","sourceCodePath","sourceCode","fileSystem","options","ownerId","address","kind","contract","initialize","tx","tag","GaAttachTx","code","$compile","gasLimit","_estimateGas","callData","_calldata","_name","authFun","contractId","transaction","rawTx","Object","freeze","owner","gaContractId","buildAuthTxHash","_ref2","fee","gasPrice","nodeNetworkId","consensusProtocolVersion","getNodeInfo","payload","_Buffer","from","Ceres","GaMetaTxAuthData","txHash","TxHash","buildAuthTxHashByGaMetaTx","_ref3","txParams","SignedTx","encodedTx","GaMetaTx"],"sources":["../../src/contract/ga.ts"],"sourcesContent":["/**\n * Generalized Account module - routines to use generalized account\n */\n\nimport { ConsensusProtocolVersion, Int, Tag } from '../tx/builder/constants';\nimport {\n buildContractIdByContractTx, buildTx, buildTxAsync, BuildTxOptions, unpackTx,\n} from '../tx/builder';\nimport { hash } from '../utils/crypto';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../utils/encoder';\nimport { ArgumentError, IllegalArgumentError } from '../utils/errors';\nimport { concatBuffers } from '../utils/other';\nimport AccountBase from '../account/Base';\nimport Contract from './Contract';\nimport Node from '../Node';\nimport { sendTransaction, SendTransactionOptions, getAccount } from '../chain';\nimport CompilerBase from './compiler/Base';\n\n/**\n * Convert current account to GA\n * @category contract\n * @param authFnName - Authorization function name\n * @param sourceCode - Auth contract source code\n * @param args - init arguments\n * @param options - Options\n * @returns General Account Object\n */\nexport async function createGeneralizedAccount(\n authFnName: string,\n args: any[],\n {\n onAccount, onCompiler, onNode, bytecode, aci, sourceCodePath, sourceCode, fileSystem, ...options\n }: CreateGeneralizedAccountOptions,\n): Promise<Readonly<{\n owner: Encoded.AccountAddress;\n transaction: Encoded.TxHash;\n rawTx: Encoded.Transaction;\n gaContractId: Encoded.ContractAddress;\n }>> {\n const ownerId = onAccount.address;\n if ((await getAccount(ownerId, { onNode })).kind === 'generalized') {\n throw new IllegalArgumentError(`Account ${ownerId} is already GA`);\n }\n\n const contract = await Contract.initialize<{ init: (...a: any[]) => void }>({\n onAccount, onCompiler, onNode, bytecode, aci, sourceCodePath, sourceCode, fileSystem,\n });\n\n const tx = await buildTxAsync({\n ...options,\n tag: Tag.GaAttachTx,\n onNode,\n code: await contract.$compile(),\n gasLimit: options.gasLimit ?? await contract._estimateGas('init', args, options),\n ownerId,\n callData: contract._calldata.encode(contract._name, 'init', args),\n authFun: hash(authFnName),\n });\n const contractId = buildContractIdByContractTx(tx);\n const { hash: transaction, rawTx } = await sendTransaction(tx, {\n onNode, onAccount, onCompiler, ...options,\n });\n\n return Object.freeze({\n owner: ownerId,\n transaction,\n rawTx,\n gaContractId: contractId,\n });\n}\n\ninterface CreateGeneralizedAccountOptions extends\n BuildTxOptions<Tag.GaAttachTx, 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit'>,\n SendTransactionOptions,\n Pick<\n Parameters<typeof Contract.initialize>[0],\n 'bytecode' | 'aci' | 'sourceCodePath' | 'sourceCode' | 'fileSystem'\n > {\n onAccount: AccountBase;\n onCompiler: CompilerBase;\n onNode: Node;\n gasLimit?: number;\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx payload\n * @category contract\n * @param transaction - tx-encoded transaction\n * @param options - Options\n * @param options.fee - GaMetaTx fee, required in Ceres\n * @param options.gasPrice - GaMetaTx gasPrice, required in Ceres\n * @param options.onNode - Node to use\n * @returns Transaction hash\n */\nexport async function buildAuthTxHash(\n transaction: Encoded.Transaction,\n { fee, gasPrice, onNode }: { fee?: Int; gasPrice?: Int; onNode: Node },\n): Promise<Buffer> {\n const { nodeNetworkId, consensusProtocolVersion } = await onNode.getNodeInfo();\n let payload = hash(concatBuffers([Buffer.from(nodeNetworkId), decode(transaction)]));\n if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {\n if (fee == null) throw new ArgumentError('fee', 'provided (in Ceres)', fee);\n if (gasPrice == null) throw new ArgumentError('gasPrice', 'provided (in Ceres)', gasPrice);\n payload = hash(decode(buildTx({\n tag: Tag.GaMetaTxAuthData,\n fee,\n gasPrice,\n txHash: encode(payload, Encoding.TxHash),\n })));\n }\n return payload;\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx\n * @category contract\n * @param transaction - tx-encoded signed GaMeta transaction\n * @param options - Options\n * @param options.onNode - Node to use\n * @returns Transaction hash\n */\nexport async function buildAuthTxHashByGaMetaTx(\n transaction: Encoded.Transaction,\n { onNode }: { onNode: Node },\n): Promise<Buffer> {\n const txParams = unpackTx(transaction, Tag.SignedTx);\n if (txParams.encodedTx.tag !== Tag.GaMetaTx) {\n throw new ArgumentError('transaction', 'to include GaMetaTx', Tag[txParams.encodedTx.tag]);\n }\n return buildAuthTxHash(buildTx(txParams.encodedTx.tx.encodedTx), {\n fee: txParams.encodedTx.fee,\n gasPrice: txParams.encodedTx.gasPrice,\n onNode,\n });\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AAFA,SAISA,wBAAwB,EAAOC,GAAG;AAAA,SAEzCC,2BAA2B,EAAEC,OAAO,EAAEC,YAAY,EAAkBC,QAAQ;AAAA,SAErEC,IAAI;AAAA,SAEXC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa,EAAEC,oBAAoB;AAAA,SACnCC,aAAa;AAAA,OAEfC,QAAQ;AAAA,SAENC,eAAe,EAA0BC,UAAU;AAG5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,UAAkB,EAClBC,IAAW,EAAAC,IAAA,EASP;EAAA,IAAAC,iBAAA;EAAA,IARJ;IACEC,SAAS;IAAEC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EAAAqB,KAAA,EAEf;EAAA,IADjB;IAAE7C;EAAyB,CAAC,GAAA6C,KAAA;EAE5B,MAAMC,QAAQ,GAAGhE,QAAQ,CAAC0C,WAAW,EAAE9C,GAAG,CAACqE,QAAQ,CAAC;EACpD,IAAID,QAAQ,CAACE,SAAS,CAACnC,GAAG,KAAKnC,GAAG,CAACuE,QAAQ,EAAE;IAC3C,MAAM,IAAI9D,aAAa,CAAC,aAAa,EAAE,qBAAqB,EAAET,GAAG,CAACoE,QAAQ,CAACE,SAAS,CAACnC,GAAG,CAAC,CAAC;EAC5F;EACA,OAAOiB,eAAe,CAAClD,OAAO,CAACkE,QAAQ,CAACE,SAAS,CAACpC,EAAE,CAACoC,SAAS,CAAC,EAAE;IAC/DhB,GAAG,EAAEc,QAAQ,CAACE,SAAS,CAAChB,GAAG;IAC3BC,QAAQ,EAAEa,QAAQ,CAACE,SAAS,CAACf,QAAQ;IACrCjC;EACF,CAAC,CAAC;AACJ"}
@@ -0,0 +1,14 @@
1
+ import { RpcError } from './aepp-wallet-communication/schema';
2
+ /**
3
+ * @category exception
4
+ * @deprecated this exception is not thrown anymore
5
+ */
6
+ export declare class RpcBroadcastError extends RpcError {
7
+ static code: number;
8
+ code: number;
9
+ constructor(data?: any);
10
+ }
11
+ /**
12
+ * @deprecated use isAuctionName instead
13
+ */
14
+ export declare const NAME_BID_MAX_LENGTH = 12;
@@ -0,0 +1,22 @@
1
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
+ import { RpcError } from "./aepp-wallet-communication/schema.mjs";
3
+ /**
4
+ * @category exception
5
+ * @deprecated this exception is not thrown anymore
6
+ */
7
+ // eslint-disable-next-line import/prefer-default-export
8
+ export class RpcBroadcastError extends RpcError {
9
+ constructor(data) {
10
+ super('Broadcast failed');
11
+ _defineProperty(this, "code", 3);
12
+ this.data = data;
13
+ this.name = 'RpcBroadcastError';
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @deprecated use isAuctionName instead
19
+ */
20
+ _defineProperty(RpcBroadcastError, "code", 3);
21
+ export const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid
22
+ //# sourceMappingURL=deprecated.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated.mjs","names":["RpcError","RpcBroadcastError","constructor","data","_defineProperty","name","NAME_BID_MAX_LENGTH"],"sources":["../src/deprecated.ts"],"sourcesContent":["import { RpcError } from './aepp-wallet-communication/schema';\n\n/**\n * @category exception\n * @deprecated this exception is not thrown anymore\n */\n// eslint-disable-next-line import/prefer-default-export\nexport class RpcBroadcastError extends RpcError {\n static override code = 3;\n\n override code = 3;\n\n constructor(data?: any) {\n super('Broadcast failed');\n this.data = data;\n this.name = 'RpcBroadcastError';\n }\n}\n\n/**\n * @deprecated use isAuctionName instead\n */\nexport const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid\n"],"mappings":";SAASA,QAAQ;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,SAASD,QAAQ,CAAC;EAK9CE,WAAWA,CAACC,IAAU,EAAE;IACtB,KAAK,CAAC,kBAAkB,CAAC;IAACC,eAAA,eAHZ,CAAC;IAIf,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACE,IAAI,GAAG,mBAAmB;EACjC;AACF;;AAEA;AACA;AACA;AAFAD,eAAA,CAZaH,iBAAiB,UACL,CAAC;AAc1B,OAAO,MAAMK,mBAAmB,GAAG,EAAE,CAAC,CAAC"}
@@ -1,22 +1,25 @@
1
- export * from './chain';
2
- export * from './utils/crypto';
3
- export * from './utils/keystore';
4
- export * from './utils/bytes';
1
+ export { _getPollInterval, InvalidTxError, getHeight, poll, awaitHeight, waitForTxConfirm, sendTransaction, getAccount, getBalance, getCurrentGeneration, getGeneration, getMicroBlockTransactions, getKeyBlock, getMicroBlockHeader, txDryRun, getContractByteCode, getContract, getName, resolveName, } from './chain';
2
+ export { getAddressFromPriv, isAddressValid, genSalt, encodeUnsigned, hash, encodeContractAddress, generateKeyPairFromSecret, generateKeyPair, sign, verify, messageToHash, signMessage, verifyMessage, isValidKeypair, } from './utils/crypto';
3
+ export { recover, dump } from './utils/keystore';
4
+ export type { Keystore } from './utils/keystore';
5
+ export { toBytes } from './utils/bytes';
5
6
  export { buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx, } from './tx/builder';
6
- export * from './tx/builder/helpers';
7
- export * from './tx/builder/constants';
7
+ export { buildContractId, oracleQueryId, produceNameId, commitmentHash, readInt, isNameValid, ensureName, getDefaultPointerKey, getMinimumNameFee, computeBidFee, computeAuctionEndBlock, isAuctionName, } from './tx/builder/helpers';
8
+ export { MAX_AUTH_FUN_GAS, NAME_TTL, NAME_MAX_TTL, NAME_MAX_CLIENT_TTL, CLIENT_TTL, MIN_GAS_PRICE, NAME_FEE_MULTIPLIER, NAME_FEE_BID_INCREMENT, NAME_BID_TIMEOUT_BLOCKS, NAME_MAX_LENGTH_FEE, NAME_BID_RANGES, ConsensusProtocolVersion, VmVersion, AbiVersion, Tag, } from './tx/builder/constants';
9
+ export type { Int, AensName } from './tx/builder/constants';
8
10
  export { ORACLE_TTL_TYPES, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL, DRY_RUN_ACCOUNT, CallReturnType, } from './tx/builder/schema';
9
11
  export { getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode, } from './tx/execution-cost';
10
12
  export { default as getTransactionSignerAddress } from './tx/transaction-signer';
11
- export * from './utils/amount-formatter';
12
- export * from './utils/hd-wallet';
13
+ export { AE_AMOUNT_FORMATS, formatAmount, toAe, toAettos, prefixedAmount, } from './utils/amount-formatter';
14
+ export { DerivationError, deriveChild, derivePathFromKey, getMasterKeyFromSeed, derivePathFromSeed, getKeyPair, generateSaveHDWalletFromSeed, getSaveHDWalletAccounts, getHdWalletAccountFromSeed, } from './utils/hd-wallet';
13
15
  export { encode, decode, Encoding, Encoded, } from './utils/encoder';
14
- export * from './aens';
16
+ export { encodeFateValue, decodeFateValue, hashTypedData, hashDomain, hashJson, } from './utils/typed-data';
17
+ export { aensRevoke, aensUpdate, aensTransfer, aensQuery, aensClaim, aensPreclaim, aensBid, } from './aens';
15
18
  export { default as Contract } from './contract/Contract';
16
19
  export type { ContractMethodsBase } from './contract/Contract';
17
- export * from './oracle';
18
- export * from './spend';
19
- export * from './contract/ga';
20
+ export { pollForQueries, pollForQueryResponse, getQueryObject, postQueryToOracle, extendOracleTtl, respondToQuery, getOracleObject, registerOracle, } from './oracle';
21
+ export { spend, transferFunds, payForTransaction } from './spend';
22
+ export { createGeneralizedAccount, buildAuthTxHash, buildAuthTxHashByGaMetaTx } from './contract/ga';
20
23
  export { default as AeSdkMethods } from './AeSdkMethods';
21
24
  export { default as AeSdkBase } from './AeSdkBase';
22
25
  export { default as AeSdk } from './AeSdk';
@@ -32,9 +35,12 @@ export { default as AccountLedgerFactory } from './account/LedgerFactory';
32
35
  export { default as CompilerBase } from './contract/compiler/Base';
33
36
  export { default as CompilerHttp } from './contract/compiler/Http';
34
37
  export { default as Channel } from './channel/Contract';
38
+ export { default as _MiddlewareSubscriber, MiddlewareSubscriberError as _MiddlewareSubscriberError, MiddlewareSubscriberDisconnected as _MiddlewareSubscriberDisconnected, } from './MiddlewareSubscriber';
39
+ export { default as _Middleware } from './Middleware';
35
40
  export { default as connectionProxy } from './aepp-wallet-communication/connection-proxy';
36
- export * from './aepp-wallet-communication/schema';
41
+ export { MESSAGE_DIRECTION, WALLET_TYPE, SUBSCRIPTION_TYPES, METHODS, RPC_STATUS, RpcError, RpcInvalidTransactionError, RpcRejectedByUserError, RpcUnsupportedProtocolError, RpcConnectionDenyError, RpcNotAuthorizeError, RpcPermissionDenyError, RpcInternalError, RpcMethodNotFoundError, } from './aepp-wallet-communication/schema';
37
42
  export { default as walletDetector } from './aepp-wallet-communication/wallet-detector';
38
43
  export { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime';
39
44
  export { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage';
40
- export * from './utils/errors';
45
+ export { BaseError, AccountError, AensError, AeppError, ChannelError, CompilerError, ContractError, CryptographyError, NodeError, TransactionError, WalletError, ArgumentError, IllegalArgumentError, ArgumentCountMismatchError, InsufficientBalanceError, MissingParamError, NoSerializerFoundError, RequestTimedOutError, TxTimedOutError, TypeError, UnsupportedPlatformError, UnsupportedProtocolError, NotImplementedError, UnsupportedVersionError, InternalError, UnexpectedTsError, UnavailableAccountError, AensPointerContextError, InsufficientNameFeeError, InvalidAensNameError, InvalidRpcMessageError, MissingCallbackError, UnAuthorizedAccountError, UnknownRpcClientError, UnsubscribedAccountError, ChannelCallError, ChannelConnectionError, ChannelPingTimedOutError, UnexpectedChannelMessageError, ChannelIncomingMessageError, UnknownChannelStateError, InvalidAuthDataError, BytecodeMismatchError, DuplicateContractError, InactiveContractError, InvalidMethodInvocationError, MissingContractAddressError, MissingContractDefError, MissingFunctionNameError, NodeInvocationError, NoSuchContractFunctionError, NotPayableFunctionError, MissingEventDefinitionError, AmbiguousEventDefinitionError, InvalidChecksumError, InvalidPasswordError, MerkleTreeHashMismatchError, MissingNodeInTreeError, UnknownNodeLengthError, UnknownPathNibbleError, DuplicateNodeError, NodeNotFoundError, DecodeError, PayloadLengthError, DryRunError, IllegalBidFeeError, InvalidSignatureError, PrefixNotFoundError, SchemaNotFoundError, TagNotFoundError, TxNotInChainError, AlreadyConnectedError, NoWalletConnectedError, RpcConnectionError, } from './utils/errors';
46
+ export { RpcBroadcastError, NAME_BID_MAX_LENGTH } from './deprecated';
@@ -1,22 +1,23 @@
1
- // TODO: avoid `export * from`
2
- export * from "./chain.mjs";
3
- export * from "./utils/crypto.mjs";
4
- export * from "./utils/keystore.mjs";
5
- export * from "./utils/bytes.mjs";
1
+ export { _getPollInterval, InvalidTxError, getHeight, poll, awaitHeight, waitForTxConfirm, sendTransaction, getAccount, getBalance, getCurrentGeneration, getGeneration, getMicroBlockTransactions, getKeyBlock, getMicroBlockHeader, txDryRun, getContractByteCode, getContract, getName, resolveName } from "./chain.mjs";
2
+ export { getAddressFromPriv, isAddressValid, genSalt, encodeUnsigned, hash, encodeContractAddress, generateKeyPairFromSecret, generateKeyPair, sign, verify, messageToHash, signMessage, verifyMessage, isValidKeypair } from "./utils/crypto.mjs";
3
+ export { recover, dump } from "./utils/keystore.mjs";
4
+ export { toBytes } from "./utils/bytes.mjs";
6
5
  export { buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx } from "./tx/builder/index.mjs";
7
- export * from "./tx/builder/helpers.mjs";
8
- export * from "./tx/builder/constants.mjs"; // TODO: move to constants
6
+ export { buildContractId, oracleQueryId, produceNameId, commitmentHash, readInt, isNameValid, ensureName, getDefaultPointerKey, getMinimumNameFee, computeBidFee, computeAuctionEndBlock, isAuctionName } from "./tx/builder/helpers.mjs";
7
+ export { MAX_AUTH_FUN_GAS, NAME_TTL, NAME_MAX_TTL, NAME_MAX_CLIENT_TTL, CLIENT_TTL, MIN_GAS_PRICE, NAME_FEE_MULTIPLIER, NAME_FEE_BID_INCREMENT, NAME_BID_TIMEOUT_BLOCKS, NAME_MAX_LENGTH_FEE, NAME_BID_RANGES, ConsensusProtocolVersion, VmVersion, AbiVersion, Tag } from "./tx/builder/constants.mjs";
8
+ // TODO: move to constants
9
9
  export { ORACLE_TTL_TYPES, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL, DRY_RUN_ACCOUNT, CallReturnType } from "./tx/builder/schema.mjs";
10
10
  export { getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode } from "./tx/execution-cost.mjs";
11
11
  export { default as getTransactionSignerAddress } from "./tx/transaction-signer.mjs";
12
- export * from "./utils/amount-formatter.mjs";
13
- export * from "./utils/hd-wallet.mjs";
12
+ export { AE_AMOUNT_FORMATS, formatAmount, toAe, toAettos, prefixedAmount } from "./utils/amount-formatter.mjs";
13
+ export { DerivationError, deriveChild, derivePathFromKey, getMasterKeyFromSeed, derivePathFromSeed, getKeyPair, generateSaveHDWalletFromSeed, getSaveHDWalletAccounts, getHdWalletAccountFromSeed } from "./utils/hd-wallet.mjs";
14
14
  export { encode, decode, Encoding, Encoded } from "./utils/encoder.mjs";
15
- export * from "./aens.mjs";
15
+ export { encodeFateValue, decodeFateValue, hashTypedData, hashDomain, hashJson } from "./utils/typed-data.mjs";
16
+ export { aensRevoke, aensUpdate, aensTransfer, aensQuery, aensClaim, aensPreclaim, aensBid } from "./aens.mjs";
16
17
  export { default as Contract } from "./contract/Contract.mjs";
17
- export * from "./oracle.mjs";
18
- export * from "./spend.mjs";
19
- export * from "./contract/ga.mjs";
18
+ export { pollForQueries, pollForQueryResponse, getQueryObject, postQueryToOracle, extendOracleTtl, respondToQuery, getOracleObject, registerOracle } from "./oracle.mjs";
19
+ export { spend, transferFunds, payForTransaction } from "./spend.mjs";
20
+ export { createGeneralizedAccount, buildAuthTxHash, buildAuthTxHashByGaMetaTx } from "./contract/ga.mjs";
20
21
  export { default as AeSdkMethods } from "./AeSdkMethods.mjs";
21
22
  export { default as AeSdkBase } from "./AeSdkBase.mjs";
22
23
  export { default as AeSdk } from "./AeSdk.mjs";
@@ -32,10 +33,13 @@ export { default as AccountLedgerFactory } from "./account/LedgerFactory.mjs";
32
33
  export { default as CompilerBase } from "./contract/compiler/Base.mjs";
33
34
  export { default as CompilerHttp } from "./contract/compiler/Http.mjs";
34
35
  export { default as Channel } from "./channel/Contract.mjs";
36
+ export { default as _MiddlewareSubscriber, MiddlewareSubscriberError as _MiddlewareSubscriberError, MiddlewareSubscriberDisconnected as _MiddlewareSubscriberDisconnected } from "./MiddlewareSubscriber.mjs";
37
+ export { default as _Middleware } from "./Middleware.mjs";
35
38
  export { default as connectionProxy } from "./aepp-wallet-communication/connection-proxy.mjs";
36
- export * from "./aepp-wallet-communication/schema.mjs";
39
+ export { MESSAGE_DIRECTION, WALLET_TYPE, SUBSCRIPTION_TYPES, METHODS, RPC_STATUS, RpcError, RpcInvalidTransactionError, RpcRejectedByUserError, RpcUnsupportedProtocolError, RpcConnectionDenyError, RpcNotAuthorizeError, RpcPermissionDenyError, RpcInternalError, RpcMethodNotFoundError } from "./aepp-wallet-communication/schema.mjs";
37
40
  export { default as walletDetector } from "./aepp-wallet-communication/wallet-detector.mjs";
38
41
  export { default as BrowserRuntimeConnection } from "./aepp-wallet-communication/connection/BrowserRuntime.mjs";
39
42
  export { default as BrowserWindowMessageConnection } from "./aepp-wallet-communication/connection/BrowserWindowMessage.mjs";
40
- export * from "./utils/errors.mjs";
43
+ export { BaseError, AccountError, AensError, AeppError, ChannelError, CompilerError, ContractError, CryptographyError, NodeError, TransactionError, WalletError, ArgumentError, IllegalArgumentError, ArgumentCountMismatchError, InsufficientBalanceError, MissingParamError, NoSerializerFoundError, RequestTimedOutError, TxTimedOutError, TypeError, UnsupportedPlatformError, UnsupportedProtocolError, NotImplementedError, UnsupportedVersionError, InternalError, UnexpectedTsError, UnavailableAccountError, AensPointerContextError, InsufficientNameFeeError, InvalidAensNameError, InvalidRpcMessageError, MissingCallbackError, UnAuthorizedAccountError, UnknownRpcClientError, UnsubscribedAccountError, ChannelCallError, ChannelConnectionError, ChannelPingTimedOutError, UnexpectedChannelMessageError, ChannelIncomingMessageError, UnknownChannelStateError, InvalidAuthDataError, BytecodeMismatchError, DuplicateContractError, InactiveContractError, InvalidMethodInvocationError, MissingContractAddressError, MissingContractDefError, MissingFunctionNameError, NodeInvocationError, NoSuchContractFunctionError, NotPayableFunctionError, MissingEventDefinitionError, AmbiguousEventDefinitionError, InvalidChecksumError, InvalidPasswordError, MerkleTreeHashMismatchError, MissingNodeInTreeError, UnknownNodeLengthError, UnknownPathNibbleError, DuplicateNodeError, NodeNotFoundError, DecodeError, PayloadLengthError, DryRunError, IllegalBidFeeError, InvalidSignatureError, PrefixNotFoundError, SchemaNotFoundError, TagNotFoundError, TxNotInChainError, AlreadyConnectedError, NoWalletConnectedError, RpcConnectionError } from "./utils/errors.mjs";
44
+ export { RpcBroadcastError, NAME_BID_MAX_LENGTH } from "./deprecated.mjs";
41
45
  //# sourceMappingURL=index-browser.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser.mjs","names":["buildTx","buildTxAsync","buildTxHash","unpackTx","buildContractIdByContractTx","ORACLE_TTL_TYPES","ORACLE_TTL","QUERY_TTL","RESPONSE_TTL","DRY_RUN_ACCOUNT","CallReturnType","getExecutionCost","getExecutionCostBySignedTx","getExecutionCostUsingNode","default","getTransactionSignerAddress","encode","decode","Encoding","Encoded","Contract","AeSdkMethods","AeSdkBase","AeSdk","AeSdkAepp","AeSdkWallet","Node","verifyTransaction","AccountBase","MemoryAccount","AccountGeneralized","AccountLedger","AccountLedgerFactory","CompilerBase","CompilerHttp","Channel","connectionProxy","walletDetector","BrowserRuntimeConnection","BrowserWindowMessageConnection"],"sources":["../src/index-browser.ts"],"sourcesContent":["// TODO: avoid `export * from`\nexport * from './chain';\nexport * from './utils/crypto';\nexport * from './utils/keystore';\nexport * from './utils/bytes';\nexport {\n buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx,\n} from './tx/builder';\nexport * from './tx/builder/helpers';\nexport * from './tx/builder/constants';\n// TODO: move to constants\nexport {\n ORACLE_TTL_TYPES, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL, DRY_RUN_ACCOUNT, CallReturnType,\n} from './tx/builder/schema';\nexport {\n getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode,\n} from './tx/execution-cost';\nexport { default as getTransactionSignerAddress } from './tx/transaction-signer';\nexport * from './utils/amount-formatter';\nexport * from './utils/hd-wallet';\nexport {\n encode, decode, Encoding, Encoded,\n} from './utils/encoder';\nexport * from './aens';\nexport { default as Contract } from './contract/Contract';\nexport type { ContractMethodsBase } from './contract/Contract';\nexport * from './oracle';\nexport * from './spend';\nexport * from './contract/ga';\n\nexport { default as AeSdkMethods } from './AeSdkMethods';\nexport { default as AeSdkBase } from './AeSdkBase';\nexport { default as AeSdk } from './AeSdk';\nexport { default as AeSdkAepp } from './AeSdkAepp';\nexport { default as AeSdkWallet } from './AeSdkWallet';\nexport { default as Node } from './Node';\nexport { default as verifyTransaction } from './tx/validator';\nexport { default as AccountBase } from './account/Base';\nexport { default as MemoryAccount } from './account/Memory';\nexport { default as AccountGeneralized } from './account/Generalized';\nexport { default as AccountLedger } from './account/Ledger';\nexport { default as AccountLedgerFactory } from './account/LedgerFactory';\nexport { default as CompilerBase } from './contract/compiler/Base';\nexport { default as CompilerHttp } from './contract/compiler/Http';\nexport { default as Channel } from './channel/Contract';\n\nexport { default as connectionProxy } from './aepp-wallet-communication/connection-proxy';\nexport * from './aepp-wallet-communication/schema';\nexport { default as walletDetector } from './aepp-wallet-communication/wallet-detector';\nexport { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime';\nexport { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage';\nexport * from './utils/errors';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAMEA,OAAO,EAAEC,YAAY,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,2BAA2B;AAAA;AAAA,4CAI3E;AAAA,SAEEC,gBAAgB,EAAEC,UAAU,EAAEC,SAAS,EAAEC,YAAY,EAAEC,eAAe,EAAEC,cAAc;AAAA,SAGtFC,gBAAgB,EAAEC,0BAA0B,EAAEC,yBAAyB;AAAA,SAEhEC,OAAO,IAAIC,2BAA2B;AAAA;AAAA;AAAA,SAI7CC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,OAAO;AAAA;AAAA,SAG1BL,OAAO,IAAIM,QAAQ;AAAA;AAAA;AAAA;AAAA,SAMnBN,OAAO,IAAIO,YAAY;AAAA,SACvBP,OAAO,IAAIQ,SAAS;AAAA,SACpBR,OAAO,IAAIS,KAAK;AAAA,SAChBT,OAAO,IAAIU,SAAS;AAAA,SACpBV,OAAO,IAAIW,WAAW;AAAA,SACtBX,OAAO,IAAIY,IAAI;AAAA,SACfZ,OAAO,IAAIa,iBAAiB;AAAA,SAC5Bb,OAAO,IAAIc,WAAW;AAAA,SACtBd,OAAO,IAAIe,aAAa;AAAA,SACxBf,OAAO,IAAIgB,kBAAkB;AAAA,SAC7BhB,OAAO,IAAIiB,aAAa;AAAA,SACxBjB,OAAO,IAAIkB,oBAAoB;AAAA,SAC/BlB,OAAO,IAAImB,YAAY;AAAA,SACvBnB,OAAO,IAAIoB,YAAY;AAAA,SACvBpB,OAAO,IAAIqB,OAAO;AAAA,SAElBrB,OAAO,IAAIsB,eAAe;AAAA;AAAA,SAE1BtB,OAAO,IAAIuB,cAAc;AAAA,SACzBvB,OAAO,IAAIwB,wBAAwB;AAAA,SACnCxB,OAAO,IAAIyB,8BAA8B;AAAA"}
1
+ {"version":3,"file":"index-browser.mjs","names":["_getPollInterval","InvalidTxError","getHeight","poll","awaitHeight","waitForTxConfirm","sendTransaction","getAccount","getBalance","getCurrentGeneration","getGeneration","getMicroBlockTransactions","getKeyBlock","getMicroBlockHeader","txDryRun","getContractByteCode","getContract","getName","resolveName","getAddressFromPriv","isAddressValid","genSalt","encodeUnsigned","hash","encodeContractAddress","generateKeyPairFromSecret","generateKeyPair","sign","verify","messageToHash","signMessage","verifyMessage","isValidKeypair","recover","dump","toBytes","buildTx","buildTxAsync","buildTxHash","unpackTx","buildContractIdByContractTx","buildContractId","oracleQueryId","produceNameId","commitmentHash","readInt","isNameValid","ensureName","getDefaultPointerKey","getMinimumNameFee","computeBidFee","computeAuctionEndBlock","isAuctionName","MAX_AUTH_FUN_GAS","NAME_TTL","NAME_MAX_TTL","NAME_MAX_CLIENT_TTL","CLIENT_TTL","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_RANGES","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag","ORACLE_TTL_TYPES","ORACLE_TTL","QUERY_TTL","RESPONSE_TTL","DRY_RUN_ACCOUNT","CallReturnType","getExecutionCost","getExecutionCostBySignedTx","getExecutionCostUsingNode","default","getTransactionSignerAddress","AE_AMOUNT_FORMATS","formatAmount","toAe","toAettos","prefixedAmount","DerivationError","deriveChild","derivePathFromKey","getMasterKeyFromSeed","derivePathFromSeed","getKeyPair","generateSaveHDWalletFromSeed","getSaveHDWalletAccounts","getHdWalletAccountFromSeed","encode","decode","Encoding","Encoded","encodeFateValue","decodeFateValue","hashTypedData","hashDomain","hashJson","aensRevoke","aensUpdate","aensTransfer","aensQuery","aensClaim","aensPreclaim","aensBid","Contract","pollForQueries","pollForQueryResponse","getQueryObject","postQueryToOracle","extendOracleTtl","respondToQuery","getOracleObject","registerOracle","spend","transferFunds","payForTransaction","createGeneralizedAccount","buildAuthTxHash","buildAuthTxHashByGaMetaTx","AeSdkMethods","AeSdkBase","AeSdk","AeSdkAepp","AeSdkWallet","Node","verifyTransaction","AccountBase","MemoryAccount","AccountGeneralized","AccountLedger","AccountLedgerFactory","CompilerBase","CompilerHttp","Channel","_MiddlewareSubscriber","MiddlewareSubscriberError","_MiddlewareSubscriberError","MiddlewareSubscriberDisconnected","_MiddlewareSubscriberDisconnected","_Middleware","connectionProxy","MESSAGE_DIRECTION","WALLET_TYPE","SUBSCRIPTION_TYPES","METHODS","RPC_STATUS","RpcError","RpcInvalidTransactionError","RpcRejectedByUserError","RpcUnsupportedProtocolError","RpcConnectionDenyError","RpcNotAuthorizeError","RpcPermissionDenyError","RpcInternalError","RpcMethodNotFoundError","walletDetector","BrowserRuntimeConnection","BrowserWindowMessageConnection","BaseError","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","IllegalArgumentError","ArgumentCountMismatchError","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","TxTimedOutError","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","InternalError","UnexpectedTsError","UnavailableAccountError","AensPointerContextError","InsufficientNameFeeError","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","UnAuthorizedAccountError","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","ChannelIncomingMessageError","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","DuplicateContractError","InactiveContractError","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","NoSuchContractFunctionError","NotPayableFunctionError","MissingEventDefinitionError","AmbiguousEventDefinitionError","InvalidChecksumError","InvalidPasswordError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","UnknownPathNibbleError","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","PrefixNotFoundError","SchemaNotFoundError","TagNotFoundError","TxNotInChainError","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError","RpcBroadcastError","NAME_BID_MAX_LENGTH"],"sources":["../src/index-browser.ts"],"sourcesContent":["export {\n _getPollInterval, InvalidTxError, getHeight, poll, awaitHeight, waitForTxConfirm, sendTransaction,\n getAccount, getBalance, getCurrentGeneration, getGeneration, getMicroBlockTransactions,\n getKeyBlock, getMicroBlockHeader, txDryRun, getContractByteCode, getContract, getName,\n resolveName,\n} from './chain';\nexport {\n getAddressFromPriv, isAddressValid, genSalt, encodeUnsigned, hash, encodeContractAddress,\n generateKeyPairFromSecret, generateKeyPair, sign, verify, messageToHash, signMessage,\n verifyMessage, isValidKeypair,\n} from './utils/crypto';\nexport { recover, dump } from './utils/keystore';\nexport type { Keystore } from './utils/keystore';\nexport { toBytes } from './utils/bytes';\nexport {\n buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx,\n} from './tx/builder';\nexport {\n buildContractId, oracleQueryId, produceNameId, commitmentHash, readInt, isNameValid, ensureName,\n getDefaultPointerKey, getMinimumNameFee, computeBidFee, computeAuctionEndBlock, isAuctionName,\n} from './tx/builder/helpers';\nexport {\n MAX_AUTH_FUN_GAS, NAME_TTL, NAME_MAX_TTL, NAME_MAX_CLIENT_TTL, CLIENT_TTL, MIN_GAS_PRICE,\n NAME_FEE_MULTIPLIER, NAME_FEE_BID_INCREMENT, NAME_BID_TIMEOUT_BLOCKS, NAME_MAX_LENGTH_FEE,\n NAME_BID_RANGES, ConsensusProtocolVersion, VmVersion, AbiVersion, Tag,\n} from './tx/builder/constants';\nexport type { Int, AensName } from './tx/builder/constants';\n// TODO: move to constants\nexport {\n ORACLE_TTL_TYPES, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL, DRY_RUN_ACCOUNT, CallReturnType,\n} from './tx/builder/schema';\nexport {\n getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode,\n} from './tx/execution-cost';\nexport { default as getTransactionSignerAddress } from './tx/transaction-signer';\nexport {\n AE_AMOUNT_FORMATS, formatAmount, toAe, toAettos, prefixedAmount,\n} from './utils/amount-formatter';\nexport {\n DerivationError, deriveChild, derivePathFromKey, getMasterKeyFromSeed, derivePathFromSeed,\n getKeyPair, generateSaveHDWalletFromSeed, getSaveHDWalletAccounts, getHdWalletAccountFromSeed,\n} from './utils/hd-wallet';\nexport {\n encode, decode, Encoding, Encoded,\n} from './utils/encoder';\nexport {\n encodeFateValue, decodeFateValue, hashTypedData, hashDomain, hashJson,\n} from './utils/typed-data';\nexport {\n aensRevoke, aensUpdate, aensTransfer, aensQuery, aensClaim, aensPreclaim, aensBid,\n} from './aens';\nexport { default as Contract } from './contract/Contract';\nexport type { ContractMethodsBase } from './contract/Contract';\nexport {\n pollForQueries, pollForQueryResponse, getQueryObject, postQueryToOracle, extendOracleTtl,\n respondToQuery, getOracleObject, registerOracle,\n} from './oracle';\nexport { spend, transferFunds, payForTransaction } from './spend';\nexport { createGeneralizedAccount, buildAuthTxHash, buildAuthTxHashByGaMetaTx } from './contract/ga';\n\nexport { default as AeSdkMethods } from './AeSdkMethods';\nexport { default as AeSdkBase } from './AeSdkBase';\nexport { default as AeSdk } from './AeSdk';\nexport { default as AeSdkAepp } from './AeSdkAepp';\nexport { default as AeSdkWallet } from './AeSdkWallet';\nexport { default as Node } from './Node';\nexport { default as verifyTransaction } from './tx/validator';\nexport { default as AccountBase } from './account/Base';\nexport { default as MemoryAccount } from './account/Memory';\nexport { default as AccountGeneralized } from './account/Generalized';\nexport { default as AccountLedger } from './account/Ledger';\nexport { default as AccountLedgerFactory } from './account/LedgerFactory';\nexport { default as CompilerBase } from './contract/compiler/Base';\nexport { default as CompilerHttp } from './contract/compiler/Http';\nexport { default as Channel } from './channel/Contract';\nexport {\n default as _MiddlewareSubscriber,\n MiddlewareSubscriberError as _MiddlewareSubscriberError,\n MiddlewareSubscriberDisconnected as _MiddlewareSubscriberDisconnected,\n} from './MiddlewareSubscriber';\nexport { default as _Middleware } from './Middleware';\n\nexport { default as connectionProxy } from './aepp-wallet-communication/connection-proxy';\nexport {\n MESSAGE_DIRECTION, WALLET_TYPE, SUBSCRIPTION_TYPES, METHODS, RPC_STATUS, RpcError,\n RpcInvalidTransactionError, RpcRejectedByUserError, RpcUnsupportedProtocolError,\n RpcConnectionDenyError, RpcNotAuthorizeError, RpcPermissionDenyError, RpcInternalError,\n RpcMethodNotFoundError,\n} from './aepp-wallet-communication/schema';\nexport { default as walletDetector } from './aepp-wallet-communication/wallet-detector';\nexport { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime';\nexport { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage';\nexport {\n BaseError, AccountError, AensError, AeppError, ChannelError, CompilerError, ContractError,\n CryptographyError, NodeError, TransactionError, WalletError, ArgumentError, IllegalArgumentError,\n ArgumentCountMismatchError, InsufficientBalanceError, MissingParamError, NoSerializerFoundError,\n RequestTimedOutError, TxTimedOutError, TypeError, UnsupportedPlatformError,\n UnsupportedProtocolError, NotImplementedError, UnsupportedVersionError, InternalError,\n UnexpectedTsError, UnavailableAccountError, AensPointerContextError, InsufficientNameFeeError,\n InvalidAensNameError, InvalidRpcMessageError, MissingCallbackError, UnAuthorizedAccountError,\n UnknownRpcClientError, UnsubscribedAccountError, ChannelCallError, ChannelConnectionError,\n ChannelPingTimedOutError, UnexpectedChannelMessageError, ChannelIncomingMessageError,\n UnknownChannelStateError, InvalidAuthDataError, BytecodeMismatchError, DuplicateContractError,\n InactiveContractError, InvalidMethodInvocationError, MissingContractAddressError,\n MissingContractDefError, MissingFunctionNameError, NodeInvocationError,\n NoSuchContractFunctionError, NotPayableFunctionError, MissingEventDefinitionError,\n AmbiguousEventDefinitionError, InvalidChecksumError, InvalidPasswordError,\n MerkleTreeHashMismatchError, MissingNodeInTreeError, UnknownNodeLengthError,\n UnknownPathNibbleError, DuplicateNodeError, NodeNotFoundError, DecodeError, PayloadLengthError,\n DryRunError, IllegalBidFeeError, InvalidSignatureError, PrefixNotFoundError, SchemaNotFoundError,\n TagNotFoundError, TxNotInChainError, AlreadyConnectedError, NoWalletConnectedError,\n RpcConnectionError,\n} from './utils/errors';\nexport { RpcBroadcastError, NAME_BID_MAX_LENGTH } from './deprecated';\n"],"mappings":"SACEA,gBAAgB,EAAEC,cAAc,EAAEC,SAAS,EAAEC,IAAI,EAAEC,WAAW,EAAEC,gBAAgB,EAAEC,eAAe,EACjGC,UAAU,EAAEC,UAAU,EAAEC,oBAAoB,EAAEC,aAAa,EAAEC,yBAAyB,EACtFC,WAAW,EAAEC,mBAAmB,EAAEC,QAAQ,EAAEC,mBAAmB,EAAEC,WAAW,EAAEC,OAAO,EACrFC,WAAW;AAAA,SAGXC,kBAAkB,EAAEC,cAAc,EAAEC,OAAO,EAAEC,cAAc,EAAEC,IAAI,EAAEC,qBAAqB,EACxFC,yBAAyB,EAAEC,eAAe,EAAEC,IAAI,EAAEC,MAAM,EAAEC,aAAa,EAAEC,WAAW,EACpFC,aAAa,EAAEC,cAAc;AAAA,SAEtBC,OAAO,EAAEC,IAAI;AAAA,SAEbC,OAAO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TTL","RESPONSE_TTL","Tag","RequestTimedOutError","decode","encode","Encoding","_getPollInterval","getHeight","sendTransaction","pollForQueries","oracleId","onQuery","_ref","_interval","interval","onNode","options","knownQueryIds","Set","checkNewQueries","_await$onNode$getOrac","queries","getOracleQueriesByPubkey","oracleQueries","filter","_ref2","id","has","forEach","query","add","stopped","catch","console","error","pollForQueryResponse","queryId","_ref3","_interval2","height","ttl","response","getOracleQueryByPubkeyAndQueryId","responseBuffer","length","toString","getQueryObject","record","decodedQuery","decodedResponse","respond","opt","respondToQuery","pollForResponse","postQueryToOracle","_options$queryFee","queryFee","getOracleByPubkey","senderId","onAccount","address","oracleQueryTx","queryTtlType","type","queryTtlValue","value","responseTtlType","responseTtlValue","tag","OracleQueryTx","nonce","extendOracleTtl","OracleAddress","oracleExtendTx","oracleTtlType","oracleTtlValue","OracleExtendTx","getOracleObject","oracleRespondTx","OracleResponseTx","pollQueries","postQuery","extendOracle","getQuery","_ref4","name","handler","_len","arguments","args","Array","_key","lastArg","constructor","Object","assign","push","includes","registerOracle","queryFormat","responseFormat","accountId","oracleRegisterTx","OracleRegisterTx"],"sources":["../src/oracle.ts"],"sourcesContent":["/**\n * Oracle methods - routines to interact with the æternity oracle system\n *\n * The high-level description of the oracle system is\n * https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol\n * repository.\n */\n\nimport { mapObject, pause } from './utils/other';\nimport { oracleQueryId } from './tx/builder/helpers';\nimport { unpackTx, buildTxAsync, BuildTxOptions } from './tx/builder';\nimport {\n ORACLE_TTL,\n ORACLE_TTL_TYPES,\n QUERY_TTL,\n RESPONSE_TTL,\n} from './tx/builder/schema';\nimport { Tag } from './tx/builder/constants';\nimport { RequestTimedOutError } from './utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from './utils/encoder';\nimport {\n _getPollInterval, getHeight, sendTransaction, SendTransactionOptions,\n} from './chain';\nimport Node from './Node';\nimport AccountBase from './account/Base';\n\ntype OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries'];\n\n/**\n * Poll for oracle queries\n * @category oracle\n * @param oracleId - Oracle public key\n * @param onQuery - OnQuery callback\n * @param options - Options object\n * @param options.interval - Poll interval(default: 5000)\n * @param options.onNode - Node to use\n * @returns Callback to stop polling function\n */\nexport function pollForQueries(\n oracleId: Encoded.OracleAddress,\n onQuery: (query: OracleQueries[number]) => void,\n { interval, onNode, ...options }: { interval?: number; onNode: Node }\n & Parameters<typeof _getPollInterval>[1],\n): () => void {\n interval ??= _getPollInterval('microblock', options);\n const knownQueryIds = new Set();\n const checkNewQueries = async (): Promise<void> => {\n const queries = ((await onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries ?? [])\n .filter(({ id }) => !knownQueryIds.has(id));\n queries.forEach((query) => {\n knownQueryIds.add(query.id);\n onQuery(query);\n });\n };\n\n let stopped = false;\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (async () => {\n while (!stopped) { // eslint-disable-line no-unmodified-loop-condition\n // TODO: allow to handle this error somehow\n await checkNewQueries().catch(console.error);\n await pause(interval);\n }\n })();\n return () => { stopped = true; };\n}\n\n/**\n * Poll for oracle query response\n * @category oracle\n * @param oracleId - Oracle public key\n * @param queryId - Oracle Query id\n * @param options - Options object\n * @param options.interval - Poll interval\n * @param options.onNode - Node to use\n * @returns OracleQuery object\n */\nexport async function pollForQueryResponse(\n oracleId: Encoded.OracleAddress,\n queryId: Encoded.OracleQueryId,\n { interval, onNode, ...options }:\n { interval?: number; onNode: Node } & Parameters<typeof _getPollInterval>[1],\n): Promise<string> {\n interval ??= _getPollInterval('microblock', options);\n let height;\n let ttl;\n let response;\n do {\n ({ response, ttl } = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));\n const responseBuffer = decode(response as Encoded.OracleResponse);\n if (responseBuffer.length > 0) return responseBuffer.toString();\n await pause(interval);\n height = await getHeight({ onNode });\n } while (ttl >= height);\n throw new RequestTimedOutError(height);\n}\n\n/**\n * Constructor for OracleQuery Object (helper object for using OracleQuery)\n * @category oracle\n * @param oracleId - Oracle public key\n * @param queryId - Oracle Query id\n * @param options - Options\n * @returns OracleQuery object\n */\nexport async function getQueryObject(\n oracleId: Encoded.OracleAddress,\n queryId: Encoded.OracleQueryId,\n options: RespondToQueryOptions & Parameters<typeof pollForQueryResponse>[2],\n): Promise<GetQueryObjectReturnType> {\n const record = await options.onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId);\n return {\n ...record,\n decodedQuery: decode(record.query as Encoded.OracleQueryId).toString(),\n decodedResponse: decode(record.response as Encoded.OracleResponse).toString(),\n respond: async (response, opt) => (\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n respondToQuery(queryId, response, { ...options, ...opt })\n ),\n pollForResponse: async (opt) => pollForQueryResponse(oracleId, queryId, { ...options, ...opt }),\n };\n}\n\ninterface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {\n decodedQuery: string;\n decodedResponse: string;\n respond: (response: string, options?: Parameters<typeof respondToQuery>[2]) =>\n ReturnType<typeof respondToQuery>;\n pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) =>\n ReturnType<typeof pollForQueryResponse>;\n}\n\n/**\n * Post query to oracle\n * @category oracle\n * @param oracleId - Oracle public key\n * @param query - Oracle query object\n * @param options - Options object\n * @param options.queryTtl - queryTtl Oracle query time to leave\n * @param options.responseTtl - queryFee Oracle query response time to leave\n * @param options.queryFee - queryFee Oracle query fee\n * @param options.fee - fee Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Query object\n */\nexport async function postQueryToOracle(\n oracleId: Encoded.OracleAddress,\n query: string,\n options: PostQueryToOracleOptions,\n): Promise<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getQueryObject>>\n > {\n options.queryFee ??= (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();\n const senderId = options.onAccount.address;\n\n const oracleQueryTx = await buildTxAsync({\n queryTtlType: QUERY_TTL.type,\n queryTtlValue: QUERY_TTL.value,\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n tag: Tag.OracleQueryTx,\n oracleId,\n senderId,\n query,\n });\n const { nonce } = unpackTx(oracleQueryTx, Tag.OracleQueryTx);\n const queryId = oracleQueryId(senderId, nonce, oracleId);\n return {\n ...await sendTransaction(oracleQueryTx, options),\n ...await getQueryObject(oracleId, queryId, options),\n };\n}\n\ntype PostQueryToOracleOptionsType = Parameters<typeof sendTransaction>[1]\n& Parameters<typeof getQueryObject>[2]\n& BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'>\n& {\n queryTtlType?: ORACLE_TTL_TYPES;\n queryTtlValue?: number;\n responseTtlType?: ORACLE_TTL_TYPES;\n responseTtlValue?: number;\n};\ninterface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {}\n\n/**\n * Extend oracle ttl\n * @category oracle\n * @param options - Options object\n * @param options.fee - fee Transaction fee\n * @param options.ttl - Transaction time to leave\n * @param options.oracleTtlType - Oracle time to leave for extend\n * @param options.oracleTtlValue - Oracle time to leave for extend\n * @returns Oracle object\n */\nexport async function extendOracleTtl(options: ExtendOracleTtlOptions): Promise<\nAwaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n> {\n const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);\n const oracleExtendTx = await buildTxAsync({\n oracleTtlType: ORACLE_TTL.type,\n oracleTtlValue: ORACLE_TTL.value,\n ...options,\n tag: Tag.OracleExtendTx,\n oracleId,\n });\n return {\n ...await sendTransaction(oracleExtendTx, options),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ...await getOracleObject(oracleId, options),\n };\n}\n\ntype ExtendOracleTtlOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleExtendTx, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'>\n& { oracleTtlType?: ORACLE_TTL_TYPES; oracleTtlValue?: number };\ninterface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {}\n\n/**\n * Extend oracle ttl\n * @category oracle\n * @param queryId - Oracle query id\n * @param response - Oracle query response\n * @param options - Options object\n * @param options.responseTtl - responseTtl Query response time to leave\n * @param options.fee - Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Oracle object\n */\nexport async function respondToQuery(\n queryId: Encoded.OracleQueryId,\n response: string,\n options: RespondToQueryOptions,\n): Promise<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n > {\n const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);\n const oracleRespondTx = await buildTxAsync({\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n tag: Tag.OracleResponseTx,\n oracleId,\n queryId,\n response,\n });\n return {\n ...await sendTransaction(oracleRespondTx, options),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ...await getOracleObject(oracleId, options),\n };\n}\n\ntype RespondToQueryOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'>\n& { responseTtlType?: ORACLE_TTL_TYPES; responseTtlValue?: number };\ninterface RespondToQueryOptions extends RespondToQueryOptionsType {}\n\n/**\n * Constructor for Oracle Object (helper object for using Oracle)\n * @category oracle\n * @param oracleId - Oracle public key\n * @param options - Options\n * @returns Oracle object\n */\nexport async function getOracleObject(\n oracleId: Encoded.OracleAddress,\n options: { onNode: Node; onAccount: AccountBase },\n): Promise<GetOracleObjectReturnType> {\n return {\n ...await options.onNode.getOracleByPubkey(oracleId),\n queries: (await options.onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries,\n ...mapObject<Function, Function>(\n {\n pollQueries: pollForQueries,\n postQuery: postQueryToOracle,\n respondToQuery,\n extendOracle: extendOracleTtl,\n getQuery: getQueryObject,\n },\n ([name, handler]) => [\n name,\n (...args: any) => {\n const lastArg = args[args.length - 1];\n if (lastArg != null && typeof lastArg === 'object' && lastArg.constructor === Object) {\n Object.assign(lastArg, { ...options, ...lastArg });\n } else args.push(options);\n return handler(\n ...['extendOracle', 'respondToQuery'].includes(name) ? [] : [oracleId],\n ...args,\n );\n },\n ],\n ),\n } as any;\n}\n\ninterface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleByPubkey']>> {\n id: Encoded.OracleAddress;\n queries: OracleQueries;\n // TODO: replace getOracleObject with a class\n pollQueries: (cb: Parameters<typeof pollForQueries>[1]) => ReturnType<typeof pollForQueries>;\n postQuery: Function;\n respondToQuery: Function;\n extendOracle: Function;\n getQuery: Function;\n}\n\n/**\n * Register oracle\n * @category oracle\n * @param queryFormat - Format of query\n * @param responseFormat - Format of query response\n * @param options - Options\n * @param options.queryFee - Oracle query Fee\n * @param options - Options object\n * @param options.abiVersion - Always 0 (do not use virtual machine)\n * @param options.fee - Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Oracle object\n */\nexport async function registerOracle(\n queryFormat: string,\n responseFormat: string,\n options: RegisterOracleOptions,\n): Promise<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n > {\n const accountId = options.onAccount.address;\n const oracleRegisterTx = await buildTxAsync({\n oracleTtlValue: ORACLE_TTL.value,\n oracleTtlType: ORACLE_TTL.type,\n ...options,\n tag: Tag.OracleRegisterTx,\n accountId,\n queryFormat,\n responseFormat,\n });\n return {\n ...await sendTransaction(oracleRegisterTx, options),\n ...await getOracleObject(encode(decode(accountId), Encoding.OracleAddress), options),\n };\n}\n\ntype RegisterOracleOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'oracleTtlType' | 'oracleTtlValue'>\n& {\n oracleTtlType?: ORACLE_TTL_TYPES;\n oracleTtlValue?: number;\n};\ninterface RegisterOracleOptions extends RegisterOracleOptionsType {}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SAQSA,SAAS,EAAEC,KAAK;AAAA,SAChBC,aAAa;AAAA,SACbC,QAAQ,EAAEC,YAAY;AAAA,SAE7BC,UAAU,EAEVC,SAAS,EACTC,YAAY;AAAA,SAELC,GAAG;AAAA,SACHC,oBAAoB;AAAA,SAE3BC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAGjCC,gBAAgB,EAAEC,SAAS,EAAEC,eAAe;AAO9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,QAA+B,EAC/BC,OAA+C,EAAAC,IAAA,EAGnC;EAAA,IAAAC,SAAA;EAAA,IAFZ;IAAEC,QAAQ;IAAEC,MAAM;IAAE,GAAGC;EACgB,CAAC,GAAAJ,IAAA;EAExC,CAAAC,SAAA,GAAAC,QAAQ,cAAAD,SAAA,cAAAA,SAAA,GAARC,QAAQ,GAAKR,gBAAgB,CAAC,YAAY,EAAEU,OAAO,CAAC;EACpD,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAAE;EAC/B,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAA2B;IAAA,IAAAC,qBAAA;IACjD,MAAMC,OAAO,GAAG,EAAAD,qBAAA,GAAC,CAAC,MAAML,MAAM,CAACO,wBAAwB,CAACZ,QAAQ,CAAC,EAAEa,aAAa,cAAAH,qBAAA,cAAAA,qBAAA,GAAI,EAAE,EACnFI,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEC;MAAG,CAAC,GAAAD,KAAA;MAAA,OAAK,CAACR,aAAa,CAACU,GAAG,CAACD,EAAE,CAAC;IAAA,EAAC;IAC7CL,OAAO,CAACO,OAAO,CAAEC,KAAK,IAAK;MACzBZ,aAAa,CAAC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AgB,EAAEtF,OAAO,CAAC;IACnD,IAAG,MAAM6D,eAAe,CAACzE,MAAM,CAACD,MAAM,CAACkG,SAAS,CAAC,EAAEhG,QAAQ,CAACmE,aAAa,CAAC,EAAExD,OAAO,CAAC;EACtF,CAAC;AACH"}
1
+ {"version":3,"file":"oracle.mjs","names":["mapObject","pause","oracleQueryId","unpackTx","buildTxAsync","ORACLE_TTL","QUERY_TTL","RESPONSE_TTL","Tag","RequestTimedOutError","decode","encode","Encoding","_getPollInterval","getHeight","sendTransaction","pollForQueries","oracleId","onQuery","_ref","_interval","interval","onNode","options","knownQueryIds","Set","checkNewQueries","_await$onNode$getOrac","queries","getOracleQueriesByPubkey","oracleQueries","filter","_ref2","id","has","forEach","query","add","stopped","catch","console","error","pollForQueryResponse","queryId","_ref3","_interval2","height","ttl","response","getOracleQueryByPubkeyAndQueryId","responseBuffer","length","toString","getQueryObject","record","decodedQuery","decodedResponse","respond","opt","respondToQuery","pollForResponse","postQueryToOracle","_options$queryFee","queryFee","getOracleByPubkey","senderId","onAccount","address","oracleQueryTx","queryTtlType","type","queryTtlValue","value","responseTtlType","responseTtlValue","tag","OracleQueryTx","nonce","extendOracleTtl","OracleAddress","oracleExtendTx","oracleTtlType","oracleTtlValue","OracleExtendTx","getOracleObject","oracleRespondTx","OracleResponseTx","pollQueries","postQuery","extendOracle","getQuery","_ref4","name","handler","_len","arguments","args","Array","_key","lastArg","constructor","Object","assign","push","includes","registerOracle","queryFormat","responseFormat","accountId","oracleRegisterTx","OracleRegisterTx"],"sources":["../src/oracle.ts"],"sourcesContent":["/**\n * Oracle methods - routines to interact with the æternity oracle system\n *\n * The high-level description of the oracle system is\n * https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol\n * repository.\n */\n\nimport { mapObject, pause } from './utils/other';\nimport { oracleQueryId } from './tx/builder/helpers';\nimport { unpackTx, buildTxAsync, BuildTxOptions } from './tx/builder';\nimport {\n ORACLE_TTL,\n ORACLE_TTL_TYPES,\n QUERY_TTL,\n RESPONSE_TTL,\n} from './tx/builder/schema';\nimport { Tag } from './tx/builder/constants';\nimport { RequestTimedOutError } from './utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from './utils/encoder';\nimport {\n _getPollInterval, getHeight, sendTransaction, SendTransactionOptions,\n} from './chain';\nimport Node from './Node';\nimport AccountBase from './account/Base';\n\ntype OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries'];\n\n/**\n * Poll for oracle queries\n * @category oracle\n * @param oracleId - Oracle public key\n * @param onQuery - OnQuery callback\n * @param options - Options object\n * @param options.interval - Poll interval(default: 5000)\n * @param options.onNode - Node to use\n * @returns Callback to stop polling function\n */\nexport function pollForQueries(\n oracleId: Encoded.OracleAddress,\n onQuery: (query: OracleQueries[number]) => void,\n { interval, onNode, ...options }: { interval?: number; onNode: Node }\n & Parameters<typeof _getPollInterval>[1],\n): () => void {\n interval ??= _getPollInterval('microblock', options);\n const knownQueryIds = new Set();\n const checkNewQueries = async (): Promise<void> => {\n const queries = ((await onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries ?? [])\n .filter(({ id }) => !knownQueryIds.has(id));\n queries.forEach((query) => {\n knownQueryIds.add(query.id);\n onQuery(query);\n });\n };\n\n let stopped = false;\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (async () => {\n while (!stopped) { // eslint-disable-line no-unmodified-loop-condition\n // TODO: allow to handle this error somehow\n await checkNewQueries().catch(console.error);\n await pause(interval);\n }\n })();\n return () => { stopped = true; };\n}\n\n/**\n * Poll for oracle query response\n * @category oracle\n * @param oracleId - Oracle public key\n * @param queryId - Oracle Query id\n * @param options - Options object\n * @param options.interval - Poll interval\n * @param options.onNode - Node to use\n * @returns OracleQuery object\n */\nexport async function pollForQueryResponse(\n oracleId: Encoded.OracleAddress,\n queryId: Encoded.OracleQueryId,\n { interval, onNode, ...options }:\n { interval?: number; onNode: Node } & Parameters<typeof _getPollInterval>[1],\n): Promise<string> {\n interval ??= _getPollInterval('microblock', options);\n let height;\n let ttl;\n let response;\n do {\n ({ response, ttl } = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId));\n const responseBuffer = decode(response as Encoded.OracleResponse);\n if (responseBuffer.length > 0) return responseBuffer.toString();\n await pause(interval);\n height = await getHeight({ onNode });\n } while (ttl >= height);\n throw new RequestTimedOutError(height);\n}\n\n/**\n * Constructor for OracleQuery Object (helper object for using OracleQuery)\n * @category oracle\n * @param oracleId - Oracle public key\n * @param queryId - Oracle Query id\n * @param options - Options\n * @returns OracleQuery object\n */\nexport async function getQueryObject(\n oracleId: Encoded.OracleAddress,\n queryId: Encoded.OracleQueryId,\n options: RespondToQueryOptions & Parameters<typeof pollForQueryResponse>[2],\n): Promise<GetQueryObjectReturnType> {\n const record = await options.onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId);\n return {\n ...record,\n decodedQuery: decode(record.query as Encoded.OracleQueryId).toString(),\n decodedResponse: decode(record.response as Encoded.OracleResponse).toString(),\n respond: async (response, opt) => (\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n respondToQuery(queryId, response, { ...options, ...opt })\n ),\n pollForResponse: async (opt) => pollForQueryResponse(oracleId, queryId, { ...options, ...opt }),\n };\n}\n\ninterface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {\n decodedQuery: string;\n decodedResponse: string;\n respond: (response: string, options?: Parameters<typeof respondToQuery>[2]) =>\n ReturnType<typeof respondToQuery>;\n pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) =>\n ReturnType<typeof pollForQueryResponse>;\n}\n\n/**\n * Post query to oracle\n * @category oracle\n * @param oracleId - Oracle public key\n * @param query - Oracle query object\n * @param options - Options object\n * @param options.queryTtl - queryTtl Oracle query time to leave\n * @param options.responseTtl - queryFee Oracle query response time to leave\n * @param options.queryFee - queryFee Oracle query fee\n * @param options.fee - fee Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Query object\n */\nexport async function postQueryToOracle(\n oracleId: Encoded.OracleAddress,\n query: string,\n options: PostQueryToOracleOptions,\n): Promise<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getQueryObject>>\n > {\n options.queryFee ??= (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();\n const senderId = options.onAccount.address;\n\n const oracleQueryTx = await buildTxAsync({\n queryTtlType: QUERY_TTL.type,\n queryTtlValue: QUERY_TTL.value,\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n tag: Tag.OracleQueryTx,\n oracleId,\n senderId,\n query,\n });\n const { nonce } = unpackTx(oracleQueryTx, Tag.OracleQueryTx);\n const queryId = oracleQueryId(senderId, nonce, oracleId);\n return {\n ...await sendTransaction(oracleQueryTx, options),\n ...await getQueryObject(oracleId, queryId, options),\n };\n}\n\ntype PostQueryToOracleOptionsType = Parameters<typeof sendTransaction>[1]\n& Parameters<typeof getQueryObject>[2]\n& BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'>\n& {\n queryTtlType?: ORACLE_TTL_TYPES;\n queryTtlValue?: number;\n responseTtlType?: ORACLE_TTL_TYPES;\n responseTtlValue?: number;\n};\ninterface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {}\n\n/**\n * Extend oracle ttl\n * @category oracle\n * @param options - Options object\n * @param options.fee - fee Transaction fee\n * @param options.ttl - Transaction time to leave\n * @param options.oracleTtlType - Oracle time to leave for extend\n * @param options.oracleTtlValue - Oracle time to leave for extend\n * @returns Oracle object\n */\nexport async function extendOracleTtl(options: ExtendOracleTtlOptions): Promise<\nAwaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n> {\n const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);\n const oracleExtendTx = await buildTxAsync({\n oracleTtlType: ORACLE_TTL.type,\n oracleTtlValue: ORACLE_TTL.value,\n ...options,\n tag: Tag.OracleExtendTx,\n oracleId,\n });\n return {\n ...await sendTransaction(oracleExtendTx, options),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ...await getOracleObject(oracleId, options),\n };\n}\n\ntype ExtendOracleTtlOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleExtendTx, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'>\n& { oracleTtlType?: ORACLE_TTL_TYPES; oracleTtlValue?: number };\ninterface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {}\n\n/**\n * Extend oracle ttl\n * @category oracle\n * @param queryId - Oracle query id\n * @param response - Oracle query response\n * @param options - Options object\n * @param options.responseTtl - responseTtl Query response time to leave\n * @param options.fee - Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Oracle object\n */\nexport async function respondToQuery(\n queryId: Encoded.OracleQueryId,\n response: string,\n options: RespondToQueryOptions,\n): Promise<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n > {\n const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);\n const oracleRespondTx = await buildTxAsync({\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n tag: Tag.OracleResponseTx,\n oracleId,\n queryId,\n response,\n });\n return {\n ...await sendTransaction(oracleRespondTx, options),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n ...await getOracleObject(oracleId, options),\n };\n}\n\ntype RespondToQueryOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'>\n& { responseTtlType?: ORACLE_TTL_TYPES; responseTtlValue?: number };\ninterface RespondToQueryOptions extends RespondToQueryOptionsType {}\n\n/**\n * Constructor for Oracle Object (helper object for using Oracle)\n * @category oracle\n * @param oracleId - Oracle public key\n * @param options - Options\n * @returns Oracle object\n */\nexport async function getOracleObject(\n oracleId: Encoded.OracleAddress,\n options: { onNode: Node; onAccount: AccountBase },\n): Promise<GetOracleObjectReturnType> {\n return {\n ...await options.onNode.getOracleByPubkey(oracleId),\n queries: (await options.onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries,\n ...mapObject<Function, Function>(\n {\n pollQueries: pollForQueries,\n postQuery: postQueryToOracle,\n respondToQuery,\n extendOracle: extendOracleTtl,\n getQuery: getQueryObject,\n },\n ([name, handler]) => [\n name,\n (...args: any) => {\n const lastArg = args[args.length - 1];\n if (lastArg != null && typeof lastArg === 'object' && lastArg.constructor === Object) {\n Object.assign(lastArg, { ...options, ...lastArg });\n } else args.push(options);\n return handler(\n ...['extendOracle', 'respondToQuery'].includes(name) ? [] : [oracleId],\n ...args,\n );\n },\n ],\n ),\n } as any;\n}\n\ninterface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleByPubkey']>> {\n id: Encoded.OracleAddress;\n queries: OracleQueries;\n // TODO: replace getOracleObject with a class\n pollQueries: (cb: Parameters<typeof pollForQueries>[1]) => ReturnType<typeof pollForQueries>;\n postQuery: Function;\n respondToQuery: Function;\n extendOracle: Function;\n getQuery: Function;\n}\n\n/**\n * Register oracle\n * @category oracle\n * @param queryFormat - Format of query\n * @param responseFormat - Format of query response\n * @param options - Options\n * @param options.queryFee - Oracle query Fee\n * @param options - Options object\n * @param options.abiVersion - Always 0 (do not use virtual machine)\n * @param options.fee - Transaction fee\n * @param options.ttl - Transaction time to leave\n * @returns Oracle object\n */\nexport async function registerOracle(\n queryFormat: string,\n responseFormat: string,\n options: RegisterOracleOptions,\n): Promise<\n Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>\n > {\n const accountId = options.onAccount.address;\n const oracleRegisterTx = await buildTxAsync({\n oracleTtlValue: ORACLE_TTL.value,\n oracleTtlType: ORACLE_TTL.type,\n ...options,\n tag: Tag.OracleRegisterTx,\n accountId,\n queryFormat,\n responseFormat,\n });\n return {\n ...await sendTransaction(oracleRegisterTx, options),\n ...await getOracleObject(encode(decode(accountId), Encoding.OracleAddress), options),\n };\n}\n\ntype RegisterOracleOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'oracleTtlType' | 'oracleTtlValue'>\n& {\n oracleTtlType?: ORACLE_TTL_TYPES;\n oracleTtlValue?: number;\n};\ninterface RegisterOracleOptions extends RegisterOracleOptionsType {}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SAQSA,SAAS,EAAEC,KAAK;AAAA,SAChBC,aAAa;AAAA,SACbC,QAAQ,EAAEC,YAAY;AAAA,SAE7BC,UAAU,EAEVC,SAAS,EACTC,YAAY;AAAA,SAELC,GAAG;AAAA,SACHC,oBAAoB;AAAA,SAE3BC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAGjCC,gBAAgB,EAAEC,SAAS,EAAEC,eAAe;AAO9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,QAA+B,EAC/BC,OAA+C,EAAAC,IAAA,EAGnC;EAAA,IAAAC,SAAA;EAAA,IAFZ;IAAEC,QAAQ;IAAEC,MAAM;IAAE,GAAGC;EACgB,CAAC,GAAAJ,IAAA;EAExC,CAAAC,SAAA,GAAAC,QAAQ,cAAAD,SAAA,cAAAA,SAAA,GAARC,QAAQ,GAAKR,gBAAgB,CAAC,YAAY,EAAEU,OAAO,CAAC;EACpD,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC/B,MAAMC,eAAe,GAAG,MAAAA,CAAA,KAA2B;IAAA,IAAAC,qBAAA;IACjD,MAAMC,OAAO,GAAG,EAAAD,qBAAA,GAAC,CAAC,MAAML,MAAM,CAACO,wBAAwB,CAACZ,QAAQ,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;EAC3C,MAAM0C,gBAAgB,GAAG,MAAMzG,YAAY,CAAC;IAC1C8E,cAAc,EAAE7E,UAAU,CAACmE,KAAK;IAChCS,aAAa,EAAE5E,UAAU,CAACiE,IAAI;IAC9B,GAAG/C,OAAO;IACVoD,GAAG,EAAEnE,GAAG,CAACsG,gBAAgB;IACzBF,SAAS;IACTF,WAAW;IACXC;EACF,CAAC,CAAC;EACF,OAAO;IACL,IAAG,MAAM5F,eAAe,CAAC8F,gBAAgB,EAAEtF,OAAO,CAAC;IACnD,IAAG,MAAM6D,eAAe,CAACzE,MAAM,CAACD,MAAM,CAACkG,SAAS,CAAC,EAAEhG,QAAQ,CAACmE,aAAa,CAAC,EAAExD,OAAO,CAAC;EACtF,CAAC;AACH"}
package/es/spend.d.ts CHANGED
@@ -34,7 +34,8 @@ interface SpendOptions extends SpendOptionsType {
34
34
  * console.log('Transaction mined at', blockHeight);
35
35
  * ```
36
36
  */
37
- export declare function transferFunds(fraction: number | string, recipientIdOrName: AensName | Encoded.AccountAddress, options: TransferFundsOptions): ReturnType<typeof sendTransaction>;
37
+ export declare function transferFunds(fraction: number | string, // TODO: accept only number
38
+ recipientIdOrName: AensName | Encoded.AccountAddress, options: TransferFundsOptions): ReturnType<typeof sendTransaction>;
38
39
  type TransferFundsOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'> & Parameters<typeof resolveName>[2] & {
39
40
  onAccount: AccountBase;
40
41
  } & SendTransactionOptions;