-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: adding export of smart contract variables for cluster deployment (
#242) Co-authored-by: Ivan Vandot <[email protected]>
- Loading branch information
1 parent
4fdb26e
commit 1bd03c0
Showing
25 changed files
with
1,740 additions
and
2,157 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# @nomiclabs/hardhat | ||
cache/ | ||
artifacts/ | ||
dist/ | ||
|
||
# solidity-coverage | ||
coverage* | ||
|
||
# vscode | ||
.vscode* | ||
|
||
# Node | ||
node_modules/ | ||
*/node_modules/ | ||
|
||
# Idea | ||
.idea/ | ||
.idea/* | ||
|
||
# Env | ||
.env | ||
|
||
# hardhat-deploy | ||
deployments/hardhat | ||
deployments/localhost | ||
deployments/localcluster | ||
deployedContracts.sh | ||
|
||
# deployment files for mainnet and testnet and an example file | ||
*_deployed.json | ||
!mainnet_deployed.json | ||
!testnet_deployed.json | ||
|
||
# Misc | ||
contractsInfo.json | ||
.DS_Store | ||
|
||
# Gas reports | ||
gas-report.txt | ||
|
||
# Tenderly | ||
tenderly.log |
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
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,54 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- '**' | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
docker_release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
|
||
- name: Docker Hub and Quay Login | ||
run: | | ||
printf ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
printf ${{ secrets.QUAY_PASSWORD }} | docker login --username ${{ secrets.QUAY_USERNAME }} quay.io --password-stdin | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ethersphere/bee-localchain | ||
quay.io/ethersphere/bee-localchain | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: amd64,arm64,arm | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=registry,ref=ethersphere/bee-localchain:buildcache | ||
cache-to: type=registry,ref=ethersphere/bee-localchain:buildcache,mode=max |
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
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,3 @@ | ||
[submodule "s3"] | ||
path = s3 | ||
url = https://github.com/ethersphere/swap-swear-and-swindle.git |
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
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,46 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, ethers }) { | ||
const { get, log, execute } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
// Access the BZZACCOUNTS environment variable | ||
const bzzAccountsRaw = process.env.BZZACCOUNTS | ||
? process.env.BZZACCOUNTS | ||
: '0xbf4f9637c281ddfb1fbd3be5a1dae6531d408f11 0xc45d64d8f9642a604db93c59fd38492b262391ca'; | ||
const bzzAccounts = bzzAccountsRaw.split(' '); | ||
|
||
// Transfer tokens to accounts used in cluster deployment | ||
const amount = ethers.utils.parseUnits('10', 18); // "10" is the token amount; adjust the decimal accordingly | ||
for (const account of bzzAccounts) { | ||
await execute('TestToken', { from: deployer }, 'transfer', ethers.utils.getAddress(account), amount); | ||
} | ||
|
||
log(`Sent BZZ tokens to ` + bzzAccountsRaw); | ||
log('----------------------------------------------------'); | ||
|
||
const Token = await get('TestToken'); | ||
const StakeRegistry = await get('StakeRegistry'); | ||
const PostageStamp = await get('PostageStamp'); | ||
const PriceOracle = await get('PriceOracle'); | ||
const Redistribution = await get('Redistribution'); | ||
|
||
// Generate content for the environment file | ||
let content = ''; | ||
|
||
content += `echo "----- USE THE COMMANDS BELOW TO SETUP YOUR TERMINALS -----" >&2\n\n`; | ||
content += `export BEE_TOKEN_ADDRESS=${Token.address}\n`; | ||
content += `export BEE_POSTAGE_STAMP_ADDRESS=${PostageStamp.address}\n`; | ||
content += `export BEE_INCENTIVES_PRICE_ORACLE_ADDRESS=${PriceOracle.address}\n`; | ||
content += `export BEE_STAKING_ADDRESS=${StakeRegistry.address}\n`; | ||
content += `export BEE_REDISTRIBUTION_ADDRESS=${Redistribution.address}\n`; | ||
|
||
// Output the content to the terminal | ||
log(content); | ||
log(`Exported contract addresses to console`); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['variables']; |
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
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
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
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,30 @@ | ||
FROM node:20.11.1-alpine as build | ||
|
||
ENV NODE_ENV=production | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json yarn.lock ./ | ||
RUN yarn install --prod --frozen-lockfile --verbose | ||
|
||
COPY s3/package.json s3/yarn.lock ./s3/ | ||
RUN cd s3 && yarn install --prod --frozen-lockfile --verbose | ||
|
||
COPY . ./ | ||
RUN yarn hardhat compile | ||
RUN cd s3 && yarn hardhat compile | ||
|
||
FROM node:20.11.1-alpine | ||
|
||
ENV NODE_ENV=production | ||
ENV WALLET_SECRET=4663c222787e30c1994b59044aa5045377a6e79193a8ead88293926b535c722d | ||
|
||
RUN apk add --no-cache curl bash | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app . | ||
|
||
RUN ln -s /app/docker/deploy.sh /app/deploy.sh | ||
|
||
CMD ["sh", "-c", "/app/docker/deploy.sh"] |
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,13 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -x | ||
while ! curl -m 1 http://geth-swap:8545; do sleep 1; done | ||
echo connected to geth >&2 | ||
sleep 2 | ||
|
||
npx hardhat deploy --network localcluster | ||
|
||
cd ./s3 | ||
npx hardhat deploy --network localcluster | ||
|
||
echo deployed |
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
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
Oops, something went wrong.