@aeternity/aepp-sdk 13.2.2 → 13.3.1

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 (494) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/bin/aesophia_cli +0 -0
  4. package/bin/aesophia_cli_8 +0 -0
  5. package/dist/aepp-sdk.browser-script.js +1 -1
  6. package/dist/aepp-sdk.browser-script.js.map +1 -1
  7. package/dist/aepp-sdk.browser.js +1 -1
  8. package/dist/aepp-sdk.browser.js.map +1 -1
  9. package/dist/aepp-sdk.js +9171 -7086
  10. package/dist/aepp-sdk.js.map +1 -1
  11. package/es/AeSdk.d.ts +3 -0
  12. package/es/AeSdk.mjs +12 -12
  13. package/es/AeSdk.mjs.map +1 -1
  14. package/es/AeSdkAepp.d.ts +0 -1
  15. package/es/AeSdkAepp.mjs +12 -16
  16. package/es/AeSdkAepp.mjs.map +1 -1
  17. package/es/AeSdkBase.d.ts +61 -6
  18. package/es/AeSdkBase.mjs +150 -69
  19. package/es/AeSdkBase.mjs.map +1 -1
  20. package/es/AeSdkMethods.d.ts +19 -7
  21. package/es/AeSdkMethods.mjs +39 -38
  22. package/es/AeSdkMethods.mjs.map +1 -1
  23. package/es/AeSdkWallet.mjs +86 -55
  24. package/es/AeSdkWallet.mjs.map +1 -1
  25. package/es/Middleware.mjs +31 -27
  26. package/es/Middleware.mjs.map +1 -1
  27. package/es/MiddlewareSubscriber.mjs +5 -14
  28. package/es/MiddlewareSubscriber.mjs.map +1 -1
  29. package/es/Node.d.ts +10 -2
  30. package/es/Node.mjs +53 -54
  31. package/es/Node.mjs.map +1 -1
  32. package/es/account/Base.d.ts +39 -3
  33. package/es/account/Base.mjs +35 -1
  34. package/es/account/Base.mjs.map +1 -1
  35. package/es/account/Generalized.d.ts +2 -0
  36. package/es/account/Generalized.mjs +15 -6
  37. package/es/account/Generalized.mjs.map +1 -1
  38. package/es/account/Ledger.d.ts +2 -0
  39. package/es/account/Ledger.mjs +14 -5
  40. package/es/account/Ledger.mjs.map +1 -1
  41. package/es/account/LedgerFactory.mjs +4 -6
  42. package/es/account/LedgerFactory.mjs.map +1 -1
  43. package/es/account/Memory.d.ts +15 -4
  44. package/es/account/Memory.mjs +96 -31
  45. package/es/account/Memory.mjs.map +1 -1
  46. package/es/account/Rpc.d.ts +16 -5
  47. package/es/account/Rpc.mjs +94 -21
  48. package/es/account/Rpc.mjs.map +1 -1
  49. package/es/aens.d.ts +17 -44
  50. package/es/aens.mjs +32 -71
  51. package/es/aens.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/connection/Browser.mjs +3 -4
  53. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  54. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  55. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +7 -5
  56. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  57. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +8 -9
  58. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +7 -7
  60. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/rpc/types.d.ts +14 -0
  62. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  63. package/es/aepp-wallet-communication/schema.d.ts +2 -0
  64. package/es/aepp-wallet-communication/schema.mjs +2 -0
  65. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  66. package/es/aepp-wallet-communication/wallet-detector.mjs +4 -5
  67. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  68. package/es/apis/compiler/compiler.mjs.map +1 -1
  69. package/es/apis/compiler/models/index.d.ts +1 -0
  70. package/es/apis/compiler/models/index.mjs.map +1 -1
  71. package/es/apis/compiler/models/mappers.mjs +13 -0
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  73. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  74. package/es/apis/middleware/middleware.d.ts +23 -5
  75. package/es/apis/middleware/middleware.mjs +114 -18
  76. package/es/apis/middleware/middleware.mjs.map +1 -1
  77. package/es/apis/middleware/models/index.d.ts +164 -15
  78. package/es/apis/middleware/models/index.mjs +53 -3
  79. package/es/apis/middleware/models/index.mjs.map +1 -1
  80. package/es/apis/middleware/models/mappers.d.ts +8 -1
  81. package/es/apis/middleware/models/mappers.mjs +376 -3
  82. package/es/apis/middleware/models/mappers.mjs.map +1 -1
  83. package/es/apis/middleware/models/parameters.d.ts +6 -3
  84. package/es/apis/middleware/models/parameters.mjs +38 -11
  85. package/es/apis/middleware/models/parameters.mjs.map +1 -1
  86. package/es/apis/node/models/index.d.ts +66 -2
  87. package/es/apis/node/models/index.mjs.map +1 -1
  88. package/es/apis/node/models/mappers.d.ts +5 -1
  89. package/es/apis/node/models/mappers.mjs +229 -7
  90. package/es/apis/node/models/mappers.mjs.map +1 -1
  91. package/es/apis/node/models/parameters.d.ts +2 -2
  92. package/es/apis/node/models/parameters.mjs +2 -2
  93. package/es/apis/node/models/parameters.mjs.map +1 -1
  94. package/es/apis/node/node.d.ts +24 -3
  95. package/es/apis/node/node.mjs +135 -3
  96. package/es/apis/node/node.mjs.map +1 -1
  97. package/es/chain.d.ts +14 -44
  98. package/es/chain.mjs +125 -219
  99. package/es/chain.mjs.map +1 -1
  100. package/es/channel/Base.d.ts +3 -47
  101. package/es/channel/Base.mjs +21 -54
  102. package/es/channel/Base.mjs.map +1 -1
  103. package/es/channel/Contract.d.ts +16 -25
  104. package/es/channel/Contract.mjs +39 -63
  105. package/es/channel/Contract.mjs.map +1 -1
  106. package/es/channel/Spend.d.ts +0 -8
  107. package/es/channel/Spend.mjs +17 -29
  108. package/es/channel/Spend.mjs.map +1 -1
  109. package/es/channel/handlers.mjs +1 -1
  110. package/es/channel/handlers.mjs.map +1 -1
  111. package/es/channel/internal.d.ts +104 -5
  112. package/es/channel/internal.mjs +26 -34
  113. package/es/channel/internal.mjs.map +1 -1
  114. package/es/contract/Contract.d.ts +9 -1
  115. package/es/contract/Contract.mjs +67 -73
  116. package/es/contract/Contract.mjs.map +1 -1
  117. package/es/contract/compiler/Base.d.ts +14 -8
  118. package/es/contract/compiler/Base.mjs.map +1 -1
  119. package/es/contract/compiler/Cli.d.ts +5 -9
  120. package/es/contract/compiler/Cli.mjs +45 -23
  121. package/es/contract/compiler/Cli.mjs.map +1 -1
  122. package/es/contract/compiler/Cli8.d.ts +13 -0
  123. package/es/contract/compiler/Cli8.mjs +22 -0
  124. package/es/contract/compiler/Cli8.mjs.map +1 -0
  125. package/es/contract/compiler/Http.d.ts +3 -9
  126. package/es/contract/compiler/Http.mjs +28 -16
  127. package/es/contract/compiler/Http.mjs.map +1 -1
  128. package/es/contract/compiler/HttpNode.d.ts +2 -5
  129. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  130. package/es/contract/delegation-signature.d.ts +2 -1
  131. package/es/contract/delegation-signature.mjs +18 -14
  132. package/es/contract/delegation-signature.mjs.map +1 -1
  133. package/es/contract/ga.d.ts +1 -2
  134. package/es/contract/ga.mjs +23 -25
  135. package/es/contract/ga.mjs.map +1 -1
  136. package/es/deprecated.d.ts +38 -0
  137. package/es/deprecated.mjs +45 -0
  138. package/es/deprecated.mjs.map +1 -1
  139. package/es/index-browser.d.ts +10 -5
  140. package/es/index-browser.mjs +9 -5
  141. package/es/index-browser.mjs.map +1 -1
  142. package/es/index.d.ts +1 -0
  143. package/es/index.mjs +1 -0
  144. package/es/index.mjs.map +1 -1
  145. package/es/oracle.d.ts +6 -37
  146. package/es/oracle.mjs +32 -66
  147. package/es/oracle.mjs.map +1 -1
  148. package/es/send-transaction.d.ts +53 -0
  149. package/es/send-transaction.mjs +109 -0
  150. package/es/send-transaction.mjs.map +1 -0
  151. package/es/spend.d.ts +4 -3
  152. package/es/spend.mjs +6 -1
  153. package/es/spend.mjs.map +1 -1
  154. package/es/tx/builder/common.d.ts +29 -0
  155. package/es/tx/builder/common.mjs +42 -0
  156. package/es/tx/builder/common.mjs.map +1 -0
  157. package/es/tx/builder/constants.d.ts +4 -4
  158. package/es/tx/builder/constants.mjs +6 -15
  159. package/es/tx/builder/constants.mjs.map +1 -1
  160. package/es/tx/builder/delegation/index.d.ts +20 -0
  161. package/es/tx/builder/delegation/index.mjs +24 -0
  162. package/es/tx/builder/delegation/index.mjs.map +1 -0
  163. package/es/tx/builder/delegation/schema.d.ts +130 -0
  164. package/es/tx/builder/delegation/schema.generated.d.ts +141 -0
  165. package/es/tx/builder/delegation/schema.generated.mjs +2 -0
  166. package/es/tx/builder/delegation/schema.generated.mjs.map +1 -0
  167. package/es/tx/builder/delegation/schema.mjs +54 -0
  168. package/es/tx/builder/delegation/schema.mjs.map +1 -0
  169. package/es/tx/builder/field-types/abi-version.mjs +8 -11
  170. package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
  171. package/es/tx/builder/field-types/address.mjs +1 -4
  172. package/es/tx/builder/field-types/address.mjs.map +1 -1
  173. package/es/tx/builder/field-types/coin-amount.d.ts +2 -2
  174. package/es/tx/builder/field-types/coin-amount.mjs +6 -6
  175. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  176. package/es/tx/builder/field-types/ct-version.mjs +3 -4
  177. package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
  178. package/es/tx/builder/field-types/entry.mjs +7 -13
  179. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  180. package/es/tx/builder/field-types/fee.d.ts +19 -11
  181. package/es/tx/builder/field-types/fee.mjs +56 -38
  182. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  183. package/es/tx/builder/field-types/gas-limit.mjs +13 -15
  184. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  185. package/es/tx/builder/field-types/gas-price.d.ts +10 -2
  186. package/es/tx/builder/field-types/gas-price.mjs +52 -3
  187. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  188. package/es/tx/builder/field-types/index.d.ts +31 -29
  189. package/es/tx/builder/field-types/index.mjs +31 -29
  190. package/es/tx/builder/field-types/index.mjs.map +1 -1
  191. package/es/tx/builder/field-types/map.mjs +20 -31
  192. package/es/tx/builder/field-types/map.mjs.map +1 -1
  193. package/es/tx/builder/field-types/mptree.mjs +14 -29
  194. package/es/tx/builder/field-types/mptree.mjs.map +1 -1
  195. package/es/tx/builder/field-types/name-fee.d.ts +1 -1
  196. package/es/tx/builder/field-types/name-fee.mjs +1 -1
  197. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  198. package/es/tx/builder/field-types/nonce.d.ts +1 -0
  199. package/es/tx/builder/field-types/nonce.mjs +2 -0
  200. package/es/tx/builder/field-types/nonce.mjs.map +1 -1
  201. package/es/tx/builder/field-types/pointers.mjs +4 -7
  202. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  203. package/es/tx/builder/field-types/pointers2.d.ts +23 -0
  204. package/es/tx/builder/field-types/pointers2.mjs +65 -0
  205. package/es/tx/builder/field-types/pointers2.mjs.map +1 -0
  206. package/es/tx/builder/field-types/query-fee.d.ts +19 -0
  207. package/es/tx/builder/field-types/query-fee.mjs +20 -0
  208. package/es/tx/builder/field-types/query-fee.mjs.map +1 -0
  209. package/es/tx/builder/field-types/ttl.d.ts +9 -1
  210. package/es/tx/builder/field-types/ttl.mjs +19 -8
  211. package/es/tx/builder/field-types/ttl.mjs.map +1 -1
  212. package/es/tx/builder/field-types/with-default.d.ts +7 -0
  213. package/es/tx/builder/field-types/with-default.mjs +9 -0
  214. package/es/tx/builder/field-types/with-default.mjs.map +1 -0
  215. package/es/tx/builder/field-types/with-formatting.d.ts +7 -0
  216. package/es/tx/builder/field-types/with-formatting.mjs +9 -0
  217. package/es/tx/builder/field-types/with-formatting.mjs.map +1 -0
  218. package/es/tx/builder/field-types/wrapped.mjs +6 -8
  219. package/es/tx/builder/field-types/wrapped.mjs.map +1 -1
  220. package/es/tx/builder/helpers.d.ts +2 -2
  221. package/es/tx/builder/helpers.mjs +12 -21
  222. package/es/tx/builder/helpers.mjs.map +1 -1
  223. package/es/tx/builder/index.d.ts +17 -10
  224. package/es/tx/builder/index.mjs +39 -65
  225. package/es/tx/builder/index.mjs.map +1 -1
  226. package/es/tx/builder/schema.d.ts +478 -257
  227. package/es/tx/builder/schema.generated.d.ts +39 -3
  228. package/es/tx/builder/schema.generated.mjs.map +1 -1
  229. package/es/tx/builder/schema.mjs +48 -36
  230. package/es/tx/builder/schema.mjs.map +1 -1
  231. package/es/tx/execution-cost.d.ts +6 -5
  232. package/es/tx/execution-cost.mjs +16 -17
  233. package/es/tx/execution-cost.mjs.map +1 -1
  234. package/es/tx/transaction-signer.mjs +1 -4
  235. package/es/tx/transaction-signer.mjs.map +1 -1
  236. package/es/tx/validator.mjs +61 -42
  237. package/es/tx/validator.mjs.map +1 -1
  238. package/es/utils/amount-formatter.mjs +15 -22
  239. package/es/utils/amount-formatter.mjs.map +1 -1
  240. package/es/utils/autorest.d.ts +2 -3
  241. package/es/utils/autorest.mjs +40 -24
  242. package/es/utils/autorest.mjs.map +1 -1
  243. package/es/utils/bytes.mjs +1 -2
  244. package/es/utils/bytes.mjs.map +1 -1
  245. package/es/utils/crypto.d.ts +8 -4
  246. package/es/utils/crypto.mjs +17 -13
  247. package/es/utils/crypto.mjs.map +1 -1
  248. package/es/utils/errors.d.ts +6 -0
  249. package/es/utils/errors.mjs +12 -6
  250. package/es/utils/errors.mjs.map +1 -1
  251. package/es/utils/hd-wallet.d.ts +2 -0
  252. package/es/utils/hd-wallet.mjs +6 -5
  253. package/es/utils/hd-wallet.mjs.map +1 -1
  254. package/es/utils/json-big.mjs +2 -10
  255. package/es/utils/json-big.mjs.map +1 -1
  256. package/es/utils/jwt.d.ts +53 -0
  257. package/es/utils/jwt.mjs +120 -0
  258. package/es/utils/jwt.mjs.map +1 -0
  259. package/es/utils/keystore.d.ts +6 -2
  260. package/es/utils/keystore.mjs +8 -16
  261. package/es/utils/keystore.mjs.map +1 -1
  262. package/es/utils/typed-data.mjs +1 -0
  263. package/es/utils/typed-data.mjs.map +1 -1
  264. package/es/utils/wrap-proxy.d.ts +2 -0
  265. package/es/utils/wrap-proxy.mjs +15 -0
  266. package/es/utils/wrap-proxy.mjs.map +1 -0
  267. package/package.json +57 -51
  268. package/src/AeSdk.ts +3 -0
  269. package/src/AeSdkAepp.ts +0 -1
  270. package/src/AeSdkBase.ts +97 -10
  271. package/src/AeSdkMethods.ts +37 -33
  272. package/src/AeSdkWallet.ts +22 -3
  273. package/src/Middleware.ts +16 -8
  274. package/src/MiddlewareSubscriber.ts +1 -1
  275. package/src/Node.ts +37 -18
  276. package/src/account/Base.ts +62 -3
  277. package/src/account/Generalized.ts +10 -0
  278. package/src/account/Ledger.ts +10 -0
  279. package/src/account/Memory.ts +83 -9
  280. package/src/account/Rpc.ts +69 -6
  281. package/src/aens.ts +35 -56
  282. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +3 -0
  283. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +2 -2
  284. package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -2
  285. package/src/aepp-wallet-communication/rpc/types.ts +13 -0
  286. package/src/aepp-wallet-communication/schema.ts +2 -0
  287. package/src/apis/compiler/compiler.ts +93 -93
  288. package/src/apis/compiler/models/index.ts +1 -0
  289. package/src/apis/compiler/models/mappers.ts +178 -165
  290. package/src/apis/compiler/models/parameters.ts +18 -18
  291. package/src/apis/middleware/middleware.ts +462 -341
  292. package/src/apis/middleware/models/index.ts +258 -56
  293. package/src/apis/middleware/models/mappers.ts +2357 -1919
  294. package/src/apis/middleware/models/parameters.ts +172 -142
  295. package/src/apis/node/models/index.ts +79 -2
  296. package/src/apis/node/models/mappers.ts +1529 -1302
  297. package/src/apis/node/models/parameters.ts +51 -51
  298. package/src/apis/node/node.ts +420 -275
  299. package/src/chain.ts +42 -128
  300. package/src/channel/Base.ts +14 -47
  301. package/src/channel/Contract.ts +18 -26
  302. package/src/channel/Spend.ts +0 -8
  303. package/src/channel/internal.ts +115 -13
  304. package/src/contract/Contract.ts +26 -8
  305. package/src/contract/compiler/Base.ts +15 -8
  306. package/src/contract/compiler/Cli.ts +37 -21
  307. package/src/contract/compiler/Cli8.ts +17 -0
  308. package/src/contract/compiler/Http.ts +24 -14
  309. package/src/contract/compiler/HttpNode.ts +2 -2
  310. package/src/contract/delegation-signature.ts +11 -5
  311. package/src/contract/ga.ts +4 -3
  312. package/src/deprecated.ts +36 -0
  313. package/src/index-browser.ts +14 -7
  314. package/src/index.ts +1 -0
  315. package/src/oracle.ts +11 -54
  316. package/src/send-transaction.ts +136 -0
  317. package/src/spend.ts +25 -11
  318. package/src/tx/builder/common.ts +74 -0
  319. package/src/tx/builder/constants.ts +6 -9
  320. package/src/tx/builder/delegation/index.ts +28 -0
  321. package/src/tx/builder/delegation/schema.generated.ts +143 -0
  322. package/src/tx/builder/delegation/schema.ts +61 -0
  323. package/src/tx/builder/field-types/coin-amount.ts +3 -2
  324. package/src/tx/builder/field-types/entry.ts +1 -4
  325. package/src/tx/builder/field-types/fee.ts +71 -43
  326. package/src/tx/builder/field-types/gas-limit.ts +4 -4
  327. package/src/tx/builder/field-types/gas-price.ts +70 -14
  328. package/src/tx/builder/field-types/index.ts +31 -59
  329. package/src/tx/builder/field-types/name-fee.ts +1 -1
  330. package/src/tx/builder/field-types/nonce.ts +7 -1
  331. package/src/tx/builder/field-types/pointers2.ts +62 -0
  332. package/src/tx/builder/field-types/query-fee.ts +25 -0
  333. package/src/tx/builder/field-types/ttl.ts +13 -3
  334. package/src/tx/builder/field-types/with-default.ts +18 -0
  335. package/src/tx/builder/field-types/with-formatting.ts +18 -0
  336. package/src/tx/builder/helpers.ts +2 -2
  337. package/src/tx/builder/index.ts +42 -59
  338. package/src/tx/builder/schema.generated.ts +39 -3
  339. package/src/tx/builder/schema.ts +55 -29
  340. package/src/tx/execution-cost.ts +6 -5
  341. package/src/tx/validator.ts +31 -5
  342. package/src/utils/autorest.ts +36 -27
  343. package/src/utils/crypto.ts +23 -13
  344. package/src/utils/errors.ts +10 -0
  345. package/src/utils/hd-wallet.ts +2 -0
  346. package/src/utils/jwt.ts +126 -0
  347. package/src/utils/keystore.ts +6 -2
  348. package/src/utils/wrap-proxy.ts +24 -0
  349. package/types-legacy/ts4.2/AeSdk.d.ts +3 -0
  350. package/types-legacy/ts4.2/AeSdkAepp.d.ts +0 -1
  351. package/types-legacy/ts4.2/AeSdkBase.d.ts +61 -6
  352. package/types-legacy/ts4.2/AeSdkMethods.d.ts +19 -7
  353. package/types-legacy/ts4.2/Node.d.ts +14 -1
  354. package/types-legacy/ts4.2/account/Base.d.ts +39 -3
  355. package/types-legacy/ts4.2/account/Generalized.d.ts +2 -0
  356. package/types-legacy/ts4.2/account/Ledger.d.ts +2 -0
  357. package/types-legacy/ts4.2/account/Memory.d.ts +15 -4
  358. package/types-legacy/ts4.2/account/Rpc.d.ts +16 -5
  359. package/types-legacy/ts4.2/aens.d.ts +17 -44
  360. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  361. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +14 -0
  362. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +2 -0
  363. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -0
  364. package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +23 -5
  365. package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +164 -15
  366. package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +8 -1
  367. package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +6 -3
  368. package/types-legacy/ts4.2/apis/node/models/index.d.ts +66 -2
  369. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +5 -1
  370. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  371. package/types-legacy/ts4.2/apis/node/node.d.ts +24 -3
  372. package/types-legacy/ts4.2/chain.d.ts +14 -44
  373. package/types-legacy/ts4.2/channel/Base.d.ts +3 -47
  374. package/types-legacy/ts4.2/channel/Contract.d.ts +16 -25
  375. package/types-legacy/ts4.2/channel/Spend.d.ts +0 -8
  376. package/types-legacy/ts4.2/channel/internal.d.ts +104 -5
  377. package/types-legacy/ts4.2/contract/Contract.d.ts +9 -1
  378. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +14 -8
  379. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +5 -9
  380. package/types-legacy/ts4.2/contract/compiler/Cli8.d.ts +13 -0
  381. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +3 -9
  382. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +2 -5
  383. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +2 -1
  384. package/types-legacy/ts4.2/contract/ga.d.ts +1 -2
  385. package/types-legacy/ts4.2/deprecated.d.ts +38 -0
  386. package/types-legacy/ts4.2/index-browser.d.ts +10 -5
  387. package/types-legacy/ts4.2/index.d.ts +1 -0
  388. package/types-legacy/ts4.2/oracle.d.ts +6 -37
  389. package/types-legacy/ts4.2/send-transaction.d.ts +53 -0
  390. package/types-legacy/ts4.2/spend.d.ts +4 -3
  391. package/types-legacy/ts4.2/tx/builder/common.d.ts +32 -0
  392. package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -4
  393. package/types-legacy/ts4.2/tx/builder/delegation/index.d.ts +20 -0
  394. package/types-legacy/ts4.2/tx/builder/delegation/schema.d.ts +136 -0
  395. package/types-legacy/ts4.2/tx/builder/delegation/schema.generated.d.ts +141 -0
  396. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +2 -2
  397. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +19 -11
  398. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +10 -2
  399. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +31 -29
  400. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
  401. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +1 -0
  402. package/types-legacy/ts4.2/tx/builder/field-types/pointers2.d.ts +26 -0
  403. package/types-legacy/ts4.2/tx/builder/field-types/query-fee.d.ts +19 -0
  404. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +9 -1
  405. package/types-legacy/ts4.2/tx/builder/field-types/with-default.d.ts +7 -0
  406. package/types-legacy/ts4.2/tx/builder/field-types/with-formatting.d.ts +7 -0
  407. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +2 -2
  408. package/types-legacy/ts4.2/tx/builder/index.d.ts +17 -10
  409. package/types-legacy/ts4.2/tx/builder/schema.d.ts +482 -257
  410. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +39 -3
  411. package/types-legacy/ts4.2/tx/execution-cost.d.ts +6 -5
  412. package/types-legacy/ts4.2/utils/autorest.d.ts +2 -3
  413. package/types-legacy/ts4.2/utils/crypto.d.ts +8 -4
  414. package/types-legacy/ts4.2/utils/errors.d.ts +6 -0
  415. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +2 -0
  416. package/types-legacy/ts4.2/utils/jwt.d.ts +53 -0
  417. package/types-legacy/ts4.2/utils/keystore.d.ts +6 -2
  418. package/types-legacy/ts4.2/utils/wrap-proxy.d.ts +2 -0
  419. package/types-legacy/ts4.5/AeSdk.d.ts +3 -0
  420. package/types-legacy/ts4.5/AeSdkAepp.d.ts +0 -1
  421. package/types-legacy/ts4.5/AeSdkBase.d.ts +61 -6
  422. package/types-legacy/ts4.5/AeSdkMethods.d.ts +19 -7
  423. package/types-legacy/ts4.5/Node.d.ts +14 -1
  424. package/types-legacy/ts4.5/account/Base.d.ts +39 -3
  425. package/types-legacy/ts4.5/account/Generalized.d.ts +2 -0
  426. package/types-legacy/ts4.5/account/Ledger.d.ts +2 -0
  427. package/types-legacy/ts4.5/account/Memory.d.ts +15 -4
  428. package/types-legacy/ts4.5/account/Rpc.d.ts +16 -5
  429. package/types-legacy/ts4.5/aens.d.ts +17 -44
  430. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  431. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +14 -0
  432. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +2 -0
  433. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -0
  434. package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +23 -5
  435. package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +164 -15
  436. package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +8 -1
  437. package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +6 -3
  438. package/types-legacy/ts4.5/apis/node/models/index.d.ts +66 -2
  439. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +5 -1
  440. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  441. package/types-legacy/ts4.5/apis/node/node.d.ts +24 -3
  442. package/types-legacy/ts4.5/chain.d.ts +14 -44
  443. package/types-legacy/ts4.5/channel/Base.d.ts +3 -47
  444. package/types-legacy/ts4.5/channel/Contract.d.ts +16 -25
  445. package/types-legacy/ts4.5/channel/Spend.d.ts +0 -8
  446. package/types-legacy/ts4.5/channel/internal.d.ts +104 -5
  447. package/types-legacy/ts4.5/contract/Contract.d.ts +9 -1
  448. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +14 -8
  449. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +5 -9
  450. package/types-legacy/ts4.5/contract/compiler/Cli8.d.ts +13 -0
  451. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +3 -9
  452. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +2 -5
  453. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +2 -1
  454. package/types-legacy/ts4.5/contract/ga.d.ts +1 -2
  455. package/types-legacy/ts4.5/deprecated.d.ts +38 -0
  456. package/types-legacy/ts4.5/index-browser.d.ts +10 -5
  457. package/types-legacy/ts4.5/index.d.ts +1 -0
  458. package/types-legacy/ts4.5/oracle.d.ts +6 -37
  459. package/types-legacy/ts4.5/send-transaction.d.ts +53 -0
  460. package/types-legacy/ts4.5/spend.d.ts +4 -3
  461. package/types-legacy/ts4.5/tx/builder/common.d.ts +32 -0
  462. package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -4
  463. package/types-legacy/ts4.5/tx/builder/delegation/index.d.ts +20 -0
  464. package/types-legacy/ts4.5/tx/builder/delegation/schema.d.ts +136 -0
  465. package/types-legacy/ts4.5/tx/builder/delegation/schema.generated.d.ts +141 -0
  466. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +2 -2
  467. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +19 -11
  468. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +10 -2
  469. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +31 -29
  470. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
  471. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +1 -0
  472. package/types-legacy/ts4.5/tx/builder/field-types/pointers2.d.ts +26 -0
  473. package/types-legacy/ts4.5/tx/builder/field-types/query-fee.d.ts +19 -0
  474. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +9 -1
  475. package/types-legacy/ts4.5/tx/builder/field-types/with-default.d.ts +7 -0
  476. package/types-legacy/ts4.5/tx/builder/field-types/with-formatting.d.ts +7 -0
  477. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +2 -2
  478. package/types-legacy/ts4.5/tx/builder/index.d.ts +17 -10
  479. package/types-legacy/ts4.5/tx/builder/schema.d.ts +482 -257
  480. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +39 -3
  481. package/types-legacy/ts4.5/tx/execution-cost.d.ts +6 -5
  482. package/types-legacy/ts4.5/utils/autorest.d.ts +2 -3
  483. package/types-legacy/ts4.5/utils/crypto.d.ts +8 -4
  484. package/types-legacy/ts4.5/utils/errors.d.ts +6 -0
  485. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +2 -0
  486. package/types-legacy/ts4.5/utils/jwt.d.ts +53 -0
  487. package/types-legacy/ts4.5/utils/keystore.d.ts +6 -2
  488. package/types-legacy/ts4.5/utils/wrap-proxy.d.ts +2 -0
  489. package/es/tx/builder/field-types/deposit.d.ts +0 -15
  490. package/es/tx/builder/field-types/deposit.mjs +0 -18
  491. package/es/tx/builder/field-types/deposit.mjs.map +0 -1
  492. package/src/tx/builder/field-types/deposit.ts +0 -23
  493. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +0 -15
  494. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +0 -15
