@aeternity/aepp-sdk 13.0.0-alpha.1 → 13.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 (394) hide show
  1. package/README.md +1 -1
  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 +1833 -1543
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdk.mjs.map +1 -1
  10. package/es/AeSdkAepp.d.ts +5 -4
  11. package/es/AeSdkAepp.mjs +13 -17
  12. package/es/AeSdkAepp.mjs.map +1 -1
  13. package/es/AeSdkBase.mjs.map +1 -1
  14. package/es/AeSdkMethods.d.ts +11 -12
  15. package/es/AeSdkMethods.mjs +6 -8
  16. package/es/AeSdkMethods.mjs.map +1 -1
  17. package/es/AeSdkWallet.mjs +1 -1
  18. package/es/AeSdkWallet.mjs.map +1 -1
  19. package/es/Node.d.ts +5 -1
  20. package/es/Node.mjs +11 -5
  21. package/es/Node.mjs.map +1 -1
  22. package/es/account/Base.d.ts +11 -6
  23. package/es/account/Base.mjs +0 -17
  24. package/es/account/Base.mjs.map +1 -1
  25. package/es/account/Generalized.mjs +12 -25
  26. package/es/account/Generalized.mjs.map +1 -1
  27. package/es/account/Ledger.mjs.map +1 -1
  28. package/es/account/LedgerFactory.mjs.map +1 -1
  29. package/es/account/Memory.d.ts +2 -1
  30. package/es/account/Memory.mjs +9 -21
  31. package/es/account/Memory.mjs.map +1 -1
  32. package/es/account/Rpc.mjs.map +1 -1
  33. package/es/aens.d.ts +12 -14
  34. package/es/aens.mjs +17 -31
  35. package/es/aens.mjs.map +1 -1
  36. package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
  37. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  38. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +0 -16
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  40. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
  41. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  42. package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
  43. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  44. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -5
  45. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
  47. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  48. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
  50. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  51. package/es/apis/compiler/compiler.d.ts +1 -1
  52. package/es/apis/compiler/compiler.mjs +4 -20
  53. package/es/apis/compiler/compiler.mjs.map +1 -1
  54. package/es/apis/compiler/models/index.d.ts +3 -2
  55. package/es/apis/compiler/models/index.mjs.map +1 -1
  56. package/es/apis/compiler/models/mappers.d.ts +1 -1
  57. package/es/apis/compiler/models/mappers.mjs +19 -2
  58. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  59. package/es/apis/node/models/index.d.ts +15 -15
  60. package/es/apis/node/models/index.mjs.map +1 -1
  61. package/es/apis/node/models/mappers.d.ts +1 -1
  62. package/es/apis/node/models/mappers.mjs +2 -1
  63. package/es/apis/node/models/mappers.mjs.map +1 -1
  64. package/es/apis/node/models/parameters.d.ts +2 -2
  65. package/es/apis/node/models/parameters.mjs +2 -2
  66. package/es/apis/node/models/parameters.mjs.map +1 -1
  67. package/es/apis/node/node.mjs +3 -19
  68. package/es/apis/node/node.mjs.map +1 -1
  69. package/es/chain.d.ts +8 -8
  70. package/es/chain.mjs +20 -23
  71. package/es/chain.mjs.map +1 -1
  72. package/es/channel/Base.d.ts +25 -12
  73. package/es/channel/Base.mjs +23 -26
  74. package/es/channel/Base.mjs.map +1 -1
  75. package/es/channel/Contract.mjs +8 -21
  76. package/es/channel/Contract.mjs.map +1 -1
  77. package/es/channel/Spend.d.ts +4 -2
  78. package/es/channel/Spend.mjs +0 -16
  79. package/es/channel/Spend.mjs.map +1 -1
  80. package/es/channel/handlers.mjs +6 -18
  81. package/es/channel/handlers.mjs.map +1 -1
  82. package/es/channel/internal.d.ts +19 -2
  83. package/es/channel/internal.mjs +19 -19
  84. package/es/channel/internal.mjs.map +1 -1
  85. package/es/contract/Contract.d.ts +30 -85
  86. package/es/contract/Contract.mjs +197 -215
  87. package/es/contract/Contract.mjs.map +1 -1
  88. package/es/contract/compiler/Base.d.ts +10 -14
  89. package/es/contract/compiler/Base.mjs.map +1 -1
  90. package/es/contract/compiler/Cli.mjs +5 -11
  91. package/es/contract/compiler/Cli.mjs.map +1 -1
  92. package/es/contract/compiler/Http.mjs +6 -30
  93. package/es/contract/compiler/Http.mjs.map +1 -1
  94. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  95. package/es/contract/compiler/getFileSystem.mjs.map +1 -1
  96. package/es/contract/delegation-signature.d.ts +43 -0
  97. package/es/contract/delegation-signature.mjs +45 -0
  98. package/es/contract/delegation-signature.mjs.map +1 -0
  99. package/es/contract/ga.d.ts +23 -7
  100. package/es/contract/ga.mjs +52 -27
  101. package/es/contract/ga.mjs.map +1 -1
  102. package/es/index-browser.d.ts +5 -4
  103. package/es/index-browser.mjs +7 -21
  104. package/es/index-browser.mjs.map +1 -1
  105. package/es/oracle.d.ts +12 -17
  106. package/es/oracle.mjs +28 -48
  107. package/es/oracle.mjs.map +1 -1
  108. package/es/spend.d.ts +19 -27
  109. package/es/spend.mjs +20 -43
  110. package/es/spend.mjs.map +1 -1
  111. package/es/tx/builder/SchemaTypes.d.ts +37 -0
  112. package/es/tx/builder/SchemaTypes.mjs +2 -0
  113. package/es/tx/builder/SchemaTypes.mjs.map +1 -0
  114. package/es/tx/builder/constants.d.ts +4 -2
  115. package/es/tx/builder/constants.mjs +2 -0
  116. package/es/tx/builder/constants.mjs.map +1 -1
  117. package/es/tx/builder/field-types/abi-version.d.ts +11 -2
  118. package/es/tx/builder/field-types/abi-version.mjs +24 -4
  119. package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
  120. package/es/tx/builder/field-types/address.mjs.map +1 -1
  121. package/es/tx/builder/field-types/array.d.ts +1 -1
  122. package/es/tx/builder/field-types/array.mjs.map +1 -1
  123. package/es/tx/builder/field-types/boolean.mjs.map +1 -1
  124. package/es/tx/builder/field-types/coin-amount.d.ts +3 -4
  125. package/es/tx/builder/field-types/coin-amount.mjs +4 -5
  126. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  127. package/es/tx/builder/field-types/ct-version.d.ts +22 -3
  128. package/es/tx/builder/field-types/ct-version.mjs +32 -4
  129. package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
  130. package/es/tx/builder/field-types/deposit.d.ts +2 -1
  131. package/es/tx/builder/field-types/deposit.mjs +3 -2
  132. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  133. package/es/tx/builder/field-types/encoded.d.ts +1 -1
  134. package/es/tx/builder/field-types/encoded.mjs.map +1 -1
  135. package/es/tx/builder/field-types/entry.mjs +3 -0
  136. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  137. package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
  138. package/es/tx/builder/field-types/fee.d.ts +3 -1
  139. package/es/tx/builder/field-types/fee.mjs +5 -1
  140. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  141. package/es/tx/builder/field-types/field.mjs.map +1 -1
  142. package/es/tx/builder/field-types/gas-limit.d.ts +3 -2
  143. package/es/tx/builder/field-types/gas-limit.mjs +4 -2
  144. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  145. package/es/tx/builder/field-types/gas-price.d.ts +3 -1
  146. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  147. package/es/tx/builder/field-types/index.d.ts +52 -13
  148. package/es/tx/builder/field-types/index.mjs +10 -2
  149. package/es/tx/builder/field-types/index.mjs.map +1 -1
  150. package/es/tx/builder/field-types/map.d.ts +13 -0
  151. package/es/tx/builder/field-types/map.mjs +49 -0
  152. package/es/tx/builder/field-types/map.mjs.map +1 -0
  153. package/es/tx/builder/field-types/mptree.d.ts +7 -2
  154. package/es/tx/builder/field-types/mptree.mjs +5 -7
  155. package/es/tx/builder/field-types/mptree.mjs.map +1 -1
  156. package/es/tx/builder/field-types/name-fee.d.ts +1 -1
  157. package/es/tx/builder/field-types/name-fee.mjs +2 -2
  158. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  159. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  160. package/es/tx/builder/field-types/name.mjs.map +1 -1
  161. package/es/tx/builder/field-types/nonce.d.ts +14 -0
  162. package/es/tx/builder/field-types/nonce.mjs +29 -0
  163. package/es/tx/builder/field-types/nonce.mjs.map +1 -0
  164. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  165. package/es/tx/builder/field-types/raw.mjs.map +1 -1
  166. package/es/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  167. package/es/tx/builder/field-types/short-u-int-const.mjs +12 -8
  168. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -1
  169. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  170. package/es/tx/builder/field-types/string.mjs.map +1 -1
  171. package/es/tx/builder/field-types/ttl.d.ts +11 -0
  172. package/es/tx/builder/field-types/ttl.mjs +21 -0
  173. package/es/tx/builder/field-types/ttl.mjs.map +1 -0
  174. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  175. package/es/tx/builder/field-types/wrapped.d.ts +14 -0
  176. package/es/tx/builder/field-types/wrapped.mjs +22 -0
  177. package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
  178. package/es/tx/builder/helpers.mjs.map +1 -1
  179. package/es/tx/builder/index.d.ts +20 -20
  180. package/es/tx/builder/index.mjs +54 -64
  181. package/es/tx/builder/index.mjs.map +1 -1
  182. package/es/tx/builder/schema.d.ts +2735 -2865
  183. package/es/tx/builder/schema.generated.d.ts +2011 -0
  184. package/es/tx/builder/schema.generated.mjs +2 -0
  185. package/es/tx/builder/schema.generated.mjs.map +1 -0
  186. package/es/tx/builder/schema.mjs +459 -155
  187. package/es/tx/builder/schema.mjs.map +1 -1
  188. package/es/tx/execution-cost.d.ts +35 -0
  189. package/es/tx/execution-cost.mjs +123 -0
  190. package/es/tx/execution-cost.mjs.map +1 -0
  191. package/es/tx/transaction-signer.d.ts +6 -0
  192. package/es/tx/transaction-signer.mjs +27 -0
  193. package/es/tx/transaction-signer.mjs.map +1 -0
  194. package/es/tx/validator.mjs +60 -109
  195. package/es/tx/validator.mjs.map +1 -1
  196. package/es/utils/amount-formatter.mjs +0 -16
  197. package/es/utils/amount-formatter.mjs.map +1 -1
  198. package/es/utils/autorest.d.ts +3 -2
  199. package/es/utils/autorest.mjs +43 -11
  200. package/es/utils/autorest.mjs.map +1 -1
  201. package/es/utils/bytes.mjs +0 -16
  202. package/es/utils/bytes.mjs.map +1 -1
  203. package/es/utils/crypto.mjs +0 -16
  204. package/es/utils/crypto.mjs.map +1 -1
  205. package/es/utils/encoder.mjs.map +1 -1
  206. package/es/utils/errors.d.ts +14 -31
  207. package/es/utils/errors.mjs +3 -33
  208. package/es/utils/errors.mjs.map +1 -1
  209. package/es/utils/hd-wallet.mjs.map +1 -1
  210. package/es/utils/json-big.mjs.map +1 -1
  211. package/es/utils/keystore.mjs.map +1 -1
  212. package/es/utils/other.d.ts +1 -1
  213. package/es/utils/other.mjs.map +1 -1
  214. package/es/utils/semver-satisfies.mjs.map +1 -1
  215. package/es/utils/string.mjs +0 -17
  216. package/es/utils/string.mjs.map +1 -1
  217. package/package.json +34 -30
  218. package/src/AeSdkAepp.ts +16 -14
  219. package/src/AeSdkMethods.ts +11 -16
  220. package/src/AeSdkWallet.ts +1 -1
  221. package/src/Node.ts +17 -6
  222. package/src/account/Base.ts +11 -22
  223. package/src/account/Generalized.ts +9 -24
  224. package/src/account/Memory.ts +14 -21
  225. package/src/aens.ts +31 -47
  226. package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
  227. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +0 -17
  228. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
  229. package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
  230. package/src/aepp-wallet-communication/rpc/types.ts +7 -2
  231. package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
  232. package/src/apis/compiler/compiler.ts +3 -27
  233. package/src/apis/compiler/models/index.ts +3 -2
  234. package/src/apis/compiler/models/mappers.ts +15 -2
  235. package/src/apis/node/models/index.ts +16 -15
  236. package/src/apis/node/models/mappers.ts +2 -1
  237. package/src/apis/node/models/parameters.ts +2 -2
  238. package/src/apis/node/node.ts +3 -27
  239. package/src/chain.ts +29 -28
  240. package/src/channel/Base.ts +33 -33
  241. package/src/channel/Contract.ts +8 -23
  242. package/src/channel/Spend.ts +2 -17
  243. package/src/channel/handlers.ts +5 -18
  244. package/src/channel/internal.ts +40 -22
  245. package/src/contract/Contract.ts +161 -170
  246. package/src/contract/compiler/Base.ts +10 -14
  247. package/src/contract/compiler/Cli.ts +5 -11
  248. package/src/contract/compiler/Http.ts +6 -25
  249. package/src/contract/delegation-signature.ts +56 -0
  250. package/src/contract/ga.ts +53 -32
  251. package/src/index-browser.ts +15 -21
  252. package/src/oracle.ts +46 -56
  253. package/src/spend.ts +33 -67
  254. package/src/tx/builder/SchemaTypes.ts +79 -0
  255. package/src/tx/builder/constants.ts +2 -0
  256. package/src/tx/builder/field-types/abi-version.ts +29 -6
  257. package/src/tx/builder/field-types/array.ts +1 -1
  258. package/src/tx/builder/field-types/coin-amount.ts +6 -4
  259. package/src/tx/builder/field-types/ct-version.ts +37 -4
  260. package/src/tx/builder/field-types/deposit.ts +3 -1
  261. package/src/tx/builder/field-types/encoded.ts +1 -1
  262. package/src/tx/builder/field-types/entry.ts +8 -3
  263. package/src/tx/builder/field-types/fee.ts +6 -4
  264. package/src/tx/builder/field-types/gas-limit.ts +2 -2
  265. package/src/tx/builder/field-types/index.ts +15 -1
  266. package/src/tx/builder/field-types/map.ts +45 -0
  267. package/src/tx/builder/field-types/mptree.ts +4 -3
  268. package/src/tx/builder/field-types/name-fee.ts +2 -1
  269. package/src/tx/builder/field-types/nonce.ts +40 -0
  270. package/src/tx/builder/field-types/short-u-int-const.ts +18 -8
  271. package/src/tx/builder/field-types/ttl.ts +24 -0
  272. package/src/tx/builder/field-types/wrapped.ts +32 -0
  273. package/src/tx/builder/index.ts +57 -71
  274. package/src/tx/builder/schema.generated.ts +2013 -0
  275. package/src/tx/builder/schema.ts +544 -624
  276. package/src/tx/execution-cost.ts +146 -0
  277. package/src/tx/transaction-signer.ts +27 -0
  278. package/src/tx/validator.ts +60 -91
  279. package/src/utils/amount-formatter.ts +0 -16
  280. package/src/utils/autorest.ts +52 -11
  281. package/src/utils/bytes.ts +0 -16
  282. package/src/utils/crypto.ts +0 -16
  283. package/src/utils/errors.ts +16 -45
  284. package/src/utils/string.ts +0 -17
  285. package/types-legacy/ts4.2/AeSdkAepp.d.ts +5 -4
  286. package/types-legacy/ts4.2/AeSdkMethods.d.ts +11 -12
  287. package/types-legacy/ts4.2/Node.d.ts +5 -1
  288. package/types-legacy/ts4.2/account/Base.d.ts +11 -6
  289. package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
  290. package/types-legacy/ts4.2/aens.d.ts +12 -14
  291. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
  292. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
  293. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
  294. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
  295. package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
  296. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
  297. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  298. package/types-legacy/ts4.2/chain.d.ts +8 -8
  299. package/types-legacy/ts4.2/channel/Base.d.ts +25 -12
  300. package/types-legacy/ts4.2/channel/Spend.d.ts +4 -2
  301. package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
  302. package/types-legacy/ts4.2/contract/Contract.d.ts +29 -84
  303. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +10 -14
  304. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
  305. package/types-legacy/ts4.2/contract/ga.d.ts +23 -7
  306. package/types-legacy/ts4.2/index-browser.d.ts +5 -4
  307. package/types-legacy/ts4.2/oracle.d.ts +12 -17
  308. package/types-legacy/ts4.2/spend.d.ts +19 -27
  309. package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
  310. package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -2
  311. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +11 -2
  312. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +1 -1
  313. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +3 -4
  314. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +33 -3
  315. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +2 -1
  316. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +1 -1
  317. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +3 -1
  318. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +3 -2
  319. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
  320. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +52 -13
  321. package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
  322. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +7 -2
  323. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
  324. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
  325. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  326. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
  327. package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
  328. package/types-legacy/ts4.2/tx/builder/index.d.ts +23 -20
  329. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2962 -4629
  330. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
  331. package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
  332. package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
  333. package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
  334. package/types-legacy/ts4.2/utils/errors.d.ts +14 -31
  335. package/types-legacy/ts4.2/utils/other.d.ts +1 -1
  336. package/types-legacy/ts4.5/AeSdkAepp.d.ts +5 -4
  337. package/types-legacy/ts4.5/AeSdkMethods.d.ts +11 -12
  338. package/types-legacy/ts4.5/Node.d.ts +5 -1
  339. package/types-legacy/ts4.5/account/Base.d.ts +11 -6
  340. package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
  341. package/types-legacy/ts4.5/aens.d.ts +12 -14
  342. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
  343. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
  344. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
  345. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
  346. package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
  347. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
  348. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  349. package/types-legacy/ts4.5/chain.d.ts +8 -8
  350. package/types-legacy/ts4.5/channel/Base.d.ts +25 -12
  351. package/types-legacy/ts4.5/channel/Spend.d.ts +4 -2
  352. package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
  353. package/types-legacy/ts4.5/contract/Contract.d.ts +29 -84
  354. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +10 -14
  355. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
  356. package/types-legacy/ts4.5/contract/ga.d.ts +23 -7
  357. package/types-legacy/ts4.5/index-browser.d.ts +5 -4
  358. package/types-legacy/ts4.5/oracle.d.ts +12 -17
  359. package/types-legacy/ts4.5/spend.d.ts +19 -27
  360. package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
  361. package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -2
  362. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +11 -2
  363. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +1 -1
  364. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +3 -4
  365. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +33 -3
  366. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +2 -1
  367. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +1 -1
  368. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +3 -1
  369. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +3 -2
  370. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
  371. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +52 -13
  372. package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
  373. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +7 -2
  374. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
  375. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
  376. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  377. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
  378. package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
  379. package/types-legacy/ts4.5/tx/builder/index.d.ts +23 -20
  380. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2962 -4629
  381. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
  382. package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
  383. package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
  384. package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
  385. package/types-legacy/ts4.5/utils/errors.d.ts +14 -31
  386. package/types-legacy/ts4.5/utils/other.d.ts +1 -1
  387. package/es/tx/index.d.ts +0 -19
  388. package/es/tx/index.mjs +0 -115
  389. package/es/tx/index.mjs.map +0 -1
  390. package/src/apis/compiler/code-model-v4.yaml +0 -2442
  391. package/src/apis/node/code-model-v4.yaml +0 -10080
  392. package/src/tx/index.ts +0 -129
  393. package/types-legacy/ts4.2/tx/index.d.ts +0 -19
  394. package/types-legacy/ts4.5/tx/index.d.ts +0 -19
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * Generalized Account module - routines to use generalized account
3
3
  */
4
- import { Tag } from '../tx/builder/constants';
5
- import { BuildTxOptions } from '../tx';
4
+ /// <reference types="node" />
5
+ import { Int, Tag } from '../tx/builder/constants';
6
+ import { BuildTxOptions } from '../tx/builder';
6
7
  import { Encoded } from '../utils/encoder';
7
8
  import AccountBase from '../account/Base';
8
9
  import Contract from './Contract';
9
- import { SendOptions } from '../spend';
10
10
  import Node from '../Node';
11
+ import { SendTransactionOptions } from '../chain';
11
12
  import CompilerBase from './compiler/Base';
12
13
  /**
13
14
  * Convert current account to GA
@@ -24,21 +25,36 @@ export declare function createGeneralizedAccount(authFnName: string, args: any[]
24
25
  rawTx: Encoded.Transaction;
25
26
  gaContractId: Encoded.ContractAddress;
26
27
  }>>;
27
- interface CreateGeneralizedAccountOptions extends BuildTxOptions<Tag.GaAttachTx, 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit'>, SendOptions, Pick<Parameters<typeof Contract.initialize>[0], 'bytecode' | 'aci' | 'sourceCodePath' | 'sourceCode' | 'fileSystem'> {
28
+ interface CreateGeneralizedAccountOptions extends BuildTxOptions<Tag.GaAttachTx, 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit'>, SendTransactionOptions, Pick<Parameters<typeof Contract.initialize>[0], 'bytecode' | 'aci' | 'sourceCodePath' | 'sourceCode' | 'fileSystem'> {
28
29
  onAccount: AccountBase;
29
30
  onCompiler: CompilerBase;
30
31
  onNode: Node;
31
32
  gasLimit?: number;
32
33
  }
33
34
  /**
34
- * Build a transaction hash the same as `Auth.tx_hash`
35
+ * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx payload
35
36
  * @category contract
36
37
  * @param transaction - tx-encoded transaction
37
38
  * @param options - Options
39
+ * @param options.fee - GaMetaTx fee, required in Ceres
40
+ * @param options.gasPrice - GaMetaTx gasPrice, required in Ceres
38
41
  * @param options.onNode - Node to use
39
42
  * @returns Transaction hash
40
43
  */
