@graphprotocol/grc-20 0.31.0 → 0.32.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 (363) hide show
  1. package/README.md +4 -0
  2. package/dist/constants.d.ts +7 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +8 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/convert-ids.d.ts +2 -0
  7. package/dist/convert-ids.d.ts.map +1 -0
  8. package/dist/convert-ids.js +42 -0
  9. package/dist/convert-ids.js.map +1 -0
  10. package/dist/examples/ranks/create-ordinal-rank.js +4 -4
  11. package/dist/examples/ranks/create-ordinal-rank.js.map +1 -1
  12. package/dist/examples/ranks/create-weighted-rank.js +4 -4
  13. package/dist/examples/ranks/create-weighted-rank.js.map +1 -1
  14. package/dist/proto.d.ts +4 -8
  15. package/dist/proto.d.ts.map +1 -1
  16. package/dist/proto.js +4 -8
  17. package/dist/proto.js.map +1 -1
  18. package/dist/protov2.d.ts +11 -0
  19. package/dist/protov2.d.ts.map +1 -0
  20. package/dist/protov2.js +11 -0
  21. package/dist/protov2.js.map +1 -0
  22. package/dist/scripts/setup-rank-types.d.ts +2 -2
  23. package/dist/scripts/setup-rank-types.d.ts.map +1 -1
  24. package/dist/scripts/setup-rank-types.js.map +1 -1
  25. package/dist/src/codec/convert.d.ts +18 -0
  26. package/dist/src/codec/convert.d.ts.map +1 -0
  27. package/dist/src/codec/convert.js +188 -0
  28. package/dist/src/codec/convert.js.map +1 -0
  29. package/dist/src/core/account.d.ts +2 -2
  30. package/dist/src/core/account.d.ts.map +1 -1
  31. package/dist/src/core/account.js +2 -0
  32. package/dist/src/core/account.js.map +1 -1
  33. package/dist/src/core/account.test.js +69 -22
  34. package/dist/src/core/account.test.js.map +1 -1
  35. package/dist/src/core/blocks/data.d.ts +3 -3
  36. package/dist/src/core/blocks/data.d.ts.map +1 -1
  37. package/dist/src/core/blocks/data.js +2 -1
  38. package/dist/src/core/blocks/data.js.map +1 -1
  39. package/dist/src/core/blocks/data.test.js +74 -36
  40. package/dist/src/core/blocks/data.test.js.map +1 -1
  41. package/dist/src/core/blocks/image.d.ts +15 -0
  42. package/dist/src/core/blocks/image.d.ts.map +1 -0
  43. package/dist/src/core/blocks/image.js +15 -0
  44. package/dist/src/core/blocks/image.js.map +1 -0
  45. package/dist/src/core/blocks/text.d.ts +3 -3
  46. package/dist/src/core/blocks/text.d.ts.map +1 -1
  47. package/dist/src/core/blocks/text.js +2 -1
  48. package/dist/src/core/blocks/text.js.map +1 -1
  49. package/dist/src/core/blocks/text.test.js +79 -15
  50. package/dist/src/core/blocks/text.test.js.map +1 -1
  51. package/dist/src/core/idsv2/content.d.ts +59 -0
  52. package/dist/src/core/idsv2/content.d.ts.map +1 -0
  53. package/dist/src/core/idsv2/content.js +59 -0
  54. package/dist/src/core/idsv2/content.js.map +1 -0
  55. package/dist/src/core/idsv2/network.d.ts +5 -0
  56. package/dist/src/core/idsv2/network.d.ts.map +1 -0
  57. package/dist/src/core/idsv2/network.js +5 -0
  58. package/dist/src/core/idsv2/network.js.map +1 -0
  59. package/dist/src/core/idsv2/system.d.ts +222 -0
  60. package/dist/src/core/idsv2/system.d.ts.map +1 -0
  61. package/dist/src/core/idsv2/system.js +230 -0
  62. package/dist/src/core/idsv2/system.js.map +1 -0
  63. package/dist/src/core/image.d.ts +40 -0
  64. package/dist/src/core/image.d.ts.map +1 -0
  65. package/dist/src/core/image.js +76 -0
  66. package/dist/src/core/image.js.map +1 -0
  67. package/dist/src/core/image.test.d.ts +2 -0
  68. package/dist/src/core/image.test.d.ts.map +1 -0
  69. package/dist/src/core/image.test.js +52 -0
  70. package/dist/src/core/image.test.js.map +1 -0
  71. package/dist/src/core/relation.d.ts +88 -0
  72. package/dist/src/core/relation.d.ts.map +1 -0
  73. package/dist/src/core/relation.js +89 -0
  74. package/dist/src/core/relation.js.map +1 -0
  75. package/dist/src/core/relation.test.d.ts +2 -0
  76. package/dist/src/core/relation.test.d.ts.map +1 -0
  77. package/dist/src/core/relation.test.js +45 -0
  78. package/dist/src/core/relation.test.js.map +1 -0
  79. package/dist/src/core/triple.d.ts +50 -0
  80. package/dist/src/core/triple.d.ts.map +1 -0
  81. package/dist/src/core/triple.js +56 -0
  82. package/dist/src/core/triple.js.map +1 -0
  83. package/dist/src/core/triple.test.d.ts +2 -0
  84. package/dist/src/core/triple.test.d.ts.map +1 -0
  85. package/dist/src/core/triple.test.js +37 -0
  86. package/dist/src/core/triple.test.js.map +1 -0
  87. package/dist/src/encoding.d.ts +2 -1
  88. package/dist/src/encoding.d.ts.map +1 -1
  89. package/dist/src/encoding.js +2 -2
  90. package/dist/src/encoding.js.map +1 -1
  91. package/dist/src/encoding.test.d.ts +2 -0
  92. package/dist/src/encoding.test.d.ts.map +1 -0
  93. package/dist/src/encoding.test.js +644 -0
  94. package/dist/src/encoding.test.js.map +1 -0
  95. package/dist/src/encodings/get-register-space-calldata.d.ts +32 -0
  96. package/dist/src/encodings/get-register-space-calldata.d.ts.map +1 -0
  97. package/dist/src/encodings/get-register-space-calldata.js +39 -0
  98. package/dist/src/encodings/get-register-space-calldata.js.map +1 -0
  99. package/dist/src/encodings/get-register-space-calldata.test.d.ts +2 -0
  100. package/dist/src/encodings/get-register-space-calldata.test.d.ts.map +1 -0
  101. package/dist/src/encodings/get-register-space-calldata.test.js +15 -0
  102. package/dist/src/encodings/get-register-space-calldata.test.js.map +1 -0
  103. package/dist/src/full-flow-test.test.js +125 -37
  104. package/dist/src/full-flow-test.test.js.map +1 -1
  105. package/dist/src/graph/constants.d.ts +4 -0
  106. package/dist/src/graph/constants.d.ts.map +1 -1
  107. package/dist/src/graph/constants.js +14 -0
  108. package/dist/src/graph/constants.js.map +1 -1
  109. package/dist/src/graph/create-entity.d.ts +0 -1
  110. package/dist/src/graph/create-entity.d.ts.map +1 -1
  111. package/dist/src/graph/create-entity.js +155 -111
  112. package/dist/src/graph/create-entity.js.map +1 -1
  113. package/dist/src/graph/create-entity.test.js +339 -206
  114. package/dist/src/graph/create-entity.test.js.map +1 -1
  115. package/dist/src/graph/create-image.d.ts.map +1 -1
  116. package/dist/src/graph/create-image.js +15 -14
  117. package/dist/src/graph/create-image.js.map +1 -1
  118. package/dist/src/graph/create-image.test.js +109 -50
  119. package/dist/src/graph/create-image.test.js.map +1 -1
  120. package/dist/src/graph/create-property.d.ts.map +1 -1
  121. package/dist/src/graph/create-property.js +10 -19
  122. package/dist/src/graph/create-property.js.map +1 -1
  123. package/dist/src/graph/create-property.test.js +129 -19
  124. package/dist/src/graph/create-property.test.js.map +1 -1
  125. package/dist/src/graph/create-relation.d.ts +1 -3
  126. package/dist/src/graph/create-relation.d.ts.map +1 -1
  127. package/dist/src/graph/create-relation.js +21 -37
  128. package/dist/src/graph/create-relation.js.map +1 -1
  129. package/dist/src/graph/create-relation.test.js +186 -200
  130. package/dist/src/graph/create-relation.test.js.map +1 -1
  131. package/dist/src/graph/create-space.d.ts +4 -3
  132. package/dist/src/graph/create-space.d.ts.map +1 -1
  133. package/dist/src/graph/create-space.js +2 -2
  134. package/dist/src/graph/create-space.js.map +1 -1
  135. package/dist/src/graph/create-type.d.ts.map +1 -1
  136. package/dist/src/graph/create-type.js +16 -21
  137. package/dist/src/graph/create-type.js.map +1 -1
  138. package/dist/src/graph/create-type.test.js +76 -67
  139. package/dist/src/graph/create-type.test.js.map +1 -1
  140. package/dist/src/graph/delete-entity.d.ts +14 -0
  141. package/dist/src/graph/delete-entity.d.ts.map +1 -0
  142. package/dist/src/graph/delete-entity.js +21 -0
  143. package/dist/src/graph/delete-entity.js.map +1 -0
  144. package/dist/src/graph/delete-entity.test.d.ts +2 -0
  145. package/dist/src/graph/delete-entity.test.d.ts.map +1 -0
  146. package/dist/src/graph/delete-entity.test.js +23 -0
  147. package/dist/src/graph/delete-entity.test.js.map +1 -0
  148. package/dist/src/graph/delete-relation.d.ts.map +1 -1
  149. package/dist/src/graph/delete-relation.js +3 -6
  150. package/dist/src/graph/delete-relation.js.map +1 -1
  151. package/dist/src/graph/delete-relation.test.js +6 -8
  152. package/dist/src/graph/delete-relation.test.js.map +1 -1
  153. package/dist/src/graph/graph.test.d.ts +2 -0
  154. package/dist/src/graph/graph.test.d.ts.map +1 -0
  155. package/dist/src/graph/graph.test.js +46 -0
  156. package/dist/src/graph/graph.test.js.map +1 -0
  157. package/dist/src/graph/helpers/create-default-properties.d.ts +5 -0
  158. package/dist/src/graph/helpers/create-default-properties.d.ts.map +1 -0
  159. package/dist/src/graph/helpers/create-default-properties.js +44 -0
  160. package/dist/src/graph/helpers/create-default-properties.js.map +1 -0
  161. package/dist/src/graph/helpers/create-properties.d.ts +8 -0
  162. package/dist/src/graph/helpers/create-properties.d.ts.map +1 -0
  163. package/dist/src/graph/helpers/create-properties.js +53 -0
  164. package/dist/src/graph/helpers/create-properties.js.map +1 -0
  165. package/dist/src/graph/index.d.ts +1 -4
  166. package/dist/src/graph/index.d.ts.map +1 -1
  167. package/dist/src/graph/index.js +1 -4
  168. package/dist/src/graph/index.js.map +1 -1
  169. package/dist/src/graph/update-entity.d.ts.map +1 -1
  170. package/dist/src/graph/update-entity.js +109 -57
  171. package/dist/src/graph/update-entity.js.map +1 -1
  172. package/dist/src/graph/update-entity.test.js +167 -40
  173. package/dist/src/graph/update-entity.test.js.map +1 -1
  174. package/dist/src/graph/update-relation.d.ts +1 -2
  175. package/dist/src/graph/update-relation.d.ts.map +1 -1
  176. package/dist/src/graph/update-relation.js +12 -16
  177. package/dist/src/graph/update-relation.js.map +1 -1
  178. package/dist/src/graph/update-relation.test.js +75 -109
  179. package/dist/src/graph/update-relation.test.js.map +1 -1
  180. package/dist/src/graphv2/constants.d.ts +2 -0
  181. package/dist/src/graphv2/constants.d.ts.map +1 -0
  182. package/dist/src/graphv2/constants.js +2 -0
  183. package/dist/src/graphv2/constants.js.map +1 -0
  184. package/dist/src/graphv2/create-entity.d.ts +52 -0
  185. package/dist/src/graphv2/create-entity.d.ts.map +1 -0
  186. package/dist/src/graphv2/create-entity.js +140 -0
  187. package/dist/src/graphv2/create-entity.js.map +1 -0
  188. package/dist/src/graphv2/create-entity.test.d.ts +2 -0
  189. package/dist/src/graphv2/create-entity.test.d.ts.map +1 -0
  190. package/dist/src/graphv2/create-entity.test.js +158 -0
  191. package/dist/src/graphv2/create-entity.test.js.map +1 -0
  192. package/dist/src/graphv2/create-image.d.ts +28 -0
  193. package/dist/src/graphv2/create-image.d.ts.map +1 -0
  194. package/dist/src/graphv2/create-image.js +71 -0
  195. package/dist/src/graphv2/create-image.js.map +1 -0
  196. package/dist/src/graphv2/create-image.test.d.ts +2 -0
  197. package/dist/src/graphv2/create-image.test.d.ts.map +1 -0
  198. package/dist/src/graphv2/create-image.test.js +142 -0
  199. package/dist/src/graphv2/create-image.test.js.map +1 -0
  200. package/dist/src/graphv2/create-property.d.ts +22 -0
  201. package/dist/src/graphv2/create-property.d.ts.map +1 -0
  202. package/dist/src/graphv2/create-property.js +129 -0
  203. package/dist/src/graphv2/create-property.js.map +1 -0
  204. package/dist/src/graphv2/create-property.test.d.ts +2 -0
  205. package/dist/src/graphv2/create-property.test.d.ts.map +1 -0
  206. package/dist/src/graphv2/create-property.test.js +82 -0
  207. package/dist/src/graphv2/create-property.test.js.map +1 -0
  208. package/dist/src/graphv2/create-relation.d.ts +33 -0
  209. package/dist/src/graphv2/create-relation.d.ts.map +1 -0
  210. package/dist/src/graphv2/create-relation.js +66 -0
  211. package/dist/src/graphv2/create-relation.js.map +1 -0
  212. package/dist/src/graphv2/create-relation.test.d.ts +2 -0
  213. package/dist/src/graphv2/create-relation.test.d.ts.map +1 -0
  214. package/dist/src/graphv2/create-relation.test.js +208 -0
  215. package/dist/src/graphv2/create-relation.test.js.map +1 -0
  216. package/dist/src/graphv2/create-space.d.ts +13 -0
  217. package/dist/src/graphv2/create-space.d.ts.map +1 -0
  218. package/dist/src/graphv2/create-space.js +21 -0
  219. package/dist/src/graphv2/create-space.js.map +1 -0
  220. package/dist/src/graphv2/create-type.d.ts +22 -0
  221. package/dist/src/graphv2/create-type.d.ts.map +1 -0
  222. package/dist/src/graphv2/create-type.js +64 -0
  223. package/dist/src/graphv2/create-type.js.map +1 -0
  224. package/dist/src/graphv2/create-type.test.d.ts +2 -0
  225. package/dist/src/graphv2/create-type.test.d.ts.map +1 -0
  226. package/dist/src/graphv2/create-type.test.js +109 -0
  227. package/dist/src/graphv2/create-type.test.js.map +1 -0
  228. package/dist/src/graphv2/delete-entity.d.ts +14 -0
  229. package/dist/src/graphv2/delete-entity.d.ts.map +1 -0
  230. package/dist/src/graphv2/delete-entity.js +21 -0
  231. package/dist/src/graphv2/delete-entity.js.map +1 -0
  232. package/dist/src/graphv2/delete-entity.test.d.ts +2 -0
  233. package/dist/src/graphv2/delete-entity.test.d.ts.map +1 -0
  234. package/dist/src/graphv2/delete-entity.test.js +24 -0
  235. package/dist/src/graphv2/delete-entity.test.js.map +1 -0
  236. package/dist/src/graphv2/delete-relation.d.ts +14 -0
  237. package/dist/src/graphv2/delete-relation.d.ts.map +1 -0
  238. package/dist/src/graphv2/delete-relation.js +21 -0
  239. package/dist/src/graphv2/delete-relation.js.map +1 -0
  240. package/dist/src/graphv2/delete-relation.test.d.ts +2 -0
  241. package/dist/src/graphv2/delete-relation.test.d.ts.map +1 -0
  242. package/dist/src/graphv2/delete-relation.test.js +24 -0
  243. package/dist/src/graphv2/delete-relation.test.js.map +1 -0
  244. package/dist/src/graphv2/index.d.ts +12 -0
  245. package/dist/src/graphv2/index.d.ts.map +1 -0
  246. package/dist/src/graphv2/index.js +12 -0
  247. package/dist/src/graphv2/index.js.map +1 -0
  248. package/dist/src/graphv2/remove-entity-properties.d.ts +25 -0
  249. package/dist/src/graphv2/remove-entity-properties.d.ts.map +1 -0
  250. package/dist/src/graphv2/remove-entity-properties.js +24 -0
  251. package/dist/src/graphv2/remove-entity-properties.js.map +1 -0
  252. package/dist/src/graphv2/unset-entity-values.d.ts +21 -0
  253. package/dist/src/graphv2/unset-entity-values.d.ts.map +1 -0
  254. package/dist/src/graphv2/unset-entity-values.js +26 -0
  255. package/dist/src/graphv2/unset-entity-values.js.map +1 -0
  256. package/dist/src/graphv2/unset-entity-values.test.d.ts +2 -0
  257. package/dist/src/graphv2/unset-entity-values.test.d.ts.map +1 -0
  258. package/dist/src/graphv2/unset-entity-values.test.js +40 -0
  259. package/dist/src/graphv2/unset-entity-values.test.js.map +1 -0
  260. package/dist/src/graphv2/unset-relation-fields.d.ts +25 -0
  261. package/dist/src/graphv2/unset-relation-fields.d.ts.map +1 -0
  262. package/dist/src/graphv2/unset-relation-fields.js +34 -0
  263. package/dist/src/graphv2/unset-relation-fields.js.map +1 -0
  264. package/dist/src/graphv2/unset-relation-fields.test.d.ts +2 -0
  265. package/dist/src/graphv2/unset-relation-fields.test.d.ts.map +1 -0
  266. package/dist/src/graphv2/unset-relation-fields.test.js +64 -0
  267. package/dist/src/graphv2/unset-relation-fields.test.js.map +1 -0
  268. package/dist/src/graphv2/update-entity.d.ts +28 -0
  269. package/dist/src/graphv2/update-entity.d.ts.map +1 -0
  270. package/dist/src/graphv2/update-entity.js +73 -0
  271. package/dist/src/graphv2/update-entity.js.map +1 -0
  272. package/dist/src/graphv2/update-entity.test.d.ts +2 -0
  273. package/dist/src/graphv2/update-entity.test.d.ts.map +1 -0
  274. package/dist/src/graphv2/update-entity.test.js +116 -0
  275. package/dist/src/graphv2/update-entity.test.js.map +1 -0
  276. package/dist/src/graphv2/update-relation.d.ts +21 -0
  277. package/dist/src/graphv2/update-relation.d.ts.map +1 -0
  278. package/dist/src/graphv2/update-relation.js +37 -0
  279. package/dist/src/graphv2/update-relation.js.map +1 -0
  280. package/dist/src/id-utils.d.ts +6 -0
  281. package/dist/src/id-utils.d.ts.map +1 -1
  282. package/dist/src/id-utils.js +13 -0
  283. package/dist/src/id-utils.js.map +1 -1
  284. package/dist/src/idv2.d.ts +27 -0
  285. package/dist/src/idv2.d.ts.map +1 -0
  286. package/dist/src/idv2.js +88 -0
  287. package/dist/src/idv2.js.map +1 -0
  288. package/dist/src/idv2.test.d.ts +2 -0
  289. package/dist/src/idv2.test.d.ts.map +1 -0
  290. package/dist/src/idv2.test.js +26 -0
  291. package/dist/src/idv2.test.js.map +1 -0
  292. package/dist/src/image.d.ts +8 -0
  293. package/dist/src/image.d.ts.map +1 -0
  294. package/dist/src/image.js +8 -0
  295. package/dist/src/image.js.map +1 -0
  296. package/dist/src/ipfs.d.ts +7 -6
  297. package/dist/src/ipfs.d.ts.map +1 -1
  298. package/dist/src/ipfs.js +31 -11
  299. package/dist/src/ipfs.js.map +1 -1
  300. package/dist/src/ipfs.test.js +130 -17
  301. package/dist/src/ipfs.test.js.map +1 -1
  302. package/dist/src/ipfsv2.d.ts +96 -0
  303. package/dist/src/ipfsv2.d.ts.map +1 -0
  304. package/dist/src/ipfsv2.js +163 -0
  305. package/dist/src/ipfsv2.js.map +1 -0
  306. package/dist/src/ipfsv2.test.d.ts +2 -0
  307. package/dist/src/ipfsv2.test.d.ts.map +1 -0
  308. package/dist/src/ipfsv2.test.js +22 -0
  309. package/dist/src/ipfsv2.test.js.map +1 -0
  310. package/dist/src/proto/editv2.d.ts +11 -0
  311. package/dist/src/proto/editv2.d.ts.map +1 -0
  312. package/dist/src/proto/editv2.js +81 -0
  313. package/dist/src/proto/editv2.js.map +1 -0
  314. package/dist/src/proto/editv2.test.d.ts +2 -0
  315. package/dist/src/proto/editv2.test.d.ts.map +1 -0
  316. package/dist/src/proto/editv2.test.js +211 -0
  317. package/dist/src/proto/editv2.test.js.map +1 -0
  318. package/dist/src/proto/gen/src/proto/ipfsv2_pb.d.ts +410 -0
  319. package/dist/src/proto/gen/src/proto/ipfsv2_pb.d.ts.map +1 -0
  320. package/dist/src/proto/gen/src/proto/ipfsv2_pb.js +536 -0
  321. package/dist/src/proto/gen/src/proto/ipfsv2_pb.js.map +1 -0
  322. package/dist/src/proto/index.d.ts +7 -1
  323. package/dist/src/proto/index.d.ts.map +1 -1
  324. package/dist/src/proto/index.js +6 -1
  325. package/dist/src/proto/index.js.map +1 -1
  326. package/dist/src/ranks/create-rank.d.ts.map +1 -1
  327. package/dist/src/ranks/create-rank.js +54 -47
  328. package/dist/src/ranks/create-rank.js.map +1 -1
  329. package/dist/src/ranks/create-rank.test.js +181 -94
  330. package/dist/src/ranks/create-rank.test.js.map +1 -1
  331. package/dist/src/relation.d.ts +7 -0
  332. package/dist/src/relation.d.ts.map +1 -0
  333. package/dist/src/relation.js +7 -0
  334. package/dist/src/relation.js.map +1 -0
  335. package/dist/src/smart-wallet-2.test-invalid.d.ts +2 -0
  336. package/dist/src/smart-wallet-2.test-invalid.d.ts.map +1 -0
  337. package/dist/src/smart-wallet-2.test-invalid.js +49 -0
  338. package/dist/src/smart-wallet-2.test-invalid.js.map +1 -0
  339. package/dist/src/smart-wallet-2.test.d.ts +2 -0
  340. package/dist/src/smart-wallet-2.test.d.ts.map +1 -0
  341. package/dist/src/smart-wallet-2.test.js +49 -0
  342. package/dist/src/smart-wallet-2.test.js.map +1 -0
  343. package/dist/src/system-ids-v2.d.ts +7 -0
  344. package/dist/src/system-ids-v2.d.ts.map +1 -0
  345. package/dist/src/system-ids-v2.js +7 -0
  346. package/dist/src/system-ids-v2.js.map +1 -0
  347. package/dist/src/triple.d.ts +7 -0
  348. package/dist/src/triple.d.ts.map +1 -0
  349. package/dist/src/triple.js +7 -0
  350. package/dist/src/triple.js.map +1 -0
  351. package/dist/src/types-backup.d.ts +134 -0
  352. package/dist/src/types-backup.d.ts.map +1 -0
  353. package/dist/src/types-backup.js +13 -0
  354. package/dist/src/types-backup.js.map +1 -0
  355. package/dist/src/types.d.ts +52 -89
  356. package/dist/src/types.d.ts.map +1 -1
  357. package/dist/src/types.js.map +1 -1
  358. package/dist/src/typesv2.d.ts +173 -0
  359. package/dist/src/typesv2.d.ts.map +1 -0
  360. package/dist/src/typesv2.js +8 -0
  361. package/dist/src/typesv2.js.map +1 -0
  362. package/dist/tsconfig.tsbuildinfo +1 -0
  363. package/package.json +2 -5
