feat: subgraph reverse lookup (gitRepo -> NFA) (#131)

* feat: define the GithubRepository entity and update the Token entity to include it.

* feat: add NewMint event to the contract and emit it in the mint function.

* feat: add newmint entity, update token and gitrepository entities. add handler for entities. update transfer entity handler. update subgraph.yaml config.

* chore: deployment update

* chore: fix proxy file with before deployments

* fix: remove constructor args in verify-polyscan.js file and update contract address at subgraph.yaml

* fix: remove develop from subgraph.yaml gh action.

* merge: develop with auto approval settings into reverse lookup branch

* fix: remove the word settings from acesspointautoapproval param.

* fix: error in hardhat last token id test

* fix: solidity tests.

* fix: proxy contract address in subgraph.yaml.

* chore: run subgraph tests only on main PRs

---------

Co-authored-by: Felipe Mendes <zo.fmendes@gmail.com>
This commit is contained in:
Shredder 2023-02-24 16:22:18 +03:30 committed by GitHub
parent 70df262d94
commit 2ae7666648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1077 additions and 160 deletions

View File

@ -4,9 +4,6 @@ on:
pull_request:
branches:
- main
push:
paths:
- 'subgraph/**'
jobs:

View File

@ -24,6 +24,11 @@
"address": "0x8679f8A4Fb3AaA1E851100D2C0444a729a3D946C",
"txHash": "0x41955ba2435182dec361dc060e7f468c52d364da4bb256c980e803ef15a4d0c6",
"kind": "transparent"
},
{
"address": "0x11Cd77Eac1a0883DE9435B5586474903A2a084cD",
"txHash": "0x5166318336c9e0bef146562d58e01ddbb937a61b721aca6b24d41b0a189fde39",
"kind": "transparent"
}
],
"impls": {
@ -194,7 +199,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -509,7 +517,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -824,7 +835,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -1139,7 +1153,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -1454,7 +1471,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -1769,7 +1789,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -2084,7 +2107,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -2399,7 +2425,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -2726,7 +2755,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -3109,7 +3141,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -3496,7 +3531,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -3895,7 +3933,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -4290,7 +4331,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -4689,7 +4733,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -5088,7 +5135,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -5487,7 +5537,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -5886,7 +5939,10 @@
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": ["Owner", "Controller"],
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
@ -6105,6 +6161,404 @@
}
}
}
},
"6b0fc2c7dba868ffb242ce4948c8c30138f2aff0ed6612d867fc76b73b0bfc16": {
"address": "0x113169680A417e4dB4AD11832486FF317fB4CB36",
"txHash": "0xf81372c165b26c5efc7a9cca5ea0a0546505597de566e3626a245a5ee093ced3",
"layout": {
"solcVersion": "0.8.12",
"storage": [
{
"label": "_initialized",
"offset": 0,
"slot": "0",
"type": "t_uint8",
"contract": "Initializable",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62",
"retypedFrom": "bool"
},
{
"label": "_initializing",
"offset": 1,
"slot": "0",
"type": "t_bool",
"contract": "Initializable",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67"
},
{
"label": "__gap",
"offset": 0,
"slot": "1",
"type": "t_array(t_uint256)50_storage",
"contract": "ContextUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36"
},
{
"label": "__gap",
"offset": 0,
"slot": "51",
"type": "t_array(t_uint256)50_storage",
"contract": "ERC165Upgradeable",
"src": "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol:41"
},
{
"label": "_name",
"offset": 0,
"slot": "101",
"type": "t_string_storage",
"contract": "ERC721Upgradeable",
"src": "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol:25"
},
{
"label": "_symbol",
"offset": 0,
"slot": "102",
"type": "t_string_storage",
"contract": "ERC721Upgradeable",
"src": "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol:28"
},
{
"label": "_owners",
"offset": 0,
"slot": "103",
"type": "t_mapping(t_uint256,t_address)",
"contract": "ERC721Upgradeable",
"src": "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol:31"
},
{
"label": "_balances",
"offset": 0,
"slot": "104",
"type": "t_mapping(t_address,t_uint256)",
"contract": "ERC721Upgradeable",
"src": "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol:34"
},
{
"label": "_tokenApprovals",
"offset": 0,
"slot": "105",
"type": "t_mapping(t_uint256,t_address)",
"contract": "ERC721Upgradeable",
"src": "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol:37"
},
{
"label": "_operatorApprovals",
"offset": 0,
"slot": "106",
"type": "t_mapping(t_address,t_mapping(t_address,t_bool))",
"contract": "ERC721Upgradeable",
"src": "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol:40"
},
{
"label": "__gap",
"offset": 0,
"slot": "107",
"type": "t_array(t_uint256)44_storage",
"contract": "ERC721Upgradeable",
"src": "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol:514"
},
{
"label": "_collectionRolesVersion",
"offset": 0,
"slot": "151",
"type": "t_struct(Counter)2774_storage",
"contract": "FleekAccessControl",
"src": "contracts/FleekAccessControl.sol:26"
},
{
"label": "_collectionRoles",
"offset": 0,
"slot": "152",
"type": "t_mapping(t_uint256,t_mapping(t_enum(Roles)3895,t_struct(Role)3943_storage))",
"contract": "FleekAccessControl",
"src": "contracts/FleekAccessControl.sol:28"
},
{
"label": "_tokenRolesVersion",
"offset": 0,
"slot": "153",
"type": "t_mapping(t_uint256,t_struct(Counter)2774_storage)",
"contract": "FleekAccessControl",
"src": "contracts/FleekAccessControl.sol:30"
},
{
"label": "_tokenRoles",
"offset": 0,
"slot": "154",
"type": "t_mapping(t_uint256,t_mapping(t_uint256,t_mapping(t_enum(Roles)3895,t_struct(Role)3943_storage)))",
"contract": "FleekAccessControl",
"src": "contracts/FleekAccessControl.sol:32"
},
{
"label": "_appIds",
"offset": 0,
"slot": "155",
"type": "t_struct(Counter)2774_storage",
"contract": "FleekERC721",
"src": "contracts/FleekERC721.sol:102"
},
{
"label": "_apps",
"offset": 0,
"slot": "156",
"type": "t_mapping(t_uint256,t_struct(App)4722_storage)",
"contract": "FleekERC721",
"src": "contracts/FleekERC721.sol:103"
},
{
"label": "_accessPoints",
"offset": 0,
"slot": "157",
"type": "t_mapping(t_string_memory_ptr,t_struct(AccessPoint)4740_storage)",
"contract": "FleekERC721",
"src": "contracts/FleekERC721.sol:104"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_array(t_address)dyn_storage": {
"label": "address[]",
"numberOfBytes": "32"
},
"t_array(t_uint256)44_storage": {
"label": "uint256[44]",
"numberOfBytes": "1408"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]",
"numberOfBytes": "1600"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_enum(Roles)3895": {
"label": "enum FleekAccessControl.Roles",
"members": [
"Owner",
"Controller"
],
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
"label": "mapping(address => bool)",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_mapping(t_address,t_bool))": {
"label": "mapping(address => mapping(address => bool))",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_uint256)": {
"label": "mapping(address => uint256)",
"numberOfBytes": "32"
},
"t_mapping(t_enum(Roles)3895,t_struct(Role)3943_storage)": {
"label": "mapping(enum FleekAccessControl.Roles => struct FleekAccessControl.Role)",
"numberOfBytes": "32"
},
"t_mapping(t_string_memory_ptr,t_struct(AccessPoint)4740_storage)": {
"label": "mapping(string => struct FleekERC721.AccessPoint)",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_address)": {
"label": "mapping(uint256 => address)",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_mapping(t_enum(Roles)3895,t_struct(Role)3943_storage))": {
"label": "mapping(uint256 => mapping(enum FleekAccessControl.Roles => struct FleekAccessControl.Role))",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_mapping(t_uint256,t_mapping(t_enum(Roles)3895,t_struct(Role)3943_storage)))": {
"label": "mapping(uint256 => mapping(uint256 => mapping(enum FleekAccessControl.Roles => struct FleekAccessControl.Role)))",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_struct(App)4722_storage)": {
"label": "mapping(uint256 => struct FleekERC721.App)",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_struct(Build)4727_storage)": {
"label": "mapping(uint256 => struct FleekERC721.Build)",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_struct(Counter)2774_storage)": {
"label": "mapping(uint256 => struct Counters.Counter)",
"numberOfBytes": "32"
},
"t_string_memory_ptr": {
"label": "string",
"numberOfBytes": "32"
},
"t_string_storage": {
"label": "string",
"numberOfBytes": "32"
},
"t_struct(AccessPoint)4740_storage": {
"label": "struct FleekERC721.AccessPoint",
"members": [
{
"label": "tokenId",
"type": "t_uint256",
"offset": 0,
"slot": "0"
},
{
"label": "score",
"type": "t_uint256",
"offset": 0,
"slot": "1"
},
{
"label": "contentVerified",
"type": "t_bool",
"offset": 0,
"slot": "2"
},
{
"label": "nameVerified",
"type": "t_bool",
"offset": 1,
"slot": "2"
},
{
"label": "owner",
"type": "t_address",
"offset": 2,
"slot": "2"
},
{
"label": "status",
"type": "t_string_storage",
"offset": 0,
"slot": "3"
}
],
"numberOfBytes": "128"
},
"t_struct(App)4722_storage": {
"label": "struct FleekERC721.App",
"members": [
{
"label": "name",
"type": "t_string_storage",
"offset": 0,
"slot": "0"
},
{
"label": "description",
"type": "t_string_storage",
"offset": 0,
"slot": "1"
},
{
"label": "externalURL",
"type": "t_string_storage",
"offset": 0,
"slot": "2"
},
{
"label": "ENS",
"type": "t_string_storage",
"offset": 0,
"slot": "3"
},
{
"label": "currentBuild",
"type": "t_uint256",
"offset": 0,
"slot": "4"
},
{
"label": "builds",
"type": "t_mapping(t_uint256,t_struct(Build)4727_storage)",
"offset": 0,
"slot": "5"
},
{
"label": "logo",
"type": "t_string_storage",
"offset": 0,
"slot": "6"
},
{
"label": "color",
"type": "t_uint24",
"offset": 0,
"slot": "7"
},
{
"label": "accessPointAutoApprovalSettings",
"type": "t_bool",
"offset": 3,
"slot": "7"
}
],
"numberOfBytes": "256"
},
"t_struct(Build)4727_storage": {
"label": "struct FleekERC721.Build",
"members": [
{
"label": "commitHash",
"type": "t_string_storage",
"offset": 0,
"slot": "0"
},
{
"label": "gitRepository",
"type": "t_string_storage",
"offset": 0,
"slot": "1"
}
],
"numberOfBytes": "64"
},
"t_struct(Counter)2774_storage": {
"label": "struct Counters.Counter",
"members": [
{
"label": "_value",
"type": "t_uint256",
"offset": 0,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_struct(Role)3943_storage": {
"label": "struct FleekAccessControl.Role",
"members": [
{
"label": "indexes",
"type": "t_mapping(t_address,t_uint256)",
"offset": 0,
"slot": "0"
},
{
"label": "members",
"type": "t_array(t_address)dyn_storage",
"offset": 0,
"slot": "1"
}
],
"numberOfBytes": "64"
},
"t_uint24": {
"label": "uint24",
"numberOfBytes": "3"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
},
"t_uint8": {
"label": "uint8",
"numberOfBytes": "1"
}
}
}
}
}
}

