@peeramid-labs/sdk 3.14.0 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. package/README.md +42 -1
  2. package/cli/abis/ArguableVotingTournament.js +15 -0
  3. package/cli/abis/ArguableVotingTournament.js.map +1 -1
  4. package/cli/abis/MAODistribution.js +16 -0
  5. package/cli/abis/MAODistribution.js.map +1 -1
  6. package/cli/abis/MockShortStrings.js +37 -0
  7. package/cli/abis/MockShortStrings.js.map +1 -0
  8. package/cli/abis/Multipass.js +7 -1
  9. package/cli/abis/Multipass.js.map +1 -1
  10. package/cli/abis/PausableUpgradeable.js +79 -0
  11. package/cli/abis/PausableUpgradeable.js.map +1 -0
  12. package/cli/abis/RankToken.js +38 -0
  13. package/cli/abis/RankToken.js.map +1 -1
  14. package/cli/abis/RankifyDiamondInstance.js +3275 -1863
  15. package/cli/abis/RankifyDiamondInstance.js.map +1 -1
  16. package/cli/abis/RankifyInstanceInit.js +190 -0
  17. package/cli/abis/RankifyInstanceInit.js.map +1 -1
  18. package/cli/abis/RankifyInstanceMainFacet.js +99 -68
  19. package/cli/abis/RankifyInstanceMainFacet.js.map +1 -1
  20. package/cli/abis/RankifyOwnersFacet.js +78 -0
  21. package/cli/abis/RankifyOwnersFacet.js.map +1 -0
  22. package/cli/abis/ScoreGetterFacet.js +195 -0
  23. package/cli/abis/ScoreGetterFacet.js.map +1 -0
  24. package/cli/abis/UBI.js +775 -0
  25. package/cli/abis/UBI.js.map +1 -0
  26. package/cli/abis/index.js +21 -1
  27. package/cli/abis/index.js.map +1 -1
  28. package/cli/abis/superinterface.js +192 -7
  29. package/cli/abis/superinterface.js.map +1 -1
  30. package/cli/cli/commands/blockchain/mine.js +0 -2
  31. package/cli/cli/commands/blockchain/mine.js.map +1 -1
  32. package/cli/cli/commands/fellowship/game/create.js +49 -2
  33. package/cli/cli/commands/fellowship/game/create.js.map +1 -1
  34. package/cli/cli/commands/fellowship/game/end-proposing.js +2 -2
  35. package/cli/cli/commands/fellowship/game/end-proposing.js.map +1 -1
  36. package/cli/cli/commands/fellowship/game/end-voting.js +2 -2
  37. package/cli/cli/commands/fellowship/game/end-voting.js.map +1 -1
  38. package/cli/cli/commands/fellowship/game/join.js +2 -1
  39. package/cli/cli/commands/fellowship/game/join.js.map +1 -1
  40. package/cli/cli/commands/fellowship/game/start.js +0 -17
  41. package/cli/cli/commands/fellowship/game/start.js.map +1 -1
  42. package/cli/cli/commands/fellowship/game/vote.js +2 -1
  43. package/cli/cli/commands/fellowship/game/vote.js.map +1 -1
  44. package/cli/cli/commands/fellowship/gameMaster/add.js +52 -0
  45. package/cli/cli/commands/fellowship/gameMaster/add.js.map +1 -0
  46. package/cli/cli/commands/fellowship/gameMaster/index.js +7 -0
  47. package/cli/cli/commands/fellowship/gameMaster/index.js.map +1 -0
  48. package/cli/cli/commands/fellowship/index.js +3 -1
  49. package/cli/cli/commands/fellowship/index.js.map +1 -1
  50. package/cli/cli/commands/instances/list.js +6 -0
  51. package/cli/cli/commands/instances/list.js.map +1 -1
  52. package/cli/cli/commands/multipass/contract.js +26 -0
  53. package/cli/cli/commands/multipass/contract.js.map +1 -1
  54. package/cli/cli/commands/multipass/domain.js +44 -1
  55. package/cli/cli/commands/multipass/domain.js.map +1 -1
  56. package/cli/cli/commands/multipass/domains.js +16 -2
  57. package/cli/cli/commands/multipass/domains.js.map +1 -1
  58. package/cli/cli/playbooks/demo-script.js +192 -0
  59. package/cli/cli/playbooks/demo-script.js.map +1 -0
  60. package/cli/cli/playbooks/demoScript.js +190 -0
  61. package/cli/cli/playbooks/demoScript.js.map +1 -0
  62. package/cli/cli/playbooks/initGameMaster.js +50 -0
  63. package/cli/cli/playbooks/initGameMaster.js.map +1 -0
  64. package/cli/cli/playbooks/playbookRunner.js +80 -0
  65. package/cli/cli/playbooks/playbookRunner.js.map +1 -0
  66. package/cli/cli/playbooks/push-game-to-next-phase.js +162 -0
  67. package/cli/cli/playbooks/push-game-to-next-phase.js.map +1 -0
  68. package/cli/cli/playbooks/utils.js +210 -0
  69. package/cli/cli/playbooks/utils.js.map +1 -0
  70. package/cli/cli/utils.js +47 -0
  71. package/cli/cli/utils.js.map +1 -1
  72. package/cli/multipass/MultipassBase.js +38 -70
  73. package/cli/multipass/MultipassBase.js.map +1 -1
  74. package/cli/multipass/Owner.js +34 -16
  75. package/cli/multipass/Owner.js.map +1 -1
  76. package/cli/rankify/GameMaster.js +1 -1
  77. package/cli/rankify/GameMaster.js.map +1 -1
  78. package/cli/rankify/InstanceAdmininstrative.js +70 -0
  79. package/cli/rankify/InstanceAdmininstrative.js.map +1 -0
  80. package/cli/rankify/InstanceBase.js +168 -2
  81. package/cli/rankify/InstanceBase.js.map +1 -1
  82. package/cli/rankify/Player.js +45 -3
  83. package/cli/rankify/Player.js.map +1 -1
  84. package/cli/types.js +7 -1
  85. package/cli/types.js.map +1 -1
  86. package/cli/utils/EnvioGraphQLClient.js +527 -0
  87. package/cli/utils/EnvioGraphQLClient.js.map +1 -1
  88. package/cli/utils/artifacts.js +23 -2
  89. package/cli/utils/artifacts.js.map +1 -1
  90. package/cli/utils/chainMapping.js +1 -1
  91. package/cli/utils/chainMapping.js.map +1 -1
  92. package/docs/classes/EnvioGraphQLClient.md +390 -22
  93. package/docs/classes/GameMaster.md +19 -0
  94. package/docs/classes/InstanceBase.md +179 -4
  95. package/docs/classes/InstancePlayer.md +214 -13
  96. package/docs/classes/InstanceUBI.md +1591 -0
  97. package/docs/classes/Multipass.md +31 -4
  98. package/docs/classes/MultipassBase.md +26 -3
  99. package/docs/docs/classes/EnvioGraphQLClient.md +390 -22
  100. package/docs/docs/classes/GameMaster.md +19 -0
  101. package/docs/docs/classes/InstanceBase.md +179 -4
  102. package/docs/docs/classes/InstancePlayer.md +214 -13
  103. package/docs/docs/classes/InstanceUBI.md +1591 -0
  104. package/docs/docs/classes/Multipass.md +31 -4
  105. package/docs/docs/classes/MultipassBase.md +26 -3
  106. package/docs/docs/enums/ContractTypes.md +27 -0
  107. package/docs/docs/index.md +25 -8
  108. package/docs/docs/interfaces/ContractCondition.md +41 -0
  109. package/docs/docs/interfaces/DailyProposal.md +36 -0
  110. package/docs/docs/interfaces/EnvioGraphQLClientConfig.md +9 -0
  111. package/docs/docs/interfaces/JoinRequirementsInput.md +20 -0
  112. package/docs/docs/interfaces/ProposalGlobalStats.md +29 -0
  113. package/docs/docs/interfaces/TransactionProperties.md +20 -0
  114. package/docs/docs/interfaces/UBIParams.md +29 -0
  115. package/docs/docs/interfaces/UserState.md +22 -0
  116. package/docs/docs/interfaces/VoteElement.md +22 -0
  117. package/docs/docs/interfaces/configSmartRequirement.md +34 -0
  118. package/docs/docs/interfaces/numericConditon.md +41 -0
  119. package/docs/enums/ContractTypes.md +27 -0
  120. package/docs/index.md +25 -8
  121. package/docs/interfaces/ContractCondition.md +41 -0
  122. package/docs/interfaces/DailyProposal.md +36 -0
  123. package/docs/interfaces/EnvioGraphQLClientConfig.md +9 -0
  124. package/docs/interfaces/JoinRequirementsInput.md +20 -0
  125. package/docs/interfaces/ProposalGlobalStats.md +29 -0
  126. package/docs/interfaces/TransactionProperties.md +20 -0
  127. package/docs/interfaces/UBIParams.md +29 -0
  128. package/docs/interfaces/UserState.md +22 -0
  129. package/docs/interfaces/VoteElement.md +22 -0
  130. package/docs/interfaces/configSmartRequirement.md +34 -0
  131. package/docs/interfaces/numericConditon.md +41 -0
  132. package/lib.commonjs/abis/ArguableVotingTournament.d.ts +12 -0
  133. package/lib.commonjs/abis/ArguableVotingTournament.d.ts.map +1 -1
  134. package/lib.commonjs/abis/ArguableVotingTournament.js +15 -0
  135. package/lib.commonjs/abis/ArguableVotingTournament.js.map +1 -1
  136. package/lib.commonjs/abis/MAODistribution.d.ts +12 -0
  137. package/lib.commonjs/abis/MAODistribution.d.ts.map +1 -1
  138. package/lib.commonjs/abis/MAODistribution.js +16 -0
  139. package/lib.commonjs/abis/MAODistribution.js.map +1 -1
  140. package/lib.commonjs/abis/MockShortStrings.d.ts +25 -0
  141. package/lib.commonjs/abis/MockShortStrings.d.ts.map +1 -0
  142. package/lib.commonjs/abis/MockShortStrings.js +37 -0
  143. package/lib.commonjs/abis/MockShortStrings.js.map +1 -0
  144. package/lib.commonjs/abis/Multipass.d.ts +5 -1
  145. package/lib.commonjs/abis/Multipass.d.ts.map +1 -1
  146. package/lib.commonjs/abis/Multipass.js +7 -1
  147. package/lib.commonjs/abis/Multipass.js.map +1 -1
  148. package/lib.commonjs/abis/PausableUpgradeable.d.ts +59 -0
  149. package/lib.commonjs/abis/PausableUpgradeable.d.ts.map +1 -0
  150. package/lib.commonjs/abis/PausableUpgradeable.js +79 -0
  151. package/lib.commonjs/abis/PausableUpgradeable.js.map +1 -0
  152. package/lib.commonjs/abis/RankToken.d.ts +30 -0
  153. package/lib.commonjs/abis/RankToken.d.ts.map +1 -1
  154. package/lib.commonjs/abis/RankToken.js +38 -0
  155. package/lib.commonjs/abis/RankToken.js.map +1 -1
  156. package/lib.commonjs/abis/RankifyDiamondInstance.d.ts +2499 -1401
  157. package/lib.commonjs/abis/RankifyDiamondInstance.d.ts.map +1 -1
  158. package/lib.commonjs/abis/RankifyDiamondInstance.js +3275 -1863
  159. package/lib.commonjs/abis/RankifyDiamondInstance.js.map +1 -1
  160. package/lib.commonjs/abis/RankifyInstanceInit.d.ts +150 -0
  161. package/lib.commonjs/abis/RankifyInstanceInit.d.ts.map +1 -1
  162. package/lib.commonjs/abis/RankifyInstanceInit.js +190 -0
  163. package/lib.commonjs/abis/RankifyInstanceInit.js.map +1 -1
  164. package/lib.commonjs/abis/RankifyInstanceMainFacet.d.ts +81 -56
  165. package/lib.commonjs/abis/RankifyInstanceMainFacet.d.ts.map +1 -1
  166. package/lib.commonjs/abis/RankifyInstanceMainFacet.js +99 -68
  167. package/lib.commonjs/abis/RankifyInstanceMainFacet.js.map +1 -1
  168. package/lib.commonjs/abis/RankifyOwnersFacet.d.ts +57 -0
  169. package/lib.commonjs/abis/RankifyOwnersFacet.d.ts.map +1 -0
  170. package/lib.commonjs/abis/RankifyOwnersFacet.js +78 -0
  171. package/lib.commonjs/abis/RankifyOwnersFacet.js.map +1 -0
  172. package/lib.commonjs/abis/ScoreGetterFacet.d.ts +145 -0
  173. package/lib.commonjs/abis/ScoreGetterFacet.d.ts.map +1 -0
  174. package/lib.commonjs/abis/ScoreGetterFacet.js +195 -0
  175. package/lib.commonjs/abis/ScoreGetterFacet.js.map +1 -0
  176. package/lib.commonjs/abis/UBI.d.ts +601 -0
  177. package/lib.commonjs/abis/UBI.d.ts.map +1 -0
  178. package/lib.commonjs/abis/UBI.js +775 -0
  179. package/lib.commonjs/abis/UBI.js.map +1 -0
  180. package/lib.commonjs/abis/index.d.ts +3746 -1533
  181. package/lib.commonjs/abis/index.d.ts.map +1 -1
  182. package/lib.commonjs/abis/index.js +21 -1
  183. package/lib.commonjs/abis/index.js.map +1 -1
  184. package/lib.commonjs/abis/superinterface.d.ts +1 -1
  185. package/lib.commonjs/abis/superinterface.d.ts.map +1 -1
  186. package/lib.commonjs/abis/superinterface.js +192 -7
  187. package/lib.commonjs/abis/superinterface.js.map +1 -1
  188. package/lib.commonjs/index.d.ts +2 -0
  189. package/lib.commonjs/index.d.ts.map +1 -1
  190. package/lib.commonjs/index.js +3 -1
  191. package/lib.commonjs/index.js.map +1 -1
  192. package/lib.commonjs/multipass/MultipassBase.d.ts +18 -4
  193. package/lib.commonjs/multipass/MultipassBase.d.ts.map +1 -1
  194. package/lib.commonjs/multipass/MultipassBase.js +39 -71
  195. package/lib.commonjs/multipass/MultipassBase.js.map +1 -1
  196. package/lib.commonjs/multipass/Owner.d.ts +22 -8
  197. package/lib.commonjs/multipass/Owner.d.ts.map +1 -1
  198. package/lib.commonjs/multipass/Owner.js +34 -16
  199. package/lib.commonjs/multipass/Owner.js.map +1 -1
  200. package/lib.commonjs/multipass/Registrar.d.ts +3 -1
  201. package/lib.commonjs/multipass/Registrar.d.ts.map +1 -1
  202. package/lib.commonjs/multipass/Registrar.js +2 -2
  203. package/lib.commonjs/multipass/Registrar.js.map +1 -1
  204. package/lib.commonjs/rankify/GameMaster.d.ts +5 -1
  205. package/lib.commonjs/rankify/GameMaster.d.ts.map +1 -1
  206. package/lib.commonjs/rankify/GameMaster.js +1 -1
  207. package/lib.commonjs/rankify/GameMaster.js.map +1 -1
  208. package/lib.commonjs/rankify/InstanceAdmininstrative.d.ts +34 -0
  209. package/lib.commonjs/rankify/InstanceAdmininstrative.d.ts.map +1 -0
  210. package/lib.commonjs/rankify/InstanceAdmininstrative.js +74 -0
  211. package/lib.commonjs/rankify/InstanceAdmininstrative.js.map +1 -0
  212. package/lib.commonjs/rankify/InstanceBase.d.ts +63 -2
  213. package/lib.commonjs/rankify/InstanceBase.d.ts.map +1 -1
  214. package/lib.commonjs/rankify/InstanceBase.js +168 -2
  215. package/lib.commonjs/rankify/InstanceBase.js.map +1 -1
  216. package/lib.commonjs/rankify/Player.d.ts +5 -35
  217. package/lib.commonjs/rankify/Player.d.ts.map +1 -1
  218. package/lib.commonjs/rankify/Player.js +45 -3
  219. package/lib.commonjs/rankify/Player.js.map +1 -1
  220. package/lib.commonjs/types.d.ts +33 -0
  221. package/lib.commonjs/types.d.ts.map +1 -1
  222. package/lib.commonjs/types.js +7 -1
  223. package/lib.commonjs/types.js.map +1 -1
  224. package/lib.commonjs/ubi/InstanceUBI.d.ts +548 -0
  225. package/lib.commonjs/ubi/InstanceUBI.d.ts.map +1 -0
  226. package/lib.commonjs/ubi/InstanceUBI.js +728 -0
  227. package/lib.commonjs/ubi/InstanceUBI.js.map +1 -0
  228. package/lib.commonjs/utils/EnvioGraphQLClient.d.ts +295 -0
  229. package/lib.commonjs/utils/EnvioGraphQLClient.d.ts.map +1 -1
  230. package/lib.commonjs/utils/EnvioGraphQLClient.js +527 -0
  231. package/lib.commonjs/utils/EnvioGraphQLClient.js.map +1 -1
  232. package/lib.commonjs/utils/artifacts.d.ts.map +1 -1
  233. package/lib.commonjs/utils/artifacts.js +23 -2
  234. package/lib.commonjs/utils/artifacts.js.map +1 -1
  235. package/lib.commonjs/utils/chainMapping.js +1 -1
  236. package/lib.commonjs/utils/chainMapping.js.map +1 -1
  237. package/lib.commonjs/utils/mockUtils.d.ts +3 -0
  238. package/lib.commonjs/utils/mockUtils.d.ts.map +1 -1
  239. package/lib.commonjs/utils/mockUtils.js +3 -0
  240. package/lib.commonjs/utils/mockUtils.js.map +1 -1
  241. package/lib.esm/abis/ArguableVotingTournament.d.ts +12 -0
  242. package/lib.esm/abis/ArguableVotingTournament.d.ts.map +1 -1
  243. package/lib.esm/abis/ArguableVotingTournament.js +15 -0
  244. package/lib.esm/abis/ArguableVotingTournament.js.map +1 -1
  245. package/lib.esm/abis/MAODistribution.d.ts +12 -0
  246. package/lib.esm/abis/MAODistribution.d.ts.map +1 -1
  247. package/lib.esm/abis/MAODistribution.js +16 -0
  248. package/lib.esm/abis/MAODistribution.js.map +1 -1
  249. package/lib.esm/abis/MockShortStrings.d.ts +25 -0
  250. package/lib.esm/abis/MockShortStrings.d.ts.map +1 -0
  251. package/lib.esm/abis/MockShortStrings.js +34 -0
  252. package/lib.esm/abis/MockShortStrings.js.map +1 -0
  253. package/lib.esm/abis/Multipass.d.ts +5 -1
  254. package/lib.esm/abis/Multipass.d.ts.map +1 -1
  255. package/lib.esm/abis/Multipass.js +7 -1
  256. package/lib.esm/abis/Multipass.js.map +1 -1
  257. package/lib.esm/abis/PausableUpgradeable.d.ts +59 -0
  258. package/lib.esm/abis/PausableUpgradeable.d.ts.map +1 -0
  259. package/lib.esm/abis/PausableUpgradeable.js +76 -0
  260. package/lib.esm/abis/PausableUpgradeable.js.map +1 -0
  261. package/lib.esm/abis/RankToken.d.ts +30 -0
  262. package/lib.esm/abis/RankToken.d.ts.map +1 -1
  263. package/lib.esm/abis/RankToken.js +38 -0
  264. package/lib.esm/abis/RankToken.js.map +1 -1
  265. package/lib.esm/abis/RankifyDiamondInstance.d.ts +2499 -1401
  266. package/lib.esm/abis/RankifyDiamondInstance.d.ts.map +1 -1
  267. package/lib.esm/abis/RankifyDiamondInstance.js +3275 -1863
  268. package/lib.esm/abis/RankifyDiamondInstance.js.map +1 -1
  269. package/lib.esm/abis/RankifyInstanceInit.d.ts +150 -0
  270. package/lib.esm/abis/RankifyInstanceInit.d.ts.map +1 -1
  271. package/lib.esm/abis/RankifyInstanceInit.js +190 -0
  272. package/lib.esm/abis/RankifyInstanceInit.js.map +1 -1
  273. package/lib.esm/abis/RankifyInstanceMainFacet.d.ts +81 -56
  274. package/lib.esm/abis/RankifyInstanceMainFacet.d.ts.map +1 -1
  275. package/lib.esm/abis/RankifyInstanceMainFacet.js +99 -68
  276. package/lib.esm/abis/RankifyInstanceMainFacet.js.map +1 -1
  277. package/lib.esm/abis/RankifyOwnersFacet.d.ts +57 -0
  278. package/lib.esm/abis/RankifyOwnersFacet.d.ts.map +1 -0
  279. package/lib.esm/abis/RankifyOwnersFacet.js +75 -0
  280. package/lib.esm/abis/RankifyOwnersFacet.js.map +1 -0
  281. package/lib.esm/abis/ScoreGetterFacet.d.ts +145 -0
  282. package/lib.esm/abis/ScoreGetterFacet.d.ts.map +1 -0
  283. package/lib.esm/abis/ScoreGetterFacet.js +192 -0
  284. package/lib.esm/abis/ScoreGetterFacet.js.map +1 -0
  285. package/lib.esm/abis/UBI.d.ts +601 -0
  286. package/lib.esm/abis/UBI.d.ts.map +1 -0
  287. package/lib.esm/abis/UBI.js +772 -0
  288. package/lib.esm/abis/UBI.js.map +1 -0
  289. package/lib.esm/abis/index.d.ts +3746 -1533
  290. package/lib.esm/abis/index.d.ts.map +1 -1
  291. package/lib.esm/abis/index.js +15 -0
  292. package/lib.esm/abis/index.js.map +1 -1
  293. package/lib.esm/abis/superinterface.d.ts +1 -1
  294. package/lib.esm/abis/superinterface.d.ts.map +1 -1
  295. package/lib.esm/abis/superinterface.js +192 -7
  296. package/lib.esm/abis/superinterface.js.map +1 -1
  297. package/lib.esm/index.d.ts +2 -0
  298. package/lib.esm/index.d.ts.map +1 -1
  299. package/lib.esm/index.js +1 -0
  300. package/lib.esm/index.js.map +1 -1
  301. package/lib.esm/multipass/MultipassBase.d.ts +18 -4
  302. package/lib.esm/multipass/MultipassBase.d.ts.map +1 -1
  303. package/lib.esm/multipass/MultipassBase.js +40 -72
  304. package/lib.esm/multipass/MultipassBase.js.map +1 -1
  305. package/lib.esm/multipass/Owner.d.ts +22 -8
  306. package/lib.esm/multipass/Owner.d.ts.map +1 -1
  307. package/lib.esm/multipass/Owner.js +34 -16
  308. package/lib.esm/multipass/Owner.js.map +1 -1
  309. package/lib.esm/multipass/Registrar.d.ts +3 -1
  310. package/lib.esm/multipass/Registrar.d.ts.map +1 -1
  311. package/lib.esm/multipass/Registrar.js +2 -2
  312. package/lib.esm/multipass/Registrar.js.map +1 -1
  313. package/lib.esm/rankify/GameMaster.d.ts +5 -1
  314. package/lib.esm/rankify/GameMaster.d.ts.map +1 -1
  315. package/lib.esm/rankify/GameMaster.js +1 -1
  316. package/lib.esm/rankify/GameMaster.js.map +1 -1
  317. package/lib.esm/rankify/InstanceAdmininstrative.d.ts +34 -0
  318. package/lib.esm/rankify/InstanceAdmininstrative.d.ts.map +1 -0
  319. package/lib.esm/rankify/InstanceAdmininstrative.js +70 -0
  320. package/lib.esm/rankify/InstanceAdmininstrative.js.map +1 -0
  321. package/lib.esm/rankify/InstanceBase.d.ts +63 -2
  322. package/lib.esm/rankify/InstanceBase.d.ts.map +1 -1
  323. package/lib.esm/rankify/InstanceBase.js +168 -2
  324. package/lib.esm/rankify/InstanceBase.js.map +1 -1
  325. package/lib.esm/rankify/Player.d.ts +5 -35
  326. package/lib.esm/rankify/Player.d.ts.map +1 -1
  327. package/lib.esm/rankify/Player.js +45 -3
  328. package/lib.esm/rankify/Player.js.map +1 -1
  329. package/lib.esm/types.d.ts +33 -0
  330. package/lib.esm/types.d.ts.map +1 -1
  331. package/lib.esm/types.js +6 -0
  332. package/lib.esm/types.js.map +1 -1
  333. package/lib.esm/ubi/InstanceUBI.d.ts +548 -0
  334. package/lib.esm/ubi/InstanceUBI.d.ts.map +1 -0
  335. package/lib.esm/ubi/InstanceUBI.js +722 -0
  336. package/lib.esm/ubi/InstanceUBI.js.map +1 -0
  337. package/lib.esm/utils/EnvioGraphQLClient.d.ts +295 -0
  338. package/lib.esm/utils/EnvioGraphQLClient.d.ts.map +1 -1
  339. package/lib.esm/utils/EnvioGraphQLClient.js +527 -0
  340. package/lib.esm/utils/EnvioGraphQLClient.js.map +1 -1
  341. package/lib.esm/utils/artifacts.d.ts.map +1 -1
  342. package/lib.esm/utils/artifacts.js +23 -2
  343. package/lib.esm/utils/artifacts.js.map +1 -1
  344. package/lib.esm/utils/chainMapping.js +1 -1
  345. package/lib.esm/utils/chainMapping.js.map +1 -1
  346. package/lib.esm/utils/mockUtils.d.ts +3 -0
  347. package/lib.esm/utils/mockUtils.d.ts.map +1 -1
  348. package/lib.esm/utils/mockUtils.js +3 -0
  349. package/lib.esm/utils/mockUtils.js.map +1 -1
  350. package/package.json +7 -7