@@ -0,0 +1,644 @@
1
+ import { decodeEdit, encodeEdit, formatId, parseId, } from '@geoprotocol/grc-20';
2
+ import { describe, expect, it } from 'vitest';
3
+ // Helper to convert string ID to GRC-20 Id
4
+ function toGrcId(id) {
5
+ const parsed = parseId(id);
6
+ if (!parsed)
7
+ throw new Error(`Invalid ID: ${id}`);
8
+ return parsed;
9
+ }
10
+ describe('GRC-20 v2 Encoding', () => {
11
+ describe('createEntity ops', () => {
12
+ it('encodes and decodes createEntity with text value', () => {
13
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
14
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
15
+ const languageId = toGrcId('a6104fe0d6954f9392fa0a1afc552bc5');
16
+ const editId = toGrcId('11111111111111111111111111111111');
17
+ const authorId = toGrcId('22222222222222222222222222222222');
18
+ const edit = {
19
+ id: editId,
20
+ name: 'test',
21
+ authors: [authorId],
22
+ createdAt: BigInt(1000000),
23
+ ops: [
24
+ {
25
+ type: 'createEntity',
26
+ id: entityId,
27
+ values: [
28
+ {
29
+ property: propertyId,
30
+ value: {
31
+ type: 'text',
32
+ value: 'test value',
33
+ language: languageId,
34
+ },
35
+ },
36
+ ],
37
+ },
38
+ ],
39
+ };
40
+ const binary = encodeEdit(edit);
41
+ const decoded = decodeEdit(binary);
42
+ expect(decoded.name).toBe('test');
43
+ expect(decoded.ops.length).toBe(1);
44
+ expect(decoded.ops[0]?.type).toBe('createEntity');
45
+ const op = decoded.ops[0];
46
+ expect(formatId(op.id)).toBe('3af3e22d21694a078681516710b7ecf1');
47
+ expect(op.values.length).toBe(1);
48
+ expect(op.values[0]?.value.type).toBe('text');
49
+ if (op.values[0]?.value.type === 'text') {
50
+ expect(op.values[0].value.value).toBe('test value');
51
+ }
52
+ });
53
+ it('encodes and decodes createEntity with float64 value', () => {
54
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
55
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
56
+ const unitId = toGrcId('a6104fe0d6954f9392fa0a1afc552bc5');
57
+ const editId = toGrcId('11111111111111111111111111111111');
58
+ const authorId = toGrcId('22222222222222222222222222222222');
59
+ const edit = {
60
+ id: editId,
61
+ name: 'test',
62
+ authors: [authorId],
63
+ createdAt: BigInt(1000000),
64
+ ops: [
65
+ {
66
+ type: 'createEntity',
67
+ id: entityId,
68
+ values: [
69
+ {
70
+ property: propertyId,
71
+ value: {
72
+ type: 'float64',
73
+ value: 42.5,
74
+ unit: unitId,
75
+ },
76
+ },
77
+ ],
78
+ },
79
+ ],
80
+ };
81
+ const binary = encodeEdit(edit);
82
+ const decoded = decodeEdit(binary);
83
+ expect(decoded.name).toBe('test');
84
+ expect(decoded.ops.length).toBe(1);
85
+ const op = decoded.ops[0];
86
+ expect(op.values[0]?.value.type).toBe('float64');
87
+ if (op.values[0]?.value.type === 'float64') {
88
+ expect(op.values[0].value.value).toBe(42.5);
89
+ }
90
+ });
91
+ it('encodes and decodes createEntity with bool value', () => {
92
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
93
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
94
+ const editId = toGrcId('11111111111111111111111111111111');
95
+ const authorId = toGrcId('22222222222222222222222222222222');
96
+ const edit = {
97
+ id: editId,
98
+ name: 'test',
99
+ authors: [authorId],
100
+ createdAt: BigInt(1000000),
101
+ ops: [
102
+ {
103
+ type: 'createEntity',
104
+ id: entityId,
105
+ values: [
106
+ {
107
+ property: propertyId,
108
+ value: {
109
+ type: 'bool',
110
+ value: true,
111
+ },
112
+ },
113
+ ],
114
+ },
115
+ ],
116
+ };
117
+ const binary = encodeEdit(edit);
118
+ const decoded = decodeEdit(binary);
119
+ const op = decoded.ops[0];
120
+ expect(op.values[0]?.value.type).toBe('bool');
121
+ if (op.values[0]?.value.type === 'bool') {
122
+ expect(op.values[0].value.value).toBe(true);
123
+ }
124
+ });
125
+ it('encodes and decodes createEntity with point value', () => {
126
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
127
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
128
+ const editId = toGrcId('11111111111111111111111111111111');
129
+ const authorId = toGrcId('22222222222222222222222222222222');
130
+ const edit = {
131
+ id: editId,
132
+ name: 'test',
133
+ authors: [authorId],
134
+ createdAt: BigInt(1000000),
135
+ ops: [
136
+ {
137
+ type: 'createEntity',
138
+ id: entityId,
139
+ values: [
140
+ {
141
+ property: propertyId,
142
+ value: {
143
+ type: 'point',
144
+ lon: -122.4194,
145
+ lat: 37.7749,
146
+ alt: 10.5,
147
+ },
148
+ },
149
+ ],
150
+ },
151
+ ],
152
+ };
153
+ const binary = encodeEdit(edit);
154
+ const decoded = decodeEdit(binary);
155
+ const op = decoded.ops[0];
156
+ expect(op.values[0]?.value.type).toBe('point');
157
+ if (op.values[0]?.value.type === 'point') {
158
+ expect(op.values[0].value.lon).toBeCloseTo(-122.4194, 4);
159
+ expect(op.values[0].value.lat).toBeCloseTo(37.7749, 4);
160
+ expect(op.values[0].value.alt).toBeCloseTo(10.5, 1);
161
+ }
162
+ });
163
+ it('encodes and decodes createEntity with date value', () => {
164
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
165
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
166
+ const editId = toGrcId('11111111111111111111111111111111');
167
+ const authorId = toGrcId('22222222222222222222222222222222');
168
+ const edit = {
169
+ id: editId,
170
+ name: 'test',
171
+ authors: [authorId],
172
+ createdAt: BigInt(1000000),
173
+ ops: [
174
+ {
175
+ type: 'createEntity',
176
+ id: entityId,
177
+ values: [
178
+ {
179
+ property: propertyId,
180
+ value: {
181
+ type: 'date',
182
+ value: '2024-01-15',
183
+ },
184
+ },
185
+ ],
186
+ },
187
+ ],
188
+ };
189
+ const binary = encodeEdit(edit);
190
+ const decoded = decodeEdit(binary);
191
+ const op = decoded.ops[0];
192
+ expect(op.values[0]?.value.type).toBe('date');
193
+ if (op.values[0]?.value.type === 'date') {
194
+ expect(op.values[0].value.value).toBe('2024-01-15');
195
+ }
196
+ });
197
+ it('encodes and decodes createEntity with time value', () => {
198
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
199
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
200
+ const editId = toGrcId('11111111111111111111111111111111');
201
+ const authorId = toGrcId('22222222222222222222222222222222');
202
+ const edit = {
203
+ id: editId,
204
+ name: 'test',
205
+ authors: [authorId],
206
+ createdAt: BigInt(1000000),
207
+ ops: [
208
+ {
209
+ type: 'createEntity',
210
+ id: entityId,
211
+ values: [
212
+ {
213
+ property: propertyId,
214
+ value: {
215
+ type: 'time',
216
+ value: '14:30:00Z',
217
+ },
218
+ },
219
+ ],
220
+ },
221
+ ],
222
+ };
223
+ const binary = encodeEdit(edit);
224
+ const decoded = decodeEdit(binary);
225
+ const op = decoded.ops[0];
226
+ expect(op.values[0]?.value.type).toBe('time');
227
+ if (op.values[0]?.value.type === 'time') {
228
+ expect(op.values[0].value.value).toBe('14:30:00Z');
229
+ }
230
+ });
231
+ it('encodes and decodes createEntity with datetime value', () => {
232
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
233
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
234
+ const editId = toGrcId('11111111111111111111111111111111');
235
+ const authorId = toGrcId('22222222222222222222222222222222');
236
+ const edit = {
237
+ id: editId,
238
+ name: 'test',
239
+ authors: [authorId],
240
+ createdAt: BigInt(1000000),
241
+ ops: [
242
+ {
243
+ type: 'createEntity',
244
+ id: entityId,
245
+ values: [
246
+ {
247
+ property: propertyId,
248
+ value: {
249
+ type: 'datetime',
250
+ value: '2024-01-15T14:30:00Z',
251
+ },
252
+ },
253
+ ],
254
+ },
255
+ ],
256
+ };
257
+ const binary = encodeEdit(edit);
258
+ const decoded = decodeEdit(binary);
259
+ const op = decoded.ops[0];
260
+ expect(op.values[0]?.value.type).toBe('datetime');
261
+ if (op.values[0]?.value.type === 'datetime') {
262
+ expect(op.values[0].value.value).toBe('2024-01-15T14:30:00Z');
263
+ }
264
+ });
265
+ it('encodes and decodes createEntity with schedule value', () => {
266
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
267
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
268
+ const editId = toGrcId('11111111111111111111111111111111');
269
+ const authorId = toGrcId('22222222222222222222222222222222');
270
+ const edit = {
271
+ id: editId,
272
+ name: 'test',
273
+ authors: [authorId],
274
+ createdAt: BigInt(1000000),
275
+ ops: [
276
+ {
277
+ type: 'createEntity',
278
+ id: entityId,
279
+ values: [
280
+ {
281
+ property: propertyId,
282
+ value: {
283
+ type: 'schedule',
284
+ value: 'FREQ=WEEKLY;BYDAY=MO,WE,FR',
285
+ },
286
+ },
287
+ ],
288
+ },
289
+ ],
290
+ };
291
+ const binary = encodeEdit(edit);
292
+ const decoded = decodeEdit(binary);
293
+ const op = decoded.ops[0];
294
+ expect(op.values[0]?.value.type).toBe('schedule');
295
+ if (op.values[0]?.value.type === 'schedule') {
296
+ expect(op.values[0].value.value).toBe('FREQ=WEEKLY;BYDAY=MO,WE,FR');
297
+ }
298
+ });
299
+ });
300
+ describe('relation ops', () => {
301
+ it('encodes and decodes createRelation', () => {
302
+ const relationId = toGrcId('765564cac7e54c61b1dcc28ab77ec6b7');
303
+ const relationTypeId = toGrcId('cf518eafef744aadbc87fe09c2631fcd');
304
+ const fromEntityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
305
+ const toEntityId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
306
+ const entityId = toGrcId('a6104fe0d6954f9392fa0a1afc552bc5');
307
+ const editId = toGrcId('11111111111111111111111111111111');
308
+ const authorId = toGrcId('22222222222222222222222222222222');
309
+ const edit = {
310
+ id: editId,
311
+ name: 'test',
312
+ authors: [authorId],
313
+ createdAt: BigInt(1000000),
314
+ ops: [
315
+ {
316
+ type: 'createRelation',
317
+ id: relationId,
318
+ relationType: relationTypeId,
319
+ from: fromEntityId,
320
+ to: toEntityId,
321
+ entity: entityId,
322
+ position: 'test-position',
323
+ },
324
+ ],
325
+ };
326
+ const binary = encodeEdit(edit);
327
+ const decoded = decodeEdit(binary);
328
+ expect(decoded.name).toBe('test');
329
+ expect(decoded.ops.length).toBe(1);
330
+ expect(decoded.ops[0]?.type).toBe('createRelation');
331
+ const op = decoded.ops[0];
332
+ expect(formatId(op.id)).toBe('765564cac7e54c61b1dcc28ab77ec6b7');
333
+ expect(formatId(op.relationType)).toBe('cf518eafef744aadbc87fe09c2631fcd');
334
+ expect(formatId(op.from)).toBe('3af3e22d21694a078681516710b7ecf1');
335
+ expect(formatId(op.to)).toBe('d4bc2f205e2d415e971eb0b9fbf6b6fc');
336
+ expect(op.position).toBe('test-position');
337
+ });
338
+ it('encodes and decodes createRelation with space pins', () => {
339
+ const relationId = toGrcId('765564cac7e54c61b1dcc28ab77ec6b7');
340
+ const relationTypeId = toGrcId('cf518eafef744aadbc87fe09c2631fcd');
341
+ const fromEntityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
342
+ const toEntityId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
343
+ const fromSpaceId = toGrcId('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
344
+ const toSpaceId = toGrcId('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
345
+ const editId = toGrcId('11111111111111111111111111111111');
346
+ const authorId = toGrcId('22222222222222222222222222222222');
347
+ const edit = {
348
+ id: editId,
349
+ name: 'test',
350
+ authors: [authorId],
351
+ createdAt: BigInt(1000000),
352
+ ops: [
353
+ {
354
+ type: 'createRelation',
355
+ id: relationId,
356
+ relationType: relationTypeId,
357
+ from: fromEntityId,
358
+ to: toEntityId,
359
+ fromSpace: fromSpaceId,
360
+ toSpace: toSpaceId,
361
+ },
362
+ ],
363
+ };
364
+ const binary = encodeEdit(edit);
365
+ const decoded = decodeEdit(binary);
366
+ const op = decoded.ops[0];
367
+ expect(op.fromSpace).toBeDefined();
368
+ expect(op.toSpace).toBeDefined();
369
+ if (op.fromSpace)
370
+ expect(formatId(op.fromSpace)).toBe('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
371
+ if (op.toSpace)
372
+ expect(formatId(op.toSpace)).toBe('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
373
+ });
374
+ it('encodes and decodes deleteRelation', () => {
375
+ const relationId = toGrcId('765564cac7e54c61b1dcc28ab77ec6b7');
376
+ const editId = toGrcId('11111111111111111111111111111111');
377
+ const authorId = toGrcId('22222222222222222222222222222222');
378
+ const edit = {
379
+ id: editId,
380
+ name: 'test',
381
+ authors: [authorId],
382
+ createdAt: BigInt(1000000),
383
+ ops: [
384
+ {
385
+ type: 'deleteRelation',
386
+ id: relationId,
387
+ },
388
+ ],
389
+ };
390
+ const binary = encodeEdit(edit);
391
+ const decoded = decodeEdit(binary);
392
+ expect(decoded.ops.length).toBe(1);
393
+ expect(decoded.ops[0]?.type).toBe('deleteRelation');
394
+ const op = decoded.ops[0];
395
+ expect(formatId(op.id)).toBe('765564cac7e54c61b1dcc28ab77ec6b7');
396
+ });
397
+ it('encodes and decodes updateRelation', () => {
398
+ const relationId = toGrcId('765564cac7e54c61b1dcc28ab77ec6b7');
399
+ const editId = toGrcId('11111111111111111111111111111111');
400
+ const authorId = toGrcId('22222222222222222222222222222222');
401
+ const edit = {
402
+ id: editId,
403
+ name: 'test',
404
+ authors: [authorId],
405
+ createdAt: BigInt(1000000),
406
+ ops: [
407
+ {
408
+ type: 'updateRelation',
409
+ id: relationId,
410
+ position: 'new-position',
411
+ unset: [],
412
+ },
413
+ ],
414
+ };
415
+ const binary = encodeEdit(edit);
416
+ const decoded = decodeEdit(binary);
417
+ expect(decoded.ops.length).toBe(1);
418
+ expect(decoded.ops[0]?.type).toBe('updateRelation');
419
+ const op = decoded.ops[0];
420
+ expect(formatId(op.id)).toBe('765564cac7e54c61b1dcc28ab77ec6b7');
421
+ expect(op.position).toBe('new-position');
422
+ });
423
+ it('encodes and decodes updateRelation with unset fields', () => {
424
+ const relationId = toGrcId('765564cac7e54c61b1dcc28ab77ec6b7');
425
+ const editId = toGrcId('11111111111111111111111111111111');
426
+ const authorId = toGrcId('22222222222222222222222222222222');
427
+ const edit = {
428
+ id: editId,
429
+ name: 'test',
430
+ authors: [authorId],
431
+ createdAt: BigInt(1000000),
432
+ ops: [
433
+ {
434
+ type: 'updateRelation',
435
+ id: relationId,
436
+ unset: ['fromSpace', 'toSpace', 'position'],
437
+ },
438
+ ],
439
+ };
440
+ const binary = encodeEdit(edit);
441
+ const decoded = decodeEdit(binary);
442
+ const op = decoded.ops[0];
443
+ expect(op.unset).toContain('fromSpace');
444
+ expect(op.unset).toContain('toSpace');
445
+ expect(op.unset).toContain('position');
446
+ });
447
+ });
448
+ describe('entity ops', () => {
449
+ it('encodes and decodes updateEntity with set and unset', () => {
450
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
451
+ const propertyId = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
452
+ const unsetPropertyId = toGrcId('a6104fe0d6954f9392fa0a1afc552bc5');
453
+ const editId = toGrcId('11111111111111111111111111111111');
454
+ const authorId = toGrcId('22222222222222222222222222222222');
455
+ const edit = {
456
+ id: editId,
457
+ name: 'test',
458
+ authors: [authorId],
459
+ createdAt: BigInt(1000000),
460
+ ops: [
461
+ {
462
+ type: 'updateEntity',
463
+ id: entityId,
464
+ set: [
465
+ {
466
+ property: propertyId,
467
+ value: {
468
+ type: 'text',
469
+ value: 'updated value',
470
+ },
471
+ },
472
+ ],
473
+ unset: [
474
+ {
475
+ property: unsetPropertyId,
476
+ language: { type: 'all' },
477
+ },
478
+ ],
479
+ },
480
+ ],
481
+ };
482
+ const binary = encodeEdit(edit);
483
+ const decoded = decodeEdit(binary);
484
+ expect(decoded.ops.length).toBe(1);
485
+ expect(decoded.ops[0]?.type).toBe('updateEntity');
486
+ const op = decoded.ops[0];
487
+ expect(formatId(op.id)).toBe('3af3e22d21694a078681516710b7ecf1');
488
+ expect(op.set.length).toBe(1);
489
+ expect(op.unset.length).toBe(1);
490
+ });
491
+ it('encodes and decodes deleteEntity', () => {
492
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
493
+ const editId = toGrcId('11111111111111111111111111111111');
494
+ const authorId = toGrcId('22222222222222222222222222222222');
495
+ const edit = {
496
+ id: editId,
497
+ name: 'test',
498
+ authors: [authorId],
499
+ createdAt: BigInt(1000000),
500
+ ops: [
501
+ {
502
+ type: 'deleteEntity',
503
+ id: entityId,
504
+ },
505
+ ],
506
+ };
507
+ const binary = encodeEdit(edit);
508
+ const decoded = decodeEdit(binary);
509
+ expect(decoded.ops.length).toBe(1);
510
+ expect(decoded.ops[0]?.type).toBe('deleteEntity');
511
+ const op = decoded.ops[0];
512
+ expect(formatId(op.id)).toBe('3af3e22d21694a078681516710b7ecf1');
513
+ });
514
+ it('encodes and decodes restoreEntity', () => {
515
+ const entityId = toGrcId('3af3e22d21694a078681516710b7ecf1');
516
+ const editId = toGrcId('11111111111111111111111111111111');
517
+ const authorId = toGrcId('22222222222222222222222222222222');
518
+ const edit = {
519
+ id: editId,
520
+ name: 'test',
521
+ authors: [authorId],
522
+ createdAt: BigInt(1000000),
523
+ ops: [
524
+ {
525
+ type: 'restoreEntity',
526
+ id: entityId,
527
+ },
528
+ ],
529
+ };
530
+ const binary = encodeEdit(edit);
531
+ const decoded = decodeEdit(binary);
532
+ expect(decoded.ops.length).toBe(1);
533
+ expect(decoded.ops[0]?.type).toBe('restoreEntity');
534
+ const op = decoded.ops[0];
535
+ expect(formatId(op.id)).toBe('3af3e22d21694a078681516710b7ecf1');
536
+ });
537
+ });
538
+ describe('multiple ops', () => {
539
+ it('encodes and decodes edit with multiple ops', () => {
540
+ const entityId1 = toGrcId('3af3e22d21694a078681516710b7ecf1');
541
+ const entityId2 = toGrcId('d4bc2f205e2d415e971eb0b9fbf6b6fc');
542
+ const propertyId = toGrcId('a6104fe0d6954f9392fa0a1afc552bc5');
543
+ const relationId = toGrcId('765564cac7e54c61b1dcc28ab77ec6b7');
544
+ const relationTypeId = toGrcId('cf518eafef744aadbc87fe09c2631fcd');
545
+ const editId = toGrcId('11111111111111111111111111111111');
546
+ const authorId = toGrcId('22222222222222222222222222222222');
547
+ const edit = {
548
+ id: editId,
549
+ name: 'multi-op test',
550
+ authors: [authorId],
551
+ createdAt: BigInt(1000000),
552
+ ops: [
553
+ {
554
+ type: 'createEntity',
555
+ id: entityId1,
556
+ values: [
557
+ {
558
+ property: propertyId,
559
+ value: { type: 'text', value: 'Entity 1' },
560
+ },
561
+ ],
562
+ },
563
+ {
564
+ type: 'createEntity',
565
+ id: entityId2,
566
+ values: [
567
+ {
568
+ property: propertyId,
569
+ value: { type: 'text', value: 'Entity 2' },
570
+ },
571
+ ],
572
+ },
573
+ {
574
+ type: 'createRelation',
575
+ id: relationId,
576
+ relationType: relationTypeId,
577
+ from: entityId1,
578
+ to: entityId2,
579
+ },
580
+ ],
581
+ };
582
+ const binary = encodeEdit(edit);
583
+ const decoded = decodeEdit(binary);
584
+ expect(decoded.name).toBe('multi-op test');
585
+ expect(decoded.ops.length).toBe(3);
586
+ expect(decoded.ops[0]?.type).toBe('createEntity');
587
+ expect(decoded.ops[1]?.type).toBe('createEntity');
588
+ expect(decoded.ops[2]?.type).toBe('createRelation');
589
+ });
590
+ });
591
+ describe('edit metadata', () => {
592
+ it('preserves edit id', () => {
593
+ const editId = toGrcId('abcdef12345678901234567890abcdef');
594
+ const authorId = toGrcId('22222222222222222222222222222222');
595
+ const edit = {
596
+ id: editId,
597
+ name: 'test',
598
+ authors: [authorId],
599
+ createdAt: BigInt(1000000),
600
+ ops: [],
601
+ };
602
+ const binary = encodeEdit(edit);
603
+ const decoded = decodeEdit(binary);
604
+ expect(formatId(decoded.id)).toBe('abcdef12345678901234567890abcdef');
605
+ });
606
+ it('preserves multiple authors', () => {
607
+ const editId = toGrcId('11111111111111111111111111111111');
608
+ const authorId1 = toGrcId('22222222222222222222222222222222');
609
+ const authorId2 = toGrcId('33333333333333333333333333333333');
610
+ const edit = {
611
+ id: editId,
612
+ name: 'test',
613
+ authors: [authorId1, authorId2],
614
+ createdAt: BigInt(1000000),
615
+ ops: [],
616
+ };
617
+ const binary = encodeEdit(edit);
618
+ const decoded = decodeEdit(binary);
619
+ expect(decoded.authors.length).toBe(2);
620
+ const author0 = decoded.authors[0];
621
+ const author1 = decoded.authors[1];
622
+ if (!author0 || !author1)
623
+ throw new Error('Expected authors to be defined');
624
+ expect(formatId(author0)).toBe('22222222222222222222222222222222');
625
+ expect(formatId(author1)).toBe('33333333333333333333333333333333');
626
+ });
627
+ it('preserves createdAt timestamp', () => {
628
+ const editId = toGrcId('11111111111111111111111111111111');
629
+ const authorId = toGrcId('22222222222222222222222222222222');
630
+ const timestamp = BigInt(1705334400000000); // 2024-01-15 in microseconds
631
+ const edit = {
632
+ id: editId,
633
+ name: 'test',
634
+ authors: [authorId],
635
+ createdAt: timestamp,
636
+ ops: [],
637
+ };
638
+ const binary = encodeEdit(edit);
639
+ const decoded = decodeEdit(binary);
640
+ expect(decoded.createdAt).toBe(timestamp);
641
+ });
642
+ });
643
+ });
644
+ //# sourceMappingURL=encoding.test.js.map