41
- export declare function buildAuthTxHash(transaction: Encoded.Transaction, { onNode }: {
44
+ export declare function buildAuthTxHash(transaction: Encoded.Transaction, { fee, gasPrice, onNode }: {
45
+ fee?: Int;
46
+ gasPrice?: Int;
42
47
  onNode: Node;
43
- }): Promise<Uint8Array>;
48
+ }): Promise<Buffer>;
49
+ /**
50
+ * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx
51
+ * @category contract
52
+ * @param transaction - tx-encoded signed GaMeta transaction
53
+ * @param options - Options
54
+ * @param options.onNode - Node to use
55
+ * @returns Transaction hash
56
+ */
57
+ export declare function buildAuthTxHashByGaMetaTx(transaction: Encoded.Transaction, { onNode }: {
58
+ onNode: Node;
59
+ }): Promise<Buffer>;
44
60
  export {};
@@ -2,35 +2,17 @@ import _buffer from "buffer";
2
2
  const {
3
3
  Buffer: _Buffer
4
4
  } = _buffer;
5
- /*
6
- * ISC License (ISC)
7
- * Copyright (c) 2022 aeternity developers
8
- *
9
- * Permission to use, copy, modify, and/or distribute this software for any
10
- * purpose with or without fee is hereby granted, provided that the above
11
- * copyright notice and this permission notice appear in all copies.
12
- *
13
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- * PERFORMANCE OF THIS SOFTWARE.
20
- */
21
5
  /**
22
6
  * Generalized Account module - routines to use generalized account
23
7
  */
