@geoprotocol/geo-sdk 0.18.3 → 0.19.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 (344) 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 +7 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +7 -0
  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-v2.test.d.ts +2 -0
  15. package/dist/src/abis/dao-space-v2.test.d.ts.map +1 -0
  16. package/dist/src/abis/dao-space-v2.test.js +67 -0
  17. package/dist/src/abis/dao-space-v2.test.js.map +1 -0
  18. package/dist/src/client/api.d.ts +86 -0
  19. package/dist/src/client/api.d.ts.map +1 -0
  20. package/dist/src/client/api.js +169 -0
  21. package/dist/src/client/api.js.map +1 -0
  22. package/dist/src/client/comments.d.ts +59 -0
  23. package/dist/src/client/comments.d.ts.map +1 -0
  24. package/dist/src/client/comments.js +96 -0
  25. package/dist/src/client/comments.js.map +1 -0
  26. package/dist/src/client/context.d.ts +20 -0
  27. package/dist/src/client/context.d.ts.map +1 -0
  28. package/dist/src/client/context.js +20 -0
  29. package/dist/src/client/context.js.map +1 -0
  30. package/dist/src/client/dao-spaces.d.ts +348 -0
  31. package/dist/src/client/dao-spaces.d.ts.map +1 -0
  32. package/dist/src/client/dao-spaces.js +494 -0
  33. package/dist/src/client/dao-spaces.js.map +1 -0
  34. package/dist/src/client/dao-spaces.test.d.ts +2 -0
  35. package/dist/src/client/dao-spaces.test.d.ts.map +1 -0
  36. package/dist/src/client/dao-spaces.test.js +263 -0
  37. package/dist/src/client/dao-spaces.test.js.map +1 -0
  38. package/dist/src/client/edits.d.ts +100 -0
  39. package/dist/src/client/edits.d.ts.map +1 -0
  40. package/dist/src/client/edits.js +131 -0
  41. package/dist/src/client/edits.js.map +1 -0
  42. package/dist/src/client/edits.test.d.ts +2 -0
  43. package/dist/src/client/edits.test.d.ts.map +1 -0
  44. package/dist/src/client/edits.test.js +98 -0
  45. package/dist/src/client/edits.test.js.map +1 -0
  46. package/dist/src/client/entities.d.ts +23 -0
  47. package/dist/src/client/entities.d.ts.map +1 -0
  48. package/dist/src/client/entities.js +88 -0
  49. package/dist/src/client/entities.js.map +1 -0
  50. package/dist/src/client/entity-votes.d.ts +141 -0
  51. package/dist/src/client/entity-votes.d.ts.map +1 -0
  52. package/dist/src/client/entity-votes.js +168 -0
  53. package/dist/src/client/entity-votes.js.map +1 -0
  54. package/dist/src/client/entity-votes.test.d.ts +2 -0
  55. package/dist/src/client/entity-votes.test.d.ts.map +1 -0
  56. package/dist/src/client/entity-votes.test.js +93 -0
  57. package/dist/src/client/entity-votes.test.js.map +1 -0
  58. package/dist/src/client/graph-workflows.test.d.ts +2 -0
  59. package/dist/src/client/graph-workflows.test.d.ts.map +1 -0
  60. package/dist/src/client/graph-workflows.test.js +83 -0
  61. package/dist/src/client/graph-workflows.test.js.map +1 -0
  62. package/dist/src/client/images-storage.test.d.ts +2 -0
  63. package/dist/src/client/images-storage.test.d.ts.map +1 -0
  64. package/dist/src/client/images-storage.test.js +52 -0
  65. package/dist/src/client/images-storage.test.js.map +1 -0
  66. package/dist/src/client/images.d.ts +35 -0
  67. package/dist/src/client/images.d.ts.map +1 -0
  68. package/dist/src/client/images.js +90 -0
  69. package/dist/src/client/images.js.map +1 -0
  70. package/dist/src/client/personal-spaces.d.ts +155 -0
  71. package/dist/src/client/personal-spaces.d.ts.map +1 -0
  72. package/dist/src/client/personal-spaces.js +198 -0
  73. package/dist/src/client/personal-spaces.js.map +1 -0
  74. package/dist/src/client/proposals.d.ts +185 -0
  75. package/dist/src/client/proposals.d.ts.map +1 -0
  76. package/dist/src/client/proposals.js +294 -0
  77. package/dist/src/client/proposals.js.map +1 -0
  78. package/dist/src/client/proposals.test.d.ts +2 -0
  79. package/dist/src/client/proposals.test.d.ts.map +1 -0
  80. package/dist/src/client/proposals.test.js +243 -0
  81. package/dist/src/client/proposals.test.js.map +1 -0
  82. package/dist/src/client/spaces.test.d.ts +2 -0
  83. package/dist/src/client/spaces.test.d.ts.map +1 -0
  84. package/dist/src/client/spaces.test.js +155 -0
  85. package/dist/src/client/spaces.test.js.map +1 -0
  86. package/dist/src/client/storage.d.ts +52 -0
  87. package/dist/src/client/storage.d.ts.map +1 -0
  88. package/dist/src/client/storage.js +53 -0
  89. package/dist/src/client/storage.js.map +1 -0
  90. package/dist/src/client.d.ts +325 -0
  91. package/dist/src/client.d.ts.map +1 -0
  92. package/dist/src/client.js +452 -0
  93. package/dist/src/client.js.map +1 -0
  94. package/dist/src/client.test.d.ts +2 -0
  95. package/dist/src/client.test.d.ts.map +1 -0
  96. package/dist/src/client.test.js +120 -0
  97. package/dist/src/client.test.js.map +1 -0
  98. package/dist/src/contracts-v2/abis.d.ts +196 -0
  99. package/dist/src/contracts-v2/abis.d.ts.map +1 -0
  100. package/dist/src/contracts-v2/abis.js +110 -0
  101. package/dist/src/contracts-v2/abis.js.map +1 -0
  102. package/dist/src/contracts-v2/actions.d.ts +56 -0
  103. package/dist/src/contracts-v2/actions.d.ts.map +1 -0
  104. package/dist/src/contracts-v2/actions.js +83 -0
  105. package/dist/src/contracts-v2/actions.js.map +1 -0
  106. package/dist/src/contracts-v2/encoding.d.ts +80 -0
  107. package/dist/src/contracts-v2/encoding.d.ts.map +1 -0
  108. package/dist/src/contracts-v2/encoding.js +193 -0
  109. package/dist/src/contracts-v2/encoding.js.map +1 -0
  110. package/dist/src/contracts-v2/encoding.test.d.ts +2 -0
  111. package/dist/src/contracts-v2/encoding.test.d.ts.map +1 -0
  112. package/dist/src/contracts-v2/encoding.test.js +93 -0
  113. package/dist/src/contracts-v2/encoding.test.js.map +1 -0
  114. package/dist/src/contracts-v2/local-geobrowser.e2e.test.d.ts +2 -0
  115. package/dist/src/contracts-v2/local-geobrowser.e2e.test.d.ts.map +1 -0
  116. package/dist/src/contracts-v2/local-geobrowser.e2e.test.js +239 -0
  117. package/dist/src/contracts-v2/local-geobrowser.e2e.test.js.map +1 -0
  118. package/dist/src/contracts-v2/voting-settings.d.ts +48 -0
  119. package/dist/src/contracts-v2/voting-settings.d.ts.map +1 -0
  120. package/dist/src/contracts-v2/voting-settings.js +69 -0
  121. package/dist/src/contracts-v2/voting-settings.js.map +1 -0
  122. package/dist/src/dao-space/constants.d.ts +6 -3
  123. package/dist/src/dao-space/constants.d.ts.map +1 -1
  124. package/dist/src/dao-space/constants.js +6 -5
  125. package/dist/src/dao-space/constants.js.map +1 -1
  126. package/dist/src/dao-space/create-space.d.ts +1 -31
  127. package/dist/src/dao-space/create-space.d.ts.map +1 -1
  128. package/dist/src/dao-space/create-space.js +5 -70
  129. package/dist/src/dao-space/create-space.js.map +1 -1
  130. package/dist/src/dao-space/execute-proposal.d.ts +1 -22
  131. package/dist/src/dao-space/execute-proposal.d.ts.map +1 -1
  132. package/dist/src/dao-space/execute-proposal.js +12 -59
  133. package/dist/src/dao-space/execute-proposal.js.map +1 -1
  134. package/dist/src/dao-space/propose-add-editor.test.js +1 -1
  135. package/dist/src/dao-space/propose-add-editor.test.js.map +1 -1
  136. package/dist/src/dao-space/propose-edit.d.ts +1 -30
  137. package/dist/src/dao-space/propose-edit.d.ts.map +1 -1
  138. package/dist/src/dao-space/propose-edit.js +12 -108
  139. package/dist/src/dao-space/propose-edit.js.map +1 -1
  140. package/dist/src/dao-space/propose-edit.test.js +8 -1
  141. package/dist/src/dao-space/propose-edit.test.js.map +1 -1
  142. package/dist/src/dao-space/propose-remove-editor.d.ts.map +1 -1
  143. package/dist/src/dao-space/propose-remove-editor.js +5 -5
  144. package/dist/src/dao-space/propose-remove-editor.js.map +1 -1
  145. package/dist/src/dao-space/propose-remove-editor.test.js +3 -8
  146. package/dist/src/dao-space/propose-remove-editor.test.js.map +1 -1
  147. package/dist/src/dao-space/propose-remove-member.d.ts.map +1 -1
  148. package/dist/src/dao-space/propose-remove-member.js +5 -5
  149. package/dist/src/dao-space/propose-remove-member.js.map +1 -1
  150. package/dist/src/dao-space/propose-request-membership.d.ts.map +1 -1
  151. package/dist/src/dao-space/propose-request-membership.js +4 -4
  152. package/dist/src/dao-space/propose-request-membership.js.map +1 -1
  153. package/dist/src/dao-space/propose-update-voting-settings.d.ts +8 -0
  154. package/dist/src/dao-space/propose-update-voting-settings.d.ts.map +1 -0
  155. package/dist/src/dao-space/propose-update-voting-settings.js +19 -0
  156. package/dist/src/dao-space/propose-update-voting-settings.js.map +1 -0
  157. package/dist/src/dao-space/propose-update-voting-settings.test.d.ts +2 -0
  158. package/dist/src/dao-space/propose-update-voting-settings.test.d.ts.map +1 -0
  159. package/dist/src/dao-space/propose-update-voting-settings.test.js +118 -0
  160. package/dist/src/dao-space/propose-update-voting-settings.test.js.map +1 -0
  161. package/dist/src/dao-space/vote-proposal.d.ts +1 -24
  162. package/dist/src/dao-space/vote-proposal.d.ts.map +1 -1
  163. package/dist/src/dao-space/vote-proposal.js +12 -64
  164. package/dist/src/dao-space/vote-proposal.js.map +1 -1
  165. package/dist/src/e2e/local-geobrowser.d.ts +9 -0
  166. package/dist/src/e2e/local-geobrowser.d.ts.map +1 -0
  167. package/dist/src/e2e/local-geobrowser.js +35 -0
  168. package/dist/src/e2e/local-geobrowser.js.map +1 -0
  169. package/dist/src/e2e/v2-contracts.test.d.ts +2 -0
  170. package/dist/src/e2e/v2-contracts.test.d.ts.map +1 -0
  171. package/dist/src/e2e/v2-contracts.test.js +25 -0
  172. package/dist/src/e2e/v2-contracts.test.js.map +1 -0
  173. package/dist/src/e2e-api-surface.test.d.ts +2 -0
  174. package/dist/src/e2e-api-surface.test.d.ts.map +1 -0
  175. package/dist/src/e2e-api-surface.test.js +1021 -0
  176. package/dist/src/e2e-api-surface.test.js.map +1 -0
  177. package/dist/src/e2e-flows.test.d.ts +2 -0
  178. package/dist/src/e2e-flows.test.d.ts.map +1 -0
  179. package/dist/src/e2e-flows.test.js +445 -0
  180. package/dist/src/e2e-flows.test.js.map +1 -0
  181. package/dist/src/e2e-legacy-api-surface.test.d.ts +2 -0
  182. package/dist/src/e2e-legacy-api-surface.test.d.ts.map +1 -0
  183. package/dist/src/e2e-legacy-api-surface.test.js +840 -0
  184. package/dist/src/e2e-legacy-api-surface.test.js.map +1 -0
  185. package/dist/src/encoding.d.ts +3 -0
  186. package/dist/src/encoding.d.ts.map +1 -1
  187. package/dist/src/encoding.js +3 -0
  188. package/dist/src/encoding.js.map +1 -1
  189. package/dist/src/encodings/get-create-dao-space-calldata.d.ts +3 -89
  190. package/dist/src/encodings/get-create-dao-space-calldata.d.ts.map +1 -1
  191. package/dist/src/encodings/get-create-dao-space-calldata.js +5 -95
  192. package/dist/src/encodings/get-create-dao-space-calldata.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/graph/comment-utils.d.ts +4 -0
  198. package/dist/src/graph/comment-utils.d.ts.map +1 -1
  199. package/dist/src/graph/comment-utils.js +4 -0
  200. package/dist/src/graph/comment-utils.js.map +1 -1
  201. package/dist/src/graph/constants.d.ts +12 -3
  202. package/dist/src/graph/constants.d.ts.map +1 -1
  203. package/dist/src/graph/constants.js +11 -5
  204. package/dist/src/graph/constants.js.map +1 -1
  205. package/dist/src/graph/create-comment.d.ts +3 -22
  206. package/dist/src/graph/create-comment.d.ts.map +1 -1
  207. package/dist/src/graph/create-comment.js +6 -136
  208. package/dist/src/graph/create-comment.js.map +1 -1
  209. package/dist/src/graph/create-comment.test.js +19 -8
  210. package/dist/src/graph/create-comment.test.js.map +1 -1
  211. package/dist/src/graph/create-entity.d.ts +2 -0
  212. package/dist/src/graph/create-entity.d.ts.map +1 -1
  213. package/dist/src/graph/create-entity.js +2 -0
  214. package/dist/src/graph/create-entity.js.map +1 -1
  215. package/dist/src/graph/create-image.d.ts +2 -21
  216. package/dist/src/graph/create-image.d.ts.map +1 -1
  217. package/dist/src/graph/create-image.js +7 -69
  218. package/dist/src/graph/create-image.js.map +1 -1
  219. package/dist/src/graph/create-property.d.ts +2 -0
  220. package/dist/src/graph/create-property.d.ts.map +1 -1
  221. package/dist/src/graph/create-property.js +2 -0
  222. package/dist/src/graph/create-property.js.map +1 -1
  223. package/dist/src/graph/create-proposal-review.d.ts +1 -27
  224. package/dist/src/graph/create-proposal-review.d.ts.map +1 -1
  225. package/dist/src/graph/create-proposal-review.js +4 -61
  226. package/dist/src/graph/create-proposal-review.js.map +1 -1
  227. package/dist/src/graph/create-relation.d.ts +2 -0
  228. package/dist/src/graph/create-relation.d.ts.map +1 -1
  229. package/dist/src/graph/create-relation.js +2 -0
  230. package/dist/src/graph/create-relation.js.map +1 -1
  231. package/dist/src/graph/create-type.d.ts +2 -0
  232. package/dist/src/graph/create-type.d.ts.map +1 -1
  233. package/dist/src/graph/create-type.js +2 -0
  234. package/dist/src/graph/create-type.js.map +1 -1
  235. package/dist/src/graph/delete-entity.d.ts +2 -14
  236. package/dist/src/graph/delete-entity.d.ts.map +1 -1
  237. package/dist/src/graph/delete-entity.js +5 -78
  238. package/dist/src/graph/delete-entity.js.map +1 -1
  239. package/dist/src/graph/delete-entity.test.js +7 -0
  240. package/dist/src/graph/delete-entity.test.js.map +1 -1
  241. package/dist/src/graph/delete-relation.d.ts +2 -0
  242. package/dist/src/graph/delete-relation.d.ts.map +1 -1
  243. package/dist/src/graph/delete-relation.js +2 -0
  244. package/dist/src/graph/delete-relation.js.map +1 -1
  245. package/dist/src/graph/entity-vote.d.ts +3 -3
  246. package/dist/src/graph/entity-vote.d.ts.map +1 -1
  247. package/dist/src/graph/entity-vote.js +21 -46
  248. package/dist/src/graph/entity-vote.js.map +1 -1
  249. package/dist/src/graph/update-comment.d.ts +3 -0
  250. package/dist/src/graph/update-comment.d.ts.map +1 -1
  251. package/dist/src/graph/update-comment.js +3 -0
  252. package/dist/src/graph/update-comment.js.map +1 -1
  253. package/dist/src/graph/update-entity.d.ts +2 -0
  254. package/dist/src/graph/update-entity.d.ts.map +1 -1
  255. package/dist/src/graph/update-entity.js +2 -0
  256. package/dist/src/graph/update-entity.js.map +1 -1
  257. package/dist/src/graph/update-proposal-review.d.ts +2 -27
  258. package/dist/src/graph/update-proposal-review.d.ts.map +1 -1
  259. package/dist/src/graph/update-proposal-review.js +4 -50
  260. package/dist/src/graph/update-proposal-review.js.map +1 -1
  261. package/dist/src/graph/update-relation.d.ts +2 -0
  262. package/dist/src/graph/update-relation.d.ts.map +1 -1
  263. package/dist/src/graph/update-relation.js +2 -0
  264. package/dist/src/graph/update-relation.js.map +1 -1
  265. package/dist/src/ipfs-core.d.ts +42 -0
  266. package/dist/src/ipfs-core.d.ts.map +1 -0
  267. package/dist/src/ipfs-core.js +165 -0
  268. package/dist/src/ipfs-core.js.map +1 -0
  269. package/dist/src/ipfs-core.test.d.ts +2 -0
  270. package/dist/src/ipfs-core.test.d.ts.map +1 -0
  271. package/dist/src/ipfs-core.test.js +56 -0
  272. package/dist/src/ipfs-core.test.js.map +1 -0
  273. package/dist/src/ipfs.d.ts +7 -52
  274. package/dist/src/ipfs.d.ts.map +1 -1
  275. package/dist/src/ipfs.js +27 -170
  276. package/dist/src/ipfs.js.map +1 -1
  277. package/dist/src/networks.d.ts +46 -0
  278. package/dist/src/networks.d.ts.map +1 -0
  279. package/dist/src/networks.js +90 -0
  280. package/dist/src/networks.js.map +1 -0
  281. package/dist/src/ops/comments.d.ts +80 -0
  282. package/dist/src/ops/comments.d.ts.map +1 -0
  283. package/dist/src/ops/comments.js +142 -0
  284. package/dist/src/ops/comments.js.map +1 -0
  285. package/dist/src/ops/entities.d.ts +50 -0
  286. package/dist/src/ops/entities.d.ts.map +1 -0
  287. package/dist/src/ops/entities.js +51 -0
  288. package/dist/src/ops/entities.js.map +1 -0
  289. package/dist/src/ops/images.d.ts +37 -0
  290. package/dist/src/ops/images.d.ts.map +1 -0
  291. package/dist/src/ops/images.js +69 -0
  292. package/dist/src/ops/images.js.map +1 -0
  293. package/dist/src/ops/index.d.ts +7 -0
  294. package/dist/src/ops/index.d.ts.map +1 -0
  295. package/dist/src/ops/index.js +7 -0
  296. package/dist/src/ops/index.js.map +1 -0
  297. package/dist/src/ops/index.test.d.ts +2 -0
  298. package/dist/src/ops/index.test.d.ts.map +1 -0
  299. package/dist/src/ops/index.test.js +115 -0
  300. package/dist/src/ops/index.test.js.map +1 -0
  301. package/dist/src/ops/properties.d.ts +20 -0
  302. package/dist/src/ops/properties.d.ts.map +1 -0
  303. package/dist/src/ops/properties.js +20 -0
  304. package/dist/src/ops/properties.js.map +1 -0
  305. package/dist/src/ops/proposal-reviews.d.ts +43 -0
  306. package/dist/src/ops/proposal-reviews.d.ts.map +1 -0
  307. package/dist/src/ops/proposal-reviews.js +103 -0
  308. package/dist/src/ops/proposal-reviews.js.map +1 -0
  309. package/dist/src/ops/relations.d.ts +57 -0
  310. package/dist/src/ops/relations.d.ts.map +1 -0
  311. package/dist/src/ops/relations.js +59 -0
  312. package/dist/src/ops/relations.js.map +1 -0
  313. package/dist/src/ops/types.d.ts +20 -0
  314. package/dist/src/ops/types.d.ts.map +1 -0
  315. package/dist/src/ops/types.js +20 -0
  316. package/dist/src/ops/types.js.map +1 -0
  317. package/dist/src/personal-space/constants.d.ts +1 -0
  318. package/dist/src/personal-space/constants.d.ts.map +1 -1
  319. package/dist/src/personal-space/constants.js +1 -0
  320. package/dist/src/personal-space/constants.js.map +1 -1
  321. package/dist/src/personal-space/create-space.d.ts +1 -18
  322. package/dist/src/personal-space/create-space.d.ts.map +1 -1
  323. package/dist/src/personal-space/create-space.js +1 -18
  324. package/dist/src/personal-space/create-space.js.map +1 -1
  325. package/dist/src/personal-space/has-space.d.ts +9 -2
  326. package/dist/src/personal-space/has-space.d.ts.map +1 -1
  327. package/dist/src/personal-space/has-space.js +9 -13
  328. package/dist/src/personal-space/has-space.js.map +1 -1
  329. package/dist/src/personal-space/has-space.test.d.ts +2 -0
  330. package/dist/src/personal-space/has-space.test.d.ts.map +1 -0
  331. package/dist/src/personal-space/has-space.test.js +30 -0
  332. package/dist/src/personal-space/has-space.test.js.map +1 -0
  333. package/dist/src/personal-space/publish-edit.d.ts +1 -22
  334. package/dist/src/personal-space/publish-edit.d.ts.map +1 -1
  335. package/dist/src/personal-space/publish-edit.js +10 -64
  336. package/dist/src/personal-space/publish-edit.js.map +1 -1
  337. package/dist/src/smart-wallet.d.ts +2 -4
  338. package/dist/src/smart-wallet.d.ts.map +1 -1
  339. package/dist/src/smart-wallet.js +6 -9
  340. package/dist/src/smart-wallet.js.map +1 -1
  341. package/dist/src/types.d.ts +25 -0
  342. package/dist/src/types.d.ts.map +1 -1
  343. package/dist/src/types.js.map +1 -1
  344. package/package.json +14 -1
@@ -0,0 +1,52 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { createGeoClient } from '../client.js';
3
+ import { IMAGE_URL_PROPERTY } from '../core/ids/system.js';
4
+ import { toGrcId } from '../id-utils.js';
5
+ import { defineGeoNetworkConfig } from '../networks.js';
6
+ const CID = 'ipfs://bafkreigwfjixq5cm3s4youhshorkpqh3ykpviyv76c2ei6gaalujtlqz5i';
7
+ const IMAGE_ID = '3af3e22d21694a078681516710b7ecf1';
8
+ function customNetwork() {
9
+ return defineGeoNetworkConfig({
10
+ id: 'LOCAL',
11
+ name: 'Local Geo',
12
+ apiOrigin: 'http://localhost:3000',
13
+ });
14
+ }
15
+ function mockUploadFetch() {
16
+ return vi.fn().mockImplementation(async () => new Response(JSON.stringify({ cid: CID })));
17
+ }
18
+ function imageUrlValue(entityOp) {
19
+ return entityOp.values.find(value => value.property.every((byte, index) => byte === toGrcId(IMAGE_URL_PROPERTY)[index]));
20
+ }
21
+ describe('geo image and storage clients', () => {
22
+ it('uploads an image through the configured API origin before creating image ops', async () => {
23
+ const fetch = mockUploadFetch();
24
+ const geo = createGeoClient({ network: customNetwork(), fetch });
25
+ const result = await geo.images.create({
26
+ id: IMAGE_ID,
27
+ name: 'Test image',
28
+ blob: new Blob([new Uint8Array([0, 0, 0, 0])], { type: 'image/png' }),
29
+ });
30
+ const entityOp = result.ops[0];
31
+ const urlValue = imageUrlValue(entityOp);
32
+ expect(result.id).toBe(IMAGE_ID);
33
+ expect(result.cid).toBe(CID);
34
+ expect(urlValue?.value.type).toBe('text');
35
+ if (urlValue?.value.type === 'text') {
36
+ expect(urlValue.value.value).toBe(CID);
37
+ }
38
+ expect(fetch).toHaveBeenCalledWith('http://localhost:3000/ipfs/upload-file', expect.objectContaining({ method: 'POST' }));
39
+ });
40
+ it('uses configured upload routes for storage helpers', async () => {
41
+ const fetch = mockUploadFetch();
42
+ const geo = createGeoClient({ network: customNetwork(), fetch });
43
+ await expect(geo.storage.uploadImage({
44
+ blob: new Blob([new Uint8Array([0, 0, 0, 0])], { type: 'image/png' }),
45
+ alternativeGateway: true,
46
+ })).resolves.toEqual({ cid: CID });
47
+ await expect(geo.storage.uploadCSV('a,b\n1,2')).resolves.toBe(CID);
48
+ expect(fetch).toHaveBeenNthCalledWith(1, 'http://localhost:3000/ipfs/upload-file-alternative-gateway', expect.objectContaining({ method: 'POST' }));
49
+ expect(fetch).toHaveBeenNthCalledWith(2, 'http://localhost:3000/ipfs/upload-edit', expect.objectContaining({ method: 'POST' }));
50
+ });
51
+ });
52
+ //# sourceMappingURL=images-storage.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"images-storage.test.js","sourceRoot":"","sources":["../../../src/client/images-storage.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,e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AC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YACrE,kBAAkB,EAAE,IAAI;SACzB,CAAC,CACH,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QACjC,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEnE,MAAM,CAAC,KAAK,CAAC,CAAC,uBAAuB,CACnC,CAAC,EACD,4DAA4D,EAC5D,MAAM,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAC5C,CAAC;QACF,MAAM,CAAC,KAAK,CAAC,CAAC,uBAAuB,CACnC,CAAC,EACD,wCAAwC,EACxC,MAAM,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAC5C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { Id } from '../id.js';
2
+ import { type PublishImageParams } from '../ipfs-core.js';
3
+ import type { CreateImageResult } from '../types.js';
4
+ import type { GeoClientContext } from './context.js';
5
+ export type CreateImageParams = PublishImageParams & {
6
+ name?: string;
7
+ description?: string;
8
+ id?: Id | string;
9
+ alternativeGateway?: boolean;
10
+ };
11
+ /**
12
+ * Uploads an image and builds the corresponding image entity ops.
13
+ *
14
+ * This is the context-aware image workflow used by `geo.images.create(...)`.
15
+ * It uploads the image through the configured API origin, attempts to read
16
+ * image dimensions, then creates image entity ops.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const { id, cid, dimensions, ops } = await geo.images.create({
21
+ * url: 'https://example.com/cover.png',
22
+ * name: 'Cover image',
23
+ * description: 'Image used as the space cover.',
24
+ * });
25
+ *
26
+ * console.log(id, cid, dimensions);
27
+ * ```
28
+ *
29
+ * @param context Client context containing network and fetch configuration.
30
+ * @param params Image source plus optional entity metadata.
31
+ * @returns Created image entity ID, uploaded CID, dimensions when detected, and ops.
32
+ * @throws When the optional ID is invalid, fetch is unavailable, upload fails, or the CID response is invalid.
33
+ */
34
+ export declare function create(context: GeoClientContext, params: CreateImageParams): Promise<CreateImageResult>;
35
+ //# sourceMappingURL=images.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../../src/client/images.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,KAAK,kBAAkB,EAAmB,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAmB,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,8BAgBhF"}
@@ -0,0 +1,90 @@
1
+ import { createRelation as grcCreateRelation } from '@geoprotocol/grc-20';
2
+ import { IMAGE_HEIGHT_PROPERTY, IMAGE_TYPE, IMAGE_URL_PROPERTY, IMAGE_WIDTH_PROPERTY, TYPES_PROPERTY, } from '../core/ids/system.js';
3
+ import { Id } from '../id.js';
4
+ import { assertValid, generate, toGrcId } from '../id-utils.js';
5
+ import { uploadImageCore } from '../ipfs-core.js';
6
+ import { create as createEntity } from '../ops/entities.js';
7
+ import { requireFetch } from './context.js';
8
+ /**
9
+ * Uploads an image and builds the corresponding image entity ops.
10
+ *
11
+ * This is the context-aware image workflow used by `geo.images.create(...)`.
12
+ * It uploads the image through the configured API origin, attempts to read
13
+ * image dimensions, then creates image entity ops.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const { id, cid, dimensions, ops } = await geo.images.create({
18
+ * url: 'https://example.com/cover.png',
19
+ * name: 'Cover image',
20
+ * description: 'Image used as the space cover.',
21
+ * });
22
+ *
23
+ * console.log(id, cid, dimensions);
24
+ * ```
25
+ *
26
+ * @param context Client context containing network and fetch configuration.
27
+ * @param params Image source plus optional entity metadata.
28
+ * @returns Created image entity ID, uploaded CID, dimensions when detected, and ops.
29
+ * @throws When the optional ID is invalid, fetch is unavailable, upload fails, or the CID response is invalid.
30
+ */
31
+ export async function create(context, params) {
32
+ if (params.id)
33
+ assertValid(params.id, '`id` in `createImage`');
34
+ const { cid, dimensions } = await uploadImageCore({
35
+ ...params,
36
+ apiOrigin: context.network.apiOrigin,
37
+ fetch: requireFetch(context, 'Image creation'),
38
+ });
39
+ return createImageOps({
40
+ id: params.id,
41
+ name: params.name,
42
+ description: params.description,
43
+ cid,
44
+ dimensions,
45
+ });
46
+ }
47
+ function createImageOps({ cid, dimensions, name, description, id: providedId, }) {
48
+ const id = providedId ?? generate();
49
+ const values = [
50
+ {
51
+ property: IMAGE_URL_PROPERTY,
52
+ type: 'text',
53
+ value: cid,
54
+ },
55
+ ];
56
+ if (dimensions?.height) {
57
+ values.push({
58
+ property: IMAGE_HEIGHT_PROPERTY,
59
+ type: 'float',
60
+ value: dimensions.height,
61
+ });
62
+ }
63
+ if (dimensions?.width) {
64
+ values.push({
65
+ property: IMAGE_WIDTH_PROPERTY,
66
+ type: 'float',
67
+ value: dimensions.width,
68
+ });
69
+ }
70
+ const result = createEntity({
71
+ id,
72
+ name,
73
+ description,
74
+ values,
75
+ });
76
+ result.ops.push(grcCreateRelation({
77
+ id: toGrcId(generate()),
78
+ entity: toGrcId(generate()),
79
+ from: toGrcId(id),
80
+ to: toGrcId(IMAGE_TYPE),
81
+ relationType: toGrcId(TYPES_PROPERTY),
82
+ }));
83
+ return {
84
+ id: Id(id),
85
+ cid,
86
+ dimensions,
87
+ ops: result.ops,
88
+ };
89
+ }
90
+ //# sourceMappingURL=images.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"images.js","sourceRoot":"","sources":["../../../src/client/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAA2B,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAS5C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAyB,EAAE,MAAyB;IAC/E,IAAI,MAAM,CAAC,EAAE;QAAE,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,uBAAuB,CAAC,CAAC;IAE/D,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,MAAM,eAAe,CAAC;QAChD,GAAG,MAAM;QACT,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS;QACpC,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC;KAC/C,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;QACpB,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC,IAAI;QACj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AM,CAAC,GAAG;KAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,155 @@
1
+ import type { Op } from '@geoprotocol/grc-20';
2
+ import { type Address, type Hex } from 'viem';
3
+ import type { Id } from '../id.js';
4
+ import type { PublishEditParams } from '../ipfs-core.js';
5
+ import type { GeoClientContext } from './context.js';
6
+ export type CreatePersonalSpaceParams = {
7
+ name: string;
8
+ accountAddress: Address;
9
+ };
10
+ export type CreatePersonalSpaceResult = {
11
+ to: `0x${string}`;
12
+ calldata: `0x${string}`;
13
+ spaceEntityId: Id;
14
+ accountId: string;
15
+ ops: Op[];
16
+ };
17
+ export type SetPersonalSpaceTopicParams = {
18
+ spaceId: Id | string;
19
+ topicId: Id | string;
20
+ authorSpaceId?: Id | string;
21
+ };
22
+ export type HasSpaceParams = {
23
+ address: Hex;
24
+ rpcUrl?: string;
25
+ };
26
+ export type PublishPersonalSpaceEditParams = PublishEditParams & {
27
+ spaceId: Id | string;
28
+ };
29
+ /**
30
+ * Builds the personal-space creation transaction and initial space content ops.
31
+ *
32
+ * The returned calldata registers the caller's address as a personal space.
33
+ * The returned ops create the space entity, the account entity, and the
34
+ * personal-space type relations that should be published after the space ID is
35
+ * available onchain.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const tx = geo.personalSpaces.create({
40
+ * name: 'Alice',
41
+ * accountAddress: account.address,
42
+ * });
43
+ *
44
+ * await walletClient.sendTransaction({
45
+ * to: tx.to,
46
+ * data: tx.calldata,
47
+ * });
48
+ *
49
+ * // Once the transaction is mined and the space ID is known:
50
+ * await geo.personalSpaces.publishEdit({
51
+ * name: 'Create personal space profile',
52
+ * spaceId,
53
+ * author: spaceId,
54
+ * ops: tx.ops,
55
+ * });
56
+ * ```
57
+ *
58
+ * @param context Client context containing the target network configuration.
59
+ * @param params Space display name and account address to describe in initial ops.
60
+ * @returns Target registry address, calldata, generated entity IDs, and initial content ops.
61
+ * @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
62
+ */
63
+ export declare function create(context: GeoClientContext, { name, accountAddress }: CreatePersonalSpaceParams): CreatePersonalSpaceResult;
64
+ /**
65
+ * Builds calldata for setting a personal space topic.
66
+ *
67
+ * Call this right after creating the personal space and publishing its initial
68
+ * profile ops. For personal spaces, `authorSpaceId` defaults to `spaceId`.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const topicTx = geo.personalSpaces.setTopic({
73
+ * spaceId,
74
+ * topicId: createSpace.spaceEntityId,
75
+ * });
76
+ *
77
+ * await walletClient.sendTransaction({
78
+ * to: topicTx.to,
79
+ * data: topicTx.calldata,
80
+ * });
81
+ * ```
82
+ *
83
+ * @param context Client context containing the target network configuration.
84
+ * @param params Space ID, topic entity ID, and optional author space ID.
85
+ * @returns Target registry address and calldata.
86
+ * @throws When an ID is invalid or the configured network is missing `SPACE_REGISTRY_ADDRESS`.
87
+ */
88
+ export declare function setTopic(context: GeoClientContext, { spaceId, topicId, authorSpaceId }: SetPersonalSpaceTopicParams): {
89
+ to: `0x${string}`;
90
+ calldata: `0x${string}`;
91
+ };
92
+ /**
93
+ * Checks whether an address already has a personal space on the configured network.
94
+ *
95
+ * The helper reads `addressToSpaceId(address)` from the configured
96
+ * `SPACE_REGISTRY_ADDRESS`. Pass `rpcUrl` to override the network's configured
97
+ * RPC URL for this lookup.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const hasExistingSpace = await geo.personalSpaces.hasSpace({
102
+ * address: account.address,
103
+ * });
104
+ *
105
+ * if (!hasExistingSpace) {
106
+ * const tx = geo.personalSpaces.create({
107
+ * name: 'Alice',
108
+ * accountAddress: account.address,
109
+ * });
110
+ * await walletClient.sendTransaction({ to: tx.to, data: tx.calldata });
111
+ * }
112
+ * ```
113
+ *
114
+ * @param context Client context containing network and contract configuration.
115
+ * @param params Wallet or smart-account address plus optional RPC URL override.
116
+ * @returns `true` when the registry maps the address to a non-empty space ID.
117
+ * @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS` or no RPC URL is available.
118
+ */
119
+ export declare function hasSpace(context: GeoClientContext, { address, rpcUrl }: HasSpaceParams): Promise<boolean>;
120
+ /**
121
+ * Publishes an edit and returns calldata for submitting it to a personal space.
122
+ *
123
+ * This is the context-explicit implementation behind
124
+ * `geo.personalSpaces.publishEdit(...)`.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * import * as Ops from '@geoprotocol/geo-sdk/ops';
129
+ *
130
+ * const { ops } = Ops.entities.create({ name: 'Geo entity' });
131
+ * const tx = await geo.personalSpaces.publishEdit({
132
+ * name: 'Create Geo entity',
133
+ * spaceId,
134
+ * author: spaceId,
135
+ * ops,
136
+ * });
137
+ *
138
+ * await walletClient.sendTransaction({
139
+ * to: tx.to,
140
+ * data: tx.calldata,
141
+ * });
142
+ * ```
143
+ *
144
+ * @param context Client context containing network, contract, API, and fetch configuration.
145
+ * @param params Edit publication params plus the target personal space ID.
146
+ * @returns Edit ID, CID, target registry address, and calldata.
147
+ * @throws When the configured network is missing required contracts or edit publishing fails.
148
+ */
149
+ export declare function publishEdit(context: GeoClientContext, params: PublishPersonalSpaceEditParams): Promise<{
150
+ editId: Id;
151
+ cid: `ipfs://${string}`;
152
+ to: `0x${string}`;
153
+ calldata: `0x${string}`;
154
+ }>;
155
+ //# sourceMappingURL=personal-spaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"personal-spaces.d.ts","sourceRoot":"","sources":["../../../src/client/personal-spaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,OAAO,EAA0C,KAAK,GAAG,EAAQ,MAAM,MAAM,CAAC;AAQ5F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAGnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,MAAM,yBAAyB,GAAG;IACt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ACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,8BAA8B;;;;;GAGlG"}
@@ -0,0 +1,198 @@
1
+ import { createPublicClient, encodeFunctionData, http } from 'viem';
2
+ import { EMPTY_SPACE_ID } from '../../contracts.js';
3
+ import { SpaceRegistryAbi } from '../abis/index.js';
4
+ import * as Account from '../core/account.js';
5
+ import { PERSON_TYPE, SPACE_TYPE, TYPES_PROPERTY } from '../core/ids/system.js';
6
+ import { getCreatePersonalSpaceCalldata } from '../encodings/get-create-personal-space-calldata.js';
7
+ import { createEntity } from '../graph/create-entity.js';
8
+ import { createRelation } from '../graph/create-relation.js';
9
+ import * as IdUtils from '../id-utils.js';
10
+ import { assertValid } from '../id-utils.js';
11
+ import { requireGeoContract } from '../networks.js';
12
+ import { EMPTY_SIGNATURE, TOPIC_DECLARED } from '../personal-space/constants.js';
13
+ function idToBytes16(id, sourceHint) {
14
+ const normalized = id.startsWith('0x') ? id.slice(2) : id.replaceAll('-', '');
15
+ assertValid(normalized, sourceHint);
16
+ return `0x${normalized.toLowerCase()}`;
17
+ }
18
+ function bytes16ToBytes32LeftAligned(bytes16Hex) {
19
+ return `0x${bytes16Hex.slice(2)}${'0'.repeat(32)}`;
20
+ }
21
+ /**
22
+ * Builds the personal-space creation transaction and initial space content ops.
23
+ *
24
+ * The returned calldata registers the caller's address as a personal space.
25
+ * The returned ops create the space entity, the account entity, and the
26
+ * personal-space type relations that should be published after the space ID is
27
+ * available onchain.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const tx = geo.personalSpaces.create({
32
+ * name: 'Alice',
33
+ * accountAddress: account.address,
34
+ * });
35
+ *
36
+ * await walletClient.sendTransaction({
37
+ * to: tx.to,
38
+ * data: tx.calldata,
39
+ * });
40
+ *
41
+ * // Once the transaction is mined and the space ID is known:
42
+ * await geo.personalSpaces.publishEdit({
43
+ * name: 'Create personal space profile',
44
+ * spaceId,
45
+ * author: spaceId,
46
+ * ops: tx.ops,
47
+ * });
48
+ * ```
49
+ *
50
+ * @param context Client context containing the target network configuration.
51
+ * @param params Space display name and account address to describe in initial ops.
52
+ * @returns Target registry address, calldata, generated entity IDs, and initial content ops.
53
+ * @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS`.
54
+ */
55
+ export function create(context, { name, accountAddress }) {
56
+ const spaceEntityId = IdUtils.generate();
57
+ const ops = [];
58
+ const { accountId, ops: accountOps } = Account.make(accountAddress);
59
+ ops.push(...accountOps);
60
+ const { ops: createSpaceEntityOps } = createEntity({
61
+ id: spaceEntityId,
62
+ name,
63
+ types: [SPACE_TYPE],
64
+ });
65
+ ops.push(...createSpaceEntityOps);
66
+ const { ops: personRelationOps } = createRelation({
67
+ fromEntity: spaceEntityId,
68
+ type: TYPES_PROPERTY,
69
+ toEntity: PERSON_TYPE,
70
+ });
71
+ ops.push(...personRelationOps);
72
+ return {
73
+ to: requireGeoContract(context.network, 'SPACE_REGISTRY_ADDRESS'),
74
+ calldata: getCreatePersonalSpaceCalldata(),
75
+ spaceEntityId,
76
+ accountId,
77
+ ops,
78
+ };
79
+ }
80
+ /**
81
+ * Builds calldata for setting a personal space topic.
82
+ *
83
+ * Call this right after creating the personal space and publishing its initial
84
+ * profile ops. For personal spaces, `authorSpaceId` defaults to `spaceId`.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * const topicTx = geo.personalSpaces.setTopic({
89
+ * spaceId,
90
+ * topicId: createSpace.spaceEntityId,
91
+ * });
92
+ *
93
+ * await walletClient.sendTransaction({
94
+ * to: topicTx.to,
95
+ * data: topicTx.calldata,
96
+ * });
97
+ * ```
98
+ *
99
+ * @param context Client context containing the target network configuration.
100
+ * @param params Space ID, topic entity ID, and optional author space ID.
101
+ * @returns Target registry address and calldata.
102
+ * @throws When an ID is invalid or the configured network is missing `SPACE_REGISTRY_ADDRESS`.
103
+ */
104
+ export function setTopic(context, { spaceId, topicId, authorSpaceId = spaceId }) {
105
+ const authorSpaceIdBytes = idToBytes16(authorSpaceId, '`authorSpaceId` in `setTopic`');
106
+ const spaceIdBytes = idToBytes16(spaceId, '`spaceId` in `setTopic`');
107
+ const topicIdBytes = idToBytes16(topicId, '`topicId` in `setTopic`');
108
+ return {
109
+ to: requireGeoContract(context.network, 'SPACE_REGISTRY_ADDRESS'),
110
+ calldata: encodeFunctionData({
111
+ abi: SpaceRegistryAbi,
112
+ functionName: 'enter',
113
+ args: [
114
+ authorSpaceIdBytes,
115
+ spaceIdBytes,
116
+ TOPIC_DECLARED,
117
+ bytes16ToBytes32LeftAligned(topicIdBytes),
118
+ '0x',
119
+ EMPTY_SIGNATURE,
120
+ ],
121
+ }),
122
+ };
123
+ }
124
+ /**
125
+ * Checks whether an address already has a personal space on the configured network.
126
+ *
127
+ * The helper reads `addressToSpaceId(address)` from the configured
128
+ * `SPACE_REGISTRY_ADDRESS`. Pass `rpcUrl` to override the network's configured
129
+ * RPC URL for this lookup.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const hasExistingSpace = await geo.personalSpaces.hasSpace({
134
+ * address: account.address,
135
+ * });
136
+ *
137
+ * if (!hasExistingSpace) {
138
+ * const tx = geo.personalSpaces.create({
139
+ * name: 'Alice',
140
+ * accountAddress: account.address,
141
+ * });
142
+ * await walletClient.sendTransaction({ to: tx.to, data: tx.calldata });
143
+ * }
144
+ * ```
145
+ *
146
+ * @param context Client context containing network and contract configuration.
147
+ * @param params Wallet or smart-account address plus optional RPC URL override.
148
+ * @returns `true` when the registry maps the address to a non-empty space ID.
149
+ * @throws When the configured network is missing `SPACE_REGISTRY_ADDRESS` or no RPC URL is available.
150
+ */
151
+ export async function hasSpace(context, { address, rpcUrl }) {
152
+ const resolvedRpcUrl = rpcUrl ?? context.network.chain?.rpcUrl;
153
+ if (!resolvedRpcUrl) {
154
+ throw new Error(`Geo network "${context.network.name}" is missing an RPC URL`);
155
+ }
156
+ const publicClient = createPublicClient({ transport: http(resolvedRpcUrl) });
157
+ const spaceIdHex = (await publicClient.readContract({
158
+ address: requireGeoContract(context.network, 'SPACE_REGISTRY_ADDRESS'),
159
+ abi: SpaceRegistryAbi,
160
+ functionName: 'addressToSpaceId',
161
+ args: [address],
162
+ }));
163
+ return spaceIdHex.toLowerCase() !== EMPTY_SPACE_ID.toLowerCase();
164
+ }
165
+ /**
166
+ * Publishes an edit and returns calldata for submitting it to a personal space.
167
+ *
168
+ * This is the context-explicit implementation behind
169
+ * `geo.personalSpaces.publishEdit(...)`.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * import * as Ops from '@geoprotocol/geo-sdk/ops';
174
+ *
175
+ * const { ops } = Ops.entities.create({ name: 'Geo entity' });
176
+ * const tx = await geo.personalSpaces.publishEdit({
177
+ * name: 'Create Geo entity',
178
+ * spaceId,
179
+ * author: spaceId,
180
+ * ops,
181
+ * });
182
+ *
183
+ * await walletClient.sendTransaction({
184
+ * to: tx.to,
185
+ * data: tx.calldata,
186
+ * });
187
+ * ```
188
+ *
189
+ * @param context Client context containing network, contract, API, and fetch configuration.
190
+ * @param params Edit publication params plus the target personal space ID.
191
+ * @returns Edit ID, CID, target registry address, and calldata.
192
+ * @throws When the configured network is missing required contracts or edit publishing fails.
193
+ */
194
+ export async function publishEdit(context, params) {
195
+ const { publishToSpace } = await import('./edits.js');
196
+ return publishToSpace(context, params);
197
+ }
198
+ //# sourceMappingURL=personal-spaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"personal-spaces.js","sourceRoot":"","sources":["../../../src/client/personal-spaces.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,kBAAkB,EAAE,kBAAkB,EAAY,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChF,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