@geoprotocol/geo-sdk 0.18.3 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/README.md +995 -372
  2. package/dist/contracts.d.ts +0 -11
  3. package/dist/contracts.d.ts.map +1 -1
  4. package/dist/contracts.js +0 -11
  5. package/dist/contracts.js.map +1 -1
  6. package/dist/index.d.ts +8 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +8 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/lite.d.ts +2 -0
  11. package/dist/lite.d.ts.map +1 -1
  12. package/dist/lite.js +2 -0
  13. package/dist/lite.js.map +1 -1
  14. package/dist/src/abis/dao-space-factory.d.ts +43 -6
  15. package/dist/src/abis/dao-space-factory.d.ts.map +1 -1
  16. package/dist/src/abis/dao-space-factory.js +38 -27
  17. package/dist/src/abis/dao-space-factory.js.map +1 -1
  18. package/dist/src/abis/dao-space-v2.test.d.ts +2 -0
  19. package/dist/src/abis/dao-space-v2.test.d.ts.map +1 -0
  20. package/dist/src/abis/dao-space-v2.test.js +67 -0
  21. package/dist/src/abis/dao-space-v2.test.js.map +1 -0
  22. package/dist/src/abis/dao-space.d.ts +98 -7
  23. package/dist/src/abis/dao-space.d.ts.map +1 -1
  24. package/dist/src/abis/dao-space.js +61 -99
  25. package/dist/src/abis/dao-space.js.map +1 -1
  26. package/dist/src/abis/index.d.ts +2 -2
  27. package/dist/src/abis/index.d.ts.map +1 -1
  28. package/dist/src/abis/index.js +2 -2
  29. package/dist/src/abis/index.js.map +1 -1
  30. package/dist/src/abis/space-registry.d.ts +26 -0
  31. package/dist/src/abis/space-registry.d.ts.map +1 -1
  32. package/dist/src/abis/space-registry.js +33 -0
  33. package/dist/src/abis/space-registry.js.map +1 -1
  34. package/dist/src/api-surface.e2e.test.d.ts +2 -0
  35. package/dist/src/api-surface.e2e.test.d.ts.map +1 -0
  36. package/dist/src/api-surface.e2e.test.js +1206 -0
  37. package/dist/src/api-surface.e2e.test.js.map +1 -0
  38. package/dist/src/client/api.d.ts +86 -0
  39. package/dist/src/client/api.d.ts.map +1 -0
  40. package/dist/src/client/api.js +169 -0
  41. package/dist/src/client/api.js.map +1 -0
  42. package/dist/src/client/comments.d.ts +59 -0
  43. package/dist/src/client/comments.d.ts.map +1 -0
  44. package/dist/src/client/comments.js +96 -0
  45. package/dist/src/client/comments.js.map +1 -0
  46. package/dist/src/client/context.d.ts +20 -0
  47. package/dist/src/client/context.d.ts.map +1 -0
  48. package/dist/src/client/context.js +20 -0
  49. package/dist/src/client/context.js.map +1 -0
  50. package/dist/src/client/dao-spaces.d.ts +408 -0
  51. package/dist/src/client/dao-spaces.d.ts.map +1 -0
  52. package/dist/src/client/dao-spaces.js +626 -0
  53. package/dist/src/client/dao-spaces.js.map +1 -0
  54. package/dist/src/client/dao-spaces.test.d.ts +2 -0
  55. package/dist/src/client/dao-spaces.test.d.ts.map +1 -0
  56. package/dist/src/client/dao-spaces.test.js +497 -0
  57. package/dist/src/client/dao-spaces.test.js.map +1 -0
  58. package/dist/src/client/edits.d.ts +100 -0
  59. package/dist/src/client/edits.d.ts.map +1 -0
  60. package/dist/src/client/edits.js +131 -0
  61. package/dist/src/client/edits.js.map +1 -0
  62. package/dist/src/client/edits.test.d.ts +2 -0
  63. package/dist/src/client/edits.test.d.ts.map +1 -0
  64. package/dist/src/client/edits.test.js +98 -0
  65. package/dist/src/client/edits.test.js.map +1 -0
  66. package/dist/src/client/entities.d.ts +23 -0
  67. package/dist/src/client/entities.d.ts.map +1 -0
  68. package/dist/src/client/entities.js +88 -0
  69. package/dist/src/client/entities.js.map +1 -0
  70. package/dist/src/client/entity-votes.d.ts +141 -0
  71. package/dist/src/client/entity-votes.d.ts.map +1 -0
  72. package/dist/src/client/entity-votes.js +168 -0
  73. package/dist/src/client/entity-votes.js.map +1 -0
  74. package/dist/src/client/entity-votes.test.d.ts +2 -0
  75. package/dist/src/client/entity-votes.test.d.ts.map +1 -0
  76. package/dist/src/client/entity-votes.test.js +93 -0
  77. package/dist/src/client/entity-votes.test.js.map +1 -0
  78. package/dist/src/client/graph-workflows.test.d.ts +2 -0
  79. package/dist/src/client/graph-workflows.test.d.ts.map +1 -0
  80. package/dist/src/client/graph-workflows.test.js +83 -0
  81. package/dist/src/client/graph-workflows.test.js.map +1 -0
  82. package/dist/src/client/images-storage.test.d.ts +2 -0
  83. package/dist/src/client/images-storage.test.d.ts.map +1 -0
  84. package/dist/src/client/images-storage.test.js +52 -0
  85. package/dist/src/client/images-storage.test.js.map +1 -0
  86. package/dist/src/client/images.d.ts +35 -0
  87. package/dist/src/client/images.d.ts.map +1 -0
  88. package/dist/src/client/images.js +90 -0
  89. package/dist/src/client/images.js.map +1 -0
  90. package/dist/src/client/personal-spaces.d.ts +229 -0
  91. package/dist/src/client/personal-spaces.d.ts.map +1 -0
  92. package/dist/src/client/personal-spaces.js +278 -0
  93. package/dist/src/client/personal-spaces.js.map +1 -0
  94. package/dist/src/client/spaces.test.d.ts +2 -0
  95. package/dist/src/client/spaces.test.d.ts.map +1 -0
  96. package/dist/src/client/spaces.test.js +175 -0
  97. package/dist/src/client/spaces.test.js.map +1 -0
  98. package/dist/src/client/storage.d.ts +52 -0
  99. package/dist/src/client/storage.d.ts.map +1 -0
  100. package/dist/src/client/storage.js +53 -0
  101. package/dist/src/client/storage.js.map +1 -0
  102. package/dist/src/client.d.ts +338 -0
  103. package/dist/src/client.d.ts.map +1 -0
  104. package/dist/src/client.js +494 -0
  105. package/dist/src/client.js.map +1 -0
  106. package/dist/src/client.test.d.ts +2 -0
  107. package/dist/src/client.test.d.ts.map +1 -0
  108. package/dist/src/client.test.js +125 -0
  109. package/dist/src/client.test.js.map +1 -0
  110. package/dist/src/contracts-v2/local-geobrowser.e2e.test.d.ts +2 -0
  111. package/dist/src/contracts-v2/local-geobrowser.e2e.test.d.ts.map +1 -0
  112. package/dist/src/contracts-v2/local-geobrowser.e2e.test.js +239 -0
  113. package/dist/src/contracts-v2/local-geobrowser.e2e.test.js.map +1 -0
  114. package/dist/src/dao-space/constants.d.ts +16 -3
  115. package/dist/src/dao-space/constants.d.ts.map +1 -1
  116. package/dist/src/dao-space/constants.js +16 -5
  117. package/dist/src/dao-space/constants.js.map +1 -1
  118. package/dist/src/dao-space/create-space.d.ts +1 -31
  119. package/dist/src/dao-space/create-space.d.ts.map +1 -1
  120. package/dist/src/dao-space/create-space.js +5 -70
  121. package/dist/src/dao-space/create-space.js.map +1 -1
  122. package/dist/src/dao-space/execute-proposal.d.ts +1 -22
  123. package/dist/src/dao-space/execute-proposal.d.ts.map +1 -1
  124. package/dist/src/dao-space/execute-proposal.js +12 -59
  125. package/dist/src/dao-space/execute-proposal.js.map +1 -1
  126. package/dist/src/dao-space/index.d.ts +2 -1
  127. package/dist/src/dao-space/index.d.ts.map +1 -1
  128. package/dist/src/dao-space/index.js +1 -0
  129. package/dist/src/dao-space/index.js.map +1 -1
  130. package/dist/src/dao-space/propose-add-editor.d.ts +1 -20
  131. package/dist/src/dao-space/propose-add-editor.d.ts.map +1 -1
  132. package/dist/src/dao-space/propose-add-editor.js +12 -87
  133. package/dist/src/dao-space/propose-add-editor.js.map +1 -1
  134. package/dist/src/dao-space/propose-add-editor.test.js +16 -4
  135. package/dist/src/dao-space/propose-add-editor.test.js.map +1 -1
  136. package/dist/src/dao-space/propose-add-member.d.ts +1 -20
  137. package/dist/src/dao-space/propose-add-member.d.ts.map +1 -1
  138. package/dist/src/dao-space/propose-add-member.js +12 -87
  139. package/dist/src/dao-space/propose-add-member.js.map +1 -1
  140. package/dist/src/dao-space/propose-add-member.test.js +13 -0
  141. package/dist/src/dao-space/propose-add-member.test.js.map +1 -1
  142. package/dist/src/dao-space/propose-edit.d.ts +1 -30
  143. package/dist/src/dao-space/propose-edit.d.ts.map +1 -1
  144. package/dist/src/dao-space/propose-edit.js +12 -108
  145. package/dist/src/dao-space/propose-edit.js.map +1 -1
  146. package/dist/src/dao-space/propose-edit.test.js +53 -1
  147. package/dist/src/dao-space/propose-edit.test.js.map +1 -1
  148. package/dist/src/dao-space/propose-remove-editor.d.ts +1 -22
  149. package/dist/src/dao-space/propose-remove-editor.d.ts.map +1 -1
  150. package/dist/src/dao-space/propose-remove-editor.js +12 -94
  151. package/dist/src/dao-space/propose-remove-editor.js.map +1 -1
  152. package/dist/src/dao-space/propose-remove-editor.test.js +24 -11
  153. package/dist/src/dao-space/propose-remove-editor.test.js.map +1 -1
  154. package/dist/src/dao-space/propose-remove-member.d.ts +1 -22
  155. package/dist/src/dao-space/propose-remove-member.d.ts.map +1 -1
  156. package/dist/src/dao-space/propose-remove-member.js +12 -94
  157. package/dist/src/dao-space/propose-remove-member.js.map +1 -1
  158. package/dist/src/dao-space/propose-remove-member.test.js +19 -0
  159. package/dist/src/dao-space/propose-remove-member.test.js.map +1 -1
  160. package/dist/src/dao-space/propose-request-membership.d.ts.map +1 -1
  161. package/dist/src/dao-space/propose-request-membership.js +4 -4
  162. package/dist/src/dao-space/propose-request-membership.js.map +1 -1
  163. package/dist/src/dao-space/propose-update-voting-settings.d.ts +8 -0
  164. package/dist/src/dao-space/propose-update-voting-settings.d.ts.map +1 -0
  165. package/dist/src/dao-space/propose-update-voting-settings.js +19 -0
  166. package/dist/src/dao-space/propose-update-voting-settings.js.map +1 -0
  167. package/dist/src/dao-space/propose-update-voting-settings.test.d.ts +2 -0
  168. package/dist/src/dao-space/propose-update-voting-settings.test.d.ts.map +1 -0
  169. package/dist/src/dao-space/propose-update-voting-settings.test.js +118 -0
  170. package/dist/src/dao-space/propose-update-voting-settings.test.js.map +1 -0
  171. package/dist/src/dao-space/types.d.ts +72 -11
  172. package/dist/src/dao-space/types.d.ts.map +1 -1
  173. package/dist/src/dao-space/vote-proposal.d.ts +1 -24
  174. package/dist/src/dao-space/vote-proposal.d.ts.map +1 -1
  175. package/dist/src/dao-space/vote-proposal.js +12 -64
  176. package/dist/src/dao-space/vote-proposal.js.map +1 -1
  177. package/dist/src/dao-space/vote-proposal.test.js +54 -0
  178. package/dist/src/dao-space/vote-proposal.test.js.map +1 -1
  179. package/dist/src/e2e-test-environment.d.ts +26 -0
  180. package/dist/src/e2e-test-environment.d.ts.map +1 -0
  181. package/dist/src/e2e-test-environment.js +150 -0
  182. package/dist/src/e2e-test-environment.js.map +1 -0
  183. package/dist/src/encoding.d.ts +3 -0
  184. package/dist/src/encoding.d.ts.map +1 -1
  185. package/dist/src/encoding.js +3 -0
  186. package/dist/src/encoding.js.map +1 -1
  187. package/dist/src/encodings/get-create-dao-space-calldata.d.ts +34 -97
  188. package/dist/src/encodings/get-create-dao-space-calldata.d.ts.map +1 -1
  189. package/dist/src/encodings/get-create-dao-space-calldata.js +66 -109
  190. package/dist/src/encodings/get-create-dao-space-calldata.js.map +1 -1
  191. package/dist/src/encodings/get-create-dao-space-calldata.test.js +90 -23
  192. package/dist/src/encodings/get-create-dao-space-calldata.test.js.map +1 -1
  193. package/dist/src/encodings/get-create-personal-space-calldata.d.ts +2 -0
  194. package/dist/src/encodings/get-create-personal-space-calldata.d.ts.map +1 -1
  195. package/dist/src/encodings/get-create-personal-space-calldata.js +2 -0
  196. package/dist/src/encodings/get-create-personal-space-calldata.js.map +1 -1
  197. package/dist/src/full-flow-test.test.js +5 -2
  198. package/dist/src/full-flow-test.test.js.map +1 -1
  199. package/dist/src/graph/comment-utils.d.ts +4 -0
  200. package/dist/src/graph/comment-utils.d.ts.map +1 -1
  201. package/dist/src/graph/comment-utils.js +4 -0
  202. package/dist/src/graph/comment-utils.js.map +1 -1
  203. package/dist/src/graph/constants.d.ts +12 -3
  204. package/dist/src/graph/constants.d.ts.map +1 -1
  205. package/dist/src/graph/constants.js +11 -5
  206. package/dist/src/graph/constants.js.map +1 -1
  207. package/dist/src/graph/create-comment.d.ts +3 -22
  208. package/dist/src/graph/create-comment.d.ts.map +1 -1
  209. package/dist/src/graph/create-comment.js +6 -136
  210. package/dist/src/graph/create-comment.js.map +1 -1
  211. package/dist/src/graph/create-comment.test.js +19 -8
  212. package/dist/src/graph/create-comment.test.js.map +1 -1
  213. package/dist/src/graph/create-entity.d.ts +2 -0
  214. package/dist/src/graph/create-entity.d.ts.map +1 -1
  215. package/dist/src/graph/create-entity.js +2 -0
  216. package/dist/src/graph/create-entity.js.map +1 -1
  217. package/dist/src/graph/create-image.d.ts +2 -21
  218. package/dist/src/graph/create-image.d.ts.map +1 -1
  219. package/dist/src/graph/create-image.js +7 -69
  220. package/dist/src/graph/create-image.js.map +1 -1
  221. package/dist/src/graph/create-property.d.ts +2 -0
  222. package/dist/src/graph/create-property.d.ts.map +1 -1
  223. package/dist/src/graph/create-property.js +2 -0
  224. package/dist/src/graph/create-property.js.map +1 -1
  225. package/dist/src/graph/create-proposal-review.d.ts +1 -27
  226. package/dist/src/graph/create-proposal-review.d.ts.map +1 -1
  227. package/dist/src/graph/create-proposal-review.js +4 -61
  228. package/dist/src/graph/create-proposal-review.js.map +1 -1
  229. package/dist/src/graph/create-relation.d.ts +2 -0
  230. package/dist/src/graph/create-relation.d.ts.map +1 -1
  231. package/dist/src/graph/create-relation.js +2 -0
  232. package/dist/src/graph/create-relation.js.map +1 -1
  233. package/dist/src/graph/create-type.d.ts +2 -0
  234. package/dist/src/graph/create-type.d.ts.map +1 -1
  235. package/dist/src/graph/create-type.js +2 -0
  236. package/dist/src/graph/create-type.js.map +1 -1
  237. package/dist/src/graph/delete-entity.d.ts +2 -14
  238. package/dist/src/graph/delete-entity.d.ts.map +1 -1
  239. package/dist/src/graph/delete-entity.js +5 -78
  240. package/dist/src/graph/delete-entity.js.map +1 -1
  241. package/dist/src/graph/delete-entity.test.js +7 -0
  242. package/dist/src/graph/delete-entity.test.js.map +1 -1
  243. package/dist/src/graph/delete-relation.d.ts +2 -0
  244. package/dist/src/graph/delete-relation.d.ts.map +1 -1
  245. package/dist/src/graph/delete-relation.js +2 -0
  246. package/dist/src/graph/delete-relation.js.map +1 -1
  247. package/dist/src/graph/entity-vote.d.ts +3 -3
  248. package/dist/src/graph/entity-vote.d.ts.map +1 -1
  249. package/dist/src/graph/entity-vote.js +21 -46
  250. package/dist/src/graph/entity-vote.js.map +1 -1
  251. package/dist/src/graph/update-comment.d.ts +3 -0
  252. package/dist/src/graph/update-comment.d.ts.map +1 -1
  253. package/dist/src/graph/update-comment.js +3 -0
  254. package/dist/src/graph/update-comment.js.map +1 -1
  255. package/dist/src/graph/update-entity.d.ts +2 -0
  256. package/dist/src/graph/update-entity.d.ts.map +1 -1
  257. package/dist/src/graph/update-entity.js +2 -0
  258. package/dist/src/graph/update-entity.js.map +1 -1
  259. package/dist/src/graph/update-proposal-review.d.ts +2 -27
  260. package/dist/src/graph/update-proposal-review.d.ts.map +1 -1
  261. package/dist/src/graph/update-proposal-review.js +4 -50
  262. package/dist/src/graph/update-proposal-review.js.map +1 -1
  263. package/dist/src/graph/update-relation.d.ts +2 -0
  264. package/dist/src/graph/update-relation.d.ts.map +1 -1
  265. package/dist/src/graph/update-relation.js +2 -0
  266. package/dist/src/graph/update-relation.js.map +1 -1
  267. package/dist/src/ipfs-core.d.ts +42 -0
  268. package/dist/src/ipfs-core.d.ts.map +1 -0
  269. package/dist/src/ipfs-core.js +165 -0
  270. package/dist/src/ipfs-core.js.map +1 -0
  271. package/dist/src/ipfs-core.test.d.ts +2 -0
  272. package/dist/src/ipfs-core.test.d.ts.map +1 -0
  273. package/dist/src/ipfs-core.test.js +56 -0
  274. package/dist/src/ipfs-core.test.js.map +1 -0
  275. package/dist/src/ipfs.d.ts +7 -52
  276. package/dist/src/ipfs.d.ts.map +1 -1
  277. package/dist/src/ipfs.js +27 -170
  278. package/dist/src/ipfs.js.map +1 -1
  279. package/dist/src/legacy-api-surface.e2e.test.d.ts +2 -0
  280. package/dist/src/legacy-api-surface.e2e.test.d.ts.map +1 -0
  281. package/dist/src/legacy-api-surface.e2e.test.js +860 -0
  282. package/dist/src/legacy-api-surface.e2e.test.js.map +1 -0
  283. package/dist/src/networks.d.ts +46 -0
  284. package/dist/src/networks.d.ts.map +1 -0
  285. package/dist/src/networks.js +90 -0
  286. package/dist/src/networks.js.map +1 -0
  287. package/dist/src/ops/comments.d.ts +80 -0
  288. package/dist/src/ops/comments.d.ts.map +1 -0
  289. package/dist/src/ops/comments.js +142 -0
  290. package/dist/src/ops/comments.js.map +1 -0
  291. package/dist/src/ops/entities.d.ts +50 -0
  292. package/dist/src/ops/entities.d.ts.map +1 -0
  293. package/dist/src/ops/entities.js +51 -0
  294. package/dist/src/ops/entities.js.map +1 -0
  295. package/dist/src/ops/index.d.ts +7 -0
  296. package/dist/src/ops/index.d.ts.map +1 -0
  297. package/dist/src/ops/index.js +7 -0
  298. package/dist/src/ops/index.js.map +1 -0
  299. package/dist/src/ops/index.test.d.ts +2 -0
  300. package/dist/src/ops/index.test.d.ts.map +1 -0
  301. package/dist/src/ops/index.test.js +115 -0
  302. package/dist/src/ops/index.test.js.map +1 -0
  303. package/dist/src/ops/properties.d.ts +20 -0
  304. package/dist/src/ops/properties.d.ts.map +1 -0
  305. package/dist/src/ops/properties.js +20 -0
  306. package/dist/src/ops/properties.js.map +1 -0
  307. package/dist/src/ops/proposal-reviews.d.ts +43 -0
  308. package/dist/src/ops/proposal-reviews.d.ts.map +1 -0
  309. package/dist/src/ops/proposal-reviews.js +103 -0
  310. package/dist/src/ops/proposal-reviews.js.map +1 -0
  311. package/dist/src/ops/relations.d.ts +57 -0
  312. package/dist/src/ops/relations.d.ts.map +1 -0
  313. package/dist/src/ops/relations.js +59 -0
  314. package/dist/src/ops/relations.js.map +1 -0
  315. package/dist/src/ops/types.d.ts +20 -0
  316. package/dist/src/ops/types.d.ts.map +1 -0
  317. package/dist/src/ops/types.js +20 -0
  318. package/dist/src/ops/types.js.map +1 -0
  319. package/dist/src/personal-space/constants.d.ts +1 -0
  320. package/dist/src/personal-space/constants.d.ts.map +1 -1
  321. package/dist/src/personal-space/constants.js +1 -0
  322. package/dist/src/personal-space/constants.js.map +1 -1
  323. package/dist/src/personal-space/create-space.d.ts +3 -20
  324. package/dist/src/personal-space/create-space.d.ts.map +1 -1
  325. package/dist/src/personal-space/create-space.js +5 -21
  326. package/dist/src/personal-space/create-space.js.map +1 -1
  327. package/dist/src/personal-space/has-space.d.ts +9 -2
  328. package/dist/src/personal-space/has-space.d.ts.map +1 -1
  329. package/dist/src/personal-space/has-space.js +9 -13
  330. package/dist/src/personal-space/has-space.js.map +1 -1
  331. package/dist/src/personal-space/has-space.test.d.ts +2 -0
  332. package/dist/src/personal-space/has-space.test.d.ts.map +1 -0
  333. package/dist/src/personal-space/has-space.test.js +30 -0
  334. package/dist/src/personal-space/has-space.test.js.map +1 -0
  335. package/dist/src/personal-space/publish-edit.d.ts +1 -22
  336. package/dist/src/personal-space/publish-edit.d.ts.map +1 -1
  337. package/dist/src/personal-space/publish-edit.js +10 -64
  338. package/dist/src/personal-space/publish-edit.js.map +1 -1
  339. package/dist/src/personal-space/types.d.ts +4 -1
  340. package/dist/src/personal-space/types.d.ts.map +1 -1
  341. package/dist/src/smart-wallet.d.ts +2 -4
  342. package/dist/src/smart-wallet.d.ts.map +1 -1
  343. package/dist/src/smart-wallet.js +6 -9
  344. package/dist/src/smart-wallet.js.map +1 -1
  345. package/dist/src/types.d.ts +25 -0
  346. package/dist/src/types.d.ts.map +1 -1
  347. package/dist/src/types.js.map +1 -1
  348. package/package.json +14 -1
  349. package/dist/proto.d.ts +0 -5
  350. package/dist/proto.d.ts.map +0 -1
  351. package/dist/proto.js +0 -5
  352. package/dist/proto.js.map +0 -1
  353. package/dist/src/graph/create-space.d.ts +0 -37
  354. package/dist/src/graph/create-space.d.ts.map +0 -1
  355. package/dist/src/graph/create-space.js +0 -67
  356. package/dist/src/graph/create-space.js.map +0 -1
  357. package/dist/src/proto/index.d.ts +0 -7
  358. package/dist/src/proto/index.d.ts.map +0 -1
  359. package/dist/src/proto/index.js +0 -7
  360. package/dist/src/proto/index.js.map +0 -1