@@ -18,7 +18,9 @@ import {
18
18
  WalletApi,
19
19
  WalletInfo,
20
20
  } from './aepp-wallet-communication/rpc/types';
21
- import { Encoded } from './utils/encoder';
21
+ import {
22
+ Encoded, Encoding, encode, decode,
23
+ } from './utils/encoder';
22
24
  import jsonBig from './utils/json-big';
23
25
 
24
26
  type RpcClientWallet = RpcClient<AeppApi, WalletApi>;
@@ -302,23 +304,40 @@ export default class AeSdkWallet extends AeSdk {
302
304
  };
303
305
  },
304
306
  [METHODS.signDelegationToContract]: async ({
305
- contractAddress, name, oracleQueryId, onAccount = this.address,
307
+ contractAddress, name, oracleQueryId, allNames, onAccount = this.address, isOracle,
306
308
  }, origin) => {
307
309
  if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
308
310
  if (!this.addresses().includes(onAccount)) {
309
311
  throw new RpcPermissionDenyError(onAccount);
310
312
  }
311
313
 
314
+ isOracle ??= false;
312
315
  const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };
313
316
  const signature = await (
314
317
  (name == null ? null : this
315
318
  .signNameDelegationToContract(contractAddress, name, parameters))
316
319
  ?? (oracleQueryId == null ? null : this
317
320
  .signOracleQueryDelegationToContract(contractAddress, oracleQueryId, parameters))
318
- ?? this.signDelegationToContract(contractAddress, parameters)
321
+ ?? (allNames !== true ? null : this
322
+ .signAllNamesDelegationToContract(contractAddress, parameters))
323
+ ?? this.signDelegationToContract(contractAddress, { ...parameters, isOracle })
319
324
  );