View File

@ -21,6 +21,21 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
using FleekStrings for string;
using FleekStrings for uint24;
event NewMint(
uint256 indexed tokenId,
string name,
string description,
string externalURL,
string ENS,
string commitHash,
string gitRepository,
string logo,
uint24 color,
bool accessPointAutoApprovalSettings,
address indexed minter,
address indexed owner
);
event MetadataUpdate(uint256 indexed _tokenId, string key, string value, address indexed triggeredBy);
event MetadataUpdate(uint256 indexed _tokenId, string key, uint24 value, address indexed triggeredBy);
event MetadataUpdate(uint256 indexed _tokenId, string key, string[2] value, address indexed triggeredBy);
@ -159,6 +174,20 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
app.currentBuild = 0;
app.builds[0] = Build(commitHash, gitRepository);
emit NewMint(
tokenId,
name,
description,
externalURL,
ENS,
commitHash,
gitRepository,
logo,
color,
accessPointAutoApproval,
msg.sender,
to
);
return tokenId;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,9 @@
{
"FleekERC721": [
{
"address": "0x11Cd77Eac1a0883DE9435B5586474903A2a084cD",
"timestamp": "2/15/2023, 12:43:39 PM"
},
{
"address": "0x8679f8A4Fb3AaA1E851100D2C0444a729a3D946C",
"timestamp": "1/19/2023, 8:33:42 PM"
@ -17,4 +21,4 @@
"timestamp": "1/16/2023, 8:49:22 AM"
}
]
}
}