24
- import { Tag } from "../tx/builder/constants.mjs";
25
- import { buildContractIdByContractTx } from "../tx/builder/index.mjs";
26
- import { _buildTx } from "../tx/index.mjs";
8
+ import { ConsensusProtocolVersion, Tag } from "../tx/builder/constants.mjs";
9
+ import { buildContractIdByContractTx, buildTx, buildTxAsync, unpackTx } from "../tx/builder/index.mjs";
27
10
  import { hash } from "../utils/crypto.mjs";
28
- import { decode } from "../utils/encoder.mjs";
29
- import { IllegalArgumentError } from "../utils/errors.mjs";
11
+ import { decode, encode, Encoding } from "../utils/encoder.mjs";
12
+ import { ArgumentError, IllegalArgumentError } from "../utils/errors.mjs";
30
13
  import { concatBuffers } from "../utils/other.mjs";
31
14
  import Contract from "./Contract.mjs";
32
- import { send } from "../spend.mjs";
33
- import { getAccount } from "../chain.mjs";
15
+ import { sendTransaction, getAccount } from "../chain.mjs";
34
16
  /**
35
17
  * Convert current account to GA
36
18
  * @category contract
@@ -69,8 +51,9 @@ export async function createGeneralizedAccount(authFnName, args, _ref) {
69
51
  sourceCode,
70
52
  fileSystem
71
53
  });
72
- const tx = await _buildTx(Tag.GaAttachTx, {
54
+ const tx = await buildTxAsync({
73
55
  ...options,
56
+ tag: Tag.GaAttachTx,
74
57
  onNode,
75
58
  code: await contract.$compile(),
76
59
  gasLimit: (_options$gasLimit = options.gasLimit) !== null && _options$gasLimit !== void 0 ? _options$gasLimit : await contract._estimateGas('init', args, options),
@@ -82,7 +65,7 @@ export async function createGeneralizedAccount(authFnName, args, _ref) {
82
65
  const {
83
66
  hash: transaction,
84
67
  rawTx
85
- } = await send(tx, {
68
+ } = await sendTransaction(tx, {
86
69
  onNode,
87
70
  onAccount,
88
71
  onCompiler,
@@ -96,17 +79,59 @@ export async function createGeneralizedAccount(authFnName, args, _ref) {
96
79
  });
97
80
  }
98
81
  /**
99
- * Build a transaction hash the same as `Auth.tx_hash`
82
+ * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx payload
100
83
  * @category contract
101
84
  * @param transaction - tx-encoded transaction
102
85
  * @param options - Options
86
+ * @param options.fee - GaMetaTx fee, required in Ceres
87
+ * @param options.gasPrice - GaMetaTx gasPrice, required in Ceres
103
88
  * @param options.onNode - Node to use
104
89
  * @returns Transaction hash
105
90
  */
106
91
  export async function buildAuthTxHash(transaction, _ref2) {
107
92
  let {
93
+ fee,
94
+ gasPrice,
108
95
  onNode
109
96
  } = _ref2;
110
- return new Uint8Array(hash(concatBuffers([_Buffer.from(await onNode.getNetworkId()), decode(transaction)])));
97
+ const {
98
+ nodeNetworkId,
99
+ consensusProtocolVersion
100
+ } = await onNode.getNodeInfo();
101
+ let payload = hash(concatBuffers([_Buffer.from(nodeNetworkId), decode(transaction)]));
102
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
103
+ if (fee == null) throw new ArgumentError('fee', 'provided (in Ceres)', fee);
104
+ if (gasPrice == null) throw new ArgumentError('gasPrice', 'provided (in Ceres)', gasPrice);
105
+ payload = hash(decode(buildTx({
106
+ tag: Tag.GaMetaTxAuthData,
107
+ fee,
108
+ gasPrice,
109
+ txHash: encode(payload, Encoding.TxHash)
110
+ })));
111
+ }
112
+ return payload;
113
+ }
114
+
115
+ /**
116
+ * Build a transaction hash the same as `Auth.tx_hash` by GaMetaTx
117
+ * @category contract
118
+ * @param transaction - tx-encoded signed GaMeta transaction
119
+ * @param options - Options
120
+ * @param options.onNode - Node to use
121
+ * @returns Transaction hash
122
+ */
123
+ export async function buildAuthTxHashByGaMetaTx(transaction, _ref3) {
124
+ let {
125
+ onNode
126
+ } = _ref3;
127
+ const txParams = unpackTx(transaction, Tag.SignedTx);
128
+ if (txParams.encodedTx.tag !== Tag.GaMetaTx) {
129
+ throw new ArgumentError('transaction', 'to include GaMetaTx', Tag[txParams.encodedTx.tag]);
130
+ }
131
+ return buildAuthTxHash(buildTx(txParams.encodedTx.tx.encodedTx), {
132
+ fee: txParams.encodedTx.fee,
133
+ gasPrice: txParams.encodedTx.gasPrice,
134
+ onNode
135
+ });
111
136
  }
112
137
  //# sourceMappingURL=ga.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ga.mjs","names":["Tag","buildContractIdByContractTx","_buildTx","hash","decode","IllegalArgumentError","concatBuffers","Contract","send","getAccount","createGeneralizedAccount","authFnName","args","onAccount","onCompiler","onNode","bytecode","aci","sourceCodePath","sourceCode","fileSystem","options","ownerId","address","kind","contract","initialize","tx","GaAttachTx","code","$compile","gasLimit","_estimateGas","callData","_calldata","encode","_name","authFun","contractId","transaction","rawTx","Object","freeze","owner","gaContractId","buildAuthTxHash","Uint8Array","from","getNetworkId"],"sources":["../../src/contract/ga.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 * Generalized Account module - routines to use generalized account\n */\n\nimport { Tag } from '../tx/builder/constants';\nimport { buildContractIdByContractTx } from '../tx/builder';\nimport { _buildTx, BuildTxOptions } from '../tx';\nimport { hash } from '../utils/crypto';\nimport { decode, Encoded } from '../utils/encoder';\nimport { IllegalArgumentError } from '../utils/errors';\nimport { concatBuffers } from '../utils/other';\nimport AccountBase from '../account/Base';\nimport Contract from './Contract';\nimport { send, SendOptions } from '../spend';\nimport Node from '../Node';\nimport { 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 _buildTx(Tag.GaAttachTx, {\n ...options,\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 send(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 SendOptions,\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`\n * @category contract\n * @param transaction - tx-encoded transaction\n * @param options - Options\n * @param options.onNode - Node to use\n * @returns Transaction hash\n */\nexport async function buildAuthTxHash(\n transaction: Encoded.Transaction,\n { onNode }: { onNode: Node },\n): Promise<Uint8Array> {\n return new Uint8Array(hash(\n concatBuffers([Buffer.from(await onNode.getNetworkId()), decode(transaction)]),\n ));\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAFA,SAISA,GAAG;AAAA,SACHC,2BAA2B;AAAA,SAC3BC,QAAQ;AAAA,SACRC,IAAI;AAAA,SACJC,MAAM;AAAA,SACNC,oBAAoB;AAAA,SACpBC,aAAa;AAAA,OAEfC,QAAQ;AAAA,SACNC,IAAI;AAAA,SAEJC,UAAU;AAGnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwB,CAC5CC,UAAkB,EAClBC,IAAW,QASP;EAAA;EAAA,IARJ;IACEC,SAAS;IAAEC,UAAU;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,GAAG;IAAEC,cAAc;IAAEC,UAAU;IAAEC,UAAU;IAAE,GAAGC;EAC1D,CAAC;EAOlC,MAAMC,OAAO,GAAGT,SAAS,CAACU,OAAO;EACjC,IAAI,CAAC,MAAMd,UAAU,CAACa,OAAO,EAAE;IAAEP;EAAO,CAAC,CAAC,EAAES,IAAI,KAAK,aAAa,EAAE;IAClE,MAAM,IAAInB,oBAAoB,CAAE,WAAUiB,OAAQ,gBAAe,CAAC;EACpE;EAEA,MAAMG,QAAQ,GAAG,MAAMlB,QAAQ,CAACmB,UAAU,CAAkC;IAC1Eb,SAAS;IAAEC,UAAU;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,GAAG;IAAEC,cAAc;IAAEC,UAAU;IAAEC;EAC5E,CAAC,CAAC;EAEF,MAAMO,EAAE,GAAG,MAAMzB,QAAQ,CAACF,GAAG,CAAC4B,UAAU,EAAE;IACxC,GAAGP,OAAO;IACVN,MAAM;IACNc,IAAI,EAAE,MAAMJ,QAAQ,CAACK,QAAQ,EAAE;IAC/BC,QAAQ,uBAAEV,OAAO,CAACU,QAAQ,iEAAI,MAAMN,QAAQ,CAACO,YAAY,CAAC,MAAM,EAAEpB,IAAI,EAAES,OAAO,CAAC;IAChFC,OAAO;IACPW,QAAQ,EAAER,QAAQ,CAACS,SAAS,CAACC,MAAM,CAACV,QAAQ,CAACW,KAAK,EAAE,MAAM,EAAExB,IAAI,CAAC;IACjEyB,OAAO,EAAElC,IAAI,CAACQ,UAAU;EAC1B,CAAC,CAAC;EACF,MAAM2B,UAAU,GAAGrC,2BAA2B,CAAC0B,EAAE,CAAC;EAClD,MAAM;IAAExB,IAAI,EAAEoC,WAAW;IAAEC;EAAM,CAAC,GAAG,MAAMhC,IAAI,CAACmB,EAAE,EAAE;IAClDZ,MAAM;IAAEF,SAAS;IAAEC,UAAU;IAAE,GAAGO;EACpC,CAAC,CAAC;EAEF,OAAOoB,MAAM,CAACC,MAAM,CAAC;IACnBC,KAAK,EAAErB,OAAO;IACdiB,WAAW;IACXC,KAAK;IACLI,YAAY,EAAEN;EAChB,CAAC,CAAC;AACJ;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeO,eAAe,CACnCN,WAAgC,SAEX;EAAA,IADrB;IAAExB;EAAyB,CAAC;EAE5B,OAAO,IAAI+B,UAAU,CAAC3C,IAAI,CACxBG,aAAa,CAAC,CAAC,QAAOyC,IAAI,CAAC,MAAMhC,MAAM,CAACiC,YAAY,EAAE,CAAC,EAAE5C,MAAM,CAACmC,WAAW,CAAC,CAAC,CAAC,CAC/E,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":"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"}
@@ -2,14 +2,15 @@ export * from './chain';
2
2
  export * from './utils/crypto';