320
325
  return { signature };
321
326
  },
327
+ [METHODS.unsafeSign]: async ({ data, onAccount = this.address }, origin) => {
328
+ if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
329
+ if (!this.addresses().includes(onAccount)) throw new RpcPermissionDenyError(onAccount);
330
+ const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };
331
+ const signature = encode(await this.sign(decode(data), parameters), Encoding.Signature);
332
+ return { signature };
333
+ },
334
+ [METHODS.signDelegation]: async ({ delegation, onAccount = this.address }, origin) => {
335
+ if (!this._isRpcClientConnected(id)) throw new RpcNotAuthorizeError();
336
+ if (!this.addresses().includes(onAccount)) throw new RpcPermissionDenyError(onAccount);
337
+ const parameters = { onAccount, aeppOrigin: origin, aeppRpcClientId: id };
338
+ const signature = await this.signDelegation(delegation, parameters);
339
+ return { signature };
340
+ },
322
341
  },
323
342
  ),
324
343
  };
package/src/Middleware.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // eslint-disable-next-line max-classes-per-file
2
2
  import BigNumber from 'bignumber.js';
3
- import { OperationArguments, OperationSpec } from '@azure/core-client';
3
+ import { OperationArguments, OperationOptions, OperationSpec } from '@azure/core-client';
4
+ import { userAgentPolicyName, setClientRequestIdPolicyName } from '@azure/core-rest-pipeline';
4
5
  import {
5
6
  genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,
6
7
  genVersionCheckPolicy, genRetryOnFailurePolicy,
@@ -119,10 +120,20 @@ export default class Middleware
119
120
  retryOverallDelay?: number;
120
121
  } = {},
