@geoprotocol/geo-sdk 0.2.0 → 0.3.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.
- 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/core/blocks/data.test.js +2 -2
- package/dist/src/core/blocks/data.test.js.map +1 -1
- package/dist/src/core/blocks/text.test.js +4 -4
- package/dist/src/core/blocks/text.test.js.map +1 -1
- package/dist/src/full-flow-test.test.js +21 -35
- package/dist/src/full-flow-test.test.js.map +1 -1
- package/dist/src/graph/update-entity.d.ts +7 -3
- package/dist/src/graph/update-entity.d.ts.map +1 -1
- package/dist/src/graph/update-entity.js +36 -6
- package/dist/src/graph/update-entity.js.map +1 -1
- package/dist/src/graph/update-entity.test.js +114 -22
- package/dist/src/graph/update-entity.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/dist/src/types.d.ts +27 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- 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,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,U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B,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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,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"}
|
|
@@ -56,10 +56,10 @@ it('should generate ops for a data block entity with a name', () => {
|
|
|
56
56
|
expect(blocksRelOp.from).toEqual(toGrcId(fromId));
|
|
57
57
|
expect(blocksRelOp.relationType).toEqual(toGrcId(BLOCKS));
|
|
58
58
|
// Check name entity update
|
|
59
|
-
expect(blockNameOp?.type).toBe('
|
|
59
|
+
expect(blockNameOp?.type).toBe('updateEntity');
|
|
60
60
|
const nameEntityOp = blockNameOp;
|
|
61
61
|
// Verify name value
|
|
62
|
-
const nameValue = nameEntityOp.
|
|
62
|
+
const nameValue = nameEntityOp.set.find(v => {
|
|
63
63
|
const propBytes = v.property;
|
|
64
64
|
return propBytes.every((b, i) => b === toGrcId(NAME_PROPERTY)[i]);
|
|
65
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.test.js","sourceRoot":"","sources":["../../../../src/core/blocks/data.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EACL,MAAM,EACN,UAAU,EACV,8BAA8B,EAC9B,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;IACrD,MAAM,MAAM,GAAG,EAA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AC,gBAAgB,CAAC,CAAC;IACpD,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAC9E,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;IACxD,MAAM,MAAM,GAAG,EAAE,CAAC,kCAAkC,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,IAAI,CAAC;QACf,MAAM;QACN,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,GAAG;KACd,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,GAAG,CAAC,CAAC,CAAmB,CAAC;IACjD,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACpD,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAC9E,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC,CAAC"}
|
|
@@ -18,10 +18,10 @@ it('should generate ops for a text block entity', () => {
|
|
|
18
18
|
expect(typeRelOp.to).toEqual(toGrcId(TEXT_BLOCK));
|
|
19
19
|
expect(typeRelOp.relationType).toEqual(toGrcId(TYPES_PROPERTY));
|
|
20
20
|
// Check entity update with markdown text
|
|
21
|
-
expect(blockMarkdownTextOp?.type).toBe('
|
|
21
|
+
expect(blockMarkdownTextOp?.type).toBe('updateEntity');
|
|
22
22
|
const markdownEntityOp = blockMarkdownTextOp;
|
|
23
23
|
// Verify markdown content value
|
|
24
|
-
const markdownValue = markdownEntityOp.
|
|
24
|
+
const markdownValue = markdownEntityOp.set.find(v => {
|
|
25
25
|
const propBytes = v.property;
|
|
26
26
|
return propBytes.every((b, i) => b === toGrcId(MARKDOWN_CONTENT)[i]);
|
|
27
27
|
});
|
|
@@ -58,7 +58,7 @@ it('should handle empty text', () => {
|
|
|
58
58
|
});
|
|
59
59
|
expect(ops.length).toBe(3);
|
|
60
60
|
const markdownEntityOp = ops[1];
|
|
61
|
-
const markdownValue = markdownEntityOp.
|
|
61
|
+
const markdownValue = markdownEntityOp.set.find(v => {
|
|
62
62
|
const propBytes = v.property;
|
|
63
63
|
return propBytes.every((b, i) => b === toGrcId(MARKDOWN_CONTENT)[i]);
|
|
64
64
|
});
|
|
@@ -81,7 +81,7 @@ This is a paragraph.
|
|
|
81
81
|
position: 'b',
|
|
82
82
|
});
|
|
83
83
|
const markdownEntityOp = ops[1];
|
|
84
|
-
const markdownValue = markdownEntityOp.
|
|
84
|
+
const markdownValue = markdownEntityOp.set.find(v => {
|
|
85
85
|
const propBytes = v.property;
|
|
86
86
|
return propBytes.every((b, i) => b === toGrcId(MARKDOWN_CONTENT)[i]);
|
|
87
87
|
});
|