3
3
  export * from './utils/keystore';
4
4
  export * from './utils/bytes';
5
- export * from './tx';
6
- export * from './tx/builder';
5
+ export { buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx, } from './tx/builder';
7
6
  export * from './tx/builder/helpers';
8
7
  export * from './tx/builder/constants';
9
- export * from './tx/builder/schema';
8
+ export { ORACLE_TTL_TYPES, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL, DRY_RUN_ACCOUNT, CallReturnType, } from './tx/builder/schema';
9
+ export { getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode, } from './tx/execution-cost';
10
+ export { default as getTransactionSignerAddress } from './tx/transaction-signer';
10
11
  export * from './utils/amount-formatter';
11
12
  export * from './utils/hd-wallet';
12
- export { encode, decode, Encoding } from './utils/encoder';
13
+ export { encode, decode, Encoding, Encoded, } from './utils/encoder';
13
14
  export * from './aens';
14
15
  export { default as Contract } from './contract/Contract';
15
16
  export type { ContractMethodsBase } from './contract/Contract';
@@ -1,31 +1,17 @@
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
- */
1
+ // TODO: avoid `export * from`
17
2
  export * from "./chain.mjs";
18
3
  export * from "./utils/crypto.mjs";
19
4
  export * from "./utils/keystore.mjs";
20
5
  export * from "./utils/bytes.mjs";
21
- export * from "./tx/index.mjs";
22
- export * from "./tx/builder/index.mjs";
6
+ export { buildTx, buildTxAsync, buildTxHash, unpackTx, buildContractIdByContractTx } from "./tx/builder/index.mjs";
23
7
  export * from "./tx/builder/helpers.mjs";
24
- export * from "./tx/builder/constants.mjs";
25
- export * from "./tx/builder/schema.mjs";
8
+ export * from "./tx/builder/constants.mjs"; // TODO: move to constants
9
+ export { ORACLE_TTL_TYPES, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL, DRY_RUN_ACCOUNT, CallReturnType } from "./tx/builder/schema.mjs";
10
+ export { getExecutionCost, getExecutionCostBySignedTx, getExecutionCostUsingNode } from "./tx/execution-cost.mjs";
11
+ export { default as getTransactionSignerAddress } from "./tx/transaction-signer.mjs";
26
12
  export * from "./utils/amount-formatter.mjs";
27
13
  export * from "./utils/hd-wallet.mjs";
28
- export { encode, decode, Encoding } from "./utils/encoder.mjs";
14
+ export { encode, decode, Encoding, Encoded } from "./utils/encoder.mjs";
29
15
  export * from "./aens.mjs";
30
16
  export { default as Contract } from "./contract/Contract.mjs";
