Skip to content
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Run migrations
run: |
cd backend
cargo install sqlx-cli --no-default-features --features postgres,native-tls --locked
sqlx migrate run
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test

- name: Install dependencies
run: |
cd backend
cargo build
cargo build
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test

Expand All @@ -119,7 +119,7 @@ jobs:
- name: Run tests
run: |
cd backend
cargo test
cargo test
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
Expand All @@ -138,7 +138,7 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
components: forge, cast, anvil, chisel
cache: true

- name: Cache Foundry
uses: actions/cache@v3
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Deploy Backend to Heroku

on:
push:
branches: [main]
paths:
- "backend/**"
- ".github/workflows/deploy-backend.yml"

jobs:
deploy-backend:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Detect backend changes
id: changes
uses: dorny/paths-filter@v3
with:
token: ${{ github.token }}
filters: |
backend:
- 'backend/Dockerfile'
- 'backend/Cargo.toml'
- 'backend/Cargo.lock'
- 'backend/src/**'
- 'backend/migrations/**'
- 'backend/rustfmt.toml'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: steps.changes.outputs.backend == 'true'

- name: Install Heroku CLI
run: |
curl https://cli-assets.heroku.com/install.sh | sh
if: steps.changes.outputs.backend == 'true'

- name: Heroku Container Registry login
env:
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
echo "$HEROKU_API_KEY" | docker login -u "$HEROKU_EMAIL" --password-stdin registry.heroku.com
if: steps.changes.outputs.backend == 'true'

- name: Build and push (linux/amd64)
env:
HEROKU_BACKEND_APP: ${{ secrets.HEROKU_BACKEND_APP }}
run: |
docker buildx build \
--platform linux/amd64 \
-t registry.heroku.com/${HEROKU_BACKEND_APP}/web \
-f backend/Dockerfile backend \
--push
if: steps.changes.outputs.backend == 'true'

- name: Release on Heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_BACKEND_APP: ${{ secrets.HEROKU_BACKEND_APP }}
run: |
heroku container:release web -a "${HEROKU_BACKEND_APP}"
if: steps.changes.outputs.backend == 'true'
69 changes: 69 additions & 0 deletions .github/workflows/deploy-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy Frontend to Heroku

on:
push:
branches: [main]
paths:
- "frontend/**"
- ".github/workflows/deploy-frontend.yml"

jobs:
deploy-frontend:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Detect frontend changes
id: changes
uses: dorny/paths-filter@v3
with:
token: ${{ github.token }}
filters: |
frontend:
- 'frontend/Dockerfile'
- 'frontend/package.json'
- 'frontend/package-lock.json'
- 'frontend/astro.config.mjs'
- 'frontend/src/**'
- 'frontend/public/**'
- 'frontend/vitest.config.ts'
- 'frontend/tsconfig.json'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: steps.changes.outputs.frontend == 'true'

- name: Install Heroku CLI
run: |
curl https://cli-assets.heroku.com/install.sh | sh
if: steps.changes.outputs.frontend == 'true'

- name: Heroku Container Registry login
env:
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
echo "$HEROKU_API_KEY" | docker login -u "$HEROKU_EMAIL" --password-stdin registry.heroku.com
if: steps.changes.outputs.frontend == 'true'

- name: Build and push (linux/amd64)
env:
HEROKU_FRONTEND_APP: ${{ secrets.HEROKU_FRONTEND_APP }}
run: |
docker buildx build \
--platform linux/amd64 \
-t registry.heroku.com/${HEROKU_FRONTEND_APP}/web \
-f frontend/Dockerfile frontend \
--push
if: steps.changes.outputs.frontend == 'true'

- name: Release on Heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_FRONTEND_APP: ${{ secrets.HEROKU_FRONTEND_APP }}
run: |
heroku container:release web -a "${HEROKU_FRONTEND_APP}"
if: steps.changes.outputs.frontend == 'true'
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM rust:latest AS build
WORKDIR /app
ENV SQLX_OFFLINE=true
COPY . .
RUN cargo build --release

Expand Down
3 changes: 2 additions & 1 deletion backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ async fn main() -> anyhow::Result<()> {

let app = create_app(pool).await;

let addr = SocketAddr::from(([0, 0, 0, 0], 3001));
let port = env::var("PORT").unwrap_or_else(|_| "3001".to_string());
let addr = SocketAddr::from(([0, 0, 0, 0], port.parse::<u16>().unwrap()));
tracing::info!("Server listening on {}", addr);

let listener = tokio::net::TcpListener::bind(&addr).await?;
Expand Down
6 changes: 3 additions & 3 deletions frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PUBLIC_WALLET_CONNECT_PROJECT_ID=your_project_id_here
PUBLIC_API_URL=http://localhost:3001

# Contract addresses (values for amoy)
PUBLIC_BADGE_REGISTRY_ADDRESS=0x7e67100ce4bc2640f50c47d2dd3eebc749d8f52e
PUBLIC_BADGE_REGISTRY_ADDRESS=0xc142ab6b4688b7b81cb4cc8b305f517bba3bfd25
PUBLIC_EAS_CONTRACT_ADDRESS=0xb101275a60d8bfb14529C421899aD7CA1Ae5B5Fc
PUBLIC_ACTIVITY_TOKEN_ADDRESS=0x5f0a5293e33af3806ed34ba7dc139c8d3c39f310
PUBLIC_SCHEMA_ID=0x7b0ac75049ac0cf0a8f6606194f9ff2b892bed81560a7d84d484f96c788042cc
PUBLIC_ACTIVITY_TOKEN_ADDRESS=0x5db978bc69e54250f577ed343273508baea136cd
PUBLIC_SCHEMA_ID=0xb167f07504166f717f2a2710dbcfbfdf8fad6e8c6128c1a7fa80768f61b1d0b2
6 changes: 3 additions & 3 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ FROM node:20-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app ./
ENV PORT=8080
EXPOSE 8080
CMD ["node", "server.js"]
ENV HOST=0.0.0.0
# keep CMD as:
CMD ["node", "./dist/server/entry.mjs"]
6 changes: 3 additions & 3 deletions the-guild-smart-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ For detailed frontend integration instructions, see [INTEGRATION.md](./INTEGRATI
Salt: "theguild_v_0.1.0"

TheGuildActivityToken
https://amoy.polygonscan.com/address/0x5f0a5293e33af3806ed34ba7dc139c8d3c39f310
https://amoy.polygonscan.com/address/0x5db978bc69e54250f577ed343273508baea136cd

TheGuildBadgeRegistry
https://amoy.polygonscan.com/address/0x7e67100ce4bc2640f50c47d2dd3eebc749d8f52e
https://amoy.polygonscan.com/address/0xc142ab6b4688b7b81cb4cc8b305f517bba3bfd25

EAS Schema ID:
0x7b0ac75049ac0cf0a8f6606194f9ff2b892bed81560a7d84d484f96c788042cc
0xb167f07504166f717f2a2710dbcfbfdf8fad6e8c6128c1a7fa80768f61b1d0b2

## Foundry Usage

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {console} from "forge-std/console.sol";
contract FullDeploymentScript is Script {
function run() public {
EAS eas;
bytes32 salt = bytes32("theguild_v_0.1.0");
bytes32 salt = bytes32("theguild_v_0.1.1");
// EAS addresses per https://github.com/ethereum-attestation-service/eas-contracts deployments
// Base mainnet (8453) and Base Goerli/Sepolia (84531/84532) use the canonical predeploy 0x...21
// Optimism mainnet (10) and OP Sepolia (11155420) also use canonical 0x...21
Expand Down
Loading