Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
12180775
Commit
12180775
authored
May 16, 2023
by
tre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update the auth id for Faucet to be bytes32 instead of bytes
parent
b353c11f
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
58 deletions
+71
-58
AdminFaucetAuthModule.t.sol
...phery/contracts/foundry-tests/AdminFaucetAuthModule.t.sol
+11
-12
Faucet.t.sol
.../contracts-periphery/contracts/foundry-tests/Faucet.t.sol
+48
-32
FaucetHelper.sol
...acts-periphery/contracts/testing/helpers/FaucetHelper.sol
+4
-6
Faucet.sol
...contracts-periphery/contracts/universal/faucet/Faucet.sol
+4
-4
AdminFaucetAuthModule.sol
...ts/universal/faucet/authmodules/AdminFaucetAuthModule.sol
+3
-3
IFaucetAuthModule.sol
...tracts/universal/faucet/authmodules/IFaucetAuthModule.sol
+1
-1
No files found.
packages/contracts-periphery/contracts/foundry-tests/AdminFaucetAuthModule.t.sol
View file @
12180775
...
...
@@ -57,11 +57,10 @@ contract AdminFaucetAuthModuleTest is Test {
* @notice Get signature as a bytes blob.
*
*/
function _getSignature(uint256 _signingPrivateKey, bytes32 _digest)
internal
pure
returns (bytes memory)
{
function _getSignature(
uint256 _signingPrivateKey,
bytes32 _digest
) internal pure returns (bytes memory) {
(uint8 v, bytes32 r, bytes32 s) = vm.sign(_signingPrivateKey, _digest);
bytes memory signature = abi.encodePacked(r, s, v);
...
...
@@ -80,7 +79,7 @@ contract AdminFaucetAuthModuleTest is Test {
uint256 _eip712Chainid,
address _eip712VerifyingContract,
address recipient,
bytes
memory
id,
bytes
32
id,
bytes32 nonce
) internal view returns (bytes memory) {
AdminFaucetAuthModule.Proof memory proof = AdminFaucetAuthModule.Proof(
...
...
@@ -114,7 +113,7 @@ contract AdminFaucetAuthModuleTest is Test {
block.chainid,
address(adminFam),
fundsReceiver,
abi.encodePacked(fundsReceiver
),
keccak256(abi.encodePacked(fundsReceiver)
),
nonce
);
...
...
@@ -122,7 +121,7 @@ contract AdminFaucetAuthModuleTest is Test {
assertEq(
adminFam.verify(
Faucet.DripParameters(payable(fundsReceiver), nonce),
abi.encodePacked(fundsReceiver
),
keccak256(abi.encodePacked(fundsReceiver)
),
proof
),
true
...
...
@@ -142,7 +141,7 @@ contract AdminFaucetAuthModuleTest is Test {
block.chainid,
address(adminFam),
fundsReceiver,
abi.encodePacked(fundsReceiver
),
keccak256(abi.encodePacked(fundsReceiver)
),
nonce
);
...
...
@@ -150,7 +149,7 @@ contract AdminFaucetAuthModuleTest is Test {
assertEq(
adminFam.verify(
Faucet.DripParameters(payable(fundsReceiver), nonce),
abi.encodePacked(fundsReceiver
),
keccak256(abi.encodePacked(fundsReceiver)
),
proof
),
false
...
...
@@ -172,7 +171,7 @@ contract AdminFaucetAuthModuleTest is Test {
block.chainid,
address(adminFam),
fundsReceiver,
abi.encodePacked(fundsReceiver
),
keccak256(abi.encodePacked(fundsReceiver)
),
nonce
);
...
...
@@ -180,7 +179,7 @@ contract AdminFaucetAuthModuleTest is Test {
assertEq(
adminFam.verify(
Faucet.DripParameters(payable(fundsReceiver), nonce),
abi.encodePacked(randomAddress
),
keccak256(abi.encodePacked(randomAddress)
),
proof
),
false
...
...
packages/contracts-periphery/contracts/foundry-tests/Faucet.t.sol
View file @
12180775
This diff is collapsed.
Click to expand it.
packages/contracts-periphery/contracts/testing/helpers/FaucetHelper.sol
View file @
12180775
...
...
@@ -16,7 +16,7 @@ contract FaucetHelper {
* @notice EIP712 typehash for the Proof type.
*/
bytes32 public constant PROOF_TYPEHASH =
keccak256("Proof(address recipient,bytes32 nonce,bytes id)");
keccak256("Proof(address recipient,bytes32 nonce,bytes
32
id)");
/**
* @notice EIP712 typehash for the EIP712Domain type that is included as part of the signature.
...
...
@@ -48,11 +48,9 @@ contract FaucetHelper {
*
* @return EIP-712 typed struct hash.
*/
function getProofStructHash(AdminFaucetAuthModule.Proof memory _proof)
public
pure
returns (bytes32)
{
function getProofStructHash(
AdminFaucetAuthModule.Proof memory _proof
) public pure returns (bytes32) {
return keccak256(abi.encode(PROOF_TYPEHASH, _proof.recipient, _proof.nonce, _proof.id));
}
...
...
packages/contracts-periphery/contracts/universal/faucet/Faucet.sol
View file @
12180775
...
...
@@ -31,7 +31,7 @@ contract Faucet {
*/
event Drip(
string indexed authModule,
bytes indexed userId,
bytes
32
indexed userId,
uint256 amount,
address indexed recipient
);
...
...
@@ -49,7 +49,7 @@ contract Faucet {
*/
struct AuthParameters {
IFaucetAuthModule module;
bytes id;
bytes
32
id;
bytes proof;
}
...
...
@@ -76,12 +76,12 @@ contract Faucet {
/**
* @notice Mapping of authentication IDs to the next timestamp at which they can be used.
*/
mapping(IFaucetAuthModule => mapping(bytes => uint256)) public timeouts;
mapping(IFaucetAuthModule => mapping(bytes
32
=> uint256)) public timeouts;
/**
* @notice Maps from id to nonces to whether or not they have been used.
*/
mapping(bytes => mapping(bytes32 => bool)) public nonces;
mapping(bytes
32
=> mapping(bytes32 => bool)) public nonces;
/**
* @notice Modifier that makes a function admin priviledged.
...
...
packages/contracts-periphery/contracts/universal/faucet/authmodules/AdminFaucetAuthModule.sol
View file @
12180775
...
...
@@ -21,7 +21,7 @@ contract AdminFaucetAuthModule is IFaucetAuthModule, EIP712 {
* @notice EIP712 typehash for the Proof type.
*/
bytes32 public constant PROOF_TYPEHASH =
keccak256("Proof(address recipient,bytes32 nonce,bytes id)");
keccak256("Proof(address recipient,bytes32 nonce,bytes
32
id)");
/**
* @notice Struct that represents a proof that verifies the admin.
...
...
@@ -33,7 +33,7 @@ contract AdminFaucetAuthModule is IFaucetAuthModule, EIP712 {
struct Proof {
address recipient;
bytes32 nonce;
bytes id;
bytes
32
id;
}
/**
...
...
@@ -54,7 +54,7 @@ contract AdminFaucetAuthModule is IFaucetAuthModule, EIP712 {
*/
function verify(
Faucet.DripParameters memory _params,
bytes
memory
_id,
bytes
32
_id,
bytes memory _proof
) external view returns (bool) {
// Generate a EIP712 typed data hash to compare against the proof.
...
...
packages/contracts-periphery/contracts/universal/faucet/authmodules/IFaucetAuthModule.sol
View file @
12180775
...
...
@@ -17,7 +17,7 @@ interface IFaucetAuthModule {
*/
function verify(
Faucet.DripParameters memory _params,
bytes
memory
_id,
bytes
32
_id,
bytes memory _proof
) external view returns (bool);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment