Skip to content
Open
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
2 changes: 2 additions & 0 deletions Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["contracts/ecdsa_k_eth_signer_account"]
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
"test:coverage": "vitest run --coverage",
"test:unit": "vitest run tests/unit",
"test:integration": "vitest run tests/integration",
"test:e2e": "yarn prep-test && yarn playwright test",
"test:e2e": "yarn prep-test && yarn playwright test --project=chromium",
"lint": "eslint src && prettier --check ./src",
"lint:fix": "eslint src --fix && prettier --write ./src"
},
"dependencies": {
"@azguardwallet/client": "0.6.0",
"@azguardwallet/types": "0.6.0",
"@aztec/accounts": "3.0.0-devnet.20251212",
"@aztec/aztec": "3.0.0-devnet.20251212",
"@aztec/aztec.js": "3.0.0-devnet.20251212",
"@aztec/constants": "3.0.0-devnet.20251212",
"@aztec/foundation": "3.0.0-devnet.20251212",
Expand Down Expand Up @@ -71,6 +70,7 @@
"@types/react-dom": "19.1.7",
"@vitejs/plugin-react": "5.0.1",
"@vitest/ui": "3.2.4",
"@wonderland/walletless": "1.0.0",
"assert": "2.1.0",
"buffer": "6.0.3",
"crypto-browserify": "3.12.1",
Expand Down Expand Up @@ -108,6 +108,7 @@
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
"resolutions": {
"systeminformation": "5.27.14"
"systeminformation": "5.27.14",
"@wonderland/walletless/viem": "2.41.2"
}
}
8 changes: 6 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export default defineConfig({
: 1,
reporter: 'list',
use: {
baseURL: 'http://127.0.0.1:3000',
baseURL: 'http://localhost:3000',
headless: !!process.env.CI,
launchOptions: {
devtools: !process.env.CI,
},
},
expect: {
timeout: 20_000,
Expand All @@ -35,7 +39,7 @@ export default defineConfig({

webServer: {
command: 'PORT=3000 yarn serve',
url: 'http://127.0.0.1:3000',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 30_000,
},
Expand Down
119 changes: 29 additions & 90 deletions scripts/build-contracts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
// Run with: tsx scripts/build-contracts.ts [--force]
// This script copies artifacts from @defi-wonderland/aztec-standards and compiles local contracts

Expand Down Expand Up @@ -77,9 +78,7 @@ function copyFiles(
copiedCount++;
}

console.log(
` 📊 Copied ${copiedCount} items, skipped ${skippedCount} existing items`
);
console.log(` 📊 Copied ${copiedCount} items, skipped ${skippedCount} existing items`);
return copiedCount;
}

Expand All @@ -100,36 +99,28 @@ function cleanOldTsWrappers(artifactsDir: string, contracts: string[]): void {
/**
* Copy aztec-standards artifacts from node_modules
*/
function copyAztecStandardsArtifacts(
projectRoot: string,
forceOverwrite: boolean
): void {
function copyAztecStandardsArtifacts(projectRoot: string, forceOverwrite: boolean): void {
console.log('\n📦 Copying aztec-standards artifacts from node_modules...');

const npmPackagePath = path.join(projectRoot, NPM_PACKAGE_PATH);

if (!fs.existsSync(npmPackagePath)) {
console.error(
`❌ Package @defi-wonderland/aztec-standards not found at ${npmPackagePath}`
);
console.error(`❌ Package @defi-wonderland/aztec-standards not found at ${npmPackagePath}`);
console.error(' Run: yarn add @defi-wonderland/aztec-standards');
throw new Error('Missing aztec-standards package');
}

// Filter for Dripper and Token contracts only
const contractFilter = (file: string) =>
(file.includes('Dripper') || file.includes('Token')) &&
!file.endsWith('.bak');
(file.includes('Dripper') || file.includes('Token')) && !file.endsWith('.bak');

// Copy TypeScript wrappers from artifacts/
const artifactsDir = path.join(projectRoot, ARTIFACTS_OUTPUT_DIR);

// Remove old .ts files first to avoid tsx resolution conflicts
cleanOldTsWrappers(artifactsDir, ['Dripper', 'Token']);

console.log(
`\n 📁 Copying TypeScript wrappers to ${ARTIFACTS_OUTPUT_DIR}/`
);
console.log(`\n 📁 Copying TypeScript wrappers to ${ARTIFACTS_OUTPUT_DIR}/`);
copyFiles(
path.join(npmPackagePath, 'artifacts'),
artifactsDir,
Expand All @@ -151,92 +142,39 @@ function copyAztecStandardsArtifacts(
}

/**
* Compile local contracts (e.g., ECDSA account contract)
* Compile local contracts using workspace Nargo.toml at root level
*/
function compileLocalContracts(
projectRoot: string,
forceOverwrite: boolean
): boolean {
const contractsDir = path.join(projectRoot, LOCAL_CONTRACTS_DIR);

if (!fs.existsSync(contractsDir)) {
console.log(`⚠️ No local contracts directory found at ${contractsDir}`);
return true;
}

// Find all contract directories (those with Nargo.toml)
const contractDirs = fs.readdirSync(contractsDir).filter((dir) => {
const nargoPath = path.join(contractsDir, dir, 'Nargo.toml');
return fs.existsSync(nargoPath);
});
function compileLocalContracts(projectRoot: string, forceOverwrite: boolean): boolean {
const workspaceNargo = path.join(projectRoot, 'Nargo.toml');

if (contractDirs.length === 0) {
console.log('📭 No local contracts found to compile');
return true;
if (!fs.existsSync(workspaceNargo)) {
console.error(`❌ No workspace Nargo.toml found at ${projectRoot}`);
return false;
}

console.log(`\n🔨 Processing ${contractDirs.length} local contract(s)...`);
let allSuccess = true;

for (const contractDir of contractDirs) {
const contractPath = path.join(contractsDir, contractDir);
const targetDir = path.join(contractPath, 'target');
const artifactsDir = path.join(projectRoot, ARTIFACTS_OUTPUT_DIR);
console.log('\n🔨 Compiling contracts from workspace...');

console.log(`\n 📦 Processing ${contractDir}...`);

// Check if we already have compiled artifacts
const hasExistingArtifacts =
fs.existsSync(targetDir) &&
fs
.readdirSync(targetDir)
.some((f) => f.endsWith('.json') && !f.endsWith('.bak'));
// Compile all contracts from workspace root
if (!tryRun(`cd "${projectRoot}" && aztec compile`)) {
console.error(' ❌ Failed to compile contracts');
return false;
}

// Try to compile (using nargo or aztec-nargo)
let compiled = false;
console.log(' ✅ Contracts compiled successfully');

// Try nargo first (standard Noir compiler)
if (tryRun(`cd "${contractPath}" && nargo compile 2>/dev/null`)) {
console.log(` ✅ ${contractDir} compiled with nargo`);
compiled = true;
}
// Try aztec-nargo if available
else if (
tryRun(`cd "${contractPath}" && aztec-nargo compile 2>/dev/null`)
) {
console.log(` ✅ ${contractDir} compiled with aztec-nargo`);
compiled = true;
}
// Try aztec compile as fallback
else if (tryRun(`cd "${contractPath}" && aztec compile . 2>/dev/null`)) {
console.log(` ✅ ${contractDir} compiled with aztec compile`);
compiled = true;
}

if (!compiled) {
if (hasExistingArtifacts) {
console.log(` ⚠️ Compilation failed, but using existing artifacts`);
} else {
console.warn(
` ❌ Failed to compile ${contractDir} (no existing artifacts)`
);
allSuccess = false;
continue;
}
}
// TODO: This might not be needed because `yarn codegen` takes care of using a path relative to the target/
// Copy artifacts from target/ to src/artifacts/
const targetDir = path.join(projectRoot, 'target');
const artifactsDir = path.join(projectRoot, ARTIFACTS_OUTPUT_DIR);

// Copy artifacts to src/artifacts
if (fs.existsSync(targetDir)) {
copyFiles(
targetDir,
artifactsDir,
forceOverwrite,
(file) => file.endsWith('.json') && !file.endsWith('.bak')
);
}
if (fs.existsSync(targetDir)) {
copyFiles(targetDir, artifactsDir, forceOverwrite, (file) =>
file.endsWith('.json') && !file.endsWith('.bak')
);
}

return allSuccess;
return true;
}

async function main() {
Expand Down Expand Up @@ -278,3 +216,4 @@ async function main() {
}

main();

6 changes: 3 additions & 3 deletions src/config/deployableContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Deployable Contracts Configuration.
* See docs/contract-ui.md for documentation.
*/
import tokenDevnet from '../artifacts/devnet/token_contract-Token.json';
import dripperSandbox from '../artifacts/sandbox/dripper-Dripper.json';
import tokenSandbox from '../artifacts/sandbox/token_contract-Token.json';
import tokenDevnet from '../artifacts/devnet/token_contract-Token.json' with { type: 'json' };
import dripperSandbox from '../artifacts/sandbox/dripper-Dripper.json' with { type: 'json' };
import tokenSandbox from '../artifacts/sandbox/token_contract-Token.json' with { type: 'json' };
import {
loadDeployableContracts,
type DeployableContractConfig,
Expand Down
4 changes: 2 additions & 2 deletions src/config/deployments/sandbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"salt": "0x0000000000000000000000000000000000000000000000000000000000000539"
},
"deployer": "0x18b1cbdcec832adbece3fb2aafa7cd0a6b7a892b76f85efc1499593b2556b20f",
"proverEnabled": true,
"deployedAt": "2025-12-26T07:56:35.696Z"
"proverEnabled": false,
"deployedAt": "2026-01-10T22:18:05.860Z"
}
4 changes: 2 additions & 2 deletions src/config/preconfiguredContracts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import tokenDevnet from '../artifacts/devnet/token_contract-Token.json';
import tokenSandbox from '../artifacts/sandbox/token_contract-Token.json';
import tokenDevnet from '../artifacts/devnet/token_contract-Token.json' with { type: 'json' };
import tokenSandbox from '../artifacts/sandbox/token_contract-Token.json' with { type: 'json' };
import type { AztecNetwork } from './networks/constants';

export type PreconfiguredContract = {
Expand Down
24 changes: 24 additions & 0 deletions src/hooks/contracts/useWriteContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,30 @@ export const useWriteContract = (options: UseWriteContractOptions = {}) => {
}

const tx = method(...(args as unknown[]));

// Simulate first to catch revert reasons before sending
console.log(
`[useWriteContract] Simulating ${String(functionName)}...`
);
try {
const simulateResult = await (
tx as { simulate: (opts: unknown) => Promise<unknown> }
).simulate({ from: account.getAddress() });
console.log(
`[useWriteContract] Simulation successful:`,
simulateResult
);
} catch (simErr) {
const simErrorMsg =
simErr instanceof Error ? simErr.message : 'Simulation failed';
console.error(
`[useWriteContract] Simulation failed for ${String(functionName)}:`,
simErr
);
setError(simErrorMsg);
return { success: false, error: `Simulation failed: ${simErrorMsg}` };
}

const sentTx = (
tx as {
send: (opts: unknown) => {
Expand Down
10 changes: 10 additions & 0 deletions src/hooks/mutations/useDripper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ export const useDripper = (options: UseDripperOptions = {}) => {
throw new Error('Account not available');
}

// Simulate first to catch revert reasons before sending
console.log('[useDripper] Simulating drip_to_public...', {
dripperAddress,
tokenAddress,
amount: amount.toString(),
account: account.getAddress().toString(),
});

const result = await writeContract({
contract: DripperContract,
address: dripperAddress,
Expand All @@ -80,9 +88,11 @@ export const useDripper = (options: UseDripperOptions = {}) => {
});

if (!result.success) {
console.error('[useDripper] drip_to_public failed:', result.error);
throw new Error(result.error ?? 'drip_to_public failed');
}

console.log('[useDripper] drip_to_public success:', result);
invalidateBalance();
},
onSuccess: () => options.onDripToPublicSuccess?.(),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const getEnv = (): AppEnv => {

return {
aztecNodeUrl: raw.VITE_AZTEC_NODE_URL,
proverEnabled: raw.VITE_PROVER_ENABLED !== 'false',
proverEnabled: raw.VITE_PROVER_ENABLED === 'true',
embeddedAccountSecretPhrase: raw.VITE_EMBEDDED_ACCOUNT_SECRET_PHRASE,
embeddedAccountSecretKey: raw.VITE_EMBEDDED_ACCOUNT_SECRET_KEY,
commonSalt: raw.VITE_COMMON_SALT,
Expand Down
54 changes: 0 additions & 54 deletions tests/e2e/e2e.spec.ts

This file was deleted.

Loading