Skip to content

Commit de28e81

Browse files
committed
feat(excubiae): add trait mechanism
1 parent 23f080e commit de28e81

16 files changed

+84
-0
lines changed

packages/excubiae/contracts/Excubia.sol

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ abstract contract Excubia is IExcubia, Ownable(msg.sender) {
2121
_;
2222
}
2323

24+
/// @inheritdoc IExcubia
25+
function trait() external pure virtual returns (string memory) {}
26+
2427
/// @inheritdoc IExcubia
2528
function setGate(address _gate) public virtual onlyOwner {
2629
if (_gate == address(0)) revert ZeroAddress();

packages/excubiae/contracts/IExcubia.sol

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ interface IExcubia {
2828
/// @notice Error thrown when the passerby has already passed the gate.
2929
error AlreadyPassed();
3030

31+
/// @notice Gets the trait of the Excubia contract.
32+
/// @return The specific trait of the Excubia contract (e.g., SemaphoreExcubia has trait `Semaphore`).
33+
function trait() external pure returns (string memory);
34+
3135
/// @notice Sets the gate address.
3236
/// @dev Only the owner can set the destination gate address.
3337
/// @param _gate The address of the contract to be set as the gate.

packages/excubiae/contracts/extensions/EASExcubia.sol

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ contract EASExcubia is Excubia {
4646
SCHEMA = _schema;
4747
}
4848

49+
/// @notice The trait of the Excubia contract.
50+
function trait() external pure override returns (string memory) {
51+
return "EAS";
52+
}
53+
4954
/// @notice Internal function to handle the passing logic with check.
5055
/// @dev Calls the parent `_pass` function and stores the attestation to avoid pass the gate twice.
5156
/// @param passerby The address of the entity attempting to pass the gate.

packages/excubiae/contracts/extensions/ERC721Excubia.sol

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ contract ERC721Excubia is Excubia {
2727
NFT = IERC721(_erc721);
2828
}
2929

30+
/// @notice The trait of the Excubia contract.
31+
function trait() external pure override returns (string memory) {
32+
return "ERC721";
33+
}
34+
3035
/// @notice Internal function to handle the passing logic with check.
3136
/// @dev Calls the parent `_pass` function and stores the NFT ID to avoid passing the gate twice.
3237
/// @param passerby The address of the entity attempting to pass the gate.

packages/excubiae/contracts/extensions/FreeForAllExcubia.sol

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ contract FreeForAllExcubia is Excubia {
1414
/// @notice Mapping to track already passed passersby.
1515
mapping(address => bool) public passedPassersby;
1616

17+
/// @notice The trait of the Excubia contract.
18+
function trait() external pure override returns (string memory) {
19+
return "FreeForAll";
20+
}
21+
1722
/// @notice Internal function to handle the gate passing logic.
1823
/// @dev This function calls the parent `_pass` function and then tracks the passerby.
1924
/// @param passerby The address of the entity passing the gate.

packages/excubiae/contracts/extensions/GitcoinPassportExcubia.sol

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ contract GitcoinPassportExcubia is Excubia {
4141
THRESHOLD_SCORE = _thresholdScore;
4242
}
4343

44+
/// @notice The trait of the Excubia contract.
45+
function trait() external pure override returns (string memory) {
46+
return "GitcoinPassport";
47+
}
48+
4449
/// @notice Internal function to handle the passing logic with check.
4550
/// @dev Calls the parent `_pass` function and stores the user to avoid passing the gate twice.
4651
/// @param passerby The address of the entity attempting to pass the gate.

packages/excubiae/contracts/extensions/HatsExcubia.sol

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ contract HatsExcubia is Excubia {
3838
}
3939
}
4040

41+
/// @notice The trait of the Excubia contract.
42+
function trait() external pure override returns (string memory) {
43+
return "Hats";
44+
}
45+
4146
/// @notice Internal function to handle the passing logic with check.
4247
/// @dev Calls the parent `_pass` function and stores the user to avoid passing the gate twice.
4348
/// @param passerby The address of the entity attempting to pass the gate.

packages/excubiae/contracts/extensions/SemaphoreExcubia.sol

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ contract SemaphoreExcubia is Excubia {
4444
GROUP_ID = _groupId;
4545
}
4646

47+
/// @notice The trait of the Excubia contract.
48+
function trait() external pure override returns (string memory) {
49+
return "Semaphore";
50+
}
51+
4752
/// @notice Internal function to handle the passing logic with check.
4853
/// @dev Calls the parent `_pass` function and stores the nullifier to avoid passing the gate twice.
4954
/// @param passerby The address of the entity attempting to pass the gate.

packages/excubiae/contracts/extensions/ZKEdDSAEventTicketPCDExcubia.sol

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ contract ZKEdDSAEventTicketPCDExcubia is Excubia {
5151
VALID_SIGNER_2 = _validSigner2;
5252
}
5353

54+
/// @notice The trait of the Excubia contract.
55+
function trait() external pure override returns (string memory) {
56+
return "ZKEdDSAEventTicketPCD";
57+
}
58+
5459
/// @notice Internal function to handle the passing logic with check.
5560
/// @dev Calls the parent `_pass` function and stores the ticket ID to avoid passing the gate twice.
5661
/// @param passerby The address of the entity attempting to pass the gate.

packages/excubiae/test/EASExcubia.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ describe("EASExcubia", function () {
6060
})
6161
})
6262

