@aeternity/aepp-sdk 11.0.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/LICENSE +1 -1
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +12 -19
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +1 -1
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +1 -1
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdk.d.ts +37 -0
  10. package/es/AeSdk.mjs +81 -0
  11. package/es/AeSdk.mjs.map +1 -0
  12. package/es/AeSdkAepp.d.ts +69 -0
  13. package/es/AeSdkAepp.mjs +175 -0
  14. package/es/AeSdkAepp.mjs.map +1 -0
  15. package/es/AeSdkBase.d.ts +212 -0
  16. package/es/AeSdkBase.mjs +310 -0
  17. package/es/AeSdkBase.mjs.map +1 -0
  18. package/es/AeSdkWallet.d.ts +103 -0
  19. package/es/AeSdkWallet.mjs +322 -0
  20. package/es/AeSdkWallet.mjs.map +1 -0
  21. package/es/Node.d.ts +44 -0
  22. package/es/Node.mjs +141 -0
  23. package/es/Node.mjs.map +1 -0
  24. package/es/account/Base.d.ts +65 -0
  25. package/es/account/Base.mjs +123 -0
  26. package/es/account/Base.mjs.map +1 -0
  27. package/es/account/Memory.d.ts +25 -0
  28. package/es/account/Memory.mjs +81 -0
  29. package/es/account/Memory.mjs.map +1 -0
  30. package/es/account/Rpc.d.ts +27 -0
  31. package/es/account/Rpc.mjs +79 -0
  32. package/es/account/Rpc.mjs.map +1 -0
  33. package/es/aens.d.ts +209 -0
  34. package/es/aens.mjs +332 -0
  35. package/es/aens.mjs.map +1 -0
  36. package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
  37. package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  45. package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
  46. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
  47. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  48. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  51. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  52. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  54. package/es/aepp-wallet-communication/schema.d.ts +90 -46
  55. package/es/aepp-wallet-communication/schema.mjs +214 -0
  56. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  57. package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
  58. package/es/aepp-wallet-communication/wallet-detector.mjs +63 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  60. package/es/apis/compiler/compiler.d.ts +92 -0
  61. package/es/apis/compiler/compiler.mjs +576 -0
  62. package/es/apis/compiler/compiler.mjs.map +1 -0
  63. package/es/apis/compiler/index.d.ts +2 -0
  64. package/es/apis/compiler/index.mjs +3 -0
  65. package/es/apis/compiler/index.mjs.map +1 -0
  66. package/es/apis/compiler/models/index.d.ts +248 -0
  67. package/es/apis/compiler/models/index.mjs +48 -0
  68. package/es/apis/compiler/models/index.mjs.map +1 -0
  69. package/es/apis/compiler/models/mappers.d.ts +23 -0
  70. package/es/apis/compiler/models/mappers.mjs +585 -0
  71. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  72. package/es/apis/compiler/models/parameters.d.ts +13 -0
  73. package/es/apis/compiler/models/parameters.mjs +71 -0
  74. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  75. package/es/apis/node/index.d.ts +2 -0
  76. package/es/apis/node/index.mjs +3 -0
  77. package/es/apis/node/index.mjs.map +1 -0
  78. package/es/apis/node/models/index.d.ts +1061 -0
  79. package/es/apis/node/models/index.mjs +2 -0
  80. package/es/apis/node/models/index.mjs.map +1 -0
  81. package/es/apis/node/models/mappers.d.ts +95 -0
  82. package/es/apis/node/models/mappers.mjs +4164 -0
  83. package/es/apis/node/models/mappers.mjs.map +1 -0
  84. package/es/apis/node/models/parameters.d.ts +17 -0
  85. package/es/apis/node/models/parameters.mjs +165 -0
  86. package/es/apis/node/models/parameters.mjs.map +1 -0
  87. package/es/apis/node/node.d.ts +215 -0
  88. package/es/apis/node/node.mjs +1165 -0
  89. package/es/apis/node/node.mjs.map +1 -0
  90. package/es/chain.d.ts +220 -0
  91. package/es/chain.mjs +524 -0
  92. package/es/chain.mjs.map +1 -0
  93. package/es/channel/handlers.d.ts +34 -0
  94. package/es/channel/handlers.mjs +147 -112
  95. package/es/channel/handlers.mjs.map +1 -1
  96. package/es/channel/index.d.ts +634 -0
  97. package/es/channel/index.mjs +898 -900
  98. package/es/channel/index.mjs.map +1 -1
  99. package/es/channel/internal.d.ts +100 -0
  100. package/es/channel/internal.mjs +97 -51
  101. package/es/channel/internal.mjs.map +1 -1
  102. package/es/contract/Compiler.d.ts +17 -0
  103. package/es/contract/Compiler.mjs +67 -0
  104. package/es/contract/Compiler.mjs.map +1 -0
  105. package/es/contract/aci.d.ts +125 -0
  106. package/es/contract/aci.mjs +199 -180
  107. package/es/contract/aci.mjs.map +1 -1
  108. package/es/contract/ga.d.ts +68 -0
  109. package/es/contract/ga.mjs +190 -0
  110. package/es/contract/ga.mjs.map +1 -0
  111. package/es/contract/methods.d.ts +68 -0
  112. package/es/contract/methods.mjs +101 -0
  113. package/es/contract/methods.mjs.map +1 -0
  114. package/es/index.d.ts +32 -0
  115. package/es/index.mjs +32 -40
  116. package/es/index.mjs.map +1 -1
  117. package/es/oracle.d.ts +154 -0
  118. package/es/oracle.mjs +288 -0
  119. package/es/oracle.mjs.map +1 -0
  120. package/es/spend.d.ts +61 -0
  121. package/es/spend.mjs +122 -0
  122. package/es/spend.mjs.map +1 -0
  123. package/es/tx/builder/constants.d.ts +41 -0
  124. package/es/tx/builder/constants.mjs +11 -19
  125. package/es/tx/builder/constants.mjs.map +1 -1
  126. package/es/tx/builder/field-types.d.ts +62 -0
  127. package/es/tx/builder/field-types.mjs +62 -10
  128. package/es/tx/builder/field-types.mjs.map +1 -1
  129. package/es/tx/builder/helpers.d.ts +131 -0
  130. package/es/tx/builder/helpers.mjs +71 -169
  131. package/es/tx/builder/helpers.mjs.map +1 -1
  132. package/es/tx/builder/index.d.ts +75 -0
  133. package/es/tx/builder/index.mjs +141 -323
  134. package/es/tx/builder/index.mjs.map +1 -1
  135. package/es/tx/builder/schema.d.ts +350 -0
  136. package/es/tx/builder/schema.mjs +173 -510
  137. package/es/tx/builder/schema.mjs.map +1 -1
  138. package/es/tx/index.d.ts +63 -0
  139. package/es/tx/index.mjs +171 -265
  140. package/es/tx/index.mjs.map +1 -1
  141. package/es/tx/min-fee.d.ts +20 -0
  142. package/es/tx/min-fee.mjs +148 -0
  143. package/es/tx/min-fee.mjs.map +1 -0
  144. package/es/tx/validator.d.ts +19 -0
  145. package/es/tx/validator.mjs +64 -71
  146. package/es/tx/validator.mjs.map +1 -1
  147. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  148. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  149. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  150. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  151. package/es/typings/bip32-path/index.d.mjs +2 -0
  152. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  153. package/es/typings/blakejs/index.d.mjs.map +1 -1
  154. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  155. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  156. package/es/utils/amount-formatter.d.ts +42 -0
  157. package/es/utils/amount-formatter.mjs +28 -41
  158. package/es/utils/amount-formatter.mjs.map +1 -1
  159. package/es/utils/autorest.d.ts +6 -0
  160. package/es/utils/autorest.mjs +97 -0
  161. package/es/utils/autorest.mjs.map +1 -0
  162. package/es/utils/bignumber.d.ts +13 -0
  163. package/es/utils/bignumber.mjs +10 -8
  164. package/es/utils/bignumber.mjs.map +1 -1
  165. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  166. package/es/utils/bytes.mjs +10 -14
  167. package/es/utils/bytes.mjs.map +1 -1
  168. package/es/utils/crypto.d.ts +103 -0
  169. package/es/utils/crypto.mjs +60 -68
  170. package/es/utils/crypto.mjs.map +1 -1
  171. package/es/utils/encoder.d.ts +26 -0
  172. package/es/utils/encoder.mjs +47 -51
  173. package/es/utils/encoder.mjs.map +1 -1
  174. package/es/{errors.d.ts → utils/errors.d.ts} +254 -57
  175. package/es/utils/errors.mjs +318 -125
  176. package/es/utils/errors.mjs.map +1 -1
  177. package/es/utils/hd-wallet.d.ts +34 -0
  178. package/es/utils/hd-wallet.mjs +27 -16
  179. package/es/utils/hd-wallet.mjs.map +1 -1
  180. package/es/utils/json-big.d.ts +5 -0
  181. package/es/utils/json-big.mjs +10 -14
  182. package/es/utils/json-big.mjs.map +1 -1
  183. package/es/utils/keystore.d.ts +51 -0
  184. package/es/utils/keystore.mjs +98 -193
  185. package/es/utils/keystore.mjs.map +1 -1
  186. package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
  187. package/es/utils/mptree.mjs +13 -14
  188. package/es/utils/mptree.mjs.map +1 -1
  189. package/es/utils/other.d.ts +14 -0
  190. package/es/utils/other.mjs +21 -36
  191. package/es/utils/other.mjs.map +1 -1
  192. package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
  193. package/es/utils/semver-satisfies.mjs.map +1 -1
  194. package/es/utils/string.d.ts +24 -0
  195. package/es/utils/string.mjs +8 -10
  196. package/es/utils/string.mjs.map +1 -1
  197. package/package.json +49 -39
  198. package/src/AeSdk.ts +65 -0
  199. package/src/AeSdkAepp.ts +167 -0
  200. package/src/AeSdkBase.ts +320 -0
  201. package/src/AeSdkWallet.ts +332 -0
  202. package/src/Node.ts +167 -0
  203. package/src/account/Base.ts +114 -0
  204. package/src/account/Memory.ts +83 -0
  205. package/src/account/Rpc.ts +67 -0
  206. package/src/aens.ts +391 -0
  207. package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
  208. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
  209. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
  210. package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +16 -17
  211. package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
  212. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  213. package/src/aepp-wallet-communication/schema.ts +181 -0
  214. package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
  215. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  216. package/src/apis/compiler/compiler.ts +585 -0
  217. package/src/apis/compiler/index.ts +2 -0
  218. package/src/apis/compiler/models/index.ts +301 -0
  219. package/src/apis/compiler/models/mappers.ts +583 -0
  220. package/src/apis/compiler/models/parameters.ts +93 -0
  221. package/src/apis/node/code-model-v4.yaml +10046 -0
  222. package/src/apis/node/index.ts +2 -0
  223. package/src/apis/node/models/index.ts +1253 -0
  224. package/src/apis/node/models/mappers.ts +4278 -0
  225. package/src/apis/node/models/parameters.ts +188 -0
  226. package/src/apis/node/node.ts +1299 -0
  227. package/src/chain.ts +444 -0
  228. package/src/channel/{handlers.js → handlers.ts} +220 -128
  229. package/src/channel/index.ts +991 -0
  230. package/src/channel/internal.ts +345 -0
  231. package/src/contract/Compiler.ts +66 -0
  232. package/src/contract/aci.ts +529 -0
  233. package/src/contract/ga.ts +178 -0
  234. package/src/contract/methods.ts +118 -0
  235. package/src/index.ts +51 -0
  236. package/src/oracle.ts +342 -0
  237. package/src/spend.ts +152 -0
  238. package/src/tx/builder/{constants.js → constants.ts} +12 -16
  239. package/src/tx/builder/field-types.ts +111 -0
  240. package/src/tx/builder/helpers.ts +253 -0
  241. package/src/tx/builder/index.ts +394 -0
  242. package/src/tx/builder/schema.ts +771 -0
  243. package/src/tx/index.ts +199 -0
  244. package/src/tx/min-fee.ts +136 -0
  245. package/src/tx/validator.ts +226 -0
  246. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  247. package/src/typings/@aeternity__uuid/index.d.ts +3 -0
  248. package/src/typings/bip32-path/index.d.ts +33 -0
  249. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  250. package/src/utils/amount-formatter.ts +29 -42
  251. package/src/utils/autorest.ts +90 -0
  252. package/src/utils/bignumber.ts +9 -11
  253. package/src/utils/bytes.ts +12 -14
  254. package/src/utils/crypto.ts +217 -0
  255. package/src/utils/encoder.ts +52 -55
  256. package/src/utils/errors.ts +268 -134
  257. package/src/utils/hd-wallet.ts +134 -0
  258. package/src/utils/json-big.ts +26 -0
  259. package/src/utils/keystore.ts +179 -0
  260. package/src/utils/mptree.ts +14 -14
  261. package/src/utils/other.ts +28 -43
  262. package/src/utils/string.ts +8 -10
  263. package/es/account/base.mjs +0 -179
  264. package/es/account/base.mjs.map +0 -1
  265. package/es/account/memory.mjs +0 -99
  266. package/es/account/memory.mjs.map +0 -1
  267. package/es/account/multiple.mjs +0 -179
  268. package/es/account/multiple.mjs.map +0 -1
  269. package/es/ae/aens.mjs +0 -404
  270. package/es/ae/aens.mjs.map +0 -1
  271. package/es/ae/aepp.mjs +0 -45
  272. package/es/ae/aepp.mjs.map +0 -1
  273. package/es/ae/contract.mjs +0 -159
  274. package/es/ae/contract.mjs.map +0 -1
  275. package/es/ae/index.mjs +0 -207
  276. package/es/ae/index.mjs.map +0 -1
  277. package/es/ae/oracle.mjs +0 -339
  278. package/es/ae/oracle.mjs.map +0 -1
  279. package/es/ae/universal.mjs +0 -45
  280. package/es/ae/universal.mjs.map +0 -1
  281. package/es/ae/wallet.mjs +0 -50
  282. package/es/ae/wallet.mjs.map +0 -1
  283. package/es/amount-formatter.d.ts +0 -58
  284. package/es/bignumber.d.ts +0 -18
  285. package/es/chain/index.mjs +0 -272
  286. package/es/chain/index.mjs.map +0 -1
  287. package/es/chain/node.mjs +0 -442
  288. package/es/chain/node.mjs.map +0 -1
  289. package/es/contract/compiler.mjs +0 -115
  290. package/es/contract/compiler.mjs.map +0 -1
  291. package/es/contract/ga/helpers.mjs +0 -30
  292. package/es/contract/ga/helpers.mjs.map +0 -1
  293. package/es/contract/ga/index.mjs +0 -178
  294. package/es/contract/ga/index.mjs.map +0 -1
  295. package/es/crypto-ts.d.ts +0 -9
  296. package/es/encoder.d.ts +0 -26
  297. package/es/node-pool/index.mjs +0 -188
  298. package/es/node-pool/index.mjs.map +0 -1
  299. package/es/node.mjs +0 -133
  300. package/es/node.mjs.map +0 -1
  301. package/es/other.d.ts +0 -31
  302. package/es/string.d.ts +0 -26
  303. package/es/tx/tx-object.mjs +0 -283
  304. package/es/tx/tx-object.mjs.map +0 -1
  305. package/es/tx/tx.mjs +0 -938
  306. package/es/tx/tx.mjs.map +0 -1
  307. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
  308. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
  309. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
  310. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
  311. package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
  312. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
  313. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
  314. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
  315. package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
  316. package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
  317. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
  318. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
  319. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
  320. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
  321. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
  322. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
  323. package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
  324. package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
  325. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
  326. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
  327. package/es/utils/async-init.mjs +0 -64
  328. package/es/utils/async-init.mjs.map +0 -1
  329. package/es/utils/crypto-ts.mjs.map +0 -1
  330. package/es/utils/swagger.mjs +0 -164
  331. package/es/utils/swagger.mjs.map +0 -1
  332. package/src/account/base.js +0 -153
  333. package/src/account/memory.js +0 -83
  334. package/src/account/multiple.js +0 -162
  335. package/src/ae/aens.js +0 -361
  336. package/src/ae/aepp.js +0 -45
  337. package/src/ae/contract.js +0 -148
  338. package/src/ae/index.js +0 -168
  339. package/src/ae/oracle.js +0 -311
  340. package/src/ae/universal.js +0 -47
  341. package/src/ae/wallet.js +0 -50
  342. package/src/chain/index.js +0 -269
  343. package/src/chain/node.js +0 -320
  344. package/src/channel/index.js +0 -903
  345. package/src/channel/internal.js +0 -236
  346. package/src/contract/aci.js +0 -376
  347. package/src/contract/compiler.js +0 -100
  348. package/src/contract/ga/helpers.js +0 -19
  349. package/src/contract/ga/index.js +0 -150
  350. package/src/index.js +0 -89
  351. package/src/node-pool/index.js +0 -172
  352. package/src/node.js +0 -116
  353. package/src/tx/builder/field-types.js +0 -61
  354. package/src/tx/builder/helpers.js +0 -334
  355. package/src/tx/builder/index.js +0 -465
  356. package/src/tx/builder/schema.js +0 -1100
  357. package/src/tx/index.js +0 -301
  358. package/src/tx/tx-object.js +0 -187
  359. package/src/tx/tx.js +0 -631
  360. package/src/tx/validator.js +0 -181
  361. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
  362. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
  363. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  364. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
  365. package/src/utils/aepp-wallet-communication/helpers.js +0 -60
  366. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
  367. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
  368. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
  369. package/src/utils/aepp-wallet-communication/schema.ts +0 -80
  370. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
  371. package/src/utils/async-init.js +0 -45
  372. package/src/utils/crypto.js +0 -219
  373. package/src/utils/hd-wallet.js +0 -100
  374. package/src/utils/json-big.js +0 -26
  375. package/src/utils/keystore.js +0 -219
  376. package/src/utils/swagger.js +0 -156
