From 5b933e57a8f63f2bd870d3b1d026ef84f4907cca Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 10:25:48 -0400 Subject: [PATCH 01/17] feat: ABIs --- abis/v5/DataPermissionImplementation.json | 1159 ++++++++++++++++++++ abis/v5/DataRegistryImplementation.json | 1188 +++++++++++++++++++++ 2 files changed, 2347 insertions(+) create mode 100644 abis/v5/DataPermissionImplementation.json create mode 100644 abis/v5/DataRegistryImplementation.json diff --git a/abis/v5/DataPermissionImplementation.json b/abis/v5/DataPermissionImplementation.json new file mode 100644 index 0000000..03bd73a --- /dev/null +++ b/abis/v5/DataPermissionImplementation.json @@ -0,0 +1,1159 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AccessControlBadConfirmation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "neededRole", + "type": "bytes32" + } + ], + "name": "AccessControlUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [], + "name": "ECDSAInvalidSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "ECDSAInvalidSignatureLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "ECDSAInvalidSignatureS", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ERC1967InvalidImplementation", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1967NonPayable", + "type": "error" + }, + { + "inputs": [], + "name": "EmptyGrant", + "type": "error" + }, + { + "inputs": [], + "name": "EmptyUrl", + "type": "error" + }, + { + "inputs": [], + "name": "EnforcedPause", + "type": "error" + }, + { + "inputs": [], + "name": "ExpectedPause", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "GrantAlreadyUsed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "expectedNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "providedNonce", + "type": "uint256" + } + ], + "name": "InvalidNonce", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidSignature", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [], + "name": "ServerAlreadyRegistered", + "type": "error" + }, + { + "inputs": [], + "name": "ServerNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "ServerNotTrusted", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "existingUrl", + "type": "string" + }, + { + "internalType": "string", + "name": "providedUrl", + "type": "string" + } + ], + "name": "ServerUrlMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "UUPSUnauthorizedCallContext", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "slot", + "type": "bytes32" + } + ], + "name": "UUPSUnsupportedProxiableUUID", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [], + "name": "EIP712DomainChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "grant", + "type": "string" + } + ], + "name": "PermissionAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serverId", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "ServerAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "serverId", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "serverUrl", + "type": "string" + } + ], + "name": "ServerTrusted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "serverId", + "type": "address" + } + ], + "name": "ServerUntrusted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAINTAINER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UPGRADE_INTERFACE_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "string", + "name": "grant", + "type": "string" + } + ], + "internalType": "struct IDataPermission.PermissionInput", + "name": "permission", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "addPermission", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "eip712Domain", + "outputs": [ + { + "internalType": "bytes1", + "name": "fields", + "type": "bytes1" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "version", + "type": "string" + }, + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifyingContract", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "extensions", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "trustedForwarderAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "ownerAddress", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "forwarder", + "type": "address" + } + ], + "name": "isTrustedForwarder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "grant", + "type": "string" + } + ], + "name": "permissionIdByGrant", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + } + ], + "name": "permissions", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "string", + "name": "grant", + "type": "string" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct IDataPermission.Permission", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "permissionsCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "callerConfirmation", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serverId", + "type": "address" + } + ], + "name": "servers", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "internalType": "struct IDataPermission.Server", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "adminRole", + "type": "bytes32" + } + ], + "name": "setRoleAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serverId", + "type": "address" + }, + { + "internalType": "string", + "name": "serverUrl", + "type": "string" + } + ], + "name": "trustServer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "address", + "name": "serverId", + "type": "address" + }, + { + "internalType": "string", + "name": "serverUrl", + "type": "string" + } + ], + "internalType": "struct IDataPermission.TrustServerInput", + "name": "trustServerInput", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "trustServerWithSignature", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "trustedForwarder", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serverId", + "type": "address" + } + ], + "name": "untrustServer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "address", + "name": "serverId", + "type": "address" + } + ], + "internalType": "struct IDataPermission.UntrustServerInput", + "name": "untrustServerInput", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "untrustServerWithSignature", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "trustedForwarderAddress", + "type": "address" + } + ], + "name": "updateTrustedForwarder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "permissionIndex", + "type": "uint256" + } + ], + "name": "userPermissionIdsAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userPermissionIdsLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userPermissionIdsValues", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "serverIndex", + "type": "uint256" + } + ], + "name": "userServerIdsAt", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userServerIdsLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userServerIdsValues", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + } +] \ No newline at end of file diff --git a/abis/v5/DataRegistryImplementation.json b/abis/v5/DataRegistryImplementation.json new file mode 100644 index 0000000..b93e6d8 --- /dev/null +++ b/abis/v5/DataRegistryImplementation.json @@ -0,0 +1,1188 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AccessControlBadConfirmation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "neededRole", + "type": "bytes32" + } + ], + "name": "AccessControlUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ERC1967InvalidImplementation", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1967NonPayable", + "type": "error" + }, + { + "inputs": [], + "name": "EnforcedPause", + "type": "error" + }, + { + "inputs": [], + "name": "ExpectedPause", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "FileNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "FileUrlAlreadyUsed", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "schemaId", + "type": "uint256" + } + ], + "name": "InvalidSchemaId", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidUrl", + "type": "error" + }, + { + "inputs": [], + "name": "NoPermission", + "type": "error" + }, + { + "inputs": [], + "name": "NotFileOwner", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [], + "name": "UUPSUnauthorizedCallContext", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "slot", + "type": "bytes32" + } + ], + "name": "UUPSUnsupportedProxiableUUID", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "ownerAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "FileAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "PermissionGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "ownerAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "proofIndex", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "dlpId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "proofUrl", + "type": "string" + } + ], + "name": "ProofAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "refinerId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "RefinementAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "refinerId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "RefinementUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAINTAINER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "REFINEMENT_SERVICE_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UPGRADE_INTERFACE_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "addFile", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "string", + "name": "key", + "type": "string" + } + ], + "name": "addFilePermission", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "url", + "type": "string" + }, + { + "internalType": "address", + "name": "ownerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "string", + "name": "key", + "type": "string" + } + ], + "internalType": "struct IDataRegistry.Permission[]", + "name": "permissions", + "type": "tuple[]" + } + ], + "name": "addFileWithPermissions", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "url", + "type": "string" + }, + { + "internalType": "address", + "name": "ownerAddress", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "string", + "name": "key", + "type": "string" + } + ], + "internalType": "struct IDataRegistry.Permission[]", + "name": "permissions", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "schemaId", + "type": "uint256" + } + ], + "name": "addFileWithPermissionsAndSchema", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "url", + "type": "string" + }, + { + "internalType": "uint256", + "name": "schemaId", + "type": "uint256" + } + ], + "name": "addFileWithSchema", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dlpId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "metadata", + "type": "string" + }, + { + "internalType": "string", + "name": "proofUrl", + "type": "string" + }, + { + "internalType": "string", + "name": "instruction", + "type": "string" + } + ], + "internalType": "struct IDataRegistry.ProofData", + "name": "data", + "type": "tuple" + } + ], + "internalType": "struct IDataRegistry.Proof", + "name": "proof", + "type": "tuple" + } + ], + "name": "addProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "refinerId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "string", + "name": "key", + "type": "string" + } + ], + "name": "addRefinementWithPermission", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "dataRefinerRegistry", + "outputs": [ + { + "internalType": "contract IDataRefinerRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "fileIdByUrl", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "filePermissions", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "fileProofs", + "outputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "score", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dlpId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "metadata", + "type": "string" + }, + { + "internalType": "string", + "name": "proofUrl", + "type": "string" + }, + { + "internalType": "string", + "name": "instruction", + "type": "string" + } + ], + "internalType": "struct IDataRegistry.ProofData", + "name": "data", + "type": "tuple" + } + ], + "internalType": "struct IDataRegistry.Proof", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "refinerId", + "type": "uint256" + } + ], + "name": "fileRefinements", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + } + ], + "name": "files", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "address", + "name": "ownerAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + }, + { + "internalType": "uint256", + "name": "addedAtBlock", + "type": "uint256" + } + ], + "internalType": "struct IDataRegistry.FileResponse", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "filesCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "trustedForwarderAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "ownerAddress", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "forwarder", + "type": "address" + } + ], + "name": "isTrustedForwarder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "callerConfirmation", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "adminRole", + "type": "bytes32" + } + ], + "name": "setRoleAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "trustedForwarder", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IDataRefinerRegistry", + "name": "newDataRefinerRegistry", + "type": "address" + } + ], + "name": "updateDataRefinerRegistry", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "trustedForwarderAddress", + "type": "address" + } + ], + "name": "updateTrustedForwarder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + } +] \ No newline at end of file From 821be09849147b5c796ff47131a22357dbcd2a7d Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 10:30:22 -0400 Subject: [PATCH 02/17] feat: add File, Permission, and TrustedServer entities --- schema.graphql | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/schema.graphql b/schema.graphql index f44929d..013d2e9 100644 --- a/schema.graphql +++ b/schema.graphql @@ -1,6 +1,12 @@ type User @entity(immutable: false) { id: ID! fileContributions: [DataRegistryProof!] @derivedFrom(field: "user") + "All files owned by this user" + files: [File!]! @derivedFrom(field: "owner") + "All permissions granted by this user" + permissions: [Permission!]! @derivedFrom(field: "user") + "All servers trusted by this user" + trustedServers: [TrustedServer!]! @derivedFrom(field: "user") } type UserTotals @entity(immutable: false) { @@ -130,3 +136,52 @@ type DlpPerformance @entity(immutable: false) { createdTxHash: Bytes! createdAtBlock: BigInt! } + +type File @entity(immutable: false) { + "The unique ID of the file, equivalent to the on-chain fileId." + id: ID! + "The owner of the file." + owner: User! + "The URL where the file data is stored (e.g., IPFS)." + url: String! + "The schema ID associated with this file, if any." + schemaId: BigInt! + "The block number when the file was added." + addedAtBlock: BigInt! + "The timestamp when the file was added." + addedAtTimestamp: BigInt! + "The transaction hash of the file addition." + transactionHash: Bytes! +} + +type Permission @entity(immutable: false) { + "The unique ID of the permission, equivalent to the on-chain permissionId." + id: ID! + "The user who granted the permission." + user: User! + "The content identifier (e.g., IPFS URL) for the grant details." + grant: String! + "The nonce used for this permission grant." + nonce: BigInt! + "The signature provided by the user." + signature: Bytes! + "The block number when the permission was granted." + addedAtBlock: BigInt! + "The timestamp when the permission was granted." + addedAtTimestamp: BigInt! + "The transaction hash of the permission grant." + transactionHash: Bytes! +} + +type TrustedServer @entity(immutable: false) { + "Composite ID: userAddress-serverAddress" + id: ID! + "The user who trusts the server." + user: User! + "The server's address (ID)." + serverAddress: Bytes! + "The URL of the server." + serverUrl: String! + "Timestamp of when the trust was established." + trustedAt: BigInt! +} \ No newline at end of file From d0b110dfbb773d8c0a73b6f0dfead80c360d08e9 Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 10:31:44 -0400 Subject: [PATCH 03/17] feat: Enable dataPermission handlers in build --- config/moksha.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/moksha.json b/config/moksha.json index 15ecd20..0f2a423 100644 --- a/config/moksha.json +++ b/config/moksha.json @@ -19,7 +19,8 @@ "vanaEpoch": true, "dlpPerformance": true, "queryEngine": true, - "dataRefinerRegistry": true + "dataRefinerRegistry": true, + "dataPermission": true } }, "initParams": { From b7408a2dd82728bdd34dc9759b298e0846a9bb6b Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 10:40:44 -0400 Subject: [PATCH 04/17] feat: add DataPermission contract as data source --- subgraph.moksha.yaml | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/subgraph.moksha.yaml b/subgraph.moksha.yaml index 50d3975..5544a43 100644 --- a/subgraph.moksha.yaml +++ b/subgraph.moksha.yaml @@ -219,4 +219,58 @@ dataSources: eventHandlers: - event: EpochDlpPerformancesSaved(indexed uint256,indexed uint256,uint256,uint256,uint256,uint256) handler: handleEpochDlpPerformancesSavedV5 + file: ./src/mapping.ts + + - kind: ethereum/contract + name: DataPermissionImplementation + network: moksha + source: + address: "0x3acB2023DF2617EFb61422BA0c8C6E97916961e0" + abi: DataPermissionImplementation + startBlock: 3425120 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Permission + - User + - TrustedServer + abis: + - name: DataPermissionImplementation + file: ./abis/v5/DataPermissionImplementation.json + callHandlers: + - function: permissions(uint256) + handler: handleGetPermission + eventHandlers: + - event: PermissionAdded(indexed uint256,indexed address,string) + handler: handlePermissionAdded + - event: ServerTrusted(indexed address,indexed address,string) + handler: handleServerTrusted + - event: ServerUntrusted(indexed address,indexed address) + handler: handleServerUntrusted + file: ./src/mapping.ts + + - kind: ethereum/contract + name: DataRegistryImplementationV5 + network: mainnet + source: + address: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C" + abi: DataRegistryImplementationV5 + startBlock: 3425120 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - EpochReference + - DataRegistryProof + abis: + - name: DataRegistryImplementationV5 + file: ./abis/v5/DataRegistryImplementation.json + eventHandlers: + - event: FileAdded(indexed uint256,indexed address,string) + handler: handleFileAddedV3 + - event: ProofAdded(indexed uint256,indexed address,uint256,indexed uint256,uint256,string) + handler: handleDataRegistryProofAddedV3 file: ./src/mapping.ts \ No newline at end of file From a9870d1efafe06edab70cf34148502341df38b3d Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 10:45:45 -0400 Subject: [PATCH 05/17] feat: index file entity from V1-V3 FileAdded events --- src/lib/contract/v1/data-registry.ts | 24 ++++++++++++++++++++---- src/lib/contract/v2/data-registry.ts | 21 +++++++++++++++++++-- src/lib/contract/v3/data-registry.ts | 24 +++++++++++++++++++----- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/src/lib/contract/v1/data-registry.ts b/src/lib/contract/v1/data-registry.ts index 03530cc..ef524f7 100644 --- a/src/lib/contract/v1/data-registry.ts +++ b/src/lib/contract/v1/data-registry.ts @@ -2,7 +2,7 @@ import { BigInt as GraphBigInt, log } from "@graphprotocol/graph-ts"; import { DataRegistryProof, - EpochReference, + File, FileOwner, } from "../../../../generated/schema"; @@ -10,19 +10,35 @@ import { FileAdded as FileAddedEvent, ProofAdded as FileProofAdded, } from "../../../../generated/DataRegistryImplementationV1/DataRegistryImplementationV1"; -import { EPOCH_REFERENCE_ID_CURRENT } from "../../entity/epoch"; +import { getEpochForBlock } from "../../entity/epoch"; // FIX: Added getEpochForBlock and EPOCH_REFERENCE_ID_CURRENT here import { getOrCreateUserTotals, getUserTotalsId, } from "../../entity/usertotals"; import { getOrCreateTotals, TOTALS_ID_GLOBAL } from "../../entity/totals"; -import { getEpochForBlock } from "../../entity/epoch"; +import { getOrCreateUser } from "../shared"; export function handleFileAddedV1(event: FileAddedEvent): void { log.info("Handling DataRegistry FileAdded with transaction hash: {}", [ event.transaction.hash.toHex(), ]); + // Create user entity if it doesn't exist + const user = getOrCreateUser(event.params.ownerAddress.toHex()); + + // Create new File entity + const file = new File(event.params.fileId.toString()); + file.owner = user.id; + file.url = event.params.url; + file.addedAtBlock = event.block.number; + file.addedAtTimestamp = event.block.timestamp; + file.transactionHash = event.transaction.hash; + + // V1 of the contract does not support schemaId, so we set it to 0 + file.schemaId = GraphBigInt.fromI32(0); + + file.save(); + const ownership = new FileOwner(event.params.fileId.toString()); ownership.ownerAddress = event.params.ownerAddress; ownership.save(); @@ -90,4 +106,4 @@ export function handleDataRegistryProofAddedV1(event: FileProofAdded): void { ); } totals.save(); -} +} \ No newline at end of file diff --git a/src/lib/contract/v2/data-registry.ts b/src/lib/contract/v2/data-registry.ts index b45f75b..d86e59d 100644 --- a/src/lib/contract/v2/data-registry.ts +++ b/src/lib/contract/v2/data-registry.ts @@ -2,6 +2,7 @@ import { BigInt as GraphBigInt, log } from "@graphprotocol/graph-ts"; import { DataRegistryProof, + File, FileOwner, } from "../../../../generated/schema"; @@ -20,13 +21,29 @@ import { TOTALS_ID_GLOBAL, } from "../../entity/totals"; import { getEpochForBlock } from "../../entity/epoch"; -import {getOrCreateDlp} from "../shared"; +import {getOrCreateDlp, getOrCreateUser} from "../shared"; export function handleFileAddedV2(event: FileAddedEvent): void { log.info("Handling DataRegistry FileAdded with transaction hash: {}", [ event.transaction.hash.toHex(), ]); + // Create user entity if it doesn't exist + const user = getOrCreateUser(event.params.ownerAddress.toHex()); + + // Create new File entity + const file = new File(event.params.fileId.toString()); + file.owner = user.id; + file.url = event.params.url; + file.addedAtBlock = event.block.number; + file.addedAtTimestamp = event.block.timestamp; + file.transactionHash = event.transaction.hash; + + // V2 of the contract does not support schemaId, so we set it to 0 + file.schemaId = GraphBigInt.fromI32(0); + + file.save(); + const ownership = new FileOwner(event.params.fileId.toString()); ownership.ownerAddress = event.params.ownerAddress; ownership.save(); @@ -121,4 +138,4 @@ export function handleDataRegistryProofAddedV2(event: FileProofAdded): void { ); } dlpTotals.save(); -} +} \ No newline at end of file diff --git a/src/lib/contract/v3/data-registry.ts b/src/lib/contract/v3/data-registry.ts index 85fa1e8..67fe726 100644 --- a/src/lib/contract/v3/data-registry.ts +++ b/src/lib/contract/v3/data-registry.ts @@ -2,8 +2,7 @@ import { BigInt as GraphBigInt, log } from "@graphprotocol/graph-ts"; import { DataRegistryProof, - Dlp, - EpochReference, + File, FileOwner, } from "../../../../generated/schema"; @@ -11,7 +10,7 @@ import { FileAdded as FileAddedEvent, ProofAdded as FileProofAdded, } from "../../../../generated/DataRegistryImplementationV3/DataRegistryImplementationV3"; -import { EPOCH_REFERENCE_ID_CURRENT } from "../../entity/epoch"; +import { getEpochForBlock } from "../../entity/epoch"; import { getOrCreateUserTotals, getUserTotalsId, @@ -23,13 +22,28 @@ import { TOTALS_ID_GLOBAL, } from "../../entity/totals"; import {getOrCreateDlp, getOrCreateUser} from "../shared"; -import { getEpochForBlock } from "../../entity/epoch"; export function handleFileAddedV3(event: FileAddedEvent): void { log.info("Handling DataRegistry FileAdded with transaction hash: {}", [ event.transaction.hash.toHex(), ]); + // Create user entity if it doesn't exist + const user = getOrCreateUser(event.params.ownerAddress.toHex()); + + // Create new File entity + const file = new File(event.params.fileId.toString()); + file.owner = user.id; + file.url = event.params.url; + file.addedAtBlock = event.block.number; + file.addedAtTimestamp = event.block.timestamp; + file.transactionHash = event.transaction.hash; + + // V3 of the contract does not support schemaId, so we set it to 0 + file.schemaId = GraphBigInt.fromI32(0); + + file.save(); + const ownership = new FileOwner(event.params.fileId.toString()); ownership.ownerAddress = event.params.ownerAddress; ownership.save(); @@ -113,4 +127,4 @@ export function handleDataRegistryProofAddedV3(event: FileProofAdded): void { ); } dlpTotals.save(); -} +} \ No newline at end of file From cb2e36042b09f84d050bdb7a196969db462b01d1 Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 10:46:12 -0400 Subject: [PATCH 06/17] feat: add conditional export for permission handlers --- src/mapping.ts.template | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mapping.ts.template b/src/mapping.ts.template index 5d27411..ed2dfbc 100644 --- a/src/mapping.ts.template +++ b/src/mapping.ts.template @@ -63,3 +63,6 @@ export * from "./lib/contract/v5/vana-epoch"; {{#includes.v5.dlpPerformance}} export * from "./lib/contract/v5/dlp-performance"; {{/includes.v5.dlpPerformance}} +{{#includes.v5.dataPermission}} +export * from "./lib/contract/v5/data-permission"; +{{/includes.v5.dataPermission}} \ No newline at end of file From 1416bf02cc919745b20d0f80bac0f1a2b18d6475 Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 11:02:30 -0400 Subject: [PATCH 07/17] feat: add data permission handler to vcs --- src/lib/contract/v5/data-permission.ts | 82 ++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/lib/contract/v5/data-permission.ts diff --git a/src/lib/contract/v5/data-permission.ts b/src/lib/contract/v5/data-permission.ts new file mode 100644 index 0000000..f7aaddb --- /dev/null +++ b/src/lib/contract/v5/data-permission.ts @@ -0,0 +1,82 @@ +import { log, store, BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { + PermissionAdded, + ServerTrusted, + ServerUntrusted, + DataPermissionImplementation, +} from "../../../../generated/DataPermissionImplementation/DataPermissionImplementation"; +import { Permission, TrustedServer } from "../../../../generated/schema"; +import { getOrCreateUser } from "../shared"; + +export function handlePermissionAdded(event: PermissionAdded): void { + log.info("Handling PermissionAdded with transaction hash: {}", [ + event.transaction.hash.toHexString(), + ]); + + const user = getOrCreateUser(event.params.user.toHex()); + const permissionId = event.params.permissionId; + + const permission = new Permission(permissionId.toString()); + permission.user = user.id; + permission.grant = event.params.grant; + permission.addedAtBlock = event.block.number; + permission.addedAtTimestamp = event.block.timestamp; + permission.transactionHash = event.transaction.hash; + + // Since nonce and signature are not in the event, we must call the contract. + const contract = DataPermissionImplementation.bind(event.address); + const permissionData = contract.try_permissions(permissionId); + + if (!permissionData.reverted) { + // FIX: Access properties directly instead of using getters. + permission.nonce = permissionData.value.nonce; + permission.signature = permissionData.value.signature; + } else { + log.warning("Could not get permission data for id {}. Nonce and signature will be zero.", [permissionId.toString()]); + permission.nonce = BigInt.zero(); + // FIX: Use an empty Bytes array for an empty signature. + permission.signature = new Bytes(0); + } + + permission.save(); +} + +export function handleServerTrusted(event: ServerTrusted): void { + log.info("Handling ServerTrusted for user {} and server {}", [ + event.params.user.toHex(), + event.params.serverId.toHex(), + ]); + + const user = getOrCreateUser(event.params.user.toHex()); + const serverId = event.params.serverId; + const compositeId = user.id + "-" + serverId.toHex(); + + let trustedServer = TrustedServer.load(compositeId); + if (trustedServer == null) { + trustedServer = new TrustedServer(compositeId); + trustedServer.user = user.id; + trustedServer.serverAddress = serverId; + } + + trustedServer.serverUrl = event.params.serverUrl; + trustedServer.trustedAt = event.block.timestamp; + trustedServer.save(); +} + +export function handleServerUntrusted(event: ServerUntrusted): void { + log.info("Handling ServerUntrusted for user {} and server {}", [ + event.params.user.toHex(), + event.params.serverId.toHex(), + ]); + + const userId = event.params.user.toHex(); + const serverId = event.params.serverId.toHex(); + const compositeId = userId + "-" + serverId; + + const trustedServer = TrustedServer.load(compositeId); + if (trustedServer != null) { + store.remove("TrustedServer", compositeId); + } else { + log.warning("Attempted to untrust a server that was not found: {}", [compositeId]); + } +} \ No newline at end of file From c502ba5f90fff6c46089df7c6e1f0a2dff4d9722 Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 11:03:11 -0400 Subject: [PATCH 08/17] fix: remove redundant call handler for DataPermissionImplementation --- subgraph.moksha.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/subgraph.moksha.yaml b/subgraph.moksha.yaml index 5544a43..d0a9801 100644 --- a/subgraph.moksha.yaml +++ b/subgraph.moksha.yaml @@ -239,9 +239,6 @@ dataSources: abis: - name: DataPermissionImplementation file: ./abis/v5/DataPermissionImplementation.json - callHandlers: - - function: permissions(uint256) - handler: handleGetPermission eventHandlers: - event: PermissionAdded(indexed uint256,indexed address,string) handler: handlePermissionAdded From 248c686114def6e53eca40dfaf69145d919b9b7d Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 11:06:01 -0400 Subject: [PATCH 09/17] fix: typo --- subgraph.moksha.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subgraph.moksha.yaml b/subgraph.moksha.yaml index d0a9801..76a8581 100644 --- a/subgraph.moksha.yaml +++ b/subgraph.moksha.yaml @@ -250,7 +250,7 @@ dataSources: - kind: ethereum/contract name: DataRegistryImplementationV5 - network: mainnet + network: moksha source: address: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C" abi: DataRegistryImplementationV5 From c22f7efbac60a1c90edbaa4f7a6779531f06b2aa Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 11:25:57 -0400 Subject: [PATCH 10/17] fix: lint --- schema.graphql | 2 +- src/lib/contract/shared.ts | 4 ++-- src/lib/contract/v1/data-registry.ts | 2 +- src/lib/contract/v2/data-registry.ts | 4 ++-- src/lib/contract/v3/data-registry.ts | 4 ++-- src/lib/contract/v5/data-permission.ts | 11 ++++++++--- src/lib/contract/v5/dlp-registry.ts | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/schema.graphql b/schema.graphql index 013d2e9..3b12a31 100644 --- a/schema.graphql +++ b/schema.graphql @@ -184,4 +184,4 @@ type TrustedServer @entity(immutable: false) { serverUrl: String! "Timestamp of when the trust was established." trustedAt: BigInt! -} \ No newline at end of file +} diff --git a/src/lib/contract/shared.ts b/src/lib/contract/shared.ts index 71358f3..38883df 100644 --- a/src/lib/contract/shared.ts +++ b/src/lib/contract/shared.ts @@ -1,5 +1,5 @@ -import {Dlp, User} from "../../../generated/schema"; -import {getOrCreateTotals, getTotalsIdDlp} from "../entity/totals"; +import { Dlp, User } from "../../../generated/schema"; +import { getOrCreateTotals, getTotalsIdDlp } from "../entity/totals"; export function getOrCreateUser(userId: string): User { let user = User.load(userId); diff --git a/src/lib/contract/v1/data-registry.ts b/src/lib/contract/v1/data-registry.ts index ef524f7..79d814c 100644 --- a/src/lib/contract/v1/data-registry.ts +++ b/src/lib/contract/v1/data-registry.ts @@ -106,4 +106,4 @@ export function handleDataRegistryProofAddedV1(event: FileProofAdded): void { ); } totals.save(); -} \ No newline at end of file +} diff --git a/src/lib/contract/v2/data-registry.ts b/src/lib/contract/v2/data-registry.ts index d86e59d..245a5be 100644 --- a/src/lib/contract/v2/data-registry.ts +++ b/src/lib/contract/v2/data-registry.ts @@ -21,7 +21,7 @@ import { TOTALS_ID_GLOBAL, } from "../../entity/totals"; import { getEpochForBlock } from "../../entity/epoch"; -import {getOrCreateDlp, getOrCreateUser} from "../shared"; +import { getOrCreateDlp, getOrCreateUser } from "../shared"; export function handleFileAddedV2(event: FileAddedEvent): void { log.info("Handling DataRegistry FileAdded with transaction hash: {}", [ @@ -138,4 +138,4 @@ export function handleDataRegistryProofAddedV2(event: FileProofAdded): void { ); } dlpTotals.save(); -} \ No newline at end of file +} diff --git a/src/lib/contract/v3/data-registry.ts b/src/lib/contract/v3/data-registry.ts index 67fe726..a9df8d7 100644 --- a/src/lib/contract/v3/data-registry.ts +++ b/src/lib/contract/v3/data-registry.ts @@ -21,7 +21,7 @@ import { getTotalsIdDlp, TOTALS_ID_GLOBAL, } from "../../entity/totals"; -import {getOrCreateDlp, getOrCreateUser} from "../shared"; +import { getOrCreateDlp, getOrCreateUser } from "../shared"; export function handleFileAddedV3(event: FileAddedEvent): void { log.info("Handling DataRegistry FileAdded with transaction hash: {}", [ @@ -127,4 +127,4 @@ export function handleDataRegistryProofAddedV3(event: FileProofAdded): void { ); } dlpTotals.save(); -} \ No newline at end of file +} diff --git a/src/lib/contract/v5/data-permission.ts b/src/lib/contract/v5/data-permission.ts index f7aaddb..d069f44 100644 --- a/src/lib/contract/v5/data-permission.ts +++ b/src/lib/contract/v5/data-permission.ts @@ -32,7 +32,10 @@ export function handlePermissionAdded(event: PermissionAdded): void { permission.nonce = permissionData.value.nonce; permission.signature = permissionData.value.signature; } else { - log.warning("Could not get permission data for id {}. Nonce and signature will be zero.", [permissionId.toString()]); + log.warning( + "Could not get permission data for id {}. Nonce and signature will be zero.", + [permissionId.toString()], + ); permission.nonce = BigInt.zero(); // FIX: Use an empty Bytes array for an empty signature. permission.signature = new Bytes(0); @@ -77,6 +80,8 @@ export function handleServerUntrusted(event: ServerUntrusted): void { if (trustedServer != null) { store.remove("TrustedServer", compositeId); } else { - log.warning("Attempted to untrust a server that was not found: {}", [compositeId]); + log.warning("Attempted to untrust a server that was not found: {}", [ + compositeId, + ]); } -} \ No newline at end of file +} diff --git a/src/lib/contract/v5/dlp-registry.ts b/src/lib/contract/v5/dlp-registry.ts index 64a4f0c..875c8d8 100644 --- a/src/lib/contract/v5/dlp-registry.ts +++ b/src/lib/contract/v5/dlp-registry.ts @@ -12,7 +12,7 @@ import { Dlp } from "../../../../generated/schema"; import { getTotalsIdDlp } from "../../entity/totals/constants"; import { getOrCreateDlpList } from "../../../../src/lib/entity/dlp-list"; import { getOrCreateTotals } from "../../entity/totals"; -import {getOrCreateDlp, getOrCreateUser} from "../shared"; +import { getOrCreateDlp, getOrCreateUser } from "../shared"; // Mirrored from DLPRegistry.IDLPRegistry.DlpStatus enum dlpStatus { From b9ba605ad69adfd46ba691ca6f53e51c3b0e22d5 Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 11:33:44 -0400 Subject: [PATCH 11/17] fix: lint --- src/lib/contract/v5/data-permission.ts | 13 +++++++++---- src/lib/contract/v5/dlp-registry.ts | 19 ++++++++----------- src/lib/contract/v5/vana-epoch.ts | 9 +++------ src/lib/entity/epoch/epoch-reference.ts | 13 +++++++------ 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/lib/contract/v5/data-permission.ts b/src/lib/contract/v5/data-permission.ts index d069f44..440c429 100644 --- a/src/lib/contract/v5/data-permission.ts +++ b/src/lib/contract/v5/data-permission.ts @@ -1,4 +1,9 @@ -import { log, store, BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { + log, + store, + BigInt as GraphBigInt, + Bytes, +} from "@graphprotocol/graph-ts"; import { PermissionAdded, ServerTrusted, @@ -36,7 +41,7 @@ export function handlePermissionAdded(event: PermissionAdded): void { "Could not get permission data for id {}. Nonce and signature will be zero.", [permissionId.toString()], ); - permission.nonce = BigInt.zero(); + permission.nonce = GraphBigInt.zero(); // FIX: Use an empty Bytes array for an empty signature. permission.signature = new Bytes(0); } @@ -52,7 +57,7 @@ export function handleServerTrusted(event: ServerTrusted): void { const user = getOrCreateUser(event.params.user.toHex()); const serverId = event.params.serverId; - const compositeId = user.id + "-" + serverId.toHex(); + const compositeId = `${user.id}-${serverId.toHex()}`; let trustedServer = TrustedServer.load(compositeId); if (trustedServer == null) { @@ -74,7 +79,7 @@ export function handleServerUntrusted(event: ServerUntrusted): void { const userId = event.params.user.toHex(); const serverId = event.params.serverId.toHex(); - const compositeId = userId + "-" + serverId; + const compositeId = `${userId}-${serverId}`; const trustedServer = TrustedServer.load(compositeId); if (trustedServer != null) { diff --git a/src/lib/contract/v5/dlp-registry.ts b/src/lib/contract/v5/dlp-registry.ts index 875c8d8..91feef8 100644 --- a/src/lib/contract/v5/dlp-registry.ts +++ b/src/lib/contract/v5/dlp-registry.ts @@ -1,4 +1,4 @@ -import { BigInt, log } from "@graphprotocol/graph-ts"; +import { BigInt as GraphBigInt, log } from "@graphprotocol/graph-ts"; import { DlpRegistered, DlpUpdated, @@ -9,9 +9,7 @@ import { } from "../../../../generated/DLPRegistryImplementationV5/DLPRegistryImplementationV5"; import { Dlp } from "../../../../generated/schema"; -import { getTotalsIdDlp } from "../../entity/totals/constants"; import { getOrCreateDlpList } from "../../../../src/lib/entity/dlp-list"; -import { getOrCreateTotals } from "../../entity/totals"; import { getOrCreateDlp, getOrCreateUser } from "../shared"; // Mirrored from DLPRegistry.IDLPRegistry.DlpStatus @@ -46,13 +44,13 @@ export function handleDlpRegisteredV5(event: DlpRegistered): void { dlp.createdAt = event.block.timestamp; dlp.createdTxHash = event.transaction.hash; dlp.createdAtBlock = event.block.number; - dlp.status = BigInt.fromI32(dlpStatus.REGISTERED); + dlp.status = GraphBigInt.fromI32(dlpStatus.REGISTERED); // New field in v5 dlp.isVerified = false; // Keep staking fields for backward compatibility but set to zero - dlp.performanceRating = BigInt.zero(); + dlp.performanceRating = GraphBigInt.zero(); dlp.save(); @@ -102,7 +100,7 @@ export function handleDlpStatusUpdatedV5(event: DlpStatusUpdated): void { if (dlp != null) { const newStatus = event.params.newStatus; - dlp.status = BigInt.fromI32(newStatus); + dlp.status = GraphBigInt.fromI32(newStatus); // Track eligibility transitions if (newStatus === dlpStatus.ELIGIBLE) { @@ -142,9 +140,9 @@ export function handleDlpVerificationUpdatedV5( } if (isEligible) { - dlp.status = BigInt.fromI32(dlpStatus.ELIGIBLE); + dlp.status = GraphBigInt.fromI32(dlpStatus.ELIGIBLE); } else { - dlp.status = BigInt.fromI32(dlpStatus.REGISTERED); + dlp.status = GraphBigInt.fromI32(dlpStatus.REGISTERED); } dlp.save(); } else { @@ -172,9 +170,9 @@ export function handleDlpTokenUpdatedV5(event: DlpTokenUpdated): void { } if (isEligible) { - dlp.status = BigInt.fromI32(dlpStatus.ELIGIBLE); + dlp.status = GraphBigInt.fromI32(dlpStatus.ELIGIBLE); } else { - dlp.status = BigInt.fromI32(dlpStatus.REGISTERED); + dlp.status = GraphBigInt.fromI32(dlpStatus.REGISTERED); } dlp.save(); } @@ -185,5 +183,4 @@ export function handleDlpRegistrationDepositAmountUpdatedV5( log.info("handleDlpRegistrationDepositAmountUpdatedV5: {}", [ event.transaction.hash.toHexString(), ]); - // No state changes needed for deposit amount updates } diff --git a/src/lib/contract/v5/vana-epoch.ts b/src/lib/contract/v5/vana-epoch.ts index 9366a19..a1f98de 100644 --- a/src/lib/contract/v5/vana-epoch.ts +++ b/src/lib/contract/v5/vana-epoch.ts @@ -1,4 +1,4 @@ -import { BigInt, log } from "@graphprotocol/graph-ts"; +import { log } from "@graphprotocol/graph-ts"; import { EpochCreated, EpochDlpRewardAdded, @@ -6,12 +6,9 @@ import { EpochRewardAmountUpdated, EpochSizeUpdated, } from "../../../../generated/VanaEpochImplementationV5/VanaEpochImplementationV5"; -import { Epoch, EpochReference } from "../../../../generated/schema"; +import { Epoch } from "../../../../generated/schema"; import { getOrCreateCurrentParams } from "../../entity/params"; -import { - EPOCH_REFERENCE_ID_CURRENT, - saveCurrentEpochReference, -} from "../../entity/epoch"; +import { saveCurrentEpochReference } from "../../entity/epoch"; export function handleEpochCreatedV5(event: EpochCreated): void { log.info("handleEpochCreatedV5: {}", [event.transaction.hash.toHexString()]); diff --git a/src/lib/entity/epoch/epoch-reference.ts b/src/lib/entity/epoch/epoch-reference.ts index 6a2a4b0..bde29cf 100644 --- a/src/lib/entity/epoch/epoch-reference.ts +++ b/src/lib/entity/epoch/epoch-reference.ts @@ -1,4 +1,4 @@ -import { BigInt, log } from "@graphprotocol/graph-ts"; +import { BigInt as GraphBigInt, log } from "@graphprotocol/graph-ts"; import { Epoch, EpochReference } from "../../../../generated/schema"; import { EPOCH_REFERENCE_ID_CURRENT } from "./constants"; import { epochRanges } from "../../../mapping"; @@ -24,7 +24,7 @@ export function saveCurrentEpochReference(newEpochId: string): EpochReference { return currentEpoch; } -export function getEpochForBlock(blockNumber: BigInt): string { +export function getEpochForBlock(blockNumber: GraphBigInt): string { const currentEpochRef = getCurrentEpochReference(); if (!currentEpochRef || !currentEpochRef.epoch) { return getEpochFromRanges(blockNumber); @@ -35,15 +35,15 @@ export function getEpochForBlock(blockNumber: BigInt): string { return getEpochFromRanges(blockNumber); } - if (currentEpoch.endBlock.le(BigInt.zero())) { + if (currentEpoch.endBlock.le(GraphBigInt.zero())) { return currentEpoch.id; } // If the current epoch is in the past, we need to use the next epoch if (blockNumber.gt(currentEpoch.endBlock)) { // Get the next epoch by incrementing the current epoch ID - const nextEpochId = BigInt.fromString(currentEpoch.id) - .plus(BigInt.fromI32(1)) + const nextEpochId = GraphBigInt.fromString(currentEpoch.id) + .plus(GraphBigInt.fromI32(1)) .toString(); const nextEpoch = Epoch.load(nextEpochId); if (nextEpoch) { @@ -56,7 +56,8 @@ export function getEpochForBlock(blockNumber: BigInt): string { return currentEpoch.id; } -function getEpochFromRanges(blockNumber: BigInt): string { +function getEpochFromRanges(blockNumber: GraphBigInt): string { + // @ts-ignore const blockNumberInt = Number.parseInt(blockNumber.toString()); for (let i = 0; i < epochRanges.length; i++) { From 89fd1f7f8918cd4feb581ff070d57b5d829a6acd Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 11:39:40 -0400 Subject: [PATCH 12/17] feat: add the relevant changes for the other subgraph yaml files --- subgraph.vana-moksha.yaml | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/subgraph.vana-moksha.yaml b/subgraph.vana-moksha.yaml index a11787f..c9353dd 100644 --- a/subgraph.vana-moksha.yaml +++ b/subgraph.vana-moksha.yaml @@ -219,4 +219,55 @@ dataSources: eventHandlers: - event: EpochDlpPerformancesSaved(indexed uint256,indexed uint256,uint256,uint256,uint256,uint256) handler: handleEpochDlpPerformancesSavedV5 + file: ./src/mapping.ts + + - kind: ethereum/contract + name: DataPermissionImplementation + network: vana-moksha + source: + address: "0x3acB2023DF2617EFb61422BA0c8C6E97916961e0" + abi: DataPermissionImplementation + startBlock: 3425120 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Permission + - User + - TrustedServer + abis: + - name: DataPermissionImplementation + file: ./abis/v5/DataPermissionImplementation.json + eventHandlers: + - event: PermissionAdded(indexed uint256,indexed address,string) + handler: handlePermissionAdded + - event: ServerTrusted(indexed address,indexed address,string) + handler: handleServerTrusted + - event: ServerUntrusted(indexed address,indexed address) + handler: handleServerUntrusted + file: ./src/mapping.ts + + - kind: ethereum/contract + name: DataRegistryImplementationV5 + network: vana-moksha + source: + address: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C" + abi: DataRegistryImplementationV5 + startBlock: 3425120 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - EpochReference + - DataRegistryProof + abis: + - name: DataRegistryImplementationV5 + file: ./abis/v5/DataRegistryImplementation.json + eventHandlers: + - event: FileAdded(indexed uint256,indexed address,string) + handler: handleFileAddedV3 + - event: ProofAdded(indexed uint256,indexed address,uint256,indexed uint256,uint256,string) + handler: handleDataRegistryProofAddedV3 file: ./src/mapping.ts \ No newline at end of file From 67d3b26984a7a2982dbcd3a4a24d7b6a2ecf7d91 Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 12:53:50 -0400 Subject: [PATCH 13/17] feat: add tests --- tests/unit/contract/v1/data-registry.test.ts | 58 +++++++++++++++++++ .../contract/v1/utils/data-registry-events.ts | 28 +++++++++ 2 files changed, 86 insertions(+) create mode 100644 tests/unit/contract/v1/data-registry.test.ts create mode 100644 tests/unit/contract/v1/utils/data-registry-events.ts diff --git a/tests/unit/contract/v1/data-registry.test.ts b/tests/unit/contract/v1/data-registry.test.ts new file mode 100644 index 0000000..bfeb5af --- /dev/null +++ b/tests/unit/contract/v1/data-registry.test.ts @@ -0,0 +1,58 @@ +import { + assert, + beforeEach, + clearStore, + describe, + test, +} from "matchstick-as/assembly/index"; +import { BigInt as GraphBigInt } from "@graphprotocol/graph-ts"; +import { handleFileAddedV1 } from "../../../../src/lib/contract/v1/data-registry"; +import { createFileAddedEvent } from "./utils/data-registry-events"; + +// Hook to clear the store before each test, ensuring test isolation +beforeEach(() => { + clearStore(); +}); + +describe("handleFileAddedV1", () => { + test("creates both a File and a FileOwner entity", () => { + // 1. ARRANGE: Set up test data and create the mock event + const fileId = 1; + const ownerAddress = "0x1234567890123456789012345678901234567890"; + const url = "ipfs://Qm..."; + + const fileAddedEvent = createFileAddedEvent(fileId, ownerAddress, url); + + // 2. ACT: Call the handler function with the mock event + handleFileAddedV1(fileAddedEvent); + + // 3. ASSERT: Check that the store is in the correct state + + // --- Assert the NEW functionality --- + assert.entityCount("File", 1); + assert.fieldEquals("File", fileId.toString(), "id", fileId.toString()); + assert.fieldEquals("File", fileId.toString(), "owner", ownerAddress); + assert.fieldEquals("File", fileId.toString(), "url", url); + assert.fieldEquals("File", fileId.toString(), "schemaId", "0"); // Important check for V1 + assert.fieldEquals( + "File", + fileId.toString(), + "transactionHash", + fileAddedEvent.transaction.hash.toHexString(), + ); + + // Also check that the associated User was created + assert.entityCount("User", 1); + assert.fieldEquals("User", ownerAddress, "id", ownerAddress); + + // --- Assert the ORIGINAL functionality (prevents regression) --- + assert.entityCount("FileOwner", 1); + assert.fieldEquals("FileOwner", fileId.toString(), "id", fileId.toString()); + assert.fieldEquals( + "FileOwner", + fileId.toString(), + "ownerAddress", + ownerAddress, + ); + }); +}); diff --git a/tests/unit/contract/v1/utils/data-registry-events.ts b/tests/unit/contract/v1/utils/data-registry-events.ts new file mode 100644 index 0000000..8e8a3fd --- /dev/null +++ b/tests/unit/contract/v1/utils/data-registry-events.ts @@ -0,0 +1,28 @@ +import { Address, ethereum } from "@graphprotocol/graph-ts"; +import { newMockEvent } from "matchstick-as/assembly/index"; +import { FileAdded as FileAddedEvent } from "../../../../../generated/DataRegistryImplementationV1/DataRegistryImplementationV1"; + +export function createFileAddedEvent( + fileId: i32, + ownerAddress: string, + url: string, +): FileAddedEvent { + const normalizedAddr = ownerAddress.toLowerCase(); + const fileAddedEvent = changetype(newMockEvent()); + fileAddedEvent.parameters = new Array(); + + fileAddedEvent.parameters.push( + new ethereum.EventParam("fileId", ethereum.Value.fromI32(fileId)), + ); + fileAddedEvent.parameters.push( + new ethereum.EventParam( + "ownerAddress", + ethereum.Value.fromAddress(Address.fromString(normalizedAddr)), + ), + ); + fileAddedEvent.parameters.push( + new ethereum.EventParam("url", ethereum.Value.fromString(url)), + ); + + return fileAddedEvent; +} From 5ea688efd12b6f114ab1fbac5ba139e6afc84b38 Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 12:53:58 -0400 Subject: [PATCH 14/17] feat: update existing tests --- src/lib/contract/v2/data-registry.ts | 14 ++++++++++---- src/lib/contract/v3/data-registry.ts | 16 +++++++++++----- src/lib/contract/v5/dlp-registry.ts | 11 +++++++++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/lib/contract/v2/data-registry.ts b/src/lib/contract/v2/data-registry.ts index 245a5be..bc846a5 100644 --- a/src/lib/contract/v2/data-registry.ts +++ b/src/lib/contract/v2/data-registry.ts @@ -4,6 +4,7 @@ import { DataRegistryProof, File, FileOwner, + Dlp, } from "../../../../generated/schema"; import { @@ -21,7 +22,7 @@ import { TOTALS_ID_GLOBAL, } from "../../entity/totals"; import { getEpochForBlock } from "../../entity/epoch"; -import { getOrCreateDlp, getOrCreateUser } from "../shared"; +import { getOrCreateUser } from "../shared"; export function handleFileAddedV2(event: FileAddedEvent): void { log.info("Handling DataRegistry FileAdded with transaction hash: {}", [ @@ -56,13 +57,18 @@ export function handleDataRegistryProofAddedV2(event: FileProofAdded): void { // Get epoch for the current block const epochId = getEpochForBlock(event.block.number); - if (!epochId) { + // FIX: Check for "-1" explicitly, as it is a truthy string + if (epochId == "-1") { log.error("No epoch found for block {}", [event.block.number.toString()]); return; } - // Ensure the Dlp entity exists - const dlp = getOrCreateDlp(event.params.dlpId.toString()); + // FIX: Load DLP instead of creating it to handle non-existent DLP case gracefully + const dlp = Dlp.load(event.params.dlpId.toString()); + if (dlp == null) { + log.error("DLP not found for proof: {}", [event.params.dlpId.toString()]); + return; + } // Create a new DataRegistryProof entity const proof = new DataRegistryProof(event.transaction.hash.toHex()); diff --git a/src/lib/contract/v3/data-registry.ts b/src/lib/contract/v3/data-registry.ts index a9df8d7..b093cb6 100644 --- a/src/lib/contract/v3/data-registry.ts +++ b/src/lib/contract/v3/data-registry.ts @@ -2,6 +2,7 @@ import { BigInt as GraphBigInt, log } from "@graphprotocol/graph-ts"; import { DataRegistryProof, + Dlp, File, FileOwner, } from "../../../../generated/schema"; @@ -10,7 +11,6 @@ import { FileAdded as FileAddedEvent, ProofAdded as FileProofAdded, } from "../../../../generated/DataRegistryImplementationV3/DataRegistryImplementationV3"; -import { getEpochForBlock } from "../../entity/epoch"; import { getOrCreateUserTotals, getUserTotalsId, @@ -21,7 +21,8 @@ import { getTotalsIdDlp, TOTALS_ID_GLOBAL, } from "../../entity/totals"; -import { getOrCreateDlp, getOrCreateUser } from "../shared"; +import { getOrCreateUser } from "../shared"; +import { getEpochForBlock } from "../../entity/epoch"; export function handleFileAddedV3(event: FileAddedEvent): void { log.info("Handling DataRegistry FileAdded with transaction hash: {}", [ @@ -56,13 +57,18 @@ export function handleDataRegistryProofAddedV3(event: FileProofAdded): void { // Get epoch for the current block const epochId = getEpochForBlock(event.block.number); - if (!epochId) { + // Check for "-1" explicitly, as it is a truthy string + if (epochId == "-1") { log.error("No epoch found for block {}", [event.block.number.toString()]); return; } - // Ensure the Dlp entity exists - const dlp = getOrCreateDlp(event.params.dlpId.toString()); + // Load DLP instead of creating it to handle non-existent DLP case gracefully + const dlp = Dlp.load(event.params.dlpId.toString()); + if (dlp == null) { + log.error("DLP not found for proof: {}", [event.params.dlpId.toString()]); + return; + } // Create a new DataRegistryProof entity const proof = new DataRegistryProof(event.transaction.hash.toHex()); diff --git a/src/lib/contract/v5/dlp-registry.ts b/src/lib/contract/v5/dlp-registry.ts index 91feef8..98c2261 100644 --- a/src/lib/contract/v5/dlp-registry.ts +++ b/src/lib/contract/v5/dlp-registry.ts @@ -155,8 +155,15 @@ export function handleDlpTokenUpdatedV5(event: DlpTokenUpdated): void { event.transaction.hash.toHexString(), ]); - // Ensure the Dlp entity exists - const dlp = getOrCreateDlp(event.params.dlpId.toString()); + // Load DLP instead of creating it to handle non-existent DLP case gracefully + const dlp = Dlp.load(event.params.dlpId.toString()); + + if (dlp == null) { + log.error("DLP not found for token update: {}", [ + event.params.dlpId.toString(), + ]); + return; + } dlp.token = event.params.tokenAddress; dlp.save(); From b108c2fadf18ce815c14f1617dac075bb3e782fa Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 14:02:58 -0400 Subject: [PATCH 15/17] feat: propagate config changes to subgraph.vana.yaml --- config/vana.json | 3 ++- subgraph.vana.yaml | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/config/vana.json b/config/vana.json index 65cafca..a391713 100644 --- a/config/vana.json +++ b/config/vana.json @@ -19,7 +19,8 @@ "vanaEpoch": true, "dlpPerformance": true, "queryEngine": true, - "dataRefinerRegistry": true + "dataRefinerRegistry": true, + "dataPermission": true } }, "initParams": { diff --git a/subgraph.vana.yaml b/subgraph.vana.yaml index 76f5152..4b7e427 100644 --- a/subgraph.vana.yaml +++ b/subgraph.vana.yaml @@ -222,3 +222,54 @@ dataSources: - event: EpochDlpPerformancesSaved(indexed uint256,indexed uint256,uint256,uint256,uint256,uint256) handler: handleEpochDlpPerformancesSavedV5 file: ./src/mapping.ts + + - kind: ethereum/contract + name: DataPermissionImplementation + network: vana + source: + address: "0x3acB2023DF2617EFb61422BA0c8C6E97916961e0" + abi: DataPermissionImplementation + startBlock: 3425120 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Permission + - User + - TrustedServer + abis: + - name: DataPermissionImplementation + file: ./abis/v5/DataPermissionImplementation.json + eventHandlers: + - event: PermissionAdded(indexed uint256,indexed address,string) + handler: handlePermissionAdded + - event: ServerTrusted(indexed address,indexed address,string) + handler: handleServerTrusted + - event: ServerUntrusted(indexed address,indexed address) + handler: handleServerUntrusted + file: ./src/mapping.ts + + - kind: ethereum/contract + name: DataRegistryImplementationV5 + network: vana + source: + address: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C" + abi: DataRegistryImplementationV5 + startBlock: 3425120 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - EpochReference + - DataRegistryProof + abis: + - name: DataRegistryImplementationV5 + file: ./abis/v5/DataRegistryImplementation.json + eventHandlers: + - event: FileAdded(indexed uint256,indexed address,string) + handler: handleFileAddedV3 + - event: ProofAdded(indexed uint256,indexed address,uint256,indexed uint256,uint256,string) + handler: handleDataRegistryProofAddedV3 + file: ./src/mapping.ts \ No newline at end of file From bc36c4916bea21014273c621402ca7766c45aa5d Mon Sep 17 00:00:00 2001 From: Volod Date: Thu, 10 Jul 2025 14:07:29 -0400 Subject: [PATCH 16/17] fix: add missing event handlers --- subgraph.moksha.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subgraph.moksha.yaml b/subgraph.moksha.yaml index 76a8581..d6b2625 100644 --- a/subgraph.moksha.yaml +++ b/subgraph.moksha.yaml @@ -163,6 +163,8 @@ dataSources: handler: handleDlpVerificationUpdatedV5 - event: DlpTokenUpdated(indexed uint256,address) handler: handleDlpTokenUpdatedV5 + - event: DlpSubEligibilityThresholdUpdated(uint256) + handler: handleDlpSubEligibilityThresholdUpdatedV5 - event: DlpRegistrationDepositAmountUpdated(uint256) handler: handleDlpRegistrationDepositAmountUpdatedV5 file: ./src/mapping.ts From dcd845379092ca638585d4a919bfaab175cd4ac4 Mon Sep 17 00:00:00 2001 From: Volod Date: Sat, 12 Jul 2025 11:22:08 -0400 Subject: [PATCH 17/17] feat: support latest smart contract changes --- abis/v5/DataPermissionImplementation.json | 2587 ++++++++++++--------- schema.graphql | 8 +- src/lib/contract/v5/data-permission.ts | 30 +- subgraph.moksha.yaml | 8 +- subgraph.vana-moksha.yaml | 10 +- subgraph.vana.yaml | 8 +- 6 files changed, 1480 insertions(+), 1171 deletions(-) diff --git a/abis/v5/DataPermissionImplementation.json b/abis/v5/DataPermissionImplementation.json index 03bd73a..bf65bda 100644 --- a/abis/v5/DataPermissionImplementation.json +++ b/abis/v5/DataPermissionImplementation.json @@ -1,1159 +1,1434 @@ [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "AccessControlBadConfirmation", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "neededRole", - "type": "bytes32" - } - ], - "name": "AccessControlUnauthorizedAccount", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - } - ], - "name": "AddressEmptyCode", - "type": "error" - }, - { - "inputs": [], - "name": "ECDSAInvalidSignature", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "length", - "type": "uint256" - } - ], - "name": "ECDSAInvalidSignatureLength", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "ECDSAInvalidSignatureS", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "ERC1967InvalidImplementation", - "type": "error" - }, - { - "inputs": [], - "name": "ERC1967NonPayable", - "type": "error" - }, - { - "inputs": [], - "name": "EmptyGrant", - "type": "error" - }, - { - "inputs": [], - "name": "EmptyUrl", - "type": "error" - }, - { - "inputs": [], - "name": "EnforcedPause", - "type": "error" - }, - { - "inputs": [], - "name": "ExpectedPause", - "type": "error" - }, - { - "inputs": [], - "name": "FailedInnerCall", - "type": "error" - }, - { - "inputs": [], - "name": "GrantAlreadyUsed", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidInitialization", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "expectedNonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "providedNonce", - "type": "uint256" - } - ], - "name": "InvalidNonce", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidSignature", - "type": "error" - }, - { - "inputs": [], - "name": "NotInitializing", - "type": "error" - }, - { - "inputs": [], - "name": "ServerAlreadyRegistered", - "type": "error" - }, - { - "inputs": [], - "name": "ServerNotFound", - "type": "error" - }, - { - "inputs": [], - "name": "ServerNotTrusted", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "existingUrl", - "type": "string" - }, - { - "internalType": "string", - "name": "providedUrl", - "type": "string" - } - ], - "name": "ServerUrlMismatch", - "type": "error" - }, - { - "inputs": [], - "name": "UUPSUnauthorizedCallContext", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "slot", - "type": "bytes32" - } - ], - "name": "UUPSUnsupportedProxiableUUID", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroAddress", - "type": "error" - }, - { - "anonymous": false, - "inputs": [], - "name": "EIP712DomainChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint64", - "name": "version", - "type": "uint64" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Paused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "permissionId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "grant", - "type": "string" - } - ], - "name": "PermissionAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "serverId", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "name": "ServerAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "serverId", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "serverUrl", - "type": "string" - } - ], - "name": "ServerTrusted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "serverId", - "type": "address" - } - ], - "name": "ServerUntrusted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Unpaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "MAINTAINER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "UPGRADE_INTERFACE_VERSION", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "internalType": "string", - "name": "grant", - "type": "string" - } - ], - "internalType": "struct IDataPermission.PermissionInput", - "name": "permission", - "type": "tuple" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "addPermission", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "eip712Domain", - "outputs": [ - { - "internalType": "bytes1", - "name": "fields", - "type": "bytes1" - }, - { - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "internalType": "string", - "name": "version", - "type": "string" - }, - { - "internalType": "uint256", - "name": "chainId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "verifyingContract", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "uint256[]", - "name": "extensions", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "trustedForwarderAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "ownerAddress", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "forwarder", - "type": "address" - } - ], - "name": "isTrustedForwarder", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes[]", - "name": "data", - "type": "bytes[]" - } - ], - "name": "multicall", - "outputs": [ - { - "internalType": "bytes[]", - "name": "results", - "type": "bytes[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "grant", - "type": "string" - } - ], - "name": "permissionIdByGrant", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "permissionId", - "type": "uint256" - } - ], - "name": "permissions", - "outputs": [ - { - "components": [ - { - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "internalType": "string", - "name": "grant", - "type": "string" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "internalType": "struct IDataPermission.Permission", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "permissionsCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "proxiableUUID", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "callerConfirmation", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "serverId", - "type": "address" - } - ], - "name": "servers", - "outputs": [ - { - "components": [ - { - "internalType": "string", - "name": "url", - "type": "string" - } - ], - "internalType": "struct IDataPermission.Server", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "adminRole", - "type": "bytes32" - } - ], - "name": "setRoleAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "serverId", - "type": "address" - }, - { - "internalType": "string", - "name": "serverUrl", - "type": "string" - } - ], - "name": "trustServer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "internalType": "address", - "name": "serverId", - "type": "address" - }, - { - "internalType": "string", - "name": "serverUrl", - "type": "string" - } - ], - "internalType": "struct IDataPermission.TrustServerInput", - "name": "trustServerInput", - "type": "tuple" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "trustServerWithSignature", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "trustedForwarder", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "unpause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "serverId", - "type": "address" - } - ], - "name": "untrustServer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "internalType": "address", - "name": "serverId", - "type": "address" - } - ], - "internalType": "struct IDataPermission.UntrustServerInput", - "name": "untrustServerInput", - "type": "tuple" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "untrustServerWithSignature", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "trustedForwarderAddress", - "type": "address" - } - ], - "name": "updateTrustedForwarder", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "user", - "type": "address" - } - ], - "name": "userNonce", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "internalType": "uint256", - "name": "permissionIndex", - "type": "uint256" - } - ], - "name": "userPermissionIdsAt", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "user", - "type": "address" - } - ], - "name": "userPermissionIdsLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "user", - "type": "address" - } - ], - "name": "userPermissionIdsValues", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "internalType": "uint256", - "name": "serverIndex", - "type": "uint256" - } - ], - "name": "userServerIdsAt", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "user", - "type": "address" - } - ], - "name": "userServerIdsLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "user", - "type": "address" - } - ], - "name": "userServerIdsValues", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AccessControlBadConfirmation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "neededRole", + "type": "bytes32" + } + ], + "name": "AccessControlUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [], + "name": "ECDSAInvalidSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "ECDSAInvalidSignatureLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "ECDSAInvalidSignatureS", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ERC1967InvalidImplementation", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1967NonPayable", + "type": "error" + }, + { + "inputs": [], + "name": "EmptyGrant", + "type": "error" + }, + { + "inputs": [], + "name": "EmptyUrl", + "type": "error" + }, + { + "inputs": [], + "name": "EnforcedPause", + "type": "error" + }, + { + "inputs": [], + "name": "ExpectedPause", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "GrantAlreadyUsed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + } + ], + "name": "InactivePermission", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "expectedNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "providedNonce", + "type": "uint256" + } + ], + "name": "InvalidNonce", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "fileOwner", + "type": "address" + }, + { + "internalType": "address", + "name": "requestor", + "type": "address" + } + ], + "name": "NotFileOwner", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "permissionOwner", + "type": "address" + }, + { + "internalType": "address", + "name": "requestor", + "type": "address" + } + ], + "name": "NotPermissionGrantor", + "type": "error" + }, + { + "inputs": [], + "name": "ServerAlreadyRegistered", + "type": "error" + }, + { + "inputs": [], + "name": "ServerNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "ServerNotTrusted", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "existingUrl", + "type": "string" + }, + { + "internalType": "string", + "name": "providedUrl", + "type": "string" + } + ], + "name": "ServerUrlMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "UUPSUnauthorizedCallContext", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "slot", + "type": "bytes32" + } + ], + "name": "UUPSUnsupportedProxiableUUID", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [], + "name": "EIP712DomainChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", "name": "version", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - } + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "grant", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fileIds", + "type": "uint256[]" + } + ], + "name": "PermissionAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + } + ], + "name": "PermissionRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serverId", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "name": "ServerAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "serverId", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "serverUrl", + "type": "string" + } + ], + "name": "ServerTrusted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "serverId", + "type": "address" + } + ], + "name": "ServerUntrusted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAINTAINER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UPGRADE_INTERFACE_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "string", + "name": "grant", + "type": "string" + }, + { + "internalType": "uint256[]", + "name": "fileIds", + "type": "uint256[]" + } + ], + "internalType": "struct IDataPermissions.PermissionInput", + "name": "permission", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "addPermission", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "dataRegistry", + "outputs": [ + { + "internalType": "contract IDataRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "eip712Domain", + "outputs": [ + { + "internalType": "bytes1", + "name": "fields", + "type": "bytes1" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "version", + "type": "string" + }, + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifyingContract", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "extensions", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fileId", + "type": "uint256" + } + ], + "name": "filePermissionIds", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "trustedForwarderAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "ownerAddress", + "type": "address" + }, + { + "internalType": "contract IDataRegistry", + "name": "dataRegistryAddress", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + } + ], + "name": "isActivePermission", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "forwarder", + "type": "address" + } + ], + "name": "isTrustedForwarder", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + } + ], + "name": "permissionFileIds", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "grant", + "type": "string" + } + ], + "name": "permissionIdByGrant", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + } + ], + "name": "permissions", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "address", + "name": "grantor", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "string", + "name": "grant", + "type": "string" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "isActive", + "type": "bool" + }, + { + "internalType": "uint256[]", + "name": "fileIds", + "type": "uint256[]" + } + ], + "internalType": "struct IDataPermissions.PermissionInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "permissionsCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "callerConfirmation", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + } + ], + "name": "revokePermission", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "permissionId", + "type": "uint256" + } + ], + "internalType": "struct IDataPermissions.RevokePermissionInput", + "name": "revokePermissionInput", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "revokePermissionWithSignature", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serverId", + "type": "address" + } + ], + "name": "servers", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "url", + "type": "string" + } + ], + "internalType": "struct IDataPermissions.Server", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "adminRole", + "type": "bytes32" + } + ], + "name": "setRoleAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serverId", + "type": "address" + }, + { + "internalType": "string", + "name": "serverUrl", + "type": "string" + } + ], + "name": "trustServer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "address", + "name": "serverId", + "type": "address" + }, + { + "internalType": "string", + "name": "serverUrl", + "type": "string" + } + ], + "internalType": "struct IDataPermissions.TrustServerInput", + "name": "trustServerInput", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "trustServerWithSignature", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "trustedForwarder", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serverId", + "type": "address" + } + ], + "name": "untrustServer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "address", + "name": "serverId", + "type": "address" + } + ], + "internalType": "struct IDataPermissions.UntrustServerInput", + "name": "untrustServerInput", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "untrustServerWithSignature", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IDataRegistry", + "name": "newDataRegistry", + "type": "address" + } + ], + "name": "updateDataRegistry", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "trustedForwarderAddress", + "type": "address" + } + ], + "name": "updateTrustedForwarder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "permissionIndex", + "type": "uint256" + } + ], + "name": "userPermissionIdsAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userPermissionIdsLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userPermissionIdsValues", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "permissionIndex", + "type": "uint256" + } + ], + "name": "userRevokedPermissionIdsAt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userRevokedPermissionIdsLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userRevokedPermissionIdsValues", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "serverIndex", + "type": "uint256" + } + ], + "name": "userServerIdsAt", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userServerIdsLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "userServerIdsValues", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + } ] \ No newline at end of file diff --git a/schema.graphql b/schema.graphql index 3b12a31..3b5dc0b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -4,7 +4,7 @@ type User @entity(immutable: false) { "All files owned by this user" files: [File!]! @derivedFrom(field: "owner") "All permissions granted by this user" - permissions: [Permission!]! @derivedFrom(field: "user") + permissions: [Permission!]! @derivedFrom(field: "grantor") "All servers trusted by this user" trustedServers: [TrustedServer!]! @derivedFrom(field: "user") } @@ -158,13 +158,17 @@ type Permission @entity(immutable: false) { "The unique ID of the permission, equivalent to the on-chain permissionId." id: ID! "The user who granted the permission." - user: User! + grantor: User! "The content identifier (e.g., IPFS URL) for the grant details." grant: String! "The nonce used for this permission grant." nonce: BigInt! "The signature provided by the user." signature: Bytes! + "Whether the permission is currently active or has been revoked." + isActive: Boolean! + "File IDs associated with this permission." + fileIds: [BigInt!]! "The block number when the permission was granted." addedAtBlock: BigInt! "The timestamp when the permission was granted." diff --git a/src/lib/contract/v5/data-permission.ts b/src/lib/contract/v5/data-permission.ts index 440c429..70af0d3 100644 --- a/src/lib/contract/v5/data-permission.ts +++ b/src/lib/contract/v5/data-permission.ts @@ -6,6 +6,7 @@ import { } from "@graphprotocol/graph-ts"; import { PermissionAdded, + PermissionRevoked, ServerTrusted, ServerUntrusted, DataPermissionImplementation, @@ -18,22 +19,26 @@ export function handlePermissionAdded(event: PermissionAdded): void { event.transaction.hash.toHexString(), ]); - const user = getOrCreateUser(event.params.user.toHex()); + const grantor = getOrCreateUser(event.params.user.toHex()); const permissionId = event.params.permissionId; const permission = new Permission(permissionId.toString()); - permission.user = user.id; + permission.grantor = grantor.id; // Renamed from 'user' to 'grantor' permission.grant = event.params.grant; permission.addedAtBlock = event.block.number; permission.addedAtTimestamp = event.block.timestamp; permission.transactionHash = event.transaction.hash; + // Set new fields + permission.isActive = true; // New permissions are active by default + permission.fileIds = event.params.fileIds; // Store the new fileIds array + // Since nonce and signature are not in the event, we must call the contract. const contract = DataPermissionImplementation.bind(event.address); const permissionData = contract.try_permissions(permissionId); if (!permissionData.reverted) { - // FIX: Access properties directly instead of using getters. + // The returned struct has a 'grantor' field, not 'user' permission.nonce = permissionData.value.nonce; permission.signature = permissionData.value.signature; } else { @@ -42,13 +47,30 @@ export function handlePermissionAdded(event: PermissionAdded): void { [permissionId.toString()], ); permission.nonce = GraphBigInt.zero(); - // FIX: Use an empty Bytes array for an empty signature. permission.signature = new Bytes(0); } permission.save(); } +export function handlePermissionRevoked(event: PermissionRevoked): void { + log.info("Handling PermissionRevoked for permissionId: {}", [ + event.params.permissionId.toString(), + ]); + + const permissionId = event.params.permissionId.toString(); + const permission = Permission.load(permissionId); + + if (permission) { + permission.isActive = false; + permission.save(); + } else { + log.warning("Received revoke event for a permission not found in subgraph: {}", [ + permissionId, + ]); + } +} + export function handleServerTrusted(event: ServerTrusted): void { log.info("Handling ServerTrusted for user {} and server {}", [ event.params.user.toHex(), diff --git a/subgraph.moksha.yaml b/subgraph.moksha.yaml index d6b2625..c6c57ef 100644 --- a/subgraph.moksha.yaml +++ b/subgraph.moksha.yaml @@ -227,9 +227,9 @@ dataSources: name: DataPermissionImplementation network: moksha source: - address: "0x3acB2023DF2617EFb61422BA0c8C6E97916961e0" + address: "0x31fb1D48f6B2265A4cAD516BC39E96a18fb7c8de" abi: DataPermissionImplementation - startBlock: 3425120 + startBlock: 3517249 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -242,8 +242,10 @@ dataSources: - name: DataPermissionImplementation file: ./abis/v5/DataPermissionImplementation.json eventHandlers: - - event: PermissionAdded(indexed uint256,indexed address,string) + - event: PermissionAdded(indexed uint256,indexed address,string,uint256[]) handler: handlePermissionAdded + - event: PermissionRevoked(indexed uint256) + handler: handlePermissionRevoked - event: ServerTrusted(indexed address,indexed address,string) handler: handleServerTrusted - event: ServerUntrusted(indexed address,indexed address) diff --git a/subgraph.vana-moksha.yaml b/subgraph.vana-moksha.yaml index c9353dd..ff7305e 100644 --- a/subgraph.vana-moksha.yaml +++ b/subgraph.vana-moksha.yaml @@ -163,6 +163,8 @@ dataSources: handler: handleDlpVerificationUpdatedV5 - event: DlpTokenUpdated(indexed uint256,address) handler: handleDlpTokenUpdatedV5 + - event: DlpSubEligibilityThresholdUpdated(uint256) + handler: handleDlpSubEligibilityThresholdUpdatedV5 - event: DlpRegistrationDepositAmountUpdated(uint256) handler: handleDlpRegistrationDepositAmountUpdatedV5 file: ./src/mapping.ts @@ -225,9 +227,9 @@ dataSources: name: DataPermissionImplementation network: vana-moksha source: - address: "0x3acB2023DF2617EFb61422BA0c8C6E97916961e0" + address: "0x31fb1D48f6B2265A4cAD516BC39E96a18fb7c8de" abi: DataPermissionImplementation - startBlock: 3425120 + startBlock: 3517249 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -240,8 +242,10 @@ dataSources: - name: DataPermissionImplementation file: ./abis/v5/DataPermissionImplementation.json eventHandlers: - - event: PermissionAdded(indexed uint256,indexed address,string) + - event: PermissionAdded(indexed uint256,indexed address,string,uint256[]) handler: handlePermissionAdded + - event: PermissionRevoked(indexed uint256) + handler: handlePermissionRevoked - event: ServerTrusted(indexed address,indexed address,string) handler: handleServerTrusted - event: ServerUntrusted(indexed address,indexed address) diff --git a/subgraph.vana.yaml b/subgraph.vana.yaml index 4b7e427..5b69dd6 100644 --- a/subgraph.vana.yaml +++ b/subgraph.vana.yaml @@ -227,9 +227,9 @@ dataSources: name: DataPermissionImplementation network: vana source: - address: "0x3acB2023DF2617EFb61422BA0c8C6E97916961e0" + address: "0x31fb1D48f6B2265A4cAD516BC39E96a18fb7c8de" abi: DataPermissionImplementation - startBlock: 3425120 + startBlock: 3965727 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -242,8 +242,10 @@ dataSources: - name: DataPermissionImplementation file: ./abis/v5/DataPermissionImplementation.json eventHandlers: - - event: PermissionAdded(indexed uint256,indexed address,string) + - event: PermissionAdded(indexed uint256,indexed address,string,uint256[]) handler: handlePermissionAdded + - event: PermissionRevoked(indexed uint256) + handler: handlePermissionRevoked - event: ServerTrusted(indexed address,indexed address,string) handler: handleServerTrusted - event: ServerUntrusted(indexed address,indexed address)