63+
describe("trait()", function () {
64+
it("should return the trait of the Excubia contract", async () => {
65+
expect(await easExcubia.trait()).to.be.equal("EAS")
66+
})
67+
})
68+
6369
describe("setGate()", function () {
6470
it("should fail to set the gate when the caller is not the owner", async () => {
6571
const [, notOwnerSigner] = await ethers.getSigners()

packages/excubiae/test/ERC721Excubia.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ describe("ERC721Excubia", function () {
6161
})
6262
})
6363

64+
describe("trait()", function () {
65+
it("should return the trait of the Excubia contract", async () => {
66+
expect(await erc721Excubia.trait()).to.be.equal("ERC721")
67+
})
68+
})
69+
6470
describe("setGate()", function () {
6571
it("should fail to set the gate when the caller is not the owner", async () => {
6672
const [, notOwnerSigner] = await ethers.getSigners()

packages/excubiae/test/FreeForAllExcubia.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ describe("FreeForAllExcubia", function () {
2828
})
2929
})
3030

31+
describe("trait()", function () {
32+
it("should return the trait of the Excubia contract", async () => {
33+
expect(await freeForAllExcubia.trait()).to.be.equal("FreeForAll")
34+
})
35+
})
36+
3137
describe("setGate()", function () {
3238
it("should fail to set the gate when the caller is not the owner", async () => {
3339
const [, notOwnerSigner] = await ethers.getSigners()

packages/excubiae/test/GitcoinPassportExcubia.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ describe("GitcoinPassportExcubia", function () {
7676
})
7777
})
7878

79+
describe("trait()", function () {
80+
it("should return the trait of the Excubia contract", async () => {
81+
expect(await gitcoinPassportExcubia.trait()).to.be.equal("GitcoinPassport")
82+
})
83+
})
84+
7985
describe("setGate()", function () {
8086
it("should fail to set the gate when the caller is not the owner", async () => {
8187
const [, notOwnerSigner] = await ethers.getSigners()

packages/excubiae/test/HatsExcubia.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ describe("HatsExcubia", function () {
6464
})
6565
})
6666

67+
describe("trait()", function () {
68+
it("should return the trait of the Excubia contract", async () => {
69+
expect(await hatsExcubia.trait()).to.be.equal("Hats")
70+
})
71+
})
72+
6773
describe("setGate()", function () {
6874
it("should fail to set the gate when the caller is not the owner", async () => {
6975
const [, notOwnerSigner] = await ethers.getSigners()

packages/excubiae/test/SemaphoreExcubia.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ describe("SemaphoreExcubia", function () {
113113
})
114114
})
115115

116+
describe("trait()", function () {
117+
it("should return the trait of the Excubia contract", async () => {
118+
expect(await semaphoreExcubia.trait()).to.be.equal("Semaphore")
119+
})
120+
})
121+
116122
describe("setGate()", function () {
117123
it("should fail to set the gate when the caller is not the owner", async () => {
118124
const [, notOwnerSigner] = await ethers.getSigners()

packages/excubiae/test/ZKEdDSAEventTicketPCD.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ describe("ZKEdDSAEventTicketPCDExcubia", function () {
116116
})
117117
})
118118

119+
describe("trait()", function () {
120+
it("should return the trait of the Excubia contract", async () => {
121+
expect(await zkEdDSAEventTicketPCDExcubia.trait()).to.be.equal("ZKEdDSAEventTicketPCD")
122+
})
123+
})
124+
119125
describe("setGate()", function () {
120126
it("should fail to set the gate when the caller is not the owner", async () => {
121127
const [, notOwnerSigner] = await ethers.getSigners()

0 commit comments

Comments
 (0)