@@ -0,0 +1,123 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
6
+
7
+ /*
8
+ * ISC License (ISC)
9
+ * Copyright (c) 2022 aeternity developers
10
+ *
11
+ * Permission to use, copy, modify, and/or distribute this software for any
12
+ * purpose with or without fee is hereby granted, provided that the above
13
+ * copyright notice and this permission notice appear in all copies.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
+ * PERFORMANCE OF THIS SOFTWARE.
22
+ */
23
+ import { messageToHash, verifyMessage as verifyMessageCrypto, hash } from "../utils/crypto.mjs";
24
+ import { buildTx } from "../tx/builder/index.mjs";
25
+ import { decode } from "../utils/encoder.mjs";
26
+ import { TX_TYPE } from "../tx/builder/schema.mjs";
27
+ import { getNetworkId } from "../Node.mjs";
28
+ import { concatBuffers } from "../utils/other.mjs";
29
+ /**
30
+ * Check is provided object looks like an instance of AccountBase
31
+ * @param acc - Object to check
32
+ */
33
+
34
+ export const isAccountBase = acc => !['sign', 'address', 'signTransaction', 'signMessage'].some(f => typeof acc[f] !== 'function');
35
+ /**
36
+ * Account is one of the three basic building blocks of an
37
+ * {@link AeSdk} and provides access to a signing key pair.
38
+ */
39
+
40
+ export default class AccountBase {
41
+ /**
42
+ * @param options - Options
43
+ * @param options.networkId - Using for signing transactions
44
+ */
45
+ constructor() {
46
+ var _this$networkId;
47
+
48
+ let {
49
+ networkId
50
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
51
+
52
+ _defineProperty(this, "getNetworkId", getNetworkId);
53
+
54
+ (_this$networkId = this.networkId) !== null && _this$networkId !== void 0 ? _this$networkId : this.networkId = networkId;
55
+ }
56
+ /**
57
+ * Sign encoded transaction
58
+ * @param tx - Transaction to sign
59
+ * @param opt - Options
60
+ * @param opt.innerTx - Sign as inner transaction for PayingFor
61
+ * @returns Signed transaction
62
+ */
63
+
64
+
65
+ async signTransaction(tx) {
66
+ let {
67
+ innerTx,
68
+ networkId,
69
+ ...options
70
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
71
+ const prefixes = [await this.getNetworkId({
72
+ networkId
73
+ })];
74
+ if (innerTx === true) prefixes.push('inner_tx');
75
+ const rlpBinaryTx = decode(tx);
76
+ const txWithNetworkId = concatBuffers([_Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)]);
77
+ const signatures = [await this.sign(txWithNetworkId, options)];
78
+ return buildTx({
79
+ encodedTx: rlpBinaryTx,
80
+ signatures
81
+ }, TX_TYPE.signed).tx;
82
+ }
83
+ /**
84
+ * Get network Id
85
+ * @returns Network Id
86
+ */
87
+
88
+
89
+ /**
90
+ * Sign message
91
+ * @param message - Message to sign
92
+ * @param opt - Options
93
+ * @returns Signature as hex string of Uint8Array
94
+ */
95
+ async signMessage(message) {
96
+ let {
97
+ returnHex = false,
98
+ ...options
99
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
100
+ const sig = await this.sign(messageToHash(message), options);
101
+ return returnHex ? _Buffer.from(sig).toString('hex') : sig;
102
+ }
103
+ /**
104
+ * Verify message
105
+ * @param message - Message to verify
106
+ * @param signature - Signature
107
+ * @param options - Options
108
+ */
109
+
110
+
111
+ async verifyMessage(message, signature, options) {
112
+ return verifyMessageCrypto(message, typeof signature === 'string' ? _Buffer.from(signature, 'hex') : signature, decode(await this.address(options)));
113
+ }
114
+ /**
115
+ * Sign data blob
116
+ * @param data - Data blob to sign
117
+ * @param options - Options
118
+ * @returns Signed data blob
119
+ */
120
+
121
+
122
+ }
123
+ //# sourceMappingURL=Base.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Base.mjs","names":["messageToHash","verifyMessage","verifyMessageCrypto","hash","buildTx","decode","TX_TYPE","getNetworkId","concatBuffers","isAccountBase","acc","some","f","AccountBase","constructor","networkId","signTransaction","tx","innerTx","options","prefixes","push","rlpBinaryTx","txWithNetworkId","from","join","signatures","sign","encodedTx","signed","signMessage","message","returnHex","sig","toString","signature","address"],"sources":["../../src/account/Base.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 */\nimport { messageToHash, verifyMessage as verifyMessageCrypto, hash } from '../utils/crypto'\nimport { buildTx } from '../tx/builder'\nimport { decode, EncodedData } from '../utils/encoder'\nimport { TX_TYPE } from '../tx/builder/schema'\nimport { getNetworkId } from '../Node'\nimport { concatBuffers } from '../utils/other'\n\n/**\n * Check is provided object looks like an instance of AccountBase\n * @param acc - Object to check\n */\nexport const isAccountBase = (acc: AccountBase | any): boolean =>\n !['sign', 'address', 'signTransaction', 'signMessage'].some(f => typeof acc[f] !== 'function')\n\n/**\n * Account is one of the three basic building blocks of an\n * {@link AeSdk} and provides access to a signing key pair.\n */\nexport default abstract class AccountBase {\n networkId?: string\n\n /**\n * @param options - Options\n * @param options.networkId - Using for signing transactions\n */\n constructor ({ networkId }: { networkId?: string } = {}) {\n this.networkId ??= networkId\n }\n\n /**\n * Sign encoded transaction\n * @param tx - Transaction to sign\n * @param opt - Options\n * @param opt.innerTx - Sign as inner transaction for PayingFor\n * @returns Signed transaction\n */\n async signTransaction (\n tx: EncodedData<'tx'>,\n { innerTx, networkId, ...options }: { innerTx?: boolean, networkId?: string } = {}\n ): Promise<EncodedData<'tx'>> {\n const prefixes = [await this.getNetworkId({ networkId })]\n if (innerTx === true) prefixes.push('inner_tx')\n const rlpBinaryTx = decode(tx)\n const txWithNetworkId = concatBuffers([Buffer.from(prefixes.join('-')), hash(rlpBinaryTx)])\n\n const signatures = [await this.sign(txWithNetworkId, options)]\n return buildTx({ encodedTx: rlpBinaryTx, signatures }, TX_TYPE.signed).tx\n }\n\n /**\n * Get network Id\n * @returns Network Id\n */\n readonly getNetworkId = getNetworkId\n\n /**\n * Sign message\n * @param message - Message to sign\n * @param opt - Options\n * @returns Signature as hex string of Uint8Array\n */\n async signMessage (\n message: string, { returnHex = false, ...options }: { returnHex?: boolean } = {}\n ): Promise<string | Uint8Array> {\n const sig = await this.sign(messageToHash(message), options)\n return returnHex ? Buffer.from(sig).toString('hex') : sig\n }\n\n /**\n * Verify message\n * @param message - Message to verify\n * @param signature - Signature\n * @param options - Options\n */\n async verifyMessage (\n message: string, signature: string | Uint8Array, options?: object\n ): Promise<boolean> {\n return verifyMessageCrypto(\n message,\n typeof signature === 'string' ? Buffer.from(signature, 'hex') : signature,\n decode(await this.address(options))\n )\n }\n\n /**\n * Sign data blob\n * @param data - Data blob to sign\n * @param options - Options\n * @returns Signed data blob\n */\n abstract sign (data: string | Uint8Array, options?: any): Promise<Uint8Array>\n\n /**\n * Obtain account address\n * @returns Public account address\n */\n abstract address (opt?: object): Promise<EncodedData<'ak'>>\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;SACSA,a,EAAeC,aAAa,IAAIC,mB,EAAqBC,I;SACrDC,O;SACAC,M;SACAC,O;SACAC,Y;SACAC,a;AAET;AACA;AACA;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AACA;AACA;EACmB,MAAXa,WAAW,CACfC,OADe,EAEe;IAAA,IADb;MAAEC,SAAS,GAAG,KAAd;MAAqB,GAAGb;IAAxB,CACa,uEADgD,EAChD;IAC9B,MAAMc,GAAG,GAAG,MAAM,KAAKN,IAAL,CAAU3B,aAAa,CAAC+B,OAAD,CAAvB,EAAkCZ,OAAlC,CAAlB;IACA,OAAOa,SAAS,GAAG,QAAOR,IAAP,CAAYS,GAAZ,EAAiBC,QAAjB,CAA0B,KAA1B,CAAH,GAAsCD,GAAtD;EACD;EAED;AACF;AACA;AACA;AACA;AACA;;;EACqB,MAAbhC,aAAa,CACjB8B,OADiB,EACAI,SADA,EACgChB,OADhC,EAEC;IAClB,OAAOjB,mBAAmB,CACxB6B,OADwB,EAExB,OAAOI,SAAP,KAAqB,QAArB,GAAgC,QAAOX,IAAP,CAAYW,SAAZ,EAAuB,KAAvB,CAAhC,GAAgEA,SAFxC,EAGxB9B,MAAM,CAAC,MAAM,KAAK+B,OAAL,CAAajB,OAAb,CAAP,CAHkB,CAA1B;EAKD;EAED;AACF;AACA;AACA;AACA;AACA;;;AAvE0C"}
@@ -0,0 +1,25 @@
1
+ import AccountBase from './Base';
2
+ import { EncodedData } from '../utils/encoder';
3
+ export interface Keypair {
4
+ publicKey: EncodedData<'ak'>;
5
+ secretKey: string | Uint8Array;
6
+ }
7
+ /**
8
+ * In-memory account class
9
+ */
10
+ export default class AccountMemory extends AccountBase {
11
+ isGa: boolean;
12
+ /**
13
+ * @param options - Options
14
+ * @param options.keypair - Key pair to use
15
+ * @param options.keypair.publicKey - Public key
16
+ * @param options.keypair.secretKey - Private key
17
+ * @param options.gaId - Address of generalized account
18
+ */
19
+ constructor({ keypair, gaId, ...options }: {
20
+ keypair?: Keypair;
21
+ gaId?: EncodedData<'ak'>;
22
+ } & ConstructorParameters<typeof AccountBase>[0]);
23
+ sign(data: string | Uint8Array): Promise<Uint8Array>;
24
+ address(): Promise<EncodedData<'ak'>>;
25
+ }
@@ -0,0 +1,81 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+
6
+ /*
7
+ * ISC License (ISC)
8
+ * Copyright (c) 2018 aeternity developers
9
+ *
10
+ * Permission to use, copy, modify, and/or distribute this software for any
11
+ * purpose with or without fee is hereby granted, provided that the above
12
+ * copyright notice and this permission notice appear in all copies.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
+ * PERFORMANCE OF THIS SOFTWARE.
21
+ */
22
+ import AccountBase from "./Base.mjs";
23
+ import { sign, isValidKeypair } from "../utils/crypto.mjs";
24
+ import { isHex } from "../utils/string.mjs";
25
+ import { decode } from "../tx/builder/helpers.mjs";
26
+ import { InvalidKeypairError, MissingParamError } from "../utils/errors.mjs";
27
+ const secrets = new WeakMap();
28
+
29
+ /**
30
+ * In-memory account class
31
+ */
32
+ export default class AccountMemory extends AccountBase {
33
+ /**
34
+ * @param options - Options
35
+ * @param options.keypair - Key pair to use
36
+ * @param options.keypair.publicKey - Public key
37
+ * @param options.keypair.secretKey - Private key
38
+ * @param options.gaId - Address of generalized account
39
+ */
40
+ constructor(_ref) {
41
+ let {
42
+ keypair,
43
+ gaId,
44
+ ...options
45
+ } = _ref;
46
+ super(options);
47
+ this.isGa = gaId != null;
48
+
49
+ if (this.isGa && gaId != null) {
50
+ decode(gaId);
51
+ secrets.set(this, {
52
+ publicKey: gaId
53
+ });
54
+ return;
55
+ }
56
+
57
+ if (keypair == null) throw new MissingParamError('Either gaId or keypair is required');
58
+ if (!_Buffer.isBuffer(keypair.secretKey) && typeof keypair.secretKey === 'string' && !isHex(keypair.secretKey)) throw new InvalidKeypairError('Secret key must be hex string or Buffer');
59
+ const secretKey = typeof keypair.secretKey === 'string' ? _Buffer.from(keypair.secretKey, 'hex') : keypair.secretKey;
60
+
61
+ if (!isValidKeypair(secretKey, decode(keypair.publicKey))) {
62
+ throw new InvalidKeypairError('Invalid Key Pair');
63
+ }
64
+
65
+ secrets.set(this, {
66
+ secretKey,
67
+ publicKey: keypair.publicKey
68
+ });
69
+ }
70
+
71
+ async sign(data) {
72
+ if (this.isGa) throw new InvalidKeypairError('You are trying to sign data using generalized account without keypair');
73
+ return sign(data, secrets.get(this).secretKey);
74
+ }
75
+
76
+ async address() {
77
+ return secrets.get(this).publicKey;
78
+ }
79
+
80
+ }
81
+ //# sourceMappingURL=Memory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Memory.mjs","names":["AccountBase","sign","isValidKeypair","isHex","decode","InvalidKeypairError","MissingParamError","secrets","WeakMap","AccountMemory","constructor","keypair","gaId","options","isGa","set","publicKey","isBuffer","secretKey","from","data","get","address"],"sources":["../../src/account/Memory.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport AccountBase from './Base'\nimport { sign, isValidKeypair } from '../utils/crypto'\nimport { isHex } from '../utils/string'\nimport { decode } from '../tx/builder/helpers'\nimport { InvalidKeypairError, MissingParamError } from '../utils/errors'\nimport { EncodedData } from '../utils/encoder'\n\nconst secrets = new WeakMap()\n\nexport interface Keypair {\n publicKey: EncodedData<'ak'>\n secretKey: string | Uint8Array\n}\n\n/**\n * In-memory account class\n */\nexport default class AccountMemory extends AccountBase {\n isGa: boolean\n\n /**\n * @param options - Options\n * @param options.keypair - Key pair to use\n * @param options.keypair.publicKey - Public key\n * @param options.keypair.secretKey - Private key\n * @param options.gaId - Address of generalized account\n */\n constructor (\n { keypair, gaId, ...options }: { keypair?: Keypair, gaId?: EncodedData<'ak'> } & ConstructorParameters<typeof AccountBase>[0]\n ) {\n super(options)\n\n this.isGa = gaId != null\n if (this.isGa && gaId != null) {\n decode(gaId)\n secrets.set(this, { publicKey: gaId })\n return\n }\n\n if (keypair == null) throw new MissingParamError('Either gaId or keypair is required')\n\n if (\n !Buffer.isBuffer(keypair.secretKey) &&\n typeof keypair.secretKey === 'string' && !isHex(keypair.secretKey)\n ) throw new InvalidKeypairError('Secret key must be hex string or Buffer')\n const secretKey = typeof keypair.secretKey === 'string'\n ? Buffer.from(keypair.secretKey, 'hex')\n : keypair.secretKey\n if (!isValidKeypair(secretKey, decode(keypair.publicKey))) {\n throw new InvalidKeypairError('Invalid Key Pair')\n }\n\n secrets.set(this, {\n secretKey,\n publicKey: keypair.publicKey\n })\n }\n\n async sign (data: string | Uint8Array): Promise<Uint8Array> {\n if (this.isGa) throw new InvalidKeypairError('You are trying to sign data using generalized account without keypair')\n return sign(data, secrets.get(this).secretKey)\n }\n\n async address (): Promise<EncodedData<'ak'>>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B,kBAAxB,CAAN;IACD;;IAEDE,OAAO,CAACQ,GAAR,CAAY,IAAZ,EAAkB;MAChBG,SADgB;MAEhBF,SAAS,EAAEL,OAAO,CAACK;IAFH,CAAlB;EAID;;EAES,MAAJf,IAAI,CAAEmB,IAAF,EAAkD;IAC1D,IAAI,KAAKN,IAAT,EAAe,MAAM,IAAIT,mBAAJ,CAAwB,uEAAxB,CAAN;IACf,OAAOJ,IAAI,CAACmB,IAAD,EAAOb,OAAO,CAACc,GAAR,CAAY,IAAZ,EAAkBH,SAAzB,CAAX;EACD;;EAEY,MAAPI,OAAO,GAAgC;IAC3C,OAAOf,OAAO,CAACc,GAAR,CAAY,IAAZ,EAAkBL,SAAzB;EACD;;AAhDoD"}
@@ -0,0 +1,27 @@
1
+ import AccountBase from './Base';
2
+ import { EncodedData } from '../utils/encoder';
3
+ /**
4
+ * Account provided by wallet
5
+ * @param params - Params
6
+ * @param params.rpcClient - RpcClient instance
7
+ * @param params.address - RPC account address
8
+ * @returns AccountRpc instance
9
+ */
10
+ export default class AccountRpc extends AccountBase {
11
+ _rpcClient: any;
12
+ _address: EncodedData<'ak'>;
13
+ constructor({ rpcClient, address, ...options }: {
14
+ rpcClient: any;
15
+ address: EncodedData<'ak'>;
16
+ } & ConstructorParameters<typeof AccountBase>[0]);
17
+ sign(data: string | Uint8Array, options?: any): Promise<Uint8Array>;
18
+ address(): Promise<EncodedData<'ak'>>;
19
+ /**
20
+ * @returns Signed transaction
21
+ */
22
+ signTransaction(tx: EncodedData<'tx'>, { innerTx, networkId }?: Parameters<AccountBase['signTransaction']>[1]): Promise<EncodedData<'tx'>>;
23
+ /**
24
+ * @returns Signed message
25
+ */
26
+ signMessage(message: string, { returnHex }?: Parameters<AccountBase['signMessage']>[1]): Promise<string | Uint8Array>;
27
+ }
@@ -0,0 +1,79 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import AccountBase from "./Base.mjs";
6
+ import { METHODS } from "../aepp-wallet-communication/schema.mjs";
7
+ import { NotImplementedError } from "../utils/errors.mjs";
8
+
9
+ /**
10
+ * Account provided by wallet
11
+ * @param params - Params
12
+ * @param params.rpcClient - RpcClient instance
13
+ * @param params.address - RPC account address
14
+ * @returns AccountRpc instance
15
+ */
16
+ export default class AccountRpc extends AccountBase {
17
+ constructor(_ref) {
18
+ let {
19
+ rpcClient,
20
+ address,
21
+ ...options
22
+ } = _ref;
23
+ super(options);
24
+ this._rpcClient = rpcClient;
25
+ this._address = address;
26
+ }
27
+
28
+ async sign(data, options) {
29
+ throw new NotImplementedError('RAW signing using wallet');
30
+ }
31
+
32
+ async address() {
33
+ return this._address;
34
+ }
35
+ /**
36
+ * @returns Signed transaction
37
+ */
38
+
39
+
40
+ async signTransaction(tx) {
41
+ let {
42
+ innerTx,
43
+ networkId
44
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
45
+ if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc');
46
+ const res = await this._rpcClient.request(METHODS.sign, {
47
+ onAccount: this._address,
48
+ tx,
49
+ returnSigned: true,
50
+
51
+ /**
52
+ * @deprecated Wallet provided networkId will be used (current network)
53
+ * required to maintain backward compatibility with wallets using SDK v11.0.1 and below
54
+ * @see {@link https://github.com/aeternity/aepp-sdk-js/commit/153fd89a52c4eab39fcd659b356b36d32129c1ba}
55
+ */
56
+ networkId
57
+ });
58
+ return res.signedTransaction;
59
+ }
60
+ /**
61
+ * @returns Signed message
62
+ */
63
+
64
+
65
+ async signMessage(message) {
66
+ let {
67
+ returnHex = false
68
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
69
+ const {
70
+ signature
71
+ } = await this._rpcClient.request(METHODS.signMessage, {
72
+ onAccount: this._address,
73
+ message
74
+ });
75
+ return returnHex ? signature : _Buffer.from(signature, 'hex');
76
+ }
77
+
78
+ }
79
+ //# sourceMappingURL=Rpc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Rpc.mjs","names":["AccountBase","METHODS","NotImplementedError","AccountRpc","constructor","rpcClient","address","options","_rpcClient","_address","sign","data","signTransaction","tx","innerTx","networkId","res","request","onAccount","returnSigned","signedTransaction","signMessage","message","returnHex","signature","from"],"sources":["../../src/account/Rpc.ts"],"sourcesContent":["import AccountBase from './Base'\nimport { METHODS } from '../aepp-wallet-communication/schema'\nimport { NotImplementedError } from '../utils/errors'\nimport { EncodedData } from '../utils/encoder'\n\n/**\n * Account provided by wallet\n * @param params - Params\n * @param params.rpcClient - RpcClient instance\n * @param params.address - RPC account address\n * @returns AccountRpc instance\n */\nexport default class AccountRpc extends AccountBase {\n _rpcClient: any\n _address: EncodedData<'ak'>\n\n constructor (\n { rpcClient, address, ...options }:\n { rpcClient: any, address: EncodedData<'ak'> } & ConstructorParameters<typeof AccountBase>[0]\n ) {\n super(options)\n this._rpcClient = rpcClient\n this._address = address\n }\n\n async sign (data: string | Uint8Array, options?: any): Promise<Uint8Array> {\n throw new NotImplementedError('RAW signing using wallet')\n }\n\n async address (): Promise<EncodedData<'ak'>> {\n return this._address\n }\n\n /**\n * @returns Signed transaction\n */\n async signTransaction (\n tx: EncodedData<'tx'>,\n { innerTx, networkId }: Parameters<AccountBase['signTransaction']>[1] = {}\n ): Promise<EncodedData<'tx'>> {\n if (innerTx != null) throw new NotImplementedError('innerTx option in AccountRpc')\n const res = await this._rpcClient.request(METHODS.sign, {\n onAccount: this._address,\n tx,\n returnSigned: true,\n /**\n * @deprecated Wallet provided networkId will be used (current network)\n * required to maintain backward compatibility with wallets using SDK v11.0.1 and below\n * @see {@link https://github.com/aeternity/aepp-sdk-js/commit/153fd89a52c4eab39fcd659b356b36d32129c1ba}\n */\n networkId\n })\n return res.signedTransaction\n }\n\n /**\n * @returns Signed message\n */\n async signMessage (\n message: string, { returnHex = false }: Parameters<AccountBase['signMessage']>[1] = {}\n ): Promise<string | Uint8Array> {\n const { signature } = await this._rpcClient.request(\n METHODS.signMessage, { onAccount: this._address, message }\n )\n return retur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5B,CADK,CAA5B;IAGA,OAAOC,SAAS,GAAGC,SAAH,GAAe,QAAOC,IAAP,CAAYD,SAAZ,EAAuB,KAAvB,CAA/B;EACD;;AArDiD"}
package/es/aens.d.ts ADDED
@@ -0,0 +1,209 @@
1
+ /// <reference types="node" />
2
+ import { Pointer } from './tx/builder/helpers';
3
+ import { TX_TYPE, AensName } from './tx/builder/schema';
4
+ import { EncodedData } from './utils/encoder';
5
+ import BigNumber from 'bignumber.js';
6
+ import { send, SendOptions } from './spend';
7
+ import { getName } from './chain';
8
+ import { BuildTxOptions } from './tx';
9
+ import { TransformNodeType } from './Node';
10
+ import { NameEntry } from './apis/node';
11
+ import AccountBase from './account/Base';
12
+ interface KeyPointers {
13
+ [key: string]: string | Buffer;
14
+ }
15
+ /**
16
+ * Revoke a name
17
+ * @param name - Name hash
18
+ * @param options - Options
19
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
20
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
21
+ * @param options.fee - fee
22
+ * @param options.ttl - ttl
23
+ * @param options.nonce - nonce
24
+ * @returns Transaction result
25
+ * @example
26
+ * ```js
27
+ * const name = 'test.chain'
28
+ * const nameObject = await sdkInstance.aensQuery(name)
29
+ *
30
+ * await sdkInstance.aensRevoke(name, { fee, ttl , nonce })
31
+ * // or
32
+ * await nameObject.revoke({ fee, ttl, nonce })
33
+ * ```
34
+ */
35
+ export declare function aensRevoke(name: AensName, options: AensRevokeOptions): ReturnType<typeof send>;
36
+ interface AensRevokeOptions extends BuildTxOptions<TX_TYPE.nameRevoke, 'nameId' | 'accountId'>, SendOptions {
37
+ }
38
+ /**
39
+ * Update a name
40
+ * @param name - AENS name
41
+ * @param pointers - Map of pointer keys to corresponding addresses
42
+ * @param options - Options
43
+ * @param options.extendPointers - Get the pointers from the node and merge with provided
44
+ * ones. Pointers with the same type will be overwritten
45
+ * @param options.onAccount - Make operation on specific account from sdk (you
46
+ * pass publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
47
+ * @param options.fee - fee
48
+ * @param options.ttl - ttl
49
+ * @param options.nonce - nonce
50
+ * @param options.nameTtl - Name ttl represented in number of
51
+ * blocks (Max value is 50000 blocks)
52
+ * @param options.clientTtl=84600 a suggestion as to how long any
53
+ * clients should cache this information
54
+ * @throws Invalid pointer array error
55
+ * @example
56
+ * ```js
57
+ * const name = 'test.chain'
58
+ * const pointersArray = ['ak_asd23dasdas...,' 'ct_asdf34fasdasd...']
59
+ * const nameObject = await sdkInstance.aensQuery(name)
60
+ *
61
+ * await sdkInstance.aensUpdate(name, pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
62
+ * // or
63
+ * await nameObject.update(pointers, { nameTtl, ttl, fee, nonce, clientTtl })
64
+ * ```
65
+ */
66
+ export declare function aensUpdate(name: AensName, pointers: KeyPointers, { extendPointers, ...options }: AensUpdateOptions): ReturnType<typeof send>;
67
+ interface AensUpdateOptions extends BuildTxOptions<TX_TYPE.nameUpdate, 'nameId' | 'accountId' | 'pointers' | 'clientTtl' | 'nameTtl'>, SendOptions {
68
+ extendPointers?: boolean;
69
+ clientTtl?: number;
70
+ nameTtl?: number;
71
+ }
72
+ /**
73
+ * Transfer a domain to another account
74
+ * @param name - AENS name
75
+ * @param account - Recipient account publick key
76
+ * @param options - Options
77
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
78
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
79
+ * @param options.fee - fee
80
+ * @param options.ttl - ttl
81
+ * @param options.nonce - nonce
82
+ * @returns Transaction result
83
+ * @example
84
+ * ```js
85
+ * const name = 'test.chain'
86
+ * const recipientPub = 'ak_asd23dasdas...'
87
+ * const nameObject = await sdkInstance.aensQuery(name)
88
+ *
89
+ * await sdkInstance.aensTransfer(name, recipientPub, { ttl, fee, nonce })
90
+ * // or
91
+ * await nameObject.transfer(recipientPub, { ttl, fee, nonce })
92
+ * ```
93
+ */
94
+ export declare function aensTransfer(name: AensName, account: EncodedData<'ak'>, options: AensTransferOptions): ReturnType<typeof send>;
95
+ interface AensTransferOptions extends BuildTxOptions<TX_TYPE.nameTransfer, 'nameId' | 'accountId' | 'recipientId'>, SendOptions {
96
+ }
97
+ /**
98
+ * Query the AENS name info from the node
99
+ * and return the object with info and predefined functions for manipulating name
100
+ * @param name - AENS name
101
+ * @param opt - Options
102
+ * @returns
103
+ * @example
104
+ * ```js
105
+ * const nameObject = sdkInstance.aensQuery('test.chain')
106
+ * console.log(nameObject)
107
+ * {
108
+ * id, // name hash
109
+ * pointers, // array of pointers
110
+ * update, // Update name function
111
+ * extendTtl, // Extend Ttl name function
112
+ * transfer, // Transfer name function
113
+ * revoke // Revoke name function
114
+ * }
115
+ * ```
116
+ */
117
+ export declare function aensQuery(name: AensName, opt: Parameters<typeof getName>[1] & Parameters<typeof aensUpdate>[2] & Parameters<typeof aensTransfer>[2]): Promise<Readonly<TransformNodeType<NameEntry> & {
118
+ id: EncodedData<'nm'>;
119
+ owner: EncodedData<'ak'>;
120
+ pointers: KeyPointers | Pointer[];
121
+ ttl: number;
122
+ update: (pointers: KeyPointers, options?: Omit<Parameters<typeof aensQuery>[1], 'onNode' | 'onCompiler' | 'onAccount'> & {
123
+ onAccount?: AccountBase;
124
+ }) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>;
125
+ transfer: (account: EncodedData<'ak'>, options?: Parameters<typeof aensQuery>[1]) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>;
126
+ revoke: (options?: Omit<Parameters<typeof aensRevoke>[1], 'onNode' | 'onCompiler' | 'onAccount'> & {
127
+ onAccount?: AccountBase;
128
+ }) => ReturnType<typeof aensRevoke>;
129
+ extendTtl: (nameTtl: number, options?: Omit<Parameters<typeof aensQuery>[1], 'onNode' | 'onCompiler' | 'onAccount'>) => ReturnType<typeof aensUpdate> & ReturnType<typeof aensQuery>;
130
+ }>>;
131
+ /**
132
+ * Claim a previously preclaimed registration. This can only be done after the
133
+ * preclaim step
134
+ * @param name - AENS name
135
+ * @param salt - Salt from pre-claim, or 0 if it's a bid
136
+ * @param options - options
137
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
138
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
139
+ * @param options.fee - fee
140
+ * @param options.ttl - ttl
141
+ * @param options.nonce - nonce
142
+ * @param options.nameFee - Name Fee (By default calculated by sdk)
143
+ * @returns the result of the claim
144
+ * @example
145
+ * ```js
146
+ * const name = 'test.chain'
147
+ * const salt = preclaimResult.salt // salt from pre-claim transaction
148
+ *
149
+ * await sdkInstance.aensClaim(name, salt, { ttl, fee, nonce, nameFee })
150
+ * ```
151
+ */
152
+ export declare function aensClaim(name: AensName, salt: number, options: AensClaimOptions): Promise<AensClaimReturnType>;
153
+ declare type AensClaimOptionsType = BuildTxOptions<TX_TYPE.nameClaim, 'accountId' | 'nameSalt' | 'name'> & SendOptions & Parameters<typeof aensQuery>[1];
154
+ interface AensClaimOptions extends AensClaimOptionsType {
155
+ }
156
+ interface AensClaimReturnType extends Awaited<ReturnType<typeof send>>, Partial<Awaited<ReturnType<typeof aensQuery>>> {
157
+ }
158
+ /**
159
+ * Preclaim a name. Sends a hash of the name and a random salt to the node
160
+ * @param name - AENS name
161
+ * @param options - Options
162
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
163
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
164
+ * @param options.fee - fee
165
+ * @param options.ttl - ttl
166
+ * @param options.nonce - nonce
167
+ * @example
168
+ * ```js
169
+ * const name = 'test.chain'
170
+ * const salt = preclaimResult.salt // salt from pre-claim transaction
171
+ *
172
+ * await sdkInstance.aensPreclaim(name, { ttl, fee, nonce })
173
+ * {
174
+ * ...transactionResult,
175
+ * claim, // Claim function (options={}) => claimTransactionResult
176
+ * salt,
177
+ * commitmentId
178
+ * }
179
+ * ```
180
+ */
181
+ export declare function aensPreclaim(name: AensName, options: AensPreclaimOptions): Promise<Readonly<Awaited<ReturnType<typeof send>> & {
182
+ height: number;
183
+ salt: number;
184
+ commitmentId: string;
185
+ claim: (opts?: Parameters<typeof aensClaim>[2]) => ReturnType<typeof aensClaim>;
186
+ }>>;
187
+ interface AensPreclaimOptions extends BuildTxOptions<TX_TYPE.namePreClaim, 'accountId' | 'commitmentId'>, SendOptions, AensClaimOptions {
188
+ }
189
+ /**
190
+ * Bid to name auction
191
+ * @param name - Domain name
192
+ * @param nameFee - Name fee (bid fee)
193
+ * @param options - Options
194
+ * @param options.onAccount - Make operation on specific account from sdk (you pass
195
+ * publickKey) or using provided KeyPair(Can be keypair object or MemoryAccount)
196
+ * @param options.fee - fee
197
+ * @param options.ttl - ttl
198
+ * @param options.nonce - nonce
199
+ * @returns Transaction result
200
+ * @example
201
+ * ```js
202
+ * const name = 'test.chain'
203
+ * const bidFee = computeBidFee(name, startFee, incrementPercentage)
204
+ *
205
+ * await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })
206
+ * ```
207
+ */
208
+ export declare function aensBid(name: AensName, nameFee: number | string | BigNumber, options: Omit<Parameters<typeof aensClaim>[2], 'nameFee'>): ReturnType<typeof aensClaim>;
209
+ export {};