31
17
  export * from "./oracle.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index-browser.mjs","names":["encode","decode","Encoding","default","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":["/*\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/constants';\nexport * from './tx/builder/schema';\nexport * from './utils/amount-formatter';\nexport * from './utils/hd-wallet';\nexport { encode, decode, Encoding } 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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAfA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SA4BSA,MAAM,EAAEC,MAAM,EAAEC,QAAQ;AAAA;AAAA,SAExBC,OAAO,IAAIC,QAAQ;AAAA;AAAA;AAAA;AAAA,SAMnBD,OAAO,IAAIE,YAAY;AAAA,SACvBF,OAAO,IAAIG,SAAS;AAAA,SACpBH,OAAO,IAAII,KAAK;AAAA,SAChBJ,OAAO,IAAIK,SAAS;AAAA,SACpBL,OAAO,IAAIM,WAAW;AAAA,SACtBN,OAAO,IAAIO,IAAI;AAAA,SACfP,OAAO,IAAIQ,iBAAiB;AAAA,SAC5BR,OAAO,IAAIS,WAAW;AAAA,SACtBT,OAAO,IAAIU,aAAa;AAAA,SACxBV,OAAO,IAAIW,kBAAkB;AAAA,SAC7BX,OAAO,IAAIY,aAAa;AAAA,SACxBZ,OAAO,IAAIa,oBAAoB;AAAA,SAC/Bb,OAAO,IAAIc,YAAY;AAAA,SACvBd,OAAO,IAAIe,YAAY;AAAA,SACvBf,OAAO,IAAIgB,OAAO;AAAA,SAElBhB,OAAO,IAAIiB,eAAe;AAAA;AAAA,SAE1BjB,OAAO,IAAIkB,cAAc;AAAA,SACzBlB,OAAO,IAAImB,wBAAwB;AAAA,SACnCnB,OAAO,IAAIoB,8BAA8B;AAAA"}
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"}
package/es/oracle.d.ts CHANGED
@@ -5,13 +5,11 @@
5
5
  * https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
6
6
  * repository.
7
7
  */
8
- import BigNumber from 'bignumber.js';
9
- import { send, SendOptions } from './spend';
8
+ import { BuildTxOptions } from './tx/builder';
10
9
  import { ORACLE_TTL_TYPES } from './tx/builder/schema';
11
10
  import { Tag } from './tx/builder/constants';
12
11
  import { Encoded } from './utils/encoder';
13
- import { _getPollInterval } from './chain';
14
- import { BuildTxOptions } from './tx';
12
+ import { _getPollInterval, sendTransaction, SendTransactionOptions } from './chain';
15
13
  import Node from './Node';
16
14
  import AccountBase from './account/Base';
17
15
  type OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['oracleQueries'];
@@ -25,7 +23,7 @@ type OracleQueries = Awaited<ReturnType<Node['getOracleQueriesByPubkey']>>['orac
25
23
  * @param options.onNode - Node to use
26
24
  * @returns Callback to stop polling function
27
25
  */
28
- export declare function pollForQueries(oracleId: Encoded.OracleAddress, onQuery: (queries: OracleQueries) => void, { interval, onNode, ...options }: {
26
+ export declare function pollForQueries(oracleId: Encoded.OracleAddress, onQuery: (query: OracleQueries[number]) => void, { interval, onNode, ...options }: {
29
27
  interval?: number;
30
28
  onNode: Node;
31
29
  } & Parameters<typeof _getPollInterval>[1]): () => void;
@@ -55,7 +53,7 @@ export declare function getQueryObject(oracleId: Encoded.OracleAddress, queryId:
55
53
  interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQueryByPubkeyAndQueryId']>> {
56
54
  decodedQuery: string;
57
55
  decodedResponse: string;
58
- respond: (response: string, options?: Parameters<typeof respondToQuery>[3]) => ReturnType<typeof respondToQuery>;
56
+ respond: (response: string, options?: Parameters<typeof respondToQuery>[2]) => ReturnType<typeof respondToQuery>;
59
57
  pollForResponse: (options?: Parameters<typeof pollForQueryResponse>[2]) => ReturnType<typeof pollForQueryResponse>;
60
58
  }
61
59
  /**
@@ -71,8 +69,8 @@ interface GetQueryObjectReturnType extends Awaited<ReturnType<Node['getOracleQue
71
69
  * @param options.ttl - Transaction time to leave
72
70
  * @returns Query object
73
71
  */
74
- export declare function postQueryToOracle(oracleId: Encoded.OracleAddress, query: string, options: PostQueryToOracleOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getQueryObject>>>;
75
- type PostQueryToOracleOptionsType = Parameters<typeof send>[1] & Parameters<typeof getQueryObject>[2] & BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'> & {
72
+ export declare function postQueryToOracle(oracleId: Encoded.OracleAddress, query: string, options: PostQueryToOracleOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getQueryObject>>>;
73
+ type PostQueryToOracleOptionsType = Parameters<typeof sendTransaction>[1] & Parameters<typeof getQueryObject>[2] & BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query' | 'queryTtlType' | 'queryTtlValue' | 'responseTtlType' | 'responseTtlValue'> & {
76
74
  queryTtlType?: ORACLE_TTL_TYPES;
77
75
  queryTtlValue?: number;
78
76
  responseTtlType?: ORACLE_TTL_TYPES;
@@ -83,7 +81,6 @@ interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {
83
81
  /**
84
82
  * Extend oracle ttl
85
83
  * @category oracle
86
- * @param oracleId - Oracle public key
87
84
  * @param options - Options object
88
85
  * @param options.fee - fee Transaction fee
89
86
  * @param options.ttl - Transaction time to leave
@@ -91,8 +88,8 @@ interface PostQueryToOracleOptions extends PostQueryToOracleOptionsType {
91
88
  * @param options.oracleTtlValue - Oracle time to leave for extend
92
89
  * @returns Oracle object
93
90
  */
94
- export declare function extendOracleTtl(oracleId: Encoded.OracleAddress, options: ExtendOracleTtlOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
95
- type ExtendOracleTtlOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleExtendTx, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'> & {
91
+ export declare function extendOracleTtl(options: ExtendOracleTtlOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>>;
92
+ type ExtendOracleTtlOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleExtendTx, 'oracleTtlType' | 'oracleTtlValue' | 'callerId' | 'oracleId'> & {
96
93
  oracleTtlType?: ORACLE_TTL_TYPES;
97
94
  oracleTtlValue?: number;
98
95
  };
@@ -101,7 +98,6 @@ interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {
101
98
  /**
102
99
  * Extend oracle ttl
103
100
  * @category oracle
104
- * @param oracleId - Oracle public key
105
101
  * @param queryId - Oracle query id
106
102
  * @param response - Oracle query response
107
103
  * @param options - Options object
@@ -110,8 +106,8 @@ interface ExtendOracleTtlOptions extends ExtendOracleTtlOptionsType {
110
106
  * @param options.ttl - Transaction time to leave
111
107
  * @returns Oracle object
112
108
  */
113
- export declare function respondToQuery(oracleId: Encoded.OracleAddress, queryId: Encoded.OracleQueryId, response: string, options: RespondToQueryOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
114
- type RespondToQueryOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'> & {
109
+ export declare function respondToQuery(queryId: Encoded.OracleQueryId, response: string, options: RespondToQueryOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>>;
110
+ type RespondToQueryOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleResponseTx, 'callerId' | 'oracleId' | 'queryId' | 'response' | 'responseTtlType' | 'responseTtlValue'> & {
115
111
  responseTtlType?: ORACLE_TTL_TYPES;
116
112
  responseTtlValue?: number;
117
113
  };
@@ -150,9 +146,8 @@ interface GetOracleObjectReturnType extends Awaited<ReturnType<Node['getOracleBy
150
146
  * @param options.ttl - Transaction time to leave
151
147
  * @returns Oracle object
152
148
  */
153
- export declare function registerOracle(queryFormat: string, responseFormat: string, options: RegisterOracleOptions): Promise<Awaited<ReturnType<typeof send>> & Awaited<ReturnType<typeof getOracleObject>>>;
154
- type RegisterOracleOptionsType = SendOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'queryFee' | 'oracleTtlType' | 'oracleTtlValue'> & {
155
- queryFee?: number | string | BigNumber;
149
+ export declare function registerOracle(queryFormat: string, responseFormat: string, options: RegisterOracleOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & Awaited<ReturnType<typeof getOracleObject>>>;
150
+ type RegisterOracleOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1] & BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'oracleTtlType' | 'oracleTtlValue'> & {
156
151
  oracleTtlType?: ORACLE_TTL_TYPES;
157
152
  oracleTtlValue?: number;
158
153
  };
package/es/oracle.mjs CHANGED
@@ -1,19 +1,3 @@
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
1
  /**
18
2
  * Oracle methods - routines to interact with the æternity oracle system
19
3
  *
@@ -21,16 +5,14 @@
21
5
  * https://github.com/aeternity/protocol/blob/master/ORACLE.md in the protocol
22
6
  * repository.
23
7
  */
24
- import { send } from "./spend.mjs";
25
8
  import { mapObject, pause } from "./utils/other.mjs";
26
9
  import { oracleQueryId } from "./tx/builder/helpers.mjs";
27
- import { unpackTx } from "./tx/builder/index.mjs";
28
- import { ORACLE_TTL, QUERY_FEE, QUERY_TTL, RESPONSE_TTL } from "./tx/builder/schema.mjs";
10
+ import { unpackTx, buildTxAsync } from "./tx/builder/index.mjs";
11
+ import { ORACLE_TTL, QUERY_TTL, RESPONSE_TTL } from "./tx/builder/schema.mjs";
29
12
  import { Tag } from "./tx/builder/constants.mjs";
30
13
  import { RequestTimedOutError } from "./utils/errors.mjs";
31
14
  import { decode, encode, Encoding } from "./utils/encoder.mjs";
32
- import { _getPollInterval, getHeight } from "./chain.mjs";
33
- import { _buildTx } from "./tx/index.mjs";
15
+ import { _getPollInterval, getHeight, sendTransaction } from "./chain.mjs";
34
16
  /**
35
17
  * Poll for oracle queries
36
18
  * @category oracle
@@ -58,13 +40,10 @@ export function pollForQueries(oracleId, onQuery, _ref) {
58
40
  } = _ref2;
59
41
  return !knownQueryIds.has(id);
60
42
  });
61
- queries.forEach(_ref3 => {
62
- let {
63
- id
64
- } = _ref3;
65
- return knownQueryIds.add(id);
43
+ queries.forEach(query => {
44
+ knownQueryIds.add(query.id);
45
+ onQuery(query);
66
46
  });
67
- if (queries.length > 0) onQuery(queries);
68
47
  };
69
48
  let stopped = false;
70
49
 
@@ -92,13 +71,13 @@ export function pollForQueries(oracleId, onQuery, _ref) {
92
71
  * @param options.onNode - Node to use
93
72
  * @returns OracleQuery object
94
73
  */
95
- export async function pollForQueryResponse(oracleId, queryId, _ref4) {
74
+ export async function pollForQueryResponse(oracleId, queryId, _ref3) {
96
75
  var _interval2;
97
76
  let {
98
77
  interval,
99
78
  onNode,
100
79
  ...options
101
- } = _ref4;
80
+ } = _ref3;
102
81
  (_interval2 = interval) !== null && _interval2 !== void 0 ? _interval2 : interval = _getPollInterval('microblock', options);
103
82
  let height;
104
83
  let ttl;
@@ -134,7 +113,7 @@ export async function getQueryObject(oracleId, queryId, options) {
134
113
  decodedResponse: decode(record.response).toString(),
135
114
  respond: async (response, opt) =>
136
115
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
137
- respondToQuery(oracleId, queryId, response, {
116
+ respondToQuery(queryId, response, {
138
117
  ...options,
139
118
  ...opt
140
119
  }),
@@ -161,12 +140,13 @@ export async function postQueryToOracle(oracleId, query, options) {
161
140
  var _options$queryFee;
162
141
  (_options$queryFee = options.queryFee) !== null && _options$queryFee !== void 0 ? _options$queryFee : options.queryFee = (await options.onNode.getOracleByPubkey(oracleId)).queryFee.toString();
163
142
  const senderId = options.onAccount.address;
164
- const oracleQueryTx = await _buildTx(Tag.OracleQueryTx, {
143
+ const oracleQueryTx = await buildTxAsync({
165
144
  queryTtlType: QUERY_TTL.type,
166
145
  queryTtlValue: QUERY_TTL.value,
167
146
  responseTtlType: RESPONSE_TTL.type,
168
147
  responseTtlValue: RESPONSE_TTL.value,
169
148
  ...options,
149
+ tag: Tag.OracleQueryTx,
170
150
  oracleId,
171
151
  senderId,
172
152
  query
@@ -176,14 +156,13 @@ export async function postQueryToOracle(oracleId, query, options) {
176
156
  } = unpackTx(oracleQueryTx, Tag.OracleQueryTx);
177
157
  const queryId = oracleQueryId(senderId, nonce, oracleId);
178
158
  return {
179
- ...(await send(oracleQueryTx, options)),
159
+ ...(await sendTransaction(oracleQueryTx, options)),
180
160
  ...(await getQueryObject(oracleId, queryId, options))
181
161
  };
182
162
  }
183
163
  /**
184
164
  * Extend oracle ttl
185
165
  * @category oracle
186
- * @param oracleId - Oracle public key
187
166
  * @param options - Options object
188
167
  * @param options.fee - fee Transaction fee
189
168
  * @param options.ttl - Transaction time to leave
@@ -191,16 +170,17 @@ export async function postQueryToOracle(oracleId, query, options) {
191
170
  * @param options.oracleTtlValue - Oracle time to leave for extend
192
171
  * @returns Oracle object
193
172
  */
194
- export async function extendOracleTtl(oracleId, options) {
195
- const oracleExtendTx = await _buildTx(Tag.OracleExtendTx, {
173
+ export async function extendOracleTtl(options) {
174
+ const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);
175
+ const oracleExtendTx = await buildTxAsync({
196
176
  oracleTtlType: ORACLE_TTL.type,
197
177
  oracleTtlValue: ORACLE_TTL.value,
198
178
  ...options,
199
- callerId: options.onAccount.address,
179
+ tag: Tag.OracleExtendTx,
200
180
  oracleId
201
181
  });
202
182
  return {
203
- ...(await send(oracleExtendTx, options)),
183
+ ...(await sendTransaction(oracleExtendTx, options)),
204
184
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
205
185
  ...(await getOracleObject(oracleId, options))
206
186
  };
@@ -208,7 +188,6 @@ export async function extendOracleTtl(oracleId, options) {
208
188
  /**
209
189
  * Extend oracle ttl
210
190
  * @category oracle
211
- * @param oracleId - Oracle public key
212
191
  * @param queryId - Oracle query id
213
192
  * @param response - Oracle query response
214
193
  * @param options - Options object
@@ -217,18 +196,19 @@ export async function extendOracleTtl(oracleId, options) {
217
196
  * @param options.ttl - Transaction time to leave
218
197
  * @returns Oracle object
219
198
  */
220
- export async function respondToQuery(oracleId, queryId, response, options) {
221
- const oracleRespondTx = await _buildTx(Tag.OracleResponseTx, {
199
+ export async function respondToQuery(queryId, response, options) {
200
+ const oracleId = encode(decode(options.onAccount.address), Encoding.OracleAddress);
201
+ const oracleRespondTx = await buildTxAsync({
222
202
  responseTtlType: RESPONSE_TTL.type,
223
203
  responseTtlValue: RESPONSE_TTL.value,
224
204
  ...options,
225
- callerId: options.onAccount.address,
205
+ tag: Tag.OracleResponseTx,
226
206
  oracleId,
227
207
  queryId,
228
208
  response
229
209
  });
230
210
  return {
231
- ...(await send(oracleRespondTx, options)),
211
+ ...(await sendTransaction(oracleRespondTx, options)),
232
212
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
233
213
  ...(await getOracleObject(oracleId, options))
234
214
  };
@@ -250,8 +230,8 @@ export async function getOracleObject(oracleId, options) {
250
230
  respondToQuery,
251
231
  extendOracle: extendOracleTtl,
252
232
  getQuery: getQueryObject
253
- }, _ref5 => {
254
- let [name, handler] = _ref5;
233
+ }, _ref4 => {
234
+ let [name, handler] = _ref4;
255
235
  return [name, function () {
256
236
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
257
237
  args[_key] = arguments[_key];
@@ -263,7 +243,7 @@ export async function getOracleObject(oracleId, options) {
263
243
  ...lastArg
264
244
  });
265
245
  } else args.push(options);
266
- return handler(oracleId, ...args);
246
+ return handler(...(['extendOracle', 'respondToQuery'].includes(name) ? [] : [oracleId]), ...args);
267
247
  }];
268
248
  })
269
249
  };
@@ -283,17 +263,17 @@ export async function getOracleObject(oracleId, options) {
283
263
  */
284
264
  export async function registerOracle(queryFormat, responseFormat, options) {
285
265
  const accountId = options.onAccount.address;
286
- const oracleRegisterTx = await _buildTx(Tag.OracleRegisterTx, {
287
- queryFee: QUERY_FEE,
266
+ const oracleRegisterTx = await buildTxAsync({
288
267
  oracleTtlValue: ORACLE_TTL.value,
289
268
  oracleTtlType: ORACLE_TTL.type,
290
269
  ...options,
270
+ tag: Tag.OracleRegisterTx,
291
271
  accountId,
292
272
  queryFormat,
293
273
  responseFormat
294
274
  });
295
275
  return {
296
- ...(await send(oracleRegisterTx, options)),
276
+ ...(await sendTransaction(oracleRegisterTx, options)),
297
277
  ...(await getOracleObject(encode(decode(accountId), Encoding.OracleAddress), options))
298
278
  };
299
279
  }