Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.10 #6

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 0.1.10
* Add `ERC721Rift` for rift states - note that state setup in constructor() does not show up and will have to be fetched on-chain.
* Fix "could not find ABI for contract `IERC721` in `naut`"
* Implement `Planet` module
* Implement `Delegation` module

### 0.1.9
* Implement `Naut` module
* Fix `ERC721` and `ERC1155` implementations not updating token URIs on every load; they were only set once on initialisation and never updated.
Expand Down
2 changes: 2 additions & 0 deletions configs/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
"module": [
"accesscontrol",
"delegation",
"erc1155",
"erc1967upgrade",
"erc20",
Expand All @@ -12,6 +13,7 @@
"naut",
"ownable",
"pausable",
"planet",
"timelock",
"voting"
]
Expand Down
10 changes: 10 additions & 0 deletions configs/delegation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"output": "generated/delegation.",
"datasources": [
{
"module": [
"delegation"
]
}
]
}
10 changes: 10 additions & 0 deletions configs/planet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"output": "generated/planet.",
"datasources": [
{
"module": [
"planet"
]
}
]
}
112 changes: 69 additions & 43 deletions generated/all.schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ type Account @entity {
roleGrantedSender: [RoleGranted!]! @derivedFrom(field: "sender")
roleRevoked: [RoleRevoked!]! @derivedFrom(field: "account")
roleRevokedSender: [RoleRevoked!]! @derivedFrom(field: "sender")
asERC721: ERC721Contract
ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner")
ERC721operatorOwner: [ERC721Operator!]! @derivedFrom(field: "owner")
ERC721operatorOperator: [ERC721Operator!]! @derivedFrom(field: "operator")
ERC721transferFromEvent: [ERC721Transfer!]! @derivedFrom(field: "from")
ERC721transferToEvent: [ERC721Transfer!]! @derivedFrom(field: "to")
asERC1155: ERC1155Contract
ERC1155balances: [ERC1155Balance!]! @derivedFrom(field: "account")
ERC1155operatorOwner: [ERC1155Operator!]! @derivedFrom(field: "owner")
Expand All @@ -31,12 +37,6 @@ type Account @entity {
ERC20approvalsSpender: [ERC20Approval!]! @derivedFrom(field: "spender")
ERC20transferFromEvent: [ERC20Transfer!]! @derivedFrom(field: "from")
ERC20transferToEvent: [ERC20Transfer!]! @derivedFrom(field: "to")
asERC721: ERC721Contract
ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner")
ERC721operatorOwner: [ERC721Operator!]! @derivedFrom(field: "owner")
ERC721operatorOperator: [ERC721Operator!]! @derivedFrom(field: "operator")
ERC721transferFromEvent: [ERC721Transfer!]! @derivedFrom(field: "from")
ERC721transferToEvent: [ERC721Transfer!]! @derivedFrom(field: "to")
asGovernor: Governor
proposed: [Proposal!]! @derivedFrom(field: "proposer")
voted: [VoteReceipt!]! @derivedFrom(field: "voter")
Expand Down Expand Up @@ -109,6 +109,54 @@ type RoleRevoked implements Event @entity(immutable: true) {
account: Account!
sender: Account!
}
type ERC721Contract @entity(immutable: true) {
id: Bytes!
asAccount: Account!
supportsMetadata: Boolean
name: String
symbol: String
tokens: [ERC721Token!]! @derivedFrom(field: "contract")
operators: [ERC721Operator!]! @derivedFrom(field: "contract")
transfers: [ERC721Transfer!]! @derivedFrom(field: "contract")
delegators: [ERC721Delegator!]! @derivedFrom(field: "contract")
rifts: [ERC721Rift!]! @derivedFrom(field: "contract")
planetDefaultState: BigInt
}
type ERC721Token @entity {
id: ID!
contract: ERC721Contract!
identifier: BigInt!
owner: Account!
approval: Account!
uri: String
transfers: [ERC721Transfer!]! @derivedFrom(field: "token")
asNaut: Naut
asPlanet: Planet
}
type ERC721Operator @entity {
id: ID!
contract: ERC721Contract!
owner: Account!
operator: Account!
approved: Boolean!
}
type ERC721Delegator @entity {
id: ID!
contract: ERC721Contract!
owner: Account!
deleagor: Account!
approved: Boolean!
}
type ERC721Transfer implements Event @entity(immutable: true) {
id: ID!
emitter: Account!
transaction: Transaction!
timestamp: BigInt!
contract: ERC721Contract!
token: ERC721Token!
from: Account!
to: Account!
}
type ERC1155Contract @entity(immutable: true) {
id: Bytes!
asAccount: Account!
Expand Down Expand Up @@ -220,43 +268,6 @@ type ERC20Transfer implements Event @entity(immutable: true) {
value: BigDecimal!
valueExact: BigInt!
}
type ERC721Contract @entity(immutable: true) {
id: Bytes!
asAccount: Account!
supportsMetadata: Boolean
name: String
symbol: String
tokens: [ERC721Token!]! @derivedFrom(field: "contract")
operators: [ERC721Operator!]! @derivedFrom(field: "contract")
transfers: [ERC721Transfer!]! @derivedFrom(field: "contract")
}
type ERC721Token @entity {
id: ID!
contract: ERC721Contract!
identifier: BigInt!
owner: Account!
approval: Account!
uri: String
transfers: [ERC721Transfer!]! @derivedFrom(field: "token")
asNaut: Naut
}
type ERC721Operator @entity {
id: ID!
contract: ERC721Contract!
owner: Account!
operator: Account!
approved: Boolean!
}
type ERC721Transfer implements Event @entity(immutable: true) {
id: ID!
emitter: Account!
transaction: Transaction!
timestamp: BigInt!
contract: ERC721Contract!
token: ERC721Token!
from: Account!
to: Account!
}
type Governor @entity(immutable: true) {
id: Bytes!
asAccount: Account!
Expand Down Expand Up @@ -357,6 +368,12 @@ type VoteCast implements Event @entity(immutable: true) {
receipt: VoteReceipt!
voter: Account!
}
type ERC721Rift @entity {
id: ID!
contract: ERC721Contract!
state: BigInt!
baseURI: String!
}
type Naut @entity {
id: ID!
token: ERC721Token!
Expand Down Expand Up @@ -390,6 +407,15 @@ type Paused implements Event @entity(immutable: true) {
contract: Pausable!
isPaused: Boolean!
}
type Planet @entity {
id: ID!
token: ERC721Token!
name: String!
description: String!
locked: Boolean!
enabled: Boolean!
state: BigInt!
}
type Timelock @entity(immutable: true) {
id: Bytes!
asAccount: Account!
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wanderers/subgraphs",
"description": "Subgraph templates for @openzeppelin/contracts, extended for the Wanderverse.",
"version": "0.1.9",
"version": "0.1.10",
"contributors": [
"OpenZeppelin Community <[email protected]>",
"Wanderers <[email protected]>"
Expand Down Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"@amxx/graphprotocol-utils": "^1.1.0",
"@openzeppelin/contracts": "^4.6.0",
"@wanderers/subgraphs-contract-abis": "^1.0.0"
"@wanderers/subgraphs-contract-abis": "^1.2.1"
},
"devDependencies": {
"@graphprotocol/graph-cli": "^0.29.2",
Expand Down
65 changes: 65 additions & 0 deletions src/datasources/delegation.gql.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[{
"name": "Account",
"fields": [
{ "name": "id", "type": "Bytes!" },
{ "name": "asERC721", "type": "ERC721Contract" },
{ "name": "ERC721tokens", "type": "ERC721Token!", "derived": "owner" },
{ "name": "ERC721operatorOwner", "type": "ERC721Operator!", "derived": "owner" },
{ "name": "ERC721operatorOperator", "type": "ERC721Operator!", "derived": "operator" },
{ "name": "ERC721transferFromEvent", "type": "ERC721Transfer!", "derived": "from" },
{ "name": "ERC721transferToEvent", "type": "ERC721Transfer!", "derived": "to" }
]
},{
"name": "ERC721Contract",
"immutable": true,
"fields": [
{ "name": "id", "type": "Bytes!" },
{ "name": "asAccount", "type": "Account!" },
{ "name": "supportsMetadata", "type": "Boolean" },
{ "name": "name", "type": "String" },
{ "name": "symbol", "type": "String" },
{ "name": "tokens", "type": "ERC721Token!", "derived": "contract" },
{ "name": "operators", "type": "ERC721Operator!", "derived": "contract" },
{ "name": "transfers", "type": "ERC721Transfer!", "derived": "contract" },
{ "name": "delegators", "type": "ERC721Delegator!","derived": "contract" }
]
},{
"name": "ERC721Token",
"fields": [
{ "name": "contract", "type": "ERC721Contract!" },
{ "name": "identifier", "type": "BigInt!" },
{ "name": "owner", "type": "Account!" },
{ "name": "approval", "type": "Account!" },
{ "name": "uri", "type": "String" },
{ "name": "transfers", "type": "ERC721Transfer!", "derived": "token" }
]
},{
"name": "ERC721Operator",
"fields": [
{ "name": "contract", "type": "ERC721Contract!" },
{ "name": "owner", "type": "Account!" },
{ "name": "operator", "type": "Account!" },
{ "name": "approved", "type": "Boolean!" }
]
},{
"name": "ERC721Delegator",
"fields": [
{ "name": "contract", "type": "ERC721Contract!" },
{ "name": "owner", "type": "Account!" },
{ "name": "deleagor", "type": "Account!" },
{ "name": "approved", "type": "Boolean!" }
]
},{
"name": "ERC721Transfer",
"parent": "Event",
"immutable": true,
"fields": [
{ "name": "emitter", "type": "Account!" },
{ "name": "transaction", "type": "Transaction!" },
{ "name": "timestamp", "type": "BigInt!" },
{ "name": "contract", "type": "ERC721Contract!" },
{ "name": "token", "type": "ERC721Token!" },
{ "name": "from", "type": "Account!" },
{ "name": "to", "type": "Account!" }
]
}]
18 changes: 18 additions & 0 deletions src/datasources/delegation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {
DelegationApproval as DelegationApprovalEvent
} from '../../generated/delegation/Delegation'
import { fetchAccount } from '../fetch/account'
import { fetchERC721Delegator } from '../fetch/delegation';
import { fetchERC721 } from '../fetch/erc721'

export function handleDelegationApproval(event: DelegationApprovalEvent): void {
let contract = fetchERC721(event.address);
if (contract != null) {
let owner = fetchAccount(event.params.owner);
let operator = fetchAccount(event.params.operator);
let delegation = fetchERC721Delegator(contract, owner, operator);

delegation.approved = event.params.approved
delegation.save()
}
}
22 changes: 22 additions & 0 deletions src/datasources/delegation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- kind: ethereum/contract
name: {id}
network: {chain}
source:
address: "{address}"
abi: Delegation
startBlock: {startBlock}
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- ERC721ContractDelegation
abis:
- name: Delegation
file: {root}/node_modules/@wanderers/subgraphs-contract-abis/src/Delegation.json
- name: IERC721
file: {root}/node_modules/@openzeppelin/contracts/build/contracts/IERC721Metadata.json
eventHandlers:
- event: DelegationApproval(indexed address,indexed address,bool)
handler: handleDelegationApproval
file: {file}
Loading