@@ -0,0 +1,131 @@
1
+ import { encodeAbiParameters, encodeFunctionData, toHex } from 'viem';
2
+ import { SpaceRegistryAbi } from '../abis/index.js';
3
+ import { isValid } from '../id.js';
4
+ import { toBytes } from '../id-utils.js';
5
+ import { UUID_DASHLESS_REGEX } from '../internal/uuid.js';
6
+ import { publishEditCore } from '../ipfs-core.js';
7
+ import { requireGeoContract } from '../networks.js';
8
+ import { EDITS_PUBLISHED, EMPTY_SIGNATURE, EMPTY_TOPIC } from '../personal-space/constants.js';
9
+ import { requireFetch } from './context.js';
10
+ function spaceIdToBytes16(spaceId) {
11
+ if (UUID_DASHLESS_REGEX.test(spaceId)) {
12
+ return `0x${spaceId.toLowerCase()}`;
13
+ }
14
+ if (isValid(spaceId)) {
15
+ return toHex(toBytes(spaceId));
16
+ }
17
+ throw new Error(`Invalid spaceId: "${spaceId}". Expected a valid UUID or 32-character hex string.`);
18
+ }
19
+ /**
20
+ * Encodes personal-space edit publish calldata.
21
+ *
22
+ * Use this when an edit is already uploaded and you only need calldata for the
23
+ * configured or supplied space registry. The function accepts dashless UUID
24
+ * space IDs and valid SDK IDs.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const tx = encodePublishEditToSpaceCalldata({
29
+ * spaceId,
30
+ * cid: 'ipfs://bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku',
31
+ * spaceRegistryAddress: '0x0000000000000000000000000000000000000000',
32
+ * });
33
+ *
34
+ * await walletClient.sendTransaction({
35
+ * to: tx.to,
36
+ * data: tx.calldata,
37
+ * });
38
+ * ```
39
+ *
40
+ * @param params Space ID, edit CID, and space registry address.
41
+ * @returns Target registry address and encoded calldata.
42
+ * @throws When the space ID is not a valid UUID or SDK ID.
43
+ */
44
+ export function encodePublishEditToSpaceCalldata({ spaceId, cid, spaceRegistryAddress, }) {
45
+ const spaceIdBytes16 = spaceIdToBytes16(spaceId);
46
+ const encodedCid = encodeAbiParameters([{ type: 'string' }], [cid]);
47
+ const calldata = encodeFunctionData({
48
+ abi: SpaceRegistryAbi,
49
+ functionName: 'enter',
50
+ args: [spaceIdBytes16, spaceIdBytes16, EDITS_PUBLISHED, EMPTY_TOPIC, encodedCid, EMPTY_SIGNATURE],
51
+ });
52
+ return {
53
+ to: spaceRegistryAddress,
54
+ calldata,
55
+ };
56
+ }
57
+ /**
58
+ * Publishes edit ops to IPFS using the configured Geo API.
59
+ *
60
+ * This helper creates a GRC-20 edit payload, uploads it, and returns the edit
61
+ * CID and generated edit ID. It does not create transaction calldata.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import * as Ops from '@geoprotocol/geo-sdk/ops';
66
+ *
67
+ * const { ops } = Ops.entities.create({ name: 'Geo entity' });
68
+ * const edit = await publish(context, {
69
+ * name: 'Create Geo entity',
70
+ * author: authorSpaceId,
71
+ * ops,
72
+ * });
73
+ *
74
+ * console.log(edit.cid);
75
+ * ```
76
+ *
77
+ * @param context Client context containing API origin and fetch configuration.
78
+ * @param params Edit name, author space ID, and ops to publish.
79
+ * @returns Uploaded edit CID and generated edit ID.
80
+ * @throws When ops are empty, IDs are invalid, fetch is unavailable, upload fails, or the CID response is invalid.
81
+ */
82
+ export function publish(context, params) {
83
+ return publishEditCore({
84
+ ...params,
85
+ apiOrigin: context.network.apiOrigin,
86
+ fetch: requireFetch(context, 'Edit publishing'),
87
+ });
88
+ }
89
+ /**
90
+ * Publishes edit ops to IPFS and returns calldata for submitting the edit to a personal space.
91
+ *
92
+ * This combines {@link publish} and {@link encodePublishEditToSpaceCalldata}
93
+ * using the space registry address from the configured network.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const tx = await geo.personalSpaces.publishEdit({
98
+ * name: 'Create entity',
99
+ * spaceId,
100
+ * author: spaceId,
101
+ * ops,
102
+ * });
103
+ *
104
+ * await walletClient.sendTransaction({
105
+ * to: tx.to,
106
+ * data: tx.calldata,
107
+ * });
108
+ * ```
109
+ *
110
+ * @param context Client context containing network, contract, and fetch configuration.
111
+ * @param params Edit publication params plus the target space ID.
112
+ * @returns Edit ID, CID, target registry address, and calldata.
113
+ * @throws When required contract addresses are missing or publish/calldata validation fails.
114
+ */
115
+ export async function publishToSpace(context, params) {
116
+ const spaceRegistryAddress = requireGeoContract(context.network, 'SPACE_REGISTRY_ADDRESS');
117
+ spaceIdToBytes16(String(params.spaceId));
118
+ const { cid, editId } = await publish(context, params);
119
+ const { to, calldata } = encodePublishEditToSpaceCalldata({
120
+ spaceId: params.spaceId,
121
+ cid,
122
+ spaceRegistryAddress,
123
+ });
124
+ return {
125
+ editId,
126
+ cid,
127
+ to,
128
+ calldata,
129
+ };
130
+ }
131
+ //# sourceMappingURL=edits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edits.js","sourceRoot":"","sources":["../../../src/client/edits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAA0B,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE/F,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAY5C,SAAS,gBAAgB,CAAC,OAAe;IACvC,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,OAAO,CAAC,WAAW,EAAE,EAAmB,CAAC;IACvD,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,MAA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E,MAAM,CAAC,CAAC;IACvD,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,gCAAgC,CAAC;QACxD,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,GAAG;QACH,oBAAoB;KACrB,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,GAAG;QACH,EAAE;QACF,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=edits.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edits.test.d.ts","sourceRoot":"","sources":["../../../src/client/edits.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,98 @@
1
+ import { decodeAbiParameters, decodeFunctionData } from 'viem';
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { SpaceRegistryAbi } from '../abis/index.js';
4
+ import { createEntity } from '../graph/create-entity.js';
5
+ import { defineGeoNetworkConfig } from '../networks.js';
6
+ import { EDITS_PUBLISHED, EMPTY_SIGNATURE, EMPTY_TOPIC } from '../personal-space/constants.js';
7
+ import { encodePublishEditToSpaceCalldata, publish, publishToSpace } from './edits.js';
8
+ const CID = 'ipfs://bafkreigwfjixq5cm3s4youhshorkpqh3ykpviyv76c2ei6gaalujtlqz5i';
9
+ const SPACE_ID = '0eed5491b917cf58b33ac81255fe7ae9';
10
+ const AUTHOR_ID = '5cade5757ecd41ae83481b22ffc2f94e';
11
+ const SPACE_REGISTRY_ADDRESS = '0x0000000000000000000000000000000000000001';
12
+ function mockUploadFetch() {
13
+ return vi.fn().mockResolvedValue(new Response(JSON.stringify({ cid: CID })));
14
+ }
15
+ function testContext(fetch = mockUploadFetch()) {
16
+ return {
17
+ network: defineGeoNetworkConfig({
18
+ id: 'LOCAL',
19
+ name: 'Local Geo',
20
+ apiOrigin: 'http://localhost:3000',
21
+ contracts: {
22
+ SPACE_REGISTRY_ADDRESS,
23
+ },
24
+ }),
25
+ fetch,
26
+ };
27
+ }
28
+ function decodePublishEditCalldata(calldata) {
29
+ const decoded = decodeFunctionData({
30
+ abi: SpaceRegistryAbi,
31
+ data: calldata,
32
+ });
33
+ expect(decoded.functionName).toBe('enter');
34
+ const [fromSpaceId, toSpaceId, action, topic, data, signature] = decoded.args;
35
+ const [cid] = decodeAbiParameters([{ type: 'string' }], data);
36
+ return {
37
+ fromSpaceId,
38
+ toSpaceId,
39
+ action,
40
+ topic,
41
+ cid,
42
+ signature,
43
+ };
44
+ }
45
+ describe('client edit helpers', () => {
46
+ it('encodes personal space publish calldata without context', () => {
47
+ const { to, calldata } = encodePublishEditToSpaceCalldata({
48
+ spaceId: SPACE_ID,
49
+ cid: CID,
50
+ spaceRegistryAddress: SPACE_REGISTRY_ADDRESS,
51
+ });
52
+ const decoded = decodePublishEditCalldata(calldata);
53
+ expect(to).toBe(SPACE_REGISTRY_ADDRESS);
54
+ expect(decoded.fromSpaceId).toBe(`0x${SPACE_ID}`);
55
+ expect(decoded.toSpaceId).toBe(`0x${SPACE_ID}`);
56
+ expect(decoded.action).toBe(EDITS_PUBLISHED);
57
+ expect(decoded.topic).toBe(EMPTY_TOPIC);
58
+ expect(decoded.cid).toBe(CID);
59
+ expect(decoded.signature).toBe(EMPTY_SIGNATURE);
60
+ });
61
+ it('publishes an edit with the configured API origin and fetch implementation', async () => {
62
+ const fetch = mockUploadFetch();
63
+ const { ops } = createEntity({ name: 'Test Entity' });
64
+ const result = await publish(testContext(fetch), {
65
+ name: 'Test Edit',
66
+ ops,
67
+ author: AUTHOR_ID,
68
+ });
69
+ expect(result.cid).toBe(CID);
70
+ expect(result.editId).toHaveLength(32);
71
+ expect(fetch).toHaveBeenCalledWith('http://localhost:3000/ipfs/upload-edit', expect.objectContaining({ method: 'POST' }));
72
+ });
73
+ it('publishes to a personal space and returns transaction data for the configured registry', async () => {
74
+ const fetch = mockUploadFetch();
75
+ const { ops } = createEntity({ name: 'Test Entity' });
76
+ const result = await publishToSpace(testContext(fetch), {
77
+ name: 'Publish to space',
78
+ spaceId: SPACE_ID,
79
+ ops,
80
+ author: AUTHOR_ID,
81
+ });
82
+ expect(result.to).toBe(SPACE_REGISTRY_ADDRESS);
83
+ expect(result.cid).toBe(CID);
84
+ expect(decodePublishEditCalldata(result.calldata).cid).toBe(CID);
85
+ });
86
+ it('validates the personal space ID before uploading', async () => {
87
+ const fetch = mockUploadFetch();
88
+ const { ops } = createEntity({ name: 'Test Entity' });
89
+ await expect(publishToSpace(testContext(fetch), {
90
+ name: 'Publish to space',
91
+ spaceId: 'not-a-space-id',
92
+ ops,
93
+ author: AUTHOR_ID,
94
+ })).rejects.toThrow('Invalid spaceId');
95
+ expect(fetch).not.toHaveBeenCalled();
96
+ });
97
+ });
98
+ //# sourceMappingURL=edits.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edits.test.js","sourceRoot":"","sources":["../../../src/client/edits.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE/F,OAAO,EAAE,gCAAgC,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEvF,MAAM,GAAG,GAAG,oEAA6E,CAAC;AAC1F,MAAM,QAAQ,GAAG,kCAAkC,CAAC;AACpD,MAAM,SAAS,GAAG,kCAAkC,CAAC;AACrD,MAAM,sBAAsB,GAAG,4CAAqD,CAAC;AAErF,SAAS,eAAe;IACtB,OAAO,EAAE,CAAC,EAAE,EAA2B,CAAC,iBAAi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ityParams } from '../types.js';
2
+ import type { GeoClientContext } from './context.js';
3
+ /**
4
+ * Fetches the current entity values and relations for a space, then builds delete ops.
5
+ *
6
+ * Entity deletion requires current graph context so the SDK can unset existing
7
+ * values and delete existing relations in the target space.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const { ops } = await geo.entities.delete({
12
+ * id: entityId,
13
+ * spaceId,
14
+ * });
15
+ * ```
16
+ *
17
+ * @param context Client context containing API origin and fetch configuration.
18
+ * @param params Entity ID and space ID to delete within.
19
+ * @returns Entity ID and deletion ops, or no ops when the entity is not found.
20
+ * @throws When IDs are invalid, fetch is unavailable, GraphQL fails, or the response is malformed.
21
+ */
22
+ export declare function deleteEntity(context: GeoClientContext, { id, spaceId }: Omit<DeleteEntityParams, 'network'>): Promise<CreateResult>;
23
+ //# sourceMappingURL=entities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../src/client/entities.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAkDrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,yBAuCjH"}
@@ -0,0 +1,88 @@
1
+ import { deleteRelation as grcDeleteRelation, updateEntity as grcUpdateEntity, } from '@geoprotocol/grc-20';
2
+ import { Id } from '../id.js';
3
+ import { assertValid, toGrcId } from '../id-utils.js';
4
+ import { graphqlData } from './api.js';
5
+ class DeleteEntityError extends Error {
6
+ _tag = 'DeleteEntityError';
7
+ }
8
+ function createDeleteEntityOps({ id, spaceId, values, relations }) {
9
+ assertValid(id, '`id` in `deleteEntity`');
10
+ assertValid(spaceId, '`spaceId` in `deleteEntity`');
11
+ const normalizedSpaceId = String(spaceId).replaceAll('-', '');
12
+ const ops = [];
13
+ const matchingValues = values.filter(v => v.spaceId === normalizedSpaceId);
14
+ const matchingRelations = relations.filter(r => r.spaceId === normalizedSpaceId);
15
+ const uniquePropertyIds = [...new Set(matchingValues.map(v => v.propertyId))];
16
+ if (uniquePropertyIds.length > 0) {
17
+ const unsetValues = uniquePropertyIds.map(propertyId => ({
18
+ property: toGrcId(propertyId),
19
+ language: { type: 'all' },
20
+ }));
21
+ ops.push(grcUpdateEntity({
22
+ id: toGrcId(id),
23
+ set: [],
24
+ unset: unsetValues,
25
+ }));
26
+ }
27
+ for (const relation of matchingRelations) {
28
+ ops.push(grcDeleteRelation(toGrcId(relation.id)));
29
+ }
30
+ return { id: Id(id), ops };
31
+ }
32
+ /**
33
+ * Fetches the current entity values and relations for a space, then builds delete ops.
34
+ *
35
+ * Entity deletion requires current graph context so the SDK can unset existing
36
+ * values and delete existing relations in the target space.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const { ops } = await geo.entities.delete({
41
+ * id: entityId,
42
+ * spaceId,
43
+ * });
44
+ * ```
45
+ *
46
+ * @param context Client context containing API origin and fetch configuration.
47
+ * @param params Entity ID and space ID to delete within.
48
+ * @returns Entity ID and deletion ops, or no ops when the entity is not found.
49
+ * @throws When IDs are invalid, fetch is unavailable, GraphQL fails, or the response is malformed.
50
+ */
51
+ export async function deleteEntity(context, { id, spaceId }) {
52
+ assertValid(id, '`id` in `deleteEntity`');
53
+ assertValid(spaceId, '`spaceId` in `deleteEntity`');
54
+ const normalizedSpaceId = String(spaceId).replaceAll('-', '');
55
+ const query = `query entity {
56
+ entity(id: "${id}") {
57
+ valuesList(filter: { spaceId: { in: [${JSON.stringify(normalizedSpaceId)}] } }) {
58
+ propertyId
59
+ spaceId
60
+ }
61
+ relationsList(filter: { spaceId: { in: [${JSON.stringify(normalizedSpaceId)}] } }) {
62
+ id
63
+ spaceId
64
+ }
65
+ }
66
+ }`;
67
+ let response;
68
+ try {
69
+ response = await graphqlData(context, query);
70
+ }
71
+ catch (error) {
72
+ const message = String(error);
73
+ if (message.includes('Could not parse GraphQL response')) {
74
+ throw new DeleteEntityError(`Could not parse GraphQL response for entity ${id}: ${error}`);
75
+ }
76
+ throw new DeleteEntityError(`Could not fetch entity data for ${id}: ${error}`);
77
+ }
78
+ if (!response.entity) {
79
+ return { id: Id(id), ops: [] };
80
+ }
81
+ return createDeleteEntityOps({
82
+ id,
83
+ spaceId,
84
+ values: response.entity.valuesList,
85
+ relations: response.entity.relationsList,
86
+ });
87
+ }
88
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/client/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,IAAI,iBAAiB,EACnC,YAAY,IAAI,eAAe,GAEhC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,MAAM,iBAAkB,SAAQ,KAAK;IAC1B,IAAI,GAAG,mBAAmB,CAAC;CACrC;AAcD,SAAS,qBAAqB,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAyB;IACtF,WAAW,CAAC,EAAE,EAAE,wBAAwB,CAAC,CAAC;IAC1C,WAAW,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;IAEpD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC9D,MAAM,GAAG,GAAS,EAAE,CAAC;IACrB,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,iBAAiB,CAAC,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AAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG;kBACE,EAAE;6CACyB,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;;;;gDAI9B,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;;;;;IAK7E,CAAC;IAEH,IAAI,QAA+B,CAAC;IACpC,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,WAAW,CAAwB,OAAO,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,iBAAiB,CAAC,+CAA+C,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC;QAC7F,CAAC;QACD,MAAM,IAAI,iBAAiB,CAAC,mCAAmC,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,qBAAqB,CAAC;QAC3B,EAAE;QACF,OAAO;QACP,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU;QAClC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa;KACzC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,141 @@
1
+ import type { Id } from '../id.js';
2
+ import type { GeoClientContext } from './context.js';
3
+ export type ClientEntityVoteParams = {
4
+ authorSpaceId: Id | string;
5
+ spaceId: Id | string;
6
+ entityId: Id | string;
7
+ };
8
+ export type EntityVoteCalldataParams = ClientEntityVoteParams & {
9
+ spaceRegistryAddress: `0x${string}`;
10
+ };
11
+ /**
12
+ * Encodes upvote calldata.
13
+ *
14
+ * Use this pure helper when you already have the target space registry address.
15
+ * Use `geo.entityVotes.upvote(...)` when the address should come from the
16
+ * configured network.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const tx = encodeUpvoteEntityCalldata({
21
+ * authorSpaceId,
22
+ * spaceId,
23
+ * entityId,
24
+ * spaceRegistryAddress,
25
+ * });
26
+ * ```
27
+ *
28
+ * @param params Author space, target space, entity ID, and space registry address.
29
+ * @returns Target registry address and encoded calldata.
30
+ * @throws When any supplied ID is invalid.
31
+ */
32
+ export declare function encodeUpvoteEntityCalldata(params: EntityVoteCalldataParams): {
33
+ to: `0x${string}`;
34
+ calldata: `0x${string}`;
35
+ };
36
+ /**
37
+ * Encodes downvote calldata.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const tx = encodeDownvoteEntityCalldata({
42
+ * authorSpaceId,
43
+ * spaceId,
44
+ * entityId,
45
+ * spaceRegistryAddress,
46
+ * });
47
+ * ```
48
+ *
49
+ * @param params Author space, target space, entity ID, and space registry address.
50
+ * @returns Target registry address and encoded calldata.
51
+ * @throws When any supplied ID is invalid.
52
+ */
53
+ export declare function encodeDownvoteEntityCalldata(params: EntityVoteCalldataParams): {
54
+ to: `0x${string}`;
55
+ calldata: `0x${string}`;
56
+ };
57
+ /**
58
+ * Encodes vote-withdrawal calldata.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const tx = encodeWithdrawEntityVoteCalldata({
63
+ * authorSpaceId,
64
+ * spaceId,
65
+ * entityId,
66
+ * spaceRegistryAddress,
67
+ * });
68
+ * ```
69
+ *
70
+ * @param params Author space, target space, entity ID, and space registry address.
71
+ * @returns Target registry address and encoded calldata.
72
+ * @throws When any supplied ID is invalid.
73
+ */
74
+ export declare function encodeWithdrawEntityVoteCalldata(params: EntityVoteCalldataParams): {
75
+ to: `0x${string}`;
76
+ calldata: `0x${string}`;
77
+ };
78
+ /**
79
+ * Builds calldata for upvoting an entity using the configured space registry.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const tx = geo.entityVotes.upvote({
84
+ * authorSpaceId,
85
+ * spaceId,
86
+ * entityId,
87
+ * });
88
+ * ```
89
+ *
90
+ * @param context Client context containing the target network configuration.
91
+ * @param params Author space, target space, and entity ID.
92
+ * @returns Target registry address and encoded calldata.
93
+ * @throws When IDs are invalid or the configured network is missing `SPACE_REGISTRY_ADDRESS`.
94
+ */
95
+ export declare function upvote(context: GeoClientContext, params: ClientEntityVoteParams): {
96
+ to: `0x${string}`;
97
+ calldata: `0x${string}`;
98
+ };
99
+ /**
100
+ * Builds calldata for downvoting an entity using the configured space registry.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const tx = geo.entityVotes.downvote({
105
+ * authorSpaceId,
106
+ * spaceId,
107
+ * entityId,
108
+ * });
109
+ * ```
110
+ *
111
+ * @param context Client context containing the target network configuration.
112
+ * @param params Author space, target space, and entity ID.
113
+ * @returns Target registry address and encoded calldata.
114
+ * @throws When IDs are invalid or the configured network is missing `SPACE_REGISTRY_ADDRESS`.
115
+ */
116
+ export declare function downvote(context: GeoClientContext, params: ClientEntityVoteParams): {
117
+ to: `0x${string}`;
118
+ calldata: `0x${string}`;
119
+ };
120
+ /**
121
+ * Builds calldata for withdrawing an entity vote using the configured space registry.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const tx = geo.entityVotes.withdraw({
126
+ * authorSpaceId,
127
+ * spaceId,
128
+ * entityId,
129
+ * });
130
+ * ```
131
+ *
132
+ * @param context Client context containing the target network configuration.
133
+ * @param params Author space, target space, and entity ID.
134
+ * @returns Target registry address and encoded calldata.
135
+ * @throws When IDs are invalid or the configured network is missing `SPACE_REGISTRY_ADDRESS`.
136
+ */
137
+ export declare function withdraw(context: GeoClientContext, params: ClientEntityVoteParams): {
138
+ to: `0x${string}`;
139
+ calldata: `0x${string}`;
140
+ };
141
+ //# sourceMappingURL=entity-votes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-votes.d.ts","sourceRoot":"","sources":["../../../src/client/entity-votes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAGnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAWrD,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,EAAE,GAAG,MAAM,CAAC;IAC3B,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC;IACrB,QAAQ,EAAE,EAAE,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,sBAAsB,GAAG;IAC9D,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;CACrC,CAAC;AA+CF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,wBAAwB;;;EAE1E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,wBAAwB;;;EAE5E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,wBAAwB;;;EAEhF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,sBAAsB;;;EAE/E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,sBAAsB;;;EAEjF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,sBAAsB;;;EAEjF"}