Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
28ddea1
adding build-push and compose .yml files
nikolaivanovj Jan 5, 2025
3ebeb6c
temp remove go.yml
nikolaivanovj Jan 5, 2025
b1a56ba
Update build-push.yml
nikolaivanovj Jan 5, 2025
734c328
push workflow
nikolaivanovj Jan 5, 2025
00b10bf
Merge branch 'initialtest' of https://github.com/nikolaivanovj/go-eth…
nikolaivanovj Jan 5, 2025
6070a1b
Update build-push.yml
nikolaivanovj Jan 5, 2025
e2513a0
test changing branch
nikolaivanovj Jan 5, 2025
18b6cbb
Merge branch 'initialtest' of https://github.com/nikolaivanovj/go-eth…
nikolaivanovj Jan 5, 2025
15e780f
changing branch to main again
nikolaivanovj Jan 5, 2025
715c75c
comment
nikolaivanovj Jan 5, 2025
2923a11
test hardcoding
nikolaivanovj Jan 5, 2025
45e7237
remove docker compose
nikolaivanovj Jan 5, 2025
0317a5b
Merge branch 'initialtest' of https://github.com/nikolaivanovj/go-eth…
nikolaivanovj Jan 5, 2025
fc5382e
Update build-push.yml
nikolaivanovj Jan 5, 2025
936e50d
Update build-push.yml
nikolaivanovj Jan 5, 2025
aadd77a
add compose and add secrets again
nikolaivanovj Jan 5, 2025
b4f6592
add compose file and add secrets again
nikolaivanovj Jan 5, 2025
a253b16
change folder structure and update main branch name
nikolaivanovj Jan 5, 2025
ef87210
Add deploy and test workflow, add hardhat
nikolaivanovj Jan 6, 2025
7830017
Check CI-Deploy
nikolaivanovj Jan 6, 2025
400f508
Check CI-Deploy2
nikolaivanovj Jan 6, 2025
78d6b48
Check CI-Deploy3
nikolaivanovj Jan 6, 2025
e2c7049
Check CI-Deploy4
nikolaivanovj Jan 6, 2025
18aab1f
hardhatcompile
nikolaivanovj Jan 6, 2025
842dbc0
hardhat
nikolaivanovj Jan 6, 2025
0ba5489
hardhatupdate
nikolaivanovj Jan 6, 2025
1b42a04
cdhardhatupdate
nikolaivanovj Jan 6, 2025
2e55292
Update deploy.js
nikolaivanovj Jan 6, 2025
645db5e
Update deploy.js
nikolaivanovj Jan 6, 2025
1664710
Update deploy.js
nikolaivanovj Jan 6, 2025
740c515
Update deploy-test.yml
nikolaivanovj Jan 6, 2025
8433ccd
Update deploy.js
nikolaivanovj Jan 7, 2025
d24470e
Update deploy.js
nikolaivanovj Jan 7, 2025
841ccaf
Update build-push.yml
nikolaivanovj Jan 10, 2025
4b2703c
Update deploy-test.yml
nikolaivanovj Jan 10, 2025
8f9f387
Update package.json
nikolaivanovj Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Push Docker Image

on:
pull_request:
branches:
- master
types:
- closed
- labeled

jobs:
build:
if: github.event.label.name == 'CI:Build'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PAT }}

- name: Build and Push Docker Image
run: |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/go-ethereum:latest .
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/go-ethereum:latest
54 changes: 54 additions & 0 deletions .github/workflows/deploy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deploy and Test Hardhat Project

on:
pull_request:
branches:
- master
types:
- labeled

jobs:
deploy:
if: github.event.label.name == 'CI:Deploy'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PAT }}

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose

- name: Export Environment Variable
run: echo "DOCKER_HUB_USERNAME=${{ secrets.DOCKER_HUB_USERNAME }}" >> $GITHUB_ENV

- name: Set up Docker Compose
run: |
docker-compose up --build -d
sleep 10

- name: Deploy Hardhat Contracts
run: |
cd hardhat
npm install
npx hardhat compile # Added the compile step
npx hardhat run scripts/deploy.js

- name: Run Hardhat Tests
run: |
cd hardhat
npx hardhat test

- name: Shutdown Docker Compose
run: docker-compose down
24 changes: 0 additions & 24 deletions .github/workflows/go.yml

This file was deleted.

9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.8'

services:
geth:
image: "${DOCKER_HUB_USERNAME}/go-ethereum:latest"
ports:
- "8545:8545"
- "30303:30303"
command: --dev --http --http.addr 0.0.0.0
17 changes: 17 additions & 0 deletions hardhat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337
13 changes: 13 additions & 0 deletions hardhat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat ignition deploy ./ignition/modules/Lock.js
```
34 changes: 34 additions & 0 deletions hardhat/contracts/Lock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;

// Uncomment this line to use console.log
// import "hardhat/console.sol";

contract Lock {
uint public unlockTime;
address payable public owner;

event Withdrawal(uint amount, uint when);

constructor(uint _unlockTime) payable {
require(
block.timestamp < _unlockTime,
"Unlock time should be in the future"
);

unlockTime = _unlockTime;
owner = payable(msg.sender);
}

function withdraw() public {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);

require(block.timestamp >= unlockTime, "You can't withdraw yet");
require(msg.sender == owner, "You aren't the owner");

emit Withdrawal(address(this).balance, block.timestamp);

owner.transfer(address(this).balance);
}
}
10 changes: 10 additions & 0 deletions hardhat/contracts/Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 1000 * 10 ** decimals());
}
}
11 changes: 11 additions & 0 deletions hardhat/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.28",
networks: {
localhost: {
url: "http://127.0.0.1:8545"
}
}
};
18 changes: 18 additions & 0 deletions hardhat/ignition/modules/Lock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This setup uses Hardhat Ignition to manage smart contract deployments.
// Learn more about it at https://hardhat.org/ignition

const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");

const JAN_1ST_2030 = 1893456000;
const ONE_GWEI = 1_000_000_000n;

module.exports = buildModule("LockModule", (m) => {
const unlockTime = m.getParameter("unlockTime", JAN_1ST_2030);
const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);

const lock = m.contract("Lock", [unlockTime], {
value: lockedAmount,
});

return { lock };
});
Loading