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

Feat/corporations #1

Merged
merged 22 commits into from
Feb 21, 2025
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
8 changes: 7 additions & 1 deletion .env.anvil
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Anvil default private key:
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
PLAYER1_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
PLAYER2_PRIVATE_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
PLAYER3_PRIVATE_KEY=0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6
PLAYER4_PRIVATE_KEY=0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a

# Anvil World address:
WORLD_ADDRESS=0x8a791620dd6260079bf849dc5567adc3f2fdc318
Expand All @@ -8,4 +12,6 @@ WORLD_ADDRESS=0x8a791620dd6260079bf849dc5567adc3f2fdc318
RPC_URL=http://127.0.0.1:8545

# Enable debug logs for MUD CLI
DEBUG=mud:*
DEBUG=mud:*

DEFAULT_NAMESPACE=beauKode_dev
12 changes: 12 additions & 0 deletions .env.garnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EVE World Address
WORLD_ADDRESS=0x7fe660995b0c59b6975d5d59973e2668af6bb9c5

RPC_URL=https://rpc.garnetchain.com
CHAIN_ID=17069

# Enable debug logs for MUD CLI
DEBUG=mud:*

DEFAULT_NAMESPACE=beauKode_dev


1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @beaukode
42 changes: 42 additions & 0 deletions .github/workflows/foundry-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Foundry tests

on:
workflow_call:

jobs:
local-deploy-and-test:
concurrency:
group: "test-${{github.ref}}"
cancel-in-progress: true
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-d14c09f15a9849fe177d097451919810e5877617
- name: Setup Node 20.x Environment
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: "Install dependencies"
run: "npm ci"
- name: "Lint"
run: "npm run lint"
- uses: JarvusInnovations/background-action@v1
name: Start Anvil
with:
run: |
gunzip anvil-test-state.json.gz
anvil --block-time 10 --block-base-fee-per-gas 0 --gas-limit 3000000000 --hardfork cancun --host 0.0.0.0 --port 8545 --state anvil-test-state.json &
wait-on: |
tcp:localhost:8545
wait-for: 30s
tail: false
log-output: true
- name: "Deploy to Anvil"
run: |
npm run deploy:local
- name: "Run tests"
run: |
npm run test
31 changes: 31 additions & 0 deletions .github/workflows/on-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy staging

on:
push:
branches:
- main

jobs:
local-deploy-and-test:
uses: ./.github/workflows/foundry-tests.yml
deploy-staging:
concurrency:
group: "deploy-staging-${{github.ref}}"
cancel-in-progress: false
runs-on: "ubuntu-latest"
environment: "staging"
steps:
- uses: actions/checkout@v4
- name: Setup Node 20.x Environment
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: "Install dependencies"
run: "npm ci"
- name: "Deploy corporations"
env:
PRIVATE_KEY: ${{ secrets.CORPORATIONS_PRIVATE_KEY }}
CORPORATIONS_NAMESPACE: ${{ vars.CORPORATIONS_NAMESPACE }}
run: |
cd packages/corporations
npm run deploy:garnet
8 changes: 8 additions & 0 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Pull request tests

on:
pull_request:

jobs:
tests:
uses: ./.github/workflows/foundry-tests.yml
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ bindings/
artifacts/
broadcast/
.mud/
.env.*
!.env.anvil

# Ignore MUD deploy artifacts
*/*/deploys
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mud"
],
"rules": {
"no-unused-import": "error",
"no-unused-import": "warn",
"compiler-version": [
"error",
">=0.8.0"
Expand Down
Binary file added anvil-test-state.json.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
# depends_on:
# foundry:
# condition: service_healthy
# command: "--rpc-url http://foundry:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --world-address 0x8a791620dd6260079bf849dc5567adc3f2fdc318"
# command: "--rpc-url http://foundry:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
# tty: true
postgres:
image: postgres
Expand Down
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"license": "CC-BY-NC-4.0",
"scripts": {
"lint": "solhint --config .solhint.json 'packages/**/*.sol'"
"lint": "solhint --config .solhint.json 'packages/**/*.sol'",
"deploy:local": "npm run deploy:local --workspaces --if-present",
"test": "npm run test --workspaces --if-present"
},
"dependencies": {
"@eveworld/common-constants": "0.0.13",
Expand All @@ -24,6 +26,7 @@
"solhint-plugin-mud": "2.2.9"
},
"workspaces": [
"packages/test-fixtures"
"packages/test-fixtures",
"packages/corporations"
]
}
38 changes: 38 additions & 0 deletions packages/corporations/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[profile.default]
solc = "0.8.24"
evm_version = "cancun"
ffi = false
fuzz_runs = 256
optimizer = true
optimizer_runs = 3000
verbosity = 2
src = "src"
example = "test"
out = "out"
allow_paths = [
# pnpm symlinks to the project root's node_modules
"../../node_modules",
]
remappings = [
"ds-test/=../../node_modules/ds-test/src/",
"forge-std/=../../node_modules/forge-std/src/",
"@latticexyz/=../../node_modules/@latticexyz/",
"@eveworld/=../../node_modules/@eveworld/",
]
extra_output_files = [
"abi",
"evm.bytecode"
]
fs_permissions = [{ access = "read", path = "./"}]

[profile.local]
# Local Anvil Instance
eth_rpc_url = "http://127.0.0.1:8545"

[profile.garnet]
# Public Testnet
eth_rpc_url = "https://rpc.garnetchain.com"

[profile.redstone]
# Public Mainnet
eth_rpc_url = "https://rpc.redstonechain.com"
28 changes: 28 additions & 0 deletions packages/corporations/mud.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineWorld } from "@latticexyz/world";

const namespace = process.env.CORPORATIONS_NAMESPACE || process.env.DEFAULT_NAMESPACE;

export default defineWorld({
namespace,
tables: {
CorporationsTable: {
schema: {
corpId: "uint256",
CEO: "uint256",
ticker: "bytes8",
claimedAt: "uint256",
name: "string",
homepage: "string",
description: "string",
},
key: ["corpId"],
},
},
systems: {
CorporationsSystem: {
deploy: {
registerWorldFunctions: false,
},
},
},
});
17 changes: 17 additions & 0 deletions packages/corporations/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "evedatacore-corporations",
"version": "1.0.0",
"description": "EVE Datacore corporations",
"main": "index.js",
"devDependencies": {},
"scripts": {
"build": "mud build",
"clean": "forge clean && rimraf src/codegen",
"dev:contracts": "export $(cat ../../.env.anvil | grep -v '^#' | xargs) && mud dev-contracts --rpc $RPC_URL --worldAddress ${WORLD_ADDRESS}",
"deploy:local": "export $(cat ../../.env.anvil | grep -v '^#' | xargs) && npm run build && mud deploy --profile=local --worldAddress ${WORLD_ADDRESS}",
"deploy:garnet": "export $(cat ../../.env.garnet | grep -v '^#' | xargs) && npm run build && mud deploy --profile=garnet --worldAddress ${WORLD_ADDRESS}",
"test": "export $(cat ../../.env.anvil | grep -v '^#' | xargs) && forge test --fork-url $RPC_URL"

},
"license": "CC-BY-NC-4.0"
}
6 changes: 6 additions & 0 deletions packages/corporations/src/codegen/index.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24;

/* Autogenerated file. Do not edit manually. */

import { CorporationsTable, CorporationsTableData } from "./tables/CorporationsTable.sol";
Loading
Loading