-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding delegation wall contract
- Loading branch information
1 parent
23618a3
commit ed637a6
Showing
5 changed files
with
74 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
import { Foo } from "../src/Foo.sol"; | ||
import { DelegationWall } from "../src/DelegationWall.sol"; | ||
|
||
import { BaseScript } from "./Base.s.sol"; | ||
|
||
/// @dev See the Solidity Scripting tutorial: https://book.getfoundry.sh/tutorials/solidity-scripting | ||
contract Deploy is BaseScript { | ||
function run() public broadcast returns (Foo foo) { | ||
foo = new Foo(); | ||
} | ||
function run() public broadcast returns (DelegationWall delegationWall) { | ||
delegationWall = new DelegationWall(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity ^0.8.25; | ||
|
||
/// @title DelegationWall - Release 1, Build 1 | ||
/// @author Aragon Association - 2024 | ||
/// @notice A smart contract where any wallet can announce itself as a delegate by providing an IPFS Id | ||
contract DelegationWall { | ||
struct Candidate { | ||
bytes contentUrl; | ||
} | ||
|
||
/// @dev Stores the data registered by the delegate candidates | ||
mapping(address => Candidate) public candidates; | ||
|
||
/// @dev Keeps track of the addresses that have been already registered, used to enumerate. | ||
address[] public candidateAddresses; | ||
|
||
/// @notice Emitted when a wallet registers as a candidate | ||
event CandidateRegistered(address indexed candidate, bytes contentUrl); | ||
|
||
/// @notice Raised when a delegate registers with an empty contentUrl | ||
error EmptyContent(); | ||
|
||
/// @notice Registers the given data as a new delegation candidate | ||
function register(bytes memory _contentUrl) public { | ||
if (_contentUrl.length == 0) revert EmptyContent(); | ||
|
||
if (candidates[msg.sender].contentUrl.length == 0) { | ||
candidateAddresses.push(msg.sender); | ||
} | ||
|
||
candidates[msg.sender].contentUrl = _contentUrl; | ||
|
||
emit CandidateRegistered(msg.sender, _contentUrl); | ||
} | ||
|
||
/// @notice Returns the list of candidate addresses registered | ||
/// @dev Use this function to get all addresses in a single call. You can still call candidateAddresses[idx] to resolve them one by one. | ||
function getCandidateAddresses() public view returns (address[] memory) { | ||
return candidateAddresses; | ||
} | ||
|
||
/// @notice Returns the number of candidate entries available | ||
function candidateCount() public view returns (uint256) { | ||
return candidateAddresses.length; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
import { Test } from "forge-std/src/Test.sol"; | ||
import { console2 } from "forge-std/src/console2.sol"; | ||
|
||
import { DelegationWall } from "../src/DelegationWall.sol"; | ||
|
||
interface IERC20 { | ||
function balanceOf(address account) external view returns (uint256); | ||
} | ||
|
||
/// @dev If this is your first time with Forge, read this tutorial in the Foundry Book: | ||
/// https://book.getfoundry.sh/forge/writing-tests | ||
contract DelegationWallTest is Test { | ||
DelegationWall internal delegationWall; | ||
|
||
/// @dev A function invoked before each test case is run. | ||
function setUp() public virtual { | ||
// Instantiate the contract-under-test. | ||
delegationWall = new DelegationWall(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.