@@ -0,0 +1,722 @@
1
+ import { handleRPCError } from "../utils/index";
2
+ import abis from "../abis";
3
+ const { UBIAbi } = abis;
4
+ import InstanceBase from "../rankify/InstanceBase";
5
+ /**
6
+ * Class for interacting with UBI facet of a Rankify instance
7
+ * Extends InstanceBase and provides UBI-specific functionality
8
+ */
9
+ export default class InstanceUBI extends InstanceBase {
10
+ /** Wallet client for write operations (optional) */
11
+ walletClient;
12
+ /** Account address for write operations */
13
+ account;
14
+ /**
15
+ * Creates a new InstanceUBI
16
+ * @param {Object} params - Constructor parameters
17
+ * @param {PublicClient} params.publicClient - Public client for blockchain interactions
18
+ * @param {WalletClient} params.walletClient - Optional wallet client for write operations
19
+ * @param {number} params.chainId - Chain ID of the network
20
+ * @param {Address} params.instanceAddress - Address of the Rankify instance with UBI facet
21
+ * @param {Address} params.account - Optional account address for write operations
22
+ * @param {EnvioGraphQLClient} params.envioClient - Envio GraphQL client for event queries
23
+ */
24
+ constructor({ publicClient, walletClient, chainId, instanceAddress, account, envioClient, }) {
25
+ super({
26
+ publicClient,
27
+ chainId,
28
+ instanceAddress,
29
+ envioClient,
30
+ });
31
+ this.walletClient = walletClient;
32
+ this.account = account || walletClient?.account?.address;
33
+ }
34
+ /**
35
+ * Gets the current day number based on block timestamp
36
+ * @returns The current day number (block.timestamp / 1 days)
37
+ */
38
+ getCurrentDay = async () => {
39
+ try {
40
+ return await this.publicClient.readContract({
41
+ address: this.instanceAddress,
42
+ abi: UBIAbi,
43
+ functionName: "getCurrentDay",
44
+ });
45
+ }
46
+ catch (e) {
47
+ throw await handleRPCError(e);
48
+ }
49
+ };
50
+ /**
51
+ * Gets the current day number (alias for getCurrentDay)
52
+ * @returns The current day number
53
+ */
54
+ currentDay = async () => {
55
+ try {
56
+ return await this.publicClient.readContract({
57
+ address: this.instanceAddress,
58
+ abi: UBIAbi,
59
+ functionName: "currentDay",
60
+ });
61
+ }
62
+ catch (e) {
63
+ throw await handleRPCError(e);
64
+ }
65
+ };
66
+ /**
67
+ * Gets the UBI system parameters
68
+ * @returns Object containing dailyClaimAmount, dailySupportAmount, and domainName
69
+ */
70
+ getUBIParams = async () => {
71
+ try {
72
+ const [dailyClaimAmount, dailySupportAmount, domainName] = await this.publicClient.readContract({
73
+ address: this.instanceAddress,
74
+ abi: UBIAbi,
75
+ functionName: "getUBIParams",
76
+ });
77
+ console.log("dailyClaimAmount", dailyClaimAmount);
78
+ console.log("dailySupportAmount", dailySupportAmount);
79
+ console.log("domainName", domainName);
80
+ return {
81
+ dailyClaimAmount,
82
+ dailySupportAmount,
83
+ domainName,
84
+ };
85
+ }
86
+ catch (e) {
87
+ throw await handleRPCError(e);
88
+ }
89
+ };
90
+ /**
91
+ * Gets the lifetime statistics for a proposal
92
+ * @param proposalHash - The hash of the proposal
93
+ * @returns Object containing aggregateScore, proposedTimes, and repostedTimes
94
+ */
95
+ getProposalLifetimeStats = async (proposalHash) => {
96
+ try {
97
+ const result = await this.publicClient.readContract({
98
+ address: this.instanceAddress,
99
+ abi: UBIAbi,
100
+ functionName: "proposalLifetimeStats",
101
+ args: [proposalHash],
102
+ });
103
+ return {
104
+ aggregateScore: result.aggregateScore,
105
+ proposedTimes: result.proposedTimes,
106
+ repostedTimes: result.repostedTimes,
107
+ };
108
+ }
109
+ catch (e) {
110
+ throw await handleRPCError(e);
111
+ }
112
+ };
113
+ /**
114
+ * Gets the daily score for a proposal on a specific day
115
+ * @param proposalHash - The hash of the proposal
116
+ * @param day - The day number to query
117
+ * @returns DailyProposal object with proposal details for that day
118
+ */
119
+ getProposalDailyScore = async (proposalHash, day) => {
120
+ try {
121
+ const result = await this.publicClient.readContract({
122
+ address: this.instanceAddress,
123
+ abi: UBIAbi,
124
+ functionName: "getProposalDailyScore",
125
+ args: [proposalHash, day],
126
+ });
127
+ return {
128
+ proposal: result.proposal,
129
+ score: result.score,
130
+ proposer: result.proposer,
131
+ exists: result.exists,
132
+ };
133
+ }
134
+ catch (e) {
135
+ throw await handleRPCError(e);
136
+ }
137
+ };
138
+ /**
139
+ * Gets the total number of proposals for a specific day
140
+ * @param day - The day number to query
141
+ * @returns The count of proposals for that day
142
+ */
143
+ getProposalsCnt = async (day) => {
144
+ try {
145
+ return await this.publicClient.readContract({
146
+ address: this.instanceAddress,
147
+ abi: UBIAbi,
148
+ functionName: "getProposalsCnt",
149
+ args: [day],
150
+ });
151
+ }
152
+ catch (e) {
153
+ throw await handleRPCError(e);
154
+ }
155
+ };
156
+ /**
157
+ * Gets the day a user last claimed their tokens
158
+ * @param user - The address of the user
159
+ * @returns The day number of the last claim (0 if never claimed)
160
+ */
161
+ getLastClaimedAt = async (user) => {
162
+ try {
163
+ return await this.publicClient.readContract({
164
+ address: this.instanceAddress,
165
+ abi: UBIAbi,
166
+ functionName: "lastClaimedAt",
167
+ args: [user],
168
+ });
169
+ }
170
+ catch (e) {
171
+ throw await handleRPCError(e);
172
+ }
173
+ };
174
+ /**
175
+ * Gets the current state for a user
176
+ * @param user - The address of the user
177
+ * @returns Object containing claimedToday and supportSpent
178
+ */
179
+ getUserState = async (user) => {
180
+ try {
181
+ const [claimedToday, supportSpent] = await this.publicClient.readContract({
182
+ address: this.instanceAddress,
183
+ abi: UBIAbi,
184
+ functionName: "getUserState",
185
+ args: [user],
186
+ });
187
+ return {
188
+ claimedToday,
189
+ supportSpent,
190
+ };
191
+ }
192
+ catch (e) {
193
+ throw await handleRPCError(e);
194
+ }
195
+ };
196
+ /**
197
+ * Gets the address of the pauser
198
+ * @returns The address with pausing/unpausing permissions
199
+ */
200
+ getPauser = async () => {
201
+ try {
202
+ return await this.publicClient.readContract({
203
+ address: this.instanceAddress,
204
+ abi: UBIAbi,
205
+ functionName: "pauser",
206
+ });
207
+ }
208
+ catch (e) {
209
+ throw await handleRPCError(e);
210
+ }
211
+ };
212
+ /**
213
+ * Gets the Multipass contract address
214
+ * @returns The address of the Multipass contract
215
+ */
216
+ getMultipass = async () => {
217
+ try {
218
+ return await this.publicClient.readContract({
219
+ address: this.instanceAddress,
220
+ abi: UBIAbi,
221
+ functionName: "multipass",
222
+ });
223
+ }
224
+ catch (e) {
225
+ throw await handleRPCError(e);
226
+ }
227
+ };
228
+ /**
229
+ * Gets the governance token contract address
230
+ * @returns The address of the DistributableGovernanceERC20 token
231
+ */
232
+ getToken = async () => {
233
+ try {
234
+ return await this.publicClient.readContract({
235
+ address: this.instanceAddress,
236
+ abi: UBIAbi,
237
+ functionName: "token",
238
+ });
239
+ }
240
+ catch (e) {
241
+ throw await handleRPCError(e);
242
+ }
243
+ };
244
+ /**
245
+ * Checks if the contract is currently paused
246
+ * @returns True if paused, false otherwise
247
+ */
248
+ isPaused = async () => {
249
+ try {
250
+ return await this.publicClient.readContract({
251
+ address: this.instanceAddress,
252
+ abi: UBIAbi,
253
+ functionName: "paused",
254
+ });
255
+ }
256
+ catch (e) {
257
+ throw await handleRPCError(e);
258
+ }
259
+ };
260
+ /**
261
+ * Gets comprehensive information about a user's current status
262
+ * @param user - The address of the user
263
+ * @returns Object containing user state, last claimed day, and current day
264
+ */
265
+ getUserInfo = async (user) => {
266
+ try {
267
+ const [userState, lastClaimedAt, currentDay] = await Promise.all([
268
+ this.getUserState(user),
269
+ this.getLastClaimedAt(user),
270
+ this.getCurrentDay(),
271
+ ]);
272
+ return {
273
+ userState,
274
+ lastClaimedAt,
275
+ currentDay,
276
+ canClaim: lastClaimedAt < currentDay,
277
+ };
278
+ }
279
+ catch (e) {
280
+ throw await handleRPCError(e);
281
+ }
282
+ };
283
+ /**
284
+ * Gets comprehensive information about a proposal
285
+ * @param proposalHash - The hash of the proposal
286
+ * @param day - Optional day to get daily score (defaults to current day - 1)
287
+ * @returns Object containing lifetime stats and daily score
288
+ */
289
+ getProposalInfo = async (proposalHash, day) => {
290
+ try {
291
+ const queryDay = day ?? (await this.getCurrentDay()) - 1n;
292
+ const [lifetimeStats, dailyScore] = await Promise.all([
293
+ this.getProposalLifetimeStats(proposalHash),
294
+ this.getProposalDailyScore(proposalHash, queryDay),
295
+ ]);
296
+ return {
297
+ lifetimeStats,
298
+ dailyScore,
299
+ day: queryDay,
300
+ };
301
+ }
302
+ catch (e) {
303
+ throw await handleRPCError(e);
304
+ }
305
+ };
306
+ /**
307
+ * Gets all proposals for a specific day (requires querying events or off-chain indexer)
308
+ * This is a helper method that would typically use an indexer/subgraph
309
+ * @param day - The day to query
310
+ * @returns The count of proposals for that day
311
+ */
312
+ getDayProposals = async (day) => {
313
+ try {
314
+ const count = await this.getProposalsCnt(day);
315
+ return {
316
+ count,
317
+ day,
318
+ };
319
+ }
320
+ catch (e) {
321
+ throw await handleRPCError(e);
322
+ }
323
+ };
324
+ // ==================== WRITE OPERATIONS ====================
325
+ /**
326
+ * Claims daily UBI tokens and optionally submits a proposal
327
+ * @param proposalText - The proposal text (empty string for no proposal)
328
+ * @returns Transaction hash
329
+ * @throws Error if wallet client is not configured
330
+ */
331
+ claim = async (proposalText = "") => {
332
+ if (!this.walletClient) {
333
+ throw new Error("Wallet client required for write operations");
334
+ }
335
+ if (!this.account) {
336
+ throw new Error("Account required for write operations");
337
+ }
338
+ try {
339
+ const { request } = await this.publicClient.simulateContract({
340
+ address: this.instanceAddress,
341
+ abi: UBIAbi,
342
+ functionName: "claim",
343
+ args: [proposalText],
344
+ account: this.account,
345
+ });
346
+ const hash = await this.walletClient.writeContract(request);
347
+ return hash;
348
+ }
349
+ catch (e) {
350
+ throw await handleRPCError(e);
351
+ }
352
+ };
353
+ /**
354
+ * Supports one or more proposals from the previous day using quadratic voting
355
+ * @param votes - Array of vote elements (proposal hash and amount)
356
+ * @returns Transaction hash
357
+ * @throws Error if wallet client is not configured
358
+ */
359
+ support = async (votes) => {
360
+ if (!this.walletClient) {
361
+ throw new Error("Wallet client required for write operations");
362
+ }
363
+ if (!this.account) {
364
+ throw new Error("Account required for write operations");
365
+ }
366
+ try {
367
+ const formattedVotes = votes.map((v) => ({
368
+ proposal: v.proposal,
369
+ amount: v.amount,
370
+ }));
371
+ const { request } = await this.publicClient.simulateContract({
372
+ address: this.instanceAddress,
373
+ abi: UBIAbi,
374
+ functionName: "support",
375
+ args: [formattedVotes],
376
+ account: this.account,
377
+ });
378
+ const hash = await this.walletClient.writeContract(request);
379
+ return hash;
380
+ }
381
+ catch (e) {
382
+ throw await handleRPCError(e);
383
+ }
384
+ };
385
+ /**
386
+ * Pauses the UBI contract (only callable by pauser)
387
+ * @returns Transaction hash
388
+ * @throws Error if wallet client is not configured or caller is not pauser
389
+ */
390
+ pause = async () => {
391
+ if (!this.walletClient) {
392
+ throw new Error("Wallet client required for write operations");
393
+ }
394
+ if (!this.account) {
395
+ throw new Error("Account required for write operations");
396
+ }
397
+ try {
398
+ const { request } = await this.publicClient.simulateContract({
399
+ address: this.instanceAddress,
400
+ abi: UBIAbi,
401
+ functionName: "pause",
402
+ account: this.account,
403
+ });
404
+ const hash = await this.walletClient.writeContract(request);
405
+ return hash;
406
+ }
407
+ catch (e) {
408
+ throw await handleRPCError(e);
409
+ }
410
+ };
411
+ /**
412
+ * Unpauses the UBI contract (only callable by pauser)
413
+ * @returns Transaction hash
414
+ * @throws Error if wallet client is not configured or caller is not pauser
415
+ */
416
+ unpause = async () => {
417
+ if (!this.walletClient) {
418
+ throw new Error("Wallet client required for write operations");
419
+ }
420
+ if (!this.account) {
421
+ throw new Error("Account required for write operations");
422
+ }
423
+ try {
424
+ const { request } = await this.publicClient.simulateContract({
425
+ address: this.instanceAddress,
426
+ abi: UBIAbi,
427
+ functionName: "unpause",
428
+ account: this.account,
429
+ });
430
+ const hash = await this.walletClient.writeContract(request);
431
+ return hash;
432
+ }
433
+ catch (e) {
434
+ throw await handleRPCError(e);
435
+ }
436
+ };
437
+ // ==================== INDEXER QUERY METHODS ====================
438
+ /**
439
+ * Gets proposals submitted by a specific address
440
+ * @param proposer - Optional address to filter by proposer
441
+ * @param day - Optional day to filter proposals
442
+ * @param limit - Maximum number of results to return
443
+ * @param offset - Number of results to skip
444
+ * @returns Array of proposal events
445
+ */
446
+ getProposalsByAddress = async ({ proposer, day, limit = 100, offset = 0, } = {}) => {
447
+ try {
448
+ return await this.envioClient.getUBIProposingByAddressEvents({
449
+ instanceAddress: this.instanceAddress,
450
+ proposer,
451
+ day,
452
+ limit,
453
+ offset,
454
+ });
455
+ }
456
+ catch (e) {
457
+ throw await handleRPCError(e);
458
+ }
459
+ };
460
+ /**
461
+ * Gets all proposals for a specific day
462
+ * @param day - Optional day to filter proposals (defaults to current day - 1)
463
+ * @param limit - Maximum number of results to return
464
+ * @param offset - Number of results to skip
465
+ * @returns Array of proposal events for the day
466
+ */
467
+ getDailyProposals = async ({ day, limit = 100, offset = 0, } = {}) => {
468
+ try {
469
+ const queryDay = day ?? (await this.getCurrentDay()) - 1n;
470
+ return await this.envioClient.getUBIProposingByAddressEvents({
471
+ instanceAddress: this.instanceAddress,
472
+ day: queryDay,
473
+ limit,
474
+ offset,
475
+ });
476
+ }
477
+ catch (e) {
478
+ throw await handleRPCError(e);
479
+ }
480
+ };
481
+ /**
482
+ * Gets proposal score updates for a specific proposal
483
+ * @param proposal - Proposal hash to query
484
+ * @param day - Optional day to filter results
485
+ * @param limit - Maximum number of results to return
486
+ * @param offset - Number of results to skip
487
+ * @returns Array of proposal score update events
488
+ */
489
+ getProposalScoreHistory = async ({ proposal, day, limit = 100, offset = 0, } = {}) => {
490
+ try {
491
+ return await this.envioClient.getUBIProposalScoreUpdatedByProposalEvents({
492
+ instanceAddress: this.instanceAddress,
493
+ proposal,
494
+ day,
495
+ limit,
496
+ offset,
497
+ });
498
+ }
499
+ catch (e) {
500
+ throw await handleRPCError(e);
501
+ }
502
+ };
503
+ /**
504
+ * Gets voting events for a specific participant
505
+ * @param participant - Address to filter by participant
506
+ * @param day - Optional day to filter votes
507
+ * @param limit - Maximum number of results to return
508
+ * @param offset - Number of results to skip
509
+ * @returns Array of voting events
510
+ */
511
+ getVotesByAddress = async ({ participant, day, limit = 100, offset = 0, } = {}) => {
512
+ try {
513
+ return await this.envioClient.getUBIVotingByAddressEvents({
514
+ instanceAddress: this.instanceAddress,
515
+ participant,
516
+ day,
517
+ limit,
518
+ offset,
519
+ });
520
+ }
521
+ catch (e) {
522
+ throw await handleRPCError(e);
523
+ }
524
+ };
525
+ /**
526
+ * Gets all votes for a specific day
527
+ * @param day - Optional day to filter votes (defaults to current day - 1)
528
+ * @param limit - Maximum number of results to return
529
+ * @param offset - Number of results to skip
530
+ * @returns Array of voting events for the day
531
+ */
532
+ getDailyVotes = async ({ day, limit = 100, offset = 0, } = {}) => {
533
+ try {
534
+ const queryDay = day ?? (await this.getCurrentDay()) - 1n;
535
+ return await this.envioClient.getUBIVotingByAddressEvents({
536
+ instanceAddress: this.instanceAddress,
537
+ day: queryDay,
538
+ limit,
539
+ offset,
540
+ });
541
+ }
542
+ catch (e) {
543
+ throw await handleRPCError(e);
544
+ }
545
+ };
546
+ /**
547
+ * Gets claim history
548
+ * @param user - Optional user address to filter claims
549
+ * @param limit - Maximum number of results to return
550
+ * @param offset - Number of results to skip
551
+ * @returns Array of claim events
552
+ */
553
+ getClaimHistory = async ({ user, limit = 100, offset = 0, } = {}) => {
554
+ try {
555
+ return await this.envioClient.getUBIClaimedEvents({
556
+ instanceAddress: this.instanceAddress,
557
+ user,
558
+ limit,
559
+ offset,
560
+ });
561
+ }
562
+ catch (e) {
563
+ throw await handleRPCError(e);
564
+ }
565
+ };
566
+ /**
567
+ * Gets repost events by reposter
568
+ * @param reposter - Optional address to filter by reposter
569
+ * @param day - Optional day to filter reposts
570
+ * @param limit - Maximum number of results to return
571
+ * @param offset - Number of results to skip
572
+ * @returns Array of repost events
573
+ */
574
+ getRepostsByAddress = async ({ reposter, day, limit = 100, offset = 0, } = {}) => {
575
+ try {
576
+ return await this.envioClient.getUBIRepostByReposterEvents({
577
+ instanceAddress: this.instanceAddress,
578
+ reposter,
579
+ day,
580
+ limit,
581
+ offset,
582
+ });
583
+ }
584
+ catch (e) {
585
+ throw await handleRPCError(e);
586
+ }
587
+ };
588
+ /**
589
+ * Gets lifetime scores for all proposals
590
+ * @param limit - Maximum number of results to return
591
+ * @param offset - Number of results to skip
592
+ * @returns Array of proposal lifetime score events
593
+ */
594
+ getProposalLifetimeScores = async ({ limit = 100, offset = 0, } = {}) => {
595
+ try {
596
+ return await this.envioClient.getUBIProposalLifetimeScoreEvents({
597
+ instanceAddress: this.instanceAddress,
598
+ limit,
599
+ offset,
600
+ });
601
+ }
602
+ catch (e) {
603
+ throw await handleRPCError(e);
604
+ }
605
+ };
606
+ /**
607
+ * Gets comprehensive proposal data including proposals, scores, and votes for a specific day
608
+ * @param day - Optional day to query (defaults to current day - 1)
609
+ * @param limit - Maximum number of results per query
610
+ * @returns Object containing proposals, scores, and votes for the day
611
+ */
612
+ getDayActivity = async ({ day, limit = 100, } = {}) => {
613
+ try {
614
+ const queryDay = day ?? (await this.getCurrentDay()) - 1n;
615
+ const [proposals, votes, reposts] = await Promise.all([
616
+ this.getDailyProposals({ day: queryDay, limit }),
617
+ this.getDailyVotes({ day: queryDay, limit }),
618
+ this.getRepostsByAddress({ day: queryDay, limit }),
619
+ ]);
620
+ return {
621
+ day: queryDay,
622
+ proposals,
623
+ votes,
624
+ reposts,
625
+ proposalCount: proposals.length,
626
+ voteCount: votes.length,
627
+ repostCount: reposts.length,
628
+ };
629
+ }
630
+ catch (e) {
631
+ throw await handleRPCError(e);
632
+ }
633
+ };
634
+ /**
635
+ * Gets comprehensive user activity data
636
+ * @param user - User address to query
637
+ * @param limit - Maximum number of results per query
638
+ * @returns Object containing user's proposals, votes, reposts, and claims
639
+ */
640
+ getUserActivity = async ({ user, limit = 100 }) => {
641
+ try {
642
+ const [proposals, votes, reposts, claims, userInfo] = await Promise.all([
643
+ this.getProposalsByAddress({ proposer: user, limit }),
644
+ this.getVotesByAddress({ participant: user, limit }),
645
+ this.getRepostsByAddress({ reposter: user, limit }),
646
+ this.getClaimHistory({ user, limit }),
647
+ this.getUserInfo(user),
648
+ ]);
649
+ return {
650
+ user,
651
+ userInfo,
652
+ proposals,
653
+ votes,
654
+ reposts,
655
+ claims,
656
+ proposalCount: proposals.length,
657
+ voteCount: votes.length,
658
+ repostCount: reposts.length,
659
+ claimCount: claims.length,
660
+ };
661
+ }
662
+ catch (e) {
663
+ throw await handleRPCError(e);
664
+ }
665
+ };
666
+ /**
667
+ * Gets aggregated proposal scores from voting events
668
+ * @param day - Optional day to filter votes
669
+ * @param limit - Maximum number of voting events to fetch
670
+ * @returns Map of proposal hashes to their total support scores
671
+ */
672
+ getProposalScores = async ({ day, limit = 1000, } = {}) => {
673
+ try {
674
+ const votes = await this.getVotesByAddress({
675
+ day,
676
+ limit,
677
+ });
678
+ // Aggregate votes by proposal
679
+ const proposalScores = new Map();
680
+ votes.forEach((vote) => {
681
+ // Each vote event has proposal and amount directly
682
+ const proposalHash = vote.proposal;
683
+ const amount = vote.amount || BigInt(0);
684
+ const currentScore = proposalScores.get(proposalHash) || BigInt(0);
685
+ proposalScores.set(proposalHash, currentScore + amount);
686
+ });
687
+ // Convert to array and sort by score
688
+ const sortedScores = Array.from(proposalScores.entries())
689
+ .map(([proposal, score]) => ({
690
+ proposal,
691
+ score,
692
+ stars: Math.floor(Number(score)), // Direct token count as stars
693
+ }))
694
+ .sort((a, b) => Number(b.score - a.score));
695
+ return sortedScores;
696
+ }
697
+ catch (e) {
698
+ throw await handleRPCError(e);
699
+ }
700
+ };
701
+ /**
702
+ * Gets the score for a specific proposal
703
+ * @param proposalHash - The hash of the proposal
704
+ * @param day - Optional day to filter votes
705
+ * @returns Total support score for the proposal
706
+ */
707
+ getProposalScore = async (proposalHash, day) => {
708
+ try {
709
+ const scores = await this.getProposalScores({ day });
710
+ const proposalScore = scores.find((s) => s.proposal === proposalHash);
711
+ return {
712
+ proposal: proposalHash,
713
+ score: proposalScore?.score || BigInt(0),
714
+ stars: proposalScore?.stars || 0,
715
+ };
716
+ }
717
+ catch (e) {
718
+ throw await handleRPCError(e);
719
+ }
720
+ };
721
+ }
722
+ //# sourceMappingURL=InstanceUBI.js.map