From c63984e10a79ba495c00db6c92cf401900331643 Mon Sep 17 00:00:00 2001 From: EcosystemNetwork Date: Sun, 29 Mar 2026 19:17:27 -0700 Subject: [PATCH 1/5] deploy --- .github/workflows/ci.yml | 48 +++------------------------------------- SwarmApp/netlify.toml | 27 ---------------------- netlify.toml | 5 ----- vercel.json | 7 ++++++ 4 files changed, 10 insertions(+), 77 deletions(-) delete mode 100644 SwarmApp/netlify.toml delete mode 100644 netlify.toml create mode 100644 vercel.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 480bf98f..6d78c7e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,50 +73,8 @@ jobs: - run: npm ci - run: npm run build - # ── Deploy to Netlify from GitHub Actions (Netlify OOMs on 573 routes) ── - - deploy: - name: Deploy (Netlify) - needs: [build, hub-test] - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - runs-on: ubuntu-latest - defaults: - run: - working-directory: SwarmApp - env: - NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} - NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }} - NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }} - NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }} - NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }} - NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }} - NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} - NEXT_PUBLIC_THIRDWEB_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_THIRDWEB_CLIENT_ID }} - NEXT_PUBLIC_APP_DOMAIN: ${{ secrets.NEXT_PUBLIC_APP_DOMAIN }} - NEXT_PUBLIC_ADMIN_ADDRESS: ${{ secrets.NEXT_PUBLIC_ADMIN_ADDRESS }} - NEXT_PUBLIC_HEDERA_CHAIN_ID: ${{ secrets.NEXT_PUBLIC_HEDERA_CHAIN_ID }} - NEXT_PUBLIC_HEDERA_RPC_URL: ${{ secrets.NEXT_PUBLIC_HEDERA_RPC_URL }} - NEXT_PUBLIC_HEDERA_TREASURY: ${{ secrets.NEXT_PUBLIC_HEDERA_TREASURY }} - NEXT_PUBLIC_HEDERA_AGENT_REGISTRY: ${{ secrets.NEXT_PUBLIC_HEDERA_AGENT_REGISTRY }} - NEXT_PUBLIC_HEDERA_ASN_REGISTRY: ${{ secrets.NEXT_PUBLIC_HEDERA_ASN_REGISTRY }} - NEXT_PUBLIC_HEDERA_TASK_BOARD: ${{ secrets.NEXT_PUBLIC_HEDERA_TASK_BOARD }} - NEXT_PUBLIC_HEDERA_AGENT_NFT: ${{ secrets.NEXT_PUBLIC_HEDERA_AGENT_NFT }} - NEXT_PUBLIC_HEDERA_MOCK_LINK: ${{ secrets.NEXT_PUBLIC_HEDERA_MOCK_LINK }} - NEXT_PUBLIC_GITHUB_APP_SLUG: ${{ secrets.NEXT_PUBLIC_GITHUB_APP_SLUG }} - NEXT_PUBLIC_SUPER_ADMINS: ${{ secrets.NEXT_PUBLIC_SUPER_ADMINS }} - NEXT_PUBLIC_OPENCLAW_WORKSPACE: ${{ secrets.NEXT_PUBLIC_OPENCLAW_WORKSPACE }} - NEXT_PUBLIC_TREASURY_ADDRESS: ${{ secrets.NEXT_PUBLIC_TREASURY_ADDRESS }} - NEXT_PUBLIC_THIRDWEB_SECRET: ${{ secrets.NEXT_PUBLIC_THIRDWEB_SECRET }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - cache-dependency-path: SwarmApp/package-lock.json - - run: npm ci - - name: Build and Deploy to Netlify - run: npx netlify-cli deploy --prod --build --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} + # Deploy handled by Vercel — auto-deploys on push to main. + # Set env vars in Vercel Dashboard → Settings → Environment Variables. # ─── Hub jobs ────────────────────────────────────────────────────────────────── @@ -183,7 +141,7 @@ jobs: gate: name: Release Gate - needs: [build, hub-test, deploy] + needs: [build, hub-test] if: always() runs-on: ubuntu-latest steps: diff --git a/SwarmApp/netlify.toml b/SwarmApp/netlify.toml deleted file mode 100644 index 8f3ce7b0..00000000 --- a/SwarmApp/netlify.toml +++ /dev/null @@ -1,27 +0,0 @@ -[build] - # Netlify auto-builds are skipped (ignore = exit 0). - # Builds run in GitHub Actions via: netlify-cli deploy --prod --build - ignore = "exit 0" - command = "npm run build" - publish = ".next" - -[build.environment] - NODE_OPTIONS = "--max-old-space-size=4096" - SECRETS_SCAN_SMART_DETECTION_ENABLED = "false" - -# ── Security headers ── -[[headers]] - for = "/*" - [headers.values] - X-Frame-Options = "SAMEORIGIN" - X-Content-Type-Options = "nosniff" - Referrer-Policy = "strict-origin-when-cross-origin" - Permissions-Policy = "camera=(), microphone=(), geolocation=()" - Content-Security-Policy = "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://*.thirdweb.com https://*.thirdwebcdn.com https://*.google.com https://*.gstatic.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com data:; img-src 'self' data: blob: https: http:; media-src 'self' data: blob:; connect-src 'self' https: wss:; frame-src 'self' https://*.thirdweb.com https://accounts.google.com https://embedded-wallet.thirdweb.com; worker-src 'self' blob:; object-src 'none'; base-uri 'self'" - -# ── Canonical domain: redirect www → apex ── -[[redirects]] - from = "https://www.swarmprotocol.fun/*" - to = "https://swarmprotocol.fun/:splat" - status = 301 - force = true diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index fa53a260..00000000 --- a/netlify.toml +++ /dev/null @@ -1,5 +0,0 @@ -[build] - base = "SwarmApp" - ignore = "exit 0" - command = "npm run build" - publish = "SwarmApp/.next" diff --git a/vercel.json b/vercel.json new file mode 100644 index 00000000..5e902cff --- /dev/null +++ b/vercel.json @@ -0,0 +1,7 @@ +{ + "buildCommand": "npm run build", + "outputDirectory": ".next", + "installCommand": "npm ci", + "framework": "nextjs", + "rootDirectory": "SwarmApp" +} \ No newline at end of file From cdbffc8aa1037453b9f6aa2fb4eddc6ceb5e3892 Mon Sep 17 00:00:00 2001 From: EcosystemNetwork Date: Sun, 29 Mar 2026 19:19:24 -0700 Subject: [PATCH 2/5] fix: simplify vercel.json, set root dir in dashboard --- vercel.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vercel.json b/vercel.json index 5e902cff..7f2984e0 100644 --- a/vercel.json +++ b/vercel.json @@ -1,7 +1,3 @@ { - "buildCommand": "npm run build", - "outputDirectory": ".next", - "installCommand": "npm ci", - "framework": "nextjs", - "rootDirectory": "SwarmApp" + "framework": "nextjs" } \ No newline at end of file From 6f7338a8c067479afb46a8feffe32f1972c233bc Mon Sep 17 00:00:00 2001 From: EcosystemNetwork Date: Mon, 30 Mar 2026 03:58:20 -0700 Subject: [PATCH 3/5] netlify --- SwarmApp/netlify.toml | 28 ++ contracts/test/SwarmContracts.test.ts | 472 ++++++++++++++++++++++++++ netlify.toml | 6 + 3 files changed, 506 insertions(+) create mode 100644 SwarmApp/netlify.toml create mode 100644 contracts/test/SwarmContracts.test.ts create mode 100644 netlify.toml diff --git a/SwarmApp/netlify.toml b/SwarmApp/netlify.toml new file mode 100644 index 00000000..7bb442e3 --- /dev/null +++ b/SwarmApp/netlify.toml @@ -0,0 +1,28 @@ +[build] + # Build skipped — handled by GitHub Actions (Netlify OOMs on 573 routes). + # GH Actions runs `npm run build` then `netlify-cli deploy --prod --dir=.next`. + # The plugin-nextjs is NOT needed here — `netlify deploy` uploads pre-built output directly. + ignore = "exit 0" + command = "echo 'Skipped — deployed from GitHub Actions'" + publish = ".next" + +[build.environment] + NODE_OPTIONS = "--max-old-space-size=3072" + SECRETS_SCAN_SMART_DETECTION_ENABLED = "false" + +# ── Security headers ── +[[headers]] + for = "/*" + [headers.values] + X-Frame-Options = "SAMEORIGIN" + X-Content-Type-Options = "nosniff" + Referrer-Policy = "strict-origin-when-cross-origin" + Permissions-Policy = "camera=(), microphone=(), geolocation=()" + Content-Security-Policy = "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://*.thirdweb.com https://*.thirdwebcdn.com https://*.google.com https://*.gstatic.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com data:; img-src 'self' data: blob: https: http:; media-src 'self' data: blob:; connect-src 'self' https: wss:; frame-src 'self' https://*.thirdweb.com https://accounts.google.com https://embedded-wallet.thirdweb.com; worker-src 'self' blob:; object-src 'none'; base-uri 'self'" + +# ── Canonical domain: redirect www → apex ── +[[redirects]] + from = "https://www.swarmprotocol.fun/*" + to = "https://swarmprotocol.fun/:splat" + status = 301 + force = true diff --git a/contracts/test/SwarmContracts.test.ts b/contracts/test/SwarmContracts.test.ts new file mode 100644 index 00000000..045827eb --- /dev/null +++ b/contracts/test/SwarmContracts.test.ts @@ -0,0 +1,472 @@ +/** + * Contract Test Suite — PRD 4 + * + * Tests: SwarmAgentRegistryLink, SwarmTaskBoardLink + * + * Run: npx hardhat test --network hardhat + */ + +import { ethers } from "hardhat"; +import { expect } from "chai"; +import { loadFixture, time } from "@nomicfoundation/hardhat-toolbox/network-helpers"; + +// ── Fixtures ───────────────────────────────────────────────────────────────── + +async function deployRegistryFixture() { + const [owner, agent1, agent2, other] = await ethers.getSigners(); + + const Registry = await ethers.getContractFactory("SwarmAgentRegistryLink"); + const registry = await Registry.deploy(); + await registry.waitForDeployment(); + + return { registry, owner, agent1, agent2, other }; +} + +async function deployTaskBoardFixture() { + const [owner, poster, agent, other] = await ethers.getSigners(); + + // Deploy MockLINK + const MockLINK = await ethers.getContractFactory("MockLINK"); + const link = await MockLINK.deploy(); + await link.waitForDeployment(); + + // Deploy TaskBoard with LINK address + const TaskBoard = await ethers.getContractFactory("SwarmTaskBoardLink"); + const board = await TaskBoard.deploy(await link.getAddress()); + await board.waitForDeployment(); + + // Fund poster with 1000 LINK + const LINK_1000 = ethers.parseEther("1000"); + await link.transfer(poster.address, LINK_1000); + + return { board, link, owner, poster, agent, other }; +} + +// ═══════════════════════════════════════════════════════════════════════════ +// SwarmAgentRegistryLink +// ═══════════════════════════════════════════════════════════════════════════ + +describe("SwarmAgentRegistryLink", () => { + // ── Deployment ───────────────────────────────────────────────────────── + + it("deploys and sets owner", async () => { + const { registry, owner } = await loadFixture(deployRegistryFixture); + expect(await registry.owner()).to.equal(owner.address); + }); + + it("starts with zero agents", async () => { + const { registry } = await loadFixture(deployRegistryFixture); + expect(await registry.agentCount()).to.equal(0n); + }); + + // ── registerAgent ─────────────────────────────────────────────────────── + + it("registers an agent and emits AgentRegistered", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await expect( + registry.connect(agent1).registerAgent("Alpha", "nlp,code", "ASN-001", 100n) + ) + .to.emit(registry, "AgentRegistered") + .withArgs(agent1.address, "Alpha", "ASN-001", await latestTimestamp()); + }); + + it("stores correct defaults after registration (creditScore 680, trustScore 50)", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("Alpha", "nlp", "ASN-001", 0n); + const a = await registry.getAgent(agent1.address); + + expect(a.creditScore).to.equal(680); + expect(a.trustScore).to.equal(50); + expect(a.active).to.equal(true); + }); + + it("increments agentCount", async () => { + const { registry, agent1, agent2 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "code", "ASN-001", 0n); + await registry.connect(agent2).registerAgent("A2", "nlp", "ASN-002", 0n); + + expect(await registry.agentCount()).to.equal(2n); + }); + + it("rejects double-registration", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("Alpha", "nlp", "ASN-001", 0n); + + await expect( + registry.connect(agent1).registerAgent("Alpha2", "code", "ASN-002", 0n) + ).to.be.revertedWith("Already registered"); + }); + + it("rejects duplicate ASN", async () => { + const { registry, agent1, agent2 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "nlp", "ASN-DUP", 0n); + + await expect( + registry.connect(agent2).registerAgent("A2", "code", "ASN-DUP", 0n) + ).to.be.revertedWith("ASN already taken"); + }); + + it("rejects empty ASN", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await expect( + registry.connect(agent1).registerAgent("A1", "nlp", "", 0n) + ).to.be.revertedWith("ASN required"); + }); + + // ── Permission checks ──────────────────────────────────────────────────── + + it("registerAgentFor is owner-only", async () => { + const { registry, agent1, agent2 } = await loadFixture(deployRegistryFixture); + + await expect( + registry.connect(agent1).registerAgentFor(agent2.address, "A2", "nlp", "ASN-003", 0n) + ).to.be.reverted; + }); + + it("owner can register on behalf of another address", async () => { + const { registry, owner, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(owner).registerAgentFor(agent1.address, "A1", "nlp", "ASN-004", 0n); + expect(await registry.isRegistered(agent1.address)).to.equal(true); + }); + + // ── updateSkills ───────────────────────────────────────────────────────── + + it("registered agent can update skills", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "nlp", "ASN-001", 0n); + + await expect(registry.connect(agent1).updateSkills("nlp,code,vision")) + .to.emit(registry, "SkillsUpdated") + .withArgs(agent1.address, "nlp,code,vision", await latestTimestamp()); + + const a = await registry.getAgent(agent1.address); + expect(a.skills).to.equal("nlp,code,vision"); + }); + + it("unregistered address cannot update skills", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await expect(registry.connect(agent1).updateSkills("nlp")).to.be.revertedWith("Not registered"); + }); + + // ── updateCredit ────────────────────────────────────────────────────────── + + it("owner can update credit score within bounds (300-900)", async () => { + const { registry, owner, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "nlp", "ASN-001", 0n); + await registry.connect(owner).updateCredit(agent1.address, 750, 80); + + const a = await registry.getAgent(agent1.address); + expect(a.creditScore).to.equal(750); + expect(a.trustScore).to.equal(80); + }); + + it("rejects credit score below 300", async () => { + const { registry, owner, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "nlp", "ASN-001", 0n); + + await expect(registry.connect(owner).updateCredit(agent1.address, 299, 50)) + .to.be.revertedWith("Credit 300-900"); + }); + + it("rejects trust score above 100", async () => { + const { registry, owner, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "nlp", "ASN-001", 0n); + + await expect(registry.connect(owner).updateCredit(agent1.address, 700, 101)) + .to.be.revertedWith("Trust 0-100"); + }); + + it("non-owner cannot update credit", async () => { + const { registry, agent1, agent2 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "nlp", "ASN-001", 0n); + + await expect(registry.connect(agent2).updateCredit(agent1.address, 700, 70)) + .to.be.reverted; + }); + + // ── deactivateAgent ─────────────────────────────────────────────────────── + + it("agent can deactivate itself", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "nlp", "ASN-001", 0n); + await registry.connect(agent1).deactivateAgent(); + + expect(await registry.isRegistered(agent1.address)).to.equal(false); + }); + + it("deactivation emits AgentDeactivated", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("A1", "nlp", "ASN-001", 0n); + + await expect(registry.connect(agent1).deactivateAgent()) + .to.emit(registry, "AgentDeactivated") + .withArgs(agent1.address, await latestTimestamp()); + }); + + it("unregistered agent cannot deactivate", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await expect(registry.connect(agent1).deactivateAgent()) + .to.be.revertedWith("Not registered"); + }); + + // ── getAgentByASN ───────────────────────────────────────────────────────── + + it("looks up agent by ASN", async () => { + const { registry, agent1 } = await loadFixture(deployRegistryFixture); + + await registry.connect(agent1).registerAgent("Alpha", "nlp", "ASN-LOOKUP", 0n); + const a = await registry.getAgentByASN("ASN-LOOKUP"); + + expect(a.agentAddress).to.equal(agent1.address); + expect(a.name).to.equal("Alpha"); + }); + + it("reverts for unknown ASN", async () => { + const { registry } = await loadFixture(deployRegistryFixture); + + await expect(registry.getAgentByASN("NONEXISTENT")).to.be.revertedWith("ASN not found"); + }); +}); + +// ═══════════════════════════════════════════════════════════════════════════ +// SwarmTaskBoardLink +// ═══════════════════════════════════════════════════════════════════════════ + +describe("SwarmTaskBoardLink", () => { + const BUDGET = ethers.parseEther("10"); + const ONE_DAY = 86400; + + async function postTask(board: any, link: any, poster: any, title = "Test Task") { + const deadline = (await time.latest()) + ONE_DAY; + await link.connect(poster).approve(await board.getAddress(), BUDGET); + await board.connect(poster).postTask( + poster.address, + title, + "Description", + "nlp,code", + deadline, + BUDGET + ); + return { taskId: 0, deadline }; + } + + // ── Deployment ───────────────────────────────────────────────────────── + + it("deploys with correct LINK address", async () => { + const { board, link } = await loadFixture(deployTaskBoardFixture); + expect(await board.linkToken()).to.equal(await link.getAddress()); + }); + + it("starts with zero tasks", async () => { + const { board } = await loadFixture(deployTaskBoardFixture); + expect(await board.taskCount()).to.equal(0n); + }); + + // ── postTask ──────────────────────────────────────────────────────────── + + it("posts a task, transfers LINK, emits TaskPosted", async () => { + const { board, link, poster } = await loadFixture(deployTaskBoardFixture); + const { deadline } = await postTask(board, link, poster); + + await expect( + (async () => { + const deadline2 = (await time.latest()) + ONE_DAY; + await link.connect(poster).approve(await board.getAddress(), BUDGET); + return board.connect(poster).postTask(poster.address, "Task 2", "Desc", "nlp", deadline2, BUDGET); + })() + ).to.emit(board, "TaskPosted"); + + expect(await board.taskCount()).to.be.greaterThan(0n); + }); + + it("task starts in Open status", async () => { + const { board, link, poster } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + const task = await board.getTask(0); + expect(task.status).to.equal(0); // TaskStatus.Open + }); + + it("rejects zero budget", async () => { + const { board, link, poster } = await loadFixture(deployTaskBoardFixture); + const deadline = (await time.latest()) + ONE_DAY; + + await expect( + board.connect(poster).postTask(poster.address, "Task", "Desc", "nlp", deadline, 0n) + ).to.be.revertedWith("Budget must be > 0"); + }); + + it("rejects past deadline", async () => { + const { board, link, poster } = await loadFixture(deployTaskBoardFixture); + const pastDeadline = (await time.latest()) - 1; + await link.connect(poster).approve(await board.getAddress(), BUDGET); + + await expect( + board.connect(poster).postTask(poster.address, "Task", "Desc", "nlp", pastDeadline, BUDGET) + ).to.be.revertedWith("Deadline must be in the future"); + }); + + // ── claimTask ─────────────────────────────────────────────────────────── + + it("agent can claim an open task, emits TaskClaimed", async () => { + const { board, link, poster, agent } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + + await expect(board.connect(agent).claimTask(0)) + .to.emit(board, "TaskClaimed") + .withArgs(0, agent.address, await latestTimestamp()); + + const task = await board.getTask(0); + expect(task.status).to.equal(1); // TaskStatus.Claimed + expect(task.claimedBy).to.equal(agent.address); + }); + + it("poster cannot claim own task", async () => { + const { board, link, poster } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + + await expect(board.connect(poster).claimTask(0)) + .to.be.revertedWith("Cannot claim own task"); + }); + + it("cannot claim already-claimed task", async () => { + const { board, link, poster, agent, other } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + await board.connect(agent).claimTask(0); + + await expect(board.connect(other).claimTask(0)) + .to.be.revertedWith("Not open"); + }); + + it("cannot claim expired task", async () => { + const { board, link, poster, agent } = await loadFixture(deployTaskBoardFixture); + const deadline = (await time.latest()) + ONE_DAY; + await link.connect(poster).approve(await board.getAddress(), BUDGET); + await board.connect(poster).postTask(poster.address, "T", "D", "nlp", deadline, BUDGET); + + await time.increase(ONE_DAY + 1); + + await expect(board.connect(agent).claimTask(0)) + .to.be.revertedWith("Expired"); + }); + + // ── submitDelivery / approveDelivery ───────────────────────────────────── + + it("full happy path: post → claim → submit → approve → payout", async () => { + const { board, link, poster, agent } = await loadFixture(deployTaskBoardFixture); + const boardAddr = await board.getAddress(); + + await postTask(board, link, poster); + await board.connect(agent).claimTask(0); + + const deliveryHash = ethers.keccak256(ethers.toUtf8Bytes("delivery-content")); + await expect(board.connect(agent).submitDelivery(0, deliveryHash)) + .to.emit(board, "DeliverySubmitted") + .withArgs(0, agent.address, deliveryHash, await latestTimestamp()); + + const agentBalanceBefore = await link.balanceOf(agent.address); + + await expect(board.connect(poster).approveDelivery(0)) + .to.emit(board, "DeliveryApproved") + .withArgs(0, agent.address, BUDGET, await latestTimestamp()); + + const agentBalanceAfter = await link.balanceOf(agent.address); + expect(agentBalanceAfter - agentBalanceBefore).to.equal(BUDGET); + + const task = await board.getTask(0); + expect(task.status).to.equal(2); // TaskStatus.Completed + }); + + it("only poster can approve delivery", async () => { + const { board, link, poster, agent, other } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + await board.connect(agent).claimTask(0); + await board.connect(agent).submitDelivery(0, ethers.keccak256(ethers.toUtf8Bytes("d"))); + + await expect(board.connect(other).approveDelivery(0)) + .to.be.revertedWith("Only poster can approve"); + }); + + it("cannot approve without delivery", async () => { + const { board, link, poster, agent } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + await board.connect(agent).claimTask(0); + + await expect(board.connect(poster).approveDelivery(0)) + .to.be.revertedWith("No delivery submitted"); + }); + + it("only assigned agent can submit delivery", async () => { + const { board, link, poster, agent, other } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + await board.connect(agent).claimTask(0); + + await expect( + board.connect(other).submitDelivery(0, ethers.keccak256(ethers.toUtf8Bytes("d"))) + ).to.be.revertedWith("Not assigned agent"); + }); + + // ── disputeDelivery ─────────────────────────────────────────────────────── + + it("poster can dispute a claimed task", async () => { + const { board, link, poster, agent } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + await board.connect(agent).claimTask(0); + + await expect(board.connect(poster).disputeDelivery(0)) + .to.emit(board, "DeliveryDisputed") + .withArgs(0, poster.address, await latestTimestamp()); + + const task = await board.getTask(0); + expect(task.status).to.equal(4); // TaskStatus.Disputed + }); + + it("non-poster cannot dispute", async () => { + const { board, link, poster, agent, other } = await loadFixture(deployTaskBoardFixture); + await postTask(board, link, poster); + await board.connect(agent).claimTask(0); + + await expect(board.connect(other).disputeDelivery(0)) + .to.be.revertedWith("Only poster can dispute"); + }); + + // ── getOpenTasks ────────────────────────────────────────────────────────── + + it("getOpenTasks returns only non-expired open tasks", async () => { + const { board, link, poster, agent } = await loadFixture(deployTaskBoardFixture); + + // Post 2 tasks + const deadline1 = (await time.latest()) + ONE_DAY; + await link.connect(poster).approve(await board.getAddress(), BUDGET * 2n); + await board.connect(poster).postTask(poster.address, "T1", "D", "nlp", deadline1, BUDGET); + await board.connect(poster).postTask(poster.address, "T2", "D", "nlp", deadline1, BUDGET); + + // Claim task 0 → removes from open + await board.connect(agent).claimTask(0); + + const open = await board.getOpenTasks(); + expect(open.length).to.equal(1); + expect(open[0].title).to.equal("T2"); + }); +}); + +// ── helpers ─────────────────────────────────────────────────────────────────── + +async function latestTimestamp(): Promise { + return BigInt(await time.latest()); +} diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 00000000..f5ae9161 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,6 @@ +[build] + base = "SwarmApp" + # Build handled by GitHub Actions — Netlify OOMs on 573 routes. + # SwarmApp/netlify.toml has ignore = "exit 0" to skip auto-builds. + command = "echo 'Skipped — deployed from GitHub Actions'" + publish = "SwarmApp/.next" From c5fbe233c23ed4a4387b963c8fdb0857718e1800 Mon Sep 17 00:00:00 2001 From: EcosystemNetwork Date: Mon, 30 Mar 2026 04:01:18 -0700 Subject: [PATCH 4/5] netlify --- .github/workflows/ci.yml | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d78c7e7..7832348e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,8 +73,55 @@ jobs: - run: npm ci - run: npm run build - # Deploy handled by Vercel — auto-deploys on push to main. - # Set env vars in Vercel Dashboard → Settings → Environment Variables. + # ── Deploy to Netlify from GitHub Actions (Netlify OOMs on 573 routes) ── + + deploy: + name: Deploy (Netlify) + needs: [build, hub-test] + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + runs-on: ubuntu-latest + defaults: + run: + working-directory: SwarmApp + env: + NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} + NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }} + NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }} + NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }} + NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }} + NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }} + NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} + NEXT_PUBLIC_THIRDWEB_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_THIRDWEB_CLIENT_ID }} + NEXT_PUBLIC_APP_DOMAIN: ${{ secrets.NEXT_PUBLIC_APP_DOMAIN }} + NEXT_PUBLIC_ADMIN_ADDRESS: ${{ secrets.NEXT_PUBLIC_ADMIN_ADDRESS }} + NEXT_PUBLIC_HEDERA_CHAIN_ID: ${{ secrets.NEXT_PUBLIC_HEDERA_CHAIN_ID }} + NEXT_PUBLIC_HEDERA_RPC_URL: ${{ secrets.NEXT_PUBLIC_HEDERA_RPC_URL }} + NEXT_PUBLIC_HEDERA_TREASURY: ${{ secrets.NEXT_PUBLIC_HEDERA_TREASURY }} + NEXT_PUBLIC_HEDERA_AGENT_REGISTRY: ${{ secrets.NEXT_PUBLIC_HEDERA_AGENT_REGISTRY }} + NEXT_PUBLIC_HEDERA_ASN_REGISTRY: ${{ secrets.NEXT_PUBLIC_HEDERA_ASN_REGISTRY }} + NEXT_PUBLIC_HEDERA_TASK_BOARD: ${{ secrets.NEXT_PUBLIC_HEDERA_TASK_BOARD }} + NEXT_PUBLIC_HEDERA_AGENT_NFT: ${{ secrets.NEXT_PUBLIC_HEDERA_AGENT_NFT }} + NEXT_PUBLIC_HEDERA_MOCK_LINK: ${{ secrets.NEXT_PUBLIC_HEDERA_MOCK_LINK }} + NEXT_PUBLIC_LINK_TREASURY: ${{ secrets.NEXT_PUBLIC_LINK_TREASURY }} + NEXT_PUBLIC_LINK_AGENT_REGISTRY: ${{ secrets.NEXT_PUBLIC_LINK_AGENT_REGISTRY }} + NEXT_PUBLIC_LINK_ASN_REGISTRY: ${{ secrets.NEXT_PUBLIC_LINK_ASN_REGISTRY }} + NEXT_PUBLIC_LINK_TASK_BOARD: ${{ secrets.NEXT_PUBLIC_LINK_TASK_BOARD }} + NEXT_PUBLIC_GITHUB_APP_SLUG: ${{ secrets.NEXT_PUBLIC_GITHUB_APP_SLUG }} + NEXT_PUBLIC_SUPER_ADMINS: ${{ secrets.NEXT_PUBLIC_SUPER_ADMINS }} + NEXT_PUBLIC_OPENCLAW_WORKSPACE: ${{ secrets.NEXT_PUBLIC_OPENCLAW_WORKSPACE }} + NEXT_PUBLIC_TREASURY_ADDRESS: ${{ secrets.NEXT_PUBLIC_TREASURY_ADDRESS }} + NEXT_PUBLIC_THIRDWEB_SECRET: ${{ secrets.NEXT_PUBLIC_THIRDWEB_SECRET }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: SwarmApp/package-lock.json + - run: npm ci + - run: npm run build + - name: Deploy to Netlify + run: npx netlify-cli deploy --prod --dir=.next --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} # ─── Hub jobs ────────────────────────────────────────────────────────────────── @@ -141,15 +188,15 @@ jobs: gate: name: Release Gate - needs: [build, hub-test] + needs: [build, hub-test, deploy] if: always() runs-on: ubuntu-latest steps: - name: All checks passed run: | - echo "✓ SwarmApp: lint, typecheck, test, build" + echo "✓ SwarmApp: lint, test, build" echo "✓ Hub: unit tests" - echo "✓ Contracts: compile + test" + echo "✓ Deploy: Netlify" echo "SHA: ${{ github.sha }}" echo "Ref: ${{ github.ref }}" echo "This commit is release-safe for staging/testnet deployment." From b96752d194b3a2228f19fd1ddf36e5e34dbd4a8e Mon Sep 17 00:00:00 2001 From: EcosystemNetwork Date: Mon, 30 Mar 2026 04:19:27 -0700 Subject: [PATCH 5/5] netlify --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7832348e..5515667d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: branches: [main] pull_request: branches: [main] + workflow_dispatch: concurrency: group: ci-${{ github.ref }}