self_agent_sdk/
constants.rs1use alloy::primitives::Address;
6use alloy::sol;
7use std::str::FromStr;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum NetworkName {
12 Mainnet,
13 Testnet,
14}
15
16#[derive(Debug, Clone)]
18pub struct NetworkConfig {
19 pub registry_address: Address,
20 pub rpc_url: &'static str,
21}
22
23pub fn network_config(network: NetworkName) -> NetworkConfig {
25 match network {
26 NetworkName::Mainnet => NetworkConfig {
27 registry_address: Address::from_str("0xaC3DF9ABf80d0F5c020C06B04Cced27763355944")
28 .unwrap(),
29 rpc_url: "https://forno.celo.org",
30 },
31 NetworkName::Testnet => NetworkConfig {
32 registry_address: Address::from_str("0x043DaCac8b0771DD5b444bCC88f2f8BBDBEdd379")
33 .unwrap(),
34 rpc_url: "https://forno.celo-sepolia.celo-testnet.org",
35 },
36 }
37}
38
39pub const DEFAULT_NETWORK: NetworkName = NetworkName::Mainnet;
41
42pub const DEFAULT_MAX_AGE_MS: u64 = 5 * 60 * 1000;
44
45pub const DEFAULT_CACHE_TTL_MS: u64 = 60_000;
47
48pub mod headers {
50 pub const ADDRESS: &str = "x-self-agent-address";
52 pub const SIGNATURE: &str = "x-self-agent-signature";
54 pub const TIMESTAMP: &str = "x-self-agent-timestamp";
56 pub const KEYTYPE: &str = "x-self-agent-keytype";
58 pub const KEY: &str = "x-self-agent-key";
60}
61
62sol! {
64 #[sol(rpc)]
65 interface IAgentRegistry {
66 function isVerifiedAgent(bytes32 agentPubKey) external view returns (bool);
67 function getAgentId(bytes32 agentPubKey) external view returns (uint256);
68 function hasHumanProof(uint256 agentId) external view returns (bool);
69 function getHumanNullifier(uint256 agentId) external view returns (uint256);
70 function getAgentCountForHuman(uint256 nullifier) external view returns (uint256);
71 function sameHuman(uint256 agentIdA, uint256 agentIdB) external view returns (bool);
72 function getProofProvider(uint256 agentId) external view returns (address);
73 function isProofFresh(uint256 agentId) external view returns (bool);
74 function selfProofProvider() external view returns (address);
75 function ownerOf(uint256 tokenId) external view returns (address);
76
77 struct AgentCredentials {
78 string issuingState;
79 string[] name;
80 string idNumber;
81 string nationality;
82 string dateOfBirth;
83 string gender;
84 string expiryDate;
85 uint256 olderThan;
86 bool[3] ofac;
87 }
88 function getAgentCredentials(uint256 agentId) external view returns (AgentCredentials);
89
90 function getAgentMetadata(uint256 agentId) external view returns (string);
92 function updateAgentMetadata(uint256 agentId, string metadata) external;
93 function agentRegisteredAt(uint256 agentId) external view returns (uint256);
94 function proofExpiresAt(uint256 agentId) external view returns (uint256);
96 function agentNonces(address agent) external view returns (uint256);
98 }
99}
100
101sol! {
103 #[sol(rpc)]
104 interface IHumanProofProvider {
105 function providerName() external view returns (string);
106 function verificationStrength() external view returns (uint8);
107 }
108}