From e4a139ff3c232de3001bade9dba2261fb10023f8 Mon Sep 17 00:00:00 2001 From: bitbeckers Date: Fri, 13 Sep 2024 01:22:18 +0200 Subject: [PATCH 1/2] feat(arbOne): update seed script with arb contracts and update gha --- .github/workflows/supabase-ci-staging.yml | 29 ++++++++- package.json | 6 +- pnpm-lock.yaml | 76 +++++++++++++++++++---- seed.ts | 27 +++++++- src/clients/evmClient.ts | 11 +++- src/utils/getDeployment.ts | 16 +++++ 6 files changed, 148 insertions(+), 17 deletions(-) diff --git a/.github/workflows/supabase-ci-staging.yml b/.github/workflows/supabase-ci-staging.yml index b0e5b17..932443d 100644 --- a/.github/workflows/supabase-ci-staging.yml +++ b/.github/workflows/supabase-ci-staging.yml @@ -38,4 +38,31 @@ jobs: - uses: actions/checkout@v4 - uses: supabase/setup-cli@v1 - run: supabase link --project-ref $PROJECT_ID - - run: supabase db push \ No newline at end of file + - run: supabase db push + + run-seed-script: + runs-on: ubuntu-latest + environment: staging + + env: + SUPABASE_CACHING_DB_URL: ${{ vars.SUPABASE_CACHING_DB_URL }} + SUPABASE_CACHING_SERVICE_API_KEY: ${{ secrets.SUPABASE_CACHING_SERVICE_API_KEY }} + OVERRIDE_LOCAL_DB_PROTECTION: "true" + + steps: + - uses: actions/checkout@v4 + - name: 'Install Node' + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + run_install: false + + - name: Install dependencies + run: pnpm install + + - name: Run seed script + run: npx tsx ./seed.ts diff --git a/package.json b/package.json index 7c843d6..7794c20 100644 --- a/package.json +++ b/package.json @@ -66,9 +66,9 @@ }, "dependencies": { "@hypercerts-org/chainsauce": "1.0.24", - "@hypercerts-org/contracts": "2.0.0-alpha.7", - "@hypercerts-org/marketplace-sdk": "^0.3.33", - "@hypercerts-org/sdk": "^2.1.1", + "@hypercerts-org/contracts": "2.0.0-alpha.8", + "@hypercerts-org/marketplace-sdk": "^0.3.35", + "@hypercerts-org/sdk": "^2.2.0-beta.2", "@opentelemetry/instrumentation": "^0.52.1", "@openzeppelin/merkle-tree": "^1.0.7", "@supabase/postgrest-js": "^1.15.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e9b35fd..3d4d005 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,14 +12,14 @@ importers: specifier: 1.0.24 version: 1.0.24(zod@3.23.8) '@hypercerts-org/contracts': - specifier: 2.0.0-alpha.7 - version: 2.0.0-alpha.7(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.5.25)(@types/node@20.11.19)(ethers@6.13.1)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2) + specifier: 2.0.0-alpha.8 + version: 2.0.0-alpha.8(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.5.25)(@types/node@20.11.19)(ethers@6.13.1)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2) '@hypercerts-org/marketplace-sdk': - specifier: ^0.3.33 - version: 0.3.33(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@types/node@20.11.19)(ethers@6.13.1)(graphql@16.8.1)(rollup@4.12.0)(svelte@4.2.18)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2) + specifier: ^0.3.35 + version: 0.3.35(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@types/node@20.11.19)(ethers@6.13.1)(graphql@16.8.1)(rollup@4.12.0)(svelte@4.2.18)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2) '@hypercerts-org/sdk': - specifier: ^2.1.1 - version: 2.1.1(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@types/node@20.11.19)(ethers@6.13.1)(graphql@16.8.1)(rollup@4.12.0)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2) + specifier: ^2.2.0-beta.2 + version: 2.2.0-beta.2(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@types/node@20.11.19)(ethers@6.13.1)(graphql@16.8.1)(rollup@4.12.0)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2) '@opentelemetry/instrumentation': specifier: ^0.52.1 version: 0.52.1(@opentelemetry/api@1.9.0) @@ -735,8 +735,11 @@ packages: '@hypercerts-org/contracts@2.0.0-alpha.7': resolution: {integrity: sha512-rnITsv1vcRsVtJxYCaHWXT9xk+5xjRRub1hJ9XqOrs0+HAvZTwBzTsoNWjjUlrW37loYHGxm5pRD+omFfeBbsw==} - '@hypercerts-org/marketplace-sdk@0.3.33': - resolution: {integrity: sha512-xbsG8fHUjDyTBRQ3FzDZbTnD/CnKU8iqPEJJn9lKwsHIXyf4q5iQSBwBi519Euh0Evi7e7jM5LGkydYmojCcJw==} + '@hypercerts-org/contracts@2.0.0-alpha.8': + resolution: {integrity: sha512-ZOZ2ByLeoc2rkvSAivyF/cZE6NYSUNYLE4oDgNHN+J/ONmxTCJCBYi92EDh+efnM/KFwsksdsIcA3TLw86bigA==} + + '@hypercerts-org/marketplace-sdk@0.3.35': + resolution: {integrity: sha512-s5k4SaNRxcKKuvTLgleoMXu6NlYmvZFx8gsiBjnbXSHYWWfyHUbF+ilAok/S1uMsDuxBQgAXO7hfj3V6WhaTVw==} engines: {node: '>= 16.15.1 <= 20.x'} peerDependencies: ethers: ^6.6.2 @@ -744,6 +747,9 @@ packages: '@hypercerts-org/sdk@2.1.1': resolution: {integrity: sha512-Wf/wZOvZfsj0Y/gVGHS8hWnLKlbN/AphLzDusX7KnhtygLC9KUnP8RnTPAAwVkd6ma4gFsVyzpKbCx2Ph7rKmw==} + '@hypercerts-org/sdk@2.2.0-beta.2': + resolution: {integrity: sha512-87nAidAyONkfBTB3bXmehCO+J6WqvrKoRt0OaRrPip60+MhipPZ9QhKQAK3dCxHbj8ZuPNaJwdNlPNuP6dlAXw==} + '@inquirer/confirm@3.0.0': resolution: {integrity: sha512-LHeuYP1D8NmQra1eR4UqvZMXwxEdDXyElJmmZfU44xdNLL6+GcQBS0uE16vyfZVjH8c22p9e+DStROfE/hyHrg==} engines: {node: '>=18'} @@ -5950,7 +5956,26 @@ snapshots: - webdriverio - zod - '@hypercerts-org/contracts@2.0.0-alpha.7(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.5.25)(@types/node@20.11.19)(ethers@6.13.1)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)': + '@hypercerts-org/contracts@2.0.0-alpha.7(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.6.5)(@types/node@20.11.19)(ethers@6.13.1)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2)': + dependencies: + '@tenderly/hardhat-tenderly': 2.3.0(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.6.5)(@types/node@20.11.19)(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)) + hardhat: 2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2) + transitivePeerDependencies: + - '@nomicfoundation/hardhat-ethers' + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - bufferutil + - c-kzg + - debug + - encoding + - ethers + - supports-color + - ts-node + - typescript + - utf-8-validate + + '@hypercerts-org/contracts@2.0.0-alpha.8(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.5.25)(@types/node@20.11.19)(ethers@6.13.1)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)': dependencies: '@tenderly/hardhat-tenderly': 2.3.0(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.5.25)(@types/node@20.11.19)(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)) hardhat: 2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2) @@ -5969,7 +5994,7 @@ snapshots: - typescript - utf-8-validate - '@hypercerts-org/contracts@2.0.0-alpha.7(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.6.5)(@types/node@20.11.19)(ethers@6.13.1)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2)': + '@hypercerts-org/contracts@2.0.0-alpha.8(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.6.5)(@types/node@20.11.19)(ethers@6.13.1)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2)': dependencies: '@tenderly/hardhat-tenderly': 2.3.0(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.6.5)(@types/node@20.11.19)(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)) hardhat: 2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2) @@ -5988,7 +6013,7 @@ snapshots: - typescript - utf-8-validate - '@hypercerts-org/marketplace-sdk@0.3.33(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@types/node@20.11.19)(ethers@6.13.1)(graphql@16.8.1)(rollup@4.12.0)(svelte@4.2.18)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2)': + '@hypercerts-org/marketplace-sdk@0.3.35(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@types/node@20.11.19)(ethers@6.13.1)(graphql@16.8.1)(rollup@4.12.0)(svelte@4.2.18)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2)': dependencies: '@hypercerts-org/sdk': 2.1.1(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@types/node@20.11.19)(ethers@6.13.1)(graphql@16.8.1)(rollup@4.12.0)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2) '@supabase/supabase-js': 2.44.2 @@ -6042,6 +6067,35 @@ snapshots: - typescript - utf-8-validate + '@hypercerts-org/sdk@2.2.0-beta.2(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@types/node@20.11.19)(ethers@6.13.1)(graphql@16.8.1)(rollup@4.12.0)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2)': + dependencies: + '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) + '@hypercerts-org/contracts': 2.0.0-alpha.8(@nomicfoundation/hardhat-ethers@3.0.6(ethers@6.13.1)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.2))(typescript@5.5.2)))(@swc/core@1.6.5)(@types/node@20.11.19)(ethers@6.13.1)(ts-node@10.9.2(@swc/core@1.5.25)(@types/node@20.11.19)(typescript@5.5.4))(typescript@5.5.2) + '@openzeppelin/merkle-tree': 1.0.7 + '@swc/core': 1.6.5 + ajv: 8.16.0 + axios: 1.7.2(debug@4.3.5) + dotenv: 16.4.5 + rollup-plugin-swc3: 0.11.2(@swc/core@1.6.5)(rollup@4.12.0) + viem: 2.19.7(typescript@5.5.2)(zod@3.23.8) + zod: 3.23.8 + transitivePeerDependencies: + - '@nomicfoundation/hardhat-ethers' + - '@swc/helpers' + - '@swc/wasm' + - '@types/node' + - bufferutil + - c-kzg + - debug + - encoding + - ethers + - graphql + - rollup + - supports-color + - ts-node + - typescript + - utf-8-validate + '@inquirer/confirm@3.0.0': dependencies: '@inquirer/core': 7.0.0 diff --git a/seed.ts b/seed.ts index 49385f8..bdb6f12 100644 --- a/seed.ts +++ b/seed.ts @@ -91,6 +91,12 @@ const main = async () => { console.log("🕊️ Seeding contracts..."); await supabase.from("contracts").upsert( [ + { + chain_id: 42161, + contract_address: "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", + start_block: 251729365, + contract_slug: minterContractSlug, + }, { chain_id: 421614, contract_address: "0x0A00a2f09cd37B24E7429c5238323bfebCfF3Ed9", @@ -174,23 +180,36 @@ const main = async () => { revocable: true, }); - await supabase.from("supported_schemas").select("*"); + const { data: supportedSchemas } = await supabase + .from("supported_schemas") + .select("*"); // combine all contract_ids with the event_ids console.log("🕊️ Seeding contract_events..."); const { data: events } = await supabase.from("events").select("*"); const { data: contracts } = await supabase.from("contracts").select("*"); + if (!supportedSchemas) { + console.error("No supported schemas found in the database"); + process.exit(); + } + + console.log(`✅ Found ${supportedSchemas.length} supported schemas`); + if (!events) { console.error("No events found in the database"); process.exit(); } + console.log(`✅ Found ${events.length} events`); + if (!contracts) { console.error("No contracts found in the database"); process.exit(); } + console.log(`✅ Found ${contracts.length} contracts`); + const contractEvents = events.map((event) => { const contractsWithMatchingSlug = contracts.filter( (contract) => contract.contract_slug === event.contract_slug, @@ -215,6 +234,12 @@ const main = async () => { console.error("Error seeding contract events", error); process.exit(); } + + const { data: _contractEvents } = await supabase + .from("contract_events") + .select("*"); + + console.log(`✅ Found ${_contractEvents.length} contract events`); console.log("🚀 Database seeded successfully!"); process.exit(); }; diff --git a/src/clients/evmClient.ts b/src/clients/evmClient.ts index 18c754a..8522564 100644 --- a/src/clients/evmClient.ts +++ b/src/clients/evmClient.ts @@ -1,5 +1,6 @@ import { createPublicClient, fallback, http } from "viem"; import { + arbitrum, arbitrumSepolia, base, baseSepolia, @@ -17,7 +18,7 @@ import { export const getSupportedChains = () => { if (environment === Environment.TEST) return [11155111, 84532, 421614]; - if (environment === Environment.PRODUCTION) return [10, 8453, 42220]; + if (environment === Environment.PRODUCTION) return [10, 8453, 42220, 42161]; }; const selectedNetwork = (chainId: number) => { @@ -28,6 +29,8 @@ const selectedNetwork = (chainId: number) => { return base; case 42220: return celo; + case 42161: + return arbitrum; case 421614: return arbitrumSepolia; case 84532: @@ -47,6 +50,8 @@ export const alchemyUrl = (chainId: number) => { return `https://base-mainnet.g.alchemy.com/v2/${alchemyApiKey}`; case 42220: return; + case 42161: + return `https://arb-mainnet.g.alchemy.com/v2/${alchemyApiKey}`; case 421614: return `https://arb-sepolia.g.alchemy.com/v2/${alchemyApiKey}`; case 84532: @@ -66,6 +71,8 @@ const infuraUrl = (chainId: number) => { return; case 42220: return `https://celo-mainnet.infura.io/v3/${infuraApiKey}`; + case 42161: + return `https://arbitrum-mainnet.infura.io/v3/${infuraApiKey}`; case 421614: return `https://arbitrum-sepolia.infura.io/v3/${infuraApiKey}`; case 84532: @@ -85,6 +92,8 @@ const drpcUrl = (chainId: number) => { return `https://lb.drpc.org/ogrpc?network=base&dkey=${drpcApiPkey}`; case 42220: return `https://lb.drpc.org/ogrpc?network=celo&dkey=${drpcApiPkey}`; + case 42161: + return `https://lb.drpc.org/ogrpc?network=arbitrum&dkey=${drpcApiPkey}`; case 421614: return `https://lb.drpc.org/ogrpc?network=arbitrum-sepolia&dkey=${drpcApiPkey}`; case 84532: diff --git a/src/utils/getDeployment.ts b/src/utils/getDeployment.ts index c06be23..e72e8ed 100644 --- a/src/utils/getDeployment.ts +++ b/src/utils/getDeployment.ts @@ -51,6 +51,14 @@ export const getDeployment = ( schemaRegistryAddress: "", chainId, }; + case 42161: + return { + ...DEPLOYMENTS["42161"], + startBlock: 251729365n, + easAddress: "0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458", + schemaRegistryAddress: "0xA310da9c5B885E7fb3fbA9D66E9Ba6Df512b78eB", + chainId, + }; // Testnets case 11155111: return { @@ -68,6 +76,14 @@ export const getDeployment = ( schemaRegistryAddress: "0x4200000000000000000000000000000000000020", chainId, }; + case 421614: + return { + ...DEPLOYMENTS["421614"], + startBlock: 69066523n, + easAddress: "", + schemaRegistryAddress: "", + chainId, + }; default: throw new Error(`Unsupported chain ID: ${chainId}`); } From 27499d9c1bcb59f42141519f9d5ac3ca6caf249b Mon Sep 17 00:00:00 2001 From: bitbeckers Date: Fri, 13 Sep 2024 01:26:36 +0200 Subject: [PATCH 2/2] feat(gha): skip duplicate actions on main and develop branch --- .github/workflows/supabase-ci-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/supabase-ci-test.yml b/.github/workflows/supabase-ci-test.yml index 6193ded..31d148e 100644 --- a/.github/workflows/supabase-ci-test.yml +++ b/.github/workflows/supabase-ci-test.yml @@ -1,6 +1,9 @@ name: verify supabase types on: pull_request: + branches-ignore: + - main + - develop env: SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}