121
122
  ) {
123
+ let version: string | undefined;
124
+ const getVersion = async (opts: OperationOptions): Promise<string> => {
125
+ if (version != null) return version;
126
+ version = (await this.getStatus(opts)).mdwVersion;
127
+ return version;
128
+ };
129
+
122
130
  // eslint-disable-next-line constructor-super
123
131
  super(url, {
124
132
  allowInsecureConnection: true,
125
133
  additionalPolicies: [
134
+ ...ignoreVersion ? [] : [
135
+ genVersionCheckPolicy('middleware', getVersion, '1.47.0', '2.0.0'),
136
+ ],
126
137
  genRequestQueuesPolicy(),
127
138
  genCombineGetRequestsPolicy(),
128
139
  genRetryOnFailurePolicy(retryCount, retryOverallDelay),
@@ -130,12 +141,9 @@ export default class Middleware
130
141
  ],
131
142
  ...options,
132
143
  });
133
- if (!ignoreVersion) {
134
- const statusPromise = this.getStatus();
135
- const versionPromise = statusPromise.then(({ mdwVersion }) => mdwVersion, (error) => error);
136
- this.pipeline.addPolicy(
137
- genVersionCheckPolicy('middleware', '/v2/status', versionPromise, '1.47.0', '2.0.0'),
138
- );
139
- }
144
+ this.pipeline.removePolicy({ name: userAgentPolicyName });
145
+ this.pipeline.removePolicy({ name: setClientRequestIdPolicyName });
146
+ // TODO: use instead our retry policy
147
+ this.pipeline.removePolicy({ name: 'defaultRetryPolicy' });
140
148
  }
