@aeternity/aepp-sdk 11.0.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/LICENSE +1 -1
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +12 -19
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +1 -1
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +1 -1
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdk.d.ts +37 -0
  10. package/es/AeSdk.mjs +81 -0
  11. package/es/AeSdk.mjs.map +1 -0
  12. package/es/AeSdkAepp.d.ts +69 -0
  13. package/es/AeSdkAepp.mjs +175 -0
  14. package/es/AeSdkAepp.mjs.map +1 -0
  15. package/es/AeSdkBase.d.ts +212 -0
  16. package/es/AeSdkBase.mjs +310 -0
  17. package/es/AeSdkBase.mjs.map +1 -0
  18. package/es/AeSdkWallet.d.ts +103 -0
  19. package/es/AeSdkWallet.mjs +322 -0
  20. package/es/AeSdkWallet.mjs.map +1 -0
  21. package/es/Node.d.ts +44 -0
  22. package/es/Node.mjs +141 -0
  23. package/es/Node.mjs.map +1 -0
  24. package/es/account/Base.d.ts +65 -0
  25. package/es/account/Base.mjs +123 -0
  26. package/es/account/Base.mjs.map +1 -0
  27. package/es/account/Memory.d.ts +25 -0
  28. package/es/account/Memory.mjs +81 -0
  29. package/es/account/Memory.mjs.map +1 -0
  30. package/es/account/Rpc.d.ts +27 -0
  31. package/es/account/Rpc.mjs +79 -0
  32. package/es/account/Rpc.mjs.map +1 -0
  33. package/es/aens.d.ts +209 -0
  34. package/es/aens.mjs +332 -0
  35. package/es/aens.mjs.map +1 -0
  36. package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
  37. package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  45. package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
  46. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
  47. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  48. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  51. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  52. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  54. package/es/aepp-wallet-communication/schema.d.ts +90 -46
  55. package/es/aepp-wallet-communication/schema.mjs +214 -0
  56. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  57. package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
  58. package/es/aepp-wallet-communication/wallet-detector.mjs +63 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  60. package/es/apis/compiler/compiler.d.ts +92 -0
  61. package/es/apis/compiler/compiler.mjs +576 -0
  62. package/es/apis/compiler/compiler.mjs.map +1 -0
  63. package/es/apis/compiler/index.d.ts +2 -0
  64. package/es/apis/compiler/index.mjs +3 -0
  65. package/es/apis/compiler/index.mjs.map +1 -0
  66. package/es/apis/compiler/models/index.d.ts +248 -0
  67. package/es/apis/compiler/models/index.mjs +48 -0
  68. package/es/apis/compiler/models/index.mjs.map +1 -0
  69. package/es/apis/compiler/models/mappers.d.ts +23 -0
  70. package/es/apis/compiler/models/mappers.mjs +585 -0
  71. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  72. package/es/apis/compiler/models/parameters.d.ts +13 -0
  73. package/es/apis/compiler/models/parameters.mjs +71 -0
  74. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  75. package/es/apis/node/index.d.ts +2 -0
  76. package/es/apis/node/index.mjs +3 -0
  77. package/es/apis/node/index.mjs.map +1 -0
  78. package/es/apis/node/models/index.d.ts +1061 -0
  79. package/es/apis/node/models/index.mjs +2 -0
  80. package/es/apis/node/models/index.mjs.map +1 -0
  81. package/es/apis/node/models/mappers.d.ts +95 -0
  82. package/es/apis/node/models/mappers.mjs +4164 -0
  83. package/es/apis/node/models/mappers.mjs.map +1 -0
  84. package/es/apis/node/models/parameters.d.ts +17 -0
  85. package/es/apis/node/models/parameters.mjs +165 -0
  86. package/es/apis/node/models/parameters.mjs.map +1 -0
  87. package/es/apis/node/node.d.ts +215 -0
  88. package/es/apis/node/node.mjs +1165 -0
  89. package/es/apis/node/node.mjs.map +1 -0
  90. package/es/chain.d.ts +220 -0
  91. package/es/chain.mjs +524 -0
  92. package/es/chain.mjs.map +1 -0
  93. package/es/channel/handlers.d.ts +34 -0
  94. package/es/channel/handlers.mjs +147 -112
  95. package/es/channel/handlers.mjs.map +1 -1
  96. package/es/channel/index.d.ts +634 -0
  97. package/es/channel/index.mjs +898 -900
  98. package/es/channel/index.mjs.map +1 -1
  99. package/es/channel/internal.d.ts +100 -0
  100. package/es/channel/internal.mjs +97 -51
  101. package/es/channel/internal.mjs.map +1 -1
  102. package/es/contract/Compiler.d.ts +17 -0
  103. package/es/contract/Compiler.mjs +67 -0
  104. package/es/contract/Compiler.mjs.map +1 -0
  105. package/es/contract/aci.d.ts +125 -0
  106. package/es/contract/aci.mjs +199 -180
  107. package/es/contract/aci.mjs.map +1 -1
  108. package/es/contract/ga.d.ts +68 -0
  109. package/es/contract/ga.mjs +190 -0
  110. package/es/contract/ga.mjs.map +1 -0
  111. package/es/contract/methods.d.ts +68 -0
  112. package/es/contract/methods.mjs +101 -0
  113. package/es/contract/methods.mjs.map +1 -0
  114. package/es/index.d.ts +32 -0
  115. package/es/index.mjs +32 -40
  116. package/es/index.mjs.map +1 -1
  117. package/es/oracle.d.ts +154 -0
  118. package/es/oracle.mjs +288 -0
  119. package/es/oracle.mjs.map +1 -0
  120. package/es/spend.d.ts +61 -0
  121. package/es/spend.mjs +122 -0
  122. package/es/spend.mjs.map +1 -0
  123. package/es/tx/builder/constants.d.ts +41 -0
  124. package/es/tx/builder/constants.mjs +11 -19
  125. package/es/tx/builder/constants.mjs.map +1 -1
  126. package/es/tx/builder/field-types.d.ts +62 -0
  127. package/es/tx/builder/field-types.mjs +62 -10
  128. package/es/tx/builder/field-types.mjs.map +1 -1
  129. package/es/tx/builder/helpers.d.ts +131 -0
  130. package/es/tx/builder/helpers.mjs +71 -169
  131. package/es/tx/builder/helpers.mjs.map +1 -1
  132. package/es/tx/builder/index.d.ts +75 -0
  133. package/es/tx/builder/index.mjs +141 -323
  134. package/es/tx/builder/index.mjs.map +1 -1
  135. package/es/tx/builder/schema.d.ts +350 -0
  136. package/es/tx/builder/schema.mjs +173 -510
  137. package/es/tx/builder/schema.mjs.map +1 -1
  138. package/es/tx/index.d.ts +63 -0
  139. package/es/tx/index.mjs +171 -265
  140. package/es/tx/index.mjs.map +1 -1
  141. package/es/tx/min-fee.d.ts +20 -0
  142. package/es/tx/min-fee.mjs +148 -0
  143. package/es/tx/min-fee.mjs.map +1 -0
  144. package/es/tx/validator.d.ts +19 -0
  145. package/es/tx/validator.mjs +64 -71
  146. package/es/tx/validator.mjs.map +1 -1
  147. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  148. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  149. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  150. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  151. package/es/typings/bip32-path/index.d.mjs +2 -0
  152. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  153. package/es/typings/blakejs/index.d.mjs.map +1 -1
  154. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  155. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  156. package/es/utils/amount-formatter.d.ts +42 -0
  157. package/es/utils/amount-formatter.mjs +28 -41
  158. package/es/utils/amount-formatter.mjs.map +1 -1
  159. package/es/utils/autorest.d.ts +6 -0
  160. package/es/utils/autorest.mjs +97 -0
  161. package/es/utils/autorest.mjs.map +1 -0
  162. package/es/utils/bignumber.d.ts +13 -0
  163. package/es/utils/bignumber.mjs +10 -8
  164. package/es/utils/bignumber.mjs.map +1 -1
  165. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  166. package/es/utils/bytes.mjs +10 -14
  167. package/es/utils/bytes.mjs.map +1 -1
  168. package/es/utils/crypto.d.ts +103 -0
  169. package/es/utils/crypto.mjs +60 -68
  170. package/es/utils/crypto.mjs.map +1 -1
  171. package/es/utils/encoder.d.ts +26 -0
  172. package/es/utils/encoder.mjs +47 -51
  173. package/es/utils/encoder.mjs.map +1 -1
  174. package/es/{errors.d.ts → utils/errors.d.ts} +254 -57
  175. package/es/utils/errors.mjs +318 -125
  176. package/es/utils/errors.mjs.map +1 -1
  177. package/es/utils/hd-wallet.d.ts +34 -0
  178. package/es/utils/hd-wallet.mjs +27 -16
  179. package/es/utils/hd-wallet.mjs.map +1 -1
  180. package/es/utils/json-big.d.ts +5 -0
  181. package/es/utils/json-big.mjs +10 -14
  182. package/es/utils/json-big.mjs.map +1 -1
  183. package/es/utils/keystore.d.ts +51 -0
  184. package/es/utils/keystore.mjs +98 -193
  185. package/es/utils/keystore.mjs.map +1 -1
  186. package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
  187. package/es/utils/mptree.mjs +13 -14
  188. package/es/utils/mptree.mjs.map +1 -1
  189. package/es/utils/other.d.ts +14 -0
  190. package/es/utils/other.mjs +21 -36
  191. package/es/utils/other.mjs.map +1 -1
  192. package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
  193. package/es/utils/semver-satisfies.mjs.map +1 -1
  194. package/es/utils/string.d.ts +24 -0
  195. package/es/utils/string.mjs +8 -10
  196. package/es/utils/string.mjs.map +1 -1
  197. package/package.json +49 -39
  198. package/src/AeSdk.ts +65 -0
  199. package/src/AeSdkAepp.ts +167 -0
  200. package/src/AeSdkBase.ts +320 -0
  201. package/src/AeSdkWallet.ts +332 -0
  202. package/src/Node.ts +167 -0
  203. package/src/account/Base.ts +114 -0
  204. package/src/account/Memory.ts +83 -0
  205. package/src/account/Rpc.ts +67 -0
  206. package/src/aens.ts +391 -0
  207. package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
  208. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
  209. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
  210. package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +16 -17
  211. package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
  212. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  213. package/src/aepp-wallet-communication/schema.ts +181 -0
  214. package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
  215. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  216. package/src/apis/compiler/compiler.ts +585 -0
  217. package/src/apis/compiler/index.ts +2 -0
  218. package/src/apis/compiler/models/index.ts +301 -0
  219. package/src/apis/compiler/models/mappers.ts +583 -0
  220. package/src/apis/compiler/models/parameters.ts +93 -0
  221. package/src/apis/node/code-model-v4.yaml +10046 -0
  222. package/src/apis/node/index.ts +2 -0
  223. package/src/apis/node/models/index.ts +1253 -0
  224. package/src/apis/node/models/mappers.ts +4278 -0
  225. package/src/apis/node/models/parameters.ts +188 -0
  226. package/src/apis/node/node.ts +1299 -0
  227. package/src/chain.ts +444 -0
  228. package/src/channel/{handlers.js → handlers.ts} +220 -128
  229. package/src/channel/index.ts +991 -0
  230. package/src/channel/internal.ts +345 -0
  231. package/src/contract/Compiler.ts +66 -0
  232. package/src/contract/aci.ts +529 -0
  233. package/src/contract/ga.ts +178 -0
  234. package/src/contract/methods.ts +118 -0
  235. package/src/index.ts +51 -0
  236. package/src/oracle.ts +342 -0
  237. package/src/spend.ts +152 -0
  238. package/src/tx/builder/{constants.js → constants.ts} +12 -16
  239. package/src/tx/builder/field-types.ts +111 -0
  240. package/src/tx/builder/helpers.ts +253 -0
  241. package/src/tx/builder/index.ts +394 -0
  242. package/src/tx/builder/schema.ts +771 -0
  243. package/src/tx/index.ts +199 -0
  244. package/src/tx/min-fee.ts +136 -0
  245. package/src/tx/validator.ts +226 -0
  246. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  247. package/src/typings/@aeternity__uuid/index.d.ts +3 -0
  248. package/src/typings/bip32-path/index.d.ts +33 -0
  249. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  250. package/src/utils/amount-formatter.ts +29 -42
  251. package/src/utils/autorest.ts +90 -0
  252. package/src/utils/bignumber.ts +9 -11
  253. package/src/utils/bytes.ts +12 -14
  254. package/src/utils/crypto.ts +217 -0
  255. package/src/utils/encoder.ts +52 -55
  256. package/src/utils/errors.ts +268 -134
  257. package/src/utils/hd-wallet.ts +134 -0
  258. package/src/utils/json-big.ts +26 -0
  259. package/src/utils/keystore.ts +179 -0
  260. package/src/utils/mptree.ts +14 -14
  261. package/src/utils/other.ts +28 -43
  262. package/src/utils/string.ts +8 -10
  263. package/es/account/base.mjs +0 -179
  264. package/es/account/base.mjs.map +0 -1
  265. package/es/account/memory.mjs +0 -99
  266. package/es/account/memory.mjs.map +0 -1
  267. package/es/account/multiple.mjs +0 -179
  268. package/es/account/multiple.mjs.map +0 -1
  269. package/es/ae/aens.mjs +0 -404
  270. package/es/ae/aens.mjs.map +0 -1
  271. package/es/ae/aepp.mjs +0 -45
  272. package/es/ae/aepp.mjs.map +0 -1
  273. package/es/ae/contract.mjs +0 -159
  274. package/es/ae/contract.mjs.map +0 -1
  275. package/es/ae/index.mjs +0 -207
  276. package/es/ae/index.mjs.map +0 -1
  277. package/es/ae/oracle.mjs +0 -339
  278. package/es/ae/oracle.mjs.map +0 -1
  279. package/es/ae/universal.mjs +0 -45
  280. package/es/ae/universal.mjs.map +0 -1
  281. package/es/ae/wallet.mjs +0 -50
  282. package/es/ae/wallet.mjs.map +0 -1
  283. package/es/amount-formatter.d.ts +0 -58
  284. package/es/bignumber.d.ts +0 -18
  285. package/es/chain/index.mjs +0 -272
  286. package/es/chain/index.mjs.map +0 -1
  287. package/es/chain/node.mjs +0 -442
  288. package/es/chain/node.mjs.map +0 -1
  289. package/es/contract/compiler.mjs +0 -115
  290. package/es/contract/compiler.mjs.map +0 -1
  291. package/es/contract/ga/helpers.mjs +0 -30
  292. package/es/contract/ga/helpers.mjs.map +0 -1
  293. package/es/contract/ga/index.mjs +0 -178
  294. package/es/contract/ga/index.mjs.map +0 -1
  295. package/es/crypto-ts.d.ts +0 -9
  296. package/es/encoder.d.ts +0 -26
  297. package/es/node-pool/index.mjs +0 -188
  298. package/es/node-pool/index.mjs.map +0 -1
  299. package/es/node.mjs +0 -133
  300. package/es/node.mjs.map +0 -1
  301. package/es/other.d.ts +0 -31
  302. package/es/string.d.ts +0 -26
  303. package/es/tx/tx-object.mjs +0 -283
  304. package/es/tx/tx-object.mjs.map +0 -1
  305. package/es/tx/tx.mjs +0 -938
  306. package/es/tx/tx.mjs.map +0 -1
  307. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
  308. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
  309. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
  310. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
  311. package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
  312. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
  313. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
  314. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
  315. package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
  316. package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
  317. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
  318. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
  319. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
  320. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
  321. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
  322. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
  323. package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
  324. package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
  325. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
  326. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
  327. package/es/utils/async-init.mjs +0 -64
  328. package/es/utils/async-init.mjs.map +0 -1
  329. package/es/utils/crypto-ts.mjs.map +0 -1
  330. package/es/utils/swagger.mjs +0 -164
  331. package/es/utils/swagger.mjs.map +0 -1
  332. package/src/account/base.js +0 -153
  333. package/src/account/memory.js +0 -83
  334. package/src/account/multiple.js +0 -162
  335. package/src/ae/aens.js +0 -361
  336. package/src/ae/aepp.js +0 -45
  337. package/src/ae/contract.js +0 -148
  338. package/src/ae/index.js +0 -168
  339. package/src/ae/oracle.js +0 -311
  340. package/src/ae/universal.js +0 -47
  341. package/src/ae/wallet.js +0 -50
  342. package/src/chain/index.js +0 -269
  343. package/src/chain/node.js +0 -320
  344. package/src/channel/index.js +0 -903
  345. package/src/channel/internal.js +0 -236
  346. package/src/contract/aci.js +0 -376
  347. package/src/contract/compiler.js +0 -100
  348. package/src/contract/ga/helpers.js +0 -19
  349. package/src/contract/ga/index.js +0 -150
  350. package/src/index.js +0 -89
  351. package/src/node-pool/index.js +0 -172
  352. package/src/node.js +0 -116
  353. package/src/tx/builder/field-types.js +0 -61
  354. package/src/tx/builder/helpers.js +0 -334
  355. package/src/tx/builder/index.js +0 -465
  356. package/src/tx/builder/schema.js +0 -1100
  357. package/src/tx/index.js +0 -301
  358. package/src/tx/tx-object.js +0 -187
  359. package/src/tx/tx.js +0 -631
  360. package/src/tx/validator.js +0 -181
  361. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
  362. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
  363. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  364. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
  365. package/src/utils/aepp-wallet-communication/helpers.js +0 -60
  366. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
  367. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
  368. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
  369. package/src/utils/aepp-wallet-communication/schema.ts +0 -80
  370. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
  371. package/src/utils/async-init.js +0 -45
  372. package/src/utils/crypto.js +0 -219
  373. package/src/utils/hd-wallet.js +0 -100
  374. package/src/utils/json-big.js +0 -26
  375. package/src/utils/keystore.js +0 -219
  376. package/src/utils/swagger.js +0 -156
