@pezkuwi/api 16.5.8 → 16.5.10

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 (381) hide show
  1. package/bundle-pezkuwi-api.js +24 -18
  2. package/cjs/packageInfo.js +1 -1
  3. package/cjs/submittable/createClass.js +1 -0
  4. package/package.json +18 -17
  5. package/packageInfo.js +1 -1
  6. package/submittable/createClass.js +1 -0
  7. package/build/LICENSE +0 -201
  8. package/build/README.md +0 -100
  9. package/build/augment.d.ts +0 -1
  10. package/build/augment.js +0 -1
  11. package/build/base/Decorate.d.ts +0 -143
  12. package/build/base/Decorate.js +0 -752
  13. package/build/base/Events.d.ts +0 -67
  14. package/build/base/Events.js +0 -78
  15. package/build/base/Getters.d.ts +0 -163
  16. package/build/base/Getters.js +0 -207
  17. package/build/base/Init.d.ts +0 -44
  18. package/build/base/Init.js +0 -400
  19. package/build/base/find.d.ts +0 -3
  20. package/build/base/find.js +0 -7
  21. package/build/base/index.d.ts +0 -47
  22. package/build/base/index.js +0 -57
  23. package/build/base/types.d.ts +0 -15
  24. package/build/base/types.js +0 -1
  25. package/build/bundle-pezkuwi-api.js +0 -26247
  26. package/build/bundle.d.ts +0 -7
  27. package/build/bundle.js +0 -7
  28. package/build/cjs/augment.d.ts +0 -1
  29. package/build/cjs/augment.js +0 -3
  30. package/build/cjs/base/Decorate.d.ts +0 -143
  31. package/build/cjs/base/Decorate.js +0 -756
  32. package/build/cjs/base/Events.d.ts +0 -67
  33. package/build/cjs/base/Events.js +0 -82
  34. package/build/cjs/base/Getters.d.ts +0 -163
  35. package/build/cjs/base/Getters.js +0 -211
  36. package/build/cjs/base/Init.d.ts +0 -44
  37. package/build/cjs/base/Init.js +0 -404
  38. package/build/cjs/base/find.d.ts +0 -3
  39. package/build/cjs/base/find.js +0 -11
  40. package/build/cjs/base/index.d.ts +0 -47
  41. package/build/cjs/base/index.js +0 -61
  42. package/build/cjs/base/types.d.ts +0 -15
  43. package/build/cjs/base/types.js +0 -2
  44. package/build/cjs/bundle.d.ts +0 -7
  45. package/build/cjs/bundle.js +0 -17
  46. package/build/cjs/index.d.ts +0 -2
  47. package/build/cjs/index.js +0 -5
  48. package/build/cjs/package.json +0 -3
  49. package/build/cjs/packageDetect.d.ts +0 -1
  50. package/build/cjs/packageDetect.js +0 -10
  51. package/build/cjs/packageInfo.d.ts +0 -6
  52. package/build/cjs/packageInfo.js +0 -4
  53. package/build/cjs/promise/Api.d.ts +0 -158
  54. package/build/cjs/promise/Api.js +0 -195
  55. package/build/cjs/promise/Combinator.d.ts +0 -12
  56. package/build/cjs/promise/Combinator.js +0 -72
  57. package/build/cjs/promise/decorateMethod.d.ts +0 -14
  58. package/build/cjs/promise/decorateMethod.js +0 -75
  59. package/build/cjs/promise/index.d.ts +0 -2
  60. package/build/cjs/promise/index.js +0 -7
  61. package/build/cjs/promise/types.d.ts +0 -5
  62. package/build/cjs/promise/types.js +0 -2
  63. package/build/cjs/rx/Api.d.ts +0 -155
  64. package/build/cjs/rx/Api.js +0 -173
  65. package/build/cjs/rx/decorateMethod.d.ts +0 -3
  66. package/build/cjs/rx/decorateMethod.js +0 -6
  67. package/build/cjs/rx/index.d.ts +0 -2
  68. package/build/cjs/rx/index.js +0 -7
  69. package/build/cjs/submittable/Result.d.ts +0 -31
  70. package/build/cjs/submittable/Result.js +0 -84
  71. package/build/cjs/submittable/createClass.d.ts +0 -12
  72. package/build/cjs/submittable/createClass.js +0 -277
  73. package/build/cjs/submittable/createSubmittable.d.ts +0 -8
  74. package/build/cjs/submittable/createSubmittable.js +0 -8
  75. package/build/cjs/submittable/index.d.ts +0 -2
  76. package/build/cjs/submittable/index.js +0 -7
  77. package/build/cjs/submittable/types.d.ts +0 -1
  78. package/build/cjs/submittable/types.js +0 -2
  79. package/build/cjs/types/calls.d.ts +0 -1
  80. package/build/cjs/types/calls.js +0 -4
  81. package/build/cjs/types/consts.d.ts +0 -1
  82. package/build/cjs/types/consts.js +0 -4
  83. package/build/cjs/types/errors.d.ts +0 -1
  84. package/build/cjs/types/errors.js +0 -4
  85. package/build/cjs/types/events.d.ts +0 -1
  86. package/build/cjs/types/events.js +0 -4
  87. package/build/cjs/types/index.d.ts +0 -114
  88. package/build/cjs/types/index.js +0 -13
  89. package/build/cjs/types/storage.d.ts +0 -1
  90. package/build/cjs/types/storage.js +0 -4
  91. package/build/cjs/types/submittable.d.ts +0 -1
  92. package/build/cjs/types/submittable.js +0 -4
  93. package/build/cjs/util/augmentObject.d.ts +0 -9
  94. package/build/cjs/util/augmentObject.js +0 -84
  95. package/build/cjs/util/decorate.d.ts +0 -16
  96. package/build/cjs/util/decorate.js +0 -17
  97. package/build/cjs/util/filterEvents.d.ts +0 -6
  98. package/build/cjs/util/filterEvents.js +0 -25
  99. package/build/cjs/util/index.d.ts +0 -4
  100. package/build/cjs/util/index.js +0 -11
  101. package/build/cjs/util/isKeyringPair.d.ts +0 -3
  102. package/build/cjs/util/isKeyringPair.js +0 -7
  103. package/build/cjs/util/logging.d.ts +0 -1
  104. package/build/cjs/util/logging.js +0 -5
  105. package/build/cjs/util/validate.d.ts +0 -3
  106. package/build/cjs/util/validate.js +0 -26
  107. package/build/index.d.ts +0 -2
  108. package/build/index.js +0 -2
  109. package/build/package.json +0 -612
  110. package/build/packageDetect.d.ts +0 -1
  111. package/build/packageDetect.js +0 -8
  112. package/build/packageInfo.d.ts +0 -6
  113. package/build/packageInfo.js +0 -1
  114. package/build/promise/Api.d.ts +0 -158
  115. package/build/promise/Api.js +0 -191
  116. package/build/promise/Combinator.d.ts +0 -12
  117. package/build/promise/Combinator.js +0 -68
  118. package/build/promise/decorateMethod.d.ts +0 -14
  119. package/build/promise/decorateMethod.js +0 -71
  120. package/build/promise/index.d.ts +0 -2
  121. package/build/promise/index.js +0 -2
  122. package/build/promise/types.d.ts +0 -5
  123. package/build/promise/types.js +0 -1
  124. package/build/rx/Api.d.ts +0 -155
  125. package/build/rx/Api.js +0 -169
  126. package/build/rx/decorateMethod.d.ts +0 -3
  127. package/build/rx/decorateMethod.js +0 -3
  128. package/build/rx/index.d.ts +0 -2
  129. package/build/rx/index.js +0 -2
  130. package/build/submittable/Result.d.ts +0 -31
  131. package/build/submittable/Result.js +0 -80
  132. package/build/submittable/createClass.d.ts +0 -12
  133. package/build/submittable/createClass.js +0 -274
  134. package/build/submittable/createSubmittable.d.ts +0 -8
  135. package/build/submittable/createSubmittable.js +0 -5
  136. package/build/submittable/index.d.ts +0 -2
  137. package/build/submittable/index.js +0 -2
  138. package/build/submittable/types.d.ts +0 -1
  139. package/build/submittable/types.js +0 -1
  140. package/build/types/calls.d.ts +0 -1
  141. package/build/types/calls.js +0 -1
  142. package/build/types/consts.d.ts +0 -1
  143. package/build/types/consts.js +0 -1
  144. package/build/types/errors.d.ts +0 -1
  145. package/build/types/errors.js +0 -1
  146. package/build/types/events.d.ts +0 -1
  147. package/build/types/events.js +0 -1
  148. package/build/types/index.d.ts +0 -114
  149. package/build/types/index.js +0 -8
  150. package/build/types/storage.d.ts +0 -1
  151. package/build/types/storage.js +0 -1
  152. package/build/types/submittable.d.ts +0 -1
  153. package/build/types/submittable.js +0 -1
  154. package/build/util/augmentObject.d.ts +0 -9
  155. package/build/util/augmentObject.js +0 -81
  156. package/build/util/decorate.d.ts +0 -16
  157. package/build/util/decorate.js +0 -14
  158. package/build/util/filterEvents.d.ts +0 -6
  159. package/build/util/filterEvents.js +0 -22
  160. package/build/util/index.d.ts +0 -4
  161. package/build/util/index.js +0 -4
  162. package/build/util/isKeyringPair.d.ts +0 -3
  163. package/build/util/isKeyringPair.js +0 -4
  164. package/build/util/logging.d.ts +0 -1
  165. package/build/util/logging.js +0 -2
  166. package/build/util/validate.d.ts +0 -3
  167. package/build/util/validate.js +0 -23
  168. package/build-deno/README.md +0 -95
  169. package/build-deno/augment.ts +0 -2
  170. package/build-deno/base/Decorate.ts +0 -1100
  171. package/build-deno/base/Events.ts +0 -89
  172. package/build-deno/base/Getters.ts +0 -243
  173. package/build-deno/base/Init.ts +0 -523
  174. package/build-deno/base/find.ts +0 -12
  175. package/build-deno/base/index.ts +0 -83
  176. package/build-deno/base/types.ts +0 -17
  177. package/build-deno/bundle.ts +0 -11
  178. package/build-deno/checkTypes.manual.ts +0 -320
  179. package/build-deno/index.ts +0 -4
  180. package/build-deno/mod.ts +0 -2
  181. package/build-deno/packageDetect.ts +0 -12
  182. package/build-deno/packageInfo.ts +0 -3
  183. package/build-deno/promise/Api.ts +0 -212
  184. package/build-deno/promise/Combinator.ts +0 -89
  185. package/build-deno/promise/decorateMethod.ts +0 -111
  186. package/build-deno/promise/index.ts +0 -3
  187. package/build-deno/promise/types.ts +0 -7
  188. package/build-deno/rx/Api.ts +0 -184
  189. package/build-deno/rx/decorateMethod.ts +0 -7
  190. package/build-deno/rx/index.ts +0 -3
  191. package/build-deno/submittable/Result.ts +0 -109
  192. package/build-deno/submittable/createClass.ts +0 -436
  193. package/build-deno/submittable/createSubmittable.ts +0 -17
  194. package/build-deno/submittable/index.ts +0 -3
  195. package/build-deno/submittable/types.ts +0 -2
  196. package/build-deno/test/SingleAccountSigner.ts +0 -51
  197. package/build-deno/test/index.ts +0 -3
  198. package/build-deno/test/logEvents.ts +0 -21
  199. package/build-deno/types/calls.ts +0 -2
  200. package/build-deno/types/consts.ts +0 -2
  201. package/build-deno/types/errors.ts +0 -2
  202. package/build-deno/types/events.ts +0 -2
  203. package/build-deno/types/index.ts +0 -124
  204. package/build-deno/types/storage.ts +0 -2
  205. package/build-deno/types/submittable.ts +0 -2
  206. package/build-deno/util/augmentObject.ts +0 -109
  207. package/build-deno/util/decorate.ts +0 -38
  208. package/build-deno/util/filterEvents.ts +0 -32
  209. package/build-deno/util/index.ts +0 -6
  210. package/build-deno/util/isKeyringPair.ts +0 -9
  211. package/build-deno/util/logging.ts +0 -4
  212. package/build-deno/util/validate.ts +0 -32
  213. package/build-tsc/augment.d.ts +0 -1
  214. package/build-tsc/base/Decorate.d.ts +0 -143
  215. package/build-tsc/base/Events.d.ts +0 -67
  216. package/build-tsc/base/Getters.d.ts +0 -163
  217. package/build-tsc/base/Init.d.ts +0 -44
  218. package/build-tsc/base/find.d.ts +0 -3
  219. package/build-tsc/base/index.d.ts +0 -47
  220. package/build-tsc/base/types.d.ts +0 -15
  221. package/build-tsc/bundle.d.ts +0 -7
  222. package/build-tsc/index.d.ts +0 -2
  223. package/build-tsc/packageDetect.d.ts +0 -1
  224. package/build-tsc/packageInfo.d.ts +0 -6
  225. package/build-tsc/promise/Api.d.ts +0 -158
  226. package/build-tsc/promise/Combinator.d.ts +0 -12
  227. package/build-tsc/promise/decorateMethod.d.ts +0 -14
  228. package/build-tsc/promise/index.d.ts +0 -2
  229. package/build-tsc/promise/types.d.ts +0 -5
  230. package/build-tsc/rx/Api.d.ts +0 -155
  231. package/build-tsc/rx/decorateMethod.d.ts +0 -3
  232. package/build-tsc/rx/index.d.ts +0 -2
  233. package/build-tsc/submittable/Result.d.ts +0 -31
  234. package/build-tsc/submittable/createClass.d.ts +0 -12
  235. package/build-tsc/submittable/createSubmittable.d.ts +0 -8
  236. package/build-tsc/submittable/index.d.ts +0 -2
  237. package/build-tsc/submittable/types.d.ts +0 -1
  238. package/build-tsc/types/calls.d.ts +0 -1
  239. package/build-tsc/types/consts.d.ts +0 -1
  240. package/build-tsc/types/errors.d.ts +0 -1
  241. package/build-tsc/types/events.d.ts +0 -1
  242. package/build-tsc/types/index.d.ts +0 -114
  243. package/build-tsc/types/storage.d.ts +0 -1
  244. package/build-tsc/types/submittable.d.ts +0 -1
  245. package/build-tsc/util/augmentObject.d.ts +0 -9
  246. package/build-tsc/util/decorate.d.ts +0 -16
  247. package/build-tsc/util/filterEvents.d.ts +0 -6
  248. package/build-tsc/util/index.d.ts +0 -4
  249. package/build-tsc/util/isKeyringPair.d.ts +0 -3
  250. package/build-tsc/util/logging.d.ts +0 -1
  251. package/build-tsc/util/validate.d.ts +0 -3
  252. package/build-tsc-cjs/augment.js +0 -3
  253. package/build-tsc-cjs/base/Decorate.js +0 -756
  254. package/build-tsc-cjs/base/Events.js +0 -82
  255. package/build-tsc-cjs/base/Getters.js +0 -211
  256. package/build-tsc-cjs/base/Init.js +0 -404
  257. package/build-tsc-cjs/base/find.js +0 -11
  258. package/build-tsc-cjs/base/index.js +0 -61
  259. package/build-tsc-cjs/base/types.js +0 -2
  260. package/build-tsc-cjs/bundle.js +0 -17
  261. package/build-tsc-cjs/index.js +0 -5
  262. package/build-tsc-cjs/packageDetect.js +0 -10
  263. package/build-tsc-cjs/packageInfo.js +0 -4
  264. package/build-tsc-cjs/promise/Api.js +0 -195
  265. package/build-tsc-cjs/promise/Combinator.js +0 -72
  266. package/build-tsc-cjs/promise/decorateMethod.js +0 -75
  267. package/build-tsc-cjs/promise/index.js +0 -7
  268. package/build-tsc-cjs/promise/types.js +0 -2
  269. package/build-tsc-cjs/rx/Api.js +0 -173
  270. package/build-tsc-cjs/rx/decorateMethod.js +0 -6
  271. package/build-tsc-cjs/rx/index.js +0 -7
  272. package/build-tsc-cjs/submittable/Result.js +0 -84
  273. package/build-tsc-cjs/submittable/createClass.js +0 -277
  274. package/build-tsc-cjs/submittable/createSubmittable.js +0 -8
  275. package/build-tsc-cjs/submittable/index.js +0 -7
  276. package/build-tsc-cjs/submittable/types.js +0 -2
  277. package/build-tsc-cjs/types/calls.js +0 -4
  278. package/build-tsc-cjs/types/consts.js +0 -4
  279. package/build-tsc-cjs/types/errors.js +0 -4
  280. package/build-tsc-cjs/types/events.js +0 -4
  281. package/build-tsc-cjs/types/index.js +0 -13
  282. package/build-tsc-cjs/types/storage.js +0 -4
  283. package/build-tsc-cjs/types/submittable.js +0 -4
  284. package/build-tsc-cjs/util/augmentObject.js +0 -84
  285. package/build-tsc-cjs/util/decorate.js +0 -17
  286. package/build-tsc-cjs/util/filterEvents.js +0 -25
  287. package/build-tsc-cjs/util/index.js +0 -11
  288. package/build-tsc-cjs/util/isKeyringPair.js +0 -7
  289. package/build-tsc-cjs/util/logging.js +0 -5
  290. package/build-tsc-cjs/util/validate.js +0 -26
  291. package/build-tsc-esm/augment.js +0 -1
  292. package/build-tsc-esm/base/Decorate.js +0 -752
  293. package/build-tsc-esm/base/Events.js +0 -78
  294. package/build-tsc-esm/base/Getters.js +0 -207
  295. package/build-tsc-esm/base/Init.js +0 -400
  296. package/build-tsc-esm/base/find.js +0 -7
  297. package/build-tsc-esm/base/index.js +0 -57
  298. package/build-tsc-esm/base/types.js +0 -1
  299. package/build-tsc-esm/bundle.js +0 -7
  300. package/build-tsc-esm/index.js +0 -2
  301. package/build-tsc-esm/packageDetect.js +0 -8
  302. package/build-tsc-esm/packageInfo.js +0 -1
  303. package/build-tsc-esm/promise/Api.js +0 -191
  304. package/build-tsc-esm/promise/Combinator.js +0 -68
  305. package/build-tsc-esm/promise/decorateMethod.js +0 -71
  306. package/build-tsc-esm/promise/index.js +0 -2
  307. package/build-tsc-esm/promise/types.js +0 -1
  308. package/build-tsc-esm/rx/Api.js +0 -169
  309. package/build-tsc-esm/rx/decorateMethod.js +0 -3
  310. package/build-tsc-esm/rx/index.js +0 -2
  311. package/build-tsc-esm/submittable/Result.js +0 -80
  312. package/build-tsc-esm/submittable/createClass.js +0 -274
  313. package/build-tsc-esm/submittable/createSubmittable.js +0 -5
  314. package/build-tsc-esm/submittable/index.js +0 -2
  315. package/build-tsc-esm/submittable/types.js +0 -1
  316. package/build-tsc-esm/types/calls.js +0 -1
  317. package/build-tsc-esm/types/consts.js +0 -1
  318. package/build-tsc-esm/types/errors.js +0 -1
  319. package/build-tsc-esm/types/events.js +0 -1
  320. package/build-tsc-esm/types/index.js +0 -8
  321. package/build-tsc-esm/types/storage.js +0 -1
  322. package/build-tsc-esm/types/submittable.js +0 -1
  323. package/build-tsc-esm/util/augmentObject.js +0 -81
  324. package/build-tsc-esm/util/decorate.js +0 -14
  325. package/build-tsc-esm/util/filterEvents.js +0 -22
  326. package/build-tsc-esm/util/index.js +0 -4
  327. package/build-tsc-esm/util/isKeyringPair.js +0 -4
  328. package/build-tsc-esm/util/logging.js +0 -2
  329. package/build-tsc-esm/util/validate.js +0 -23
  330. package/src/augment.ts +0 -4
  331. package/src/base/Decorate.ts +0 -1103
  332. package/src/base/Events.ts +0 -91
  333. package/src/base/Getters.ts +0 -245
  334. package/src/base/Init.ts +0 -525
  335. package/src/base/find.ts +0 -14
  336. package/src/base/index.ts +0 -85
  337. package/src/base/types.ts +0 -19
  338. package/src/bundle.ts +0 -16
  339. package/src/checkTypes.manual.ts +0 -323
  340. package/src/index.ts +0 -6
  341. package/src/mod.ts +0 -4
  342. package/src/packageDetect.ts +0 -16
  343. package/src/packageInfo.ts +0 -6
  344. package/src/promise/Api.ts +0 -214
  345. package/src/promise/Combinator.ts +0 -91
  346. package/src/promise/Combinators.spec.ts +0 -109
  347. package/src/promise/decorateMethod.ts +0 -118
  348. package/src/promise/index.spec.ts +0 -167
  349. package/src/promise/index.ts +0 -5
  350. package/src/promise/types.ts +0 -9
  351. package/src/rx/Api.ts +0 -186
  352. package/src/rx/decorateMethod.ts +0 -9
  353. package/src/rx/index.ts +0 -5
  354. package/src/submittable/Result.ts +0 -111
  355. package/src/submittable/createClass.ts +0 -438
  356. package/src/submittable/createSubmittable.ts +0 -19
  357. package/src/submittable/index.ts +0 -5
  358. package/src/submittable/types.ts +0 -4
  359. package/src/test/SingleAccountSigner.ts +0 -53
  360. package/src/test/index.ts +0 -5
  361. package/src/test/logEvents.ts +0 -24
  362. package/src/types/calls.ts +0 -4
  363. package/src/types/consts.ts +0 -4
  364. package/src/types/errors.ts +0 -4
  365. package/src/types/events.ts +0 -4
  366. package/src/types/index.ts +0 -137
  367. package/src/types/storage.ts +0 -4
  368. package/src/types/submittable.ts +0 -4
  369. package/src/util/augmentObject.spec.ts +0 -54
  370. package/src/util/augmentObject.ts +0 -112
  371. package/src/util/decorate.ts +0 -43
  372. package/src/util/filterEvents.ts +0 -34
  373. package/src/util/index.ts +0 -10
  374. package/src/util/isKeyringPair.ts +0 -11
  375. package/src/util/logging.ts +0 -6
  376. package/src/util/validate.spec.ts +0 -72
  377. package/src/util/validate.ts +0 -36
  378. package/tsconfig.build.json +0 -25
  379. package/tsconfig.build.tsbuildinfo +0 -1
  380. package/tsconfig.spec.json +0 -26
  381. package/tsconfig.spec.tsbuildinfo +0 -1