File diff suppressed because one or more lines are too long

View File

@ -6,10 +6,7 @@ async function main() {
// Verify the contract after deploying
await hre.run('verify:verify', {
address: address,
constructorArguments: [
'FleekNFA', // Collection name
'FLKNFA', // Collection symbol
],
constructorArguments: [],
});
}
// Call the main function and catch if there is any error

View File

@ -93,7 +93,6 @@ contract Test_FleekERC721_Mint is Test_FleekERC721_Base {
color,
autoApprovalAp
);
assertEq(tokenId, 0);
assertEq(CuT.ownerOf(tokenId), to);
}

View File

@ -11,6 +11,12 @@ export const TestConstants = Object.freeze({
REJECTED: 2,
REMOVED: 3,
},
AccessPointStatus: {
DRAFT: 0,
APPROVED: 1,
REJECTED: 2,
REMOVED: 3,
},
MintParams: {
name: 'Fleek Test App',
description: 'Fleek Test App Description',

View File

@ -38,6 +38,25 @@ type CollectionRoleRevoked @entity(immutable: true) {
transactionHash: Bytes!
}
type NewMint @entity(immutable: true) {
id: Bytes!
tokenId: BigInt! # uint256
name: String!
description: String!
externalURL: String!
ENS: String!
commitHash: String! # string
gitRepository: String! # string
logo: String!
color: Int!
accessPointAutoApprovalSettings: Boolean!
triggeredBy: Bytes! # address
tokenOwner: Owner! # address
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type NewBuild @entity(immutable: true) {
id: Bytes!
token: BigInt! # uint256
@ -132,20 +151,29 @@ type Transfer @entity(immutable: true) {
type Token @entity {
id: Bytes! # Token ID
mint_transaction_hash: Bytes!
mintTransaction: NewMint!
tokenId: BigInt! # uint256
name: String!
description: String!
externalURL: String!
ENS: String!
logo: String!
color: Int!
accessPointAutoApprovalSettings: Boolean!
owner: Owner!
minted_by: Bytes!
mintedBy: Bytes!
controllers: [Controller!]
gitRepository: GitRepository!
commitHash: String!
}
type Owner @entity {
id: Bytes! #address
id: Bytes! # address
tokens: [Token!] @derivedFrom(field: "owner")
}
type Controller @entity {
id: Bytes! #address
id: Bytes! # address
tokens: [Token!] @derivedFrom(field: "controllers")
}
type Collection @entity {
@ -160,3 +188,8 @@ type CollectionOwner @entity {
accessGrantedBy: Bytes! #address
transactionHash: Bytes!
}
type GitRepository @entity {
id: String! # transaction hash of the first transaction this repository appeared in
tokens: [Token!] @derivedFrom(field: "gitRepository")
}

View File

@ -14,6 +14,7 @@ import {
TokenRoleGranted as TokenRoleGrantedEvent,
TokenRoleRevoked as TokenRoleRevokedEvent,
Transfer as TransferEvent,
NewMint as NewMintEvent,
} from '../generated/FleekNFA/FleekNFA';
import {
Approval,
@ -23,7 +24,9 @@ import {
CollectionRoleGranted,
CollectionRoleRevoked,
Controller,
GitRepository as GitRepositoryEntity,
NewBuild,
NewMint,
NewTokenDescription,
NewTokenENS,
NewTokenExternalURL,
@ -153,6 +156,89 @@ export function handleCollectionRoleRevoked(
}
}
export function handleNewMint(event: NewMintEvent): void {
let newMintEntity = new NewMint(
event.transaction.hash.concatI32(event.logIndex.toI32())
);
let name = event.params.name;
let description = event.params.description;
let externalURL = event.params.externalURL;
let ENS = event.params.ENS;
let gitRepository = event.params.gitRepository;
let commitHash = event.params.commitHash;
let logo = event.params.logo;
let color = event.params.color;
let accessPointAutoApprovalSettings =
event.params.accessPointAutoApprovalSettings;
let tokenId = event.params.tokenId;
let ownerAddress = event.params.owner;
newMintEntity.tokenId = tokenId;
newMintEntity.name = name;
newMintEntity.description = description;
newMintEntity.externalURL = externalURL;
newMintEntity.ENS = ENS;
newMintEntity.commitHash = commitHash;
newMintEntity.gitRepository = gitRepository;
newMintEntity.logo = logo;
newMintEntity.color = color;
newMintEntity.accessPointAutoApprovalSettings =
accessPointAutoApprovalSettings;
newMintEntity.triggeredBy = event.params.minter;
newMintEntity.tokenOwner = ownerAddress;
newMintEntity.blockNumber = event.block.number;
newMintEntity.blockTimestamp = event.block.timestamp;
newMintEntity.transactionHash = event.transaction.hash;
newMintEntity.save();
// Create Token, Owner, and Controller entities
let owner = Owner.load(ownerAddress);
let controller = Controller.load(ownerAddress);
let gitRepositoryEntity = GitRepositoryEntity.load(gitRepository);
let token = new Token(Bytes.fromByteArray(Bytes.fromBigInt(tokenId)));
if (!owner) {
// Create a new owner entity
owner = new Owner(ownerAddress);
}
if (!controller) {
// Create a new controller entity
controller = new Controller(ownerAddress);
}
if (!gitRepositoryEntity) {
// Create a new gitRepository entity
gitRepositoryEntity = new GitRepositoryEntity(gitRepository);
}
// Populate Token with data from the event
token.tokenId = tokenId;
token.name = name;
token.description = description;
token.externalURL = externalURL;
token.ENS = ENS;
token.gitRepository = gitRepository;
token.commitHash = commitHash;
token.logo = logo;
token.color = color;
token.accessPointAutoApprovalSettings = accessPointAutoApprovalSettings;
token.owner = ownerAddress;
token.mintTransaction = event.transaction.hash.concatI32(
event.logIndex.toI32()
);
token.mintedBy = event.params.minter;
token.controllers = [ownerAddress];
// Save entities
owner.save();
controller.save();
gitRepositoryEntity.save();
token.save();
}
export function handleNewBuild(event: NewBuildEvent): void {
let entity = new NewBuild(
event.transaction.hash.concatI32(event.logIndex.toI32())
@ -274,7 +360,6 @@ export function handleTokenRoleGranted(event: TokenRoleGrantedEvent): void {
if (!controller) {
// Create a new controller entity
log.debug('CONTROLLER IS GOING TO BE CREATED HERE.', []);
controller = new Controller(event.params.toAddress);
}
@ -375,24 +460,7 @@ export function handleTransfer(event: TransferEvent): void {
owner = new Owner(owner_address);
}
if (parseInt(event.params.from.toHexString()) === 0) {
// MINT
// Create a new Token entity
token = new Token(
Bytes.fromByteArray(Bytes.fromBigInt(event.params.tokenId))
);
// Populate Token with data from the event
token.owner = owner_address;
token.mint_transaction_hash = event.transaction.hash;
token.minted_by = event.transaction.from;
token.tokenId = event.params.tokenId;
// Save both entities
owner.save();
token.save();
} else {
if (parseInt(event.params.from.toHexString()) !== 0) {
// Transfer
// Load the Token by using its TokenId

View File

@ -6,9 +6,9 @@ dataSources:
name: FleekNFA
network: mumbai
source:
address: "0x34F21E970A7cd383eE429aDB5ed57bbc40ea2B57"
address: "0x11cd77eac1a0883de9435b5586474903a2a084cd" # <- Proxy Contract | Current implementation contract: 0x113169680A417e4dB4AD11832486FF317fB4CB36
abi: FleekNFA
startBlock: 30825341
startBlock: 32071579
mapping:
kind: ethereum/events
apiVersion: 0.0.7
@ -31,6 +31,7 @@ dataSources:
- Owner
- Controller
- CollectionOwner
- GithubRepository
abis:
- name: FleekNFA
file: ../contracts/artifacts/contracts/FleekERC721.sol/FleekERC721.json
@ -43,6 +44,8 @@ dataSources:
handler: handleCollectionRoleGranted
- event: CollectionRoleRevoked(indexed uint8,indexed address,address)
handler: handleCollectionRoleRevoked
- event: NewMint(indexed uint256,string,string,string,string,string,string,string,uint24,bool,indexed address,indexed address)
handler: handleNewMint
- event: NewBuild(indexed uint256,string,indexed address)
handler: handleNewBuild
- event: NewTokenDescription(indexed uint256,string,indexed address)