feat: access point integration with the subgraph (#141)
* feat: define entities, add handlers for access points. * feat: change ChangeAccessPointAutoApproval event to metadataUpdate with boolean value (new event), and also add NewMint handler again. * test: rename ChangeAccessPointStatus to ChangeAccessPointCreationStatus in hardhat tests. * refactor: deploy the new version of the contract and update the proxy address and block number in the subgraph config file. * refactor: change name of status to creationStatus in schema. Co-authored-by: Janison Sivarajah <jsonsivar@gmail.com> * refactor: remove commented handlers for ACL. * feat: add the condition for deploying proxy again * refactor: remove newAccessPoint from subgraph.yaml --------- Co-authored-by: Janison Sivarajah <jsonsivar@gmail.com>
This commit is contained in:
parent
751983ff37
commit
a6123d4c22
|
|
@ -29,6 +29,11 @@
|
|||
"address": "0x11Cd77Eac1a0883DE9435B5586474903A2a084cD",
|
||||
"txHash": "0x5166318336c9e0bef146562d58e01ddbb937a61b721aca6b24d41b0a189fde39",
|
||||
"kind": "transparent"
|
||||
},
|
||||
{
|
||||
"address": "0x550Ee47Fa9E0B81c1b9C394FeE62Fe699a955519",
|
||||
"txHash": "0x7076aaf31e50c5f9ddc4aeb1025c8b41e753ee99cc0d15ac5ac26395f04326e3",
|
||||
"kind": "transparent"
|
||||
}
|
||||
],
|
||||
"impls": {
|
||||
|
|
@ -6559,6 +6564,430 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"185ebe4c7108bb878e61aa9ca7bf5e8738cb39efc72aa2191dafdd8a74421a34": {
|
||||
"address": "0x9e4A318C788e0097A24146Fe7041a0CD93939D56",
|
||||
"txHash": "0xa7c1909a3a0d5d46a1cdd9f75b16661d7278ee1b1a1734b5cb61a3be691f5788",
|
||||
"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": "_collectionRolesCounter",
|
||||
"offset": 0,
|
||||
"slot": "151",
|
||||
"type": "t_mapping(t_enum(CollectionRoles)3829,t_uint256)",
|
||||
"contract": "FleekAccessControl",
|
||||
"src": "contracts/FleekAccessControl.sol:58"
|
||||
},
|
||||
{
|
||||
"label": "_collectionRoles",
|
||||
"offset": 0,
|
||||
"slot": "152",
|
||||
"type": "t_mapping(t_enum(CollectionRoles)3829,t_mapping(t_address,t_bool))",
|
||||
"contract": "FleekAccessControl",
|
||||
"src": "contracts/FleekAccessControl.sol:63"
|
||||
},
|
||||
{
|
||||
"label": "_tokenRolesVersion",
|
||||
"offset": 0,
|
||||
"slot": "153",
|
||||
"type": "t_mapping(t_uint256,t_uint256)",
|
||||
"contract": "FleekAccessControl",
|
||||
"src": "contracts/FleekAccessControl.sol:70"
|
||||
},
|
||||
{
|
||||
"label": "_tokenRoles",
|
||||
"offset": 0,
|
||||
"slot": "154",
|
||||
"type": "t_mapping(t_uint256,t_mapping(t_uint256,t_mapping(t_enum(TokenRoles)3831,t_mapping(t_address,t_bool))))",
|
||||
"contract": "FleekAccessControl",
|
||||
"src": "contracts/FleekAccessControl.sol:75"
|
||||
},
|
||||
{
|
||||
"label": "__gap",
|
||||
"offset": 0,
|
||||
"slot": "155",
|
||||
"type": "t_array(t_uint256)49_storage",
|
||||
"contract": "FleekAccessControl",
|
||||
"src": "contracts/FleekAccessControl.sol:178"
|
||||
},
|
||||
{
|
||||
"label": "_paused",
|
||||
"offset": 0,
|
||||
"slot": "204",
|
||||
"type": "t_bool",
|
||||
"contract": "FleekPausable",
|
||||
"src": "contracts/FleekPausable.sol:23"
|
||||
},
|
||||
{
|
||||
"label": "_canPause",
|
||||
"offset": 1,
|
||||
"slot": "204",
|
||||
"type": "t_bool",
|
||||
"contract": "FleekPausable",
|
||||
"src": "contracts/FleekPausable.sol:24"
|
||||
},
|
||||
{
|
||||
"label": "__gap",
|
||||
"offset": 0,
|
||||
"slot": "205",
|
||||
"type": "t_array(t_uint256)49_storage",
|
||||
"contract": "FleekPausable",
|
||||
"src": "contracts/FleekPausable.sol:133"
|
||||
},
|
||||
{
|
||||
"label": "_appIds",
|
||||
"offset": 0,
|
||||
"slot": "254",
|
||||
"type": "t_uint256",
|
||||
"contract": "FleekERC721",
|
||||
"src": "contracts/FleekERC721.sol:113"
|
||||
},
|
||||
{
|
||||
"label": "_apps",
|
||||
"offset": 0,
|
||||
"slot": "255",
|
||||
"type": "t_mapping(t_uint256,t_struct(App)4408_storage)",
|
||||
"contract": "FleekERC721",
|
||||
"src": "contracts/FleekERC721.sol:114"
|
||||
},
|
||||
{
|
||||
"label": "_accessPoints",
|
||||
"offset": 0,
|
||||
"slot": "256",
|
||||
"type": "t_mapping(t_string_memory_ptr,t_struct(AccessPoint)4432_storage)",
|
||||
"contract": "FleekERC721",
|
||||
"src": "contracts/FleekERC721.sol:115"
|
||||
}
|
||||
],
|
||||
"types": {
|
||||
"t_address": {
|
||||
"label": "address",
|
||||
"numberOfBytes": "20"
|
||||
},
|
||||
"t_array(t_uint256)44_storage": {
|
||||
"label": "uint256[44]",
|
||||
"numberOfBytes": "1408"
|
||||
},
|
||||
"t_array(t_uint256)49_storage": {
|
||||
"label": "uint256[49]",
|
||||
"numberOfBytes": "1568"
|
||||
},
|
||||
"t_array(t_uint256)50_storage": {
|
||||
"label": "uint256[50]",
|
||||
"numberOfBytes": "1600"
|
||||
},
|
||||
"t_bool": {
|
||||
"label": "bool",
|
||||
"numberOfBytes": "1"
|
||||
},
|
||||
"t_enum(AccessPointCreationStatus)4418": {
|
||||
"label": "enum FleekERC721.AccessPointCreationStatus",
|
||||
"members": [
|
||||
"DRAFT",
|
||||
"APPROVED",
|
||||
"REJECTED",
|
||||
"REMOVED"
|
||||
],
|
||||
"numberOfBytes": "1"
|
||||
},
|
||||
"t_enum(CollectionRoles)3829": {
|
||||
"label": "enum FleekAccessControl.CollectionRoles",
|
||||
"members": [
|
||||
"Owner"
|
||||
],
|
||||
"numberOfBytes": "1"
|
||||
},
|
||||
"t_enum(TokenRoles)3831": {
|
||||
"label": "enum FleekAccessControl.TokenRoles",
|
||||
"members": [
|
||||
"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(CollectionRoles)3829,t_mapping(t_address,t_bool))": {
|
||||
"label": "mapping(enum FleekAccessControl.CollectionRoles => mapping(address => bool))",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_enum(CollectionRoles)3829,t_uint256)": {
|
||||
"label": "mapping(enum FleekAccessControl.CollectionRoles => uint256)",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_enum(TokenRoles)3831,t_mapping(t_address,t_bool))": {
|
||||
"label": "mapping(enum FleekAccessControl.TokenRoles => mapping(address => bool))",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_string_memory_ptr,t_struct(AccessPoint)4432_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(TokenRoles)3831,t_mapping(t_address,t_bool)))": {
|
||||
"label": "mapping(uint256 => mapping(enum FleekAccessControl.TokenRoles => mapping(address => bool)))",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_uint256,t_mapping(t_uint256,t_mapping(t_enum(TokenRoles)3831,t_mapping(t_address,t_bool))))": {
|
||||
"label": "mapping(uint256 => mapping(uint256 => mapping(enum FleekAccessControl.TokenRoles => mapping(address => bool))))",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_uint256,t_struct(App)4408_storage)": {
|
||||
"label": "mapping(uint256 => struct FleekERC721.App)",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_uint256,t_struct(Build)4413_storage)": {
|
||||
"label": "mapping(uint256 => struct FleekERC721.Build)",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_uint256,t_uint256)": {
|
||||
"label": "mapping(uint256 => uint256)",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_string_memory_ptr": {
|
||||
"label": "string",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_string_storage": {
|
||||
"label": "string",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_struct(AccessPoint)4432_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_enum(AccessPointCreationStatus)4418",
|
||||
"offset": 22,
|
||||
"slot": "2"
|
||||
}
|
||||
],
|
||||
"numberOfBytes": "96"
|
||||
},
|
||||
"t_struct(App)4408_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)4413_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": "accessPointAutoApproval",
|
||||
"type": "t_bool",
|
||||
"offset": 3,
|
||||
"slot": "7"
|
||||
}
|
||||
],
|
||||
"numberOfBytes": "256"
|
||||
},
|
||||
"t_struct(Build)4413_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_uint24": {
|
||||
"label": "uint24",
|
||||
"numberOfBytes": "3"
|
||||
},
|
||||
"t_uint256": {
|
||||
"label": "uint256",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_uint8": {
|
||||
"label": "uint8",
|
||||
"numberOfBytes": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
|
|||
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);
|
||||
event MetadataUpdate(uint256 indexed _tokenId, string key, bool value, address indexed triggeredBy);
|
||||
|
||||
|
||||
event NewAccessPoint(string apName, uint256 indexed tokenId, address indexed owner);
|
||||
event RemoveAccessPoint(string apName, uint256 indexed tokenId, address indexed owner);
|
||||
|
||||
event ChangeAccessPointAutoApproval(uint256 indexed token, bool indexed settings, address indexed triggeredBy);
|
||||
|
||||
event ChangeAccessPointScore(string apName, uint256 indexed tokenId, uint256 score, address indexed triggeredBy);
|
||||
|
||||
event ChangeAccessPointNameVerify(
|
||||
|
|
@ -63,7 +63,7 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
|
|||
bool indexed verified,
|
||||
address indexed triggeredBy
|
||||
);
|
||||
event ChangeAccessPointStatus(
|
||||
event ChangeAccessPointCreationStatus(
|
||||
string apName,
|
||||
uint256 tokenId,
|
||||
AccessPointCreationStatus status,
|
||||
|
|
@ -291,7 +291,7 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
|
|||
/**
|
||||
* @dev Updates the `accessPointAutoApproval` settings on minted `tokenId`.
|
||||
*
|
||||
* May emit a {ChangeAccessPointAutoApproval} event.
|
||||
* May emit a {MetadataUpdate} event.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
|
|
@ -305,7 +305,7 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
|
|||
) public virtual requireTokenOwner(tokenId) {
|
||||
_requireMinted(tokenId);
|
||||
_apps[tokenId].accessPointAutoApproval = _apAutoApproval;
|
||||
emit ChangeAccessPointAutoApproval(tokenId, _apAutoApproval, msg.sender);
|
||||
emit MetadataUpdate(tokenId, 'accessPointAutoApproval', _apAutoApproval, msg.sender);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -479,11 +479,11 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
|
|||
AccessPointCreationStatus.APPROVED
|
||||
);
|
||||
|
||||
emit ChangeAccessPointStatus(apName, tokenId, AccessPointCreationStatus.APPROVED, msg.sender);
|
||||
emit ChangeAccessPointCreationStatus(apName, tokenId, AccessPointCreationStatus.APPROVED, msg.sender);
|
||||
} else {
|
||||
// Auto Approval is off. Should wait for approval.
|
||||
_accessPoints[apName] = AccessPoint(tokenId, 0, false, false, msg.sender, AccessPointCreationStatus.DRAFT);
|
||||
emit ChangeAccessPointStatus(apName, tokenId, AccessPointCreationStatus.DRAFT, msg.sender);
|
||||
emit ChangeAccessPointCreationStatus(apName, tokenId, AccessPointCreationStatus.DRAFT, msg.sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -511,11 +511,11 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
|
|||
if (approved) {
|
||||
// Approval
|
||||
accessPoint.status = AccessPointCreationStatus.APPROVED;
|
||||
emit ChangeAccessPointStatus(apName, tokenId, AccessPointCreationStatus.APPROVED, msg.sender);
|
||||
emit ChangeAccessPointCreationStatus(apName, tokenId, AccessPointCreationStatus.APPROVED, msg.sender);
|
||||
} else {
|
||||
// Not Approved
|
||||
accessPoint.status = AccessPointCreationStatus.REJECTED;
|
||||
emit ChangeAccessPointStatus(apName, tokenId, AccessPointCreationStatus.REJECTED, msg.sender);
|
||||
emit ChangeAccessPointCreationStatus(apName, tokenId, AccessPointCreationStatus.REJECTED, msg.sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -536,7 +536,7 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
|
|||
if (msg.sender != _accessPoints[apName].owner) revert MustBeAccessPointOwner();
|
||||
_accessPoints[apName].status = AccessPointCreationStatus.REMOVED;
|
||||
uint256 tokenId = _accessPoints[apName].tokenId;
|
||||
emit ChangeAccessPointStatus(apName, tokenId, AccessPointCreationStatus.REMOVED, msg.sender);
|
||||
emit ChangeAccessPointCreationStatus(apName, tokenId, AccessPointCreationStatus.REMOVED, msg.sender);
|
||||
emit RemoveAccessPoint(apName, tokenId, msg.sender);
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,9 @@
|
|||
{
|
||||
"FleekERC721": [
|
||||
{
|
||||
"address": "0x550Ee47Fa9E0B81c1b9C394FeE62Fe699a955519",
|
||||
"timestamp": "2/24/2023, 5:28:44 PM"
|
||||
},
|
||||
{
|
||||
"address": "0x11Cd77Eac1a0883DE9435B5586474903A2a084cD",
|
||||
"timestamp": "2/15/2023, 12:43:39 PM"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -17,7 +17,7 @@ describe('FleekERC721.AccessPoints.AutoApprovalOn', () => {
|
|||
const { contract, owner, tokenId } = fixture;
|
||||
|
||||
await expect(contract.addAccessPoint(tokenId, 'random.com'))
|
||||
.to.emit(contract, 'ChangeAccessPointStatus')
|
||||
.to.emit(contract, 'ChangeAccessPointCreationStatus')
|
||||
.withArgs(
|
||||
'random.com',
|
||||
tokenId,
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ type MetadataUpdate @entity(immutable: true) {
|
|||
stringValue: String
|
||||
uint24Value: Int
|
||||
doubleStringValue: [String!]!
|
||||
booleanValue: Boolean
|
||||
byAddress: Bytes!
|
||||
blockNumber: BigInt!
|
||||
blockTimestamp: BigInt!
|
||||
|
|
@ -76,11 +77,13 @@ type Token @entity {
|
|||
controllers: [Controller!]
|
||||
gitRepository: GitRepository!
|
||||
commitHash: String!
|
||||
accessPoints: [AccessPoint!] @derivedFrom(field: "token")
|
||||
}
|
||||
|
||||
type Owner @entity {
|
||||
id: Bytes! # address
|
||||
tokens: [Token!] @derivedFrom(field: "owner")
|
||||
accessPoints: [AccessPoint!] @derivedFrom(field: "owner")
|
||||
}
|
||||
|
||||
type Controller @entity {
|
||||
|
|
@ -104,3 +107,13 @@ type GitRepository @entity {
|
|||
id: String! # transaction hash of the first transaction this repository appeared in
|
||||
tokens: [Token!] @derivedFrom(field: "gitRepository")
|
||||
}
|
||||
|
||||
type AccessPoint @entity {
|
||||
id: String! # AP Name
|
||||
token: Token!
|
||||
score: BigInt!
|
||||
contentVerified: Boolean!
|
||||
nameVerified: Boolean!
|
||||
owner: Owner!
|
||||
creationStatus: String!
|
||||
}
|
||||
|
|
@ -1,14 +1,21 @@
|
|||
import { Address, Bytes, log, store, ethereum } from '@graphprotocol/graph-ts';
|
||||
import { Address, Bytes, log, store, ethereum, BigInt } from '@graphprotocol/graph-ts';
|
||||
import {
|
||||
Approval as ApprovalEvent,
|
||||
ApprovalForAll as ApprovalForAllEvent,
|
||||
MetadataUpdate as MetadataUpdateEvent,
|
||||
MetadataUpdate1 as MetadataUpdateEvent1,
|
||||
MetadataUpdate2 as MetadataUpdateEvent2,
|
||||
MetadataUpdate3 as MetadataUpdateEvent3,
|
||||
Transfer as TransferEvent,
|
||||
NewMint as NewMintEvent,
|
||||
ChangeAccessPointCreationStatus as ChangeAccessPointCreationStatusEvent,
|
||||
ChangeAccessPointScore as ChangeAccessPointCreationScoreEvent,
|
||||
NewAccessPoint as NewAccessPointEvent,
|
||||
ChangeAccessPointNameVerify as ChangeAccessPointNameVerifyEvent,
|
||||
ChangeAccessPointContentVerify as ChangeAccessPointContentVerifyEvent,
|
||||
} from '../generated/FleekNFA/FleekNFA';
|
||||
import {
|
||||
AccessPoint,
|
||||
Approval,
|
||||
ApprovalForAll,
|
||||
Collection,
|
||||
|
|
@ -250,6 +257,33 @@ export function handleMetadataUpdateWithIntValue(
|
|||
}
|
||||
}
|
||||
|
||||
export function handleMetadataUpdateWithBooleanValue(event: MetadataUpdateEvent3): void {
|
||||
/**
|
||||
* accessPointAutoApproval
|
||||
*/
|
||||
let entity = new MetadataUpdate(
|
||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||
);
|
||||
|
||||
entity.key = event.params.key;
|
||||
entity.tokenId = event.params._tokenId;
|
||||
entity.booleanValue = event.params.value;
|
||||
entity.blockNumber = event.block.number;
|
||||
entity.blockTimestamp = event.block.timestamp;
|
||||
entity.transactionHash = event.transaction.hash;
|
||||
|
||||
entity.save();
|
||||
|
||||
let token = Token.load(Bytes.fromByteArray(Bytes.fromBigInt(event.params._tokenId)));
|
||||
|
||||
if (token) {
|
||||
if (event.params.key == 'accessPointAutoApproval') {
|
||||
token.accessPointAutoApproval = event.params.value;
|
||||
}
|
||||
token.save();
|
||||
}
|
||||
}
|
||||
|
||||
export function handleTransfer(event: TransferEvent): void {
|
||||
let entity = new Transfer(
|
||||
event.transaction.hash.concatI32(event.logIndex.toI32())
|
||||
|
|
@ -295,3 +329,109 @@ export function handleTransfer(event: TransferEvent): void {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This handler will create and load entities in the following order:
|
||||
* - AccessPoint [create]
|
||||
* - Owner [load / create]
|
||||
* Note to discuss later: Should a `NewAccessPoint` entity be also created and defined?
|
||||
*/
|
||||
export function handleNewAccessPoint(event: NewAccessPointEvent): void {
|
||||
// Create an AccessPoint entity
|
||||
let accessPointEntity = new AccessPoint(event.params.apName);
|
||||
accessPointEntity.score = BigInt.fromU32(0);
|
||||
accessPointEntity.contentVerified = false;
|
||||
accessPointEntity.nameVerified = false;
|
||||
accessPointEntity.status = 'DRAFT'; // Since a `ChangeAccessPointCreationStatus` event is emitted instantly after `NewAccessPoint`, the status will be updated in that handler.
|
||||
accessPointEntity.owner = event.params.owner;
|
||||
accessPointEntity.token = Bytes.fromByteArray(Bytes.fromBigInt(event.params.tokenId));
|
||||
|
||||
// Load / Create an Owner entity
|
||||
let ownerEntity = Owner.load(event.params.owner);
|
||||
|
||||
if (!ownerEntity) {
|
||||
// Create a new owner entity
|
||||
ownerEntity = new Owner(event.params.owner);
|
||||
}
|
||||
|
||||
// Save entities.
|
||||
accessPointEntity.save();
|
||||
ownerEntity.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* This handler will update the status of an access point entity.
|
||||
*/
|
||||
export function handleChangeAccessPointCreationStatus(event: ChangeAccessPointCreationStatusEvent): void {
|
||||
// Load the AccessPoint entity
|
||||
let accessPointEntity = AccessPoint.load(event.params.apName);
|
||||
let status = event.params.status;
|
||||
|
||||
if (accessPointEntity) {
|
||||
if (status == 0) {
|
||||
accessPointEntity.status = 'DRAFT';
|
||||
} else if (status == 1) {
|
||||
accessPointEntity.status = 'APPROVED';
|
||||
} else if (status == 2) {
|
||||
accessPointEntity.status = 'REJECTED';
|
||||
} else if (status == 3) {
|
||||
accessPointEntity.status = 'REMOVED';
|
||||
} else {
|
||||
// Unknown status
|
||||
log.error('Unable to handle ChangeAccessPointCreationStatus. Unknown status. Status: {}, AccessPoint: {}', [status.toString(), event.params.apName]);
|
||||
}
|
||||
accessPointEntity.save();
|
||||
} else {
|
||||
// Unknown access point
|
||||
log.error('Unable to handle ChangeAccessPointCreationStatus. Unknown access point. Status: {}, AccessPoint: {}', [status.toString(), event.params.apName]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This handler will update the score of an access point entity.
|
||||
*/
|
||||
export function handleChangeAccessPointScore(event: ChangeAccessPointCreationScoreEvent): void {
|
||||
// Load the AccessPoint entity
|
||||
let accessPointEntity = AccessPoint.load(event.params.apName);
|
||||
|
||||
if (accessPointEntity) {
|
||||
accessPointEntity.score = event.params.score;
|
||||
accessPointEntity.save();
|
||||
} else {
|
||||
// Unknown access point
|
||||
log.error('Unable to handle ChangeAccessPointScore. Unknown access point. Score: {}, AccessPoint: {}', [event.params.score.toString(), event.params.apName]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This handler will update the nameVerified field of an access point entity.
|
||||
*/
|
||||
export function handleChangeAccessPointNameVerify(event: ChangeAccessPointNameVerifyEvent): void {
|
||||
// Load the AccessPoint entity
|
||||
let accessPointEntity = AccessPoint.load(event.params.apName);
|
||||
|
||||
if (accessPointEntity) {
|
||||
accessPointEntity.nameVerified = event.params.verified;
|
||||
accessPointEntity.save();
|
||||
} else {
|
||||
// Unknown access point
|
||||
log.error('Unable to handle ChangeAccessPointNameVerify. Unknown access point. Verified: {}, AccessPoint: {}', [event.params.verified.toString(), event.params.apName]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This handler will update the contentVerified field of an access point entity.
|
||||
*/
|
||||
export function handleChangeAccessPointContentVerify(event: ChangeAccessPointContentVerifyEvent): void {
|
||||
// Load the AccessPoint entity
|
||||
let accessPointEntity = AccessPoint.load(event.params.apName);
|
||||
|
||||
if (accessPointEntity) {
|
||||
accessPointEntity.contentVerified = event.params.verified;
|
||||
accessPointEntity.save();
|
||||
} else {
|
||||
// Unknown access point
|
||||
log.error('Unable to handle ChangeAccessPointContentVerify. Unknown access point. Verified: {}, AccessPoint: {}', [event.params.verified.toString(), event.params.apName]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
specVersion: 0.0.5
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
|
|
@ -6,9 +5,9 @@ dataSources:
|
|||
name: FleekNFA
|
||||
network: mumbai
|
||||
source:
|
||||
address: "0x11cd77eac1a0883de9435b5586474903a2a084cd" # <- Proxy Contract | Current implementation contract: 0x113169680A417e4dB4AD11832486FF317fB4CB36
|
||||
address: "0x550Ee47Fa9E0B81c1b9C394FeE62Fe699a955519" # <- Proxy Contract | Current implementation contract: 0x9e4a318c788e0097a24146fe7041a0cd93939d56
|
||||
abi: FleekNFA
|
||||
startBlock: 32071579
|
||||
startBlock: 32373064
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
|
|
@ -16,18 +15,20 @@ dataSources:
|
|||
entities:
|
||||
- Approval
|
||||
- ApprovalForAll
|
||||
- CollectionRoleGranted
|
||||
- CollectionRoleRevoked
|
||||
- MetadataUpdate
|
||||
- NewMint
|
||||
- TokenRoleGranted
|
||||
- TokenRoleRevoked
|
||||
- Transfer
|
||||
- Token
|
||||
- Owner
|
||||
- Controller
|
||||
- CollectionOwner
|
||||
- GithubRepository
|
||||
- AccessPoint
|
||||
- ChangeAccessPointCreationStatus
|
||||
- ChangeAccessPointScore
|
||||
- ChangeAccessPointNameVerify
|
||||
- ChangeAccessPointContentVerify
|
||||
- ChangeAccessPointAutoApproval
|
||||
abis:
|
||||
- name: FleekNFA
|
||||
file: ../contracts/artifacts/contracts/FleekERC721.sol/FleekERC721.json
|
||||
|
|
@ -42,8 +43,21 @@ dataSources:
|
|||
handler: handleMetadataUpdateWithDoubleStringValue
|
||||
- event: MetadataUpdate(indexed uint256,string,uint24,indexed address)
|
||||
handler: handleMetadataUpdateWithIntValue
|
||||
- event: MetadataUpdate(indexed uint256,string,bool,indexed address)
|
||||
handler: handleMetadataUpdateWithBooleanValue
|
||||
- event: NewMint(indexed uint256,string,string,string,string,string,string,string,uint24,bool,indexed address,indexed address)
|
||||
handler: handleNewMint
|
||||
- event: Transfer(indexed address,indexed address,indexed uint256)
|
||||
handler: handleTransfer
|
||||
- event: ChangeAccessPointContentVerify(string,uint256,indexed bool,indexed address)
|
||||
handler: handleChangeAccessPointContentVerify
|
||||
- event: ChangeAccessPointNameVerify(string,uint256,indexed bool,indexed address)
|
||||
handler: handleChangeAccessPointNameVerify
|
||||
- event: ChangeAccessPointScore(string,indexed uint256,uint256,indexed address)
|
||||
handler: handleChangeAccessPointScore
|
||||
- event: ChangeAccessPointCreationStatus(string,uint256,uint8,indexed address)
|
||||
handler: handleChangeAccessPointCreationStatus
|
||||
- event: NewAccessPoint(string,indexed uint256,indexed address)
|
||||
handler: handleNewAccessPoint
|
||||
file: ./src/fleek-nfa.ts
|
||||
specVersion: 0.0.5
|
||||
|
|
|
|||
Loading…
Reference in New Issue