@pezkuwi/api 16.5.5 → 16.5.8

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 (498) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +12 -12
  3. package/augment.d.ts +1 -0
  4. package/augment.js +1 -0
  5. package/base/Decorate.d.ts +143 -0
  6. package/base/Decorate.js +752 -0
  7. package/base/Events.d.ts +67 -0
  8. package/base/Events.js +78 -0
  9. package/base/Getters.d.ts +163 -0
  10. package/base/Getters.js +207 -0
  11. package/base/Init.d.ts +44 -0
  12. package/base/Init.js +400 -0
  13. package/base/find.d.ts +3 -0
  14. package/base/find.js +7 -0
  15. package/base/index.d.ts +47 -0
  16. package/base/index.js +57 -0
  17. package/base/types.d.ts +15 -0
  18. package/base/types.js +1 -0
  19. package/build/LICENSE +201 -0
  20. package/build/README.md +100 -0
  21. package/build/augment.js +1 -0
  22. package/build/base/Decorate.js +752 -0
  23. package/build/base/Events.js +78 -0
  24. package/build/base/Getters.js +207 -0
  25. package/build/base/Init.js +400 -0
  26. package/build/base/find.js +7 -0
  27. package/build/base/index.d.ts +1 -1
  28. package/build/base/index.js +57 -0
  29. package/build/base/types.js +1 -0
  30. package/build/bundle-pezkuwi-api.js +26247 -0
  31. package/build/bundle.js +7 -0
  32. package/build/cjs/augment.d.ts +1 -0
  33. package/build/cjs/augment.js +3 -0
  34. package/build/cjs/base/Decorate.d.ts +143 -0
  35. package/build/cjs/base/Decorate.js +756 -0
  36. package/build/cjs/base/Events.d.ts +67 -0
  37. package/build/cjs/base/Events.js +82 -0
  38. package/build/cjs/base/Getters.d.ts +163 -0
  39. package/build/cjs/base/Getters.js +211 -0
  40. package/build/cjs/base/Init.d.ts +44 -0
  41. package/build/cjs/base/Init.js +404 -0
  42. package/build/cjs/base/find.d.ts +3 -0
  43. package/build/cjs/base/find.js +11 -0
  44. package/build/cjs/base/index.d.ts +47 -0
  45. package/build/cjs/base/index.js +61 -0
  46. package/build/cjs/base/types.d.ts +15 -0
  47. package/build/cjs/base/types.js +2 -0
  48. package/build/cjs/bundle.d.ts +7 -0
  49. package/build/cjs/bundle.js +17 -0
  50. package/build/cjs/index.d.ts +2 -0
  51. package/build/cjs/index.js +5 -0
  52. package/build/cjs/package.json +3 -0
  53. package/build/cjs/packageDetect.d.ts +1 -0
  54. package/build/cjs/packageDetect.js +10 -0
  55. package/build/cjs/packageInfo.d.ts +6 -0
  56. package/build/cjs/packageInfo.js +4 -0
  57. package/build/cjs/promise/Api.d.ts +158 -0
  58. package/build/cjs/promise/Api.js +195 -0
  59. package/build/cjs/promise/Combinator.d.ts +12 -0
  60. package/build/cjs/promise/Combinator.js +72 -0
  61. package/build/cjs/promise/decorateMethod.d.ts +14 -0
  62. package/build/cjs/promise/decorateMethod.js +75 -0
  63. package/build/cjs/promise/index.d.ts +2 -0
  64. package/build/cjs/promise/index.js +7 -0
  65. package/build/cjs/promise/types.d.ts +5 -0
  66. package/build/cjs/promise/types.js +2 -0
  67. package/build/cjs/rx/Api.d.ts +155 -0
  68. package/build/cjs/rx/Api.js +173 -0
  69. package/build/cjs/rx/decorateMethod.d.ts +3 -0
  70. package/build/cjs/rx/decorateMethod.js +6 -0
  71. package/build/cjs/rx/index.d.ts +2 -0
  72. package/build/cjs/rx/index.js +7 -0
  73. package/build/cjs/submittable/Result.d.ts +31 -0
  74. package/build/cjs/submittable/Result.js +84 -0
  75. package/build/cjs/submittable/createClass.d.ts +12 -0
  76. package/build/cjs/submittable/createClass.js +277 -0
  77. package/build/cjs/submittable/createSubmittable.d.ts +8 -0
  78. package/build/cjs/submittable/createSubmittable.js +8 -0
  79. package/build/cjs/submittable/index.d.ts +2 -0
  80. package/build/cjs/submittable/index.js +7 -0
  81. package/build/cjs/submittable/types.d.ts +1 -0
  82. package/build/cjs/submittable/types.js +2 -0
  83. package/build/cjs/types/calls.d.ts +1 -0
  84. package/build/cjs/types/calls.js +4 -0
  85. package/build/cjs/types/consts.d.ts +1 -0
  86. package/build/cjs/types/consts.js +4 -0
  87. package/build/cjs/types/errors.d.ts +1 -0
  88. package/build/cjs/types/errors.js +4 -0
  89. package/build/cjs/types/events.d.ts +1 -0
  90. package/build/cjs/types/events.js +4 -0
  91. package/build/cjs/types/index.d.ts +114 -0
  92. package/build/cjs/types/index.js +13 -0
  93. package/build/cjs/types/storage.d.ts +1 -0
  94. package/build/cjs/types/storage.js +4 -0
  95. package/build/cjs/types/submittable.d.ts +1 -0
  96. package/build/cjs/types/submittable.js +4 -0
  97. package/build/cjs/util/augmentObject.d.ts +9 -0
  98. package/build/cjs/util/augmentObject.js +84 -0
  99. package/build/cjs/util/decorate.d.ts +16 -0
  100. package/build/cjs/util/decorate.js +17 -0
  101. package/build/cjs/util/filterEvents.d.ts +6 -0
  102. package/build/cjs/util/filterEvents.js +25 -0
  103. package/build/cjs/util/index.d.ts +4 -0
  104. package/build/cjs/util/index.js +11 -0
  105. package/build/cjs/util/isKeyringPair.d.ts +3 -0
  106. package/build/cjs/util/isKeyringPair.js +7 -0
  107. package/build/cjs/util/logging.d.ts +1 -0
  108. package/build/cjs/util/logging.js +5 -0
  109. package/build/cjs/util/validate.d.ts +3 -0
  110. package/build/cjs/util/validate.js +26 -0
  111. package/build/index.js +2 -0
  112. package/build/package.json +612 -0
  113. package/build/packageDetect.js +8 -0
  114. package/build/packageInfo.js +1 -0
  115. package/build/promise/Api.d.ts +2 -2
  116. package/build/promise/Api.js +191 -0
  117. package/build/promise/Combinator.js +68 -0
  118. package/build/promise/decorateMethod.js +71 -0
  119. package/build/promise/index.js +2 -0
  120. package/build/promise/types.js +1 -0
  121. package/build/rx/Api.d.ts +2 -2
  122. package/build/rx/Api.js +169 -0
  123. package/build/rx/decorateMethod.js +3 -0
  124. package/build/rx/index.js +2 -0
  125. package/build/submittable/Result.js +80 -0
  126. package/build/submittable/createClass.js +274 -0
  127. package/build/submittable/createSubmittable.js +5 -0
  128. package/build/submittable/index.js +2 -0
  129. package/build/submittable/types.js +1 -0
  130. package/build/types/calls.js +1 -0
  131. package/build/types/consts.js +1 -0
  132. package/build/types/errors.js +1 -0
  133. package/build/types/events.js +1 -0
  134. package/build/types/index.js +8 -0
  135. package/build/types/storage.js +1 -0
  136. package/build/types/submittable.js +1 -0
  137. package/build/util/augmentObject.js +81 -0
  138. package/build/util/decorate.js +14 -0
  139. package/build/util/filterEvents.js +22 -0
  140. package/build/util/index.js +4 -0
  141. package/build/util/isKeyringPair.js +4 -0
  142. package/build/util/logging.js +2 -0
  143. package/build/util/validate.js +23 -0
  144. package/build-deno/README.md +95 -0
  145. package/build-deno/augment.ts +2 -0
  146. package/build-deno/base/Decorate.ts +1100 -0
  147. package/build-deno/base/Events.ts +89 -0
  148. package/build-deno/base/Getters.ts +243 -0
  149. package/build-deno/base/Init.ts +523 -0
  150. package/build-deno/base/find.ts +12 -0
  151. package/build-deno/base/index.ts +83 -0
  152. package/build-deno/base/types.ts +17 -0
  153. package/build-deno/bundle.ts +11 -0
  154. package/build-deno/checkTypes.manual.ts +320 -0
  155. package/build-deno/index.ts +4 -0
  156. package/build-deno/mod.ts +2 -0
  157. package/build-deno/packageDetect.ts +12 -0
  158. package/build-deno/packageInfo.ts +3 -0
  159. package/build-deno/promise/Api.ts +212 -0
  160. package/build-deno/promise/Combinator.ts +89 -0
  161. package/build-deno/promise/decorateMethod.ts +111 -0
  162. package/build-deno/promise/index.ts +3 -0
  163. package/build-deno/promise/types.ts +7 -0
  164. package/build-deno/rx/Api.ts +184 -0
  165. package/build-deno/rx/decorateMethod.ts +7 -0
  166. package/build-deno/rx/index.ts +3 -0
  167. package/build-deno/submittable/Result.ts +109 -0
  168. package/build-deno/submittable/createClass.ts +436 -0
  169. package/build-deno/submittable/createSubmittable.ts +17 -0
  170. package/build-deno/submittable/index.ts +3 -0
  171. package/build-deno/submittable/types.ts +2 -0
  172. package/build-deno/test/SingleAccountSigner.ts +51 -0
  173. package/build-deno/test/index.ts +3 -0
  174. package/build-deno/test/logEvents.ts +21 -0
  175. package/build-deno/types/calls.ts +2 -0
  176. package/build-deno/types/consts.ts +2 -0
  177. package/build-deno/types/errors.ts +2 -0
  178. package/build-deno/types/events.ts +2 -0
  179. package/build-deno/types/index.ts +124 -0
  180. package/build-deno/types/storage.ts +2 -0
  181. package/build-deno/types/submittable.ts +2 -0
  182. package/build-deno/util/augmentObject.ts +109 -0
  183. package/build-deno/util/decorate.ts +38 -0
  184. package/build-deno/util/filterEvents.ts +32 -0
  185. package/build-deno/util/index.ts +6 -0
  186. package/build-deno/util/isKeyringPair.ts +9 -0
  187. package/build-deno/util/logging.ts +4 -0
  188. package/build-deno/util/validate.ts +32 -0
  189. package/build-tsc/augment.d.ts +1 -0
  190. package/build-tsc/base/Decorate.d.ts +143 -0
  191. package/build-tsc/base/Events.d.ts +67 -0
  192. package/build-tsc/base/Getters.d.ts +163 -0
  193. package/build-tsc/base/Init.d.ts +44 -0
  194. package/build-tsc/base/find.d.ts +3 -0
  195. package/build-tsc/base/index.d.ts +47 -0
  196. package/build-tsc/base/types.d.ts +15 -0
  197. package/build-tsc/bundle.d.ts +7 -0
  198. package/build-tsc/index.d.ts +2 -0
  199. package/build-tsc/packageDetect.d.ts +1 -0
  200. package/build-tsc/packageInfo.d.ts +6 -0
  201. package/build-tsc/promise/Api.d.ts +158 -0
  202. package/build-tsc/promise/Combinator.d.ts +12 -0
  203. package/build-tsc/promise/decorateMethod.d.ts +14 -0
  204. package/build-tsc/promise/index.d.ts +2 -0
  205. package/build-tsc/promise/types.d.ts +5 -0
  206. package/build-tsc/rx/Api.d.ts +155 -0
  207. package/build-tsc/rx/decorateMethod.d.ts +3 -0
  208. package/build-tsc/rx/index.d.ts +2 -0
  209. package/build-tsc/submittable/Result.d.ts +31 -0
  210. package/build-tsc/submittable/createClass.d.ts +12 -0
  211. package/build-tsc/submittable/createSubmittable.d.ts +8 -0
  212. package/build-tsc/submittable/index.d.ts +2 -0
  213. package/build-tsc/submittable/types.d.ts +1 -0
  214. package/build-tsc/types/calls.d.ts +1 -0
  215. package/build-tsc/types/consts.d.ts +1 -0
  216. package/build-tsc/types/errors.d.ts +1 -0
  217. package/build-tsc/types/events.d.ts +1 -0
  218. package/build-tsc/types/index.d.ts +114 -0
  219. package/build-tsc/types/storage.d.ts +1 -0
  220. package/build-tsc/types/submittable.d.ts +1 -0
  221. package/build-tsc/util/augmentObject.d.ts +9 -0
  222. package/build-tsc/util/decorate.d.ts +16 -0
  223. package/build-tsc/util/filterEvents.d.ts +6 -0
  224. package/build-tsc/util/index.d.ts +4 -0
  225. package/build-tsc/util/isKeyringPair.d.ts +3 -0
  226. package/build-tsc/util/logging.d.ts +1 -0
  227. package/build-tsc/util/validate.d.ts +3 -0
  228. package/build-tsc-cjs/augment.js +3 -0
  229. package/build-tsc-cjs/base/Decorate.js +756 -0
  230. package/build-tsc-cjs/base/Events.js +82 -0
  231. package/build-tsc-cjs/base/Getters.js +211 -0
  232. package/build-tsc-cjs/base/Init.js +404 -0
  233. package/build-tsc-cjs/base/find.js +11 -0
  234. package/build-tsc-cjs/base/index.js +61 -0
  235. package/build-tsc-cjs/base/types.js +2 -0
  236. package/build-tsc-cjs/bundle.js +17 -0
  237. package/build-tsc-cjs/index.js +5 -0
  238. package/build-tsc-cjs/packageDetect.js +10 -0
  239. package/build-tsc-cjs/packageInfo.js +4 -0
  240. package/build-tsc-cjs/promise/Api.js +195 -0
  241. package/build-tsc-cjs/promise/Combinator.js +72 -0
  242. package/build-tsc-cjs/promise/decorateMethod.js +75 -0
  243. package/build-tsc-cjs/promise/index.js +7 -0
  244. package/build-tsc-cjs/promise/types.js +2 -0
  245. package/build-tsc-cjs/rx/Api.js +173 -0
  246. package/build-tsc-cjs/rx/decorateMethod.js +6 -0
  247. package/build-tsc-cjs/rx/index.js +7 -0
  248. package/build-tsc-cjs/submittable/Result.js +84 -0
  249. package/build-tsc-cjs/submittable/createClass.js +277 -0
  250. package/build-tsc-cjs/submittable/createSubmittable.js +8 -0
  251. package/build-tsc-cjs/submittable/index.js +7 -0
  252. package/build-tsc-cjs/submittable/types.js +2 -0
  253. package/build-tsc-cjs/types/calls.js +4 -0
  254. package/build-tsc-cjs/types/consts.js +4 -0
  255. package/build-tsc-cjs/types/errors.js +4 -0
  256. package/build-tsc-cjs/types/events.js +4 -0
  257. package/build-tsc-cjs/types/index.js +13 -0
  258. package/build-tsc-cjs/types/storage.js +4 -0
  259. package/build-tsc-cjs/types/submittable.js +4 -0
  260. package/build-tsc-cjs/util/augmentObject.js +84 -0
  261. package/build-tsc-cjs/util/decorate.js +17 -0
  262. package/build-tsc-cjs/util/filterEvents.js +25 -0
  263. package/build-tsc-cjs/util/index.js +11 -0
  264. package/build-tsc-cjs/util/isKeyringPair.js +7 -0
  265. package/build-tsc-cjs/util/logging.js +5 -0
  266. package/build-tsc-cjs/util/validate.js +26 -0
  267. package/build-tsc-esm/augment.js +1 -0
  268. package/build-tsc-esm/base/Decorate.js +752 -0
  269. package/build-tsc-esm/base/Events.js +78 -0
  270. package/build-tsc-esm/base/Getters.js +207 -0
  271. package/build-tsc-esm/base/Init.js +400 -0
  272. package/build-tsc-esm/base/find.js +7 -0
  273. package/build-tsc-esm/base/index.js +57 -0
  274. package/build-tsc-esm/base/types.js +1 -0
  275. package/build-tsc-esm/bundle.js +7 -0
  276. package/build-tsc-esm/index.js +2 -0
  277. package/build-tsc-esm/packageDetect.js +8 -0
  278. package/build-tsc-esm/packageInfo.js +1 -0
  279. package/build-tsc-esm/promise/Api.js +191 -0
  280. package/build-tsc-esm/promise/Combinator.js +68 -0
  281. package/build-tsc-esm/promise/decorateMethod.js +71 -0
  282. package/build-tsc-esm/promise/index.js +2 -0
  283. package/build-tsc-esm/promise/types.js +1 -0
  284. package/build-tsc-esm/rx/Api.js +169 -0
  285. package/build-tsc-esm/rx/decorateMethod.js +3 -0
  286. package/build-tsc-esm/rx/index.js +2 -0
  287. package/build-tsc-esm/submittable/Result.js +80 -0
  288. package/build-tsc-esm/submittable/createClass.js +274 -0
  289. package/build-tsc-esm/submittable/createSubmittable.js +5 -0
  290. package/build-tsc-esm/submittable/index.js +2 -0
  291. package/build-tsc-esm/submittable/types.js +1 -0
  292. package/build-tsc-esm/types/calls.js +1 -0
  293. package/build-tsc-esm/types/consts.js +1 -0
  294. package/build-tsc-esm/types/errors.js +1 -0
  295. package/build-tsc-esm/types/events.js +1 -0
  296. package/build-tsc-esm/types/index.js +8 -0
  297. package/build-tsc-esm/types/storage.js +1 -0
  298. package/build-tsc-esm/types/submittable.js +1 -0
  299. package/build-tsc-esm/util/augmentObject.js +81 -0
  300. package/build-tsc-esm/util/decorate.js +14 -0
  301. package/build-tsc-esm/util/filterEvents.js +22 -0
  302. package/build-tsc-esm/util/index.js +4 -0
  303. package/build-tsc-esm/util/isKeyringPair.js +4 -0
  304. package/build-tsc-esm/util/logging.js +2 -0
  305. package/build-tsc-esm/util/validate.js +23 -0
  306. package/bundle-pezkuwi-api.js +26247 -0
  307. package/bundle.d.ts +7 -0
  308. package/bundle.js +7 -0
  309. package/cjs/augment.d.ts +1 -0
  310. package/cjs/augment.js +3 -0
  311. package/cjs/base/Decorate.d.ts +143 -0
  312. package/cjs/base/Decorate.js +756 -0
  313. package/cjs/base/Events.d.ts +67 -0
  314. package/cjs/base/Events.js +82 -0
  315. package/cjs/base/Getters.d.ts +163 -0
  316. package/cjs/base/Getters.js +211 -0
  317. package/cjs/base/Init.d.ts +44 -0
  318. package/cjs/base/Init.js +404 -0
  319. package/cjs/base/find.d.ts +3 -0
  320. package/cjs/base/find.js +11 -0
  321. package/cjs/base/index.d.ts +47 -0
  322. package/cjs/base/index.js +61 -0
  323. package/cjs/base/types.d.ts +15 -0
  324. package/cjs/base/types.js +2 -0
  325. package/cjs/bundle.d.ts +7 -0
  326. package/cjs/bundle.js +17 -0
  327. package/cjs/index.d.ts +2 -0
  328. package/cjs/index.js +5 -0
  329. package/cjs/package.json +3 -0
  330. package/cjs/packageDetect.d.ts +1 -0
  331. package/cjs/packageDetect.js +10 -0
  332. package/cjs/packageInfo.d.ts +6 -0
  333. package/cjs/packageInfo.js +4 -0
  334. package/cjs/promise/Api.d.ts +158 -0
  335. package/cjs/promise/Api.js +195 -0
  336. package/cjs/promise/Combinator.d.ts +12 -0
  337. package/cjs/promise/Combinator.js +72 -0
  338. package/cjs/promise/decorateMethod.d.ts +14 -0
  339. package/cjs/promise/decorateMethod.js +75 -0
  340. package/cjs/promise/index.d.ts +2 -0
  341. package/cjs/promise/index.js +7 -0
  342. package/cjs/promise/types.d.ts +5 -0
  343. package/cjs/promise/types.js +2 -0
  344. package/cjs/rx/Api.d.ts +155 -0
  345. package/cjs/rx/Api.js +173 -0
  346. package/cjs/rx/decorateMethod.d.ts +3 -0
  347. package/cjs/rx/decorateMethod.js +6 -0
  348. package/cjs/rx/index.d.ts +2 -0
  349. package/cjs/rx/index.js +7 -0
  350. package/cjs/submittable/Result.d.ts +31 -0
  351. package/cjs/submittable/Result.js +84 -0
  352. package/cjs/submittable/createClass.d.ts +12 -0
  353. package/cjs/submittable/createClass.js +277 -0
  354. package/cjs/submittable/createSubmittable.d.ts +8 -0
  355. package/cjs/submittable/createSubmittable.js +8 -0
  356. package/cjs/submittable/index.d.ts +2 -0
  357. package/cjs/submittable/index.js +7 -0
  358. package/cjs/submittable/types.d.ts +1 -0
  359. package/cjs/submittable/types.js +2 -0
  360. package/cjs/types/calls.d.ts +1 -0
  361. package/cjs/types/calls.js +4 -0
  362. package/cjs/types/consts.d.ts +1 -0
  363. package/cjs/types/consts.js +4 -0
  364. package/cjs/types/errors.d.ts +1 -0
  365. package/cjs/types/errors.js +4 -0
  366. package/cjs/types/events.d.ts +1 -0
  367. package/cjs/types/events.js +4 -0
  368. package/cjs/types/index.d.ts +114 -0
  369. package/cjs/types/index.js +13 -0
  370. package/cjs/types/storage.d.ts +1 -0
  371. package/cjs/types/storage.js +4 -0
  372. package/cjs/types/submittable.d.ts +1 -0
  373. package/cjs/types/submittable.js +4 -0
  374. package/cjs/util/augmentObject.d.ts +9 -0
  375. package/cjs/util/augmentObject.js +84 -0
  376. package/cjs/util/decorate.d.ts +16 -0
  377. package/cjs/util/decorate.js +17 -0
  378. package/cjs/util/filterEvents.d.ts +6 -0
  379. package/cjs/util/filterEvents.js +25 -0
  380. package/cjs/util/index.d.ts +4 -0
  381. package/cjs/util/index.js +11 -0
  382. package/cjs/util/isKeyringPair.d.ts +3 -0
  383. package/cjs/util/isKeyringPair.js +7 -0
  384. package/cjs/util/logging.d.ts +1 -0
  385. package/cjs/util/logging.js +5 -0
  386. package/cjs/util/validate.d.ts +3 -0
  387. package/cjs/util/validate.js +26 -0
  388. package/index.d.ts +2 -0
  389. package/index.js +2 -0
  390. package/package.json +588 -22
  391. package/packageDetect.d.ts +1 -0
  392. package/packageDetect.js +8 -0
  393. package/packageInfo.d.ts +6 -0
  394. package/packageInfo.js +1 -0
  395. package/promise/Api.d.ts +158 -0
  396. package/promise/Api.js +191 -0
  397. package/promise/Combinator.d.ts +12 -0
  398. package/promise/Combinator.js +68 -0
  399. package/promise/decorateMethod.d.ts +14 -0
  400. package/promise/decorateMethod.js +71 -0
  401. package/promise/index.d.ts +2 -0
  402. package/promise/index.js +2 -0
  403. package/promise/types.d.ts +5 -0
  404. package/promise/types.js +1 -0
  405. package/rx/Api.d.ts +155 -0
  406. package/rx/Api.js +169 -0
  407. package/rx/decorateMethod.d.ts +3 -0
  408. package/rx/decorateMethod.js +3 -0
  409. package/rx/index.d.ts +2 -0
  410. package/rx/index.js +2 -0
  411. package/src/augment.ts +1 -1
  412. package/src/base/Decorate.ts +1 -1
  413. package/src/base/Events.ts +1 -1
  414. package/src/base/Getters.ts +1 -1
  415. package/src/base/Init.ts +1 -1
  416. package/src/base/find.ts +1 -1
  417. package/src/base/index.ts +1 -1
  418. package/src/base/types.ts +1 -1
  419. package/src/bundle.ts +1 -1
  420. package/src/checkTypes.manual.ts +7 -7
  421. package/src/index.ts +1 -1
  422. package/src/mod.ts +1 -1
  423. package/src/packageDetect.ts +2 -2
  424. package/src/packageInfo.ts +3 -3
  425. package/src/promise/Api.ts +3 -3
  426. package/src/promise/Combinator.ts +1 -1
  427. package/src/promise/Combinators.spec.ts +1 -1
  428. package/src/promise/decorateMethod.ts +1 -1
  429. package/src/promise/index.spec.ts +1 -1
  430. package/src/promise/index.ts +1 -1
  431. package/src/promise/types.ts +1 -1
  432. package/src/rx/Api.ts +3 -3
  433. package/src/rx/decorateMethod.ts +1 -1
  434. package/src/rx/index.ts +1 -1
  435. package/src/submittable/Result.ts +1 -1
  436. package/src/submittable/createClass.ts +1 -1
  437. package/src/submittable/createSubmittable.ts +1 -1
  438. package/src/submittable/index.ts +1 -1
  439. package/src/submittable/types.ts +1 -1
  440. package/src/test/SingleAccountSigner.ts +1 -1
  441. package/src/test/index.ts +1 -1
  442. package/src/test/logEvents.ts +1 -1
  443. package/src/types/calls.ts +1 -1
  444. package/src/types/consts.ts +1 -1
  445. package/src/types/errors.ts +1 -1
  446. package/src/types/events.ts +1 -1
  447. package/src/types/index.ts +1 -1
  448. package/src/types/storage.ts +1 -1
  449. package/src/types/submittable.ts +1 -1
  450. package/src/util/augmentObject.spec.ts +1 -1
  451. package/src/util/augmentObject.ts +1 -1
  452. package/src/util/decorate.ts +1 -1
  453. package/src/util/filterEvents.ts +1 -1
  454. package/src/util/index.ts +1 -1
  455. package/src/util/isKeyringPair.ts +1 -1
  456. package/src/util/logging.ts +1 -1
  457. package/src/util/validate.spec.ts +2 -2
  458. package/src/util/validate.ts +1 -1
  459. package/submittable/Result.d.ts +31 -0
  460. package/submittable/Result.js +80 -0
  461. package/submittable/createClass.d.ts +12 -0
  462. package/submittable/createClass.js +274 -0
  463. package/submittable/createSubmittable.d.ts +8 -0
  464. package/submittable/createSubmittable.js +5 -0
  465. package/submittable/index.d.ts +2 -0
  466. package/submittable/index.js +2 -0
  467. package/submittable/types.d.ts +1 -0
  468. package/submittable/types.js +1 -0
  469. package/tsconfig.build.tsbuildinfo +1 -1
  470. package/tsconfig.spec.tsbuildinfo +1 -0
  471. package/types/calls.d.ts +1 -0
  472. package/types/calls.js +1 -0
  473. package/types/consts.d.ts +1 -0
  474. package/types/consts.js +1 -0
  475. package/types/errors.d.ts +1 -0
  476. package/types/errors.js +1 -0
  477. package/types/events.d.ts +1 -0
  478. package/types/events.js +1 -0
  479. package/types/index.d.ts +114 -0
  480. package/types/index.js +8 -0
  481. package/types/storage.d.ts +1 -0
  482. package/types/storage.js +1 -0
  483. package/types/submittable.d.ts +1 -0
  484. package/types/submittable.js +1 -0
  485. package/util/augmentObject.d.ts +9 -0
  486. package/util/augmentObject.js +81 -0
  487. package/util/decorate.d.ts +16 -0
  488. package/util/decorate.js +14 -0
  489. package/util/filterEvents.d.ts +6 -0
  490. package/util/filterEvents.js +22 -0
  491. package/util/index.d.ts +4 -0
  492. package/util/index.js +4 -0
  493. package/util/isKeyringPair.d.ts +3 -0
  494. package/util/isKeyringPair.js +4 -0
  495. package/util/logging.d.ts +1 -0
  496. package/util/logging.js +2 -0
  497. package/util/validate.d.ts +3 -0
  498. package/util/validate.js +23 -0