package/es/index.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ export * from './chain';
2
+ export * from './utils/crypto';
3
+ export * from './utils/keystore';
4
+ export * from './utils/bytes';
5
+ export * from './tx';
6
+ export * from './tx/builder';
7
+ export * from './tx/builder/helpers';
8
+ export * from './tx/builder/schema';
9
+ export * from './utils/amount-formatter';
10
+ export * from './utils/hd-wallet';
11
+ export * from './aens';
12
+ export * from './contract/methods';
13
+ export * from './oracle';
14
+ export * from './spend';
15
+ export * from './contract/ga';
16
+ export { default as AeSdkBase } from './AeSdkBase';
17
+ export { default as AeSdk } from './AeSdk';
18
+ export { default as AeSdkAepp } from './AeSdkAepp';
19
+ export { default as AeSdkWallet } from './AeSdkWallet';
20
+ export { default as Node } from './Node';
21
+ export { default as verifyTransaction } from './tx/validator';
22
+ export { default as calculateMinFee } from './tx/min-fee';
23
+ export { default as AccountBase } from './account/Base';
24
+ export { default as MemoryAccount } from './account/Memory';
25
+ export { default as Compiler } from './contract/Compiler';
26
+ export { default as Channel } from './channel';
27
+ export { default as connectionProxy } from './aepp-wallet-communication/connection-proxy';
28
+ export * from './aepp-wallet-communication/schema';
29
+ export { default as walletDetector } from './aepp-wallet-communication/wallet-detector';
30
+ export { default as BrowserRuntimeConnection } from './aepp-wallet-communication/connection/BrowserRuntime';
31
+ export { default as BrowserWindowMessageConnection } from './aepp-wallet-communication/connection/BrowserWindowMessage';
32
+ export * from './utils/errors';
package/es/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * ISC License (ISC)
3
- * Copyright (c) 2021 aeternity developers
3
+ * Copyright (c) 2022 aeternity developers
4
4
  *
