@geoprotocol/geo-sdk 0.2.0 → 0.2.2
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.
- package/README.md +154 -161
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/src/full-flow-test.test.js +12 -34
- package/dist/src/full-flow-test.test.js.map +1 -1
- package/dist/src/id.d.ts.map +1 -1
- package/dist/src/id.js +3 -8
- package/dist/src/id.js.map +1 -1
- package/dist/src/internal/uuid.d.ts +1 -0
- package/dist/src/internal/uuid.d.ts.map +1 -1
- package/dist/src/internal/uuid.js +1 -1
- package/dist/src/internal/uuid.js.map +1 -1
- package/dist/src/personal-space/constants.d.ts +4 -0
- package/dist/src/personal-space/constants.d.ts.map +1 -0
- package/dist/src/personal-space/constants.js +5 -0
- package/dist/src/personal-space/constants.js.map +1 -0
- package/dist/src/personal-space/create-space.d.ts +25 -0
- package/dist/src/personal-space/create-space.d.ts.map +1 -0
- package/dist/src/personal-space/create-space.js +31 -0
- package/dist/src/personal-space/create-space.js.map +1 -0
- package/dist/src/personal-space/create-space.test.d.ts +2 -0
- package/dist/src/personal-space/create-space.test.d.ts.map +1 -0
- package/dist/src/personal-space/create-space.test.js +26 -0
- package/dist/src/personal-space/create-space.test.js.map +1 -0
- package/dist/src/personal-space/index.d.ts +4 -0
- package/dist/src/personal-space/index.d.ts.map +1 -0
- package/dist/src/personal-space/index.js +3 -0
- package/dist/src/personal-space/index.js.map +1 -0
- package/dist/src/personal-space/publish-edit.d.ts +29 -0
- package/dist/src/personal-space/publish-edit.d.ts.map +1 -0
- package/dist/src/personal-space/publish-edit.js +73 -0
- package/dist/src/personal-space/publish-edit.js.map +1 -0
- package/dist/src/personal-space/publish-edit.test.d.ts +2 -0
- package/dist/src/personal-space/publish-edit.test.d.ts.map +1 -0
- package/dist/src/personal-space/publish-edit.test.js +124 -0
- package/dist/src/personal-space/publish-edit.test.js.map +1 -0
- package/dist/src/personal-space/types.d.ts +21 -0
- package/dist/src/personal-space/types.d.ts.map +1 -0
- package/dist/src/personal-space/types.js +2 -0
- package/dist/src/personal-space/types.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ When writing data, these ops are grouped into a logical set called an "Edit." An
|
|
|
46
46
|
Entities throughout The Graph are referenced via globally unique identifiers. The SDK exposes APIs for creating these IDs.
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
|
-
import { Id } from
|
|
49
|
+
import { Id } from "@geoprotocol/geo-sdk";
|
|
50
50
|
|
|
51
51
|
const newId = Id.generate();
|
|
52
52
|
```
|
|
@@ -105,34 +105,34 @@ const { id: restaurantId, ops: createRestaurantOps } = Graph.createEntity({
|
|
|
105
105
|
Values are passed as typed objects with a `type` field that determines the value format:
|
|
106
106
|
|
|
107
107
|
```ts
|
|
108
|
-
import { Graph, Id } from
|
|
108
|
+
import { Graph, Id } from "@geoprotocol/geo-sdk";
|
|
109
109
|
|
|
110
110
|
const { id: personId, ops: createPersonOps } = Graph.createEntity({
|
|
111
111
|
values: [
|
|
112
112
|
// Text value (with optional language)
|
|
113
113
|
{
|
|
114
114
|
property: someTextPropertyId,
|
|
115
|
-
type:
|
|
116
|
-
value:
|
|
117
|
-
language: Id(
|
|
115
|
+
type: "text",
|
|
116
|
+
value: "Hello",
|
|
117
|
+
language: Id("dad6e52a5e944e559411cfe3a3c3ea64"), // optional
|
|
118
118
|
},
|
|
119
119
|
// Number value (with optional unit)
|
|
120
120
|
{
|
|
121
121
|
property: someNumberPropertyId,
|
|
122
|
-
type:
|
|
122
|
+
type: "float64",
|
|
123
123
|
value: 42.5,
|
|
124
|
-
unit: Id(
|
|
124
|
+
unit: Id("016c9b1cd8a84e4d9e844e40878bb235"), // optional
|
|
125
125
|
},
|
|
126
126
|
// Boolean value
|
|
127
127
|
{
|
|
128
128
|
property: someBooleanPropertyId,
|
|
129
|
-
type:
|
|
129
|
+
type: "bool",
|
|
130
130
|
value: true,
|
|
131
131
|
},
|
|
132
132
|
// Point value (with optional altitude)
|
|
133
133
|
{
|
|
134
134
|
property: somePointPropertyId,
|
|
135
|
-
type:
|
|
135
|
+
type: "point",
|
|
136
136
|
lon: -122.4194,
|
|
137
137
|
lat: 37.7749,
|
|
138
138
|
alt: 10.5, // optional
|
|
@@ -140,98 +140,101 @@ const { id: personId, ops: createPersonOps } = Graph.createEntity({
|
|
|
140
140
|
// Date value (ISO 8601 format: YYYY-MM-DD)
|
|
141
141
|
{
|
|
142
142
|
property: someDatePropertyId,
|
|
143
|
-
type:
|
|
144
|
-
value:
|
|
143
|
+
type: "date",
|
|
144
|
+
value: "2024-01-15",
|
|
145
145
|
},
|
|
146
146
|
// Time value (ISO 8601 format with timezone)
|
|
147
147
|
{
|
|
148
148
|
property: someTimePropertyId,
|
|
149
|
-
type:
|
|
150
|
-
value:
|
|
149
|
+
type: "time",
|
|
150
|
+
value: "14:30:00Z",
|
|
151
151
|
},
|
|
152
152
|
// Datetime value (ISO 8601 combined format)
|
|
153
153
|
{
|
|
154
154
|
property: someDatetimePropertyId,
|
|
155
|
-
type:
|
|
156
|
-
value:
|
|
155
|
+
type: "datetime",
|
|
156
|
+
value: "2024-01-15T14:30:00Z",
|
|
157
157
|
},
|
|
158
158
|
// Schedule value (iCalendar RRULE format)
|
|
159
159
|
{
|
|
160
160
|
property: someSchedulePropertyId,
|
|
161
|
-
type:
|
|
162
|
-
value:
|
|
161
|
+
type: "schedule",
|
|
162
|
+
value: "FREQ=WEEKLY;BYDAY=MO,WE,FR",
|
|
163
163
|
},
|
|
164
|
-
]
|
|
164
|
+
],
|
|
165
165
|
});
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
#### Example Flow
|
|
169
169
|
|
|
170
170
|
```ts
|
|
171
|
-
import { Graph, type Op } from
|
|
171
|
+
import { Graph, type Op } from "@geoprotocol/geo-sdk";
|
|
172
172
|
|
|
173
173
|
const ops: Array<Op> = [];
|
|
174
174
|
|
|
175
175
|
// create an age property
|
|
176
176
|
const { id: agePropertyId, ops: createAgePropertyOps } = Graph.createProperty({
|
|
177
|
-
dataType:
|
|
178
|
-
name:
|
|
177
|
+
dataType: "INT64",
|
|
178
|
+
name: "Age",
|
|
179
179
|
});
|
|
180
180
|
ops.push(...createAgePropertyOps);
|
|
181
181
|
|
|
182
182
|
// create a likes property
|
|
183
|
-
const { id: likesPropertyId, ops: createLikesPropertyOps } =
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
const { id: likesPropertyId, ops: createLikesPropertyOps } =
|
|
184
|
+
Graph.createProperty({
|
|
185
|
+
dataType: "RELATION",
|
|
186
|
+
name: "Likes",
|
|
187
|
+
});
|
|
187
188
|
ops.push(...createLikesPropertyOps);
|
|
188
189
|
|
|
189
190
|
// create a person type
|
|
190
191
|
const { id: personTypeId, ops: createPersonTypeOps } = Graph.createType({
|
|
191
|
-
name:
|
|
192
|
+
name: "Person",
|
|
192
193
|
cover: personCoverId,
|
|
193
194
|
properties: [agePropertyId, likesPropertyId],
|
|
194
195
|
});
|
|
195
196
|
ops.push(...createPersonTypeOps);
|
|
196
197
|
|
|
197
198
|
// create an restaurant cover image
|
|
198
|
-
const { id: restaurantCoverId, ops: createRestaurantCoverOps } =
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
const { id: restaurantCoverId, ops: createRestaurantCoverOps } =
|
|
200
|
+
await Graph.createImage({
|
|
201
|
+
url: "https://example.com/image.png",
|
|
202
|
+
});
|
|
201
203
|
ops.push(...createRestaurantCoverOps);
|
|
202
204
|
|
|
203
205
|
// create a restaurant entity with a website property
|
|
204
|
-
const restaurantTypeId =
|
|
206
|
+
const restaurantTypeId = "A9QizqoXSqjfPUBjLoPJa2";
|
|
205
207
|
const { id: restaurantId, ops: createRestaurantOps } = Graph.createEntity({
|
|
206
|
-
name:
|
|
207
|
-
description:
|
|
208
|
+
name: "Yum Yum",
|
|
209
|
+
description: "A restaurant serving fusion cuisine",
|
|
208
210
|
cover: restaurantCoverId,
|
|
209
211
|
types: [restaurantTypeId],
|
|
210
212
|
values: [
|
|
211
213
|
{
|
|
212
214
|
property: WEBSITE_PROPERTY,
|
|
213
|
-
type:
|
|
214
|
-
value:
|
|
215
|
+
type: "text",
|
|
216
|
+
value: "https://example.com",
|
|
215
217
|
},
|
|
216
218
|
],
|
|
217
219
|
});
|
|
218
220
|
ops.push(...createRestaurantOps);
|
|
219
221
|
|
|
220
222
|
// create a person cover image
|
|
221
|
-
const { id: personCoverId, ops: createPersonCoverOps } =
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
const { id: personCoverId, ops: createPersonCoverOps } =
|
|
224
|
+
await Graph.createImage({
|
|
225
|
+
url: "https://example.com/avatar.png",
|
|
226
|
+
});
|
|
224
227
|
ops.push(...createPersonCoverOps);
|
|
225
228
|
|
|
226
229
|
// create a person entity with a likes relation to the restaurant entity
|
|
227
230
|
const { id: personId, ops: createPersonOps } = Graph.createEntity({
|
|
228
|
-
name:
|
|
231
|
+
name: "Jane Doe",
|
|
229
232
|
types: [personTypeId],
|
|
230
233
|
cover: personCoverId,
|
|
231
234
|
values: [
|
|
232
235
|
{
|
|
233
236
|
property: agePropertyId,
|
|
234
|
-
type:
|
|
237
|
+
type: "float64",
|
|
235
238
|
value: 42,
|
|
236
239
|
},
|
|
237
240
|
],
|
|
@@ -250,19 +253,19 @@ Once you have a set of ops ready to publish, you'll need to binary encode them i
|
|
|
250
253
|
|
|
251
254
|
Currently the indexer only supports reading a specific gateway. You should use our IPFS API to guarantee data availability for your published data while in early access.
|
|
252
255
|
|
|
253
|
-
Additionally, the indexer expects that IPFS CIDs be prefixed with `ipfs://` so it knows how to process it correctly. The API already returns the CID prefixed with `ipfs://`.
|
|
256
|
+
Additionally, the indexer expects that IPFS CIDs be prefixed with `ipfs://` so it knows how to process it correctly. The API already returns the CID prefixed with `ipfs://`.
|
|
254
257
|
|
|
255
258
|
We've abstracted the IPFS publishing and binary encoding into a single API.
|
|
256
259
|
|
|
257
260
|
```ts
|
|
258
|
-
import { Ipfs } from
|
|
261
|
+
import { Ipfs } from "@geoprotocol/geo-sdk";
|
|
259
262
|
|
|
260
263
|
const { cid, editId } = await Ipfs.publishEdit({
|
|
261
|
-
name:
|
|
264
|
+
name: "Edit name",
|
|
262
265
|
ops: ops,
|
|
263
|
-
author:
|
|
264
|
-
network:
|
|
265
|
-
})
|
|
266
|
+
author: "0x000000000000000000000000000000000000",
|
|
267
|
+
network: "TESTNET", // TESTNET (defaults to TESTNET)
|
|
268
|
+
});
|
|
266
269
|
```
|
|
267
270
|
|
|
268
271
|
### Publishing an edit onchain using SpaceRegistry
|
|
@@ -270,34 +273,43 @@ const { cid, editId } = await Ipfs.publishEdit({
|
|
|
270
273
|
Once you've uploaded the binary encoded Edit to IPFS and have correctly formed `ipfs://hash`, you can write this to a space using the SpaceRegistry contract.
|
|
271
274
|
|
|
272
275
|
```ts
|
|
273
|
-
import {
|
|
274
|
-
|
|
276
|
+
import {
|
|
277
|
+
createPublicClient,
|
|
278
|
+
encodeAbiParameters,
|
|
279
|
+
encodeFunctionData,
|
|
280
|
+
type Hex,
|
|
281
|
+
http,
|
|
282
|
+
keccak256,
|
|
283
|
+
toHex,
|
|
284
|
+
} from "viem";
|
|
285
|
+
import { SpaceRegistryAbi, getWalletClient } from "@geoprotocol/geo-sdk";
|
|
275
286
|
|
|
276
287
|
// Contract addresses for testnet
|
|
277
|
-
const SPACE_REGISTRY_ADDRESS =
|
|
278
|
-
|
|
288
|
+
const SPACE_REGISTRY_ADDRESS =
|
|
289
|
+
"0xB01683b2f0d38d43fcD4D9aAB980166988924132" as const;
|
|
290
|
+
const EDITS_PUBLISHED = keccak256(toHex("GOVERNANCE.EDITS_PUBLISHED"));
|
|
279
291
|
|
|
280
292
|
// You'll need your space ID in hex format (bytes16) and an IPFS CID
|
|
281
|
-
const spaceIdHex =
|
|
282
|
-
const cid =
|
|
293
|
+
const spaceIdHex = "0x..." as Hex; // bytes16 space ID
|
|
294
|
+
const cid = "ipfs://hash";
|
|
283
295
|
|
|
284
296
|
const walletClient = await getWalletClient({
|
|
285
297
|
privateKey: addressPrivateKey,
|
|
286
298
|
});
|
|
287
299
|
|
|
288
300
|
// Encode the CID as a single string
|
|
289
|
-
const enterData = encodeAbiParameters([{ type:
|
|
301
|
+
const enterData = encodeAbiParameters([{ type: "string" }], [cid]);
|
|
290
302
|
|
|
291
303
|
const calldata = encodeFunctionData({
|
|
292
304
|
abi: SpaceRegistryAbi,
|
|
293
|
-
functionName:
|
|
305
|
+
functionName: "enter",
|
|
294
306
|
args: [
|
|
295
307
|
spaceIdHex, // fromSpaceId (bytes16)
|
|
296
308
|
spaceIdHex, // toSpaceId (bytes16)
|
|
297
309
|
EDITS_PUBLISHED, // action
|
|
298
|
-
|
|
310
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000" as Hex, // topic
|
|
299
311
|
enterData, // data
|
|
300
|
-
|
|
312
|
+
"0x" as Hex, // signature (empty for direct calls)
|
|
301
313
|
],
|
|
302
314
|
});
|
|
303
315
|
|
|
@@ -312,12 +324,12 @@ const txResult = await walletClient.sendTransaction({
|
|
|
312
324
|
### Getting a wallet client
|
|
313
325
|
|
|
314
326
|
```ts
|
|
315
|
-
import { privateKeyToAccount } from
|
|
327
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
316
328
|
import { getWalletClient } from "@geoprotocol/geo-sdk";
|
|
317
329
|
|
|
318
330
|
// IMPORTANT: Be careful with your private key. Don't commit it to version control.
|
|
319
331
|
// You can get your private key using https://www.geobrowser.io/export-wallet
|
|
320
|
-
const addressPrivateKey =
|
|
332
|
+
const addressPrivateKey = "0xTODO";
|
|
321
333
|
const { address } = privateKeyToAccount(addressPrivateKey);
|
|
322
334
|
|
|
323
335
|
// Take the address and enter it in Faucet to get some testnet ETH https://faucet.conduit.xyz/geo-test-zc16z3tcvf
|
|
@@ -336,7 +348,7 @@ To use `getSmartAccountWalletClient` you'll need the private key associated with
|
|
|
336
348
|
Transaction costs from your smart account will be sponsored by the Geo team for the duration of the early access period. Eventually you will need to provide your own API key or provide funds to your smart account.
|
|
337
349
|
|
|
338
350
|
```ts
|
|
339
|
-
import { getSmartAccountWalletClient } from
|
|
351
|
+
import { getSmartAccountWalletClient } from "@geoprotocol/geo-sdk";
|
|
340
352
|
|
|
341
353
|
// IMPORTANT: Be careful with your private key. Don't commit it to version control.
|
|
342
354
|
// You can get your private key using https://www.geobrowser.io/export-wallet
|
|
@@ -347,84 +359,84 @@ const smartAccountWalletClient = await getSmartAccountWalletClient({
|
|
|
347
359
|
});
|
|
348
360
|
```
|
|
349
361
|
|
|
350
|
-
###
|
|
362
|
+
### Personal Spaces
|
|
351
363
|
|
|
352
|
-
|
|
364
|
+
Personal spaces are owned by a single address and don't require voting for governance. The SDK provides a `personalSpace` module with helper functions for creating and publishing to personal spaces.
|
|
353
365
|
|
|
354
|
-
|
|
355
|
-
import { createPublicClient, encodeAbiParameters, encodeFunctionData, type Hex, http, keccak256, toHex } from 'viem';
|
|
356
|
-
import { SpaceRegistryAbi, getWalletClient } from '@geoprotocol/geo-sdk';
|
|
366
|
+
#### Creating a personal space
|
|
357
367
|
|
|
358
|
-
|
|
359
|
-
|
|
368
|
+
```ts
|
|
369
|
+
import { personalSpace, getWalletClient } from "@geoprotocol/geo-sdk";
|
|
360
370
|
|
|
361
371
|
const walletClient = await getWalletClient({
|
|
362
372
|
privateKey: addressPrivateKey,
|
|
363
373
|
});
|
|
364
374
|
|
|
365
|
-
|
|
366
|
-
const
|
|
375
|
+
// Get the calldata for creating a personal space
|
|
376
|
+
const { to, calldata } = personalSpace.createSpace();
|
|
367
377
|
|
|
368
|
-
|
|
369
|
-
|
|
378
|
+
// Submit the transaction
|
|
379
|
+
const txHash = await walletClient.sendTransaction({
|
|
380
|
+
account: walletClient.account,
|
|
381
|
+
to,
|
|
382
|
+
data: calldata,
|
|
370
383
|
});
|
|
384
|
+
```
|
|
371
385
|
|
|
372
|
-
|
|
373
|
-
let spaceIdHex = await publicClient.readContract({
|
|
374
|
-
address: SPACE_REGISTRY_ADDRESS,
|
|
375
|
-
abi: SpaceRegistryAbi,
|
|
376
|
-
functionName: 'addressToSpaceId',
|
|
377
|
-
args: [account.address],
|
|
378
|
-
}) as Hex;
|
|
386
|
+
#### Publishing an edit to a personal space
|
|
379
387
|
|
|
380
|
-
|
|
381
|
-
if (spaceIdHex.toLowerCase() === EMPTY_SPACE_ID.toLowerCase()) {
|
|
382
|
-
const createSpaceTxHash = await walletClient.sendTransaction({
|
|
383
|
-
account: walletClient.account,
|
|
384
|
-
to: SPACE_REGISTRY_ADDRESS,
|
|
385
|
-
value: 0n,
|
|
386
|
-
data: encodeFunctionData({
|
|
387
|
-
abi: SpaceRegistryAbi,
|
|
388
|
-
functionName: 'registerSpaceId',
|
|
389
|
-
args: [
|
|
390
|
-
keccak256(toHex('EOA_SPACE')), // _type
|
|
391
|
-
encodeAbiParameters([{ type: 'string' }], ['1.0.0']), // _version
|
|
392
|
-
],
|
|
393
|
-
}),
|
|
394
|
-
});
|
|
388
|
+
The `personalSpace.publishEdit()` function handles both IPFS upload and calldata encoding in a single call:
|
|
395
389
|
|
|
396
|
-
|
|
390
|
+
```ts
|
|
391
|
+
import { personalSpace, Graph, getWalletClient } from "@geoprotocol/geo-sdk";
|
|
397
392
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
abi: SpaceRegistryAbi,
|
|
402
|
-
functionName: 'addressToSpaceId',
|
|
403
|
-
args: [account.address],
|
|
404
|
-
}) as Hex;
|
|
405
|
-
}
|
|
393
|
+
const walletClient = await getWalletClient({
|
|
394
|
+
privateKey: addressPrivateKey,
|
|
395
|
+
});
|
|
406
396
|
|
|
407
|
-
//
|
|
408
|
-
const
|
|
397
|
+
// Create some ops
|
|
398
|
+
const { ops } = Graph.createEntity({
|
|
399
|
+
name: "Test Entity",
|
|
400
|
+
description: "Created via SDK",
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// Publish to IPFS and get calldata for on-chain submission
|
|
404
|
+
const { editId, cid, to, calldata } = await personalSpace.publishEdit({
|
|
405
|
+
name: "My Edit",
|
|
406
|
+
spaceId: "your-space-id", // 32-char hex string from on-chain
|
|
407
|
+
ops,
|
|
408
|
+
author: walletClient.account.address,
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
// Submit the transaction
|
|
412
|
+
const txHash = await walletClient.sendTransaction({
|
|
413
|
+
account: walletClient.account,
|
|
414
|
+
to,
|
|
415
|
+
data: calldata,
|
|
416
|
+
});
|
|
409
417
|
```
|
|
410
418
|
|
|
411
419
|
## Full Publishing Flow
|
|
412
420
|
|
|
413
|
-
This example shows the complete flow for creating a personal space and publishing an edit on testnet.
|
|
421
|
+
This example shows the complete flow for creating a personal space and publishing an edit on testnet using the `personalSpace` module.
|
|
414
422
|
|
|
415
423
|
```ts
|
|
416
|
-
import { createPublicClient,
|
|
417
|
-
import { privateKeyToAccount } from
|
|
418
|
-
import {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
+
import { createPublicClient, type Hex, http } from "viem";
|
|
425
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
426
|
+
import {
|
|
427
|
+
Graph,
|
|
428
|
+
personalSpace,
|
|
429
|
+
getWalletClient,
|
|
430
|
+
SpaceRegistryAbi,
|
|
431
|
+
} from "@geoprotocol/geo-sdk";
|
|
432
|
+
|
|
433
|
+
const SPACE_REGISTRY_ADDRESS =
|
|
434
|
+
"0xB01683b2f0d38d43fcD4D9aAB980166988924132" as const;
|
|
435
|
+
const EMPTY_SPACE_ID = "0x00000000000000000000000000000000" as Hex;
|
|
424
436
|
|
|
425
437
|
// IMPORTANT: Be careful with your private key. Don't commit it to version control.
|
|
426
438
|
// You can get your private key using https://www.geobrowser.io/export-wallet
|
|
427
|
-
const addressPrivateKey =
|
|
439
|
+
const addressPrivateKey = "0xTODO" as `0x${string}`;
|
|
428
440
|
const { address } = privateKeyToAccount(addressPrivateKey);
|
|
429
441
|
|
|
430
442
|
// Take the address and enter it in Faucet to get some testnet ETH https://faucet.conduit.xyz/geo-test-zc16z3tcvf
|
|
@@ -442,87 +454,68 @@ const publicClient = createPublicClient({
|
|
|
442
454
|
});
|
|
443
455
|
|
|
444
456
|
// Check if a personal space already exists for this address
|
|
445
|
-
let spaceIdHex = await publicClient.readContract({
|
|
457
|
+
let spaceIdHex = (await publicClient.readContract({
|
|
446
458
|
address: SPACE_REGISTRY_ADDRESS,
|
|
447
459
|
abi: SpaceRegistryAbi,
|
|
448
|
-
functionName:
|
|
460
|
+
functionName: "addressToSpaceId",
|
|
449
461
|
args: [account.address],
|
|
450
|
-
}) as Hex;
|
|
462
|
+
})) as Hex;
|
|
451
463
|
|
|
452
464
|
// Create a personal space if one doesn't exist
|
|
453
465
|
if (spaceIdHex.toLowerCase() === EMPTY_SPACE_ID.toLowerCase()) {
|
|
454
|
-
console.log(
|
|
466
|
+
console.log("Creating personal space...");
|
|
467
|
+
|
|
468
|
+
const { to, calldata } = personalSpace.createSpace();
|
|
455
469
|
|
|
456
470
|
const createSpaceTxHash = await walletClient.sendTransaction({
|
|
457
471
|
account: walletClient.account,
|
|
458
|
-
to
|
|
459
|
-
|
|
460
|
-
data: encodeFunctionData({
|
|
461
|
-
abi: SpaceRegistryAbi,
|
|
462
|
-
functionName: 'registerSpaceId',
|
|
463
|
-
args: [
|
|
464
|
-
keccak256(toHex('EOA_SPACE')), // _type
|
|
465
|
-
encodeAbiParameters([{ type: 'string' }], ['1.0.0']), // _version
|
|
466
|
-
],
|
|
467
|
-
}),
|
|
472
|
+
to,
|
|
473
|
+
data: calldata,
|
|
468
474
|
});
|
|
469
475
|
|
|
470
476
|
await publicClient.waitForTransactionReceipt({ hash: createSpaceTxHash });
|
|
471
477
|
|
|
472
478
|
// Re-fetch the space ID after creation
|
|
473
|
-
spaceIdHex = await publicClient.readContract({
|
|
479
|
+
spaceIdHex = (await publicClient.readContract({
|
|
474
480
|
address: SPACE_REGISTRY_ADDRESS,
|
|
475
481
|
abi: SpaceRegistryAbi,
|
|
476
|
-
functionName:
|
|
482
|
+
functionName: "addressToSpaceId",
|
|
477
483
|
args: [account.address],
|
|
478
|
-
}) as Hex;
|
|
484
|
+
})) as Hex;
|
|
479
485
|
}
|
|
480
486
|
|
|
481
487
|
// Convert bytes16 hex to UUID string (without dashes)
|
|
482
488
|
const spaceId = spaceIdHex.slice(2, 34).toLowerCase();
|
|
483
|
-
console.log(
|
|
489
|
+
console.log("spaceId", spaceId);
|
|
484
490
|
|
|
485
491
|
// Create an entity with some data
|
|
486
492
|
const { ops, id: entityId } = Graph.createEntity({
|
|
487
|
-
name:
|
|
488
|
-
description:
|
|
493
|
+
name: "Test Entity",
|
|
494
|
+
description: "Created via SDK",
|
|
489
495
|
});
|
|
490
|
-
console.log(
|
|
496
|
+
console.log("entityId", entityId);
|
|
491
497
|
|
|
492
|
-
// Publish
|
|
493
|
-
const { cid, editId } = await
|
|
494
|
-
name:
|
|
498
|
+
// Publish to IPFS and get calldata for on-chain submission
|
|
499
|
+
const { cid, editId, to, calldata } = await personalSpace.publishEdit({
|
|
500
|
+
name: "Test Edit",
|
|
501
|
+
spaceId,
|
|
495
502
|
ops,
|
|
496
503
|
author: account.address,
|
|
497
|
-
network:
|
|
498
|
-
});
|
|
499
|
-
console.log('cid', cid);
|
|
500
|
-
console.log('editId', editId);
|
|
501
|
-
|
|
502
|
-
// Publish edit on-chain via SpaceRegistry.enter(...)
|
|
503
|
-
const enterData = encodeAbiParameters([{ type: 'string' }], [cid]);
|
|
504
|
-
|
|
505
|
-
const calldata = encodeFunctionData({
|
|
506
|
-
abi: SpaceRegistryAbi,
|
|
507
|
-
functionName: 'enter',
|
|
508
|
-
args: [
|
|
509
|
-
spaceIdHex, // fromSpaceId (bytes16)
|
|
510
|
-
spaceIdHex, // toSpaceId (bytes16)
|
|
511
|
-
EDITS_PUBLISHED, // action
|
|
512
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000' as Hex, // topic
|
|
513
|
-
enterData, // data
|
|
514
|
-
'0x' as Hex, // signature (empty for direct calls)
|
|
515
|
-
],
|
|
504
|
+
network: "TESTNET",
|
|
516
505
|
});
|
|
506
|
+
console.log("cid", cid);
|
|
507
|
+
console.log("editId", editId);
|
|
517
508
|
|
|
509
|
+
// Submit the edit on-chain
|
|
518
510
|
const publishTxHash = await walletClient.sendTransaction({
|
|
519
511
|
account: walletClient.account,
|
|
520
|
-
to
|
|
521
|
-
value: 0n,
|
|
512
|
+
to,
|
|
522
513
|
data: calldata,
|
|
523
514
|
});
|
|
524
|
-
console.log(
|
|
515
|
+
console.log("publishTxHash", publishTxHash);
|
|
525
516
|
|
|
526
|
-
const publishReceipt = await publicClient.waitForTransactionReceipt({
|
|
527
|
-
|
|
528
|
-
|
|
517
|
+
const publishReceipt = await publicClient.waitForTransactionReceipt({
|
|
518
|
+
hash: publishTxHash,
|
|
519
|
+
});
|
|
520
|
+
console.log("Successfully published edit to space", spaceId);
|
|
521
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,12 @@ export * as IdUtils from './src/id-utils.js';
|
|
|
28
28
|
* @since 0.1.1
|
|
29
29
|
*/
|
|
30
30
|
export * as Ipfs from './src/ipfs.js';
|
|
31
|
+
/**
|
|
32
|
+
* This module provides functions for creating and managing personal spaces.
|
|
33
|
+
*
|
|
34
|
+
* @since 0.2.0
|
|
35
|
+
*/
|
|
36
|
+
export * as personalSpace from './src/personal-space/index.js';
|
|
31
37
|
export { Position } from './src/position.js';
|
|
32
38
|
/**
|
|
33
39
|
* This module provides utility functions for working with ranks in the Knowledge Graph.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE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AAoC,CAAC;AACxE,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC;;;;GAIG;AACH,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAErF;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxE,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,12 @@ export * as IdUtils from './src/id-utils.js';
|
|
|
28
28
|
* @since 0.1.1
|
|
29
29
|
*/
|
|
30
30
|
export * as Ipfs from './src/ipfs.js';
|
|
31
|
+
/**
|
|
32
|
+
* This module provides functions for creating and managing personal spaces.
|
|
33
|
+
*
|
|
34
|
+
* @since 0.2.0
|
|
35
|
+
*/
|
|
36
|
+
export * as personalSpace from './src/personal-space/index.js';
|
|
31
37
|
export { Position } from './src/position.js';
|
|
32
38
|
/**
|
|
33
39
|
* This module provides utility functions for working with ranks in the Knowledge Graph.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAErF;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxE,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC;;;;GAIG;AACH,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAE7C;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAErF;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxE,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { createPublicClient,
|
|
1
|
+
import { createPublicClient, http } from 'viem';
|
|
2
2
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
3
|
import { it } from 'vitest';
|
|
4
4
|
import { SpaceRegistryAbi } from './abis/index.js';
|
|
5
5
|
import { createEntity } from './graph/create-entity.js';
|
|
6
|
-
import
|
|
6
|
+
import * as personalSpace from './personal-space/index.js';
|
|
7
7
|
import { getWalletClient } from './smart-wallet.js';
|
|
8
8
|
// Contract addresses for testnet
|
|
9
|
-
// Note: These should be imported from contracts.ts once it's exported
|
|
10
9
|
const SPACE_REGISTRY_ADDRESS = '0xB01683b2f0d38d43fcD4D9aAB980166988924132';
|
|
11
10
|
const EMPTY_SPACE_ID = '0x00000000000000000000000000000000';
|
|
12
11
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
13
|
-
// Action constants
|
|
14
|
-
const EDITS_PUBLISHED = keccak256(toHex('GOVERNANCE.EDITS_PUBLISHED'));
|
|
15
12
|
/**
|
|
16
13
|
* Converts a bytes16 hex space ID to a UUID string (without dashes).
|
|
17
14
|
*/
|
|
@@ -52,19 +49,13 @@ it.skip('should create a space and publish an edit', async () => {
|
|
|
52
49
|
// Create a personal space if one doesn't exist
|
|
53
50
|
if (spaceIdHex.toLowerCase() === EMPTY_SPACE_ID.toLowerCase()) {
|
|
54
51
|
console.log('Creating personal space...');
|
|
52
|
+
const { to, calldata } = personalSpace.createSpace();
|
|
55
53
|
const createSpaceTxHash = await walletClient.sendTransaction({
|
|
56
54
|
// @ts-expect-error - viem type mismatch for account
|
|
57
55
|
account: walletClient.account,
|
|
58
|
-
to
|
|
56
|
+
to,
|
|
59
57
|
value: 0n,
|
|
60
|
-
data:
|
|
61
|
-
abi: SpaceRegistryAbi,
|
|
62
|
-
functionName: 'registerSpaceId',
|
|
63
|
-
args: [
|
|
64
|
-
keccak256(toHex('EOA_SPACE')), // _type
|
|
65
|
-
encodeAbiParameters([{ type: 'string' }], ['1.0.0']), // _version
|
|
66
|
-
],
|
|
67
|
-
}),
|
|
58
|
+
data: calldata,
|
|
68
59
|
});
|
|
69
60
|
console.log('createSpaceTxHash', createSpaceTxHash);
|
|
70
61
|
await publicClient.waitForTransactionReceipt({ hash: createSpaceTxHash });
|
|
@@ -99,40 +90,27 @@ it.skip('should create a space and publish an edit', async () => {
|
|
|
99
90
|
description: 'Created via full-flow test',
|
|
100
91
|
});
|
|
101
92
|
console.log('entityId', entityId);
|
|
102
|
-
// Publish the edit to IPFS
|
|
103
|
-
const { cid, editId } = await publishEdit({
|
|
93
|
+
// Publish the edit to IPFS and get calldata for on-chain submission
|
|
94
|
+
const { cid, editId, to, calldata } = await personalSpace.publishEdit({
|
|
104
95
|
name: 'Test Edit',
|
|
96
|
+
spaceId,
|
|
105
97
|
ops,
|
|
106
98
|
author: account.address,
|
|
107
99
|
network: 'TESTNET',
|
|
108
100
|
});
|
|
109
101
|
console.log('cid', cid);
|
|
110
102
|
console.log('editId', editId);
|
|
111
|
-
// Publish edit on-chain via SpaceRegistry.enter(...)
|
|
112
|
-
// SpaceRegistry.enter expects `bytes data`; we ABI-encode the CID as a single string
|
|
113
|
-
const enterData = encodeAbiParameters([{ type: 'string' }], [cid]);
|
|
114
|
-
const calldata = encodeFunctionData({
|
|
115
|
-
abi: SpaceRegistryAbi,
|
|
116
|
-
functionName: 'enter',
|
|
117
|
-
args: [
|
|
118
|
-
spaceIdHex, // fromSpaceId (bytes16)
|
|
119
|
-
spaceIdHex, // toSpaceId (bytes16)
|
|
120
|
-
EDITS_PUBLISHED, // action
|
|
121
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', // topic
|
|
122
|
-
enterData, // data
|
|
123
|
-
'0x',
|
|
124
|
-
],
|
|
125
|
-
});
|
|
126
103
|
const publishTxHash = await walletClient.sendTransaction({
|
|
127
104
|
// @ts-expect-error - viem type mismatch for account
|
|
128
105
|
account: walletClient.account,
|
|
129
106
|
chain: walletClient.chain ?? null,
|
|
130
|
-
to
|
|
131
|
-
value: 0n,
|
|
107
|
+
to,
|
|
132
108
|
data: calldata,
|
|
133
109
|
});
|
|
134
110
|
console.log('publishTxHash', publishTxHash);
|
|
135
|
-
const publishReceipt = await publicClient.waitForTransactionReceipt({
|
|
111
|
+
const publishReceipt = await publicClient.waitForTransactionReceipt({
|
|
112
|
+
hash: publishTxHash,
|
|
113
|
+
});
|
|
136
114
|
console.log('publishReceipt status', publishReceipt.status);
|
|
137
115
|
if (publishReceipt.status === 'reverted') {
|
|
138
116
|
throw new Error(`Publish transaction reverted: ${publishTxHash}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full-flow-test.test.js","sourceRoot":"","sources":["../../src/full-flow-test.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"full-flow-test.test.js","sourceRoot":"","sources":["../../src/full-flow-test.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAY,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,iCAAiC;AACjC,MAAM,sBAAsB,GAAG,4CAAqD,CAAC;AACrF,MAAM,cAAc,GAAG,oCAA2C,CAAC;AACnE,MAAM,YAAY,GAAG,4CAAmD,CAAC;AAEzE;;GAEG;AACH,SAAS,SAAS,CAAC,GAAQ;IACzB,gEAAgE;IAChE,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACxC,CAAC;AAED,EAAE,CAAC,IAAI,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;IAC9D,8DAA8D;IAC9D,6EAA6E;IAC7E,MAAM,iBAAiB,GAAG,QAAyB,CAAC;IACpD,MAAM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E,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC,EAAE,KAAK,CAAC,CAAC"}
|
package/dist/src/id.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAE5C,eAAO,MAAM,EAAE,6BAGd,CAAC;AAKF,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE3C"}
|
package/dist/src/id.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { Brand } from 'effect';
|
|
2
|
-
import { validate as uuidValidate } from 'uuid';
|
|
3
|
-
import { dashlessUuidToDashed } from './internal/uuid.js';
|
|
4
2
|
export const Id = Brand.refined(id => isValid(id), id => Brand.error(`Expected ${id} to be a valid Id`));
|
|
3
|
+
const UUID_DASHED_REGEX = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
4
|
+
const UUID_DASHLESS_REGEX = /^[0-9a-fA-F]{32}$/;
|
|
5
5
|
export function isValid(id) {
|
|
6
|
-
|
|
7
|
-
return true;
|
|
8
|
-
const dashed = dashlessUuidToDashed(id);
|
|
9
|
-
if (!dashed)
|
|
10
|
-
return false;
|
|
11
|
-
return uuidValidate(dashed);
|
|
6
|
+
return UUID_DASHED_REGEX.test(id) || UUID_DASHLESS_REGEX.test(id);
|
|
12
7
|
}
|
|
13
8
|
//# sourceMappingURL=id.js.map
|
package/dist/src/id.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAU/B,MAAM,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAC7B,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EACjB,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,mBAAmB,CAAC,CACrD,CAAC;AAEF,MAAM,iBAAiB,GAAG,+EAA+E,CAAC;AAC1G,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAEhD,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/internal/uuid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/internal/uuid.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,QAAsB,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG9D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/internal/uuid.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/internal/uuid.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAU;IAC7C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;AACxG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,EAAU;IAC9C,OAAO,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/personal-space/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,eAAiD,CAAC;AAC9E,eAAO,MAAM,WAAW,EAAG,oEAA6E,CAAC;AACzG,eAAO,MAAM,eAAe,EAAG,IAAa,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { keccak256, toHex } from 'viem';
|
|
2
|
+
export const EDITS_PUBLISHED = keccak256(toHex('GOVERNANCE.EDITS_PUBLISHED'));
|
|
3
|
+
export const EMPTY_TOPIC = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
4
|
+
export const EMPTY_SIGNATURE = '0x';
|
|
5
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/personal-space/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAExC,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,oEAA6E,CAAC;AACzG,MAAM,CAAC,MAAM,eAAe,GAAG,IAAa,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CreateSpaceResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the target address and calldata for creating a personal space.
|
|
4
|
+
*
|
|
5
|
+
* This function returns everything needed to submit a transaction that creates
|
|
6
|
+
* a personal space on the Space Registry contract.
|
|
7
|
+
*
|
|
8
|
+
* @returns Object containing `to` (contract address) and `calldata` for the transaction
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { personalSpace } from '@geoprotocol/geo-sdk';
|
|
13
|
+
* import { createWalletClient, http } from 'viem';
|
|
14
|
+
*
|
|
15
|
+
* const { to, calldata } = personalSpace.createSpace();
|
|
16
|
+
*
|
|
17
|
+
* // Using viem
|
|
18
|
+
* const hash = await walletClient.sendTransaction({
|
|
19
|
+
* to,
|
|
20
|
+
* data: calldata,
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSpace(): CreateSpaceResult;
|
|
25
|
+
//# sourceMappingURL=create-space.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-space.d.ts","sourceRoot":"","sources":["../../../src/personal-space/create-space.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,CAK/C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TESTNET } from '../../contracts.js';
|
|
2
|
+
import { getCreatePersonalSpaceCalldata } from '../encodings/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get the target address and calldata for creating a personal space.
|
|
5
|
+
*
|
|
6
|
+
* This function returns everything needed to submit a transaction that creates
|
|
7
|
+
* a personal space on the Space Registry contract.
|
|
8
|
+
*
|
|
9
|
+
* @returns Object containing `to` (contract address) and `calldata` for the transaction
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { personalSpace } from '@geoprotocol/geo-sdk';
|
|
14
|
+
* import { createWalletClient, http } from 'viem';
|
|
15
|
+
*
|
|
16
|
+
* const { to, calldata } = personalSpace.createSpace();
|
|
17
|
+
*
|
|
18
|
+
* // Using viem
|
|
19
|
+
* const hash = await walletClient.sendTransaction({
|
|
20
|
+
* to,
|
|
21
|
+
* data: calldata,
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function createSpace() {
|
|
26
|
+
return {
|
|
27
|
+
to: TESTNET.SPACE_REGISTRY_ADDRESS,
|
|
28
|
+
calldata: getCreatePersonalSpaceCalldata(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=create-space.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-space.js","sourceRoot":"","sources":["../../../src/personal-space/create-space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAGvE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,sBAAsB;QAClC,QAAQ,EAAE,8BAA8B,EAAE;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-space.test.d.ts","sourceRoot":"","sources":["../../../src/personal-space/create-space.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { TESTNET } from '../../contracts.js';
|
|
3
|
+
import { createSpace } from './create-space.js';
|
|
4
|
+
describe('createSpace', () => {
|
|
5
|
+
it('should return correct structure with to and calldata', () => {
|
|
6
|
+
const result = createSpace();
|
|
7
|
+
expect(result).toHaveProperty('to');
|
|
8
|
+
expect(result).toHaveProperty('calldata');
|
|
9
|
+
});
|
|
10
|
+
it('should return the correct contract address', () => {
|
|
11
|
+
const { to } = createSpace();
|
|
12
|
+
expect(to).toBe(TESTNET.SPACE_REGISTRY_ADDRESS);
|
|
13
|
+
});
|
|
14
|
+
it('should return valid calldata', () => {
|
|
15
|
+
const { calldata } = createSpace();
|
|
16
|
+
expect(calldata).toBeTypeOf('string');
|
|
17
|
+
expect(calldata.startsWith('0x')).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it('should return consistent results', () => {
|
|
20
|
+
const result1 = createSpace();
|
|
21
|
+
const result2 = createSpace();
|
|
22
|
+
expect(result1.to).toBe(result2.to);
|
|
23
|
+
expect(result1.calldata).toBe(result2.calldata);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=create-space.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-space.test.js","sourceRoot":"","sources":["../../../src/personal-space/create-space.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MA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Root":"","sources":["../../../src/personal-space/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/personal-space/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PublishEditParams, PublishEditResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Publish an edit to IPFS and get the calldata for submitting it on-chain.
|
|
4
|
+
*
|
|
5
|
+
* This function:
|
|
6
|
+
* 1. Validates the spaceId (accepts UUID or 32-char hex string)
|
|
7
|
+
* 2. Publishes the ops to IPFS using the GRC-20 binary format
|
|
8
|
+
* 3. Encodes the calldata for the Space Registry's `enter()` function
|
|
9
|
+
*
|
|
10
|
+
* @param params - The parameters for publishing the edit
|
|
11
|
+
* @returns Object containing `editId`, `cid`, `to` (contract address), and `calldata`
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { personalSpace, Graph } from '@geoprotocol/geo-sdk';
|
|
16
|
+
*
|
|
17
|
+
* const { ops } = Graph.createEntity({ name: 'Test' });
|
|
18
|
+
* const { editId, cid, to, calldata } = await personalSpace.publishEdit({
|
|
19
|
+
* name: 'Add entity',
|
|
20
|
+
* spaceId: 'your-space-id',
|
|
21
|
+
* ops,
|
|
22
|
+
* author: '0x...',
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* await walletClient.sendTransaction({ to, data: calldata });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function publishEdit(params: PublishEditParams): Promise<PublishEditResult>;
|
|
29
|
+
//# sourceMappingURL=publish-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-edit.d.ts","sourceRoot":"","sources":["../../../src/personal-space/publish-edit.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAsBvE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwBvF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { encodeFunctionData, stringToHex, toHex } from 'viem';
|
|
2
|
+
import { TESTNET } from '../../contracts.js';
|
|
3
|
+
import { SpaceRegistryAbi } from '../abis/index.js';
|
|
4
|
+
import { isValid } from '../id.js';
|
|
5
|
+
import { toBytes } from '../id-utils.js';
|
|
6
|
+
import { UUID_DASHLESS_REGEX } from '../internal/uuid.js';
|
|
7
|
+
import * as Ipfs from '../ipfs.js';
|
|
8
|
+
import { EDITS_PUBLISHED, EMPTY_SIGNATURE, EMPTY_TOPIC } from './constants.js';
|
|
9
|
+
/**
|
|
10
|
+
* Converts a spaceId to bytes16 hex format.
|
|
11
|
+
* Accepts either a valid UUID (Id type) or a 32-char hex string (on-chain bytes16).
|
|
12
|
+
*/
|
|
13
|
+
function spaceIdToBytes16(spaceId) {
|
|
14
|
+
// If it's a 32-char hex string (bytes16 from on-chain), use directly
|
|
15
|
+
// Check this first since on-chain space IDs may look like UUIDs but aren't valid ones
|
|
16
|
+
if (UUID_DASHLESS_REGEX.test(spaceId)) {
|
|
17
|
+
return `0x${spaceId.toLowerCase()}`;
|
|
18
|
+
}
|
|
19
|
+
// If it's a valid UUID (with dashes), use the standard toBytes conversion
|
|
20
|
+
if (isValid(spaceId)) {
|
|
21
|
+
const bytes = toBytes(spaceId);
|
|
22
|
+
return toHex(bytes);
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`Invalid spaceId: "${spaceId}". Expected a valid UUID or 32-character hex string.`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Publish an edit to IPFS and get the calldata for submitting it on-chain.
|
|
28
|
+
*
|
|
29
|
+
* This function:
|
|
30
|
+
* 1. Validates the spaceId (accepts UUID or 32-char hex string)
|
|
31
|
+
* 2. Publishes the ops to IPFS using the GRC-20 binary format
|
|
32
|
+
* 3. Encodes the calldata for the Space Registry's `enter()` function
|
|
33
|
+
*
|
|
34
|
+
* @param params - The parameters for publishing the edit
|
|
35
|
+
* @returns Object containing `editId`, `cid`, `to` (contract address), and `calldata`
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { personalSpace, Graph } from '@geoprotocol/geo-sdk';
|
|
40
|
+
*
|
|
41
|
+
* const { ops } = Graph.createEntity({ name: 'Test' });
|
|
42
|
+
* const { editId, cid, to, calldata } = await personalSpace.publishEdit({
|
|
43
|
+
* name: 'Add entity',
|
|
44
|
+
* spaceId: 'your-space-id',
|
|
45
|
+
* ops,
|
|
46
|
+
* author: '0x...',
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* await walletClient.sendTransaction({ to, data: calldata });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export async function publishEdit(params) {
|
|
53
|
+
const { name, spaceId, ops, author, network = 'TESTNET' } = params;
|
|
54
|
+
const spaceIdBytes16 = spaceIdToBytes16(spaceId);
|
|
55
|
+
const { cid, editId } = await Ipfs.publishEdit({
|
|
56
|
+
name,
|
|
57
|
+
ops,
|
|
58
|
+
author,
|
|
59
|
+
network,
|
|
60
|
+
});
|
|
61
|
+
const calldata = encodeFunctionData({
|
|
62
|
+
abi: SpaceRegistryAbi,
|
|
63
|
+
functionName: 'enter',
|
|
64
|
+
args: [spaceIdBytes16, spaceIdBytes16, EDITS_PUBLISHED, EMPTY_TOPIC, stringToHex(cid), EMPTY_SIGNATURE],
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
editId,
|
|
68
|
+
cid,
|
|
69
|
+
to: TESTNET.SPACE_REGISTRY_ADDRESS,
|
|
70
|
+
calldata,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=publish-edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-edit.js","sourceRoot":"","sources":["../../../src/personal-space/publish-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG/E;;;GAGG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACvC,qEAAqE;IACrE,sFAAsF;IACtF,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,OAAO,CAAC,WAAW,EAAE,EAAmB,CAAC;IACvD,CAAC;IAED,0EAA0E;IAC1E,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,sDAAsD,CAAC,CAAC;AACtG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAyB;IACzD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC;IAEnE,MAAM,cAAc,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAEjD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC;QAC7C,IAAI;QACJ,GAAG;QACH,MAAM;QACN,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,kBAAkB,CAAC;QAClC,GAAG,EAAE,gBAAgB;QACrB,YAAY,EAAE,OAAO;QACrB,IAAI,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC;KACxG,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,GAAG;QACH,EAAE,EAAE,OAAO,CAAC,sBAAsB;QAClC,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-edit.test.d.ts","sourceRoot":"","sources":["../../../src/personal-space/publish-edit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { TESTNET } from '../../contracts.js';
|
|
3
|
+
import { createEntity } from '../graph/create-entity.js';
|
|
4
|
+
import { generate } from '../id-utils.js';
|
|
5
|
+
import { publishEdit } from './publish-edit.js';
|
|
6
|
+
describe('publishEdit', () => {
|
|
7
|
+
it('should return correct structure', async () => {
|
|
8
|
+
const spaceId = '0eed5491b917cf58b33ac81255fe7ae9';
|
|
9
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
10
|
+
const result = await publishEdit({
|
|
11
|
+
name: 'Test Edit',
|
|
12
|
+
spaceId,
|
|
13
|
+
ops,
|
|
14
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
15
|
+
});
|
|
16
|
+
expect(result).toHaveProperty('editId');
|
|
17
|
+
expect(result).toHaveProperty('cid');
|
|
18
|
+
expect(result).toHaveProperty('to');
|
|
19
|
+
expect(result).toHaveProperty('calldata');
|
|
20
|
+
});
|
|
21
|
+
it('should return the correct contract address', async () => {
|
|
22
|
+
const spaceId = '0eed5491b917cf58b33ac81255fe7ae9';
|
|
23
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
24
|
+
const { to } = await publishEdit({
|
|
25
|
+
name: 'Test Edit',
|
|
26
|
+
spaceId,
|
|
27
|
+
ops,
|
|
28
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
29
|
+
});
|
|
30
|
+
expect(to).toBe(TESTNET.SPACE_REGISTRY_ADDRESS);
|
|
31
|
+
});
|
|
32
|
+
it('should return valid calldata', async () => {
|
|
33
|
+
const spaceId = '0eed5491b917cf58b33ac81255fe7ae9';
|
|
34
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
35
|
+
const { calldata } = await publishEdit({
|
|
36
|
+
name: 'Test Edit',
|
|
37
|
+
spaceId,
|
|
38
|
+
ops,
|
|
39
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
40
|
+
});
|
|
41
|
+
expect(calldata).toBeTypeOf('string');
|
|
42
|
+
expect(calldata.startsWith('0x')).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
it('should return valid CID', async () => {
|
|
45
|
+
const spaceId = '0eed5491b917cf58b33ac81255fe7ae9';
|
|
46
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
47
|
+
const { cid } = await publishEdit({
|
|
48
|
+
name: 'Test Edit',
|
|
49
|
+
spaceId,
|
|
50
|
+
ops,
|
|
51
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
52
|
+
});
|
|
53
|
+
expect(cid).toMatch(/^ipfs:\/\//);
|
|
54
|
+
});
|
|
55
|
+
it('should return valid editId', async () => {
|
|
56
|
+
const spaceId = '0eed5491b917cf58b33ac81255fe7ae9';
|
|
57
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
58
|
+
const { editId } = await publishEdit({
|
|
59
|
+
name: 'Test Edit',
|
|
60
|
+
spaceId,
|
|
61
|
+
ops,
|
|
62
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
63
|
+
});
|
|
64
|
+
expect(editId).toBeTruthy();
|
|
65
|
+
expect(editId).toHaveLength(32);
|
|
66
|
+
});
|
|
67
|
+
it('should accept 32-char hex string spaceId (on-chain format)', async () => {
|
|
68
|
+
const spaceId = 'abcdef12345678901234567890abcdef';
|
|
69
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
70
|
+
const result = await publishEdit({
|
|
71
|
+
name: 'Test Edit',
|
|
72
|
+
spaceId,
|
|
73
|
+
ops,
|
|
74
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
75
|
+
});
|
|
76
|
+
expect(result.cid).toMatch(/^ipfs:\/\//);
|
|
77
|
+
expect(result.calldata.startsWith('0x')).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
it('should accept valid UUID spaceId', async () => {
|
|
80
|
+
const spaceId = generate();
|
|
81
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
82
|
+
const result = await publishEdit({
|
|
83
|
+
name: 'Test Edit',
|
|
84
|
+
spaceId,
|
|
85
|
+
ops,
|
|
86
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
87
|
+
});
|
|
88
|
+
expect(result.cid).toMatch(/^ipfs:\/\//);
|
|
89
|
+
expect(result.calldata.startsWith('0x')).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
it('should accept UUID with dashes', async () => {
|
|
92
|
+
const spaceId = '550e8400-e29b-41d4-a716-446655440000';
|
|
93
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
94
|
+
const result = await publishEdit({
|
|
95
|
+
name: 'Test Edit',
|
|
96
|
+
spaceId,
|
|
97
|
+
ops,
|
|
98
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
99
|
+
});
|
|
100
|
+
expect(result.cid).toMatch(/^ipfs:\/\//);
|
|
101
|
+
expect(result.calldata.startsWith('0x')).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
it('should throw for invalid spaceId', async () => {
|
|
104
|
+
const invalidSpaceId = 'invalid';
|
|
105
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
106
|
+
await expect(publishEdit({
|
|
107
|
+
name: 'Test Edit',
|
|
108
|
+
spaceId: invalidSpaceId,
|
|
109
|
+
ops,
|
|
110
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
111
|
+
})).rejects.toThrow('Invalid spaceId');
|
|
112
|
+
});
|
|
113
|
+
it('should throw for spaceId that is too short', async () => {
|
|
114
|
+
const shortSpaceId = 'abc123';
|
|
115
|
+
const { ops } = createEntity({ name: 'Test Entity' });
|
|
116
|
+
await expect(publishEdit({
|
|
117
|
+
name: 'Test Edit',
|
|
118
|
+
spaceId: shortSpaceId,
|
|
119
|
+
ops,
|
|
120
|
+
author: '0x0000000000000000000000000000000000000000',
|
|
121
|
+
})).rejects.toThrow('Invalid spaceId');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=publish-edit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-edit.test.js","sourceRoot":"","sources":["../../../src/personal-space/publish-edit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAA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21 @@
|
|
|
1
|
+
import type { Op } from '@geoprotocol/grc-20';
|
|
2
|
+
import type { Id } from '../id.js';
|
|
3
|
+
import type { Network } from '../types.js';
|
|
4
|
+
export type CreateSpaceResult = {
|
|
5
|
+
to: `0x${string}`;
|
|
6
|
+
calldata: `0x${string}`;
|
|
7
|
+
};
|
|
8
|
+
export type PublishEditParams = {
|
|
9
|
+
name: string;
|
|
10
|
+
spaceId: Id | string;
|
|
11
|
+
ops: Op[];
|
|
12
|
+
author: `0x${string}`;
|
|
13
|
+
network?: Network;
|
|
14
|
+
};
|
|
15
|
+
export type PublishEditResult = {
|
|
16
|
+
editId: Id;
|
|
17
|
+
cid: string;
|
|
18
|
+
to: `0x${string}`;
|
|
19
|
+
calldata: `0x${string}`;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/personal-space/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC;IACrB,GAAG,EAAE,EAAE,EAAE,CAAC;IACV,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,EAAE,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/personal-space/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoprotocol/geo-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./abis": "./dist/abis.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@geoprotocol/grc-20": "^0.2.
|
|
21
|
+
"@geoprotocol/grc-20": "^0.2.3",
|
|
22
22
|
"effect": "^3.17.13",
|
|
23
23
|
"fflate": "^0.8.2",
|
|
24
24
|
"fractional-indexing-jittered": "^1.0.0",
|