@@ -0,0 +1,752 @@
1
+ import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray } from 'rxjs';
2
+ import { getAvailableDerives } from '@pezkuwi/api-derive';
3
+ import { memo, RpcCore } from '@pezkuwi/rpc-core';
4
+ import { WsProvider } from '@pezkuwi/rpc-provider';
5
+ import { expandMetadata, GenericExtrinsic, typeDefinitions, TypeRegistry } from '@pezkuwi/types';
6
+ import { getSpecRuntime } from '@pezkuwi/types-known';
7
+ import { arrayChunk, arrayFlatten, assertReturn, BN, compactStripLength, lazyMethod, lazyMethods, logger, nextTick, objectSpread, stringCamelCase, stringUpperFirst, u8aConcatStrict, u8aToHex } from '@pezkuwi/util';
8
+ import { blake2AsHex } from '@pezkuwi/util-crypto';
9
+ import { createSubmittable } from '../submittable/index.js';
10
+ import { augmentObject } from '../util/augmentObject.js';
11
+ import { decorateDeriveSections } from '../util/decorate.js';
12
+ import { extractStorageArgs } from '../util/validate.js';
13
+ import { Events } from './Events.js';
14
+ import { findCall, findError } from './find.js';
15
+ const PAGE_SIZE_K = 1000; // limit aligned with the 1k on the node (trie lookups are heavy)
16
+ const PAGE_SIZE_V = 250; // limited since the data may be > 16MB (e.g. misfiring elections)
17
+ const PAGE_SIZE_Q = 50; // queue of pending storage queries (mapped together, next tick)
18
+ const l = logger('api/init');
19
+ let instanceCounter = 0;
20
+ function getAtQueryFn(api, { method, section }) {
21
+ return assertReturn(api.rx.query[section] && api.rx.query[section][method], () => `query.${section}.${method} is not available in this version of the metadata`);
22
+ }
23
+ export class Decorate extends Events {
24
+ #instanceId;
25
+ #runtimeLog = {};
26
+ #registry;
27
+ #storageGetQ = [];
28
+ #storageSubQ = [];
29
+ // HACK Use BN import so decorateDerive works... yes, wtf.
30
+ __phantom = new BN(0);
31
+ _type;
32
+ _call = {};
33
+ _consts = {};
34
+ _derive;
35
+ _errors = {};
36
+ _events = {};
37
+ _extrinsics;
38
+ _extrinsicType = GenericExtrinsic.LATEST_EXTRINSIC_VERSION;
39
+ _genesisHash;
40
+ _isConnected;
41
+ _isReady = false;
42
+ _query = {};
43
+ _queryMulti;
44
+ _rpc;
45
+ _rpcCore;
46
+ _runtimeMap = {};
47
+ _runtimeChain;
48
+ _runtimeMetadata;
49
+ _runtimeVersion;
50
+ _rx = { call: {}, consts: {}, query: {}, tx: {} };
51
+ _options;
52
+ /**
53
+ * This is the one and only method concrete children classes need to implement.
54
+ * It's a higher-order function, which takes one argument
55
+ * `method: Method extends (...args: any[]) => Observable<any>`
56
+ * (and one optional `options`), and should return the user facing method.
57
+ * For example:
58
+ * - For ApiRx, `decorateMethod` should just be identity, because the input
59
+ * function is already an Observable
60
+ * - For ApiPromise, `decorateMethod` should return a function that takes all
61
+ * the parameters from `method`, adds an optional `callback` argument, and
62
+ * returns a Promise.
63
+ *
64
+ * We could easily imagine other user-facing interfaces, which are simply
65
+ * implemented by transforming the Observable to Stream/Iterator/Kefir/Bacon
66
+ * via `decorateMethod`.
67
+ */
68
+ _decorateMethod;
69
+ /**
70
+ * @description Create an instance of the class
71
+ *
72
+ * @param options Options object to create API instance or a Provider instance
73
+ *
74
+ * @example
75
+ * <BR>
76
+ *
77
+ * ```javascript
78
+ * import Api from '@pezkuwi/api/promise';
79
+ *
80
+ * const api = new Api().isReady();
81
+ *
82
+ * api.rpc.subscribeNewHeads((header) => {
83
+ * console.log(`new block #${header.number.toNumber()}`);
84
+ * });
85
+ * ```
86
+ */
87
+ constructor(options, type, decorateMethod) {
88
+ super();
89
+ this.#instanceId = `${++instanceCounter}`;
90
+ this.#registry = options.source?.registry || options.registry || new TypeRegistry();
91
+ this._rx.callAt = (blockHash, knownVersion) => from(this.at(blockHash, knownVersion)).pipe(map((a) => a.rx.call));
92
+ this._rx.queryAt = (blockHash, knownVersion) => from(this.at(blockHash, knownVersion)).pipe(map((a) => a.rx.query));
93
+ this._rx.registry = this.#registry;
94
+ this._decorateMethod = decorateMethod;
95
+ this._options = options;
96
+ this._type = type;
97
+ const provider = options.source
98
+ ? options.source._rpcCore.provider.isClonable
99
+ ? options.source._rpcCore.provider.clone()
100
+ : options.source._rpcCore.provider
101
+ : (options.provider || new WsProvider());
102
+ // The RPC interface decorates the known interfaces on init
103
+ this._rpcCore = new RpcCore(this.#instanceId, this.#registry, {
104
+ isPedantic: this._options.isPedantic,
105
+ provider,
106
+ rpcCacheCapacity: this._options.rpcCacheCapacity,
107
+ ttl: this._options.provider?.ttl,
108
+ userRpc: this._options.rpc
109
+ });
110
+ this._isConnected = new BehaviorSubject(this._rpcCore.provider.isConnected);
111
+ this._rx.hasSubscriptions = this._rpcCore.provider.hasSubscriptions;
112
+ }
113
+ /**
114
+ * @description Return the current used registry
115
+ */
116
+ get registry() {
117
+ return this.#registry;
118
+ }
119
+ /**
120
+ * @description Creates an instance of a type as registered
121
+ */
122
+ createType(type, ...params) {
123
+ return this.#registry.createType(type, ...params);
124
+ }
125
+ /**
126
+ * @description Register additional user-defined of chain-specific types in the type registry
127
+ */
128
+ registerTypes(types) {
129
+ types && this.#registry.register(types);
130
+ }
131
+ /**
132
+ * @returns `true` if the API operates with subscriptions
133
+ */
134
+ get hasSubscriptions() {
135
+ return this._rpcCore.provider.hasSubscriptions;
136
+ }
137
+ /**
138
+ * @returns `true` if the API decorate multi-key queries
139
+ */
140
+ get supportMulti() {
141
+ return this._rpcCore.provider.hasSubscriptions || !!this._rpcCore.state.queryStorageAt;
142
+ }
143
+ _emptyDecorated(registry, blockHash) {
144
+ return {
145
+ call: {},
146
+ consts: {},
147
+ errors: {},
148
+ events: {},
149
+ query: {},
150
+ registry,
151
+ rx: {
152
+ call: {},
153
+ query: {}
154
+ },
155
+ tx: createSubmittable(this._type, this._rx, this._decorateMethod, registry, blockHash)
156
+ };
157
+ }
158
+ _createDecorated(registry, fromEmpty, decoratedApi, blockHash) {
159
+ if (!decoratedApi) {
160
+ decoratedApi = this._emptyDecorated(registry.registry, blockHash);
161
+ }
162
+ if (fromEmpty || !registry.decoratedMeta) {
163
+ registry.decoratedMeta = expandMetadata(registry.registry, registry.metadata);
164
+ }
165
+ const runtime = this._decorateCalls(registry, this._decorateMethod, blockHash);
166
+ const runtimeRx = this._decorateCalls(registry, this._rxDecorateMethod, blockHash);
167
+ const storage = this._decorateStorage(registry.decoratedMeta, this._decorateMethod, blockHash);
168
+ const storageRx = this._decorateStorage(registry.decoratedMeta, this._rxDecorateMethod, blockHash);
169
+ augmentObject('consts', registry.decoratedMeta.consts, decoratedApi.consts, fromEmpty);
170
+ augmentObject('errors', registry.decoratedMeta.errors, decoratedApi.errors, fromEmpty);
171
+ augmentObject('events', registry.decoratedMeta.events, decoratedApi.events, fromEmpty);
172
+ augmentObject('query', storage, decoratedApi.query, fromEmpty);
173
+ augmentObject('query', storageRx, decoratedApi.rx.query, fromEmpty);
174
+ augmentObject('call', runtime, decoratedApi.call, fromEmpty);
175
+ augmentObject('call', runtimeRx, decoratedApi.rx.call, fromEmpty);
176
+ decoratedApi.findCall = (callIndex) => findCall(registry.registry, callIndex);
177
+ decoratedApi.findError = (errorIndex) => findError(registry.registry, errorIndex);
178
+ decoratedApi.queryMulti = blockHash
179
+ ? this._decorateMultiAt(decoratedApi, this._decorateMethod, blockHash)
180
+ : this._decorateMulti(this._decorateMethod);
181
+ decoratedApi.runtimeVersion = registry.runtimeVersion;
182
+ return {
183
+ createdAt: blockHash,
184
+ decoratedApi,
185
+ decoratedMeta: registry.decoratedMeta
186
+ };
187
+ }
188
+ _injectMetadata(registry, fromEmpty = false) {
189
+ // clear the decoration, we are redoing it here
190
+ if (fromEmpty || !registry.decoratedApi) {
191
+ registry.decoratedApi = this._emptyDecorated(registry.registry);
192
+ }
193
+ const { decoratedApi, decoratedMeta } = this._createDecorated(registry, fromEmpty, registry.decoratedApi);
194
+ this._call = decoratedApi.call;
195
+ this._consts = decoratedApi.consts;
196
+ this._errors = decoratedApi.errors;
197
+ this._events = decoratedApi.events;
198
+ this._query = decoratedApi.query;
199
+ this._rx.call = decoratedApi.rx.call;
200
+ this._rx.query = decoratedApi.rx.query;
201
+ const tx = this._decorateExtrinsics(decoratedMeta, this._decorateMethod);
202
+ const rxtx = this._decorateExtrinsics(decoratedMeta, this._rxDecorateMethod);
203
+ if (fromEmpty || !this._extrinsics) {
204
+ this._extrinsics = tx;
205
+ this._rx.tx = rxtx;
206
+ }
207
+ else {
208
+ augmentObject('tx', tx, this._extrinsics, false);
209
+ augmentObject(null, rxtx, this._rx.tx, false);
210
+ }
211
+ augmentObject(null, decoratedMeta.consts, this._rx.consts, fromEmpty);
212
+ this.emit('decorated');
213
+ }
214
+ /**
215
+ * @deprecated
216
+ * backwards compatible endpoint for metadata injection, may be removed in the future (However, it is still useful for testing injection)
217
+ */
218
+ injectMetadata(metadata, fromEmpty, registry) {
219
+ this._injectMetadata({ counter: 0, metadata, registry: registry || this.#registry, runtimeVersion: this.#registry.createType('RuntimeVersionPartial') }, fromEmpty);
220
+ }
221
+ _decorateFunctionMeta(input, output) {
222
+ output.meta = input.meta;
223
+ output.method = input.method;
224
+ output.section = input.section;
225
+ output.toJSON = input.toJSON;
226
+ if (input.callIndex) {
227
+ output.callIndex = input.callIndex;
228
+ }
229
+ return output;
230
+ }
231
+ // Filter all RPC methods based on the results of the rpc_methods call. We do this in the following
232
+ // manner to cater for both old and new:
233
+ // - when the number of entries are 0, only remove the ones with isOptional (account & contracts)
234
+ // - when non-zero, remove anything that is not in the array (we don't do this)
235
+ _filterRpc(methods, additional) {
236
+ // add any specific user-base RPCs
237
+ if (Object.keys(additional).length !== 0) {
238
+ this._rpcCore.addUserInterfaces(additional);
239
+ // re-decorate, only adding any new additional interfaces
240
+ this._decorateRpc(this._rpcCore, this._decorateMethod, this._rpc);
241
+ this._decorateRpc(this._rpcCore, this._rxDecorateMethod, this._rx.rpc);
242
+ }
243
+ // extract the actual sections from the methods (this is useful when
244
+ // we try and create mappings to runtime names via a hash mapping)
245
+ const sectionMap = {};
246
+ for (let i = 0, count = methods.length; i < count; i++) {
247
+ const [section] = methods[i].split('_');
248
+ sectionMap[section] = true;
249
+ }
250
+ // convert the actual section names into an easy name lookup
251
+ const sections = Object.keys(sectionMap);
252
+ for (let i = 0, count = sections.length; i < count; i++) {
253
+ const nameA = stringUpperFirst(sections[i]);
254
+ const nameB = `${nameA}Api`;
255
+ this._runtimeMap[blake2AsHex(nameA, 64)] = nameA;
256
+ this._runtimeMap[blake2AsHex(nameB, 64)] = nameB;
257
+ }
258
+ // finally we filter the actual methods to expose
259
+ this._filterRpcMethods(methods);
260
+ }
261
+ _filterRpcMethods(exposed) {
262
+ const hasResults = exposed.length !== 0;
263
+ const allKnown = [...this._rpcCore.mapping.entries()];
264
+ const allKeys = [];
265
+ const count = allKnown.length;
266
+ for (let i = 0; i < count; i++) {
267
+ const [, { alias, endpoint, method, pubsub, section }] = allKnown[i];
268
+ allKeys.push(`${section}_${method}`);
269
+ if (pubsub) {
270
+ allKeys.push(`${section}_${pubsub[1]}`);
271
+ allKeys.push(`${section}_${pubsub[2]}`);
272
+ }
273
+ if (alias) {
274
+ allKeys.push(...alias);
275
+ }
276
+ if (endpoint) {
277
+ allKeys.push(endpoint);
278
+ }
279
+ }
280
+ const unknown = exposed.filter((k) => !allKeys.includes(k) &&
281
+ !k.includes('_unstable_'));
282
+ if (unknown.length && !this._options.noInitWarn) {
283
+ l.warn(`RPC methods not decorated: ${unknown.join(', ')}`);
284
+ }
285
+ // loop through all entries we have (populated in decorate) and filter as required
286
+ // only remove when we have results and method missing, or with no results if optional
287
+ for (let i = 0; i < count; i++) {
288
+ const [k, { method, section }] = allKnown[i];
289
+ if (hasResults && !exposed.includes(k) && k !== 'rpc_methods') {
290
+ if (this._rpc[section]) {
291
+ delete this._rpc[section][method];
292
+ delete this._rx.rpc[section][method];
293
+ }
294
+ }
295
+ }
296
+ }
297
+ _rpcSubmitter(decorateMethod) {
298
+ const method = (method, ...params) => {
299
+ return from(this._rpcCore.provider.send(method, params));
300
+ };
301
+ return decorateMethod(method);
302
+ }
303
+ _decorateRpc(rpc, decorateMethod, input = this._rpcSubmitter(decorateMethod)) {
304
+ const out = input;
305
+ const decorateFn = (section, method) => {
306
+ const source = rpc[section][method];
307
+ const fn = decorateMethod(source, { methodName: method });
308
+ fn.meta = source.meta;
309
+ fn.raw = decorateMethod(source.raw, { methodName: method });
310
+ return fn;
311
+ };
312
+ for (let s = 0, scount = rpc.sections.length; s < scount; s++) {
313
+ const section = rpc.sections[s];
314
+ if (!Object.prototype.hasOwnProperty.call(out, section)) {
315
+ const methods = Object.keys(rpc[section]);
316
+ const decorateInternal = (method) => decorateFn(section, method);
317
+ for (let m = 0, mcount = methods.length; m < mcount; m++) {
318
+ const method = methods[m];
319
+ // skip subscriptions where we have a non-subscribe interface
320
+ if (this.hasSubscriptions || !(method.startsWith('subscribe') || method.startsWith('unsubscribe'))) {
321
+ if (!Object.prototype.hasOwnProperty.call(out, section)) {
322
+ out[section] = {};
323
+ }
324
+ lazyMethod(out[section], method, decorateInternal);
325
+ }
326
+ }
327
+ }
328
+ }
329
+ return out;
330
+ }
331
+ // add all definition entries
332
+ _addRuntimeDef(result, additional) {
333
+ if (!additional) {
334
+ return;
335
+ }
336
+ const entries = Object.entries(additional);
337
+ for (let j = 0, ecount = entries.length; j < ecount; j++) {
338
+ const [key, defs] = entries[j];
339
+ if (result[key]) {
340
+ // we have this one already, step through for new versions or
341
+ // new methods and add those as applicable
342
+ for (let k = 0, dcount = defs.length; k < dcount; k++) {
343
+ const def = defs[k];
344
+ const prev = result[key].find(({ version }) => def.version === version);
345
+ if (prev) {
346
+ // interleave the new methods with the old - last definition wins
347
+ objectSpread(prev.methods, def.methods);
348
+ }
349
+ else {
350
+ // we don't have this specific version, add it
351
+ result[key].push(def);
352
+ }
353
+ }
354
+ }
355
+ else {
356
+ // we don't have this runtime definition, add it as-is
357
+ result[key] = defs;
358
+ }
359
+ }
360
+ }
361
+ // extract all runtime definitions
362
+ _getRuntimeDefs(registry, specName, chain = '') {
363
+ const result = {};
364
+ const defValues = Object.values(typeDefinitions);
365
+ // options > chain/spec > built-in, apply in reverse order with
366
+ // methods overriding previous definitions (or interleave missing)
367
+ for (let i = 0, count = defValues.length; i < count; i++) {
368
+ this._addRuntimeDef(result, defValues[i].runtime);
369
+ }
370
+ this._addRuntimeDef(result, getSpecRuntime(registry, chain, specName));
371
+ this._addRuntimeDef(result, this._options.runtime);
372
+ return Object.entries(result);
373
+ }
374
+ // Helper for _getRuntimeDefsViaMetadata
375
+ _getMethods(registry, methods) {
376
+ const result = {};
377
+ methods.forEach((m) => {
378
+ const { docs, inputs, name, output } = m;
379
+ result[name.toString()] = {
380
+ description: docs.map((d) => d.toString()).join(),
381
+ params: inputs.map(({ name, type }) => {
382
+ return { name: name.toString(), type: registry.lookup.getName(type) || registry.lookup.getTypeDef(type).type };
383
+ }),
384
+ type: registry.lookup.getName(output) || registry.lookup.getTypeDef(output).type
385
+ };
386
+ });
387
+ return result;
388
+ }
389
+ // Maintains the same structure as `_getRuntimeDefs` in order to make conversion easier.
390
+ _getRuntimeDefsViaMetadata(registry) {
391
+ const result = {};
392
+ const { apis } = registry.metadata;
393
+ for (let i = 0, count = apis.length; i < count; i++) {
394
+ const { methods, name } = apis[i];
395
+ result[name.toString()] = [{
396
+ methods: this._getMethods(registry, methods),
397
+ // We set the version to 0 here since it will not be relevant when we are grabbing the runtime apis
398
+ // from the Metadata.
399
+ version: 0
400
+ }];
401
+ }
402
+ return Object.entries(result);
403
+ }
404
+ // When the calls are available in the metadata, it will generate them based off of the metadata.
405
+ // When they are not available it will use the hardcoded calls generated in the static types.
406
+ _decorateCalls({ registry, runtimeVersion: { apis, specName, specVersion } }, decorateMethod, blockHash) {
407
+ const result = {};
408
+ const named = {};
409
+ const hashes = {};
410
+ const isApiInMetadata = registry.metadata.apis.length > 0;
411
+ const sections = isApiInMetadata ? this._getRuntimeDefsViaMetadata(registry) : this._getRuntimeDefs(registry, specName, this._runtimeChain);
412
+ const older = [];
413
+ const implName = `${specName.toString()}/${specVersion.toString()}`;
414
+ const hasLogged = this.#runtimeLog[implName] || false;
415
+ this.#runtimeLog[implName] = true;
416
+ if (isApiInMetadata) {
417
+ for (let i = 0, scount = sections.length; i < scount; i++) {
418
+ const [_section, secs] = sections[i];
419
+ const sec = secs[0];
420
+ const sectionHash = blake2AsHex(_section, 64);
421
+ const section = stringCamelCase(_section);
422
+ const methods = Object.entries(sec.methods);
423
+ if (!named[section]) {
424
+ named[section] = {};
425
+ }
426
+ for (let m = 0, mcount = methods.length; m < mcount; m++) {
427
+ const [_method, def] = methods[m];
428
+ const method = stringCamelCase(_method);
429
+ named[section][method] = objectSpread({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
430
+ }
431
+ }
432
+ }
433
+ else {
434
+ for (let i = 0, scount = sections.length; i < scount; i++) {
435
+ const [_section, secs] = sections[i];
436
+ const sectionHash = blake2AsHex(_section, 64);
437
+ const rtApi = apis.find(([a]) => a.eq(sectionHash));
438
+ hashes[sectionHash] = true;
439
+ if (rtApi) {
440
+ const all = secs.map(({ version }) => version).sort();
441
+ const sec = secs.find(({ version }) => rtApi[1].eq(version));
442
+ if (sec) {
443
+ const section = stringCamelCase(_section);
444
+ const methods = Object.entries(sec.methods);
445
+ if (methods.length) {
446
+ if (!named[section]) {
447
+ named[section] = {};
448
+ }
449
+ for (let m = 0, mcount = methods.length; m < mcount; m++) {
450
+ const [_method, def] = methods[m];
451
+ const method = stringCamelCase(_method);
452
+ named[section][method] = objectSpread({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
453
+ }
454
+ }
455
+ }
456
+ else {
457
+ older.push(`${_section}/${rtApi[1].toString()} (${all.join('/')} known)`);
458
+ }
459
+ }
460
+ }
461
+ // find the runtimes that we don't have hashes for
462
+ const notFound = apis
463
+ .map(([a, v]) => [a.toHex(), v.toString()])
464
+ .filter(([a]) => !hashes[a])
465
+ .map(([a, v]) => `${this._runtimeMap[a] || a}/${v}`);
466
+ if (!this._options.noInitWarn && !hasLogged) {
467
+ if (older.length) {
468
+ l.warn(`${implName}: Not decorating runtime apis without matching versions: ${older.join(', ')}`);
469
+ }
470
+ if (notFound.length) {
471
+ l.warn(`${implName}: Not decorating unknown runtime apis: ${notFound.join(', ')}`);
472
+ }
473
+ }
474
+ }
475
+ const stateCall = blockHash
476
+ ? (name, bytes) => this._rpcCore.state.call(name, bytes, blockHash)
477
+ : (name, bytes) => this._rpcCore.state.call(name, bytes);
478
+ const lazySection = (section) => lazyMethods({}, Object.keys(named[section]), (method) => this._decorateCall(registry, named[section][method], stateCall, decorateMethod));
479
+ const modules = Object.keys(named);
480
+ for (let i = 0, count = modules.length; i < count; i++) {
481
+ lazyMethod(result, modules[i], lazySection);
482
+ }
483
+ return result;
484
+ }
485
+ _decorateCall(registry, def, stateCall, decorateMethod) {
486
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
487
+ const decorated = decorateMethod((...args) => {
488
+ if (args.length !== def.params.length) {
489
+ throw new Error(`${def.name}:: Expected ${def.params.length} arguments, found ${args.length}`);
490
+ }
491
+ const bytes = registry.createType('Raw', u8aConcatStrict(args.map((a, i) => registry.createTypeUnsafe(def.params[i].type, [a]).toU8a())));
492
+ return stateCall(def.name, bytes).pipe(map((r) => registry.createTypeUnsafe(def.type, [r])));
493
+ });
494
+ decorated.meta = def;
495
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
496
+ return decorated;
497
+ }
498
+ // only be called if supportMulti is true
499
+ _decorateMulti(decorateMethod) {
500
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
501
+ return decorateMethod((keys) => keys.length
502
+ ? (this.hasSubscriptions
503
+ ? this._rpcCore.state.subscribeStorage
504
+ : this._rpcCore.state.queryStorageAt)(keys.map((args) => Array.isArray(args)
505
+ ? args[0].creator.meta.type.isPlain
506
+ ? [args[0].creator]
507
+ : args[0].creator.meta.type.asMap.hashers.length === 1
508
+ ? [args[0].creator, args.slice(1)]
509
+ : [args[0].creator, ...args.slice(1)]
510
+ : [args.creator]))
511
+ : of([]));
512
+ }
513
+ _decorateMultiAt(atApi, decorateMethod, blockHash) {
514
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
515
+ return decorateMethod((calls) => calls.length
516
+ ? this._rpcCore.state.queryStorageAt(calls.map((args) => {
517
+ if (Array.isArray(args)) {
518
+ const { creator } = getAtQueryFn(atApi, args[0].creator);
519
+ return creator.meta.type.isPlain
520
+ ? [creator]
521
+ : creator.meta.type.asMap.hashers.length === 1
522
+ ? [creator, args.slice(1)]
523
+ : [creator, ...args.slice(1)];
524
+ }
525
+ return [getAtQueryFn(atApi, args.creator).creator];
526
+ }), blockHash)
527
+ : of([]));
528
+ }
529
+ _decorateExtrinsics({ tx }, decorateMethod) {
530
+ const result = createSubmittable(this._type, this._rx, decorateMethod);
531
+ const lazySection = (section) => lazyMethods({}, Object.keys(tx[section]), (method) => method.startsWith('$')
532
+ ? tx[section][method]
533
+ : this._decorateExtrinsicEntry(tx[section][method], result));
534
+ const sections = Object.keys(tx);
535
+ for (let i = 0, count = sections.length; i < count; i++) {
536
+ lazyMethod(result, sections[i], lazySection);
537
+ }
538
+ return result;
539
+ }
540
+ _decorateExtrinsicEntry(method, creator) {
541
+ const decorated = (...params) => creator(method(...params));
542
+ // pass through the `.is`
543
+ decorated.is = (other) => method.is(other);
544
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
545
+ return this._decorateFunctionMeta(method, decorated);
546
+ }
547
+ _decorateStorage({ query, registry }, decorateMethod, blockHash) {
548
+ const result = {};
549
+ const lazySection = (section) => lazyMethods({}, Object.keys(query[section]), (method) => blockHash
550
+ ? this._decorateStorageEntryAt(registry, query[section][method], decorateMethod, blockHash)
551
+ : this._decorateStorageEntry(query[section][method], decorateMethod));
552
+ const sections = Object.keys(query);
553
+ for (let i = 0, count = sections.length; i < count; i++) {
554
+ lazyMethod(result, sections[i], lazySection);
555
+ }
556
+ return result;
557
+ }
558
+ _decorateStorageEntry(creator, decorateMethod) {
559
+ const getArgs = (args, registry) => extractStorageArgs(registry || this.#registry, creator, args);
560
+ const getQueryAt = (blockHash) => from(this.at(blockHash)).pipe(map((api) => getAtQueryFn(api, creator)));
561
+ // Disable this where it occurs for each field we are decorating
562
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
563
+ const decorated = this._decorateStorageCall(creator, decorateMethod);
564
+ decorated.creator = creator;
565
+ // eslint-disable-next-line deprecation/deprecation
566
+ decorated.at = decorateMethod((blockHash, ...args) => getQueryAt(blockHash).pipe(switchMap((q) => q(...args))));
567
+ decorated.hash = decorateMethod((...args) => this._rpcCore.state.getStorageHash(getArgs(args)));
568
+ decorated.is = (key) => key.section === creator.section &&
569
+ key.method === creator.method;
570
+ decorated.key = (...args) => u8aToHex(compactStripLength(creator(...args))[1]);
571
+ decorated.keyPrefix = (...args) => u8aToHex(creator.keyPrefix(...args));
572
+ decorated.size = decorateMethod((...args) => this._rpcCore.state.getStorageSize(getArgs(args)));
573
+ // eslint-disable-next-line deprecation/deprecation
574
+ decorated.sizeAt = decorateMethod((blockHash, ...args) => getQueryAt(blockHash).pipe(switchMap((q) => this._rpcCore.state.getStorageSize(getArgs(args, q.creator.meta.registry), blockHash))));
575
+ // .keys() & .entries() only available on map types
576
+ if (creator.iterKey && creator.meta.type.isMap) {
577
+ decorated.entries = decorateMethod(memo(this.#instanceId, (...args) => this._retrieveMapEntries(creator, null, args)));
578
+ // eslint-disable-next-line deprecation/deprecation
579
+ decorated.entriesAt = decorateMethod(memo(this.#instanceId, (blockHash, ...args) => getQueryAt(blockHash).pipe(switchMap((q) => this._retrieveMapEntries(q.creator, blockHash, args)))));
580
+ decorated.entriesPaged = decorateMethod(memo(this.#instanceId, (opts) => this._retrieveMapEntriesPaged(creator, undefined, opts)));
581
+ decorated.keys = decorateMethod(memo(this.#instanceId, (...args) => this._retrieveMapKeys(creator, null, args)));
582
+ // eslint-disable-next-line deprecation/deprecation
583
+ decorated.keysAt = decorateMethod(memo(this.#instanceId, (blockHash, ...args) => getQueryAt(blockHash).pipe(switchMap((q) => this._retrieveMapKeys(q.creator, blockHash, args)))));
584
+ decorated.keysPaged = decorateMethod(memo(this.#instanceId, (opts) => this._retrieveMapKeysPaged(creator, undefined, opts)));
585
+ }
586
+ if (this.supportMulti && creator.meta.type.isMap) {
587
+ // When using double map storage function, user need to pass double map key as an array
588
+ decorated.multi = decorateMethod((args) => creator.meta.type.asMap.hashers.length === 1
589
+ ? this._retrieveMulti(args.map((a) => [creator, [a]]))
590
+ : this._retrieveMulti(args.map((a) => [creator, a])));
591
+ }
592
+ /* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
593
+ return this._decorateFunctionMeta(creator, decorated);
594
+ }
595
+ _decorateStorageEntryAt(registry, creator, decorateMethod, blockHash) {
596
+ const getArgs = (args) => extractStorageArgs(registry, creator, args);
597
+ // Disable this where it occurs for each field we are decorating
598
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
599
+ const decorated = decorateMethod((...args) => this._rpcCore.state.getStorage(getArgs(args), blockHash));
600
+ decorated.creator = creator;
601
+ decorated.hash = decorateMethod((...args) => this._rpcCore.state.getStorageHash(getArgs(args), blockHash));
602
+ decorated.is = (key) => key.section === creator.section &&
603
+ key.method === creator.method;
604
+ decorated.key = (...args) => u8aToHex(compactStripLength(creator(...args))[1]);
605
+ decorated.keyPrefix = (...keys) => u8aToHex(creator.keyPrefix(...keys));
606
+ decorated.size = decorateMethod((...args) => this._rpcCore.state.getStorageSize(getArgs(args), blockHash));
607
+ // .keys() & .entries() only available on map types
608
+ if (creator.iterKey && creator.meta.type.isMap) {
609
+ decorated.entries = decorateMethod(memo(this.#instanceId, (...args) => this._retrieveMapEntries(creator, blockHash, args)));
610
+ decorated.entriesPaged = decorateMethod(memo(this.#instanceId, (opts) => this._retrieveMapEntriesPaged(creator, blockHash, opts)));
611
+ decorated.keys = decorateMethod(memo(this.#instanceId, (...args) => this._retrieveMapKeys(creator, blockHash, args)));
612
+ decorated.keysPaged = decorateMethod(memo(this.#instanceId, (opts) => this._retrieveMapKeysPaged(creator, blockHash, opts)));
613
+ }
614
+ if (this.supportMulti && creator.meta.type.isMap) {
615
+ // When using double map storage function, user need to pass double map key as an array
616
+ decorated.multi = decorateMethod((args) => creator.meta.type.asMap.hashers.length === 1
617
+ ? this._retrieveMulti(args.map((a) => [creator, [a]]), blockHash)
618
+ : this._retrieveMulti(args.map((a) => [creator, a]), blockHash));
619
+ }
620
+ /* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
621
+ return this._decorateFunctionMeta(creator, decorated);
622
+ }
623
+ _queueStorage(call, queue) {
624
+ const query = queue === this.#storageSubQ
625
+ ? this._rpcCore.state.subscribeStorage
626
+ : this._rpcCore.state.queryStorageAt;
627
+ let queueIdx = queue.length - 1;
628
+ let valueIdx = 0;
629
+ let valueObs;
630
+ // if we don't have queue entries yet,
631
+ // or the current queue has fired (see from below),
632
+ // or the current queue has the max entries,
633
+ // then we create a new queue
634
+ if (queueIdx === -1 || !queue[queueIdx] || queue[queueIdx][1].length === PAGE_SIZE_Q) {
635
+ queueIdx++;
636
+ valueObs = from(
637
+ // we delay the execution until the next tick, this allows
638
+ // any queries made in this timeframe to be added to the same
639
+ // queue for a single query
640
+ new Promise((resolve) => {
641
+ nextTick(() => {
642
+ // get all the calls in this instance, resolve with it
643
+ // and then clear the queue so we don't add more
644
+ // (anything after this will be added to a new queue)
645
+ const calls = queue[queueIdx][1];
646
+ delete queue[queueIdx];
647
+ resolve(calls);
648
+ });
649
+ })).pipe(switchMap((calls) => query(calls)));
650
+ queue.push([valueObs, [call]]);
651
+ }
652
+ else {
653
+ valueObs = queue[queueIdx][0];
654
+ valueIdx = queue[queueIdx][1].length;
655
+ queue[queueIdx][1].push(call);
656
+ }
657
+ return valueObs.pipe(
658
+ // return the single value at this index
659
+ map((values) => values[valueIdx]));
660
+ }
661
+ // Decorate the base storage call. In the case or rxjs or promise-without-callback (await)
662
+ // we make a subscription, alternatively we push this through a single-shot query
663
+ _decorateStorageCall(creator, decorateMethod) {
664
+ const memoed = memo(this.#instanceId, (...args) => {
665
+ const call = extractStorageArgs(this.#registry, creator, args);
666
+ if (!this.hasSubscriptions) {
667
+ return this._rpcCore.state.getStorage(call);
668
+ }
669
+ return this._queueStorage(call, this.#storageSubQ);
670
+ });
671
+ return decorateMethod(memoed, {
672
+ methodName: creator.method,
673
+ overrideNoSub: (...args) => this._queueStorage(extractStorageArgs(this.#registry, creator, args), this.#storageGetQ)
674
+ });
675
+ }
676
+ // retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
677
+ _retrieveMulti(keys, blockHash) {
678
+ if (!keys.length) {
679
+ return of([]);
680
+ }
681
+ const query = this.hasSubscriptions && !blockHash
682
+ ? this._rpcCore.state.subscribeStorage
683
+ : this._rpcCore.state.queryStorageAt;
684
+ if (keys.length <= PAGE_SIZE_V) {
685
+ return blockHash
686
+ ? query(keys, blockHash)
687
+ : query(keys);
688
+ }
689
+ return combineLatest(arrayChunk(keys, PAGE_SIZE_V).map((k) => blockHash
690
+ ? query(k, blockHash)
691
+ : query(k))).pipe(map(arrayFlatten));
692
+ }
693
+ _retrieveMapKeys({ iterKey, meta, method, section }, at, args) {
694
+ if (!iterKey || !meta.type.isMap) {
695
+ throw new Error('keys can only be retrieved on maps');
696
+ }
697
+ const headKey = iterKey(...args).toHex();
698
+ const startSubject = new BehaviorSubject(headKey);
699
+ const query = at
700
+ ? (startKey) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey, at)
701
+ : (startKey) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey);
702
+ const setMeta = (key) => key.setMeta(meta, section, method);
703
+ return startSubject.pipe(switchMap(query), map((keys) => keys.map(setMeta)), tap((keys) => nextTick(() => {
704
+ keys.length === PAGE_SIZE_K
705
+ ? startSubject.next(keys[PAGE_SIZE_K - 1].toHex())
706
+ : startSubject.complete();
707
+ })), toArray(), // toArray since we want to startSubject to be completed
708
+ map(arrayFlatten));
709
+ }
710
+ _retrieveMapKeysPaged({ iterKey, meta, method, section }, at, opts) {
711
+ if (!iterKey || !meta.type.isMap) {
712
+ throw new Error('keys can only be retrieved on maps');
713
+ }
714
+ const setMeta = (key) => key.setMeta(meta, section, method);
715
+ const query = at
716
+ ? (headKey) => this._rpcCore.state.getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey, at)
717
+ : (headKey) => this._rpcCore.state.getKeysPaged(headKey, opts.pageSize, opts.startKey || headKey);
718
+ return query(iterKey(...opts.args).toHex()).pipe(map((keys) => keys.map(setMeta)));
719
+ }
720
+ _retrieveMapEntries(entry, at, args) {
721
+ const query = at
722
+ ? (keys) => this._rpcCore.state.queryStorageAt(keys, at)
723
+ : (keys) => this._rpcCore.state.queryStorageAt(keys);
724
+ return this._retrieveMapKeys(entry, at, args).pipe(switchMap((keys) => keys.length
725
+ ? combineLatest(arrayChunk(keys, PAGE_SIZE_V).map(query)).pipe(map((valsArr) => arrayFlatten(valsArr).map((value, index) => [keys[index], value])))
726
+ : of([])));
727
+ }
728
+ _retrieveMapEntriesPaged(entry, at, opts) {
729
+ const query = at
730
+ ? (keys) => this._rpcCore.state.queryStorageAt(keys, at)
731
+ : (keys) => this._rpcCore.state.queryStorageAt(keys);
732
+ return this._retrieveMapKeysPaged(entry, at, opts).pipe(switchMap((keys) => keys.length
733
+ ? query(keys).pipe(map((valsArr) => valsArr.map((value, index) => [keys[index], value])))
734
+ : of([])));
735
+ }
736
+ _decorateDeriveRx(decorateMethod) {
737
+ const specName = this._runtimeVersion?.specName.toString();
738
+ // Pull in derive from api-derive
739
+ const available = getAvailableDerives(this.#instanceId, this._rx, objectSpread({}, this._options.derives, this._options.typesBundle?.spec?.[specName || '']?.derives));
740
+ return decorateDeriveSections(decorateMethod, available);
741
+ }
742
+ _decorateDerive(decorateMethod) {
743
+ return decorateDeriveSections(decorateMethod, this._rx.derive);
744
+ }
745
+ /**
746
+ * Put the `this.onCall` function of ApiRx here, because it is needed by
747
+ * `api._rx`.
748
+ */
749
+ _rxDecorateMethod = (method) => {
750
+ return method;
751
+ };
752
+ }