Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(*): cleanup #8

Merged
merged 7 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# anvil account 2
PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d

# portal address for CLI devnet
PORTAL_ADDRESS=0xb835dc695c6bfc8373c0d56973b5d9e9b083e97b

# address of contract deployed with nonce 1 for above PK.
# TODO: don't hardcode this
DEPLOYED_ADDRESS=0x8464135c8F25Da09e49BC8782676a84730C318bC

GLOBAL_CHAIN_ID=1651
OP_CHAIN_ID=1655
ARB_CHAIN_ID=1656

OMNI_RPC_URL=http://localhost:8000
OP_RPC_URL=http://localhost:8001
ARB_RPC_URL=http://localhost:8002
25 changes: 7 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
name: test

on: workflow_dispatch

env:
FOUNDRY_PROFILE: ci
on:
pull_request:
branches:
- main

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
forge-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
- name: install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build

- name: Run Forge tests
- name: run forge tests
run: |
forge test -vvv
id: test
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ifneq ("$(wildcard .env)","")
include .env
export $(shell sed 's/=.*//' .env)
endif

help: ## Display this help message
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}'

ensure-deps:
@which omni > /dev/null 2>&1 || { \
echo "Binary `omni` not found. Installing..."; \
curl -sSfL https://raw.githubusercontent.com/omni-network/omni/main/scripts/install_omni_cli.sh | sh -s; \
}

build:
forge build

test:
forge test -vvv

devnet-start:
omni devnet start

devnet-clean:
omni devnet clean

deploy:
forge script DeployGreetingBook --broadcast --rpc-url $(OMNI_RPC_URL) --private-key $(PRIVATE_KEY)
forge script DeployGreeter --broadcast --rpc-url $(OP_RPC_URL) --private-key $(PRIVATE_KEY)
forge script DeployGreeter --broadcast --rpc-url $(ARB_RPC_URL) --private-key $(PRIVATE_KEY)

.PHONY: ensure-deps build test devnet-start devnet-clean deploy
49 changes: 13 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,33 @@
# Omni Hello World Template

This repository serves as a template for Ethereum smart contract development using Foundry, specifically designed for projects intending to utilize the Omni protocol for cross-chain interactions. The template features the `RollupGreeter` and `GlobalGreeter` contracts as examples to demonstrate how contracts can interact across different blockchain networks.
This repository serves as a template for Ethereum smart contract development using Foundry, specifically designed for projects intending to utilize the Omni protocol for cross-chain interactions. The template features the `Greeter` and `GreetingBook` contracts as examples to demonstrate how contracts can interact across different blockchain networks.

## Getting Started
## Installation

To use this template for your project, initialize a new project with Foundry by running the following within your project directory:
To use this template for your project, initialize a new project either by using `forge init` or cloning this repo::

```bash
forge init --template https://github.com/omni-network/hello-world-template.git
```

### Cloning the Template

To clone this template along with its dependencies, use the following command:

```bash
git clone --recursive https://github.com/omni-network/hello-world-template.git
```

If you've already cloned the repository without submodules, initialize and update them with:

```bash
git submodule update --init --recursive
```

## Compiling Contracts

After initializing your project with this template, compile the smart contracts using:

```bash
forge build
```

## Running Tests
## Usage

This template includes tests for the `XGreeter` contract. Run these tests to ensure everything is set up correctly:

```bash
forge test
```
1. Run `make build` to build the smart contracts.
2. Run `make test` to run tests.

## Contributing
If you want to deploy the contracts agains a local devnet:

Contributions to this template are welcome. To contribute:
1. Run `make ensure-deps` to ensure you've installed the `omni` cli.
2. Run `make devnet-start` to deploy a local instance of Omni, which includes local deployments of Omni, Arbitrum, and Optimism.
3. Run `make deploy` to deploy your smart contracts.

1. Fork the repository.
2. Create a new branch for your feature (`git checkout -b feature/amazing-feature`).
3. Commit your changes (`git commit -am 'feat(dir): Add some amazing feature'`).
4. Push to the branch (`git push origin feature/amazing-feature`).
5. Open a pull request.
Note: you'll need to have docker installed to run the local devnet.

## Acknowledgments
When finished, you can run:

- This template is designed for developers looking to explore cross-chain capabilities with the Omni protocol.
- Special thanks to the Foundry team for providing such a powerful tool for smart contract development.
`make devnet-clean`
2 changes: 1 addition & 1 deletion lib/omni
Submodule omni updated 132 files
18 changes: 18 additions & 0 deletions script/DeployGreeter.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.23;

import {Script, console} from "forge-std/Script.sol";
import {Greeter} from "src/Greeter.sol";

contract DeployGreeter is Script {
function run() external {
address portalAddress = vm.envAddress("PORTAL_ADDRESS");
address greetingBookAddress = vm.envAddress("DEPLOYED_ADDRESS");

vm.startBroadcast();
Greeter greeter = new Greeter(portalAddress, greetingBookAddress);
vm.stopBroadcast();

console.log("Deployed Greeter at:", address(greeter));
}
}
18 changes: 18 additions & 0 deletions script/DeployGreetingBook.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.23;

import {Script, console} from "forge-std/Script.sol";
import {GreetingBook} from "src/GreetingBook.sol";


contract DeployGreetingBook is Script {
function run() external {
address portalAddress = vm.envAddress("PORTAL_ADDRESS");

vm.startBroadcast();
GreetingBook greetingBook = new GreetingBook(portalAddress);
vm.stopBroadcast();

console.log("Deployed GreetingBook at:", address(greetingBook));
}
}
29 changes: 0 additions & 29 deletions script/GlobalGreeter.s.sol

This file was deleted.

31 changes: 0 additions & 31 deletions script/RollupGreeter.s.sol

This file was deleted.

14 changes: 0 additions & 14 deletions script/bash/.env.example

This file was deleted.

47 changes: 0 additions & 47 deletions script/bash/deploy.sh

This file was deleted.

45 changes: 0 additions & 45 deletions src/GlobalGreeter.sol

This file was deleted.

Loading