141
149
  }
@@ -35,7 +35,7 @@ export default class MiddlewareSubscriber {
35
35
  readonly [target: string, s: Source, cb: (p?: Object, e?: Error) => void]
36
36
  > = [];
37
37
 
38
- #requestQueue: Array<[isSubscribe: boolean, target: string]> = [];
38
+ readonly #requestQueue: Array<[isSubscribe: boolean, target: string]> = [];
39
39
 
40
40
  #webSocket?: WebSocket;
41
41
 
package/src/Node.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // eslint-disable-next-line max-classes-per-file
2
2
  import BigNumber from 'bignumber.js';
3
- import { OperationArguments, OperationSpec } from '@azure/core-client';
3
+ import { OperationArguments, OperationOptions, OperationSpec } from '@azure/core-client';
4
+ import { userAgentPolicyName, setClientRequestIdPolicyName } from '@azure/core-rest-pipeline';
4
5
  import {
5
6
  genRequestQueuesPolicy, genCombineGetRequestsPolicy, genErrorFormatterPolicy,
6
7
  genVersionCheckPolicy, genRetryOnFailurePolicy,
@@ -14,7 +15,7 @@ import { ConsensusProtocolVersion } from './tx/builder/constants';
14
15
  const bigIntPropertyNames = [
15
16
  'balance', 'queryFee', 'fee', 'amount', 'nameFee', 'channelAmount',
16
17
  'initiatorAmount', 'responderAmount', 'channelReserve', 'initiatorAmountFinal',
17
- 'responderAmountFinal', 'gasPrice', 'deposit',
18
+ 'responderAmountFinal', 'gasPrice', 'minGasPrice', 'deposit',
18
19
  ] as const;
19
20
 
20
21
  const numberPropertyNames = [
@@ -22,7 +23,7 @@ const numberPropertyNames = [
22
23
  'nonce', 'nextNonce', 'height', 'blockHeight', 'topBlockHeight',
23
24
  'ttl', 'nameTtl', 'clientTtl',
24
25
  'inbound', 'outbound', 'peerCount', 'pendingTransactionsCount', 'effectiveAtHeight',
25
- 'version', 'solutions', 'round',
26
+ 'version', 'solutions', 'round', 'minutes', 'utilization', 'difficulty', 'hashrate',
26
27
  ] as const;
27
28
 
28
29
  class NodeTransformed extends NodeApi {
@@ -112,8 +113,6 @@ interface NodeInfo {
112
113
  }
113
114
 
114
115
  export default class Node extends (NodeTransformed as unknown as NodeTransformedApi) {
115
- #networkIdPromise?: Promise<string | Error>;
116
-
117
116
  /**
118
117
  * @param url - Url for node API
119
118
  * @param options - Options
@@ -131,33 +130,53 @@ export default class Node extends (NodeTransformed as unknown as NodeTransformed
131
130
  retryOverallDelay?: number;
132
131
  } = {},
133
132
  ) {
133
+ const getVersion = async (opts: OperationOptions): Promise<string> => (
134
+ (await this._getCachedStatus(opts)).nodeVersion
135
+ );
134
136
  // eslint-disable-next-line constructor-super
135
137
  super(url, {
136
138
  allowInsecureConnection: true,
137
139
  additionalPolicies: [
140
+ ...ignoreVersion ? [] : [genVersionCheckPolicy('node', getVersion, '6.2.0', '8.0.0')],
138
141
  genRequestQueuesPolicy(),
139
142
  genCombineGetRequestsPolicy(),
140
143
  genRetryOnFailurePolicy(retryCount, retryOverallDelay),
141
- genErrorFormatterPolicy((body: ErrorModel) => ` ${body.reason}`),
144
+ genErrorFormatterPolicy((body: ErrorModel) => [
145
+ ' ', body.reason, body.errorCode == null ? '' : ` (${body.errorCode})`,
146
+ ].join('')),
142
147
  ],
143
148
  ...options,
144
149
  });
145
- if (!ignoreVersion) {
146
- const statusPromise = this.getStatus();
147
- const versionPromise = statusPromise.then(({ nodeVersion }) => nodeVersion, (error) => error);
148
- this.#networkIdPromise = statusPromise.then(({ networkId }) => networkId, (error) => error);
149
- this.pipeline.addPolicy(
150
- genVersionCheckPolicy('node', '/v3/status', versionPromise, '6.2.0', '7.0.0'),
151
- );
152
- }
150
+ this.pipeline.removePolicy({ name: userAgentPolicyName });
151
+ this.pipeline.removePolicy({ name: setClientRequestIdPolicyName });
152
+ // TODO: use instead our retry policy
153
+ this.pipeline.removePolicy({ name: 'defaultRetryPolicy' });
153
154
  this.intAsString = true;
154
155
  }
155
156
 
157
+ #cachedStatusPromise?: ReturnType<Node['getStatus']>;
158
+
159
+ async _getCachedStatus(options?: OperationOptions): ReturnType<Node['getStatus']> {
160
+ if (this.#cachedStatusPromise != null) return this.#cachedStatusPromise;
161
+ return this.getStatus(options);
162
+ }
163
+
164
+ // eslint-disable-next-line rulesdir/tsdoc-syntax
165
+ /** @ts-expect-error use code generation to create node class? */
166
+ override async getStatus(
167
+ ...args: Parameters<InstanceType<NodeTransformedApi>['getStatus']>
168
+ ): ReturnType<InstanceType<NodeTransformedApi>['getStatus']> {
169
+ const promise = super.getStatus(...args);
170
+ promise.then(() => { this.#cachedStatusPromise = promise; }, () => {});
171
+ return promise;
172
+ }
173
+
174
+ /**
175
+ * Returns network ID provided by node.
176
+ * This method won't do extra requests on subsequent calls.
177
+ */
156
178
  async getNetworkId(): Promise<string> {
157
- this.#networkIdPromise ??= this.getStatus().then(({ networkId }) => networkId);
158
- const networkId = await this.#networkIdPromise;
159
- if (networkId instanceof Error) throw networkId;
160
- return networkId;
179
+ return (await this._getCachedStatus()).networkId;
161
180
  }
162
181
 
163
182
  async getNodeInfo(): Promise<NodeInfo> {
@@ -1,7 +1,7 @@
1
1
  import { Encoded } from '../utils/encoder';
2
2
  import Node from '../Node';
3
3
  import CompilerBase from '../contract/compiler/Base';
4
- import { AensName, Int } from '../tx/builder/constants';
4
+ import { AensName, ConsensusProtocolVersion, Int } from '../tx/builder/constants';
5
5
  import { AciValue, Domain } from '../utils/typed-data';
6
6
  import { NotImplementedError } from '../utils/errors';
7
7
 
@@ -56,8 +56,8 @@ export default abstract class AccountBase {
56
56
 
57
57
  /**
58
58
  * Sign typed data
59
- * @param type - Type of data to sign
60
59
  * @param data - Encoded data to sign
60
+ * @param aci - Type of data to sign
61
61
  * @param options - Options
62
62
  * @returns Signature
63
63
  */
@@ -80,7 +80,10 @@ export default abstract class AccountBase {
80
80
  * Sign delegation of AENS, oracle operations to a contract
81
81
  * @param contractAddress - Address of a contract to delegate permissions to
82
82
  * @param options - Options
83
+ * @param options.isOracle - Use to generate an oracle delegation signature in Ceres, otherwise an
84
+ * AENS preclaim delegation signature would be generated
83
85
  * @returns Signature
86
+ * @deprecated use AccountBase:signDelegation in Ceres
84
87
  */
85
88
  // TODO: make abstract in the next major release
86
89
  // eslint-disable-next-line class-methods-use-this
@@ -89,6 +92,8 @@ export default abstract class AccountBase {
89
92
  contractAddress: Encoded.ContractAddress,
90
93
  options?: {
91
94
  networkId?: string;
95
+ consensusProtocolVersion?: ConsensusProtocolVersion;
96
+ isOracle?: boolean;
92
97
  aeppOrigin?: string;
93
98
  aeppRpcClientId?: string;
94
99
  },
@@ -103,6 +108,7 @@ export default abstract class AccountBase {
103
108
  * @param name - AENS name to manage by a contract
104
109
  * @param options - Options
105
110
  * @returns Signature
111
+ * @deprecated use AccountBase:signDelegation in Ceres
106
112
  */
107
113
  // TODO: make abstract in the next major release
108
114
  // eslint-disable-next-line class-methods-use-this
@@ -112,6 +118,7 @@ export default abstract class AccountBase {
112
118
  name: AensName,
113
119
  options?: {
114
120
  networkId?: string;
121
+ consensusProtocolVersion?: ConsensusProtocolVersion;
115
122
  aeppOrigin?: string;
116
123
  aeppRpcClientId?: string;
117
124
  },
@@ -120,6 +127,29 @@ export default abstract class AccountBase {
120
127
  throw new NotImplementedError('signNameDelegationToContract method');
121
128
  }
122
129
 
130
+ /**
131
+ * Sign delegation of all AENS names to a contract (not available in Iris)
132
+ * @param contractAddress - Address of a contract to delegate permissions to
133
+ * @param options - Options
134
+ * @returns Signature
135
+ * @deprecated use AccountBase:signDelegation in Ceres
136
+ */
137
+ // TODO: make abstract in the next major release
138
+ // eslint-disable-next-line class-methods-use-this
139
+ async signAllNamesDelegationToContract(
140
+ /* eslint-disable @typescript-eslint/no-unused-vars */
141
+ contractAddress: Encoded.ContractAddress,
142
+ options?: {
143
+ networkId?: string;
144
+ consensusProtocolVersion?: ConsensusProtocolVersion;
145
+ aeppOrigin?: string;
146
+ aeppRpcClientId?: string;
147
+ },
148
+ /* eslint-enable @typescript-eslint/no-unused-vars */
149
+ ): Promise<Encoded.Signature> {
150
+ throw new NotImplementedError('signAllNamesDelegationToContract method');
151
+ }
152
+
123
153
  /**
124
154
  * Sign delegation of oracle query to a contract
125
155
  *
@@ -133,6 +163,7 @@ export default abstract class AccountBase {
133
163
  * @param oracleQueryId - Oracle query ID to reply by a contract
134
164
  * @param options - Options
135
165
  * @returns Signature
166
+ * @deprecated use AccountBase:signDelegation in Ceres
136
167
  */
137
168
  // TODO: make abstract in the next major release
138
169
  // eslint-disable-next-line class-methods-use-this
@@ -142,6 +173,7 @@ export default abstract class AccountBase {
142
173
  oracleQueryId: Encoded.OracleQueryId,
143
174
  options?: {
144
175
  networkId?: string;
176
+ consensusProtocolVersion?: ConsensusProtocolVersion;
145
177
  aeppOrigin?: string;
146
178
  aeppRpcClientId?: string;
147
179
  },
@@ -156,10 +188,37 @@ export default abstract class AccountBase {
156
188
  * @param options - Options
157
189
  * @returns Signature
158
190
  */
159
- abstract sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
191
+ abstract sign(
192
+ data: string | Uint8Array,
193
+ options?: {
194
+ aeppOrigin?: string;
195
+ aeppRpcClientId?: string;
196
+ },
197
+ ): Promise<Uint8Array>;
160
198
 
161
199
  /**
162
200
  * Account address
163
201
  */
164
202
  readonly address!: Encoded.AccountAddress;
203
+
204
+ /**
205
+ * Sign delegation, works only in Ceres
206
+ * @param delegation - Delegation to sign
207
+ * @param options - Options
208
+ * @returns Signature
209
+ */
210
+ // TODO: make abstract in the next major release
211
+ // eslint-disable-next-line class-methods-use-this
212
+ async signDelegation(
213
+ /* eslint-disable @typescript-eslint/no-unused-vars */
214
+ delegation: Encoded.Bytearray,
215
+ options?: {
216
+ networkId?: string;
217
+ aeppOrigin?: string;
218
+ aeppRpcClientId?: string;
219
+ },
220
+ /* eslint-enable @typescript-eslint/no-unused-vars */
221
+ ): Promise<Encoded.Signature> {
222
+ throw new NotImplementedError('signDelegation method');
223
+ }
165
224
  }
@@ -53,11 +53,21 @@ export default class AccountGeneralized extends AccountBase {
53
53
  throw new NotImplementedError('signing delegation to contract using generalized account');
54
54
  }
55
55
 
56
+ // eslint-disable-next-line class-methods-use-this
57
+ override async signAllNamesDelegationToContract(): Promise<Encoded.Signature> {
58
+ throw new NotImplementedError('signing delegation to contract using generalized account');
59
+ }
60
+
56
61
  // eslint-disable-next-line class-methods-use-this
57
62
  override async signOracleQueryDelegationToContract(): Promise<Encoded.Signature> {
58
63
  throw new NotImplementedError('signing delegation to contract using generalized account');
59
64
  }
60
65
 
66
+ // eslint-disable-next-line class-methods-use-this
67
+ override async signDelegation(): Promise<Encoded.Signature> {
68
+ throw new NotImplementedError('signing delegation using generalized account');
69
+ }
70
+
61
71
  override async signTransaction(
62
72
  tx: Encoded.Transaction,
63
73
  { authData, onCompiler, onNode }: Parameters<AccountBase['signTransaction']>[1],
@@ -55,11 +55,21 @@ export default class AccountLedger extends AccountBase {
55
55
  throw new NotImplementedError('signing delegation to contract using Ledger HW');
56
56
  }
57
57
 
58
+ // eslint-disable-next-line class-methods-use-this
59
+ override async signAllNamesDelegationToContract(): Promise<Encoded.Signature> {
60
+ throw new NotImplementedError('signing delegation to contract using Ledger HW');
61
+ }
62
+
58
63
  // eslint-disable-next-line class-methods-use-this
59
64
  override async signOracleQueryDelegationToContract(): Promise<Encoded.Signature> {
60
65
  throw new NotImplementedError('signing delegation to contract using Ledger HW');
61
66
  }
62
67
 
68
+ // eslint-disable-next-line class-methods-use-this
69
+ override async signDelegation(): Promise<Encoded.Signature> {
70
+ throw new NotImplementedError('signing delegation using Ledger HW');
71
+ }
72
+
63
73
  override async signTransaction(
64
74
  tx: Encoded.Transaction,
65
75
  { innerTx, networkId }: { innerTx?: boolean; networkId?: string } = {},
@@ -1,18 +1,20 @@
1
1
  import AccountBase from './Base';
2
2
  import {
3
- generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash,
3
+ generateKeyPairFromSecret, sign, generateKeyPair, hash, messageToHash, messagePrefixLength,
4
4
  } from '../utils/crypto';
5
- import { ArgumentError } from '../utils/errors';
5
+ import { ArgumentError, UnexpectedTsError } from '../utils/errors';
6
6
  import {
7
7
  decode, encode, Encoded, Encoding,
8
8
  } from '../utils/encoder';
9
9
  import { concatBuffers } from '../utils/other';
10
10
  import { hashTypedData, AciValue } from '../utils/typed-data';
11
11
  import { buildTx } from '../tx/builder';
12
- import { Tag, AensName } from '../tx/builder/constants';
12
+ import { Tag, AensName, ConsensusProtocolVersion } from '../tx/builder/constants';
13
13
  import { produceNameId } from '../tx/builder/helpers';
14
+ import { DelegationTag } from '../tx/builder/delegation/schema';
15
+ import { packDelegation } from '../tx/builder/delegation';
14
16
 
15
- const secretKeys = new WeakMap();
17
+ const secretKeys = new WeakMap<AccountMemory, Uint8Array>();
16
18
 
17
19
  export function getBufferToSign(
18
20
  transaction: Encoded.Transaction,
@@ -42,7 +44,7 @@ export default class AccountMemory extends AccountBase {
42
44
  }
43
45
  secretKeys.set(this, secretKey);
44
46
  this.address = encode(
45
- generateKeyPairFromSecret(secretKeys.get(this)).publicKey,
47
+ generateKeyPairFromSecret(secretKey).publicKey,
46
48
  Encoding.AccountAddress,
47
49
  );
48
50
  }
@@ -56,7 +58,9 @@ export default class AccountMemory extends AccountBase {
56
58
 
57
59
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
58
60
  override async sign(data: string | Uint8Array, options?: any): Promise<Uint8Array> {
59
- return sign(data, secretKeys.get(this));
61
+ const secretKey = secretKeys.get(this);
62
+ if (secretKey == null) throw new UnexpectedTsError();
63
+ return sign(data, secretKey);
60
64
  }
61
65
 
62
66
  override async signTransaction(
@@ -93,8 +97,24 @@ export default class AccountMemory extends AccountBase {
93
97
 
94
98
  override async signDelegationToContract(
95
99
  contractAddress: Encoded.ContractAddress,
96
- { networkId }: { networkId?: string } = {},
100
+ { networkId, consensusProtocolVersion, isOracle }: {
101
+ networkId?: string;
102
+ consensusProtocolVersion?: ConsensusProtocolVersion;
103
+ isOracle?: boolean;
104
+ } = {},
97
105
  ): Promise<Encoded.Signature> {
106
+ if (isOracle == null) {
107
+ const protocol = (consensusProtocolVersion != null) ? ConsensusProtocolVersion[consensusProtocolVersion] : 'unknown';
108
+ console.warn(`AccountMemory:signDelegationToContract: isOracle is not set. By default, sdk would generate an AENS preclaim delegation signature, but it won't be the same as the oracle delegation signature in Ceres (current protocol is ${protocol}).`);
109
+ }
110
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
111
+ const delegation = packDelegation({
112
+ tag: isOracle === true ? DelegationTag.Oracle : DelegationTag.AensPreclaim,
113
+ accountAddress: this.address,
114
+ contractAddress,
115
+ });
116
+ return this.signDelegation(delegation, { networkId });
117
+ }
98
118
  if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
99
119
  const payload = concatBuffers([
100
120
  Buffer.from(networkId),
@@ -108,8 +128,17 @@ export default class AccountMemory extends AccountBase {
108
128
  override async signNameDelegationToContract(
109
129
  contractAddress: Encoded.ContractAddress,
110
130
  name: AensName,
111
- { networkId }: { networkId?: string } = {},
131
+ { networkId, consensusProtocolVersion }: {
132
+ networkId?: string;
133
+ consensusProtocolVersion?: ConsensusProtocolVersion;
134
+ } = {},
112
135
  ): Promise<Encoded.Signature> {
136
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
137
+ const delegation = packDelegation({
138
+ tag: DelegationTag.AensName, accountAddress: this.address, contractAddress, nameId: name,
139
+ });
140
+ return this.signDelegation(delegation, { networkId });
141
+ }
113
142
  if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
114
143
  const payload = concatBuffers([
115
144
  Buffer.from(networkId),
@@ -121,11 +150,44 @@ export default class AccountMemory extends AccountBase {
121
150
  return encode(signature, Encoding.Signature);
122
151
  }
123
152
 
153
+ override async signAllNamesDelegationToContract(
154
+ contractAddress: Encoded.ContractAddress,
155
+ { networkId, consensusProtocolVersion }: {
156
+ networkId?: string;
157
+ consensusProtocolVersion?: ConsensusProtocolVersion;
158
+ } = {},
159
+ ): Promise<Encoded.Signature> {
160
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
161
+ const delegation = packDelegation({
162
+ tag: DelegationTag.AensWildcard, accountAddress: this.address, contractAddress,
163
+ });
164
+ return this.signDelegation(delegation, { networkId });
165
+ }
166
+ if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
167
+ const payload = concatBuffers([
168
+ Buffer.from(networkId),
169
+ decode(this.address),
170
+ Buffer.from('AENS'),
171
+ decode(contractAddress),
172
+ ]);
173
+ const signature = await this.sign(payload);
174
+ return encode(signature, Encoding.Signature);
175
+ }
176
+
124
177
  override async signOracleQueryDelegationToContract(
125
178
  contractAddress: Encoded.ContractAddress,
126
179
  oracleQueryId: Encoded.OracleQueryId,
127
- { networkId }: { networkId?: string } = {},
180
+ { networkId, consensusProtocolVersion }: {
181
+ networkId?: string;
182
+ consensusProtocolVersion?: ConsensusProtocolVersion;
183
+ } = {},
128
184
  ): Promise<Encoded.Signature> {
185
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
186
+ const delegation = packDelegation({
187
+ tag: DelegationTag.OracleResponse, queryId: oracleQueryId, contractAddress,
188
+ });
189
+ return this.signDelegation(delegation, { networkId });
190
+ }
129
191
  const oracleQueryIdDecoded = decode(oracleQueryId);
130
192
  const addressDecoded = decode(this.address);
131
193
  // TODO: remove after fixing https://github.com/aeternity/aesophia/issues/475
@@ -141,4 +203,16 @@ export default class AccountMemory extends AccountBase {
141
203
  const signature = await this.sign(payload);
142
204
  return encode(signature, Encoding.Signature);
143
205
  }
206
+
207
+ override async signDelegation(
208
+ delegation: Encoded.Bytearray,
209
+ { networkId }: { networkId?: string } = {},
210
+ ): Promise<Encoded.Signature> {
211
+ if (networkId == null) throw new ArgumentError('networkId', 'provided', networkId);
212
+ const payload = concatBuffers([
213
+ messagePrefixLength, new Uint8Array([1]), Buffer.from(networkId), decode(delegation),
214
+ ]);
215
+ const signature = await this.sign(payload);
216
+ return encode(signature, Encoding.Signature);
217
+ }
144
218
  }
@@ -1,10 +1,14 @@
1
1
  import AccountBase from './Base';
2
2
  import { METHODS } from '../aepp-wallet-communication/schema';
3
- import { ArgumentError, NotImplementedError, UnsupportedProtocolError } from '../utils/errors';
4
- import { Encoded } from '../utils/encoder';
3
+ import { ArgumentError, UnsupportedProtocolError } from '../utils/errors';
4
+ import {
5
+ Encoded, Encoding, decode, encode,
6
+ } from '../utils/encoder';
5
7
  import RpcClient from '../aepp-wallet-communication/rpc/RpcClient';
6
8
  import { AeppApi, WalletApi } from '../aepp-wallet-communication/rpc/types';
7
- import { AensName } from '../tx/builder/constants';
9
+ import { AensName, ConsensusProtocolVersion } from '../tx/builder/constants';
10
+ import { packDelegation } from '../tx/builder/delegation';
11
+ import { DelegationTag } from '../tx/builder/delegation/schema';
8
12
 
9
13
  /**
10
14
  * Account provided by wallet
@@ -24,9 +28,11 @@ export default class AccountRpc extends AccountBase {
24
28
  this.address = address;
25
29
  }
26
30
 
27
- // eslint-disable-next-line class-methods-use-this
28
- async sign(): Promise<Uint8Array> {
29
- throw new NotImplementedError('RAW signing using wallet');
31
+ async sign(dataRaw: string | Uint8Array): Promise<Uint8Array> {
32
+ const data = encode(Buffer.from(dataRaw), Encoding.Bytearray);
33
+ const { signature } = await this._rpcClient
34
+ .request(METHODS.unsafeSign, { onAccount: this.address, data });
35
+ return decode(signature);
30
36
  }
31
37
 
32
38
  override async signTransaction(
@@ -73,10 +79,27 @@ export default class AccountRpc extends AccountBase {
73
79
 
74
80
  override async signDelegationToContract(
75
81
  contractAddress: Encoded.ContractAddress,
82
+ { consensusProtocolVersion, isOracle }: {
83
+ consensusProtocolVersion?: ConsensusProtocolVersion;
84
+ isOracle?: boolean;
85
+ } = {},
76
86
  ): Promise<Encoded.Signature> {
87
+ if (isOracle == null) {
88
+ const protocol = (consensusProtocolVersion != null) ? ConsensusProtocolVersion[consensusProtocolVersion] : 'unknown';
89
+ console.warn(`AccountRpc:signDelegationToContract: isOracle is not set. By default, sdk would generate an AENS preclaim delegation signature, but it won't be the same as the oracle delegation signature in Ceres (current protocol is ${protocol}).`);
90
+ }
91
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
92
+ const delegation = packDelegation({
93
+ tag: isOracle === true ? DelegationTag.Oracle : DelegationTag.AensPreclaim,
94
+ accountAddress: this.address,
95
+ contractAddress,
96
+ });
97
+ return this.signDelegation(delegation);
98
+ }
77
99
  const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
78
100
  onAccount: this.address,
79
101
  contractAddress,
102
+ isOracle,
80
103
  });
81
104
  return signature;
82
105
  }
@@ -84,7 +107,14 @@ export default class AccountRpc extends AccountBase {
84
107
  override async signNameDelegationToContract(
85
108
  contractAddress: Encoded.ContractAddress,
86
109
  name: AensName,
110
+ { consensusProtocolVersion }: { consensusProtocolVersion?: ConsensusProtocolVersion } = {},
87
111
  ): Promise<Encoded.Signature> {
112
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
113
+ const delegation = packDelegation({
114
+ tag: DelegationTag.AensName, accountAddress: this.address, contractAddress, nameId: name,
115
+ });
116
+ return this.signDelegation(delegation);
117
+ }
88
118
  const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
89
119
  onAccount: this.address,
90
120
  contractAddress,
@@ -93,10 +123,35 @@ export default class AccountRpc extends AccountBase {
93
123
  return signature;
94
124
  }
95
125
 
126
+ override async signAllNamesDelegationToContract(
127
+ contractAddress: Encoded.ContractAddress,
128
+ { consensusProtocolVersion }: { consensusProtocolVersion?: ConsensusProtocolVersion } = {},
129
+ ): Promise<Encoded.Signature> {
130
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
131
+ const delegation = packDelegation({
132
+ tag: DelegationTag.AensWildcard, accountAddress: this.address, contractAddress,
133
+ });
134
+ return this.signDelegation(delegation);
135
+ }
136
+ const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
137
+ onAccount: this.address,
138
+ contractAddress,
139
+ allNames: true,
140
+ });
141
+ return signature;
142
+ }
143
+
96
144
  override async signOracleQueryDelegationToContract(
97
145
  contractAddress: Encoded.ContractAddress,
98
146
  oracleQueryId: Encoded.OracleQueryId,
147
+ { consensusProtocolVersion }: { consensusProtocolVersion?: ConsensusProtocolVersion } = {},
99
148
  ): Promise<Encoded.Signature> {
149
+ if (consensusProtocolVersion === ConsensusProtocolVersion.Ceres) {
150
+ const delegation = packDelegation({
151
+ tag: DelegationTag.OracleResponse, queryId: oracleQueryId, contractAddress,
152
+ });
153
+ return this.signDelegation(delegation);
154
+ }
100
155
  const { signature } = await this._rpcClient.request(METHODS.signDelegationToContract, {
101
156
  onAccount: this.address,
102
157
  contractAddress,
@@ -104,4 +159,12 @@ export default class AccountRpc extends AccountBase {
104
159
  });
105
160
  return signature;
106
161
  }
162
+
163
+ override async signDelegation(delegation: Encoded.Bytearray): Promise<Encoded.Signature> {
164
+ const { signature } = await this._rpcClient.request(
165
+ METHODS.signDelegation,
166
+ { delegation, onAccount: this.address },
167
+ );
168
+ return signature;
169
+ }
107
170
  }