@graphprotocol/grc-20 0.0.8 → 0.2.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 (2) hide show
  1. package/README.md +21 -28
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Knowledge Graph SDK
2
2
 
3
- A collection of tools for interacting with the The Graph.
3
+ A collection of tools for interacting with The Graph.
4
4
 
5
5
  ## Installing
6
6
 
@@ -54,7 +54,7 @@ Entities throughout The Graph are referenced via globally unique identifiers. Th
54
54
  ```ts
55
55
  import { ID } from 'graphprotocol/grc-20';
56
56
 
57
- const newId = ID.make();
57
+ const newId = ID.generate();
58
58
  ```
59
59
 
60
60
  ### Making ops
@@ -102,26 +102,16 @@ Currently the indexer only supports reading a specific gateway. You should use o
102
102
 
103
103
  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://`.
104
104
 
105
+ We've abstracted the IPFS publishing and binary encoding into a single API.
106
+
105
107
  ```ts
106
- import { EditProposal } from '@graphprotocol/grc-20/proto';
108
+ import { IPFS } from '@graphprotocol/grc-20';
107
109
 
108
- const binaryEncodedEdit = EditProposal.make({
110
+ const cid = await IPFS.publishEdit({
109
111
  name: 'Edit name',
110
112
  ops: ops,
111
- author: '0x000000000000000000000000000000000000',
112
- });
113
-
114
- // Upload binary via Geo API
115
- const blob = new Blob([binaryEncodedEdit], { type: 'application/octet-stream' });
116
- const formData = new FormData();
117
- formData.append('file', blob);
118
-
119
- const result = await fetch('https://geobrowser.io/api/ipfs/upload', {
120
- method: 'POST',
121
- body: formData,
122
- });
123
-
124
- const { cid } = await result.json();
113
+ author: '0x000000000000000000000000000000000000',
114
+ })
125
115
  ```
126
116
 
127
117
  ### Publishing an edit onchain
@@ -130,14 +120,18 @@ Once you've uploaded the binary encoded Edit to IPFS and have correctly formed `
130
120
 
131
121
  The calldata used to write the edit onchain depends on the governance structure of the space. Currently The Graph supports two governance modes, one with voting and one without. The API exposes metadata about each space, its governance structure, and what smart contracts exist for it.
132
122
 
133
- We expose an API for fetching the appropriate calldata for the correct contract address based for each space.
123
+ We expose an API for fetching the appropriate calldata for the correct contract addresses for each space.
134
124
 
135
125
  ```ts
136
- // You'll need to know your space id ahead of time
126
+ // You'll need to know your space id and have an IPFS hash ahead of time
137
127
  const spaceId = 'space-id';
128
+ const cid = 'ipfs://hash';
138
129
 
139
130
  // This returns the correct contract address and calldata depending on the space id
140
- const result = await fetch(`https://geobrowser.io/api/get-edit-calldata?spaceId=${spaceId}&cid=${cid}`);
131
+ const result = await fetch(`https://api.geobrowser.io/space/${spaceId}/edit/calldata`, {
132
+ method: "POST",
133
+ body: JSON.stringify({ cid }),
134
+ });
141
135
 
142
136
  const { to, data } = await result.json();
143
137
 
@@ -150,14 +144,13 @@ const txResult = await walletClient.sendTransaction({
150
144
 
151
145
  ### Deploying a space
152
146
 
153
- You can deploy spaces programmatically using the API. Currently there are two types of governance modes for spaces: one with voting and one without. They're called PUBLIC or PERSONAL spaces respectively.
147
+ You can deploy spaces programmatically using the API. Currently there are two types of governance modes for spaces: one with voting and one without. They're called PUBLIC or PERSONAL spaces respectively. The API only supports deploying the PERSONAL governance mode currently.
154
148
 
155
149
  ```ts
156
150
  const editorAddress = '0x000000000000000000000000000000000000';
157
- const spaceId = await fetch(`https://geobrowser.io/api/space/deploy?type=PERSONAL&initialEditorAddress=${editorAddress}`);
158
-
159
-
151
+ const spaceName = 'Example-Name';
152
+ const spaceId = await fetch("https://api.geobrowser.io/deploy", {
153
+ method: "POST",
154
+ body: JSON.stringify({ editorAddress, spaceName }),
155
+ });
160
156
  ```
161
-
162
-
163
- ### Smart accounts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/grc-20",
3
- "version": "0.0.8",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -32,6 +32,7 @@
32
32
  "@ethersproject/abi": "^5.6.4",
33
33
  "@ethersproject/providers": "^5.6.8",
34
34
  "@types/uuid": "^9.0.8",
35
+ "effect": "^3.12.11",
35
36
  "ethers": "^5.7.2",
36
37
  "position-strings": "^2.0.1",
37
38
  "uuid": "^9.0.0",