Skip to main content

libid_contracts/bindings/
identity.rs

1//! Bindings for the identity-names stack (`solidity/contracts/identity/`):
2//! `IdentityNames`.
3
4/// Bindings for `identity/IdentityNames.sol`.
5///
6/// `Rules` mirrors `HandleNormalizer.Rules` — the normalization rules the
7/// contract stores per platform. Platform ids are `keccak256` of the
8/// platform's domain string.
9#[allow(clippy::too_many_arguments, unused_attributes)]
10mod names_inner {
11    use alloy::sol;
12
13    sol! {
14        #[sol(rpc)]
15        interface IdentityNames {
16            #[derive(Debug, serde::Serialize, serde::Deserialize)]
17            struct Rules {
18                uint16 maxLength;
19                bool stripLeadingAt;
20                bool isEmail;
21                bool allowUnderscore;
22                bool allowHyphen;
23            }
24
25            function initialize(address owner_) external;
26
27            /// The keyspace half: what a handle on this platform means. It
28            /// does not vary by proof version — two versions normalizing
29            /// differently would put one handle on two nodes.
30            function setPlatform(bytes32 platformId, Rules calldata rules) external;
31
32            /// Which contract holds the Supported Version Set. Registering a
33            /// version is that contract's call, not this one's.
34            function setProofVerifier(address verifier) external;
35            function proofVerifier() external view returns (address);
36
37            /// The one write. The contract does not know what `payload` is:
38            /// it names a platform and this chain's verifier version for it,
39            /// and the Proof Verifier routes the bytes to the one contract
40            /// that decodes them. The value attached must equal `quoteClaim`
41            /// for the same pair exactly.
42            function claim(bytes32 platformId, uint16 verifierVersion, bytes calldata payload, bool publishName) external payable;
43            function quoteClaim(bytes32 platformId, uint16 verifierVersion) external view returns (uint256);
44            function digestSpent(bytes32 digest) external view returns (bool);
45            function unpublish(bytes32 platformId) external;
46            function resolveId(bytes32 platformId, string calldata userId) external view returns (address);
47            function resolveHandle(bytes32 platformId, string calldata handle) external view returns (address);
48            function resolvePair(bytes32 platformId, string calldata handle, string calldata userId) external view returns (address);
49            function reverseOf(address wallet, bytes32 platformId) external view returns (string memory);
50            function primaryOf(address wallet, bytes32 platformId) external view returns (string memory);
51
52            /// Carries the ceremony version that proved the binding -- logged,
53            /// never stored, because nothing on chain acts on it and an
54            /// operator asking which bindings a version touched reads the log.
55            /// What the ceremony authenticated beyond the binding rides on
56            /// `CeremonyBound` instead.
57            event IdentityBound(
58                address indexed owner,
59                bytes32 indexed idNode,
60                bytes32 indexed handleNode,
61                bytes32 platformId,
62                string userId,
63                string handle,
64                uint64 observedAt,
65                bool published,
66                uint16 ceremonyVersion
67            );
68            event HandleRetired(bytes32 indexed platformId, bytes32 indexed handleNode, address indexed owner);
69            event PlatformConfigured(bytes32 indexed platformId);
70            event ProofVerifierConfigured(address verifier);
71            event NameUnpublished(address indexed owner, bytes32 indexed platformId);
72            /// The OAuth client a ceremony authenticated. Nothing stores it, so
73            /// "which application produced these bindings" is answerable only
74            /// from this log.
75            event CeremonyBound(
76                bytes32 indexed authorizationDigest,
77                address indexed owner,
78                bytes32 indexed platformId,
79                bytes clientIdentifier
80            );
81        }
82    }
83}
84
85pub use names_inner::IdentityNames;