@@ -1,158 +0,0 @@
1
- import type { ApiOptions, UnsubscribePromise } from '../types/index.js';
2
- import type { CombinatorCallback, CombinatorFunction } from './Combinator.js';
3
- import { ApiBase } from '../base/index.js';
4
- /**
5
- * # @pezkuwi/api/promise
6
- *
7
- * ## Overview
8
- *
9
- * @name ApiPromise
10
- * @description
11
- * ApiPromise is a standard JavaScript wrapper around the RPC and interfaces on the Pezkuwi network. As a full Promise-based, all interface calls return Promises, including the static `.create(...)`. Subscription calls utilise `(value) => {}` callbacks to pass through the latest values.
12
- *
13
- * The API is well suited to real-time applications where either the single-shot state is needed or use is to be made of the subscription-based features of Pezkuwi (and Bizinikiwi) clients.
14
- *
15
- * @see [[ApiRx]]
16
- *
17
- * ## Usage
18
- *
19
- * Making rpc calls -
20
- * <BR>
21
- *
22
- * ```javascript
23
- * import ApiPromise from '@pezkuwi/api/promise';
24
- *
25
- * // initialise via static create
26
- * const api = await ApiPromise.create();
27
- *
28
- * // make a subscription to the network head
29
- * api.rpc.chain.subscribeNewHeads((header) => {
30
- * console.log(`Chain is at #${header.number}`);
31
- * });
32
- * ```
33
- * <BR>
34
- *
35
- * Subscribing to chain state -
36
- * <BR>
37
- *
38
- * ```javascript
39
- * import { ApiPromise, WsProvider } from '@pezkuwi/api';
40
- *
41
- * // initialise a provider with a specific endpoint
42
- * const provider = new WsProvider('wss://example.com:9944')
43
- *
44
- * // initialise via isReady & new with specific provider
45
- * const api = await new ApiPromise({ provider }).isReady;
46
- *
47
- * // retrieve the block target time
48
- * const blockPeriod = await api.query.timestamp.blockPeriod().toNumber();
49
- * let last = 0;
50
- *
51
- * // subscribe to the current block timestamp, updates automatically (callback provided)
52
- * api.query.timestamp.now((timestamp) => {
53
- * const elapsed = last
54
- * ? `, ${timestamp.toNumber() - last}s since last`
55
- * : '';
56
- *
57
- * last = timestamp.toNumber();
58
- * console.log(`timestamp ${timestamp}${elapsed} (${blockPeriod}s target)`);
59
- * });
60
- * ```
61
- * <BR>
62
- *
63
- * Submitting a transaction -
64
- * <BR>
65
- *
66
- * ```javascript
67
- * import ApiPromise from '@pezkuwi/api/promise';
68
- *
69
- * ApiPromise.create().then((api) => {
70
- * const [nonce] = await api.query.system.account(keyring.alice.address);
71
- *
72
- * api.tx.balances
73
- * // create transfer
74
- * transfer(keyring.bob.address, 12345)
75
- * // sign the transcation
76
- * .sign(keyring.alice, { nonce })
77
- * // send the transaction (optional status callback)
78
- * .send((status) => {
79
- * console.log(`current status ${status.type}`);
80
- * })
81
- * // retrieve the submitted extrinsic hash
82
- * .then((hash) => {
83
- * console.log(`submitted with hash ${hash}`);
84
- * });
85
- * });
86
- * ```
87
- */
88
- export declare class ApiPromise extends ApiBase<'promise'> {
89
- #private;
90
- /**
91
- * @description Creates an instance of the ApiPromise class
92
- * @param options Options to create an instance. This can be either [[ApiOptions]] or
93
- * an [[WsProvider]].
94
- * @example
95
- * <BR>
96
- *
97
- * ```javascript
98
- * import Api from '@pezkuwi/api/promise';
99
- *
100
- * new Api().isReady.then((api) => {
101
- * api.rpc.subscribeNewHeads((header) => {
102
- * console.log(`new block #${header.number.toNumber()}`);
103
- * });
104
- * });
105
- * ```
106
- */
107
- constructor(options?: ApiOptions);
108
- /**
109
- * @description Creates an ApiPromise instance using the supplied provider. Returns an Promise containing the actual Api instance.
110
- * @param options options that is passed to the class contructor. Can be either [[ApiOptions]] or a
111
- * provider (see the constructor arguments)
112
- * @example
113
- * <BR>
114
- *
115
- * ```javascript
116
- * import Api from '@pezkuwi/api/promise';
117
- *
118
- * Api.create().then(async (api) => {
119
- * const timestamp = await api.query.timestamp.now();
120
- *
121
- * console.log(`lastest block timestamp ${timestamp}`);
122
- * });
123
- * ```
124
- */
125
- static create(options?: ApiOptions): Promise<ApiPromise>;
126
- /**
127
- * @description Promise that resolves the first time we are connected and loaded
128
- */
129
- get isReady(): Promise<ApiPromise>;
130
- /**
131
- * @description Promise that resolves if we can connect, or reject if there is an error
132
- */
133
- get isReadyOrError(): Promise<ApiPromise>;
134
- /**
135
- * @description Returns a clone of this ApiPromise instance (new underlying provider connection)
136
- */
137
- clone(): ApiPromise;
138
- /**
139
- * @description Creates a combinator that can be used to combine the latest results from multiple subscriptions
140
- * @param fns An array of function to combine, each in the form of `(cb: (value: void)) => void`
141
- * @param callback A callback that will return an Array of all the values this combinator has been applied to
142
- * @example
143
- * <BR>
144
- *
145
- * ```javascript
146
- * const address = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFacT7';
147
- *
148
- * // combines values from balance & nonce as it updates
149
- * api.combineLatest([
150
- * api.rpc.chain.subscribeNewHeads,
151
- * (cb) => api.query.system.account(address, cb)
152
- * ], ([head, [balance, nonce]]) => {
153
- * console.log(`#${head.number}: You have ${balance.free} units, with ${nonce} transactions sent`);
154
- * });
155
- * ```
156
- */
157
- combineLatest<T extends any[] = any[]>(fns: (CombinatorFunction | [CombinatorFunction, ...any[]])[], callback: CombinatorCallback<T>): UnsubscribePromise;
158
- }
@@ -1,195 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiPromise = void 0;
4
- const util_1 = require("@pezkuwi/util");
5
- const index_js_1 = require("../base/index.js");
6
- const Combinator_js_1 = require("./Combinator.js");
7
- const decorateMethod_js_1 = require("./decorateMethod.js");
8
- /**
9
- * # @pezkuwi/api/promise
10
- *
11
- * ## Overview
12
- *
13
- * @name ApiPromise
14
- * @description
15
- * ApiPromise is a standard JavaScript wrapper around the RPC and interfaces on the Pezkuwi network. As a full Promise-based, all interface calls return Promises, including the static `.create(...)`. Subscription calls utilise `(value) => {}` callbacks to pass through the latest values.
16
- *
17
- * The API is well suited to real-time applications where either the single-shot state is needed or use is to be made of the subscription-based features of Pezkuwi (and Bizinikiwi) clients.
18
- *
19
- * @see [[ApiRx]]
20
- *
21
- * ## Usage
22
- *
23
- * Making rpc calls -
24
- * <BR>
25
- *
26
- * ```javascript
27
- * import ApiPromise from '@pezkuwi/api/promise';
28
- *
29
- * // initialise via static create
30
- * const api = await ApiPromise.create();
31
- *
32
- * // make a subscription to the network head
33
- * api.rpc.chain.subscribeNewHeads((header) => {
34
- * console.log(`Chain is at #${header.number}`);
35
- * });
36
- * ```
37
- * <BR>
38
- *
39
- * Subscribing to chain state -
40
- * <BR>
41
- *
42
- * ```javascript
43
- * import { ApiPromise, WsProvider } from '@pezkuwi/api';
44
- *
45
- * // initialise a provider with a specific endpoint
46
- * const provider = new WsProvider('wss://example.com:9944')
47
- *
48
- * // initialise via isReady & new with specific provider
49
- * const api = await new ApiPromise({ provider }).isReady;
50
- *
51
- * // retrieve the block target time
52
- * const blockPeriod = await api.query.timestamp.blockPeriod().toNumber();
53
- * let last = 0;
54
- *
55
- * // subscribe to the current block timestamp, updates automatically (callback provided)
56
- * api.query.timestamp.now((timestamp) => {
57
- * const elapsed = last
58
- * ? `, ${timestamp.toNumber() - last}s since last`
59
- * : '';
60
- *
61
- * last = timestamp.toNumber();
62
- * console.log(`timestamp ${timestamp}${elapsed} (${blockPeriod}s target)`);
63
- * });
64
- * ```
65
- * <BR>
66
- *
67
- * Submitting a transaction -
68
- * <BR>
69
- *
70
- * ```javascript
71
- * import ApiPromise from '@pezkuwi/api/promise';
72
- *
73
- * ApiPromise.create().then((api) => {
74
- * const [nonce] = await api.query.system.account(keyring.alice.address);
75
- *
76
- * api.tx.balances
77
- * // create transfer
78
- * transfer(keyring.bob.address, 12345)
79
- * // sign the transcation
80
- * .sign(keyring.alice, { nonce })
81
- * // send the transaction (optional status callback)
82
- * .send((status) => {
83
- * console.log(`current status ${status.type}`);
84
- * })
85
- * // retrieve the submitted extrinsic hash
86
- * .then((hash) => {
87
- * console.log(`submitted with hash ${hash}`);
88
- * });
89
- * });
90
- * ```
91
- */
92
- class ApiPromise extends index_js_1.ApiBase {
93
- #isReadyPromise;
94
- #isReadyOrErrorPromise;
95
- /**
96
- * @description Creates an instance of the ApiPromise class
97
- * @param options Options to create an instance. This can be either [[ApiOptions]] or
98
- * an [[WsProvider]].
99
- * @example
100
- * <BR>
101
- *
102
- * ```javascript
103
- * import Api from '@pezkuwi/api/promise';
104
- *
105
- * new Api().isReady.then((api) => {
106
- * api.rpc.subscribeNewHeads((header) => {
107
- * console.log(`new block #${header.number.toNumber()}`);
108
- * });
109
- * });
110
- * ```
111
- */
112
- constructor(options) {
113
- super(options, 'promise', decorateMethod_js_1.toPromiseMethod);
114
- this.#isReadyPromise = new Promise((resolve) => {
115
- super.once('ready', () => resolve(this));
116
- });
117
- this.#isReadyOrErrorPromise = new Promise((resolve, reject) => {
118
- const tracker = (0, decorateMethod_js_1.promiseTracker)(resolve, reject);
119
- super.once('ready', () => tracker.resolve(this));
120
- super.once('error', (error) => tracker.reject(error));
121
- });
122
- }
123
- /**
124
- * @description Creates an ApiPromise instance using the supplied provider. Returns an Promise containing the actual Api instance.
125
- * @param options options that is passed to the class contructor. Can be either [[ApiOptions]] or a
126
- * provider (see the constructor arguments)
127
- * @example
128
- * <BR>
129
- *
130
- * ```javascript
131
- * import Api from '@pezkuwi/api/promise';
132
- *
133
- * Api.create().then(async (api) => {
134
- * const timestamp = await api.query.timestamp.now();
135
- *
136
- * console.log(`lastest block timestamp ${timestamp}`);
137
- * });
138
- * ```
139
- */
140
- static create(options) {
141
- const instance = new ApiPromise(options);
142
- if (options && options.throwOnConnect) {
143
- return instance.isReadyOrError;
144
- }
145
- // Swallow any rejections on isReadyOrError
146
- // (in Node 15.x this creates issues, when not being looked at)
147
- instance.isReadyOrError.catch(util_1.noop);
148
- return instance.isReady;
149
- }
150
- /**
151
- * @description Promise that resolves the first time we are connected and loaded
152
- */
153
- get isReady() {
154
- return this.#isReadyPromise;
155
- }
156
- /**
157
- * @description Promise that resolves if we can connect, or reject if there is an error
158
- */
159
- get isReadyOrError() {
160
- return this.#isReadyOrErrorPromise;
161
- }
162
- /**
163
- * @description Returns a clone of this ApiPromise instance (new underlying provider connection)
164
- */
165
- clone() {
166
- return new ApiPromise((0, util_1.objectSpread)({}, this._options, { source: this }));
167
- }
168
- /**
169
- * @description Creates a combinator that can be used to combine the latest results from multiple subscriptions
170
- * @param fns An array of function to combine, each in the form of `(cb: (value: void)) => void`
171
- * @param callback A callback that will return an Array of all the values this combinator has been applied to
172
- * @example
173
- * <BR>
174
- *
175
- * ```javascript
176
- * const address = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFacT7';
177
- *
178
- * // combines values from balance & nonce as it updates
179
- * api.combineLatest([
180
- * api.rpc.chain.subscribeNewHeads,
181
- * (cb) => api.query.system.account(address, cb)
182
- * ], ([head, [balance, nonce]]) => {
183
- * console.log(`#${head.number}: You have ${balance.free} units, with ${nonce} transactions sent`);
184
- * });
185
- * ```
186
- */
187
- // eslint-disable-next-line @typescript-eslint/require-await
188
- async combineLatest(fns, callback) {
189
- const combinator = new Combinator_js_1.Combinator(fns, callback);
190
- return () => {
191
- combinator.unsubscribe();
192
- };
193
- }
194
- }
195
- exports.ApiPromise = ApiPromise;
@@ -1,12 +0,0 @@
1
- import type { Callback } from '@pezkuwi/types/types';
2
- import type { UnsubscribePromise } from '../types/index.js';
3
- export type CombinatorCallback<T extends unknown[]> = Callback<T>;
4
- export type CombinatorFunction = (cb: Callback<any>) => UnsubscribePromise;
5
- export declare class Combinator<T extends unknown[] = unknown[]> {
6
- #private;
7
- constructor(fns: (CombinatorFunction | [CombinatorFunction, ...unknown[]])[], callback: CombinatorCallback<T>);
8
- protected _allHasFired(): boolean;
9
- protected _createCallback(index: number): (value: any) => void;
10
- protected _triggerUpdate(): void;
11
- unsubscribe(): void;
12
- }
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Combinator = void 0;
4
- const util_1 = require("@pezkuwi/util");
5
- class Combinator {
6
- #allHasFired = false;
7
- #callback;
8
- #fired = [];
9
- #fns = [];
10
- #isActive = true;
11
- #results = [];
12
- #subscriptions = [];
13
- constructor(fns, callback) {
14
- this.#callback = callback;
15
- // eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/require-await
16
- this.#subscriptions = fns.map(async (input, index) => {
17
- const [fn, ...args] = Array.isArray(input)
18
- ? input
19
- : [input];
20
- this.#fired.push(false);
21
- this.#fns.push(fn);
22
- // Not quite 100% how to have a variable number at the front here
23
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/ban-types
24
- return fn(...args, this._createCallback(index));
25
- });
26
- }
27
- _allHasFired() {
28
- this.#allHasFired ||= this.#fired.filter((hasFired) => !hasFired).length === 0;
29
- return this.#allHasFired;
30
- }
31
- _createCallback(index) {
32
- return (value) => {
33
- this.#fired[index] = true;
34
- this.#results[index] = value;
35
- this._triggerUpdate();
36
- };
37
- }
38
- _triggerUpdate() {
39
- if (!this.#isActive || !(0, util_1.isFunction)(this.#callback) || !this._allHasFired()) {
40
- return;
41
- }
42
- try {
43
- Promise
44
- .resolve(this.#callback(this.#results))
45
- .catch(util_1.noop);
46
- }
47
- catch {
48
- // swallow, we don't want the handler to trip us up
49
- }
50
- }
51
- unsubscribe() {
52
- if (!this.#isActive) {
53
- return;
54
- }
55
- this.#isActive = false;
56
- Promise
57
- .all(this.#subscriptions.map(async (subscription) => {
58
- try {
59
- const unsubscribe = await subscription;
60
- if ((0, util_1.isFunction)(unsubscribe)) {
61
- unsubscribe();
62
- }
63
- }
64
- catch {
65
- // ignore
66
- }
67
- })).catch(() => {
68
- // ignore, already ignored above, should never throw
69
- });
70
- }
71
- }
72
- exports.Combinator = Combinator;
@@ -1,14 +0,0 @@
1
- import type { Observable } from 'rxjs';
2
- import type { Codec } from '@pezkuwi/types/types';
3
- import type { DecorateFn, DecorateMethodOptions, ObsInnerType, StorageEntryPromiseOverloads } from '../types/index.js';
4
- interface Tracker<T> {
5
- reject: (value: Error) => Observable<never>;
6
- resolve: (value: T) => void;
7
- }
8
- type CodecReturnType<T extends (...args: unknown[]) => Observable<Codec>> = T extends (...args: any) => infer R ? R extends Observable<Codec> ? ObsInnerType<R> : never : never;
9
- export declare function promiseTracker<T>(resolve: (value: T) => void, reject: (value: Error) => void): Tracker<T>;
10
- /**
11
- * @description Decorate method for ApiPromise, where the results are converted to the Promise equivalent
12
- */
13
- export declare function toPromiseMethod<M extends DecorateFn<CodecReturnType<M>>>(method: M, options?: DecorateMethodOptions): StorageEntryPromiseOverloads;
14
- export {};
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promiseTracker = promiseTracker;
4
- exports.toPromiseMethod = toPromiseMethod;
5
- const rxjs_1 = require("rxjs");
6
- const util_1 = require("@pezkuwi/util");
7
- function promiseTracker(resolve, reject) {
8
- let isCompleted = false;
9
- return {
10
- reject: (error) => {
11
- if (!isCompleted) {
12
- isCompleted = true;
13
- reject(error);
14
- }
15
- return rxjs_1.EMPTY;
16
- },
17
- resolve: (value) => {
18
- if (!isCompleted) {
19
- isCompleted = true;
20
- resolve(value);
21
- }
22
- }
23
- };
24
- }
25
- function extractArgs(args, needsCallback) {
26
- const actualArgs = args.slice();
27
- // If the last arg is a function, we pop it, put it into callback.
28
- // actualArgs will then hold the actual arguments to be passed to `method`
29
- const callback = (args.length && (0, util_1.isFunction)(args[args.length - 1]))
30
- ? actualArgs.pop()
31
- : undefined;
32
- // When we need a subscription, ensure that a valid callback is actually passed
33
- if (needsCallback && !(0, util_1.isFunction)(callback)) {
34
- throw new Error('Expected a callback to be passed with subscriptions');
35
- }
36
- return [actualArgs, callback];
37
- }
38
- function decorateCall(method, args) {
39
- return new Promise((resolve, reject) => {
40
- // single result tracker - either reject with Error or resolve with Codec result
41
- const tracker = promiseTracker(resolve, reject);
42
- // encoding errors reject immediately, any result unsubscribes and resolves
43
- const subscription = method(...args)
44
- .pipe((0, rxjs_1.catchError)((error) => tracker.reject(error)))
45
- .subscribe((result) => {
46
- tracker.resolve(result);
47
- (0, util_1.nextTick)(() => subscription.unsubscribe());
48
- });
49
- });
50
- }
51
- function decorateSubscribe(method, args, resultCb) {
52
- return new Promise((resolve, reject) => {
53
- // either reject with error or resolve with unsubscribe callback
54
- const tracker = promiseTracker(resolve, reject);
55
- // errors reject immediately, the first result resolves with an unsubscribe promise, all results via callback
56
- const subscription = method(...args)
57
- .pipe((0, rxjs_1.catchError)((error) => tracker.reject(error)), (0, rxjs_1.tap)(() => tracker.resolve(() => subscription.unsubscribe())))
58
- .subscribe((result) => {
59
- // queue result (back of queue to clear current)
60
- (0, util_1.nextTick)(() => resultCb(result));
61
- });
62
- });
63
- }
64
- /**
65
- * @description Decorate method for ApiPromise, where the results are converted to the Promise equivalent
66
- */
67
- function toPromiseMethod(method, options) {
68
- const needsCallback = !!(options?.methodName && options.methodName.includes('subscribe'));
69
- return function (...args) {
70
- const [actualArgs, resultCb] = extractArgs(args, needsCallback);
71
- return resultCb
72
- ? decorateSubscribe(method, actualArgs, resultCb)
73
- : decorateCall(options?.overrideNoSub || method, actualArgs);
74
- };
75
- }
@@ -1,2 +0,0 @@
1
- export { ApiPromise } from './Api.js';
2
- export { toPromiseMethod } from './decorateMethod.js';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toPromiseMethod = exports.ApiPromise = void 0;
4
- var Api_js_1 = require("./Api.js");
5
- Object.defineProperty(exports, "ApiPromise", { enumerable: true, get: function () { return Api_js_1.ApiPromise; } });
6
- var decorateMethod_js_1 = require("./decorateMethod.js");
7
- Object.defineProperty(exports, "toPromiseMethod", { enumerable: true, get: function () { return decorateMethod_js_1.toPromiseMethod; } });
@@ -1,5 +0,0 @@
1
- import type { SubmittableExtrinsic as SubmittableExtrinsicBase } from '../submittable/types.js';
2
- import type { QueryableStorageEntry as QueryableStorageEntryBase, SubmittableExtrinsicFunction as SubmittableExtrinsicFunctionBase } from '../types/index.js';
3
- export type QueryableStorageEntry = QueryableStorageEntryBase<'promise'>;
4
- export type SubmittableExtrinsic = SubmittableExtrinsicBase<'promise'>;
5
- export type SubmittableExtrinsicFunction = SubmittableExtrinsicFunctionBase<'promise'>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });