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
31 changes: 23 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
- next
workflow_dispatch:

env:
Expand All @@ -27,25 +28,35 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
node-version: '24'

- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: yarn install --immutable

- name: Extract Aztec version
id: aztec-version
run: |
VERSION=$(jq -r '.dependencies["@aztec/aztec.js"]' package.json)
VERSION_NO_V=${VERSION#v}
echo "version=$VERSION_NO_V" >> $GITHUB_OUTPUT
echo "Aztec version: $VERSION_NO_V"

- name: Install Aztec CLI
run: |
curl -s https://install.aztec.network > tmp.sh
bash tmp.sh <<< yes "yes"
export CI=1
export FOUNDRY_DIR="$HOME/.foundry"
echo "Running version-specific installer for ${{ steps.aztec-version.outputs.version }}..."
curl -fsSL "https://install.aztec.network/${{ steps.aztec-version.outputs.version }}/install" | VERSION="${{ steps.aztec-version.outputs.version }}" bash
echo "Installation completed"
ls -la ~/.aztec/versions/${{ steps.aztec-version.outputs.version }}/bin/

- name: Update path
run: echo "/home/runner/.aztec/bin" >> $GITHUB_PATH

- name: Set Aztec version
run: |
aztec-up ${{ vars.VERSION }}
echo "$HOME/.aztec/versions/${{ steps.aztec-version.outputs.version }}/bin" >> $GITHUB_PATH
echo "$HOME/.aztec/versions/${{ steps.aztec-version.outputs.version }}/node_modules/.bin" >> $GITHUB_PATH

- name: Compile contracts
run: yarn compile:contracts
Expand All @@ -59,7 +70,11 @@ jobs:
- name: Deploy to Vercel
id: deploy
run: |
DEPLOY_URL=$(vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }} --archive=tgz --yes)
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
DEPLOY_URL=$(vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }} --archive=tgz --yes)
else
DEPLOY_URL=$(vercel deploy --token=${{ secrets.VERCEL_TOKEN }} --archive=tgz --yes)
fi
echo "url=$DEPLOY_URL" >> $GITHUB_OUTPUT

- name: Comment deployment URL on PR
Expand Down
22 changes: 20 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
GregoSwap is a decentralized token swap application built on the Aztec blockchain. It demonstrates private token swaps using an Automated Market Maker (AMM), with a token faucet (drip) mechanism using proof-of-password.

**Key Features:**

- Private token swaps (GregoCoin ↔ GregoCoinPremium) via AMM
- Token faucet with proof-of-password (PoP) contract
- Multi-flow onboarding supporting embedded and external wallets
- Network switching (local sandbox / devnet)

**Tech Stack:**

- React 18 + TypeScript
- Material-UI (MUI) component library
- Vite build tooling
Expand Down Expand Up @@ -83,17 +85,19 @@ export const useSwapReducer = createReducerHook(swapReducer, swapActions, initia

// Usage in context:
const [state, actions] = useSwapReducer();
actions.setFromAmount('100'); // Type-safe, no dispatch() needed
actions.setFromAmount('100'); // Type-safe, no dispatch() needed
```

**Key benefits:**

- Type-safe action creators
- No dispatch callback boilerplate
- Actions bound automatically via `bindActions()`

### Reducer File Structure

Each reducer.ts exports:

- **State type and initial state** (e.g., `SwapState`, `initialSwapState`)
- **Actions object** with action creators (e.g., `swapActions`)
- **Action union type** via `ActionsFrom<typeof actions>`
Expand All @@ -107,11 +111,13 @@ Each reducer.ts exports:
**Purpose:** Network selection and configuration

**State:**

- `activeNetwork: NetworkConfig` - Currently selected network
- `availableNetworks: NetworkConfig[]` - All discovered networks
- `isLoading: boolean`

**Key behavior:**

- Loads network configs from `src/config/networks/deployed-addresses.json`
- Persists selection to localStorage
- Excludes local network in production builds
Expand All @@ -121,13 +127,15 @@ Each reducer.ts exports:
**Purpose:** Wallet instance management (embedded vs external)

**State:**

- `wallet: Wallet | null` - Active wallet
- `node: AztecNode | null` - Aztec node client
- `currentAddress: AztecAddress | null` - Selected account
- `isUsingEmbeddedWallet: boolean` - Wallet type flag
- `isLoading: boolean` / `error: string | null`

**Key methods:**

```typescript
discoverWallets(timeout?): DiscoverySession
initiateConnection(provider): Promise<PendingConnection>
Expand All @@ -139,6 +147,7 @@ onWalletDisconnect(callback): () => void // Returns unsubscribe
```

**Key behavior:**

- Auto-creates embedded wallet on network change
- Manages disconnect callback registry
- Reverts to embedded wallet on external disconnect
Expand All @@ -148,10 +157,12 @@ onWalletDisconnect(callback): () => void // Returns unsubscribe
**Purpose:** Contract instances and registration

**State:**

- `contracts: { gregoCoin, gregoCoinPremium, amm, pop }`
- `isLoading: boolean`

**Key methods:**

```typescript
registerBaseContracts(): Promise<void> // AMM + tokens
registerDripContracts(): Promise<void> // PoP contract
Expand All @@ -167,13 +178,15 @@ drip(password, recipient): Promise<TxReceipt>
**Purpose:** Orchestrates multi-step onboarding flow

**Status flow:**

```
idle → connecting → registering → simulating →
[if balance=0] → registering_drip → awaiting_drip → executing_drip →
completed
```

**State:**

- `status: OnboardingStatus` - Current flow state
- `result: OnboardingResult | null` - Simulation results
- `needsDrip: boolean` - User needs to claim tokens
Expand All @@ -183,6 +196,7 @@ completed
- `hasRegisteredBase/hasSimulated` - Tracking flags

**Key behavior:**

- Effects drive automatic state transitions
- Checks balance after simulation to determine drip need
- Persists completion to localStorage per address
Expand All @@ -192,13 +206,15 @@ completed
**Purpose:** Swap UI state and execution

**State:**

- `fromAmount: string` / `toAmount: string`
- `exchangeRate: number | null`
- `isLoadingRate: boolean`
- `phase: SwapPhase` - 'idle' | 'sending' | 'success' | 'error'
- `error: string | null`

**Computed values (in context):**

- `fromAmountUSD` / `toAmountUSD`
- `canSwap` - Whether swap button is enabled
- `isSwapping` - phase === 'sending'
Expand Down Expand Up @@ -387,6 +403,7 @@ yarn serve
## Theme (src/theme.ts)

**Color palette:**

- Primary: Chartreuse green (#D4FF28) - Aztec branded
- Secondary: Deep purple (#80336A)
- Background: Pure black (#000000)
Expand Down Expand Up @@ -423,6 +440,7 @@ Used for exchange rate calculations with 18 decimal precision.
## Common Pitfalls

1. **Don't use re-exports** - Import directly from specific files

```typescript
// WRONG
import { useWallet } from '../contexts';
Expand Down Expand Up @@ -459,7 +477,7 @@ Used for exchange rate calculations with 18 decimal precision.

## Version Information

- **Aztec SDK:** v4.0.0-nightly.20260126
- **Aztec SDK:** v4.0.0-nightly.20260204
- **React:** 18.3.1
- **Vite:** 7.1.4
- **Node.js:** v22+
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ curl -s https://install.aztec.network | bash

### 3. Set Aztec Version

The project uses Aztec version `v4.0.0-nightly.20260126`. Set it using:
The project uses Aztec version `v4.0.0-nightly.20260204`. Set it using:

```bash
aztec-up 4.0.0-nightly.20260126
aztec-up 4.0.0-nightly.20260204
```

## Development Setup
Expand Down
6 changes: 3 additions & 3 deletions contracts/proof_of_password/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type = "contract"
authors = [""]

[dependencies]
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v4.0.0-nightly.20260126", directory = "noir-projects/aztec-nr/aztec" }
token = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v4.0.0-nightly.20260126", directory = "noir-projects/noir-contracts/contracts/app/token_contract" }
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v4.0.0-nightly.20260204", directory = "noir-projects/aztec-nr/aztec" }
token = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v4.0.0-nightly.20260204", directory = "noir-projects/noir-contracts/contracts/app/token_contract" }
poseidon = { tag = "v0.1.1", git = "https://github.com/noir-lang/poseidon" }
compressed_string = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v4.0.0-nightly.20260126", directory = "noir-projects/aztec-nr/compressed-string" }
compressed_string = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v4.0.0-nightly.20260204", directory = "noir-projects/aztec-nr/compressed-string" }
2 changes: 1 addition & 1 deletion contracts/proof_of_password/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub contract ProofOfPassword {
use aztec::{
macros::{functions::{external, initializer, only_self}, storage::storage},
oracle::notes::set_sender_for_tags,
protocol_types::{address::AztecAddress, hash::poseidon2_hash, traits::{Serialize, ToField}},
protocol::{address::AztecAddress, hash::poseidon2_hash, traits::{Serialize, ToField}},
state_vars::PublicImmutable,
};
use compressed_string::FieldCompressedString;
Expand Down
4 changes: 1 addition & 3 deletions contracts/proof_of_password/src/test/mod.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use super::ProofOfPassword;
use aztec::{
protocol_types::address::AztecAddress, test::helpers::test_environment::TestEnvironment,
};
use aztec::{protocol::address::AztecAddress, test::helpers::test_environment::TestEnvironment};
use token::Token;

global PASSWORD: str<31> = "potato0000000000000000000000000";
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,29 @@
"serve": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"copy:dependencies": "cd contracts && aztec check && WORKDIR=$(pwd) && cd $HOME/nargo/github.com/AztecProtocol/aztec-packages/v4.0.0-nightly.20260126/noir-projects/noir-contracts && aztec compile --package token_contract && mkdir -p $WORKDIR/target && cp $HOME/nargo/github.com/AztecProtocol/aztec-packages/v4.0.0-nightly.20260126/noir-projects/noir-contracts/target/token_contract-Token.json $WORKDIR/target/token_contract-Token.json",
"copy:dependencies": "cd contracts && aztec check && WORKDIR=$(pwd) && cd $HOME/nargo/github.com/AztecProtocol/aztec-packages/v4.0.0-nightly.20260204/noir-projects/noir-contracts && aztec compile --package token_contract && mkdir -p $WORKDIR/target && cp $HOME/nargo/github.com/AztecProtocol/aztec-packages/v4.0.0-nightly.20260204/noir-projects/noir-contracts/target/token_contract-Token.json $WORKDIR/target/token_contract-Token.json",
"compile:contracts": "cd contracts && aztec compile --package proof_of_password && aztec codegen ./target/proof_of_password-ProofOfPassword.json",
"test": "cd contracts && aztec test",
"preview": "vite preview",
"deploy:local": "node --experimental-transform-types scripts/deploy.ts --network local",
"deploy:devnet": "node --experimental-transform-types scripts/deploy.ts --network devnet",
"deploy:nextnet": "node --experimental-transform-types scripts/deploy.ts --network nextnet",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
"local-aztec:enable": "node scripts/toggle-local-aztec.js enable && corepack yarn install",
"local-aztec:disable": "node scripts/toggle-local-aztec.js disable && corepack yarn install",
"local-aztec:status": "node scripts/toggle-local-aztec.js status"
},
"dependencies": {
"@aztec/accounts": "v4.0.0-nightly.20260126",
"@aztec/aztec.js": "v4.0.0-nightly.20260126",
"@aztec/constants": "v4.0.0-nightly.20260126",
"@aztec/entrypoints": "v4.0.0-nightly.20260126",
"@aztec/foundation": "v4.0.0-nightly.20260126",
"@aztec/noir-contracts.js": "v4.0.0-nightly.20260126",
"@aztec/pxe": "v4.0.0-nightly.20260126",
"@aztec/stdlib": "v4.0.0-nightly.20260126",
"@aztec/wallet-sdk": "v4.0.0-nightly.20260126",
"@aztec/accounts": "v4.0.0-nightly.20260204",
"@aztec/aztec.js": "v4.0.0-nightly.20260204",
"@aztec/constants": "v4.0.0-nightly.20260204",
"@aztec/entrypoints": "v4.0.0-nightly.20260204",
"@aztec/foundation": "v4.0.0-nightly.20260204",
"@aztec/noir-contracts.js": "v4.0.0-nightly.20260204",
"@aztec/pxe": "v4.0.0-nightly.20260204",
"@aztec/stdlib": "v4.0.0-nightly.20260204",
"@aztec/wallet-sdk": "v4.0.0-nightly.20260204",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@mui/icons-material": "^6.3.1",
Expand All @@ -43,7 +44,7 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@aztec/test-wallet": "v4.0.0-nightly.20260126",
"@aztec/test-wallet": "v4.0.0-nightly.20260204",
"@eslint/js": "^9.18.0",
"@playwright/test": "1.49.0",
"@types/buffer-json": "^2",
Expand Down
Loading