Skip to content

Commit

Permalink
Merge pull request #211 from hypercerts-org/fix/seed_arbitrum
Browse files Browse the repository at this point in the history
feat(arbOne): update seed script with arb contracts and update gha
  • Loading branch information
bitbeckers authored Sep 12, 2024
2 parents dfe01a1 + 27499d9 commit 257fd4d
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 17 deletions.
29 changes: 28 additions & 1 deletion .github/workflows/supabase-ci-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
3 changes: 3 additions & 0 deletions .github/workflows/supabase-ci-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: verify supabase types
on:
pull_request:
branches-ignore:
- main
- develop

env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
76 changes: 65 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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();
};
Expand Down
11 changes: 10 additions & 1 deletion src/clients/evmClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createPublicClient, fallback, http } from "viem";
import {
arbitrum,
arbitrumSepolia,
base,
baseSepolia,
Expand All @@ -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) => {
Expand All @@ -28,6 +29,8 @@ const selectedNetwork = (chainId: number) => {
return base;
case 42220:
return celo;
case 42161:
return arbitrum;
case 421614:
return arbitrumSepolia;
case 84532:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions src/utils/getDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}`);
}
Expand Down

0 comments on commit 257fd4d

Please sign in to comment.