@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,860 @@
1
+ import { createPublicClient, createWalletClient, http } from 'viem';
2
+ import { privateKeyToAccount } from 'viem/accounts';
3
+ import { describe, expect, it } from 'vitest';
4
+ import { daoSpace, Graph, Ipfs, personalSpace } from '../index.js';
5
+ import { SpaceRegistryAbi } from './abis/index.js';
6
+ import { DESCRIPTION_PROPERTY, RELATION_TYPE, REPLY_TO_PROPERTY } from './core/ids/system.js';
7
+ import { createE2ETestEnvironment } from './e2e-test-environment.js';
8
+ import { deriveCommentName } from './graph/comment-utils.js';
9
+ import { toGrcId } from './id-utils.js';
10
+ const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
11
+ const EMPTY_SPACE_ID = '0x00000000000000000000000000000000';
12
+ const INDEXER_TIMEOUT_MS = 120_000;
13
+ const TEST_TIMEOUT_MS = 600_000;
14
+ const replyToGrcId = toGrcId(REPLY_TO_PROPERTY);
15
+ let cachedE2E;
16
+ function getE2E() {
17
+ cachedE2E ??= createE2ETestEnvironment();
18
+ return cachedE2E;
19
+ }
20
+ const e2e = new Proxy({}, {
21
+ get(_target, property) {
22
+ return getE2E()[property];
23
+ },
24
+ });
25
+ function getLegacyNetwork() {
26
+ return getE2E().networkish;
27
+ }
28
+ class GraphQlRequestError extends Error {
29
+ errors;
30
+ constructor(errors) {
31
+ super(`GraphQL errors: ${JSON.stringify(errors)}`);
32
+ this.errors = errors;
33
+ }
34
+ hasValidationError() {
35
+ return JSON.stringify(this.errors).includes('GRAPHQL_VALIDATION_FAILED');
36
+ }
37
+ }
38
+ function sleep(ms) {
39
+ return new Promise(resolve => setTimeout(resolve, ms));
40
+ }
41
+ function filterReplyToRelations(ops) {
42
+ return ops.filter((op) => op.type === 'createRelation' &&
43
+ 'relationType' in op &&
44
+ op.relationType.every((b, i) => b === replyToGrcId[i]));
45
+ }
46
+ function hexToUuid(hex) {
47
+ return hex.slice(2, 34).toLowerCase();
48
+ }
49
+ function uniqueName(prefix) {
50
+ return `${prefix} ${Date.now().toString(36)}`;
51
+ }
52
+ function tinyPngBlob() {
53
+ return new Blob([
54
+ new Uint8Array([
55
+ 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0, 0, 0, 31, 21,
56
+ 196, 137, 0, 0, 0, 13, 73, 68, 65, 84, 120, 156, 99, 248, 255, 255, 63, 0, 5, 254, 2, 254, 167, 53, 129, 132, 0,
57
+ 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130,
58
+ ]),
59
+ ], { type: 'image/png' });
60
+ }
61
+ function entityQuery(id, spaceId) {
62
+ const normalizedSpaceId = spaceId.replaceAll('-', '');
63
+ return `query entity {
64
+ entity(id: ${JSON.stringify(id)}) {
65
+ id
66
+ name
67
+ valuesList(filter: { spaceId: { in: [${JSON.stringify(normalizedSpaceId)}] } }) {
68
+ propertyId
69
+ spaceId
70
+ }
71
+ relationsList(filter: { spaceId: { in: [${JSON.stringify(normalizedSpaceId)}] } }) {
72
+ id
73
+ spaceId
74
+ }
75
+ }
76
+ }`;
77
+ }
78
+ function replyToRelationsQuery(id) {
79
+ return `query entity {
80
+ entity(id: ${JSON.stringify(id)}) {
81
+ relationsList(filter: { typeId: { in: [${JSON.stringify(REPLY_TO_PROPERTY)}] } }) {
82
+ toEntity { id }
83
+ toSpace { id }
84
+ position
85
+ }
86
+ }
87
+ }`;
88
+ }
89
+ function proposalUuid(proposalId) {
90
+ return proposalId.replace(/^0x/, '').toLowerCase();
91
+ }
92
+ function proposalQuery(proposalId) {
93
+ const id = proposalUuid(proposalId);
94
+ return `query proposal {
95
+ proposals(condition: { id: ${JSON.stringify(id)} }) {
96
+ id
97
+ spaceId
98
+ proposedBy
99
+ currentVersion
100
+ proposalVersions {
101
+ proposalVersion
102
+ votingMode
103
+ name
104
+ }
105
+ }
106
+ proposalActions(condition: { proposalId: ${JSON.stringify(id)} }) {
107
+ proposalId
108
+ proposalVersion
109
+ actionType
110
+ targetId
111
+ contentUri
112
+ }
113
+ }`;
114
+ }
115
+ function proposalVoteQuery(proposalId, voterId, spaceId) {
116
+ return `query proposalVote {
117
+ proposalVotes(condition: {
118
+ proposalId: ${JSON.stringify(proposalUuid(proposalId))}
119
+ voterId: ${JSON.stringify(voterId.replaceAll('-', ''))}
120
+ spaceId: ${JSON.stringify(spaceId.replaceAll('-', ''))}
121
+ }) {
122
+ proposalId
123
+ voterId
124
+ spaceId
125
+ vote
126
+ }
127
+ }`;
128
+ }
129
+ function entityVoteQuery(entityId, voterId, spaceId) {
130
+ return `query entityVote {
131
+ votes(condition: {
132
+ voterId: ${JSON.stringify(voterId.replaceAll('-', ''))}
133
+ objectId: ${JSON.stringify(entityId.replaceAll('-', ''))}
134
+ objectType: 0
135
+ spaceId: ${JSON.stringify(spaceId.replaceAll('-', ''))}
136
+ }) {
137
+ voterId
138
+ objectId
139
+ objectType
140
+ spaceId
141
+ vote
142
+ }
143
+ }`;
144
+ }
145
+ async function queryGraph(query) {
146
+ const response = await fetch(`${e2e.apiOrigin}/graphql`, {
147
+ method: 'POST',
148
+ headers: { 'Content-Type': 'application/json' },
149
+ body: JSON.stringify({ query }),
150
+ });
151
+ if (!response.ok) {
152
+ throw new Error(`GraphQL request failed: ${response.status} ${await response.text()}`);
153
+ }
154
+ const envelope = (await response.json());
155
+ if (envelope.errors) {
156
+ throw new GraphQlRequestError(envelope.errors);
157
+ }
158
+ if (envelope.data === undefined) {
159
+ throw new Error('GraphQL response did not include data');
160
+ }
161
+ return envelope.data;
162
+ }
163
+ async function waitFor(label, read, predicate) {
164
+ const deadline = Date.now() + INDEXER_TIMEOUT_MS;
165
+ let lastValue;
166
+ let lastError;
167
+ while (Date.now() < deadline) {
168
+ try {
169
+ lastValue = await read();
170
+ lastError = undefined;
171
+ if (predicate(lastValue)) {
172
+ return lastValue;
173
+ }
174
+ }
175
+ catch (error) {
176
+ if (error instanceof GraphQlRequestError && error.hasValidationError()) {
177
+ throw error;
178
+ }
179
+ lastError = error;
180
+ }
181
+ await sleep(3_000);
182
+ }
183
+ throw new Error(`Timed out waiting for ${label}. Last value: ${JSON.stringify(lastValue)}. Last error: ${String(lastError)}`);
184
+ }
185
+ async function waitForEntityName(entityId, spaceId, expectedName) {
186
+ const data = await waitFor(`entity ${entityId} name "${expectedName}"`, () => queryGraph(entityQuery(entityId, spaceId)), value => value.entity?.name === expectedName);
187
+ expect(data.entity?.name).toBe(expectedName);
188
+ return data.entity;
189
+ }
190
+ async function waitForEntityDeleted(entityId, spaceId) {
191
+ await waitFor(`entity ${entityId} deletion in space ${spaceId}`, () => queryGraph(entityQuery(entityId, spaceId)), value => !value.entity || (value.entity.valuesList.length === 0 && value.entity.relationsList.length === 0));
192
+ }
193
+ async function waitForReplyToRelations(entityId, expectedTargets) {
194
+ const data = await waitFor(`reply-to relations for ${entityId}`, () => queryGraph(replyToRelationsQuery(entityId)), value => {
195
+ const targets = value.entity?.relationsList.map(relation => relation.toEntity.id) ?? [];
196
+ return expectedTargets.every(target => targets.includes(target));
197
+ });
198
+ const targets = data.entity?.relationsList.map(relation => relation.toEntity.id) ?? [];
199
+ expect(targets).toEqual(expect.arrayContaining(expectedTargets));
200
+ return data.entity?.relationsList ?? [];
201
+ }
202
+ async function waitForProposal(proposalId, expected) {
203
+ const data = await waitFor(`proposal ${proposalUuid(proposalId)}`, () => queryGraph(proposalQuery(proposalId)), value => {
204
+ const proposal = value.proposals[0];
205
+ if (!proposal)
206
+ return false;
207
+ if (proposal.spaceId !== expected.daoSpaceId.replaceAll('-', ''))
208
+ return false;
209
+ if (proposal.proposedBy !== expected.proposedBy.replaceAll('-', ''))
210
+ return false;
211
+ const currentVersion = proposal.proposalVersions.find(version => version.proposalVersion === proposal.currentVersion);
212
+ if (expected.votingMode && currentVersion?.votingMode !== expected.votingMode)
213
+ return false;
214
+ if (!expected.actionType)
215
+ return true;
216
+ const expectedActionTypes = Array.isArray(expected.actionType) ? expected.actionType : [expected.actionType];
217
+ return value.proposalActions.some(action => expectedActionTypes.includes(action.actionType) &&
218
+ (expected.targetId === undefined ||
219
+ action.targetId === expected.targetId.replace(/^0x/, '').replaceAll('-', '')) &&
220
+ (expected.contentUri === undefined || action.contentUri === expected.contentUri));
221
+ });
222
+ expect(data.proposals[0]?.id).toBe(proposalUuid(proposalId));
223
+ if (expected.actionType) {
224
+ const expectedActionTypes = Array.isArray(expected.actionType) ? expected.actionType : [expected.actionType];
225
+ expect(data.proposalActions.some(action => expectedActionTypes.includes(action.actionType))).toBe(true);
226
+ }
227
+ }
228
+ async function waitForProposalVote(proposalId, voterId, daoSpaceId, vote) {
229
+ const data = await waitFor(`proposal ${proposalUuid(proposalId)} vote ${vote}`, () => queryGraph(proposalVoteQuery(proposalId, voterId, daoSpaceId)), value => value.proposalVotes.some(proposalVote => proposalVote.vote === vote));
230
+ expect(data.proposalVotes.map(proposalVote => proposalVote.vote)).toContain(vote);
231
+ }
232
+ async function waitForEntityVote(entityId, voterId, spaceId, predicate) {
233
+ const data = await waitFor(`entity vote for ${entityId}`, () => queryGraph(entityVoteQuery(entityId, voterId, spaceId)), value => predicate(value.votes));
234
+ expect(predicate(data.votes)).toBe(true);
235
+ }
236
+ async function getSpaceIdHex(publicClient, address) {
237
+ return (await publicClient.readContract({
238
+ address: e2e.contracts.SPACE_REGISTRY_ADDRESS,
239
+ abi: SpaceRegistryAbi,
240
+ functionName: 'addressToSpaceId',
241
+ args: [address],
242
+ }));
243
+ }
244
+ async function ensurePersonalSpace({ account, publicClient, walletClient }) {
245
+ let spaceIdHex = await getSpaceIdHex(publicClient, account.address);
246
+ const hasExistingSpace = await personalSpace.hasSpace({
247
+ address: account.address,
248
+ network: e2e.networkish,
249
+ });
250
+ expect(hasExistingSpace).toBe(spaceIdHex.toLowerCase() !== EMPTY_SPACE_ID.toLowerCase());
251
+ if (spaceIdHex.toLowerCase() === EMPTY_SPACE_ID.toLowerCase()) {
252
+ const createSpace = personalSpace.createSpace({ network: e2e.networkish });
253
+ await sendTransactionAndWait({ account, publicClient, walletClient }, {
254
+ label: 'legacy create personal space',
255
+ to: createSpace.to,
256
+ calldata: createSpace.calldata,
257
+ });
258
+ spaceIdHex = await getSpaceIdHex(publicClient, account.address);
259
+ }
260
+ if (spaceIdHex.toLowerCase() === EMPTY_SPACE_ID.toLowerCase()) {
261
+ throw new Error(`Failed to create personal space for address ${account.address}`);
262
+ }
263
+ return {
264
+ spaceIdHex,
265
+ spaceId: hexToUuid(spaceIdHex),
266
+ };
267
+ }
268
+ async function setupWallet() {
269
+ const account = privateKeyToAccount(e2e.privateKey);
270
+ const walletClient = createWalletClient({
271
+ account,
272
+ chain: e2e.chain,
273
+ transport: http(e2e.rpcUrl),
274
+ });
275
+ expect(account.address).toBe(privateKeyToAccount(e2e.privateKey).address);
276
+ const publicClient = createPublicClient({
277
+ chain: e2e.chain,
278
+ transport: http(e2e.rpcUrl),
279
+ });
280
+ return { account, publicClient, walletClient };
281
+ }
282
+ async function sendTransactionAndWait({ account, publicClient, walletClient }, { label, to, calldata, value = 0n, }) {
283
+ const hash = await walletClient.sendTransaction({
284
+ account,
285
+ chain: walletClient.chain ?? null,
286
+ to,
287
+ value,
288
+ data: calldata,
289
+ });
290
+ const receipt = await publicClient.waitForTransactionReceipt({ hash });
291
+ expect(receipt.status, `${label} transaction ${hash}`).toBe('success');
292
+ return { hash, receipt };
293
+ }
294
+ let contextPromise;
295
+ let daoContextPromise;
296
+ async function getTestContext() {
297
+ contextPromise ??= (async () => {
298
+ const wallet = await setupWallet();
299
+ const { spaceId, spaceIdHex } = await ensurePersonalSpace(wallet);
300
+ return {
301
+ ...wallet,
302
+ spaceId,
303
+ spaceIdHex,
304
+ };
305
+ })();
306
+ return contextPromise;
307
+ }
308
+ async function publishOps(context, name, ops, spaceId = context.spaceId) {
309
+ const publish = await personalSpace.publishEdit({
310
+ name,
311
+ spaceId,
312
+ author: context.spaceId,
313
+ ops,
314
+ network: getLegacyNetwork(),
315
+ });
316
+ await sendTransactionAndWait(context, {
317
+ label: name,
318
+ to: publish.to,
319
+ calldata: publish.calldata,
320
+ });
321
+ return publish;
322
+ }
323
+ async function createIndexedEntity(context, name = uniqueName('E2E Legacy Entity')) {
324
+ const entity = Graph.createEntity({ name });
325
+ await publishOps(context, `Publish ${name}`, entity.ops);
326
+ await waitForEntityName(entity.id, context.spaceId, name);
327
+ return entity;
328
+ }
329
+ async function getDaoContext() {
330
+ daoContextPromise ??= (async () => {
331
+ const context = await getTestContext();
332
+ const daoName = uniqueName('E2E Legacy DAO Space');
333
+ const createdDaoSpace = await daoSpace.createSpace({
334
+ name: daoName,
335
+ votingSettings: {
336
+ partialPercentageSupportThreshold: 50,
337
+ universalPercentageSupportThreshold: 90,
338
+ flatSupportThreshold: 1,
339
+ quorum: 1,
340
+ durationInDays: 2,
341
+ disableFastPathAccessForNewMembers: true,
342
+ executionGracePeriodInDays: 14,
343
+ },
344
+ initialEditorSpaceIds: [context.spaceIdHex],
345
+ author: context.spaceId,
346
+ network: getLegacyNetwork(),
347
+ });
348
+ const daoCreateTx = await sendTransactionAndWait(context, {
349
+ label: 'create legacy API DAO space',
350
+ to: createdDaoSpace.to,
351
+ calldata: createdDaoSpace.calldata,
352
+ });
353
+ const daoSpaceAddress = daoCreateTx.receipt.logs.find(log => log.address.toLowerCase() !== createdDaoSpace.to.toLowerCase())?.address;
354
+ if (!daoSpaceAddress) {
355
+ throw new Error('Could not find DAO space address in creation logs');
356
+ }
357
+ const daoSpaceIdHex = await getSpaceIdHex(context.publicClient, daoSpaceAddress);
358
+ expect(daoSpaceIdHex.toLowerCase()).not.toBe(EMPTY_SPACE_ID.toLowerCase());
359
+ const daoSpaceId = hexToUuid(daoSpaceIdHex);
360
+ await waitForEntityName(createdDaoSpace.spaceEntityId, daoSpaceId, daoName);
361
+ return {
362
+ ...context,
363
+ daoSpaceAddress,
364
+ daoSpaceId,
365
+ daoSpaceIdHex,
366
+ };
367
+ })();
368
+ return daoContextPromise;
369
+ }
370
+ async function createLegacyAddMemberProposal(context, label) {
371
+ const proposal = daoSpace.proposeAddMember({
372
+ authorSpaceId: context.spaceIdHex,
373
+ spaceId: context.daoSpaceIdHex,
374
+ daoSpaceAddress: context.daoSpaceAddress,
375
+ newMemberSpaceId: context.spaceIdHex,
376
+ network: getLegacyNetwork(),
377
+ });
378
+ await sendTransactionAndWait(context, {
379
+ label,
380
+ to: proposal.to,
381
+ calldata: proposal.calldata,
382
+ });
383
+ await waitForProposal(proposal.proposalId, {
384
+ daoSpaceId: context.daoSpaceId,
385
+ proposedBy: context.spaceId,
386
+ votingMode: 'SLOW',
387
+ });
388
+ return proposal;
389
+ }
390
+ describe.sequential('legacy deprecated API e2e surface', () => {
391
+ it('personalSpace.hasSpace validates the account space onchain', async () => {
392
+ const context = await getTestContext();
393
+ const hasSpace = await personalSpace.hasSpace({
394
+ address: context.account.address,
395
+ network: e2e.networkish,
396
+ });
397
+ expect(hasSpace).toBe(true);
398
+ const spaceAddress = (await context.publicClient.readContract({
399
+ address: e2e.contracts.SPACE_REGISTRY_ADDRESS,
400
+ abi: SpaceRegistryAbi,
401
+ functionName: 'spaceIdToAddress',
402
+ args: [context.spaceIdHex],
403
+ }));
404
+ expect(spaceAddress.toLowerCase()).not.toBe(ZERO_ADDRESS.toLowerCase());
405
+ }, TEST_TIMEOUT_MS);
406
+ it('Ipfs.uploadCSV uploads CSV data', async () => {
407
+ const csvCid = await Ipfs.uploadCSV(`name,run\nLegacy API surface,${Date.now().toString(36)}`, getLegacyNetwork());
408
+ expect(csvCid).toMatch(/^ipfs:\/\//);
409
+ }, TEST_TIMEOUT_MS);
410
+ it('Ipfs.uploadImage uploads an image and returns dimensions', async () => {
411
+ const uploadedImage = await Ipfs.uploadImage({ blob: tinyPngBlob() }, getLegacyNetwork(), true);
412
+ expect(uploadedImage.cid).toMatch(/^ipfs:\/\//);
413
+ expect(uploadedImage.dimensions).toEqual({ width: 1, height: 1 });
414
+ }, TEST_TIMEOUT_MS);
415
+ it('Graph.createImage builds publishable image ops', async () => {
416
+ const context = await getTestContext();
417
+ const imageName = uniqueName('E2E Legacy Image');
418
+ const image = await Graph.createImage({
419
+ blob: tinyPngBlob(),
420
+ name: imageName,
421
+ description: 'Created by the legacy API e2e surface test',
422
+ network: getLegacyNetwork(),
423
+ });
424
+ expect(image.cid).toMatch(/^ipfs:\/\//);
425
+ await publishOps(context, 'E2E legacy API image', image.ops);
426
+ await waitForEntityName(image.id, context.spaceId, imageName);
427
+ }, TEST_TIMEOUT_MS);
428
+ it('Ipfs.publishEdit uploads an edit payload', async () => {
429
+ const context = await getTestContext();
430
+ const entity = Graph.createEntity({
431
+ name: uniqueName('E2E Legacy Upload Only Entity'),
432
+ });
433
+ const edit = await Ipfs.publishEdit({
434
+ name: 'E2E legacy upload-only edit',
435
+ ops: entity.ops,
436
+ author: context.spaceId,
437
+ network: getLegacyNetwork(),
438
+ });
439
+ expect(edit.cid).toMatch(/^ipfs:\/\//);
440
+ }, TEST_TIMEOUT_MS);
441
+ it('personalSpace.publishEdit publishes ops into an indexed personal space', async () => {
442
+ const context = await getTestContext();
443
+ const entityName = uniqueName('E2E Legacy Publish Edit Entity');
444
+ const entity = Graph.createEntity({ name: entityName });
445
+ await publishOps(context, 'E2E legacy personal publish', entity.ops);
446
+ await waitForEntityName(entity.id, context.spaceId, entityName);
447
+ }, TEST_TIMEOUT_MS);
448
+ it('Graph.createProperty creates an indexed property entity', async () => {
449
+ const context = await getTestContext();
450
+ const propertyName = uniqueName('E2E Legacy Property');
451
+ const property = Graph.createProperty({
452
+ name: propertyName,
453
+ dataType: 'TEXT',
454
+ });
455
+ await publishOps(context, 'E2E legacy property', property.ops);
456
+ await waitForEntityName(property.id, context.spaceId, propertyName);
457
+ }, TEST_TIMEOUT_MS);
458
+ it('Graph.createType creates an indexed type entity', async () => {
459
+ const context = await getTestContext();
460
+ const property = Graph.createProperty({
461
+ name: uniqueName('E2E Legacy Type Property'),
462
+ dataType: 'TEXT',
463
+ });
464
+ const typeName = uniqueName('E2E Legacy Type');
465
+ const type = Graph.createType({
466
+ name: typeName,
467
+ properties: [property.id],
468
+ });
469
+ await publishOps(context, 'E2E legacy type', [...property.ops, ...type.ops]);
470
+ await waitForEntityName(type.id, context.spaceId, typeName);
471
+ }, TEST_TIMEOUT_MS);
472
+ it('Graph.createEntity creates an indexed entity', async () => {
473
+ const context = await getTestContext();
474
+ const entityName = uniqueName('E2E Legacy Entity');
475
+ const entity = Graph.createEntity({
476
+ name: entityName,
477
+ description: 'Created through the legacy API e2e surface test',
478
+ });
479
+ await publishOps(context, 'E2E legacy entity', entity.ops);
480
+ await waitForEntityName(entity.id, context.spaceId, entityName);
481
+ }, TEST_TIMEOUT_MS);
482
+ it('Graph.updateEntity updates an indexed entity', async () => {
483
+ const context = await getTestContext();
484
+ const entity = await createIndexedEntity(context, uniqueName('E2E Legacy Entity To Update'));
485
+ const updatedName = `${entity.id} updated`;
486
+ const update = Graph.updateEntity({
487
+ id: entity.id,
488
+ name: updatedName,
489
+ unset: [{ property: DESCRIPTION_PROPERTY }],
490
+ });
491
+ await publishOps(context, 'E2E legacy entity update', update.ops);
492
+ await waitForEntityName(entity.id, context.spaceId, updatedName);
493
+ }, TEST_TIMEOUT_MS);
494
+ it('Graph.createRelation creates an indexed relation', async () => {
495
+ const context = await getTestContext();
496
+ const fromName = uniqueName('E2E Legacy Relation From');
497
+ const from = Graph.createEntity({ name: fromName });
498
+ const to = Graph.createEntity({
499
+ name: uniqueName('E2E Legacy Relation To'),
500
+ });
501
+ const relation = Graph.createRelation({
502
+ fromEntity: from.id,
503
+ toEntity: to.id,
504
+ type: RELATION_TYPE,
505
+ position: 'a0',
506
+ });
507
+ await publishOps(context, 'E2E legacy relation', [...from.ops, ...to.ops, ...relation.ops]);
508
+ const entity = await waitForEntityName(from.id, context.spaceId, fromName);
509
+ expect(entity?.relationsList.map(item => item.id)).toContain(relation.id);
510
+ }, TEST_TIMEOUT_MS);
511
+ it('Graph.updateRelation keeps an updated relation indexed', async () => {
512
+ const context = await getTestContext();
513
+ const fromName = uniqueName('E2E Legacy Relation Update From');
514
+ const from = Graph.createEntity({ name: fromName });
515
+ const to = Graph.createEntity({
516
+ name: uniqueName('E2E Legacy Relation Update To'),
517
+ });
518
+ const relation = Graph.createRelation({
519
+ fromEntity: from.id,
520
+ toEntity: to.id,
521
+ type: RELATION_TYPE,
522
+ position: 'a0',
523
+ });
524
+ const update = Graph.updateRelation({
525
+ id: relation.id,
526
+ position: 'a1',
527
+ });
528
+ await publishOps(context, 'E2E legacy relation update', [...from.ops, ...to.ops, ...relation.ops, ...update.ops]);
529
+ const entity = await waitForEntityName(from.id, context.spaceId, fromName);
530
+ expect(entity?.relationsList.map(item => item.id)).toContain(relation.id);
531
+ }, TEST_TIMEOUT_MS);
532
+ it('Graph.deleteRelation removes an indexed relation', async () => {
533
+ const context = await getTestContext();
534
+ const fromName = uniqueName('E2E Legacy Relation Delete From');
535
+ const from = Graph.createEntity({ name: fromName });
536
+ const to = Graph.createEntity({
537
+ name: uniqueName('E2E Legacy Relation Delete To'),
538
+ });
539
+ const relation = Graph.createRelation({
540
+ fromEntity: from.id,
541
+ toEntity: to.id,
542
+ type: RELATION_TYPE,
543
+ });
544
+ await publishOps(context, 'E2E legacy relation delete setup', [...from.ops, ...to.ops, ...relation.ops]);
545
+ await waitForEntityName(from.id, context.spaceId, fromName);
546
+ const deleteRelation = Graph.deleteRelation({ id: relation.id });
547
+ await publishOps(context, 'E2E legacy relation delete', deleteRelation.ops);
548
+ await waitFor(`relation ${relation.id} deletion`, () => queryGraph(entityQuery(from.id, context.spaceId)), value => !(value.entity?.relationsList ?? []).some(item => item.id === relation.id));
549
+ }, TEST_TIMEOUT_MS);
550
+ it('Graph.createProposalReview creates an indexed proposal review', async () => {
551
+ const context = await getTestContext();
552
+ const proposal = await createIndexedEntity(context, uniqueName('E2E Legacy Reviewed Proposal'));
553
+ const reviewName = uniqueName('E2E Legacy Proposal Review');
554
+ const review = Graph.createProposalReview({
555
+ proposal: { id: proposal.id, name: reviewName },
556
+ pass: true,
557
+ content: 'The proposal looks good.',
558
+ completeness: 1,
559
+ accuracy: 0.8,
560
+ skill: 0.8,
561
+ effort: 0.6,
562
+ });
563
+ await publishOps(context, 'E2E legacy proposal review', review.ops);
564
+ await waitForEntityName(review.id, context.spaceId, reviewName);
565
+ }, TEST_TIMEOUT_MS);
566
+ it('Graph.updateProposalReview updates an indexed proposal review', async () => {
567
+ const context = await getTestContext();
568
+ const proposal = await createIndexedEntity(context, uniqueName('E2E Legacy Reviewed Proposal Update'));
569
+ const reviewName = uniqueName('E2E Legacy Proposal Review Update');
570
+ const review = Graph.createProposalReview({
571
+ proposal: { id: proposal.id, name: reviewName },
572
+ pass: true,
573
+ content: 'The proposal looks good.',
574
+ });
575
+ await publishOps(context, 'E2E legacy proposal review setup', review.ops);
576
+ await waitForEntityName(review.id, context.spaceId, reviewName);
577
+ const update = Graph.updateProposalReview({
578
+ proposalReviewId: review.id,
579
+ pass: false,
580
+ content: 'Updated legacy review content.',
581
+ });
582
+ await publishOps(context, 'E2E legacy proposal review update', update.ops);
583
+ await waitForEntityName(review.id, context.spaceId, reviewName);
584
+ }, TEST_TIMEOUT_MS);
585
+ it('Graph.createComment creates indexed comments with reply-to chains', async () => {
586
+ const context = await getTestContext();
587
+ const entity = await createIndexedEntity(context, uniqueName('E2E Legacy Commented Entity'));
588
+ const commentAContent = 'Legacy API comment A on the entity';
589
+ const commentA = await Graph.createComment({
590
+ content: commentAContent,
591
+ replyTo: { entityId: entity.id, spaceId: context.spaceId },
592
+ network: getLegacyNetwork(),
593
+ });
594
+ expect(filterReplyToRelations(commentA.ops)).toHaveLength(1);
595
+ await publishOps(context, 'E2E legacy comment A', commentA.ops);
596
+ await waitForEntityName(commentA.id, context.spaceId, deriveCommentName(commentAContent));
597
+ await waitForReplyToRelations(commentA.id, [entity.id]);
598
+ const commentBContent = 'Legacy API comment B on comment A';
599
+ const commentB = await Graph.createComment({
600
+ content: commentBContent,
601
+ replyTo: { entityId: commentA.id, spaceId: context.spaceId },
602
+ network: getLegacyNetwork(),
603
+ });
604
+ expect(filterReplyToRelations(commentB.ops)).toHaveLength(2);
605
+ await publishOps(context, 'E2E legacy comment B', commentB.ops);
606
+ await waitForEntityName(commentB.id, context.spaceId, deriveCommentName(commentBContent));
607
+ await waitForReplyToRelations(commentB.id, [commentA.id, entity.id]);
608
+ }, TEST_TIMEOUT_MS);
609
+ it('Graph.updateComment updates an indexed comment', async () => {
610
+ const context = await getTestContext();
611
+ const entity = await createIndexedEntity(context, uniqueName('E2E Legacy Comment Update Entity'));
612
+ const comment = await Graph.createComment({
613
+ content: 'Legacy API comment before update',
614
+ replyTo: { entityId: entity.id, spaceId: context.spaceId },
615
+ network: getLegacyNetwork(),
616
+ });
617
+ await publishOps(context, 'E2E legacy comment update setup', comment.ops);
618
+ await waitForEntityName(comment.id, context.spaceId, deriveCommentName('Legacy API comment before update'));
619
+ const updatedContent = 'Legacy API comment after update';
620
+ const update = Graph.updateComment({
621
+ id: comment.id,
622
+ content: updatedContent,
623
+ resolved: true,
624
+ });
625
+ await publishOps(context, 'E2E legacy comment update', update.ops);
626
+ await waitForEntityName(comment.id, context.spaceId, deriveCommentName(updatedContent));
627
+ }, TEST_TIMEOUT_MS);
628
+ it('Graph.deleteEntity removes indexed entity values and relations', async () => {
629
+ const context = await getTestContext();
630
+ const related = await createIndexedEntity(context, uniqueName('E2E Legacy Delete Related Entity'));
631
+ const deleteContextName = uniqueName('E2E Legacy Entity To Delete');
632
+ const deleteContextEntity = Graph.createEntity({
633
+ name: deleteContextName,
634
+ });
635
+ const deleteContextRelation = Graph.createRelation({
636
+ fromEntity: deleteContextEntity.id,
637
+ toEntity: related.id,
638
+ type: RELATION_TYPE,
639
+ });
640
+ await publishOps(context, 'E2E legacy create entity for deletion', [
641
+ ...deleteContextEntity.ops,
642
+ ...deleteContextRelation.ops,
643
+ ]);
644
+ await waitForEntityName(deleteContextEntity.id, context.spaceId, deleteContextName);
645
+ const deleteResult = await Graph.deleteEntity({
646
+ id: deleteContextEntity.id,
647
+ spaceId: context.spaceId,
648
+ network: getLegacyNetwork(),
649
+ });
650
+ expect(deleteResult.ops.length).toBeGreaterThan(0);
651
+ await publishOps(context, 'E2E legacy delete entity', deleteResult.ops);
652
+ await waitForEntityDeleted(deleteContextEntity.id, context.spaceId);
653
+ }, TEST_TIMEOUT_MS);
654
+ it('Graph.upvoteEntity submits and indexes an upvote', async () => {
655
+ const context = await getTestContext();
656
+ const entity = await createIndexedEntity(context, uniqueName('E2E Legacy Upvoted Entity'));
657
+ const upvote = Graph.upvoteEntity({
658
+ authorSpaceId: context.spaceId,
659
+ spaceId: context.spaceId,
660
+ entityId: entity.id,
661
+ network: getLegacyNetwork(),
662
+ });
663
+ await sendTransactionAndWait(context, {
664
+ label: 'E2E legacy upvote entity',
665
+ to: upvote.to,
666
+ calldata: upvote.calldata,
667
+ });
668
+ await waitForEntityVote(entity.id, context.spaceId, context.spaceId, votes => votes.some(vote => vote.vote === 0));
669
+ }, TEST_TIMEOUT_MS);
670
+ it('Graph.downvoteEntity submits and indexes a downvote', async () => {
671
+ const context = await getTestContext();
672
+ const entity = await createIndexedEntity(context, uniqueName('E2E Legacy Downvoted Entity'));
673
+ const downvote = Graph.downvoteEntity({
674
+ authorSpaceId: context.spaceId,
675
+ spaceId: context.spaceId,
676
+ entityId: entity.id,
677
+ network: getLegacyNetwork(),
678
+ });
679
+ await sendTransactionAndWait(context, {
680
+ label: 'E2E legacy downvote entity',
681
+ to: downvote.to,
682
+ calldata: downvote.calldata,
683
+ });
684
+ await waitForEntityVote(entity.id, context.spaceId, context.spaceId, votes => votes.some(vote => vote.vote === 1));
685
+ }, TEST_TIMEOUT_MS);
686
+ it('Graph.withdrawEntityVote submits and indexes a vote withdrawal', async () => {
687
+ const context = await getTestContext();
688
+ const entity = await createIndexedEntity(context, uniqueName('E2E Legacy Vote Withdraw Entity'));
689
+ const upvote = Graph.upvoteEntity({
690
+ authorSpaceId: context.spaceId,
691
+ spaceId: context.spaceId,
692
+ entityId: entity.id,
693
+ network: getLegacyNetwork(),
694
+ });
695
+ await sendTransactionAndWait(context, {
696
+ label: 'E2E legacy upvote before withdraw',
697
+ to: upvote.to,
698
+ calldata: upvote.calldata,
699
+ });
700
+ await waitForEntityVote(entity.id, context.spaceId, context.spaceId, votes => votes.length > 0);
701
+ const withdraw = Graph.withdrawEntityVote({
702
+ authorSpaceId: context.spaceId,
703
+ spaceId: context.spaceId,
704
+ entityId: entity.id,
705
+ network: getLegacyNetwork(),
706
+ });
707
+ await sendTransactionAndWait(context, {
708
+ label: 'E2E legacy withdraw entity vote',
709
+ to: withdraw.to,
710
+ calldata: withdraw.calldata,
711
+ });
712
+ await waitForEntityVote(entity.id, context.spaceId, context.spaceId, votes => votes.some(vote => vote.vote === 2));
713
+ }, TEST_TIMEOUT_MS);
714
+ it('daoSpace.createSpace creates an indexed DAO space', async () => {
715
+ const dao = await getDaoContext();
716
+ expect(dao.daoSpaceAddress.toLowerCase()).not.toBe(ZERO_ADDRESS.toLowerCase());
717
+ expect(dao.daoSpaceIdHex.toLowerCase()).not.toBe(EMPTY_SPACE_ID.toLowerCase());
718
+ }, TEST_TIMEOUT_MS);
719
+ it('daoSpace.proposeEdit creates an indexed publish proposal', async () => {
720
+ const dao = await getDaoContext();
721
+ const daoEntity = Graph.createEntity({
722
+ name: uniqueName('E2E Legacy DAO Proposed Entity'),
723
+ });
724
+ const proposal = await daoSpace.proposeEdit({
725
+ name: 'E2E legacy API DAO propose edit',
726
+ ops: daoEntity.ops,
727
+ author: dao.spaceId,
728
+ daoSpaceAddress: dao.daoSpaceAddress,
729
+ callerSpaceId: dao.spaceIdHex,
730
+ daoSpaceId: dao.daoSpaceIdHex,
731
+ votingMode: 'FAST',
732
+ network: getLegacyNetwork(),
733
+ });
734
+ await sendTransactionAndWait(dao, {
735
+ label: 'legacy API DAO propose edit',
736
+ to: proposal.to,
737
+ calldata: proposal.calldata,
738
+ });
739
+ await waitForProposal(proposal.proposalId, {
740
+ daoSpaceId: dao.daoSpaceId,
741
+ proposedBy: dao.spaceId,
742
+ votingMode: 'FAST',
743
+ actionType: ['PUBLISH', 'UNKNOWN'],
744
+ });
745
+ }, TEST_TIMEOUT_MS);
746
+ it('daoSpace.proposeAddMember creates an indexed add-member proposal', async () => {
747
+ const dao = await getDaoContext();
748
+ await createLegacyAddMemberProposal(dao, 'legacy API DAO propose add member');
749
+ }, TEST_TIMEOUT_MS);
750
+ it('daoSpace.proposeRemoveMember creates an indexed remove-member proposal', async () => {
751
+ const dao = await getDaoContext();
752
+ const proposal = daoSpace.proposeRemoveMember({
753
+ authorSpaceId: dao.spaceIdHex,
754
+ spaceId: dao.daoSpaceIdHex,
755
+ daoSpaceAddress: dao.daoSpaceAddress,
756
+ memberToRemoveSpaceId: dao.spaceIdHex,
757
+ network: getLegacyNetwork(),
758
+ });
759
+ await sendTransactionAndWait(dao, {
760
+ label: 'legacy API DAO propose remove member',
761
+ to: proposal.to,
762
+ calldata: proposal.calldata,
763
+ });
764
+ await waitForProposal(proposal.proposalId, {
765
+ daoSpaceId: dao.daoSpaceId,
766
+ proposedBy: dao.spaceId,
767
+ votingMode: 'SLOW',
768
+ });
769
+ }, TEST_TIMEOUT_MS);
770
+ it('daoSpace.proposeAddEditor creates an indexed add-editor proposal', async () => {
771
+ const dao = await getDaoContext();
772
+ const proposal = daoSpace.proposeAddEditor({
773
+ authorSpaceId: dao.spaceIdHex,
774
+ spaceId: dao.daoSpaceIdHex,
775
+ daoSpaceAddress: dao.daoSpaceAddress,
776
+ newEditorSpaceId: dao.spaceIdHex,
777
+ network: getLegacyNetwork(),
778
+ });
779
+ await sendTransactionAndWait(dao, {
780
+ label: 'legacy API DAO propose add editor',
781
+ to: proposal.to,
782
+ calldata: proposal.calldata,
783
+ });
784
+ await waitForProposal(proposal.proposalId, {
785
+ daoSpaceId: dao.daoSpaceId,
786
+ proposedBy: dao.spaceId,
787
+ votingMode: 'SLOW',
788
+ });
789
+ }, TEST_TIMEOUT_MS);
790
+ it('daoSpace.proposeRemoveEditor creates an indexed remove-editor proposal', async () => {
791
+ const dao = await getDaoContext();
792
+ const proposal = daoSpace.proposeRemoveEditor({
793
+ authorSpaceId: dao.spaceIdHex,
794
+ spaceId: dao.daoSpaceIdHex,
795
+ daoSpaceAddress: dao.daoSpaceAddress,
796
+ editorToRemoveSpaceId: dao.spaceIdHex,
797
+ network: getLegacyNetwork(),
798
+ });
799
+ await sendTransactionAndWait(dao, {
800
+ label: 'legacy API DAO propose remove editor',
801
+ to: proposal.to,
802
+ calldata: proposal.calldata,
803
+ });
804
+ await waitForProposal(proposal.proposalId, {
805
+ daoSpaceId: dao.daoSpaceId,
806
+ proposedBy: dao.spaceId,
807
+ votingMode: 'SLOW',
808
+ });
809
+ }, TEST_TIMEOUT_MS);
810
+ it('daoSpace.proposeRequestMembership creates an indexed membership proposal', async () => {
811
+ const dao = await getDaoContext();
812
+ const proposal = daoSpace.proposeRequestMembership({
813
+ authorSpaceId: dao.spaceIdHex,
814
+ spaceId: dao.daoSpaceIdHex,
815
+ network: getLegacyNetwork(),
816
+ });
817
+ await sendTransactionAndWait(dao, {
818
+ label: 'legacy API DAO propose request membership',
819
+ to: proposal.to,
820
+ calldata: proposal.calldata,
821
+ });
822
+ await waitForProposal(proposal.proposalId, {
823
+ daoSpaceId: dao.daoSpaceId,
824
+ proposedBy: dao.daoSpaceId,
825
+ votingMode: 'FAST',
826
+ actionType: 'ADD_MEMBER',
827
+ targetId: dao.spaceId,
828
+ });
829
+ }, TEST_TIMEOUT_MS);
830
+ it('daoSpace.voteProposal creates an indexed proposal vote', async () => {
831
+ const dao = await getDaoContext();
832
+ const proposal = await createLegacyAddMemberProposal(dao, 'legacy API DAO proposal for vote');
833
+ const vote = daoSpace.voteProposal({
834
+ authorSpaceId: dao.spaceIdHex,
835
+ spaceId: dao.daoSpaceIdHex,
836
+ proposalId: proposal.proposalId,
837
+ vote: 'YES',
838
+ network: getLegacyNetwork(),
839
+ });
840
+ await sendTransactionAndWait(dao, {
841
+ label: 'legacy API DAO vote proposal',
842
+ to: vote.to,
843
+ calldata: vote.calldata,
844
+ });
845
+ await waitForProposalVote(proposal.proposalId, dao.spaceId, dao.daoSpaceId, 'YES');
846
+ }, TEST_TIMEOUT_MS);
847
+ it('daoSpace.executeProposal builds execute calldata for an indexed proposal', async () => {
848
+ const dao = await getDaoContext();
849
+ const proposal = await createLegacyAddMemberProposal(dao, 'legacy API DAO proposal for execute calldata');
850
+ const execute = daoSpace.executeProposal({
851
+ authorSpaceId: dao.spaceIdHex,
852
+ spaceId: dao.daoSpaceIdHex,
853
+ proposalId: proposal.proposalId,
854
+ network: getLegacyNetwork(),
855
+ });
856
+ expect(execute.to).toBe(e2e.contracts.SPACE_REGISTRY_ADDRESS);
857
+ expect(execute.calldata).toMatch(/^0x[0-9a-fA-F]+$/);
858
+ }, TEST_TIMEOUT_MS);
859
+ });
860
+ //# sourceMappingURL=legacy-api-surface.e2e.test.js.map