-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 784cccb
Showing
10 changed files
with
3,861 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,286 @@ | ||
[ | ||
{ "type": "constructor", "stateMutability": "nonpayable", "inputs": [] }, | ||
{ | ||
"type": "event", | ||
"name": "Approval", | ||
"inputs": [ | ||
{ | ||
"type": "address", | ||
"name": "owner", | ||
"internalType": "address", | ||
"indexed": true | ||
}, | ||
{ | ||
"type": "address", | ||
"name": "approved", | ||
"internalType": "address", | ||
"indexed": true | ||
}, | ||
{ | ||
"type": "uint256", | ||
"name": "tokenId", | ||
"internalType": "uint256", | ||
"indexed": true | ||
} | ||
], | ||
"anonymous": false | ||
}, | ||
{ | ||
"type": "event", | ||
"name": "ApprovalForAll", | ||
"inputs": [ | ||
{ | ||
"type": "address", | ||
"name": "owner", | ||
"internalType": "address", | ||
"indexed": true | ||
}, | ||
{ | ||
"type": "address", | ||
"name": "operator", | ||
"internalType": "address", | ||
"indexed": true | ||
}, | ||
{ | ||
"type": "bool", | ||
"name": "approved", | ||
"internalType": "bool", | ||
"indexed": false | ||
} | ||
], | ||
"anonymous": false | ||
}, | ||
{ | ||
"type": "event", | ||
"name": "OwnershipTransferred", | ||
"inputs": [ | ||
{ | ||
"type": "address", | ||
"name": "previousOwner", | ||
"internalType": "address", | ||
"indexed": true | ||
}, | ||
{ | ||
"type": "address", | ||
"name": "newOwner", | ||
"internalType": "address", | ||
"indexed": true | ||
} | ||
], | ||
"anonymous": false | ||
}, | ||
{ | ||
"type": "event", | ||
"name": "Transfer", | ||
"inputs": [ | ||
{ | ||
"type": "address", | ||
"name": "from", | ||
"internalType": "address", | ||
"indexed": true | ||
}, | ||
{ | ||
"type": "address", | ||
"name": "to", | ||
"internalType": "address", | ||
"indexed": true | ||
}, | ||
{ | ||
"type": "uint256", | ||
"name": "tokenId", | ||
"internalType": "uint256", | ||
"indexed": true | ||
} | ||
], | ||
"anonymous": false | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "nonpayable", | ||
"outputs": [], | ||
"name": "approve", | ||
"inputs": [ | ||
{ "type": "address", "name": "to", "internalType": "address" }, | ||
{ "type": "uint256", "name": "tokenId", "internalType": "uint256" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "uint256", "name": "", "internalType": "uint256" }], | ||
"name": "balanceOf", | ||
"inputs": [ | ||
{ "type": "address", "name": "owner", "internalType": "address" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "string", "name": "", "internalType": "string" }], | ||
"name": "baseURI", | ||
"inputs": [] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "address", "name": "", "internalType": "address" }], | ||
"name": "getApproved", | ||
"inputs": [ | ||
{ "type": "uint256", "name": "tokenId", "internalType": "uint256" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "bool", "name": "", "internalType": "bool" }], | ||
"name": "isApprovedForAll", | ||
"inputs": [ | ||
{ "type": "address", "name": "owner", "internalType": "address" }, | ||
{ "type": "address", "name": "operator", "internalType": "address" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "nonpayable", | ||
"outputs": [{ "type": "uint256", "name": "", "internalType": "uint256" }], | ||
"name": "mintItem", | ||
"inputs": [ | ||
{ "type": "address", "name": "to", "internalType": "address" }, | ||
{ "type": "string", "name": "tokenURI", "internalType": "string" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "string", "name": "", "internalType": "string" }], | ||
"name": "name", | ||
"inputs": [] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "address", "name": "", "internalType": "address" }], | ||
"name": "owner", | ||
"inputs": [] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "address", "name": "", "internalType": "address" }], | ||
"name": "ownerOf", | ||
"inputs": [ | ||
{ "type": "uint256", "name": "tokenId", "internalType": "uint256" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "nonpayable", | ||
"outputs": [], | ||
"name": "renounceOwnership", | ||
"inputs": [] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "nonpayable", | ||
"outputs": [], | ||
"name": "safeTransferFrom", | ||
"inputs": [ | ||
{ "type": "address", "name": "from", "internalType": "address" }, | ||
{ "type": "address", "name": "to", "internalType": "address" }, | ||
{ "type": "uint256", "name": "tokenId", "internalType": "uint256" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "nonpayable", | ||
"outputs": [], | ||
"name": "safeTransferFrom", | ||
"inputs": [ | ||
{ "type": "address", "name": "from", "internalType": "address" }, | ||
{ "type": "address", "name": "to", "internalType": "address" }, | ||
{ "type": "uint256", "name": "tokenId", "internalType": "uint256" }, | ||
{ "type": "bytes", "name": "_data", "internalType": "bytes" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "nonpayable", | ||
"outputs": [], | ||
"name": "setApprovalForAll", | ||
"inputs": [ | ||
{ "type": "address", "name": "operator", "internalType": "address" }, | ||
{ "type": "bool", "name": "approved", "internalType": "bool" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "bool", "name": "", "internalType": "bool" }], | ||
"name": "supportsInterface", | ||
"inputs": [ | ||
{ "type": "bytes4", "name": "interfaceId", "internalType": "bytes4" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "string", "name": "", "internalType": "string" }], | ||
"name": "symbol", | ||
"inputs": [] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "uint256", "name": "", "internalType": "uint256" }], | ||
"name": "tokenByIndex", | ||
"inputs": [ | ||
{ "type": "uint256", "name": "index", "internalType": "uint256" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "uint256", "name": "", "internalType": "uint256" }], | ||
"name": "tokenOfOwnerByIndex", | ||
"inputs": [ | ||
{ "type": "address", "name": "owner", "internalType": "address" }, | ||
{ "type": "uint256", "name": "index", "internalType": "uint256" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "string", "name": "", "internalType": "string" }], | ||
"name": "tokenURI", | ||
"inputs": [ | ||
{ "type": "uint256", "name": "tokenId", "internalType": "uint256" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "view", | ||
"outputs": [{ "type": "uint256", "name": "", "internalType": "uint256" }], | ||
"name": "totalSupply", | ||
"inputs": [] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "nonpayable", | ||
"outputs": [], | ||
"name": "transferFrom", | ||
"inputs": [ | ||
{ "type": "address", "name": "from", "internalType": "address" }, | ||
{ "type": "address", "name": "to", "internalType": "address" }, | ||
{ "type": "uint256", "name": "tokenId", "internalType": "uint256" } | ||
] | ||
}, | ||
{ | ||
"type": "function", | ||
"stateMutability": "nonpayable", | ||
"outputs": [], | ||
"name": "transferOwnership", | ||
"inputs": [ | ||
{ "type": "address", "name": "newOwner", "internalType": "address" } | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "fuse-network-erc721", | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"codegen": "graph codegen", | ||
"build": "graph build", | ||
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ gundamdweeb/fuse-nftv2", | ||
"create-local": "graph create --node http://localhost:8020/ gundamdweeb/fuse-network-erc721", | ||
"remove-local": "graph remove --node http://localhost:8020/ gundamdweeb/fuse-network-erc721", | ||
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 gundamdweeb/fuse-network-erc721" | ||
}, | ||
"dependencies": { | ||
"@graphprotocol/graph-cli": "0.27.0", | ||
"@graphprotocol/graph-ts": "0.24.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
type Account @entity { | ||
id: ID! | ||
address: Bytes! | ||
} | ||
|
||
type Collectible @entity { | ||
id: ID! | ||
collection: Collection! | ||
|
||
owner: Account! | ||
creator: Account! | ||
|
||
tokenId: BigInt! | ||
descriptorURI: String! | ||
|
||
#timestamps | ||
modified: BigInt | ||
created: BigInt | ||
removed: BigInt | ||
|
||
#Metadata | ||
name: String | ||
description: String | ||
|
||
} | ||
|
||
type Collection @entity { | ||
id: ID! | ||
collectionName: String! | ||
collectionSymbol: String! | ||
collectionAddress: Bytes! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { BigInt, log } from "@graphprotocol/graph-ts" | ||
import { | ||
ERC721, | ||
Transfer | ||
} from "../generated/ERC721/ERC721" | ||
import { Account, Collectible, Collection} from "../generated/schema"; | ||
import { ADDRESS_ZERO, getOrCreateAccount } from "./utils"; | ||
|
||
|
||
export function handleTransfer(event: Transfer): void { | ||
let from = getOrCreateAccount(event.params.from); | ||
let to = getOrCreateAccount(event.params.to); | ||
let collection = Collection.load(event.address.toHex()) | ||
let collectibleId = event.address.toHex() + "-" + event.params.tokenId.toHex(); | ||
|
||
if (event.params.from.toHexString() == ADDRESS_ZERO.toHexString()){ | ||
// THIS IS A MINT EVENT | ||
let collectible = new Collectible(collectibleId); | ||
collectible.collection = event.address.toHex(); | ||
collectible.tokenId = event.params.tokenId; | ||
collectible.owner = to.id; | ||
collectible.creator = to.id; | ||
collectible.created = event.block.timestamp; | ||
|
||
let erc721Contract = ERC721.bind(event.address); | ||
let descriptorUri = erc721Contract.try_tokenURI(event.params.tokenId); | ||
if(!descriptorUri.reverted) | ||
{ | ||
collectible.descriptorURI = descriptorUri.value; | ||
}else{ | ||
collectible.descriptorURI = ""; | ||
} | ||
collectible.save() | ||
log.info("MINT EVENT - TOKENID {}, TxHash {}", [collectibleId, event.transaction.hash.toHexString()]) | ||
} | ||
else { | ||
let collectible = Collectible.load(collectibleId); | ||
|
||
if (collectible != null) { | ||
collectible.modified = event.block.timestamp; | ||
if(event.params.to.toHexString() === ADDRESS_ZERO.toHexString()) { | ||
collectible.removed = event.block.timestamp; | ||
log.info("BURN EVENT - TOKENID {}, TxHash {}", [collectibleId, event.transaction.hash.toHexString()]) | ||
} else { | ||
collectible.owner = to.id; | ||
log.info("TRANSFER EVENT - TOKENID {}, TxHash {}", [collectibleId, event.transaction.hash.toHexString()]) | ||
} | ||
collectible.save() | ||
} | ||
} | ||
} |
Oops, something went wrong.