5
5
  * Permission to use, copy, modify, and/or distribute this software for any
6
6
  * purpose with or without fee is hereby granted, provided that the above
@@ -14,44 +14,36 @@
14
14
  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  * PERFORMANCE OF THIS SOFTWARE.
16
16
  */
17
- import * as Crypto from "./utils/crypto.mjs";
18
- import * as Keystore from "./utils/keystore.mjs";
19
- import * as Bytes from "./utils/bytes.mjs";
20
- import * as TxBuilder from "./tx/builder/index.mjs";
21
- import * as TxBuilderHelper from "./tx/builder/helpers.mjs";
22
- import * as SCHEMA from "./tx/builder/schema.mjs";
23
- import * as AmountFormatter from "./utils/amount-formatter.mjs";
24
- import * as HdWallet from "./utils/hd-wallet.mjs";
25
- import Ae from "./ae/index.mjs";
26
- import Chain from "./chain/index.mjs";
27
- import ChainNode from "./chain/node.mjs";
28
- import Node from "./node.mjs";
29
- import NodePool from "./node-pool/index.mjs";
30
- import Tx from "./tx/index.mjs";
31
- import Transaction from "./tx/tx.mjs";
32
- import verifyTransaction from "./tx/validator.mjs";
33
- import AccountBase from "./account/base.mjs";
34
- import AccountMultiple from "./account/multiple.mjs";
35
- import MemoryAccount from "./account/memory.mjs";
36
- import Aens from "./ae/aens.mjs";
37
- import Contract from "./ae/contract.mjs";
38
- import GeneralizedAccount from "./contract/ga/index.mjs";
39
- import ContractCompilerHttp from "./contract/compiler.mjs";
40
- import RpcAepp from "./ae/aepp.mjs";
41
- import RpcWallet from "./ae/wallet.mjs";
42
- import Oracle from "./ae/oracle.mjs";
43
- import genSwaggerClient from "./utils/swagger.mjs";
44
- import Channel from "./channel/index.mjs";
45
- import Universal from "./ae/universal.mjs";
46
- export { default as ContentScriptBridge } from "./utils/aepp-wallet-communication/content-script-bridge.mjs";
47
- import * as _AeppWalletHelpers from "./utils/aepp-wallet-communication/helpers.mjs";
48
- export { _AeppWalletHelpers as AeppWalletHelpers };
49
- import * as _AeppWalletSchema from "./utils/aepp-wallet-communication/schema.mjs";
50
- export { _AeppWalletSchema as AeppWalletSchema };
51
- export { default as WalletDetector } from "./utils/aepp-wallet-communication/wallet-detector.mjs";
52
- export { default as BrowserRuntimeConnection } from "./utils/aepp-wallet-communication/connection/browser-runtime.mjs";
53
- export { default as BrowserWindowMessageConnection } from "./utils/aepp-wallet-communication/connection/browser-window-message.mjs";
17
+ export * from "./chain.mjs";
18
+ export * from "./utils/crypto.mjs";
19
+ export * from "./utils/keystore.mjs";
20
+ export * from "./utils/bytes.mjs";
21
+ export * from "./tx/index.mjs";
22
+ export * from "./tx/builder/index.mjs";
23
+ export * from "./tx/builder/helpers.mjs";
24
+ export * from "./tx/builder/schema.mjs";
25
+ export * from "./utils/amount-formatter.mjs";
26
+ export * from "./utils/hd-wallet.mjs";
27
+ export * from "./aens.mjs";
28
+ export * from "./contract/methods.mjs";
29
+ export * from "./oracle.mjs";
30
+ export * from "./spend.mjs";
31
+ export * from "./contract/ga.mjs";
32
+ export { default as AeSdkBase } from "./AeSdkBase.mjs";
33
+ export { default as AeSdk } from "./AeSdk.mjs";
34
+ export { default as AeSdkAepp } from "./AeSdkAepp.mjs";
35
+ export { default as AeSdkWallet } from "./AeSdkWallet.mjs";
36
+ export { default as Node } from "./Node.mjs";
37
+ export { default as verifyTransaction } from "./tx/validator.mjs";
38
+ export { default as calculateMinFee } from "./tx/min-fee.mjs";
39
+ export { default as AccountBase } from "./account/Base.mjs";
40
+ export { default as MemoryAccount } from "./account/Memory.mjs";
41
+ export { default as Compiler } from "./contract/Compiler.mjs";
42
+ export { default as Channel } from "./channel/index.mjs";
43
+ export { default as connectionProxy } from "./aepp-wallet-communication/connection-proxy.mjs";
44
+ export * from "./aepp-wallet-communication/schema.mjs";
45
+ export { default as walletDetector } from "./aepp-wallet-communication/wallet-detector.mjs";
46
+ export { default as BrowserRuntimeConnection } from "./aepp-wallet-communication/connection/BrowserRuntime.mjs";
47
+ export { default as BrowserWindowMessageConnection } from "./aepp-wallet-communication/connection/BrowserWindowMessage.mjs";
54
48
  export * from "./utils/errors.mjs";
55
- export const getDefaultPointerKey = TxBuilderHelper.getDefaultPointerKey;
56
- export { AmountFormatter, AccountBase, AccountMultiple, Ae, Aens, Bytes, Contract, ContractCompilerHttp, ChainNode, RpcAepp, RpcWallet, Channel, Crypto, Keystore, Chain, GeneralizedAccount, HdWallet, MemoryAccount, Node, NodePool, Oracle, genSwaggerClient, Transaction, verifyTransaction, Tx, TxBuilder, TxBuilderHelper, Universal, SCHEMA };
57
49
  //# sourceMappingURL=index.mjs.map
package/es/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["Crypto","Keystore","Bytes","TxBuilder","TxBuilderHelper","SCHEMA","AmountFormatter","HdWallet","Ae","Chain","ChainNode","Node","NodePool","Tx","Transaction","verifyTransaction","AccountBase","AccountMultiple","MemoryAccount","Aens","Contract","GeneralizedAccount","ContractCompilerHttp","RpcAepp","RpcWallet","Oracle","genSwaggerClient","Channel","Universal","default","ContentScriptBridge","AeppWalletHelpers","AeppWalletSchema","WalletDetector","BrowserRuntimeConnection","BrowserWindowMessageConnection","getDefaultPointerKey"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;OAEO,KAAKA,M;OACL,KAAKC,Q;OACL,KAAKC,K;OACL,KAAKC,S;OACL,KAAKC,e;OACL,KAAKC,M;OACL,KAAKC,e;OACL,KAAKC,Q;OAELC,E;OACAC,K;OACAC,S;OACAC,I;OACAC,Q;OACAC,E;OACAC,W;OACAC,iB;OACAC,W;OACAC,e;OACAC,a;OACAC,I;OACAC,Q;OACAC,kB;OACAC,oB;OACAC,O;OACAC,S;OACAC,M;OACAC,gB;OACAC,O;OACAC,S;SAEEC,OAAO,IAAIC,mB;;+BACRC,iB;;8BACAC,gB;SACHH,OAAO,IAAII,c;SACXJ,OAAO,IAAIK,wB;SACXL,OAAO,IAAIM,8B;;AAGpB,OAAO,MAAMC,oBAAoB,GAAGhC,eAAe,CAACgC,oBAA7C;AAEP,SACE9B,eADF,EAEEU,WAFF,EAGEC,eAHF,EAIET,EAJF,EAKEW,IALF,EAMEjB,KANF,EAOEkB,QAPF,EAQEE,oBARF,EASEZ,SATF,EAUEa,OAVF,EAWEC,SAXF,EAYEG,OAZF,EAaE3B,MAbF,EAcEC,QAdF,EAeEQ,KAfF,EAgBEY,kBAhBF,EAiBEd,QAjBF,EAkBEW,aAlBF,EAmBEP,IAnBF,EAoBEC,QApBF,EAqBEa,MArBF,EAsBEC,gBAtBF,EAuBEZ,WAvBF,EAwBEC,iBAxBF,EAyBEF,EAzBF,EA0BEV,SA1BF,EA2BEC,eA3BF,EA4BEwB,SA5BF,EA6BEvB,MA7BF","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2021 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\nimport * as Crypto from './utils/crypto'\nimport * as Keystore from './utils/keystore'\nimport * as Bytes from './utils/bytes'\nimport * as TxBuilder from './tx/builder'\nimport * as TxBuilderHelper from './tx/builder/helpers'\nimport * as SCHEMA from './tx/builder/schema'\nimport * as AmountFormatter from './utils/amount-formatter'\nimport * as HdWallet from './utils/hd-wallet'\n\nimport Ae from './ae'\nimport Chain from './chain'\nimport ChainNode from './chain/node'\nimport Node from './node'\nimport NodePool from './node-pool'\nimport Tx from './tx'\nimport Transaction from './tx/tx'\nimport verifyTransaction from './tx/validator'\nimport AccountBase from './account/base'\nimport AccountMultiple from './account/multiple'\nimport MemoryAccount from './account/memory'\nimport Aens from './ae/aens'\nimport Contract from './ae/contract'\nimport GeneralizedAccount from './contract/ga'\nimport ContractCompilerHttp from './contract/compiler'\nimport RpcAepp from './ae/aepp'\nimport RpcWallet from './ae/wallet'\nimport Oracle from './ae/oracle'\nimport genSwaggerClient from './utils/swagger'\nimport Channel from './channel'\nimport Universal from './ae/universal'\n\nexport { default as ContentScriptBridge } from './utils/aepp-wallet-communication/content-script-bridge'\nexport * as AeppWalletHelpers from './utils/aepp-wallet-communication/helpers'\nexport * as AeppWalletSchema from './utils/aepp-wallet-communication/schema'\nexport { default as WalletDetector } from './utils/aepp-wallet-communication/wallet-detector'\nexport { default as BrowserRuntimeConnection } from './utils/aepp-wallet-communication/connection/browser-runtime'\nexport { default as BrowserWindowMessageConnection } from './utils/aepp-wallet-communication/connection/browser-window-message'\nexport * from './utils/errors'\n\nexport const getDefaultPointerKey = TxBuilderHelper.getDefaultPointerKey\n\nexport {\n AmountFormatter,\n AccountBase,\n AccountMultiple,\n Ae,\n Aens,\n Bytes,\n Contract,\n ContractCompilerHttp,\n ChainNode,\n RpcAepp,\n RpcWallet,\n Channel,\n Crypto,\n Keystore,\n Chain,\n GeneralizedAccount,\n HdWallet,\n MemoryAccount,\n Node,\n NodePool,\n Oracle,\n genSwaggerClient,\n Transaction,\n verifyTransaction,\n Tx,\n TxBuilder,\n TxBuilderHelper,\n Universal,\n SCHEMA\n}\n"],"file":"index.mjs"}
1
+ {"version":3,"file":"index.mjs","names":["default","AeSdkBase","AeSdk","AeSdkAepp","AeSdkWallet","Node","verifyTransaction","calculateMinFee","AccountBase","MemoryAccount","Compiler","Channel","connectionProxy","walletDetector","BrowserRuntimeConnection","BrowserWindowMessageConnection"],"sources":["../src/index.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\nexport * from './chain'\nexport * from './utils/crypto'\nexport * from './utils/keystore'\nexport * from './utils/bytes'\nexport * from './tx'\nexport * from './tx/builder'\nexport * from './tx/builder/helpers'\nexport * from './tx/builder/schema'\nexport * from './utils/amount-formatter'\nexport * from './utils/hd-wallet'\nexport * from './aens'\nexport * from './contract/methods'\nexport * from './oracle'\nexport * from './spend'\nexport * from './contract/ga'\n\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 calculateMinFee } from './tx/min-fee'\nexport { default as AccountBase } from './account/Base'\nexport { default as MemoryAccount } from './account/Memory'\nexport { default as Compiler } from './contract/Compiler'\nexport { default as Channel } from './channel'\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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;SAkBSA,OAAO,IAAIC,S;SACXD,OAAO,IAAIE,K;SACXF,OAAO,IAAIG,S;SACXH,OAAO,IAAII,W;SACXJ,OAAO,IAAIK,I;SACXL,OAAO,IAAIM,iB;SACXN,OAAO,IAAIO,e;SACXP,OAAO,IAAIQ,W;SACXR,OAAO,IAAIS,a;SACXT,OAAO,IAAIU,Q;SACXV,OAAO,IAAIW,O;SAEXX,OAAO,IAAIY,e;;SAEXZ,OAAO,IAAIa,c;SACXb,OAAO,IAAIc,wB;SACXd,OAAO,IAAIe,8B"}
package/es/oracle.d.ts ADDED
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Oracle methods - routines to interact with the æternity oracle system
3
+ *
4
+ * The high-level description of the oracle system is
5
+ * https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
6
+ * repository.
7
+ */
8
+ import { send, SendOptions } from './spend';
9
+ import { ORACLE_TTL_TYPES, TX_TYPE } from './tx/builder/schema';
10
+ import { EncodedData } from './utils/encoder';
11
+ import { _getPollInterval } from './chain';
12
+ import { BuildTxOptions } from './tx';
13
+ import Node from './Node';
14
+ import BigNumber from 'bignumber.js';
15
+ import AccountBase from './account/Base';
16
+ declare type OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries'];
17
+ /**
18
+ * Constructor for Oracle Object (helper object for using Oracle)
19
+ * @param oracleId - Oracle public key
20
+ * @param options - Options
21
+ * @returns Oracle object
22
+ */
23
+ export declare function getOracleObject(oracleId: EncodedData<'ok'>, options: {
24
+ onNode: Node;
25
+ onAccount: AccountBase;
26
+ }): Promise<GetOracleObjectReturnType>;
27
+ interface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleByPubkey']>> {
28
+ id: EncodedData<'ok'>;
29
+ queries: OracleQueries;
30
+ pollQueries: (cb: Parameters<typeof pollForQueries>[1]) => ReturnType<typeof pollForQueries>;
31
+ postQuery: Function;
32
+ respondToQuery: Function;
33
+ extendOracle: Function;
34
+ getQuery: Function;
35
+ }
36
+ /**
37
+ * Poll for oracle queries
38
+ * @param oracleId - Oracle public key
39
+ * @param onQuery - OnQuery callback
40
+ * @param options - Options object
41
+ * @param options.interval - Poll interval(default: 5000)
42
+ * @param options.onNode - Node to use
43
+ * @returns Callback to stop polling function
44
+ */
45
+ export declare function pollForQueries(oracleId: EncodedData<'ok'>, onQuery: (queries: OracleQueries) => void, { interval, onNode, ...options }: {
46
+ interval?: number;
47
+ onNode: Node;
48
+ } & Parameters<typeof _getPollInterval>[1]): () => void;
49
+ /**
50
+ * Constructor for OracleQuery Object (helper object for using OracleQuery)
51
+ * @param oracleId - Oracle public key
52
+ * @param queryId - Oracle Query id
53
+ * @param options - Options
54
+ * @returns OracleQuery object
55
+ */
56
+ export declare function getQueryObject(oracleId: EncodedData<'ok'>, queryId: EncodedData<'oq'>, options: RespondToQueryOptions & Parameters<typeof pollForQueryResponse>[2]): Promise<GetQueryObjectReturnType>;
57
+ interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {
58
+ decodedQuery: string;
59
+ decodedResponse: string;
60
+ respond: (response: string, options?: Parameters<typeof respondToQuery>[3]) => ReturnType<typeof respondToQuery>;
61
+ pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) => ReturnType<typeof pollForQueryResponse>;
62
+ }
63
+ /**
64
+ * Poll for oracle query response
65
+ * @param oracleId - Oracle public key
66
+ * @param queryId - Oracle Query id
67
+ * @param options - Options object
68
+ * @param options.attempts - Poll attempts
69
+ * @param options.interval - Poll interval
70
+ * @param options.onNode - Node to use
71
+ * @returns OracleQuery object
72
+ */
73
+ export declare function pollForQueryResponse(oracleId: EncodedData<'ok'>, queryId: EncodedData<'oq'>, { attempts, interval, onNode, ...options }: {
74
+ attempts?: number;
75
+ interval?: number;
76
+ onNode: Node;
77
+ } & Parameters<typeof _getPollInterval>[1]): Promise<string>;
78
+ /**
79
+ * Register oracle
80
+ * @param queryFormat - Format of query
81
+ * @param responseFormat - Format of query response
82
+ * @param options - Options
83
+ * @param options.queryFee - Oracle query Fee
84
+ * @param options - Options object
85
+ * @param options.abiVersion - Always 0 (do not use virtual machine)
86
+ * @param options.fee - Transaction fee
87
+ * @param options.ttl - Transaction time to leave
88
+ * @returns Oracle object
89
+ */
90
+ export declare function registerOracle(queryFormat: string, responseFormat: string, options: RegisterOracleOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
91
+ declare type RegisterOracleOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<TX_TYPE.oracleRegister, 'accountId' | 'queryFormat' | 'responseFormat' | 'queryFee' | 'oracleTtlType' | 'oracleTtlValue'> & {
92
+ queryFee?: number | string | BigNumber;
93
+ oracleTtlType?: ORACLE_TTL_TYPES;
94
+ oracleTtlValue?: number;
95
+ };
96
+ interface RegisterOracleOptions extends RegisterOracleOptionsType {
97
+ }
98
+ /**
99
+ * Post query to oracle
100
+ * @param oracleId - Oracle public key
101
+ * @param query - Oracle query object
102
+ * @param options - Options object
103
+ * @param options.queryTtl - queryTtl Oracle query time to leave
104
+ * @param options.responseTtl - queryFee Oracle query response time to leave
105
+ * @param options.queryFee - queryFee Oracle query fee
106
+ * @param options.fee - fee Transaction fee
107
+ * @param options.ttl - Transaction time to leave
108
+ * @returns Query object
109
+ */
110
+ export declare function postQueryToOracle(oracleId: EncodedData<'ok'>, query: string, options: PostQueryToOracleOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getQueryObject>>>;
111
+ declare type PostQueryToOracleOptionsType = Parameters<typeof send>[1] & Parameters<typeof getQueryObject>[2] & BuildTxOptions<TX_TYPE.oracleQuery, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'> & {
112
+ queryTtlType?: ORACLE_TTL_TYPES;
113
+ queryTtlValue?: number;
114
+ responseTtlType?: ORACLE_TTL_TYPES;
115
+ responseTtlValue?: number;
116
+ };
117
+ interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {
118
+ }
119
+ /**
120
+ * Extend oracle ttl
121
+ * @param oracleId - Oracle public key
122
+ * @param options - Options object
123
+ * @param options.fee - fee Transaction fee
124
+ * @param options.ttl - Transaction time to leave
125
+ * @param options.oracleTtlType - Oracle time to leave for extend
126
+ * @param options.oracleTtlValue - Oracle time to leave for extend
127
+ * @returns Oracle object
128
+ */
129
+ export declare function extendOracleTtl(oracleId: EncodedData<'ok'>, options: ExtendOracleTtlOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
130
+ declare type ExtendOracleTtlOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<TX_TYPE.oracleExtend, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'> & {
131
+ oracleTtlType?: ORACLE_TTL_TYPES;
132
+ oracleTtlValue?: number;
133
+ };
134
+ interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {
135
+ }
136
+ /**
137
+ * Extend oracle ttl
138
+ * @param oracleId - Oracle public key
139
+ * @param queryId - Oracle query id
140
+ * @param response - Oracle query response
141
+ * @param options - Options object
142
+ * @param options.responseTtl - responseTtl Query response time to leave
143
+ * @param options.fee - Transaction fee
144
+ * @param options.ttl - Transaction time to leave
145
+ * @returns Oracle object
146
+ */
147
+ export declare function respondToQuery(oracleId: EncodedData<'ok'>, queryId: EncodedData<'oq'>, response: string, options: RespondToQueryOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
148
+ declare type RespondToQueryOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<TX_TYPE.oracleResponse, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'> & {
149
+ responseTtlType?: ORACLE_TTL_TYPES;
150
+ responseTtlValue?: number;
151
+ };
152
+ interface RespondToQueryOptions extends RespondToQueryOptionsType {
153
+ }
154
+ export {};
package/es/oracle.mjs ADDED
@@ -0,0 +1,288 @@
1
+ /*
2
+ * ISC License (ISC)
3
+ * Copyright (c) 2022 aeternity developers
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose with or without fee is hereby granted, provided that the above
7
+ * copyright notice and this permission notice appear in all copies.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ * PERFORMANCE OF THIS SOFTWARE.
16
+ */
17
+
18
+ /**
19
+ * Oracle methods - routines to interact with the æternity oracle system
20
+ *
21
+ * The high-level description of the oracle system is
22
+ * https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
23
+ * repository.
24
+ */
25
+ import { send } from "./spend.mjs";
26
+ import { mapObject, pause } from "./utils/other.mjs";
27
+ import { oracleQueryId, decode, encode } from "./tx/builder/helpers.mjs";
28
+ import { unpackTx } from "./tx/builder/index.mjs";
29
+ import { ORACLE_TTL, QUERY_FEE, QUERY_TTL, RESPONSE_TTL, TX_TYPE } from "./tx/builder/schema.mjs";
30
+ import { RequestTimedOutError } from "./utils/errors.mjs";
31
+ import { _getPollInterval } from "./chain.mjs";
32
+ import { _buildTx } from "./tx/index.mjs";
33
+
34
+ /**
35
+ * Constructor for Oracle Object (helper object for using Oracle)
36
+ * @param oracleId - Oracle public key
37
+ * @param options - Options
38
+ * @returns Oracle object
39
+ */
40
+ export async function getOracleObject(oracleId, options) {
41
+ return { ...(await options.onNode.getOracleByPubkey(oracleId)),
42
+ queries: (await options.onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries,
43
+ ...mapObject({
44
+ pollQueries: pollForQueries,
45
+ postQuery: postQueryToOracle,
46
+ respondToQuery,
47
+ extendOracle: extendOracleTtl,
48
+ getQuery: getQueryObject
49
+ }, _ref => {
50
+ let [name, handler] = _ref;
51
+ return [name, function () {
52
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
53
+ args[_key] = arguments[_key];
54
+ }
55
+
56
+ const lastArg = args[args.length - 1];
57
+
58
+ if (lastArg != null && typeof lastArg === 'object' && lastArg.constructor === Object) {
59
+ Object.assign(lastArg, { ...options,
60
+ ...lastArg
61
+ });
62
+ } else args.push(options);
63
+
64
+ return handler(oracleId, ...args);
65
+ }];
66
+ })
67
+ };
68
+ }
69
+
70
+ /**
71
+ * Poll for oracle queries
72
+ * @param oracleId - Oracle public key
73
+ * @param onQuery - OnQuery callback
74
+ * @param options - Options object
75
+ * @param options.interval - Poll interval(default: 5000)
76
+ * @param options.onNode - Node to use
77
+ * @returns Callback to stop polling function
78
+ */
79
+ export function pollForQueries(oracleId, onQuery, _ref2) {
80
+ var _interval;
81
+
82
+ let {
83
+ interval,
84
+ onNode,
85
+ ...options
86
+ } = _ref2;
87
+ (_interval = interval) !== null && _interval !== void 0 ? _interval : interval = _getPollInterval('microblock', options);
88
+ const knownQueryIds = new Set();
89
+
90
+ const checkNewQueries = async () => {
91
+ var _await$onNode$getOrac;
92
+
93
+ const queries = ((_await$onNode$getOrac = (await onNode.getOracleQueriesByPubkey(oracleId)).oracleQueries) !== null && _await$onNode$getOrac !== void 0 ? _await$onNode$getOrac : []).filter(_ref3 => {
94
+ let {
95
+ id
96
+ } = _ref3;
97
+ return !knownQueryIds.has(id);
98
+ });
99
+ queries.forEach(_ref4 => {
100
+ let {
101
+ id
102
+ } = _ref4;
103
+ return knownQueryIds.add(id);
104
+ });
105
+ if (queries.length > 0) onQuery(queries);
106
+ };
107
+
108
+ let stopped = false; // eslint-disable-next-line @typescript-eslint/no-floating-promises
109
+
110
+ (async () => {
111
+ while (!stopped) {
112
+ // eslint-disable-line no-unmodified-loop-condition
113
+ // TODO: allow to handle this error somehow
114
+ await checkNewQueries().catch(console.error);
115
+ await pause(interval);
116
+ }
117
+ })();
118
+
119
+ return () => {
120
+ stopped = true;
121
+ };
122
+ }
123
+ /**
124
+ * Constructor for OracleQuery Object (helper object for using OracleQuery)
125
+ * @param oracleId - Oracle public key
126
+ * @param queryId - Oracle Query id
127
+ * @param options - Options
128
+ * @returns OracleQuery object
129
+ */
130
+
131
+ export async function getQueryObject(oracleId, queryId, options) {
132
+ const record = await options.onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId);
133
+ return { ...record,
134
+ decodedQuery: decode(record.query).toString(),
135
+ decodedResponse: decode(record.response).toString(),
136
+ respond: async (response, opt) => await respondToQuery(oracleId, queryId, response, { ...options,
137
+ ...opt
138
+ }),
139
+ pollForResponse: async opt => await pollForQueryResponse(oracleId, queryId, { ...options,
140
+ ...opt
141
+ })
142
+ };
143
+ }
144
+
145
+ /**
146
+ * Poll for oracle query response
147
+ * @param oracleId - Oracle public key
148
+ * @param queryId - Oracle Query id
149
+ * @param options - Options object
150
+ * @param options.attempts - Poll attempts
151
+ * @param options.interval - Poll interval
152
+ * @param options.onNode - Node to use
153
+ * @returns OracleQuery object
154
+ */
155
+ export async function pollForQueryResponse(oracleId, queryId, _ref5) {
156
+ var _interval2;
157
+
158
+ let {
159
+ attempts = 20,
160
+ interval,
161
+ onNode,
162
+ ...options
163
+ } = _ref5;
164
+ (_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = _getPollInterval('microblock', options);
165
+
166
+ for (let i = 0; i < attempts; i++) {
167
+ if (i > 0) await pause(interval);
168
+ const {
169
+ response
170
+ } = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId);
171
+ const responseBuffer = decode(response);
172
+ if (responseBuffer.length > 0) return responseBuffer.toString();
173
+ }
174
+
175
+ throw new RequestTimedOutError((attempts - 1) * interval);
176
+ }
177
+ /**
178
+ * Register oracle
179
+ * @param queryFormat - Format of query
180
+ * @param responseFormat - Format of query response
181
+ * @param options - Options
182
+ * @param options.queryFee - Oracle query Fee
183
+ * @param options - Options object
184
+ * @param options.abiVersion - Always 0 (do not use virtual machine)
185
+ * @param options.fee - Transaction fee
186
+ * @param options.ttl - Transaction time to leave
187
+ * @returns Oracle object
188
+ */
189
+
190
+ export async function registerOracle(queryFormat, responseFormat, options) {
191
+ const accountId = await options.onAccount.address(options);
192
+ const oracleRegisterTx = await _buildTx(TX_TYPE.oracleRegister, {
193
+ queryFee: QUERY_FEE,
194
+ oracleTtlValue: ORACLE_TTL.value,
195
+ oracleTtlType: ORACLE_TTL.type,
196
+ ...options,
197
+ accountId,
198
+ queryFormat,
199
+ responseFormat
200
+ });
201
+ return { ...(await send(oracleRegisterTx, options)),
202
+ ...(await getOracleObject(encode(decode(accountId), 'ok'), options))
203
+ };
204
+ }
205
+
206
+ /**
207
+ * Post query to oracle
208
+ * @param oracleId - Oracle public key
209
+ * @param query - Oracle query object
210
+ * @param options - Options object
211
+ * @param options.queryTtl - queryTtl Oracle query time to leave
212
+ * @param options.responseTtl - queryFee Oracle query response time to leave
213
+ * @param options.queryFee - queryFee Oracle query fee
214
+ * @param options.fee - fee Transaction fee
215
+ * @param options.ttl - Transaction time to leave
216
+ * @returns Query object
217
+ */
218
+ export async function postQueryToOracle(oracleId, query, options) {
219
+ var _options$queryFee;
220
+
221
+ (_options$queryFee = options.queryFee) !== null && _options$queryFee !== void 0 ? _options$queryFee : options.queryFee = (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();
222
+ const senderId = await options.onAccount.address(options);
223
+ const oracleQueryTx = await _buildTx(TX_TYPE.oracleQuery, {
224
+ queryTtlType: QUERY_TTL.type,
225
+ queryTtlValue: QUERY_TTL.value,
226
+ responseTtlType: RESPONSE_TTL.type,
227
+ responseTtlValue: RESPONSE_TTL.value,
228
+ ...options,
229
+ oracleId,
230
+ senderId,
231
+ query
232
+ });
233
+ const nonce = unpackTx(oracleQueryTx, TX_TYPE.oracleQuery).tx.nonce;
234
+ const queryId = oracleQueryId(senderId, nonce, oracleId);
235
+ return { ...(await send(oracleQueryTx, options)),
236
+ ...(await getQueryObject(oracleId, queryId, options))
237
+ };
238
+ }
239
+
240
+ /**
241
+ * Extend oracle ttl
242
+ * @param oracleId - Oracle public key
243
+ * @param options - Options object
244
+ * @param options.fee - fee Transaction fee
245
+ * @param options.ttl - Transaction time to leave
246
+ * @param options.oracleTtlType - Oracle time to leave for extend
247
+ * @param options.oracleTtlValue - Oracle time to leave for extend
248
+ * @returns Oracle object
249
+ */
250
+ export async function extendOracleTtl(oracleId, options) {
251
+ const oracleExtendTx = await _buildTx(TX_TYPE.oracleExtend, {
252
+ oracleTtlType: ORACLE_TTL.type,
253
+ oracleTtlValue: ORACLE_TTL.value,
254
+ ...options,
255
+ callerId: await options.onAccount.address(options),
256
+ oracleId
257
+ });
258
+ return { ...(await send(oracleExtendTx, options)),
259
+ ...(await getOracleObject(oracleId, options))
260
+ };
261
+ }
262
+
263
+ /**
264
+ * Extend oracle ttl
265
+ * @param oracleId - Oracle public key
266
+ * @param queryId - Oracle query id
267
+ * @param response - Oracle query response
268
+ * @param options - Options object
269
+ * @param options.responseTtl - responseTtl Query response time to leave
270
+ * @param options.fee - Transaction fee
271
+ * @param options.ttl - Transaction time to leave
272
+ * @returns Oracle object
273
+ */
274
+ export async function respondToQuery(oracleId, queryId, response, options) {
275
+ const oracleRespondTx = await _buildTx(TX_TYPE.oracleResponse, {
276
+ responseTtlType: RESPONSE_TTL.type,
277
+ responseTtlValue: RESPONSE_TTL.value,
278
+ ...options,
279
+ callerId: await options.onAccount.address(options),
280
+ oracleId,
281
+ queryId,
282
+ response
283
+ });
284
+ return { ...(await send(oracleRespondTx, options)),
285
+ ...(await getOracleObject(oracleId, options))
286
+ };
287
+ }
288
+ //# sourceMappingURL=oracle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oracle.mjs","names":["send","mapObject","pause","oracleQueryId","decode","encode","unpackTx","ORACLE_TTL","QUERY_FEE","QUERY_TTL","RESPONSE_TTL","TX_TYPE","RequestTimedOutError","_getPollInterval","_buildTx","getOracleObject","oracleId","options","onNode","getOracleByPubkey","queries","getOracleQueriesByPubkey","oracleQueries","pollQueries","pollForQueries","postQuery","postQueryToOracle","respondToQuery","extendOracle","extendOracleTtl","getQuery","getQueryObject","name","handler","args","lastArg","length","constructor","Object","assign","push","onQuery","interval","knownQueryIds","Set","checkNewQueries","filter","id","has","forEach","add","stopped","catch","console","error","queryId","record","getOracleQueryByPubkeyAndQueryId","decodedQuery","query","toString","decodedResponse","response","respond","opt","pollForResponse","pollForQueryResponse","attempts","i","responseBuffer","registerOracle","queryFormat","responseFormat","accountId","onAccount","address","oracleRegisterTx","oracleRegister","queryFee","oracleTtlValue","value","oracleTtlType","type","senderId","oracleQueryTx","oracleQuery","queryTtlType","queryTtlValue","responseTtlType","responseTtlValue","nonce","tx","oracleExtendTx","oracleExtend","callerId","oracleRespondTx","oracleResponse"],"sources":["../src/oracle.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\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 { send, SendOptions } from './spend'\nimport { mapObject, pause } from './utils/other'\nimport { oracleQueryId, decode, encode } from './tx/builder/helpers'\nimport { unpackTx } from './tx/builder'\nimport {\n ORACLE_TTL,\n ORACLE_TTL_TYPES,\n QUERY_FEE,\n QUERY_TTL,\n RESPONSE_TTL,\n TX_TYPE\n} from './tx/builder/schema'\nimport { RequestTimedOutError } from './utils/errors'\nimport { EncodedData } from './utils/encoder'\nimport { _getPollInterval } from './chain'\nimport { _buildTx, BuildTxOptions } from './tx'\nimport Node from './Node'\nimport BigNumber from 'bignumber.js'\nimport AccountBase from './account/Base'\n\ntype OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries']\n\n/**\n * Constructor for Oracle Object (helper object for using Oracle)\n * @param oracleId - Oracle public key\n * @param options - Options\n * @returns Oracle object\n */\nexport async function getOracleObject (\n oracleId: EncodedData<'ok'>, 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 function (...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(oracleId, ...args)\n }\n ])\n } as any\n}\n\ninterface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleByPubkey']>> {\n id: EncodedData<'ok'>\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 * Poll for oracle queries\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: EncodedData<'ok'>,\n onQuery: (queries: OracleQueries) => 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(({ id }) => knownQueryIds.add(id))\n if (queries.length > 0) onQuery(queries)\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 * Constructor for OracleQuery Object (helper object for using OracleQuery)\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: EncodedData<'ok'>,\n queryId: EncodedData<'oq'>,\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 EncodedData<'oq'>).toString(),\n decodedResponse: decode(record.response as EncodedData<'or'>).toString(),\n respond: async (response, opt) =>\n await respondToQuery(oracleId, queryId, response, { ...options, ...opt }),\n pollForResponse: async (opt) =>\n await 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>[3]) =>\n ReturnType<typeof respondToQuery>\n pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) =>\n ReturnType<typeof pollForQueryResponse>\n}\n\n/**\n * Poll for oracle query response\n * @param oracleId - Oracle public key\n * @param queryId - Oracle Query id\n * @param options - Options object\n * @param options.attempts - Poll attempts\n * @param options.interval - Poll interval\n * @param options.onNode - Node to use\n * @returns OracleQuery object\n */\nexport async function pollForQueryResponse (\n oracleId: EncodedData<'ok'>,\n queryId: EncodedData<'oq'>,\n { attempts = 20, interval, onNode, ...options }:\n { attempts?: number, interval?: number, onNode: Node } & Parameters<typeof _getPollInterval>[1]\n): Promise<string> {\n interval ??= _getPollInterval('microblock', options)\n for (let i = 0; i < attempts; i++) {\n if (i > 0) await pause(interval)\n const { response } = await onNode.getOracleQueryByPubkeyAndQueryId(oracleId, queryId)\n const responseBuffer = decode(response as EncodedData<'or'>)\n if (responseBuffer.length > 0) return responseBuffer.toString()\n }\n throw new RequestTimedOutError((attempts - 1) * interval)\n}\n\n/**\n * Register 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, responseFormat: string, options: RegisterOracleOptions\n): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>> {\n const accountId = await options.onAccount.address(options)\n const oracleRegisterTx = await _buildTx(TX_TYPE.oracleRegister, {\n queryFee: QUERY_FEE,\n oracleTtlValue: ORACLE_TTL.value,\n oracleTtlType: ORACLE_TTL.type,\n ...options,\n accountId,\n queryFormat,\n responseFormat\n })\n return {\n ...await send(oracleRegisterTx, options),\n ...await getOracleObject(encode(decode(accountId), 'ok'), options)\n }\n}\n\ntype RegisterOracleOptionsType = SendOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<TX_TYPE.oracleRegister, 'accountId' | 'queryFormat' | 'responseFormat' | 'queryFee' | 'oracleTtlType' | 'oracleTtlValue'>\n& {\n queryFee?: number | string | BigNumber\n oracleTtlType?: ORACLE_TTL_TYPES\n oracleTtlValue?: number\n}\ninterface RegisterOracleOptions extends RegisterOracleOptionsType {}\n\n/**\n * Post query to 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 (oracleId: EncodedData<'ok'>,\n query: string, options: PostQueryToOracleOptions\n): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getQueryObject>>> {\n options.queryFee ??= (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString()\n const senderId = await options.onAccount.address(options)\n\n const oracleQueryTx = await _buildTx(TX_TYPE.oracleQuery, {\n queryTtlType: QUERY_TTL.type,\n queryTtlValue: QUERY_TTL.value,\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n oracleId,\n senderId,\n query\n })\n const nonce = unpackTx(oracleQueryTx, TX_TYPE.oracleQuery).tx.nonce\n const queryId = oracleQueryId(senderId, nonce, oracleId)\n return {\n ...await send(oracleQueryTx, options),\n ...await getQueryObject(oracleId, queryId, options)\n }\n}\n\ntype PostQueryToOracleOptionsType = Parameters<typeof send>[1]\n& Parameters<typeof getQueryObject>[2]\n& BuildTxOptions<TX_TYPE.oracleQuery, '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 * @param oracleId - Oracle public key\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 (\n oracleId: EncodedData<'ok'>,\n options: ExtendOracleTtlOptions\n): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>> {\n const oracleExtendTx = await _buildTx(TX_TYPE.oracleExtend, {\n oracleTtlType: ORACLE_TTL.type,\n oracleTtlValue: ORACLE_TTL.value,\n ...options,\n callerId: await options.onAccount.address(options),\n oracleId\n })\n return {\n ...await send(oracleExtendTx, options),\n ...await getOracleObject(oracleId, options)\n }\n}\n\ntype ExtendOracleTtlOptionsType = SendOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<TX_TYPE.oracleExtend, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'>\n& { oracleTtlType?: ORACLE_TTL_TYPES, oracleTtlValue?: number }\ninterface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {}\n\n/**\n * Extend oracle ttl\n * @param oracleId - Oracle public key\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 oracleId: EncodedData<'ok'>,\n queryId: EncodedData<'oq'>,\n response: string,\n options: RespondToQueryOptions\n): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>> {\n const oracleRespondTx = await _buildTx(TX_TYPE.oracleResponse, {\n responseTtlType: RESPONSE_TTL.type,\n responseTtlValue: RESPONSE_TTL.value,\n ...options,\n callerId: await options.onAccount.address(options),\n oracleId,\n queryId,\n response\n })\n return {\n ...await send(oracleRespondTx, options),\n ...await getOracleObject(oracleId, options)\n }\n}\n\ntype RespondToQueryOptionsType = SendOptions & Parameters<typeof getOracleObject>[1]\n& BuildTxOptions<TX_TYPE.oracleResponse, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'>\n& { responseTtlType?: ORACLE_TTL_TYPES, responseTtlValue?: number }\ninterface RespondToQueryOptions extends RespondToQueryOptionsType {}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;SAESA,I;SACAC,S,EAAWC,K;SACXC,a,EAAeC,M,EAAQC,M;SACvBC,Q;SAEPC,U,EAEAC,S,EACAC,S,EACAC,Y,EACAC,O;SAEOC,oB;SAEAC,gB;SACAC,Q;;AAOT;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,eAAf,CACLC,QADK,EACwBC,OADxB,EAE+B;EACpC,OAAO,EACL,IAAG,MAAMA,OAAO,CAACC,MAAR,CAAeC,iBAAf,CAAiCH,QAAjC,CAAT,CADK;IAELI,OAAO,EAAE,CAAC,MAAMH,OAAO,CAACC,MAAR,CAAeG,wBAAf,CAAwCL,QAAxC,CAAP,EAA0DM,aAF9D;IAGL,GAAGrB,SAAS,CACV;MACEsB,WAAW,EAAEC,cADf;MAEEC,SAAS,EAAEC,iBAFb;MAGEC,cAHF;MAIEC,YAAY,EAAEC,eAJhB;MAKEC,QAAQ,EAAEC;IALZ,CADU,EAQV;MAAA,IAAC,CAACC,IAAD,EAAOC,OAAP,CAAD;MAAA,OAAqB,CACnBD,IADmB,EAEnB,YAAwB;QAAA,kCAAXE,IAAW;UAAXA,IAAW;QAAA;;QACtB,MAAMC,OAAO,GAAGD,IAAI,CAACA,IAAI,CAACE,MAAL,GAAc,CAAf,CAApB;;QACA,IAAID,OAAO,IAAI,IAAX,IAAmB,OAAOA,OAAP,KAAmB,QAAtC,IAAkDA,OAAO,CAACE,WAAR,KAAwBC,MAA9E,EAAsF;UACpF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