Skip to content

Commit

Permalink
Merge pull request #7 from figment-networks/pre-prod
Browse files Browse the repository at this point in the history
Pre prod
  • Loading branch information
zurgl authored Nov 24, 2021
2 parents ff3d623 + 4aa112c commit ba0f755
Show file tree
Hide file tree
Showing 6 changed files with 13,999 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Installation

1. Clone the repository `git clone [email protected]:figment-networks/figment-eth2-depositor.git`
2. Install the npm dependencies `npm install`
3. Set a working version of the compiler `npx truffle obtain --solc v0.8.1+commit.df193b15`
3. Set a working version of the compiler `npx truffle obtain --solc v0.8.10+commit.fc410830`

Deployment (Goerli)
------------
Expand Down
38 changes: 16 additions & 22 deletions contracts/FigmentEth2Depositor.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
pragma solidity 0.8.10;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../contracts/interfaces/IDepositContract.sol";

contract FigmentEth2Depositor is ReentrancyGuard, Pausable, Ownable {
contract FigmentEth2Depositor is Pausable, Ownable {

/**
* @dev Eth2 Deposit Contract address.
*/
IDepositContract public depositContract;
IDepositContract public immutable depositContract;

/**
* @dev Minimal and maximum amount of nodes per transaction.
Expand All @@ -31,21 +30,16 @@ contract FigmentEth2Depositor is ReentrancyGuard, Pausable, Ownable {
/**
* @dev Setting Eth2 Smart Contract address during construction.
*/
constructor(bool mainnet, address depositContract_) {
if (mainnet == true) {
depositContract = IDepositContract(0x00000000219ab540356cBB839Cbe05303d7705Fa);
} else if (depositContract_ == 0x0000000000000000000000000000000000000000) {
depositContract = IDepositContract(0x8c5fecdC472E27Bc447696F431E425D02dd46a8c);
} else {
depositContract = IDepositContract(depositContract_);
}
constructor(address depositContract_) {
require(depositContract_ != address(0), "Zero address");
depositContract = IDepositContract(depositContract_);
}

/**
* @dev This contract will not accept direct ETH transactions.
*/
receive() external payable {
revert("FigmentEth2Depositor: do not send ETH directly here");
revert("Do not send ETH here");
}

/**
Expand All @@ -65,20 +59,20 @@ contract FigmentEth2Depositor is ReentrancyGuard, Pausable, Ownable {

uint256 nodesAmount = pubkeys.length;

require(nodesAmount > 0 && nodesAmount <= 100, "FigmentEth2Depositor: you can deposit only 1 to 100 nodes per transaction");
require(msg.value == collateral * nodesAmount, "FigmentEth2Depositor: the amount of ETH does not match the amount of nodes");
require(nodesAmount > 0 && nodesAmount <= 100, "100 nodes max / tx");
require(msg.value == collateral * nodesAmount, "ETH amount missmatch");


require(
withdrawal_credentials.length == nodesAmount &&
signatures.length == nodesAmount &&
deposit_data_roots.length == nodesAmount,
"FigmentEth2Depositor: amount of parameters do no match");
"Paramters missmatch");

for (uint256 i = 0; i < nodesAmount; ++i) {
require(pubkeys[i].length == pubkeyLength, "FigmentEth2Depositor: wrong pubkey");
require(withdrawal_credentials[i].length == credentialsLength, "FigmentEth2Depositor: wrong withdrawal credentials");
require(signatures[i].length == signatureLength, "FigmentEth2Depositor: wrong signatures");
for (uint256 i; i < nodesAmount; ++i) {
require(pubkeys[i].length == pubkeyLength, "Wrong pubkey");
require(withdrawal_credentials[i].length == credentialsLength, "Wrong withdrawal cred");
require(signatures[i].length == signatureLength, "Wrong signatures");

IDepositContract(address(depositContract)).deposit{value: collateral}(
pubkeys[i],
Expand All @@ -99,7 +93,7 @@ contract FigmentEth2Depositor is ReentrancyGuard, Pausable, Ownable {
*
* - The contract must not be paused.
*/
function pause() public onlyOwner {
function pause() external onlyOwner {
_pause();
}

Expand All @@ -110,7 +104,7 @@ contract FigmentEth2Depositor is ReentrancyGuard, Pausable, Ownable {
*
* - The contract must be paused.
*/
function unpause() public onlyOwner {
function unpause() external onlyOwner {
_unpause();
}

Expand Down
4 changes: 3 additions & 1 deletion migrations/2_contract_migration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const FigmentEth2Depositor = artifacts.require("FigmentEth2Depositor");

module.exports = function (deployer) {
deployer.deploy(FigmentEth2Depositor, false, "0x0000000000000000000000000000000000000000");
// Contract address on mainnet: 0x00000000219ab540356cBB839Cbe05303d7705Fa
// Contract address on testnet: 0x8c5fecdC472E27Bc447696F431E425D02dd46a8c
deployer.deploy(FigmentEth2Depositor, "0x8c5fecdC472E27Bc447696F431E425D02dd46a8c");
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"keywords": [],
"author": "",
"license": "ISC",
"license": "MIT",
"dependencies": {
"@openzeppelin/contracts": "^4.3.1",
"chai": "^4.3.4",
Expand Down
6 changes: 2 additions & 4 deletions truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,15 @@
// Configure your compilers
compilers: {
solc: {
version: "v0.8.1+commit.df193b15", // Fetch exact version from solc-bin (default: truffle's version)
version: "v0.8.10+commit.fc410830", // Fetch exact version from solc-bin (default: truffle's version)
settings: {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "istanbul",
"libraries": {
"": {}
},
"libraries": {},
"outputSelection": {
"*": {
"*": [
Expand Down
Loading

0 comments on commit ba0f755

Please sign in to comment.