Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pablitto818 authored Apr 4, 2024
0 parents commit 0768149
Show file tree
Hide file tree
Showing 40 changed files with 11,234 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Make sure to rename this file to .env before adding your private keys!!!
PRIVATE_KEY_1=''
# Add more if your project requires more private keys

# API keys for developer tooling and infra
OP_ALCHEMY_API_KEY=''
BASE_ALCHEMY_API_KEY=''
OP_BLOCKSCOUT_API_KEY=''
BASE_BLOCKSCOUT_API_KEY=''
# TENDERLY_TOKEN=''

# Contract addresses last updated on 2024-03-05, for public testnet launch
OP_DISPATCHER='0x58f1863f75c9db1c7266dc3d7b43832b58f35e83'
BASE_DISPATCHER='0xfc1d3e02e00e0077628e8cc9edb6812f95db05dc'

OP_UC_MW='0x34a0e37cCCEdaC70EC1807e5a1f6A4a91D4AE0Ce'
BASE_UC_MW='0x50E32e236bfE4d514f786C9bC80061637dd5AF98'

# Contract addresses for the sim-client
OP_DISPATCHER_SIM="0x6C9427E8d770Ad9e5a493D201280Cc178125CEc0"
BASE_DISPATCHER_SIM="0x0dE926fE2001B2c96e9cA6b79089CEB276325E9F"

OP_UC_MW_SIM='0xC3318ce027C560B559b09b1aA9cA4FEBDDF252F5'
BASE_UC_MW_SIM='0x5031fb609569b67608Ffb9e224754bb317f174cD'

# Configuration file the scripts will use, defaulting to config.json when not set
CONFIG_PATH='config.json'
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'prettier/prettier': ['error', { singleQuote: true }],
'comma-dangle': 'off',
},
ignorePatterns: ['node_modules/', 'lib/'],
};
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# Foundry files
/out
/cache_forge
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "lib/vibc-core-smart-contracts"]
path = lib/vibc-core-smart-contracts
url = https://github.com/open-ibc/vibc-core-smart-contracts
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
singleQuote: true,
printWidth: 150,
semi: true,
trailingComma: 'all',
};
97 changes: 97 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Install dependencies
install:
echo "Installing dependencies"
npm install
forge install --shallow

# Compile contracts using the specified compiler or default to Hardhat
# The compiler argument is optional; if not provided, it defaults to "hardhat".
# Usage: just compile [compiler]
compile COMPILER='hardhat':
#!/usr/bin/env sh
if test "{{COMPILER}}" = "hardhat"; then
echo "Compiling contracts with Hardhat..."
npx hardhat compile
elif test "{{COMPILER}}" = "foundry"; then
echo "Compiling contracts with Foundry..."
forge build
else
echo "Unknown compiler: {{COMPILER}}"
exit 1
fi
# Update the config.json file with the contract type for a specified chain/rollup
# The chain and contract-type arguments are REQUIRED;
# The universal argument is optional; if not provided, it defaults to "true".
# It indicates whether the contracts to deploy are using custom or universal IBC channels to send packets.
# Usage: just set-contracts [chain] [contract-type] [universal]
set-contracts CHAIN CONTRACT_TYPE UNIVERSAL='true':
echo "Updating config.json with contract type..."
node scripts/private/_set-contracts-config.js {{CHAIN}} {{CONTRACT_TYPE}} {{UNIVERSAL}}

# Deploy the contracts in the /contracts folder using Hardhat and updating the config.json file
# The source and destination arguments are REQUIRED;
# Usage: just deploy [source] [destination]
deploy SOURCE DESTINATION:
echo "Deploying contracts with Hardhat..."
node scripts/private/_deploy-config.js {{SOURCE}} {{DESTINATION}}

# Run the sanity check script to verify that configuration (.env) files match with deployed contracts' stored values
# Usage: just sanity-check
sanity-check:
echo "Running sanity check..."
node scripts/private/_sanity-check.js

# Update the dispatcher or universal channel handler address on the IBC application, with that from the .env file
# The chain argument is REQUIRED;
# Usage: just update-vibc [chain]
update-vibc CHAIN:
echo "Updating the dispatcher or universal channel handler address..."
npx hardhat run scripts/private/_update-vibc-address.js --network {{CHAIN}}

# Create a channel by triggering a channel handshake from the source and with parameters found in the config.json file
# Usage: just create-channel
create-channel:
echo "Attempting to create a channel with the values from the config..."
node scripts/private/_create-channel-config.js

# Send a packet over the universal channel or a custom channel as defined in the config.json file
# The source argument is REQUIRED;
# Usage: just send-packet [source]
send-packet SOURCE:
echo "Sending a packet with the values from the config..."
node scripts/private/_send-packet-config.js {{SOURCE}}

# Switch between the sim client and the client with proofs
# Usage: just switch-client
switch-client:
echo "Switching between sim client and client with proofs..."
npx hardhat run scripts/private/_update-vibc-address.js --network optimism
npx hardhat run scripts/private/_update-vibc-address.js --network base
node scripts/private/_switch-clients.js

# Run the full E2E flow by setting the contracts, deploying them, creating a channel, and sending a packet
# Usage: just do-it
do-it:
echo "Running the full E2E flow..."
just set-contracts optimism XCounter false && just set-contracts base XCounter false
just deploy optimism base
just sanity-check
just create-channel
just send-packet optimism
echo "You've done it!"

# Clean up the environment by removing the artifacts and cache folders and running the forge clean command
# Usage: just clean
clean:
echo "Cleaning up environment..."
rm -rf artifacts cache
forge clean

# Fully clean the environment by removing the artifacts, the dependencies, and cache folders and running the forge clean-all command
# Usage: just clean-all
clean-all:
echo "Cleaning up environment..."
rm -rf artifacts cache
forge clean
rm -rf node_modules
Loading

0 comments on commit 0768149

Please sign in to comment.