diff --git a/packages/dvilela/contracts/agent_registry.json b/packages/dvilela/contracts/agent_registry.json new file mode 100644 index 0000000..6d3e917 --- /dev/null +++ b/packages/dvilela/contracts/agent_registry.json @@ -0,0 +1,1256 @@ +[ + { + "inputs":[ + { + "internalType":"string", + "name":"_name", + "type":"string" + }, + { + "internalType":"string", + "name":"_symbol", + "type":"string" + }, + { + "internalType":"string", + "name":"_baseURI", + "type":"string" + }, + { + "internalType":"address", + "name":"_componentRegistry", + "type":"address" + } + ], + "stateMutability":"nonpayable", + "type":"constructor" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + } + ], + "name":"AgentInstanceRegistered", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"AgentInstancesSlotsFilled", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + } + ], + "name":"AgentNotFound", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"AgentNotInService", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"componentId", + "type":"uint256" + } + ], + "name":"ComponentNotFound", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"HashExists", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"sent", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"expected", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"IncorrectAgentBondingValue", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"sent", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"expected", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"IncorrectRegistrationDepositValue", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"sender", + "type":"address" + }, + { + "internalType":"address", + "name":"manager", + "type":"address" + } + ], + "name":"ManagerOnly", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"provided", + "type":"address" + }, + { + "internalType":"address", + "name":"expected", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"OnlyOwnServiceMultisig", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"OperatorHasNoInstances", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"provided", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"max", + "type":"uint256" + } + ], + "name":"Overflow", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"sender", + "type":"address" + }, + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"OwnerOnly", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"Paused", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ReentrancyGuard", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"ServiceMustBeInactive", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"token", + "type":"address" + }, + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"value", + "type":"uint256" + } + ], + "name":"TransferFailed", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"multisig", + "type":"address" + } + ], + "name":"UnauthorizedMultisig", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + } + ], + "name":"WrongAgentId", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"numValues1", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"numValues2", + "type":"uint256" + } + ], + "name":"WrongArrayLength", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"WrongOperator", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"state", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"WrongServiceState", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"currentThreshold", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"minThreshold", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"maxThreshold", + "type":"uint256" + } + ], + "name":"WrongThreshold", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ZeroAddress", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ZeroValue", + "type":"error" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"spender", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"Approval", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "indexed":false, + "internalType":"bool", + "name":"approved", + "type":"bool" + } + ], + "name":"ApprovalForAll", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "internalType":"string", + "name":"baseURI", + "type":"string" + } + ], + "name":"BaseURIChanged", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + }, + { + "indexed":false, + "internalType":"enum UnitRegistry.UnitType", + "name":"uType", + "type":"uint8" + }, + { + "indexed":false, + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + } + ], + "name":"CreateUnit", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"manager", + "type":"address" + } + ], + "name":"ManagerUpdated", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"OwnerUpdated", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"Transfer", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + }, + { + "indexed":false, + "internalType":"enum UnitRegistry.UnitType", + "name":"uType", + "type":"uint8" + }, + { + "indexed":false, + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + } + ], + "name":"UpdateUnitHash", + "type":"event" + }, + { + "inputs":[ + + ], + "name":"CID_PREFIX", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"VERSION", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"spender", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"approve", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"balanceOf", + "outputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"baseURI", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint32[]", + "name":"unitIds", + "type":"uint32[]" + } + ], + "name":"calculateSubComponents", + "outputs":[ + { + "internalType":"uint32[]", + "name":"subComponentIds", + "type":"uint32[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"newManager", + "type":"address" + } + ], + "name":"changeManager", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"newOwner", + "type":"address" + } + ], + "name":"changeOwner", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"componentRegistry", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"unitOwner", + "type":"address" + }, + { + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + }, + { + "internalType":"uint32[]", + "name":"dependencies", + "type":"uint32[]" + } + ], + "name":"create", + "outputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"exists", + "outputs":[ + { + "internalType":"bool", + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"getApproved", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"getDependencies", + "outputs":[ + { + "internalType":"uint256", + "name":"numDependencies", + "type":"uint256" + }, + { + "internalType":"uint32[]", + "name":"dependencies", + "type":"uint32[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"getLocalSubComponents", + "outputs":[ + { + "internalType":"uint32[]", + "name":"subComponentIds", + "type":"uint32[]" + }, + { + "internalType":"uint256", + "name":"numSubComponents", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"getUnit", + "outputs":[ + { + "components":[ + { + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + }, + { + "internalType":"uint32[]", + "name":"dependencies", + "type":"uint32[]" + } + ], + "internalType":"struct UnitRegistry.Unit", + "name":"unit", + "type":"tuple" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"getUpdatedHashes", + "outputs":[ + { + "internalType":"uint256", + "name":"numHashes", + "type":"uint256" + }, + { + "internalType":"bytes32[]", + "name":"unitHashes", + "type":"bytes32[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + }, + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "name":"isApprovedForAll", + "outputs":[ + { + "internalType":"bool", + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"manager", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapSubComponents", + "outputs":[ + { + "internalType":"uint32", + "name":"", + "type":"uint32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapUnitIdHashes", + "outputs":[ + { + "internalType":"bytes32", + "name":"", + "type":"bytes32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapUnits", + "outputs":[ + { + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"name", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"owner", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"ownerOf", + "outputs":[ + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"safeTransferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + }, + { + "internalType":"bytes", + "name":"data", + "type":"bytes" + } + ], + "name":"safeTransferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"bool", + "name":"approved", + "type":"bool" + } + ], + "name":"setApprovalForAll", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"string", + "name":"bURI", + "type":"string" + } + ], + "name":"setBaseURI", + "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":"symbol", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"tokenByIndex", + "outputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"tokenURI", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"totalSupply", + "outputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"transferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"unitType", + "outputs":[ + { + "internalType":"enum UnitRegistry.UnitType", + "name":"", + "type":"uint8" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"unitOwner", + "type":"address" + }, + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + }, + { + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + } + ], + "name":"updateHash", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + } + ], + "stateMutability":"nonpayable", + "type":"function" + } +] \ No newline at end of file diff --git a/packages/dvilela/contracts/component_registry.json b/packages/dvilela/contracts/component_registry.json new file mode 100644 index 0000000..943555e --- /dev/null +++ b/packages/dvilela/contracts/component_registry.json @@ -0,0 +1,1217 @@ +[ + { + "inputs":[ + { + "internalType":"string", + "name":"_name", + "type":"string" + }, + { + "internalType":"string", + "name":"_symbol", + "type":"string" + }, + { + "internalType":"string", + "name":"_baseURI", + "type":"string" + } + ], + "stateMutability":"nonpayable", + "type":"constructor" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + } + ], + "name":"AgentInstanceRegistered", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"AgentInstancesSlotsFilled", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + } + ], + "name":"AgentNotFound", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"AgentNotInService", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"componentId", + "type":"uint256" + } + ], + "name":"ComponentNotFound", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"HashExists", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"sent", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"expected", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"IncorrectAgentBondingValue", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"sent", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"expected", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"IncorrectRegistrationDepositValue", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"sender", + "type":"address" + }, + { + "internalType":"address", + "name":"manager", + "type":"address" + } + ], + "name":"ManagerOnly", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"provided", + "type":"address" + }, + { + "internalType":"address", + "name":"expected", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"OnlyOwnServiceMultisig", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"OperatorHasNoInstances", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"provided", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"max", + "type":"uint256" + } + ], + "name":"Overflow", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"sender", + "type":"address" + }, + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"OwnerOnly", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"Paused", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ReentrancyGuard", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"ServiceMustBeInactive", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"token", + "type":"address" + }, + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"value", + "type":"uint256" + } + ], + "name":"TransferFailed", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"multisig", + "type":"address" + } + ], + "name":"UnauthorizedMultisig", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + } + ], + "name":"WrongAgentId", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"numValues1", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"numValues2", + "type":"uint256" + } + ], + "name":"WrongArrayLength", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"WrongOperator", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"state", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"WrongServiceState", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"currentThreshold", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"minThreshold", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"maxThreshold", + "type":"uint256" + } + ], + "name":"WrongThreshold", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ZeroAddress", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ZeroValue", + "type":"error" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"spender", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"Approval", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "indexed":false, + "internalType":"bool", + "name":"approved", + "type":"bool" + } + ], + "name":"ApprovalForAll", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "internalType":"string", + "name":"baseURI", + "type":"string" + } + ], + "name":"BaseURIChanged", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + }, + { + "indexed":false, + "internalType":"enum UnitRegistry.UnitType", + "name":"uType", + "type":"uint8" + }, + { + "indexed":false, + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + } + ], + "name":"CreateUnit", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"manager", + "type":"address" + } + ], + "name":"ManagerUpdated", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"OwnerUpdated", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"Transfer", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + }, + { + "indexed":false, + "internalType":"enum UnitRegistry.UnitType", + "name":"uType", + "type":"uint8" + }, + { + "indexed":false, + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + } + ], + "name":"UpdateUnitHash", + "type":"event" + }, + { + "inputs":[ + + ], + "name":"CID_PREFIX", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"VERSION", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"spender", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"approve", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"balanceOf", + "outputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"baseURI", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"newManager", + "type":"address" + } + ], + "name":"changeManager", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"newOwner", + "type":"address" + } + ], + "name":"changeOwner", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"unitOwner", + "type":"address" + }, + { + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + }, + { + "internalType":"uint32[]", + "name":"dependencies", + "type":"uint32[]" + } + ], + "name":"create", + "outputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"exists", + "outputs":[ + { + "internalType":"bool", + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"getApproved", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"getDependencies", + "outputs":[ + { + "internalType":"uint256", + "name":"numDependencies", + "type":"uint256" + }, + { + "internalType":"uint32[]", + "name":"dependencies", + "type":"uint32[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"getLocalSubComponents", + "outputs":[ + { + "internalType":"uint32[]", + "name":"subComponentIds", + "type":"uint32[]" + }, + { + "internalType":"uint256", + "name":"numSubComponents", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"getUnit", + "outputs":[ + { + "components":[ + { + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + }, + { + "internalType":"uint32[]", + "name":"dependencies", + "type":"uint32[]" + } + ], + "internalType":"struct UnitRegistry.Unit", + "name":"unit", + "type":"tuple" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"getUpdatedHashes", + "outputs":[ + { + "internalType":"uint256", + "name":"numHashes", + "type":"uint256" + }, + { + "internalType":"bytes32[]", + "name":"unitHashes", + "type":"bytes32[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + }, + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "name":"isApprovedForAll", + "outputs":[ + { + "internalType":"bool", + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"manager", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapSubComponents", + "outputs":[ + { + "internalType":"uint32", + "name":"", + "type":"uint32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapUnitIdHashes", + "outputs":[ + { + "internalType":"bytes32", + "name":"", + "type":"bytes32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapUnits", + "outputs":[ + { + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"name", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"owner", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"ownerOf", + "outputs":[ + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"safeTransferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + }, + { + "internalType":"bytes", + "name":"data", + "type":"bytes" + } + ], + "name":"safeTransferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"bool", + "name":"approved", + "type":"bool" + } + ], + "name":"setApprovalForAll", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"string", + "name":"bURI", + "type":"string" + } + ], + "name":"setBaseURI", + "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":"symbol", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"tokenByIndex", + "outputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"tokenURI", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"totalSupply", + "outputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"transferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"unitType", + "outputs":[ + { + "internalType":"enum UnitRegistry.UnitType", + "name":"", + "type":"uint8" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"unitOwner", + "type":"address" + }, + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + }, + { + "internalType":"bytes32", + "name":"unitHash", + "type":"bytes32" + } + ], + "name":"updateHash", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + } + ], + "stateMutability":"nonpayable", + "type":"function" + } +] \ No newline at end of file diff --git a/packages/dvilela/contracts/service_registry.json b/packages/dvilela/contracts/service_registry.json new file mode 100644 index 0000000..cde7ef7 --- /dev/null +++ b/packages/dvilela/contracts/service_registry.json @@ -0,0 +1,2031 @@ +[ + { + "inputs":[ + { + "internalType":"string", + "name":"_name", + "type":"string" + }, + { + "internalType":"string", + "name":"_symbol", + "type":"string" + }, + { + "internalType":"string", + "name":"_baseURI", + "type":"string" + }, + { + "internalType":"address", + "name":"_agentRegistry", + "type":"address" + } + ], + "stateMutability":"nonpayable", + "type":"constructor" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + } + ], + "name":"AgentInstanceRegistered", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"AgentInstancesSlotsFilled", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + } + ], + "name":"AgentNotFound", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"AgentNotInService", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"componentId", + "type":"uint256" + } + ], + "name":"ComponentNotFound", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"HashExists", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"sent", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"expected", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"IncorrectAgentBondingValue", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"sent", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"expected", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"IncorrectRegistrationDepositValue", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"sender", + "type":"address" + }, + { + "internalType":"address", + "name":"manager", + "type":"address" + } + ], + "name":"ManagerOnly", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"provided", + "type":"address" + }, + { + "internalType":"address", + "name":"expected", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"OnlyOwnServiceMultisig", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"OperatorHasNoInstances", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"provided", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"max", + "type":"uint256" + } + ], + "name":"Overflow", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"sender", + "type":"address" + }, + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"OwnerOnly", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"Paused", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ReentrancyGuard", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"ServiceMustBeInactive", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"token", + "type":"address" + }, + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"value", + "type":"uint256" + } + ], + "name":"TransferFailed", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"multisig", + "type":"address" + } + ], + "name":"UnauthorizedMultisig", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + } + ], + "name":"WrongAgentId", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"numValues1", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"numValues2", + "type":"uint256" + } + ], + "name":"WrongArrayLength", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"WrongOperator", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"state", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"WrongServiceState", + "type":"error" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"currentThreshold", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"minThreshold", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"maxThreshold", + "type":"uint256" + } + ], + "name":"WrongThreshold", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ZeroAddress", + "type":"error" + }, + { + "inputs":[ + + ], + "name":"ZeroValue", + "type":"error" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"ActivateRegistration", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"spender", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"Approval", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "indexed":false, + "internalType":"bool", + "name":"approved", + "type":"bool" + } + ], + "name":"ApprovalForAll", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "internalType":"string", + "name":"baseURI", + "type":"string" + } + ], + "name":"BaseURIChanged", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + }, + { + "indexed":true, + "internalType":"address", + "name":"multisig", + "type":"address" + } + ], + "name":"CreateMultisigWithAgents", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"CreateService", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"DeployService", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"sender", + "type":"address" + }, + { + "indexed":false, + "internalType":"uint256", + "name":"amount", + "type":"uint256" + } + ], + "name":"Deposit", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"drainer", + "type":"address" + }, + { + "indexed":false, + "internalType":"uint256", + "name":"amount", + "type":"uint256" + } + ], + "name":"Drain", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"drainer", + "type":"address" + } + ], + "name":"DrainerUpdated", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"manager", + "type":"address" + } + ], + "name":"ManagerUpdated", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":false, + "internalType":"uint256", + "name":"amount", + "type":"uint256" + }, + { + "indexed":true, + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"OperatorSlashed", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"OperatorUnbond", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"OwnerUpdated", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"receiver", + "type":"address" + }, + { + "indexed":false, + "internalType":"uint256", + "name":"amount", + "type":"uint256" + } + ], + "name":"Refund", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + }, + { + "indexed":true, + "internalType":"address", + "name":"agentInstance", + "type":"address" + }, + { + "indexed":false, + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + } + ], + "name":"RegisterInstance", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"TerminateService", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "indexed":true, + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "indexed":true, + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"Transfer", + "type":"event" + }, + { + "anonymous":false, + "inputs":[ + { + "indexed":true, + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + }, + { + "indexed":false, + "internalType":"bytes32", + "name":"configHash", + "type":"bytes32" + } + ], + "name":"UpdateService", + "type":"event" + }, + { + "inputs":[ + + ], + "name":"CID_PREFIX", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"VERSION", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"serviceOwner", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"activateRegistration", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + } + ], + "stateMutability":"payable", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"agentRegistry", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"spender", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"approve", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "name":"balanceOf", + "outputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"baseURI", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"newDrainer", + "type":"address" + } + ], + "name":"changeDrainer", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"newManager", + "type":"address" + } + ], + "name":"changeManager", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"multisig", + "type":"address" + }, + { + "internalType":"bool", + "name":"permission", + "type":"bool" + } + ], + "name":"changeMultisigPermission", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"newOwner", + "type":"address" + } + ], + "name":"changeOwner", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"serviceOwner", + "type":"address" + }, + { + "internalType":"bytes32", + "name":"configHash", + "type":"bytes32" + }, + { + "internalType":"uint32[]", + "name":"agentIds", + "type":"uint32[]" + }, + { + "components":[ + { + "internalType":"uint32", + "name":"slots", + "type":"uint32" + }, + { + "internalType":"uint96", + "name":"bond", + "type":"uint96" + } + ], + "internalType":"struct AgentParams[]", + "name":"agentParams", + "type":"tuple[]" + }, + { + "internalType":"uint32", + "name":"threshold", + "type":"uint32" + } + ], + "name":"create", + "outputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"serviceOwner", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + }, + { + "internalType":"address", + "name":"multisigImplementation", + "type":"address" + }, + { + "internalType":"bytes", + "name":"data", + "type":"bytes" + } + ], + "name":"deploy", + "outputs":[ + { + "internalType":"address", + "name":"multisig", + "type":"address" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"drain", + "outputs":[ + { + "internalType":"uint256", + "name":"amount", + "type":"uint256" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"drainer", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"exists", + "outputs":[ + { + "internalType":"bool", + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"getAgentInstances", + "outputs":[ + { + "internalType":"uint256", + "name":"numAgentInstances", + "type":"uint256" + }, + { + "internalType":"address[]", + "name":"agentInstances", + "type":"address[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"getAgentParams", + "outputs":[ + { + "internalType":"uint256", + "name":"numAgentIds", + "type":"uint256" + }, + { + "components":[ + { + "internalType":"uint32", + "name":"slots", + "type":"uint32" + }, + { + "internalType":"uint96", + "name":"bond", + "type":"uint96" + } + ], + "internalType":"struct AgentParams[]", + "name":"agentParams", + "type":"tuple[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"getApproved", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"agentId", + "type":"uint256" + } + ], + "name":"getInstancesForAgentId", + "outputs":[ + { + "internalType":"uint256", + "name":"numAgentInstances", + "type":"uint256" + }, + { + "internalType":"address[]", + "name":"agentInstances", + "type":"address[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"getOperatorBalance", + "outputs":[ + { + "internalType":"uint256", + "name":"balance", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"getPreviousHashes", + "outputs":[ + { + "internalType":"uint256", + "name":"numHashes", + "type":"uint256" + }, + { + "internalType":"bytes32[]", + "name":"configHashes", + "type":"bytes32[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"getService", + "outputs":[ + { + "components":[ + { + "internalType":"uint96", + "name":"securityDeposit", + "type":"uint96" + }, + { + "internalType":"address", + "name":"multisig", + "type":"address" + }, + { + "internalType":"bytes32", + "name":"configHash", + "type":"bytes32" + }, + { + "internalType":"uint32", + "name":"threshold", + "type":"uint32" + }, + { + "internalType":"uint32", + "name":"maxNumAgentInstances", + "type":"uint32" + }, + { + "internalType":"uint32", + "name":"numAgentInstances", + "type":"uint32" + }, + { + "internalType":"enum ServiceRegistry.ServiceState", + "name":"state", + "type":"uint8" + }, + { + "internalType":"uint32[]", + "name":"agentIds", + "type":"uint32[]" + } + ], + "internalType":"struct ServiceRegistry.Service", + "name":"service", + "type":"tuple" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"enum IRegistry.UnitType", + "name":"unitType", + "type":"uint8" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"getUnitIdsOfService", + "outputs":[ + { + "internalType":"uint256", + "name":"numUnitIds", + "type":"uint256" + }, + { + "internalType":"uint32[]", + "name":"unitIds", + "type":"uint32[]" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + }, + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "name":"isApprovedForAll", + "outputs":[ + { + "internalType":"bool", + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"manager", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "name":"mapAgentInstanceOperators", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapConfigHashes", + "outputs":[ + { + "internalType":"bytes32", + "name":"", + "type":"bytes32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "name":"mapMultisigs", + "outputs":[ + { + "internalType":"bool", + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapOperatorAndServiceIdAgentInstances", + "outputs":[ + { + "internalType":"address", + "name":"instance", + "type":"address" + }, + { + "internalType":"uint32", + "name":"agentId", + "type":"uint32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapOperatorAndServiceIdOperatorBalances", + "outputs":[ + { + "internalType":"uint96", + "name":"", + "type":"uint96" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapServiceAndAgentIdAgentInstances", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapServiceAndAgentIdAgentParams", + "outputs":[ + { + "internalType":"uint32", + "name":"slots", + "type":"uint32" + }, + { + "internalType":"uint96", + "name":"bond", + "type":"uint96" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapServiceIdSetAgentIds", + "outputs":[ + { + "internalType":"uint32", + "name":"", + "type":"uint32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + }, + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapServiceIdSetComponentIds", + "outputs":[ + { + "internalType":"uint32", + "name":"", + "type":"uint32" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "name":"mapServices", + "outputs":[ + { + "internalType":"uint96", + "name":"securityDeposit", + "type":"uint96" + }, + { + "internalType":"address", + "name":"multisig", + "type":"address" + }, + { + "internalType":"bytes32", + "name":"configHash", + "type":"bytes32" + }, + { + "internalType":"uint32", + "name":"threshold", + "type":"uint32" + }, + { + "internalType":"uint32", + "name":"maxNumAgentInstances", + "type":"uint32" + }, + { + "internalType":"uint32", + "name":"numAgentInstances", + "type":"uint32" + }, + { + "internalType":"enum ServiceRegistry.ServiceState", + "name":"state", + "type":"uint8" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"name", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"owner", + "outputs":[ + { + "internalType":"address", + "name":"", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"ownerOf", + "outputs":[ + { + "internalType":"address", + "name":"owner", + "type":"address" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + }, + { + "internalType":"address[]", + "name":"agentInstances", + "type":"address[]" + }, + { + "internalType":"uint32[]", + "name":"agentIds", + "type":"uint32[]" + } + ], + "name":"registerAgents", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + } + ], + "stateMutability":"payable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"safeTransferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + }, + { + "internalType":"bytes", + "name":"data", + "type":"bytes" + } + ], + "name":"safeTransferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"bool", + "name":"approved", + "type":"bool" + } + ], + "name":"setApprovalForAll", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"string", + "name":"bURI", + "type":"string" + } + ], + "name":"setBaseURI", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address[]", + "name":"agentInstances", + "type":"address[]" + }, + { + "internalType":"uint96[]", + "name":"amounts", + "type":"uint96[]" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"slash", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"slashedFunds", + "outputs":[ + { + "internalType":"uint96", + "name":"", + "type":"uint96" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"bytes4", + "name":"interfaceId", + "type":"bytes4" + } + ], + "name":"supportsInterface", + "outputs":[ + { + "internalType":"bool", + "name":"", + "type":"bool" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"symbol", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"serviceOwner", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"terminate", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + }, + { + "internalType":"uint256", + "name":"refund", + "type":"uint256" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"tokenByIndex", + "outputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"uint256", + "name":"unitId", + "type":"uint256" + } + ], + "name":"tokenURI", + "outputs":[ + { + "internalType":"string", + "name":"", + "type":"string" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + + ], + "name":"totalSupply", + "outputs":[ + { + "internalType":"uint256", + "name":"", + "type":"uint256" + } + ], + "stateMutability":"view", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"from", + "type":"address" + }, + { + "internalType":"address", + "name":"to", + "type":"address" + }, + { + "internalType":"uint256", + "name":"id", + "type":"uint256" + } + ], + "name":"transferFrom", + "outputs":[ + + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"operator", + "type":"address" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"unbond", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + }, + { + "internalType":"uint256", + "name":"refund", + "type":"uint256" + } + ], + "stateMutability":"nonpayable", + "type":"function" + }, + { + "inputs":[ + { + "internalType":"address", + "name":"serviceOwner", + "type":"address" + }, + { + "internalType":"bytes32", + "name":"configHash", + "type":"bytes32" + }, + { + "internalType":"uint32[]", + "name":"agentIds", + "type":"uint32[]" + }, + { + "components":[ + { + "internalType":"uint32", + "name":"slots", + "type":"uint32" + }, + { + "internalType":"uint96", + "name":"bond", + "type":"uint96" + } + ], + "internalType":"struct AgentParams[]", + "name":"agentParams", + "type":"tuple[]" + }, + { + "internalType":"uint32", + "name":"threshold", + "type":"uint32" + }, + { + "internalType":"uint256", + "name":"serviceId", + "type":"uint256" + } + ], + "name":"update", + "outputs":[ + { + "internalType":"bool", + "name":"success", + "type":"bool" + } + ], + "stateMutability":"nonpayable", + "type":"function" + } +] \ No newline at end of file diff --git a/packages/dvilela/contracts/service_registry/contract.py b/packages/dvilela/contracts/service_registry/contract.py index 323623d..e0ecd1e 100644 --- a/packages/dvilela/contracts/service_registry/contract.py +++ b/packages/dvilela/contracts/service_registry/contract.py @@ -20,6 +20,7 @@ """This module contains the class to connect to the wveolas contract.""" import logging from typing import Optional +from web3.types import BlockIdentifier from aea.common import JSONLike from aea.configurations.base import PublicId @@ -41,19 +42,54 @@ class ServiceRegistryContract(Contract): contract_id = PUBLIC_ID @classmethod - def get_create_events( - cls, ledger_api: EthereumApi, contract_address: str, from_block: int + def get_events( + cls, + ledger_api: EthereumApi, + contract_address: str, + event_name: str, + from_block: BlockIdentifier = "earliest", + to_block: BlockIdentifier = "latest", ) -> Optional[JSONLike]: - """Get CreateService events.""" + """Get events.""" contract_instance = cls.get_instance(ledger_api, contract_address) - create_service_events = ledger_api.contract_method_call( + # Avoid parsing too many blocks at a time. This might take too long and + # the connection could time out. + MAX_BLOCKS = 300000 + + to_block = ( + ledger_api.api.eth.get_block_number() - 1 if to_block == "latest" else to_block + ) + ranges = list(range(from_block, to_block, MAX_BLOCKS)) + [to_block] + + # Event loop + event = getattr(contract_instance.events, event_name) + events = [] + for i in range(len(ranges) - 1): + from_block = ranges[i] + to_block = ranges[i + 1] + events += event.create_filter( + fromBlock=from_block, # exclusive + toBlock=to_block, # inclusive + ).get_all_entries() # limited to 10k entries for now: https://github.com/valory-xyz/contribution-service/issues/13 + + return dict( + events=events, + last_block=int(to_block), + ) + + + @classmethod + def get_token_uri( + cls, ledger_api: EthereumApi, contract_address: str, unit_id: int + ) -> Optional[JSONLike]: + """Get events.""" + contract_instance = cls.get_instance(ledger_api, contract_address) + + result = ledger_api.contract_method_call( contract_instance=contract_instance, - method_name="getVotes", - account=owner_address, + method_name="tokenURI", + unitId=unit_id, ) - return { - "last_parsed_block": last_parsed_block, - "create_service_events": create_service_events, - } + return {"result": result} \ No newline at end of file diff --git a/packages/dvilela/skills/tsunami_abci/behaviours.py b/packages/dvilela/skills/tsunami_abci/behaviours.py index f1ecac5..2921990 100644 --- a/packages/dvilela/skills/tsunami_abci/behaviours.py +++ b/packages/dvilela/skills/tsunami_abci/behaviours.py @@ -20,8 +20,9 @@ """This package contains round behaviours of TsunamiAbciApp.""" from abc import ABC -from typing import Generator, Set, Type, cast, Optional +from typing import Generator, Set, Type, cast, Optional, List, Tuple, Dict import json +from twitter_text import parse_tweet from packages.dvilela.skills.tsunami_abci.models import Params from packages.dvilela.skills.tsunami_abci.rounds import ( PrepareTweetsPayload, @@ -42,6 +43,10 @@ from packages.valory.connections.farcaster.connection import ( PUBLIC_ID as FARCASTER_CONNECTION_PUBLIC_ID, ) +from packages.dvilela.connections.llama.connection import ( + PUBLIC_ID as LLAMA_CONNECTION_PUBLIC_ID, +) + from packages.valory.connections.twitter.connection import ( PUBLIC_ID as TWITTER_CONNECTION_PUBLIC_ID, ) @@ -50,6 +55,15 @@ TwitterDialogue, TwitterDialogues, ) +from packages.dvilela.skills.tsunami_abci.prompts import SYSTEM_PROMPTS, USER_PROMPT_TEMPLATES +from packages.valory.protocols.contract_api import ContractApiMessage +from packages.dvilela.contracts.service_registry.contract import ServiceRegistryContract +import random + + +MAX_TWEET_ATTEMPTS = 5 +MAX_TWEET_CHARS = 280 +HTTP_OK = 200 class TsunamiBaseBehaviour(BaseBehaviour, ABC): @@ -65,70 +79,6 @@ def params(self) -> Params: """Return the params.""" return cast(Params, super().params) - -class PrepareTweetsBehaviour(TsunamiBaseBehaviour): - """PrepareTweetsBehaviour""" - - matching_round: Type[AbstractRound] = PrepareTweetsRound - - def async_act(self) -> Generator: - """Do the act, supporting asynchronous execution.""" - - with self.context.benchmark_tool.measure(self.behaviour_id).local(): - sender = self.context.agent_address - payload = PrepareTweetsPayload(sender=sender, content=...) - - with self.context.benchmark_tool.measure(self.behaviour_id).consensus(): - yield from self.send_a2a_transaction(payload) - yield from self.wait_until_round_end() - - self.set_done() - - - def get_events(self) -> Generator: - """Get registries events""" - - # Loop chains - - # Loop registries - - -class PublishTweetsBehaviour(TsunamiBaseBehaviour): - """PublishTweetsBehaviour""" - - matching_round: Type[AbstractRound] = PublishTweetsRound - - def async_act(self) -> Generator: - """Do the act, supporting asynchronous execution.""" - - with self.context.benchmark_tool.measure(self.behaviour_id).local(): - - tweets = self.synchronized_data.tweets - - # Publish tweets - for tweet in tweets: - - if not tweet["twitter"]: - tweet["twitter"] = yield from self.publish_tweet(tweet["text"]) - - if not tweet["farcaster"]: - tweet["farcaster"] = yield from self.publish_cast(tweet["text"]) - - # Remove published tweets - tweets = [t for t in tweets if t["twitter"] and t["farcaster"]] - - payload = PublishTweetsPayload( - sender=self.context.agent_address, - tweets=tweets - ) - - with self.context.benchmark_tool.measure(self.behaviour_id).consensus(): - yield from self.send_a2a_transaction(payload) - yield from self.wait_until_round_end() - - self.set_done() - - def publish_tweet(self, text) -> Generator: """Publish tweet""" @@ -168,7 +118,7 @@ def _create_tweet( text: str, credentials: dict, ) -> Generator[None, None, TwitterMessage]: - """Send an http request message from the skill context.""" + """Send a request message from the skill context.""" twitter_dialogues = cast(TwitterDialogues, self.context.twitter_dialogues) twitter_message, twitter_dialogue = twitter_dialogues.create( counterparty=str(TWITTER_CONNECTION_PUBLIC_ID), @@ -185,45 +135,67 @@ def _create_tweet( return response + def _do_twitter_request( + self, + message: TwitterMessage, + dialogue: TwitterDialogue, + timeout: Optional[float] = None, + ) -> Generator[None, None, TwitterMessage]: + """Do a request and wait the response, asynchronously.""" + + self.context.outbox.put_message(message=message) + request_nonce = self._get_request_nonce_from_dialogue(dialogue) + cast(Requests, self.context.requests).request_id_to_callback[ + request_nonce + ] = self.get_callback_request() + response = yield from self.wait_for_message(timeout=timeout) + return response + + def _create_cast( self, text: str, ) -> Generator[None, None, SrrMessage]: - """Send an http request message from the skill context.""" + """Send a request message from the skill context.""" srr_dialogues = cast(SrrDialogues, self.context.srr_dialogues) - farcaster_message, srr_dialogue = srr_dialogues.create( + srr_message, srr_dialogue = srr_dialogues.create( counterparty=str(FARCASTER_CONNECTION_PUBLIC_ID), performative=SrrMessage.Performative.REQUEST, payload=json.dumps( {"method": "post_cast", "args": {"text": text}} ), ) - farcaster_message = cast(SrrMessage, farcaster_message) + srr_message = cast(SrrMessage, srr_message) srr_dialogue = cast(SrrDialogue, srr_dialogue) - response = yield from self._do_farcaster_request( - farcaster_message, srr_dialogue + response = yield from self._do_srr_request( + srr_message, srr_dialogue ) return response - def _do_twitter_request( + def _call_llama( self, - message: TwitterMessage, - dialogue: TwitterDialogue, - timeout: Optional[float] = None, - ) -> Generator[None, None, TwitterMessage]: - """Do a request and wait the response, asynchronously.""" - - self.context.outbox.put_message(message=message) - request_nonce = self._get_request_nonce_from_dialogue(dialogue) - cast(Requests, self.context.requests).request_id_to_callback[ - request_nonce - ] = self.get_callback_request() - response = yield from self.wait_for_message(timeout=timeout) + system_prompt: str, + user_prompt: str, + ) -> Generator[None, None, SrrMessage]: + """Send a request message from the skill context.""" + srr_dialogues = cast(SrrDialogues, self.context.srr_dialogues) + srr_message, srr_dialogue = srr_dialogues.create( + counterparty=str(LLAMA_CONNECTION_PUBLIC_ID), + performative=SrrMessage.Performative.REQUEST, + payload=json.dumps( + {"system": system_prompt, "user": user_prompt} + ), + ) + srr_message = cast(SrrMessage, srr_message) + srr_dialogue = cast(SrrDialogue, srr_dialogue) + response = yield from self._do_srr_request( + srr_message, srr_dialogue + ) return response - def _do_farcaster_request( + def _do_srr_request( self, message: SrrMessage, dialogue: SrrDialogue, @@ -240,6 +212,224 @@ def _do_farcaster_request( return response +class PrepareTweetsBehaviour(TsunamiBaseBehaviour): + """PrepareTweetsBehaviour""" + + matching_round: Type[AbstractRound] = PrepareTweetsRound + + def async_act(self) -> Generator: + """Do the act, supporting asynchronous execution.""" + + with self.context.benchmark_tool.measure(self.behaviour_id).local(): + sender = self.context.agent_address + payload = PrepareTweetsPayload(sender=sender, content=...) + + with self.context.benchmark_tool.measure(self.behaviour_id).consensus(): + yield from self.send_a2a_transaction(payload) + yield from self.wait_until_round_end() + + self.set_done() + + + def build_tweets(self) -> Generator[None, None, List[str]]: + """Build tweets""" + + # TODO: Loop chains + # TODO: Loop registries + # TODO: common last block for every call + + # Get from_block + from_block = 0 + + # Get events + contract_id = str(ServiceRegistryContract.contract_id) + contract_address = self.params.service_registry_address_ethereum + + events = yield from self.get_events( + contract_id, + contract_address, + "CreateService", + from_block + ) + + tweets = [] + for event in events: + + self.context.logger.info(f"Processing event {event}") + + unit_id = event.args.serviceId # TODO: change for different events + + # Get token URI + uri = yield from self.get_token_uri( + contract_id, + contract_address, + unit_id + ) + + # Get unit data + self.context.logger.info(f"Getting token data...") + response = yield from self.get_http_response( + method="GET", url=uri + ) + + if response.status_code != HTTP_OK: + self.context.logger.info(f"Failed to download token data: {response.status_code}") + continue # TODO: retries + + response_json = json.loads(response.body) + self.context.logger.info(f"Got token data: {response_json}") + + unit_name = response_json["name"] + unit_description = response_json["description"] + + unit_type="service", + + user_prompt = USER_PROMPT_TEMPLATES[unit_type].format( + { + f"{unit_type}_id": unit_id, + "chain_name": "Ethereum" # TODO: dynamic + } + ) + + user_prompt += f"The {unit_type}'s name is {unit_name}. Its description is '{unit_description}'" + + tweet = yield from self.build_tweet( + user_prompt + ) + + if tweet: + tweets.append(tweet) + + return tweets + + + def get_events(self, contract_id, contract_address, event, from_block) -> Generator[None, None, Tuple[Optional[List], Optional[int]]]: + """Get registries events""" + + self.context.logger.info( + f"Retrieving {event} events later than block {from_block} on contract {contract_id}::{contract_address}" + ) + + contract_api_msg = yield from self.get_contract_api_response( + performative=ContractApiMessage.Performative.GET_STATE, # type: ignore + contract_address=contract_address, + contract_id=contract_id, + contract_callable="get_events", + event_name=event, + from_block=from_block, + ) + + if contract_api_msg.performative != ContractApiMessage.Performative.STATE: + self.context.logger.info( + f"Error retrieving the events [{contract_api_msg.performative}]" + ) + return None + + events = cast(dict, contract_api_msg.state.body)["events"] + last_block = cast(dict, contract_api_msg.state.body)["last_block"] + + self.context.logger.info( + f"Got {len(events)} events until block {last_block}" + ) + + return events, last_block + + + def get_token_uri(self, contract_id, contract_address, unit_id) -> Generator[None, None, Optional[str]]: + """Get registries events""" + + self.context.logger.info( + f"Retrieving uri for unit_id {unit_id} on contract {contract_id}::{contract_address}" + ) + + contract_api_msg = yield from self.get_contract_api_response( + performative=ContractApiMessage.Performative.GET_STATE, # type: ignore + contract_address=contract_address, + contract_id=contract_id, + contract_callable="get_token_uri", + unit_id=unit_id, + ) + + if contract_api_msg.performative != ContractApiMessage.Performative.STATE: + self.context.logger.info( + f"Error retrieving the events [{contract_api_msg.performative}]" + ) + return None + + uri = cast(dict, contract_api_msg.state.body)["result"] + + self.context.logger.info( + f"Got uri: {uri}" + ) + + return uri + + + def build_tweet(self, user_prompt: str) -> Generator[None, None, Optional[str]]: + """Build tweet""" + + # Randomly select a personality + # TODO: this only works for a single agent + system_prompt = random.choice(SYSTEM_PROMPTS) + + attempts = 0 + tweet = None + while attempts < MAX_TWEET_ATTEMPTS: + + # Call llama conection + response = yield from self._call_llama(system_prompt=system_prompt, user_prompt=user_prompt) + tweet_attempt = json.loads(response.payload)["response"] + + # Check tweet length + tweet_len = parse_tweet(tweet_attempt).asdict()["weightedLength"] + if tweet_len < MAX_TWEET_CHARS: + tweet = tweet_attempt + break + + attempts += 1 + + return tweet + + +class PublishTweetsBehaviour(TsunamiBaseBehaviour): + """PublishTweetsBehaviour""" + + matching_round: Type[AbstractRound] = PublishTweetsRound + + def async_act(self) -> Generator: + """Do the act, supporting asynchronous execution.""" + + with self.context.benchmark_tool.measure(self.behaviour_id).local(): + + tweets = self.synchronized_data.tweets + + # Publish tweets + for tweet in tweets: + + if self.params.publish_twitter and not tweet["twitter_published"]: + tweet["twitter_published"] = yield from self.publish_tweet(tweet["text"])["success"] + + if self.params.publish_farcaster and not tweet["farcaster_published"]: + tweet["farcaster_published"] = yield from self.publish_cast(tweet["text"])["success"] + + # Remove published tweets + tweets = [t for t in tweets if t["twitter"] and t["farcaster"]] + + payload = PublishTweetsPayload( + sender=self.context.agent_address, + tweets=tweets + ) + + with self.context.benchmark_tool.measure(self.behaviour_id).consensus(): + yield from self.send_a2a_transaction(payload) + yield from self.wait_until_round_end() + + self.set_done() + + + + + class TsunamiRoundBehaviour(AbstractRoundBehaviour): """TsunamiRoundBehaviour""" diff --git a/packages/dvilela/skills/tsunami_abci/models.py b/packages/dvilela/skills/tsunami_abci/models.py index cd07985..3afc893 100644 --- a/packages/dvilela/skills/tsunami_abci/models.py +++ b/packages/dvilela/skills/tsunami_abci/models.py @@ -19,6 +19,8 @@ """This module contains the shared state for the abci skill of TsunamiAbciApp.""" +from typing import Any + from packages.dvilela.skills.tsunami_abci.rounds import TsunamiAbciApp from packages.valory.skills.abstract_round_abci.models import BaseParams from packages.valory.skills.abstract_round_abci.models import ( @@ -36,6 +38,16 @@ class SharedState(BaseSharedState): abci_app_cls = TsunamiAbciApp -Params = BaseParams Requests = BaseRequests BenchmarkTool = BaseBenchmarkTool + + +class Params(BaseParams): + """Parameters.""" + + def __init__(self, *args: Any, **kwargs: Any) -> None: + """Initialize the parameters object.""" + self.publish_twitter = self._ensure("publish_twitter", kwargs, bool) + self.publish_farcaster = self._ensure("publish_farcaster", kwargs, bool) + self.service_registry_address_ethereum = self._ensure("service_registry_address_ethereum", kwargs, str) + super().__init__(*args, **kwargs) \ No newline at end of file diff --git a/packages/dvilela/skills/tsunami_abci/prompts.py b/packages/dvilela/skills/tsunami_abci/prompts.py new file mode 100644 index 0000000..05c8f67 --- /dev/null +++ b/packages/dvilela/skills/tsunami_abci/prompts.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2024 David Vilela Freire +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ +"""Prompts""" + +SYSTEM_PROMPT_PIRATE = """ +You are an old Twitter influencer who used to be a drunk pirate. + +You announce new events in the blockchain space using your pirate language and words +related to the sea, fish and rum. + +Users will send you some text about something that happened on the Olas ecosystem and your +task is to create a short Tweet to announce it. +Keep it short, under 250 characters. +""" + +SYSTEM_PROMPT_OLAD = """ +You are an Olad, a sophisticated, elegant, intellectual Twitter influencer from the 18th +century who uses a monocle, top hat and expensive silk three-piece suits. + +You announce new events in the Olas blockchain ecosystem using well-mannered Victorian language, +sometimes referencing the way you dress and Olads, your colleagues. + +Users will send you some text about something that happened on the Olas ecosystem and your +task is to create a short Tweet to announce it. +Keep it short, under 250 characters. +""" + +SYSTEM_PROMPT_TECHIE = """ +You are a sassy, grumpy techie Twitter influencer who writes about web3 protocols. + +You announce new events in the blockchain space and you are really hyped up about it, +usually making sci-fi movie analogies like Star Trek, Dune or Star Wars. + +Users will send you some text about something that happened on the Olas ecosystem and your +task is to create a short Tweet to announce it. +Keep it short, under 250 characters. +""" + +USER_PROMPT_SERVICE = "A new service with id {service_id} has been minted on the Olas protocol on {chain_name}" +USER_PROMPT_AGENT = "A new agent with id {agent_id} has been minted on the Olas protocol on {chain_name}" +USER_PROMPT_COMPONENT = "A new component with id {component_id} has been minted on the Olas protocol on {chain_name}" + +SYSTEM_PROMPTS = [SYSTEM_PROMPT_PIRATE, SYSTEM_PROMPT_OLAD, SYSTEM_PROMPT_TECHIE] + +USER_PROMPT_TEMPLATES = { + "service": USER_PROMPT_SERVICE, + "agent": USER_PROMPT_AGENT, + "component": USER_PROMPT_COMPONENT +} diff --git a/packages/dvilela/skills/tsunami_abci/skill.yaml b/packages/dvilela/skills/tsunami_abci/skill.yaml index 08f53ba..08a5a84 100644 --- a/packages/dvilela/skills/tsunami_abci/skill.yaml +++ b/packages/dvilela/skills/tsunami_abci/skill.yaml @@ -126,6 +126,9 @@ models: tendermint_url: http://localhost:26657 tx_timeout: 10.0 validate_timeout: 1205 + publish_twitter: true + publish_farcaster: true + service_registry_address_ethereum: '0x48b6af7B12C71f09e2fC8aF4855De4Ff54e775cA' class_name: Params requests: args: {} @@ -139,6 +142,8 @@ models: tendermint_dialogues: args: {} class_name: TendermintDialogues -dependencies: {} +dependencies: + twitter_text_parser: + version: ==3.0.0 is_abstract: true customs: [] diff --git a/poetry.lock b/poetry.lock index 3130f5e..9eaf808 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1989,6 +1989,17 @@ notebook = ["ipywidgets (>=6)"] slack = ["slack-sdk"] telegram = ["requests"] +[[package]] +name = "twitter-text-parser" +version = "3.0.0" +description = "A library to parse or validate Twitter texts properly" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "twitter_text_parser-3.0.0-py3-none-any.whl", hash = "sha256:b36bd22e147db2234e79c73b021f10c3073e8c54f22b68c31696239b6917cdd3"}, + {file = "twitter_text_parser-3.0.0.tar.gz", hash = "sha256:9426e4fb9393c8c1adfb36ff5d91495ff4524782e85f80748f6ae0bc1efffcda"}, +] + [[package]] name = "typing-extensions" version = "4.9.0" @@ -2264,4 +2275,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "<4.0,>=3.8" -content-hash = "096411aa7aa3f52fe92649bd1c0eb469788510c521df6b587f7f93cc8cf22c8e" +content-hash = "59c382ed108ffcb68b97ff1ce368690545a75dbbbcff99b0e3d0c2470e957202" diff --git a/pyproject.toml b/pyproject.toml index b0e107e..01fbc91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,3 +26,4 @@ isort = "^5.13.2" peewee = "3.17.1" llama-cpp-python = "0.2.56" huggingface-hub = "0.21.4" +twitter-text-parser = "3.0.0"