@graphprotocol/grc-20 0.11.5 → 0.12.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 +7 -48
- package/dist/convert-ids.d.ts +2 -0
- package/dist/convert-ids.d.ts.map +1 -0
- package/dist/convert-ids.js +42 -0
- package/dist/convert-ids.js.map +1 -0
- package/dist/index.d.ts +1 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -25
- package/dist/index.js.map +1 -1
- package/dist/proto.d.ts +0 -4
- package/dist/proto.d.ts.map +1 -1
- package/dist/proto.js +0 -4
- package/dist/proto.js.map +1 -1
- package/dist/protov2.d.ts +11 -0
- package/dist/protov2.d.ts.map +1 -0
- package/dist/protov2.js +11 -0
- package/dist/protov2.js.map +1 -0
- package/dist/src/blocks.d.ts +0 -7
- package/dist/src/blocks.d.ts.map +1 -1
- package/dist/src/blocks.js +0 -7
- package/dist/src/blocks.js.map +1 -1
- package/dist/src/core/account.d.ts +2 -2
- package/dist/src/core/account.d.ts.map +1 -1
- package/dist/src/core/account.js +27 -38
- package/dist/src/core/account.js.map +1 -1
- package/dist/src/core/account.test.js +25 -17
- package/dist/src/core/account.test.js.map +1 -1
- package/dist/src/core/blocks/data.d.ts +2 -2
- package/dist/src/core/blocks/data.d.ts.map +1 -1
- package/dist/src/core/blocks/data.js +25 -24
- package/dist/src/core/blocks/data.js.map +1 -1
- package/dist/src/core/blocks/data.test.js +20 -20
- package/dist/src/core/blocks/data.test.js.map +1 -1
- package/dist/src/core/blocks/text.d.ts.map +1 -1
- package/dist/src/core/blocks/text.js +22 -22
- package/dist/src/core/blocks/text.js.map +1 -1
- package/dist/src/core/blocks/text.test.js +11 -11
- package/dist/src/core/blocks/text.test.js.map +1 -1
- package/dist/src/core/ids/content.d.ts +1 -37
- package/dist/src/core/ids/content.d.ts.map +1 -1
- package/dist/src/core/ids/content.js +55 -199
- package/dist/src/core/ids/content.js.map +1 -1
- package/dist/src/core/ids/network.d.ts.map +1 -1
- package/dist/src/core/ids/network.js +3 -3
- package/dist/src/core/ids/network.js.map +1 -1
- package/dist/src/core/ids/system.d.ts +6 -51
- package/dist/src/core/ids/system.d.ts.map +1 -1
- package/dist/src/core/ids/system.js +142 -310
- package/dist/src/core/ids/system.js.map +1 -1
- package/dist/src/core/idsv2/content.d.ts +59 -0
- package/dist/src/core/idsv2/content.d.ts.map +1 -0
- package/dist/src/core/idsv2/content.js +59 -0
- package/dist/src/core/idsv2/content.js.map +1 -0
- package/dist/src/core/idsv2/network.d.ts +5 -0
- package/dist/src/core/idsv2/network.d.ts.map +1 -0
- package/dist/src/core/idsv2/network.js +5 -0
- package/dist/src/core/idsv2/network.js.map +1 -0
- package/dist/src/core/idsv2/system.d.ts +222 -0
- package/dist/src/core/idsv2/system.d.ts.map +1 -0
- package/dist/src/core/idsv2/system.js +230 -0
- package/dist/src/core/idsv2/system.js.map +1 -0
- package/dist/src/core/scheme.d.ts +1 -1
- package/dist/src/core/scheme.d.ts.map +1 -1
- package/dist/src/graph/create-entity.d.ts +21 -18
- package/dist/src/graph/create-entity.d.ts.map +1 -1
- package/dist/src/graph/create-entity.js +96 -27
- package/dist/src/graph/create-entity.js.map +1 -1
- package/dist/src/graph/create-entity.test.js +101 -245
- package/dist/src/graph/create-entity.test.js.map +1 -1
- package/dist/src/graph/create-image.d.ts +1 -14
- package/dist/src/graph/create-image.d.ts.map +1 -1
- package/dist/src/graph/create-image.js +34 -7
- package/dist/src/graph/create-image.js.map +1 -1
- package/dist/src/graph/create-image.test.js +38 -47
- package/dist/src/graph/create-image.test.js.map +1 -1
- package/dist/src/graph/create-property.d.ts +1 -9
- package/dist/src/graph/create-property.d.ts.map +1 -1
- package/dist/src/graph/create-property.js +52 -36
- package/dist/src/graph/create-property.js.map +1 -1
- package/dist/src/graph/create-property.test.js +10 -12
- package/dist/src/graph/create-property.test.js.map +1 -1
- package/dist/src/graph/create-relation.d.ts +33 -0
- package/dist/src/graph/create-relation.d.ts.map +1 -0
- package/dist/src/graph/create-relation.js +66 -0
- package/dist/src/graph/create-relation.js.map +1 -0
- package/dist/src/graph/create-relation.test.d.ts +2 -0
- package/dist/src/graph/create-relation.test.d.ts.map +1 -0
- package/dist/src/graph/create-relation.test.js +208 -0
- package/dist/src/graph/create-relation.test.js.map +1 -0
- package/dist/src/graph/create-type.d.ts +3 -8
- package/dist/src/graph/create-type.d.ts.map +1 -1
- package/dist/src/graph/create-type.js +29 -17
- package/dist/src/graph/create-type.js.map +1 -1
- package/dist/src/graph/create-type.test.js +37 -35
- package/dist/src/graph/create-type.test.js.map +1 -1
- package/dist/src/graph/delete-entity.d.ts +4 -10
- package/dist/src/graph/delete-entity.d.ts.map +1 -1
- package/dist/src/graph/delete-entity.js +10 -35
- package/dist/src/graph/delete-entity.js.map +1 -1
- package/dist/src/graph/delete-entity.test.js +17 -35
- package/dist/src/graph/delete-entity.test.js.map +1 -1
- package/dist/src/graph/delete-relation.d.ts +14 -0
- package/dist/src/graph/delete-relation.d.ts.map +1 -0
- package/dist/src/graph/delete-relation.js +21 -0
- package/dist/src/graph/delete-relation.js.map +1 -0
- package/dist/src/graph/delete-relation.test.d.ts +2 -0
- package/dist/src/graph/delete-relation.test.d.ts.map +1 -0
- package/dist/src/graph/delete-relation.test.js +24 -0
- package/dist/src/graph/delete-relation.test.js.map +1 -0
- package/dist/src/graph/index.d.ts +5 -0
- package/dist/src/graph/index.d.ts.map +1 -1
- package/dist/src/graph/index.js +5 -0
- package/dist/src/graph/index.js.map +1 -1
- package/dist/src/graph/unset-entity-values.d.ts +21 -0
- package/dist/src/graph/unset-entity-values.d.ts.map +1 -0
- package/dist/src/graph/unset-entity-values.js +26 -0
- package/dist/src/graph/unset-entity-values.js.map +1 -0
- package/dist/src/graph/unset-entity-values.test.d.ts +2 -0
- package/dist/src/graph/unset-entity-values.test.d.ts.map +1 -0
- package/dist/src/graph/unset-entity-values.test.js +40 -0
- package/dist/src/graph/unset-entity-values.test.js.map +1 -0
- package/dist/src/graph/unset-relation-fields.d.ts +25 -0
- package/dist/src/graph/unset-relation-fields.d.ts.map +1 -0
- package/dist/src/graph/unset-relation-fields.js +34 -0
- package/dist/src/graph/unset-relation-fields.js.map +1 -0
- package/dist/src/graph/unset-relation-fields.test.d.ts +2 -0
- package/dist/src/graph/unset-relation-fields.test.d.ts.map +1 -0
- package/dist/src/graph/unset-relation-fields.test.js +64 -0
- package/dist/src/graph/unset-relation-fields.test.js.map +1 -0
- package/dist/src/graph/update-entity.d.ts +28 -0
- package/dist/src/graph/update-entity.d.ts.map +1 -0
- package/dist/src/graph/update-entity.js +73 -0
- package/dist/src/graph/update-entity.js.map +1 -0
- package/dist/src/graph/update-entity.test.d.ts +2 -0
- package/dist/src/graph/update-entity.test.d.ts.map +1 -0
- package/dist/src/graph/update-entity.test.js +116 -0
- package/dist/src/graph/update-entity.test.js.map +1 -0
- package/dist/src/graph/update-relation.d.ts +21 -0
- package/dist/src/graph/update-relation.d.ts.map +1 -0
- package/dist/src/graph/update-relation.js +37 -0
- package/dist/src/graph/update-relation.js.map +1 -0
- package/dist/src/graphv2/constants.d.ts +2 -0
- package/dist/src/graphv2/constants.d.ts.map +1 -0
- package/dist/src/graphv2/constants.js +2 -0
- package/dist/src/graphv2/constants.js.map +1 -0
- package/dist/src/graphv2/create-entity.d.ts +52 -0
- package/dist/src/graphv2/create-entity.d.ts.map +1 -0
- package/dist/src/graphv2/create-entity.js +140 -0
- package/dist/src/graphv2/create-entity.js.map +1 -0
- package/dist/src/graphv2/create-entity.test.d.ts +2 -0
- package/dist/src/graphv2/create-entity.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-entity.test.js +158 -0
- package/dist/src/graphv2/create-entity.test.js.map +1 -0
- package/dist/src/graphv2/create-image.d.ts +28 -0
- package/dist/src/graphv2/create-image.d.ts.map +1 -0
- package/dist/src/graphv2/create-image.js +71 -0
- package/dist/src/graphv2/create-image.js.map +1 -0
- package/dist/src/graphv2/create-image.test.d.ts +2 -0
- package/dist/src/graphv2/create-image.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-image.test.js +142 -0
- package/dist/src/graphv2/create-image.test.js.map +1 -0
- package/dist/src/graphv2/create-property.d.ts +22 -0
- package/dist/src/graphv2/create-property.d.ts.map +1 -0
- package/dist/src/graphv2/create-property.js +129 -0
- package/dist/src/graphv2/create-property.js.map +1 -0
- package/dist/src/graphv2/create-property.test.d.ts +2 -0
- package/dist/src/graphv2/create-property.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-property.test.js +82 -0
- package/dist/src/graphv2/create-property.test.js.map +1 -0
- package/dist/src/graphv2/create-relation.d.ts +33 -0
- package/dist/src/graphv2/create-relation.d.ts.map +1 -0
- package/dist/src/graphv2/create-relation.js +66 -0
- package/dist/src/graphv2/create-relation.js.map +1 -0
- package/dist/src/graphv2/create-relation.test.d.ts +2 -0
- package/dist/src/graphv2/create-relation.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-relation.test.js +208 -0
- package/dist/src/graphv2/create-relation.test.js.map +1 -0
- package/dist/src/graphv2/create-space.d.ts +13 -0
- package/dist/src/graphv2/create-space.d.ts.map +1 -0
- package/dist/src/graphv2/create-space.js +21 -0
- package/dist/src/graphv2/create-space.js.map +1 -0
- package/dist/src/graphv2/create-type.d.ts +22 -0
- package/dist/src/graphv2/create-type.d.ts.map +1 -0
- package/dist/src/graphv2/create-type.js +64 -0
- package/dist/src/graphv2/create-type.js.map +1 -0
- package/dist/src/graphv2/create-type.test.d.ts +2 -0
- package/dist/src/graphv2/create-type.test.d.ts.map +1 -0
- package/dist/src/graphv2/create-type.test.js +109 -0
- package/dist/src/graphv2/create-type.test.js.map +1 -0
- package/dist/src/graphv2/delete-entity.d.ts +14 -0
- package/dist/src/graphv2/delete-entity.d.ts.map +1 -0
- package/dist/src/graphv2/delete-entity.js +21 -0
- package/dist/src/graphv2/delete-entity.js.map +1 -0
- package/dist/src/graphv2/delete-entity.test.d.ts +2 -0
- package/dist/src/graphv2/delete-entity.test.d.ts.map +1 -0
- package/dist/src/graphv2/delete-entity.test.js +24 -0
- package/dist/src/graphv2/delete-entity.test.js.map +1 -0
- package/dist/src/graphv2/delete-relation.d.ts +14 -0
- package/dist/src/graphv2/delete-relation.d.ts.map +1 -0
- package/dist/src/graphv2/delete-relation.js +21 -0
- package/dist/src/graphv2/delete-relation.js.map +1 -0
- package/dist/src/graphv2/delete-relation.test.d.ts +2 -0
- package/dist/src/graphv2/delete-relation.test.d.ts.map +1 -0
- package/dist/src/graphv2/delete-relation.test.js +24 -0
- package/dist/src/graphv2/delete-relation.test.js.map +1 -0
- package/dist/src/graphv2/index.d.ts +12 -0
- package/dist/src/graphv2/index.d.ts.map +1 -0
- package/dist/src/graphv2/index.js +12 -0
- package/dist/src/graphv2/index.js.map +1 -0
- package/dist/src/graphv2/remove-entity-properties.d.ts +25 -0
- package/dist/src/graphv2/remove-entity-properties.d.ts.map +1 -0
- package/dist/src/graphv2/remove-entity-properties.js +24 -0
- package/dist/src/graphv2/remove-entity-properties.js.map +1 -0
- package/dist/src/graphv2/unset-entity-values.d.ts +21 -0
- package/dist/src/graphv2/unset-entity-values.d.ts.map +1 -0
- package/dist/src/graphv2/unset-entity-values.js +26 -0
- package/dist/src/graphv2/unset-entity-values.js.map +1 -0
- package/dist/src/graphv2/unset-entity-values.test.d.ts +2 -0
- package/dist/src/graphv2/unset-entity-values.test.d.ts.map +1 -0
- package/dist/src/graphv2/unset-entity-values.test.js +40 -0
- package/dist/src/graphv2/unset-entity-values.test.js.map +1 -0
- package/dist/src/graphv2/unset-relation-fields.d.ts +25 -0
- package/dist/src/graphv2/unset-relation-fields.d.ts.map +1 -0
- package/dist/src/graphv2/unset-relation-fields.js +34 -0
- package/dist/src/graphv2/unset-relation-fields.js.map +1 -0
- package/dist/src/graphv2/unset-relation-fields.test.d.ts +2 -0
- package/dist/src/graphv2/unset-relation-fields.test.d.ts.map +1 -0
- package/dist/src/graphv2/unset-relation-fields.test.js +64 -0
- package/dist/src/graphv2/unset-relation-fields.test.js.map +1 -0
- package/dist/src/graphv2/update-entity.d.ts +28 -0
- package/dist/src/graphv2/update-entity.d.ts.map +1 -0
- package/dist/src/graphv2/update-entity.js +73 -0
- package/dist/src/graphv2/update-entity.js.map +1 -0
- package/dist/src/graphv2/update-entity.test.d.ts +2 -0
- package/dist/src/graphv2/update-entity.test.d.ts.map +1 -0
- package/dist/src/graphv2/update-entity.test.js +116 -0
- package/dist/src/graphv2/update-entity.test.js.map +1 -0
- package/dist/src/graphv2/update-relation.d.ts +21 -0
- package/dist/src/graphv2/update-relation.d.ts.map +1 -0
- package/dist/src/graphv2/update-relation.js +37 -0
- package/dist/src/graphv2/update-relation.js.map +1 -0
- package/dist/src/id.d.ts +9 -2
- package/dist/src/id.d.ts.map +1 -1
- package/dist/src/id.js +55 -22
- package/dist/src/id.js.map +1 -1
- package/dist/src/id.test.js +13 -10
- package/dist/src/id.test.js.map +1 -1
- package/dist/src/idv2.d.ts +27 -0
- package/dist/src/idv2.d.ts.map +1 -0
- package/dist/src/idv2.js +88 -0
- package/dist/src/idv2.js.map +1 -0
- package/dist/src/idv2.test.d.ts +2 -0
- package/dist/src/idv2.test.d.ts.map +1 -0
- package/dist/src/idv2.test.js +26 -0
- package/dist/src/idv2.test.js.map +1 -0
- package/dist/src/ipfs.d.ts +2 -2
- package/dist/src/ipfs.d.ts.map +1 -1
- package/dist/src/ipfs.js +2 -2
- package/dist/src/ipfs.js.map +1 -1
- package/dist/src/ipfs.test.d.ts +2 -0
- package/dist/src/ipfs.test.d.ts.map +1 -0
- package/dist/src/ipfs.test.js +22 -0
- package/dist/src/ipfs.test.js.map +1 -0
- package/dist/src/ipfsv2.d.ts +96 -0
- package/dist/src/ipfsv2.d.ts.map +1 -0
- package/dist/src/ipfsv2.js +163 -0
- package/dist/src/ipfsv2.js.map +1 -0
- package/dist/src/ipfsv2.test.d.ts +2 -0
- package/dist/src/ipfsv2.test.d.ts.map +1 -0
- package/dist/src/ipfsv2.test.js +22 -0
- package/dist/src/ipfsv2.test.js.map +1 -0
- package/dist/src/proto/edit.d.ts +4 -2
- package/dist/src/proto/edit.d.ts.map +1 -1
- package/dist/src/proto/edit.js +53 -32
- package/dist/src/proto/edit.js.map +1 -1
- package/dist/src/proto/edit.test.js +139 -152
- package/dist/src/proto/edit.test.js.map +1 -1
- package/dist/src/proto/editv2.d.ts +11 -0
- package/dist/src/proto/editv2.d.ts.map +1 -0
- package/dist/src/proto/editv2.js +81 -0
- package/dist/src/proto/editv2.js.map +1 -0
- package/dist/src/proto/editv2.test.d.ts +2 -0
- package/dist/src/proto/editv2.test.d.ts.map +1 -0
- package/dist/src/proto/editv2.test.js +211 -0
- package/dist/src/proto/editv2.test.js.map +1 -0
- package/dist/src/proto/gen/src/proto/ipfs_pb.d.ts +249 -369
- package/dist/src/proto/gen/src/proto/ipfs_pb.d.ts.map +1 -1
- package/dist/src/proto/gen/src/proto/ipfs_pb.js +244 -484
- package/dist/src/proto/gen/src/proto/ipfs_pb.js.map +1 -1
- package/dist/src/proto/gen/src/proto/ipfsv2_pb.d.ts +410 -0
- package/dist/src/proto/gen/src/proto/ipfsv2_pb.d.ts.map +1 -0
- package/dist/src/proto/gen/src/proto/ipfsv2_pb.js +536 -0
- package/dist/src/proto/gen/src/proto/ipfsv2_pb.js.map +1 -0
- package/dist/src/smart-wallet-2.test-invalid.d.ts +2 -0
- package/dist/src/smart-wallet-2.test-invalid.d.ts.map +1 -0
- package/dist/src/smart-wallet-2.test-invalid.js +49 -0
- package/dist/src/smart-wallet-2.test-invalid.js.map +1 -0
- package/dist/src/smart-wallet-2.test.d.ts +2 -0
- package/dist/src/smart-wallet-2.test.d.ts.map +1 -0
- package/dist/src/smart-wallet-2.test.js +49 -0
- package/dist/src/smart-wallet-2.test.js.map +1 -0
- package/dist/src/system-ids-v2.d.ts +7 -0
- package/dist/src/system-ids-v2.d.ts.map +1 -0
- package/dist/src/system-ids-v2.js +7 -0
- package/dist/src/system-ids-v2.js.map +1 -0
- package/dist/src/system-ids.d.ts +0 -2
- package/dist/src/system-ids.d.ts.map +1 -1
- package/dist/src/system-ids.js +0 -2
- package/dist/src/system-ids.js.map +1 -1
- package/dist/src/types-backup.d.ts +134 -0
- package/dist/src/types-backup.d.ts.map +1 -0
- package/dist/src/types-backup.js +13 -0
- package/dist/src/types-backup.js.map +1 -0
- package/dist/src/types.d.ts +126 -103
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +0 -5
- package/dist/src/types.js.map +1 -1
- package/dist/src/typesv2.d.ts +173 -0
- package/dist/src/typesv2.d.ts.map +1 -0
- package/dist/src/typesv2.js +8 -0
- package/dist/src/typesv2.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,12 +19,6 @@ Data in The Graph lives both offchain and onchain. This data is written to IPFS,
|
|
|
19
19
|
|
|
20
20
|
On The Graph, knowledge is organized into spaces. Anyone can create a space for a community, project or individual. Spaces are organized onchain into a set of multiple smart contracts. These smart contracts represent the space itself, its data and its governance process. Depending on which onchain actions you're taking you might be interacting with one or more of these smart contracts.
|
|
21
21
|
|
|
22
|
-
### Triple
|
|
23
|
-
|
|
24
|
-
The structure of knowledge on The Graph is built on simple primitives that compose to create more complex structures. Triples are the atomic unit. Triples are combined into entities. Entities are linked together to form a graph.
|
|
25
|
-
|
|
26
|
-
[Read more about Triples in GRC-20](https://github.com/graphprotocol/graph-improvement-proposals/blob/main/grcs/0020-knowledge-graph.md#4-triples)
|
|
27
|
-
|
|
28
22
|
### Relations
|
|
29
23
|
|
|
30
24
|
Relations describe the edges within the graph. Relations are themselves entities that include details about the relationship. For example a Company can have Team Members. Each Team Member relation can have an attribute describing when the person joined the team. This is a model that is commonly called a property graph.
|
|
@@ -57,43 +51,6 @@ import { Id } from '@graphprotocol/grc-20';
|
|
|
57
51
|
const newId = Id.generate();
|
|
58
52
|
```
|
|
59
53
|
|
|
60
|
-
### Making ops
|
|
61
|
-
|
|
62
|
-
The SDK exports a set of APIs for creating and deleting triple and relation ops.
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
import {
|
|
66
|
-
type CreateRelationOp,
|
|
67
|
-
type DeleteRelationOp,
|
|
68
|
-
type DeleteTripleOp,
|
|
69
|
-
Relation,
|
|
70
|
-
type SetTripleOp,
|
|
71
|
-
Triple,
|
|
72
|
-
} from '@graphprotocol/grc-20';
|
|
73
|
-
|
|
74
|
-
const setTripleOp: SetTripleOp = Triple.make({
|
|
75
|
-
entityId: 'id of entity',
|
|
76
|
-
attributeId: 'id of attribute',
|
|
77
|
-
value: {
|
|
78
|
-
type: 'TEXT', // TEXT | NUMBER | URL | TIME | POINT | CHECKBOX,
|
|
79
|
-
value: 'hello world',
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const deleteTripleOp: DeleteTripleOp = Triple.remove({
|
|
84
|
-
entityId: 'id of entity',
|
|
85
|
-
attributeId: 'id of attribute',
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const setRelationOp: CreateRelationOp = Relation.make({
|
|
89
|
-
fromId: 'id of from entity',
|
|
90
|
-
relationTypeId: 'id of relation type',
|
|
91
|
-
toId: 'id of to entity',
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const deleteRelationOp: DeleteRelationOp = Relation.remove('id of relation');
|
|
95
|
-
```
|
|
96
|
-
|
|
97
54
|
### Creating properties, types and entities
|
|
98
55
|
|
|
99
56
|
Working with triple and relations ops is a low level API and give you maximum flexibility. In order to ease the process of creating and updating data, the library also exports APIs for creating properties, types and entities.
|
|
@@ -125,18 +82,20 @@ const { id: restaurantId, ops: createRestaurantOps } = Graph.createEntity({
|
|
|
125
82
|
description: 'description of the entity',
|
|
126
83
|
types: […listOfTypeIds],
|
|
127
84
|
cover: imageId,
|
|
128
|
-
|
|
85
|
+
values: {
|
|
129
86
|
// value property like text, number, url, time, point, checkbox
|
|
130
87
|
[propertyId]: {
|
|
131
88
|
type: 'TEXT', // TEXT | NUMBER | URL | TIME | POINT | CHECKBOX,
|
|
132
89
|
value: 'value of the property',
|
|
133
90
|
},
|
|
91
|
+
},
|
|
92
|
+
relations: {
|
|
134
93
|
// relation property
|
|
135
94
|
[propertyId]: {
|
|
136
95
|
to: 'id of the entity',
|
|
137
|
-
|
|
96
|
+
id: 'id of the relation', // optional
|
|
138
97
|
position: positionString, // optional
|
|
139
|
-
|
|
98
|
+
values: {
|
|
140
99
|
[propertyId]: {
|
|
141
100
|
type: 'TEXT', // TEXT | NUMBER | URL | TIME | POINT | CHECKBOX,
|
|
142
101
|
value: 'value of the property',
|
|
@@ -189,7 +148,7 @@ const { id: restaurantId, ops: createRestaurantOps } = Graph.createEntity({
|
|
|
189
148
|
description: 'A restaurant serving fusion cuisine',
|
|
190
149
|
cover: restaurantCoverId,
|
|
191
150
|
types: [restaurantTypeId],
|
|
192
|
-
|
|
151
|
+
values: {
|
|
193
152
|
[WEBSITE_PROPERTY]: {
|
|
194
153
|
type: 'URL',
|
|
195
154
|
value: 'https://example.com',
|
|
@@ -209,7 +168,7 @@ const { id: personId, ops: createPersonOps } = Graph.createEntity({
|
|
|
209
168
|
name: 'Jane Doe',
|
|
210
169
|
types: [personTypeId],
|
|
211
170
|
cover: personCoverId,
|
|
212
|
-
|
|
171
|
+
values: {
|
|
213
172
|
[agePropertyId]: {
|
|
214
173
|
type: 'NUMBER',
|
|
215
174
|
value: 42,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-ids.d.ts","sourceRoot":"","sources":["../convert-ids.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { decodeBase58ToUUID } from './src/core/base58.js';
|
|
5
|
+
// Helper function to check if a string is a UUID
|
|
6
|
+
function isUUID(str) {
|
|
7
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8
|
+
return uuidRegex.test(str);
|
|
9
|
+
}
|
|
10
|
+
async function convertIds() {
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
13
|
+
const filePath = join(__dirname, 'src/core/idsv2/content.ts');
|
|
14
|
+
// Read the file content
|
|
15
|
+
const content = await readFile(filePath, 'utf-8');
|
|
16
|
+
// Find all Id() calls and convert them
|
|
17
|
+
const updatedContent = content.replace(/Id\(['"]([^'"]+)['"]\)/g, (match, id) => {
|
|
18
|
+
if (isUUID(id)) {
|
|
19
|
+
console.log(`Already a UUID: ${id}`);
|
|
20
|
+
return match;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const uuid = decodeBase58ToUUID(id);
|
|
24
|
+
console.log(`Converting ${id} to UUID ${uuid}`);
|
|
25
|
+
return `Id('${uuid}')`;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error instanceof Error) {
|
|
29
|
+
console.error(`Error converting ${id}: ${error.message}`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.error(`Error converting ${id}: Unknown error`);
|
|
33
|
+
}
|
|
34
|
+
return match;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
// Write the updated content back to the file
|
|
38
|
+
await writeFile(filePath, updatedContent, 'utf-8');
|
|
39
|
+
console.log('File has been updated with converted UUIDs');
|
|
40
|
+
}
|
|
41
|
+
convertIds().catch(console.error);
|
|
42
|
+
//# sourceMappingURL=convert-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-ids.js","sourceRoot":"","sources":["../convert-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EA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AAE,iBAAiB,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,6CAA6C;IAC7C,MAAM,SAAS,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;AAC5D,CAAC;AAED,UAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,6 @@ export * from './src/types.js';
|
|
|
6
6
|
* @since 0.0.6
|
|
7
7
|
*/
|
|
8
8
|
export * as Id from './src/id.js';
|
|
9
|
-
/**
|
|
10
|
-
* This module provides utility functions for working with base58 ids
|
|
11
|
-
* in TypeScript.
|
|
12
|
-
*/
|
|
13
|
-
export * as Base58 from './src/core/base58.js';
|
|
14
9
|
export { getAcceptEditorArguments, getAcceptSubspaceArguments, getCalldataForSpaceGovernanceType, getProcessGeoProposalArguments, getRemoveEditorArguments, getRemoveSubspaceArguments, } from './src/encodings/index.js';
|
|
15
10
|
/**
|
|
16
11
|
* This module provides utility functions for working with knowledge graph
|
|
@@ -19,17 +14,10 @@ export { getAcceptEditorArguments, getAcceptSubspaceArguments, getCalldataForSpa
|
|
|
19
14
|
* @since 0.0.6
|
|
20
15
|
*/
|
|
21
16
|
export { Account } from './src/account.js';
|
|
22
|
-
export { DataBlock,
|
|
17
|
+
export { DataBlock, TextBlock } from './src/blocks.js';
|
|
23
18
|
export * as Encoding from './src/encoding.js';
|
|
24
19
|
export { getChecksumAddress } from './src/core/get-checksum-address.js';
|
|
25
20
|
export * as Graph from './src/graph/index.js';
|
|
26
|
-
/**
|
|
27
|
-
* This module provides utility functions for working with knowledge graph
|
|
28
|
-
* images in TypeScript.
|
|
29
|
-
*
|
|
30
|
-
* @since 0.0.6
|
|
31
|
-
*/
|
|
32
|
-
export { Image } from './src/image.js';
|
|
33
21
|
/**
|
|
34
22
|
* This module provides utility functions for interacting with the default
|
|
35
23
|
* IPFS gateway in TypeScript.
|
|
@@ -38,12 +26,6 @@ export { Image } from './src/image.js';
|
|
|
38
26
|
*/
|
|
39
27
|
export * as Ipfs from './src/ipfs.js';
|
|
40
28
|
export { Position, PositionRange } from './src/position.js';
|
|
41
|
-
/**
|
|
42
|
-
* This module provides utility functions for working with Relations in TypeScript.
|
|
43
|
-
*
|
|
44
|
-
* @since 0.0.6
|
|
45
|
-
*/
|
|
46
|
-
export { Relation } from './src/relation.js';
|
|
47
29
|
/**
|
|
48
30
|
* This module provides utility functions for working with Graph URIs in TypeScript.
|
|
49
31
|
*
|
|
@@ -55,10 +37,4 @@ export { getSmartAccountWalletClient } from './src/smart-wallet.js';
|
|
|
55
37
|
* Provides ids for commonly used entities across the Knowledge Graph.
|
|
56
38
|
*/
|
|
57
39
|
export { ContentIds, NetworkIds, SystemIds } from './src/system-ids.js';
|
|
58
|
-
/**
|
|
59
|
-
* This module provides utility functions for working with Triples in TypeScript.
|
|
60
|
-
*
|
|
61
|
-
* @since 0.0.6
|
|
62
|
-
*/
|
|
63
|
-
export { Triple } from './src/triple.js';
|
|
64
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAE/B;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAE/B;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,8BAA8B,EAC9B,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAElC;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,6 @@ export * from './src/types.js';
|
|
|
6
6
|
* @since 0.0.6
|
|
7
7
|
*/
|
|
8
8
|
export * as Id from './src/id.js';
|
|
9
|
-
/**
|
|
10
|
-
* This module provides utility functions for working with base58 ids
|
|
11
|
-
* in TypeScript.
|
|
12
|
-
*/
|
|
13
|
-
export * as Base58 from './src/core/base58.js';
|
|
14
9
|
export { getAcceptEditorArguments, getAcceptSubspaceArguments, getCalldataForSpaceGovernanceType, getProcessGeoProposalArguments, getRemoveEditorArguments, getRemoveSubspaceArguments, } from './src/encodings/index.js';
|
|
15
10
|
/**
|
|
16
11
|
* This module provides utility functions for working with knowledge graph
|
|
@@ -19,17 +14,10 @@ export { getAcceptEditorArguments, getAcceptSubspaceArguments, getCalldataForSpa
|
|
|
19
14
|
* @since 0.0.6
|
|
20
15
|
*/
|
|
21
16
|
export { Account } from './src/account.js';
|
|
22
|
-
export { DataBlock,
|
|
17
|
+
export { DataBlock, TextBlock } from './src/blocks.js';
|
|
23
18
|
export * as Encoding from './src/encoding.js';
|
|
24
19
|
export { getChecksumAddress } from './src/core/get-checksum-address.js';
|
|
25
20
|
export * as Graph from './src/graph/index.js';
|
|
26
|
-
/**
|
|
27
|
-
* This module provides utility functions for working with knowledge graph
|
|
28
|
-
* images in TypeScript.
|
|
29
|
-
*
|
|
30
|
-
* @since 0.0.6
|
|
31
|
-
*/
|
|
32
|
-
export { Image } from './src/image.js';
|
|
33
21
|
/**
|
|
34
22
|
* This module provides utility functions for interacting with the default
|
|
35
23
|
* IPFS gateway in TypeScript.
|
|
@@ -38,12 +26,6 @@ export { Image } from './src/image.js';
|
|
|
38
26
|
*/
|
|
39
27
|
export * as Ipfs from './src/ipfs.js';
|
|
40
28
|
export { Position, PositionRange } from './src/position.js';
|
|
41
|
-
/**
|
|
42
|
-
* This module provides utility functions for working with Relations in TypeScript.
|
|
43
|
-
*
|
|
44
|
-
* @since 0.0.6
|
|
45
|
-
*/
|
|
46
|
-
export { Relation } from './src/relation.js';
|
|
47
29
|
/**
|
|
48
30
|
* This module provides utility functions for working with Graph URIs in TypeScript.
|
|
49
31
|
*
|
|
@@ -55,10 +37,4 @@ export { getSmartAccountWalletClient } from './src/smart-wallet.js';
|
|
|
55
37
|
* Provides ids for commonly used entities across the Knowledge Graph.
|
|
56
38
|
*/
|
|
57
39
|
export { ContentIds, NetworkIds, SystemIds } from './src/system-ids.js';
|
|
58
|
-
/**
|
|
59
|
-
* This module provides utility functions for working with Triples in TypeScript.
|
|
60
|
-
*
|
|
61
|
-
* @since 0.0.6
|
|
62
|
-
*/
|
|
63
|
-
export { Triple } from './src/triple.js';
|
|
64
40
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAE/B;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAE/B;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,8BAA8B,EAC9B,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAElC;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/proto.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module provides utility functions for working with GRC-20 protobufs
|
|
3
3
|
* in TypeScript.
|
|
4
|
-
*
|
|
5
|
-
* @since 0.0.6
|
|
6
4
|
*/
|
|
7
5
|
export * from './src/proto/gen/src/proto/ipfs_pb.js';
|
|
8
6
|
/**
|
|
9
7
|
* This module provides utility functions for working with the GRC-20 Edit
|
|
10
8
|
* protobuf in TypeScript.
|
|
11
|
-
*
|
|
12
|
-
* @since 0.0.6
|
|
13
9
|
*/
|
|
14
10
|
export * as EditProposal from './src/proto/edit.js';
|
|
15
11
|
//# sourceMappingURL=proto.d.ts.map
|
package/dist/proto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../proto.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../proto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,sCAAsC,CAAC;AAErD;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAC"}
|
package/dist/proto.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module provides utility functions for working with GRC-20 protobufs
|
|
3
3
|
* in TypeScript.
|
|
4
|
-
*
|
|
5
|
-
* @since 0.0.6
|
|
6
4
|
*/
|
|
7
5
|
export * from './src/proto/gen/src/proto/ipfs_pb.js';
|
|
8
6
|
/**
|
|
9
7
|
* This module provides utility functions for working with the GRC-20 Edit
|
|
10
8
|
* protobuf in TypeScript.
|
|
11
|
-
*
|
|
12
|
-
* @since 0.0.6
|
|
13
9
|
*/
|
|
14
10
|
export * as EditProposal from './src/proto/edit.js';
|
|
15
11
|
//# sourceMappingURL=proto.js.map
|
package/dist/proto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proto.js","sourceRoot":"","sources":["../proto.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"proto.js","sourceRoot":"","sources":["../proto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,sCAAsC,CAAC;AAErD;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides utility functions for working with GRC-20 protobufs
|
|
3
|
+
* in TypeScript.
|
|
4
|
+
*/
|
|
5
|
+
export * from './src/proto/gen/src/proto/ipfsv2_pb.js';
|
|
6
|
+
/**
|
|
7
|
+
* This module provides utility functions for working with the GRC-20 Edit
|
|
8
|
+
* protobuf in TypeScript.
|
|
9
|
+
*/
|
|
10
|
+
export * as EditProposal from './src/proto/editv2.js';
|
|
11
|
+
//# sourceMappingURL=protov2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protov2.d.ts","sourceRoot":"","sources":["../protov2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,wCAAwC,CAAC;AAEvD;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC"}
|
package/dist/protov2.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides utility functions for working with GRC-20 protobufs
|
|
3
|
+
* in TypeScript.
|
|
4
|
+
*/
|
|
5
|
+
export * from './src/proto/gen/src/proto/ipfsv2_pb.js';
|
|
6
|
+
/**
|
|
7
|
+
* This module provides utility functions for working with the GRC-20 Edit
|
|
8
|
+
* protobuf in TypeScript.
|
|
9
|
+
*/
|
|
10
|
+
export * as EditProposal from './src/proto/editv2.js';
|
|
11
|
+
//# sourceMappingURL=protov2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protov2.js","sourceRoot":"","sources":["../protov2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,wCAAwC,CAAC;AAEvD;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC"}
|
package/dist/src/blocks.d.ts
CHANGED
|
@@ -12,11 +12,4 @@ export * as DataBlock from './core/blocks/data.js';
|
|
|
12
12
|
* @since 0.0.6
|
|
13
13
|
*/
|
|
14
14
|
export * as TextBlock from './core/blocks/text.js';
|
|
15
|
-
/**
|
|
16
|
-
* This module provides utility functions for working with image blocks
|
|
17
|
-
* in TypeScript.
|
|
18
|
-
*
|
|
19
|
-
* @since 0.0.6
|
|
20
|
-
*/
|
|
21
|
-
export * as ImageBlock from './core/blocks/image.js';
|
|
22
15
|
//# sourceMappingURL=blocks.d.ts.map
|
package/dist/src/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAEnD;;;;;GAKG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAEnD;;;;;GAKG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC"}
|
package/dist/src/blocks.js
CHANGED
|
@@ -12,11 +12,4 @@ export * as DataBlock from './core/blocks/data.js';
|
|
|
12
12
|
* @since 0.0.6
|
|
13
13
|
*/
|
|
14
14
|
export * as TextBlock from './core/blocks/text.js';
|
|
15
|
-
/**
|
|
16
|
-
* This module provides utility functions for working with image blocks
|
|
17
|
-
* in TypeScript.
|
|
18
|
-
*
|
|
19
|
-
* @since 0.0.6
|
|
20
|
-
*/
|
|
21
|
-
export * as ImageBlock from './core/blocks/image.js';
|
|
22
15
|
//# sourceMappingURL=blocks.js.map
|
package/dist/src/blocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAEnD;;;;;GAKG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAEnD;;;;;GAKG;AACH,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC"}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @since 0.0.6
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { Op } from '../types.js';
|
|
8
8
|
type MakeAccountReturnType = {
|
|
9
9
|
accountId: string;
|
|
10
|
-
ops: [
|
|
10
|
+
ops: Op[];
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Returns the ops to create an entity representing an Account.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/core/account.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/core/account.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAKtC,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,EAAE,EAAE,CAAC;CACX,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAoC3D"}
|
package/dist/src/core/account.js
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @since 0.0.6
|
|
6
6
|
*/
|
|
7
|
+
import { createEntity } from '../graph/create-entity.js';
|
|
8
|
+
import { createRelation } from '../graph/create-relation.js';
|
|
7
9
|
import { generate } from '../id.js';
|
|
8
|
-
import { Relation } from '../relation.js';
|
|
9
10
|
import { getChecksumAddress } from './get-checksum-address.js';
|
|
10
11
|
import { ETHEREUM } from './ids/network.js';
|
|
11
12
|
import { ACCOUNT_TYPE, ADDRESS_PROPERTY, NAME_PROPERTY, NETWORK_PROPERTY, TYPES_PROPERTY } from './ids/system.js';
|
|
@@ -26,45 +27,33 @@ import { ACCOUNT_TYPE, ADDRESS_PROPERTY, NAME_PROPERTY, NETWORK_PROPERTY, TYPES_
|
|
|
26
27
|
export function make(address) {
|
|
27
28
|
const accountId = generate();
|
|
28
29
|
const checkedAddress = getChecksumAddress(address);
|
|
30
|
+
const ops = [];
|
|
31
|
+
const { ops: entityOps } = createEntity({
|
|
32
|
+
id: accountId,
|
|
33
|
+
values: {
|
|
34
|
+
[ADDRESS_PROPERTY]: { value: checkedAddress },
|
|
35
|
+
[NAME_PROPERTY]: { value: checkedAddress },
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
ops.push(...entityOps);
|
|
39
|
+
// Types -> Account
|
|
40
|
+
const { ops: accountOps } = createRelation({
|
|
41
|
+
fromEntity: accountId,
|
|
42
|
+
type: TYPES_PROPERTY,
|
|
43
|
+
toEntity: ACCOUNT_TYPE,
|
|
44
|
+
});
|
|
45
|
+
ops.push(...accountOps);
|
|
46
|
+
// Network -> Ethereum
|
|
47
|
+
// Signals that the account is for the Ethereum family of chains
|
|
48
|
+
const { ops: networkOps } = createRelation({
|
|
49
|
+
fromEntity: accountId,
|
|
50
|
+
type: NETWORK_PROPERTY,
|
|
51
|
+
toEntity: ETHEREUM,
|
|
52
|
+
});
|
|
53
|
+
ops.push(...networkOps);
|
|
29
54
|
return {
|
|
30
55
|
accountId,
|
|
31
|
-
ops
|
|
32
|
-
// Types -> Account
|
|
33
|
-
Relation.make({
|
|
34
|
-
fromId: accountId,
|
|
35
|
-
relationTypeId: TYPES_PROPERTY,
|
|
36
|
-
toId: ACCOUNT_TYPE,
|
|
37
|
-
}),
|
|
38
|
-
// Network -> Ethereum
|
|
39
|
-
// Signals that the account is for the Ethereum family of chains
|
|
40
|
-
Relation.make({
|
|
41
|
-
fromId: accountId,
|
|
42
|
-
relationTypeId: NETWORK_PROPERTY,
|
|
43
|
-
toId: ETHEREUM,
|
|
44
|
-
}),
|
|
45
|
-
{
|
|
46
|
-
type: 'SET_TRIPLE',
|
|
47
|
-
triple: {
|
|
48
|
-
entity: accountId,
|
|
49
|
-
attribute: ADDRESS_PROPERTY,
|
|
50
|
-
value: {
|
|
51
|
-
type: 'TEXT',
|
|
52
|
-
value: checkedAddress,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
type: 'SET_TRIPLE',
|
|
58
|
-
triple: {
|
|
59
|
-
entity: accountId,
|
|
60
|
-
attribute: NAME_PROPERTY,
|
|
61
|
-
value: {
|
|
62
|
-
type: 'TEXT',
|
|
63
|
-
value: checkedAddress,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
],
|
|
56
|
+
ops,
|
|
68
57
|
};
|
|
69
58
|
}
|
|
70
59
|
//# sourceMappingURL=account.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/core/account.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/core/account.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOlH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,MAAM,SAAS,GAAG,QAAQ,EAAE,CAAC;IAC7B,MAAM,cAAc,GAAW,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAE3D,MAAM,GAAG,GAAS,EAAE,CAAC;IAErB,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC;QACtC,EAAE,EAAE,SAAS;QACb,MAAM,EAAE;YACN,CAAC,gBAAgB,CAAC,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE;YAC7C,CAAC,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE;SAC3C;KACF,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;IAEvB,mBAAmB;IACnB,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;QACzC,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;IAExB,sBAAsB;IACtB,gEAAgE;IAChE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;QACzC,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;IAExB,OAAO;QACL,SAAS;QACT,GAAG;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { expect, it } from 'vitest';
|
|
2
|
+
import { Id, toBase64 } from '../id.js';
|
|
2
3
|
import { NetworkIds, SystemIds } from '../system-ids.js';
|
|
3
4
|
import { make } from './account.js';
|
|
4
5
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
5
6
|
it('should generate ops for an account entity', () => {
|
|
6
7
|
const { accountId, ops } = make(ZERO_ADDRESS);
|
|
7
|
-
const [accountTypeOp, networkOp
|
|
8
|
-
expect(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
expect(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
const [entityOp, accountTypeOp, networkOp] = ops;
|
|
9
|
+
expect(entityOp?.type).toBe('UPDATE_ENTITY');
|
|
10
|
+
if (entityOp?.type === 'UPDATE_ENTITY' && entityOp?.entity.values?.[0]) {
|
|
11
|
+
expect(entityOp.entity.values[0].propertyId).toBe(toBase64(SystemIds.ADDRESS_PROPERTY));
|
|
12
|
+
expect(entityOp.entity.values[0].value).toBe(ZERO_ADDRESS);
|
|
13
|
+
expect(entityOp.entity.id).toBe(toBase64(Id(accountId)));
|
|
14
|
+
}
|
|
15
|
+
if (entityOp?.type === 'UPDATE_ENTITY' && entityOp?.entity.values?.[1]) {
|
|
16
|
+
expect(entityOp.entity.values[1].propertyId).toBe(toBase64(SystemIds.NAME_PROPERTY));
|
|
17
|
+
expect(entityOp.entity.values[1].value).toBe(ZERO_ADDRESS);
|
|
18
|
+
expect(entityOp.entity.id).toBe(toBase64(Id(accountId)));
|
|
19
|
+
}
|
|
20
|
+
expect(accountTypeOp?.type).toBe('CREATE_RELATION');
|
|
21
|
+
if (accountTypeOp?.type === 'CREATE_RELATION') {
|
|
22
|
+
expect(accountTypeOp.relation.type).toBe(toBase64(SystemIds.TYPES_PROPERTY));
|
|
23
|
+
expect(accountTypeOp.relation.toEntity).toBe(toBase64(SystemIds.ACCOUNT_TYPE));
|
|
24
|
+
expect(accountTypeOp.relation.fromEntity).toBe(toBase64(Id(accountId)));
|
|
25
|
+
}
|
|
26
|
+
expect(networkOp?.type).toBe('CREATE_RELATION');
|
|
27
|
+
if (networkOp?.type === 'CREATE_RELATION') {
|
|
28
|
+
expect(networkOp.relation.type).toBe(toBase64(SystemIds.NETWORK_PROPERTY));
|
|
29
|
+
expect(networkOp.relation.toEntity).toBe(toBase64(NetworkIds.ETHEREUM));
|
|
30
|
+
expect(networkOp.relation.fromEntity).toBe(toBase64(Id(accountId)));
|
|
31
|
+
}
|
|
24
32
|
});
|
|
25
33
|
//# sourceMappingURL=account.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.test.js","sourceRoot":"","sources":["../../../src/core/account.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAElE,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACnD,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"account.test.js","sourceRoot":"","sources":["../../../src/core/account.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAElE,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACnD,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,SAAS,CAAC,GAAG,GAAG,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: string;
|
|
@@ -29,6 +29,6 @@ type DataBlockParams = {
|
|
|
29
29
|
* @param param args {@link TextBlockParams}
|
|
30
30
|
* @returns ops – The ops for the Data Block entity: {@link Op}[]
|
|
31
31
|
*/
|
|
32
|
-
export declare function make({ fromId, sourceType, position, name }: DataBlockParams):
|
|
32
|
+
export declare function make({ fromId, sourceType, position, name }: DataBlockParams): Op[];
|
|
33
33
|
export {};
|
|
34
34
|
//# sourceMappingURL=data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/core/blocks/data.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/core/blocks/data.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGzC,KAAK,mBAAmB,GAAG,OAAO,GAAG,YAAY,GAAG,KAAK,CAAC;AAa1D,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,mBAAmB,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,EAAE,EAAE,CAqClF"}
|