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
4 changes: 2 additions & 2 deletions apps/api-compile-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
},
"dependencies": {
"@cloudflare/containers": "0.3.7",
"hono": "4.13.2"
"hono": "4.13.5"
},
"devDependencies": {
"@types/node": "24.13.3",
"typescript": "7.0.2",
"wrangler": "4.123.0"
"wrangler": "4.127.1"
}
}
2 changes: 1 addition & 1 deletion apps/api-compile/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
FROM rust AS rust-builder
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
cargo install cargo-miden --version 0.9.2
cargo install cargo-miden --version 0.10.0-rc.1

WORKDIR /home/node/crates
COPY apps/api-compile/crates .
Expand Down
14 changes: 10 additions & 4 deletions apps/api-compile/__tests__/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ import { describe, expect, it } from "vitest";

const api = request(process.env.API_URL ?? "http://localhost:8080");

const networkId = process.env.NETWORK_ID ?? "mtst";

const otherNetworkId = "mlcl";

describe("GET /:networkId/import/:resourceId", () => {
it("imports an on-chain account", async () => {
const res = await api.get(`/mtst/import/${COUNTER_CONTRACT_ID_1}`);
const res = await api.get(`/${networkId}/import/${COUNTER_CONTRACT_ID_1}`);

const { code } = accounts[COUNTER_CONTRACT_ID_1];

Expand All @@ -21,7 +25,7 @@ describe("GET /:networkId/import/:resourceId", () => {
});

it("imports an on-chain note", async () => {
const res = await api.get(`/mtst/import/${COUNTER_NOTE_ID_1}`);
const res = await api.get(`/${networkId}/import/${COUNTER_NOTE_ID_1}`);

const { code } = notes[COUNTER_NOTE_ID_1];

Expand All @@ -31,14 +35,16 @@ describe("GET /:networkId/import/:resourceId", () => {
});

it("returns 404 for an account not found on the given network", async () => {
const res = await api.get(`/mdev/import/${COUNTER_CONTRACT_ID_1}`);
const res = await api.get(
`/${otherNetworkId}/import/${COUNTER_CONTRACT_ID_1}`,
);

expect(res.status).toBe(404);
expect(res.body).toHaveProperty("error");
});

it("returns 404 for a note not found on the given network", async () => {
const res = await api.get(`/mdev/import/${COUNTER_NOTE_ID_1}`);
const res = await api.get(`/${otherNetworkId}/import/${COUNTER_NOTE_ID_1}`);

expect(res.status).toBe(404);
expect(res.body).toHaveProperty("error");
Expand Down
39 changes: 22 additions & 17 deletions apps/api-compile/__tests__/verify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const basicWalletDir = `${examplesDir}/basic-wallet`;

const api = request(process.env.API_URL ?? "http://localhost:8080");

const networkId = process.env.NETWORK_ID ?? "mtst";

const otherNetworkId = "mlcl";

describe("POST /verify", () => {
it("rejects requests with no files object", async () => {
const res = await api.post("/verify").send({});
Expand Down Expand Up @@ -76,10 +80,7 @@ describe("POST /verify", () => {
);
expect(files["Cargo.toml"]).toBeDefined();

const res = await api.post("/verify").send({
files,
networkId: "mtst",
});
const res = await api.post("/verify").send({ files, networkId });

expect(res.status).toBe(400);
expect(res.body).toHaveProperty("error", "missing resourceId");
Expand All @@ -96,7 +97,7 @@ describe("POST /verify", () => {

const res = await api
.post("/verify")
.send({ files, networkId: "mtst", resourceId, resource });
.send({ files, networkId, resourceId, resource });

expect(res.status).toBe(200);
expect(res.body).toHaveProperty("verified", true);
Expand All @@ -113,7 +114,7 @@ describe("POST /verify", () => {

const res = await api
.post("/verify")
.send({ files, networkId: "mtst", resourceId: COUNTER_CONTRACT_ID_1 });
.send({ files, networkId, resourceId: COUNTER_CONTRACT_ID_1 });

expect(res.status).toBe(200);
expect(res.body).toHaveProperty("verified", true);
Expand All @@ -130,7 +131,11 @@ describe("POST /verify", () => {

const res = await api
.post("/verify")
.send({ files, networkId: "mdev", resourceId: COUNTER_CONTRACT_ID_1 });
.send({
files,
networkId: otherNetworkId,
resourceId: COUNTER_CONTRACT_ID_1,
});

expect(res.status).toBe(500);
});
Expand All @@ -147,7 +152,7 @@ describe("POST /verify", () => {

const res = await api
.post("/verify")
.send({ files, networkId: "mtst", resourceId, resource });
.send({ files, networkId, resourceId, resource });

expect(res.status).toBe(200);
expect(res.body).toHaveProperty("verified", false);
Expand All @@ -161,7 +166,7 @@ describe("POST /verify", () => {

const res = await api
.post("/verify")
.send({ files, networkId: "mtst", resourceId: COUNTER_CONTRACT_ID_1 });
.send({ files, networkId, resourceId: COUNTER_CONTRACT_ID_1 });

expect(res.status).toBe(200);
expect(res.body).toHaveProperty("verified", true);
Expand All @@ -180,7 +185,7 @@ describe("POST /verify", () => {

const res = await api
.post("/verify")
.send({ files, entrypoint, networkId: "mtst", resourceId, resource });
.send({ files, entrypoint, networkId, resourceId, resource });

expect(res.status).toBe(200);
expect(res.body).toHaveProperty("verified", true);
Expand All @@ -197,7 +202,7 @@ describe("POST /verify", () => {
const res = await api.post("/verify").send({
files,
entrypoint,
networkId: "mtst",
networkId,
resourceId: COUNTER_NOTE_ID_1,
});

Expand All @@ -216,7 +221,7 @@ describe("POST /verify", () => {
const res = await api.post("/verify").send({
files,
entrypoint,
networkId: "mdev",
networkId: otherNetworkId,
resourceId: COUNTER_NOTE_ID_1,
});

Expand All @@ -229,14 +234,14 @@ describe("POST /verify", () => {
expect(files[`${entrypoint}/Cargo.toml`]).toBeDefined();
files[`${entrypoint}/src/lib.rs`] = files[
`${entrypoint}/src/lib.rs`
].replace("Felt::from_u32", "felt!");
].replace("felt!", "Felt::from_u32");

const resourceId = COUNTER_NOTE_ID_1;
const { resource } = notes[resourceId];

const res = await api
.post("/verify")
.send({ files, entrypoint, networkId: "mtst", resourceId, resource });
.send({ files, entrypoint, networkId, resourceId, resource });

expect(res.status).toBe(200);
expect(res.body).toHaveProperty("verified", false);
Expand All @@ -253,7 +258,7 @@ describe("POST /verify", () => {
const res = await api.post("/verify").send({
files,
entrypoint,
networkId: "mtst",
networkId,
resourceId: COUNT_READER_ID,
resource,
});
Expand All @@ -276,7 +281,7 @@ describe("POST /verify", () => {

const res = await api.post("/verify").send({
files,
networkId: "mtst",
networkId,
resourceId: BASIC_WALLET_ID_1,
resource,
});
Expand All @@ -297,7 +302,7 @@ describe("POST /verify", () => {

const res = await api.post("/verify").send({
files,
networkId: "mtst",
networkId,
resourceId: BASIC_WALLET_ID_1,
resource,
});
Expand Down
Loading