Skip to content

Commit

Permalink
feat: update token registry v4 compatibility (#10)
Browse files Browse the repository at this point in the history
* feat: v4 compatibility

* chore: bump token registry version

* docs: update examples

* chore: bump token registry version

* chore: bump token registry

* fix: update nominee call

* feat: update config network to goerli

* docs: update rinkey to goerli
  • Loading branch information
superical authored Oct 27, 2022
1 parent 61da000 commit 77008c6
Show file tree
Hide file tree
Showing 10 changed files with 572 additions and 390 deletions.
128 changes: 69 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Configure your Token Registry contract addresses in the `config.json` file.

```json
{
"network": "rinkeby",
"network": "goerli",
"dataSources": [
{
"address": "0xabc",
Expand Down Expand Up @@ -100,74 +100,84 @@ deploy the subgraph to the hosted service.
There are many interesting queries that can be made. Here are some example queries:

* What are all the document IDs and their surrender statuses in my Token Registries?
```graphql
{
tokenRegistries {
tokens {
documentIdHex
surrendered
}
```graphql
{
tokenRegistries {
tokens {
documentId
surrendered
}
}
```
}
```
* What are all the documents that the user `0xbabe` is currently a beneficiary?
```graphql
{
accounts (where: {
id: "0xbabe"
}) {
tokensAsBeneficiary {
documentIdHex
```graphql
{
accounts(where: { id: "0xbabe" }) {
id
titleEscrowsAsBeneficiary {
token {
documentId
}
}
}
}
```
* What about listing snapshots of a document at the time of all actions (issuance, surrender, etc)?
```graphql
{
tokens(
where: { documentId: "0x0ddba11" }
) {
tokenSnapshots (orderBy: timestamp) {
timestamp
action
beneficiary {
id
}
holder {
id
}
nominee {
id
}
surrendered
accepted
}
}
```
}
```
* Can I have the complete token transfers (including holder transfers) and approval histories of the document ID `0x0ddba11`? I want to know the beneficiaries and holders that were transferred to and from.
> 💡 This query is useful (and also a much easier and elegant way) for building the [endorsement chain](https://docs.tradetrust.io/docs/tradetrust-website/endorsement-chain/) of a document or just trying to retrieve the ownership details of any documents.
```graphql
{
tokens (where: {
documentIdHex: "0x0ddba11"
}) {
transferEvents (orderBy: timestamp) {
timestamp
type
fromTitleEscrow {
beneficiary {
id
}
holder {
id
}
}
toTitleEscrow {
beneficiary {
id
}
holder {
id
}
}
```graphql
{
tokens(
where: { documentId: "0x0ddba11" }
) {
beneficiaryTransfers(orderBy: timestamp) {
timestamp
from {
id
}
titleEscrowApprovalEvents (orderBy: timestamp) {
timestamp
approvedBeneficiary {
id
}
approvedHolder {
id
}
to {
id
}
}
holderTransfers(orderBy: timestamp) {
timestamp
from {
id
}
titleEscrowHolderTransferEvents (orderBy: timestamp) {
timestamp
prevHolder {
id
}
holder {
id
}
to {
id
}
}
nominations(orderBy: timestamp) {
timestamp
nominee {
id
}
}
}
```

}
```
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"network": "rinkeby",
"network": "goerli",
"dataSources": [
{
"address": "0xabc",
Expand Down
27 changes: 23 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 token-registry-subgraph"
},
"devDependencies": {
"@govtechsg/token-registry": "^4.0.0-beta.5",
"@govtechsg/token-registry": "^4.0.0-beta.18",
"@graphprotocol/graph-cli": "0.26.0",
"@graphprotocol/graph-ts": "0.24.1",
"handlebars": "^4.7.7"
Expand Down
Loading

0 comments on commit 77008c6

Please sign in to comment.