Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: index both mainnet and sepolia #1092

Merged
merged 6 commits into from
Feb 3, 2025
Merged
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
73 changes: 37 additions & 36 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,44 @@ on:
- master

jobs:
deploy_api_mainnet:
name: Deploy API to mainnet
environment: api_mainnet
concurrency:
group: api_mainnet
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Deploy if files have changed
run: ./scripts/deploy-api-prod.sh
# Those are disabled as part of transition to unified API
# deploy_api_mainnet:
# name: Deploy API to mainnet
# environment: api_mainnet
# concurrency:
# group: api_mainnet
# cancel-in-progress: true
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Repo
# uses: actions/checkout@v3
# with:
# fetch-depth: 2
# - name: Install doctl
# uses: digitalocean/action-doctl@v2
# with:
# token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
# - name: Deploy if files have changed
# run: ./scripts/deploy-api-prod.sh

deploy_api_testnet:
name: Deploy API to testnet
environment: api_testnet
concurrency:
group: api_testnet
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Deploy if files have changed
run: ./scripts/deploy-changed.sh apps/api ${{ vars.DIGITALOCEAN_APP_ID }}
# deploy_api_testnet:
# name: Deploy API to testnet
# environment: api_testnet
# concurrency:
# group: api_testnet
# cancel-in-progress: true
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Repo
# uses: actions/checkout@v3
# with:
# fetch-depth: 2
# - name: Install doctl
# uses: digitalocean/action-doctl@v2
# with:
# token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
# - name: Deploy if files have changed
# run: ./scripts/deploy-changed.sh apps/api ${{ vars.DIGITALOCEAN_APP_ID }}

deploy_mana_prod:
name: Deploy mana to production
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@ethersproject/providers": "^5.7.2",
"@ethersproject/units": "^5.6.1",
"@faker-js/faker": "^7.4.0",
"@snapshot-labs/checkpoint": "^0.1.0-beta.44",
"@snapshot-labs/checkpoint": "^0.1.0-beta.47",
"@snapshot-labs/sx": "^0.1.0",
"@types/bn.js": "^5.1.0",
"@types/mysql": "^2.15.21",
Expand Down
94 changes: 0 additions & 94 deletions apps/api/src/config.json

This file was deleted.

16 changes: 0 additions & 16 deletions apps/api/src/currentConfig.ts

This file was deleted.

22 changes: 9 additions & 13 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin
import { startStandaloneServer } from '@apollo/server/standalone';
import Checkpoint, {
createGetLoader,
LogLevel,
starknet
LogLevel
} from '@snapshot-labs/checkpoint';
import spaceAbi from './abis/space.json';
import spaceFactoryAbi from './abis/spaceFactory.json';
import config from './currentConfig';
import * as writer from './writer';
import overrides from './overrides.json';
import { addStarknetIndexers } from './starknet';

const dir = __dirname.endsWith('dist/src') ? '../' : '';
const schemaFile = path.join(__dirname, `${dir}../src/schema.gql`);
Expand All @@ -25,17 +22,15 @@ if (process.env.CA_CERT) {
process.env.CA_CERT = process.env.CA_CERT.replace(/\\n/g, '\n');
}

const indexer = new starknet.StarknetIndexer(writer);
const checkpoint = new Checkpoint(config, indexer, schema, {
const checkpoint = new Checkpoint(schema, {
logLevel: LogLevel.Info,
resetOnConfigChange: true,
prettifyLogs: process.env.NODE_ENV !== 'production',
abis: {
SpaceFactory: spaceFactoryAbi,
Space: spaceAbi
}
overridesConfig: overrides
});

addStarknetIndexers(checkpoint);

const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));

async function run() {
Expand Down Expand Up @@ -65,7 +60,8 @@ async function run() {
await sleep(PRODUCTION_INDEXER_DELAY);
}

// await checkpoint.reset();
await checkpoint.resetMetadata();
await checkpoint.reset();
checkpoint.start();
}

Expand Down
8 changes: 8 additions & 0 deletions apps/api/src/overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"decimal_types": {
"BigDecimalVP": {
"p": 60,
"d": 0
}
}
}
53 changes: 0 additions & 53 deletions apps/api/src/overrrides.ts

This file was deleted.

File renamed without changes.
Loading