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
b6847696
Commit
b6847696
authored
Jun 29, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: port faucet
parent
a4315c8c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
6 deletions
+95
-6
Faucet.sol
...s/contracts-bedrock/contracts/periphery/faucet/Faucet.sol
+0
-0
AdminFaucetAuthModule.sol
...ts/periphery/faucet/authmodules/AdminFaucetAuthModule.sol
+0
-0
IFaucetAuthModule.sol
...tracts/periphery/faucet/authmodules/IFaucetAuthModule.sol
+0
-0
AdminFaucetAuthModule.t.sol
...tracts-bedrock/contracts/test/AdminFaucetAuthModule.t.sol
+3
-3
Faucet.t.sol
packages/contracts-bedrock/contracts/test/Faucet.t.sol
+3
-3
Helpers.sol
packages/contracts-bedrock/contracts/test/Helpers.sol
+89
-0
No files found.
packages/contracts-
periphery/contracts/universal
/faucet/Faucet.sol
→
packages/contracts-
bedrock/contracts/periphery
/faucet/Faucet.sol
View file @
b6847696
File moved
packages/contracts-
periphery/contracts/universal
/faucet/authmodules/AdminFaucetAuthModule.sol
→
packages/contracts-
bedrock/contracts/periphery
/faucet/authmodules/AdminFaucetAuthModule.sol
View file @
b6847696
File moved
packages/contracts-
periphery/contracts/universal
/faucet/authmodules/IFaucetAuthModule.sol
→
packages/contracts-
bedrock/contracts/periphery
/faucet/authmodules/IFaucetAuthModule.sol
View file @
b6847696
File moved
packages/contracts-
periphery/contracts/foundry-tests
/AdminFaucetAuthModule.t.sol
→
packages/contracts-
bedrock/contracts/test
/AdminFaucetAuthModule.t.sol
View file @
b6847696
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
pragma solidity 0.8.15;
pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { Test } from "forge-std/Test.sol";
import { AdminFaucetAuthModule } from "../
universal
/faucet/authmodules/AdminFaucetAuthModule.sol";
import { AdminFaucetAuthModule } from "../
periphery
/faucet/authmodules/AdminFaucetAuthModule.sol";
import { Faucet } from "../
universal
/faucet/Faucet.sol";
import { Faucet } from "../
periphery
/faucet/Faucet.sol";
import { FaucetHelper } from ".
./testing/helpers/FaucetHelper
.sol";
import { FaucetHelper } from ".
/Helpers
.sol";
/**
/**
* @title AdminFaucetAuthModuleTest
* @title AdminFaucetAuthModuleTest
...
...
packages/contracts-
periphery/contracts/foundry-tests
/Faucet.t.sol
→
packages/contracts-
bedrock/contracts/test
/Faucet.t.sol
View file @
b6847696
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
pragma solidity 0.8.15;
pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { Test } from "forge-std/Test.sol";
import { Faucet } from "../
universal
/faucet/Faucet.sol";
import { Faucet } from "../
periphery
/faucet/Faucet.sol";
import { AdminFaucetAuthModule } from "../
universal
/faucet/authmodules/AdminFaucetAuthModule.sol";
import { AdminFaucetAuthModule } from "../
periphery
/faucet/authmodules/AdminFaucetAuthModule.sol";
import { FaucetHelper } from ".
./testing/helpers/FaucetHelper
.sol";
import { FaucetHelper } from ".
/Helpers
.sol";
contract Faucet_Initializer is Test {
contract Faucet_Initializer is Test {
event Drip(
event Drip(
...
...
packages/contracts-bedrock/contracts/test/Helpers.sol
View file @
b6847696
...
@@ -7,6 +7,13 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
...
@@ -7,6 +7,13 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { OptimistInviter } from "../periphery/op-nft/OptimistInviter.sol";
import { OptimistInviter } from "../periphery/op-nft/OptimistInviter.sol";
import { IERC1271 } from "@openzeppelin/contracts/interfaces/IERC1271.sol";
import { IERC1271 } from "@openzeppelin/contracts/interfaces/IERC1271.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import {
ECDSAUpgradeable
} from "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import {
AdminFaucetAuthModule
} from "../periphery/faucet/authmodules/AdminFaucetAuthModule.sol";
contract TestERC20 is ERC20 {
contract TestERC20 is ERC20 {
constructor() ERC20("TEST", "TST", 18) {}
constructor() ERC20("TEST", "TST", 18) {}
...
@@ -222,3 +229,85 @@ contract TestERC1271Wallet is Ownable, IERC1271 {
...
@@ -222,3 +229,85 @@ contract TestERC1271Wallet is Ownable, IERC1271 {
ECDSA.recover(hash, signature) == owner() ? this.isValidSignature.selector : bytes4(0);
ECDSA.recover(hash, signature) == owner() ? this.isValidSignature.selector : bytes4(0);
}
}
}
}
/**
* Simple helper contract that helps with testing the Faucet contract.
*/
contract FaucetHelper {
/**
* @notice EIP712 typehash for the Proof type.
*/
bytes32 public constant PROOF_TYPEHASH =
keccak256("Proof(address recipient,bytes32 nonce,bytes32 id)");
/**
* @notice EIP712 typehash for the EIP712Domain type that is included as part of the signature.
*/
bytes32 public constant EIP712_DOMAIN_TYPEHASH =
keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
/**
* @notice Keeps track of current nonce to generate new nonces for each drip.
*/
uint256 public currentNonce;
/**
* @notice Returns a bytes32 nonce that should change everytime. In practice, people should use
* pseudorandom nonces.
*
* @return Nonce that should be used as part of drip parameters.
*/
function consumeNonce() public returns (bytes32) {
return bytes32(keccak256(abi.encode(currentNonce++)));
}
/**
* @notice Returns the hash of the struct Proof.
*
* @param _proof Proof struct to hash.
*
* @return EIP-712 typed struct hash.
*/
function getProofStructHash(AdminFaucetAuthModule.Proof memory _proof)
public
pure
returns (bytes32)
{
return keccak256(abi.encode(PROOF_TYPEHASH, _proof.recipient, _proof.nonce, _proof.id));
}
/**
* @notice Computes the EIP712 digest with the given domain parameters.
* Used for testing that different domain parameters fail.
*
* @param _proof Proof struct to hash.
* @param _name Contract name to use in the EIP712 domain.
* @param _version Contract version to use in the EIP712 domain.
* @param _chainid Chain ID to use in the EIP712 domain.
* @param _verifyingContract Address to use in the EIP712 domain.
* @param _verifyingContract Address to use in the EIP712 domain.
* @param _verifyingContract Address to use in the EIP712 domain.
*
* @return EIP-712 compatible digest.
*/
function getDigestWithEIP712Domain(
AdminFaucetAuthModule.Proof memory _proof,
bytes memory _name,
bytes memory _version,
uint256 _chainid,
address _verifyingContract
) public pure returns (bytes32) {
bytes32 domainSeparator = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(_name),
keccak256(_version),
_chainid,
_verifyingContract
)
);
return ECDSAUpgradeable.toTypedDataHash(domainSeparator, getProofStructHash(_proof));
}
}
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