diff --git a/spartan/terraform/deploy-release/main.tf b/spartan/terraform/deploy-release/main.tf index 5ea4cdc801b..73eba9e5b37 100644 --- a/spartan/terraform/deploy-release/main.tf +++ b/spartan/terraform/deploy-release/main.tf @@ -40,7 +40,7 @@ resource "helm_release" "aztec-gke-cluster" { upgrade_install = true # base values file - values = [file("../../aztec-network/values/${var.VALUES_FILE}"), "${var.VALUES_INLINE}"] + values = [file("../../aztec-network/values/${var.VALUES_FILE}")] set { name = "images.aztec.image" diff --git a/spartan/terraform/deploy-release/variables.tf b/spartan/terraform/deploy-release/variables.tf index c277d49e803..0dff0d4509b 100644 --- a/spartan/terraform/deploy-release/variables.tf +++ b/spartan/terraform/deploy-release/variables.tf @@ -14,12 +14,6 @@ variable "VALUES_FILE" { type = string } -variable "VALUES_INLINE" { - description = "Inline values to set in a cluster" - type = string - default = "" -} - variable "AZTEC_DOCKER_IMAGE" { description = "Docker image to use for the aztec network" type = string diff --git a/yarn-project/aztec-faucet/package.json b/yarn-project/aztec-faucet/package.json index f88bd735eca..2285a4087c0 100644 --- a/yarn-project/aztec-faucet/package.json +++ b/yarn-project/aztec-faucet/package.json @@ -70,6 +70,7 @@ "@aztec/l1-artifacts": "workspace:^", "@koa/cors": "^5.0.0", "koa": "^2.14.2", + "koa-bodyparser": "^4.4.1", "koa-router": "^12.0.0", "viem": "^2.7.15", "zod": "^3.23.8" @@ -77,6 +78,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@types/jest": "^29.5.0", + "@types/koa-bodyparser": "^4.3.12", "@types/node": "^18.7.23", "jest": "^29.5.0", "ts-node": "^10.9.1", diff --git a/yarn-project/aztec-faucet/src/http.ts b/yarn-project/aztec-faucet/src/http.ts index 18e8609c472..7e2e10723d6 100644 --- a/yarn-project/aztec-faucet/src/http.ts +++ b/yarn-project/aztec-faucet/src/http.ts @@ -5,6 +5,7 @@ import { type ApiSchemaFor, schemas } from '@aztec/foundation/schemas'; import cors from '@koa/cors'; import { createServer } from 'http'; import Koa from 'koa'; +import bodyParser from 'koa-bodyparser'; import Router from 'koa-router'; import { z } from 'zod'; @@ -17,7 +18,7 @@ export function createFaucetHttpServer(faucet: Faucet, apiPrefix = '', logger = const { asset } = ctx.query; if (typeof asset !== 'string') { - throw new Error(`Bad asset: ${asset}`); + throw new Error(`Bad asset: [${asset}]`); } await faucet.send(EthAddress.fromString(address), asset); @@ -25,6 +26,29 @@ export function createFaucetHttpServer(faucet: Faucet, apiPrefix = '', logger = ctx.status = 200; }); + const L1AssetRequestSchema = z.object({ + address: z.string().transform(str => EthAddress.fromString(str)), + amount: z.string().transform(str => BigInt(str)), + }); + + router.post('/l1-asset', async ctx => { + if (!ctx.request.body) { + throw new Error('Invalid request body'); + } + + const result = L1AssetRequestSchema.safeParse(ctx.request.body); + + if (!result.success) { + throw new Error(`Invalid request: ${result.error.message}`); + } + + const { address, amount } = result.data; + + await faucet.addL1Asset({ address, amount }); + + ctx.status = 200; + }); + const app = new Koa(); app.on('error', error => { @@ -42,6 +66,7 @@ export function createFaucetHttpServer(faucet: Faucet, apiPrefix = '', logger = }); app.use(cors()); + app.use(bodyParser()); app.use(router.routes()); app.use(router.allowedMethods()); diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 082b7b730b5..2a4d38a760d 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -129,9 +129,11 @@ __metadata: "@jest/globals": ^29.5.0 "@koa/cors": ^5.0.0 "@types/jest": ^29.5.0 + "@types/koa-bodyparser": ^4.3.12 "@types/node": ^18.7.23 jest: ^29.5.0 koa: ^2.14.2 + koa-bodyparser: ^4.4.1 koa-router: ^12.0.0 ts-node: ^10.9.1 typescript: ^5.0.4 @@ -5196,7 +5198,7 @@ __metadata: languageName: node linkType: hard -"@types/koa-bodyparser@npm:^4.3.10": +"@types/koa-bodyparser@npm:^4.3.10, @types/koa-bodyparser@npm:^4.3.12": version: 4.3.12 resolution: "@types/koa-bodyparser@npm:4.3.12" dependencies: @@ -13680,7 +13682,7 @@ __metadata: languageName: node linkType: hard -"koa-bodyparser@npm:^4.4.0": +"koa-bodyparser@npm:^4.4.0, koa-bodyparser@npm:^4.4.1": version: 4.4.1 resolution: "koa-bodyparser@npm:4.4.1" dependencies: