Skip to content

Commit

Permalink
Feat/357 fix indexer deploy (#360)
Browse files Browse the repository at this point in the history
* feat: add github workflow for nestjs-indexer

* chore: temporary disabled typo check

* feat: cleanup and fix prisma config

* feat: check data-backend build

* chore: fix format

* chore: fix backend build

* feat: fix path
  • Loading branch information
ncoquelet authored Dec 14, 2024
1 parent 7d8fad6 commit 0181d10
Show file tree
Hide file tree
Showing 59 changed files with 764 additions and 960 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/data-backend.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
name: Data Backend App

on:
push:
branches:
- main
paths:
- "apps/data-backend/**"
pull_request:
paths:
- "apps/data-backend/**"
on: [push, pull_request]

jobs:
check-app:
Expand All @@ -25,7 +17,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: '20.x'

- name: Install pnpm
uses: pnpm/action-setup@v4
Expand All @@ -46,7 +38,7 @@ jobs:
- name: Install Dependencies
run: |
if [ -f "apps/data-backend/pnpm-lock.yaml" ]; then
if [ -f "pnpm-lock.yaml" ]; then
pnpm install --frozen-lockfile
else
pnpm install
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/nestjs-indexer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: NestJS Indexer App

on: [push, pull_request]

jobs:
check-app:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./apps/nestjs-indexer

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: |
if [ -f "pnpm-lock.yaml" ]; then
pnpm install --frozen-lockfile
else
pnpm install
fi
- name: Build Prisma client
run: pnpm generate
working-directory: ./packages/indexer-prisma

- name: Prettier Format Check
run: pnpm format:check

- name: TypeScript Check
run: pnpm ts:check

- name: Build
run: pnpm build
1 change: 1 addition & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
typos:
if: ${{ false }} # disable for now
name: Spell Check with Typos
runs-on: ubuntu-22.04
steps:
Expand Down
44 changes: 22 additions & 22 deletions apps/data-backend/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { z } from "zod";
import { v2 as cloudinary } from "cloudinary";
import { ConfigSchema } from "../validations/config.validation";
import dotenv from "dotenv";
import { z } from 'zod';
import { v2 as cloudinary } from 'cloudinary';
import { ConfigSchema } from '../validations/config.validation';
import dotenv from 'dotenv';

// Load environment variables from .env file
dotenv.config();

// Create the config object
const rawConfig = {
jwt: {
secret: process.env.JWT_SECRET || "your-secret-key",
accessTokenExpiry: "30m",
refreshTokenExpiry: "7d",
secret: process.env.JWT_SECRET || 'your-secret-key',
accessTokenExpiry: '30m',
refreshTokenExpiry: '7d',
},
server: {
port: parseInt(process.env.PORT || "5050", 10),
host: process.env.HOST || "0.0.0.0",
port: parseInt(process.env.PORT || '5050', 10),
host: process.env.HOST || '0.0.0.0',
},
cloudinary: {
cloud_name: process.env.CLOUDINARY_CLOUD_NAME || "",
api_key: process.env.CLOUDINARY_API_KEY || "",
api_secret: process.env.CLOUDINARY_API_SECRET || "",
cloud_name: process.env.CLOUDINARY_CLOUD_NAME || '',
api_key: process.env.CLOUDINARY_API_KEY || '',
api_secret: process.env.CLOUDINARY_API_SECRET || '',
},
rpc: {
starknetRpcUrl: process.env.STARKNET_RPC_PROVIDER_URL || "",
starknetNetwork: process.env.STARKNET_RPC_NETWORK || "",
api_key: process.env.RPC_NODE_API_KEY || "",
network: process.env.SN_NETWORK || "",
starknetRpcUrl: process.env.STARKNET_RPC_PROVIDER_URL || '',
starknetNetwork: process.env.STARKNET_RPC_NETWORK || '',
api_key: process.env.RPC_NODE_API_KEY || '',
network: process.env.SN_NETWORK || '',
},
cloudfare: {
accountId: process.env.CLOUDFARE_ACCOUNT_ID || "",
token: process.env.CLOUDFARE_AUTH_TOKEN || "",
r2BucketName: process.env.CLOUDFARE_R2_BUCKET || "",
r2Access: process.env.CLOUDFARE_R2_ACCESS || "",
r2Secret: process.env.CLOUDFARE_R2_SECRET || "",
r2Domain: process.env.CLOUDFARE_R2_DOMAIN || "",
accountId: process.env.CLOUDFARE_ACCOUNT_ID || '',
token: process.env.CLOUDFARE_AUTH_TOKEN || '',
r2BucketName: process.env.CLOUDFARE_R2_BUCKET || '',
r2Access: process.env.CLOUDFARE_R2_ACCESS || '',
r2Secret: process.env.CLOUDFARE_R2_SECRET || '',
r2Domain: process.env.CLOUDFARE_R2_DOMAIN || '',
},
} as const;

Expand Down
39 changes: 17 additions & 22 deletions apps/data-backend/src/constants/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { constants, hash, shortString } from "starknet";
import { constants, hash, shortString } from 'starknet';

// type SupportedChainId = Exclude<
// constants.StarknetChainId,
Expand All @@ -9,27 +9,24 @@ type SupportedChainId = constants.StarknetChainId;
type AddressesMap = Record<SupportedChainId, string>;

export const BLANK_ACCOUNT_CLASS_HASH =
"0x1fa186ff7ea06307ded0baa1eb7648afc43618b92084da1110a9c0bd2b6bf56";
'0x1fa186ff7ea06307ded0baa1eb7648afc43618b92084da1110a9c0bd2b6bf56';

export enum Entrypoint {
DEPLOY_ACCOUNT = "deploy_account",
EXECUTE_FROM_OUTSIDE = "execute_from_outside_v2",
DEPLOY_ACCOUNT = 'deploy_account',
EXECUTE_FROM_OUTSIDE = 'execute_from_outside_v2',
}

export const VAULT_FACTORY_ADDRESSES: AddressesMap = {
[constants.StarknetChainId.SN_MAIN]:
"0x410da9af28e654fa93354430841ce7c5f0c2c17cc92971fb23d3d4f826d9834",
'0x410da9af28e654fa93354430841ce7c5f0c2c17cc92971fb23d3d4f826d9834',
[constants.StarknetChainId.SN_SEPOLIA]:
"0x33498f0d9e6ebef71b3d8dfa56501388cfe5ce96cba81503cd8572be92bd77c",
'0x33498f0d9e6ebef71b3d8dfa56501388cfe5ce96cba81503cd8572be92bd77c',
};

// eslint-disable-next-line import/no-unused-modules
export const SN_CHAIN_ID = (constants.StarknetChainId[
(process.env.SN_NETWORK ?? "SN_SEPOLIA") as constants.NetworkName
] ??
constants.StarknetChainId[
constants.NetworkName.SN_SEPOLIA
]) as SupportedChainId;
(process.env.SN_NETWORK ?? 'SN_SEPOLIA') as constants.NetworkName
] ?? constants.StarknetChainId[constants.NetworkName.SN_SEPOLIA]) as SupportedChainId;

// const NODE_URLS = {
// [constants.StarknetChainId.SN_MAIN]: (apiKey: string) => `https://rpc.nethermind.io/mainnet-juno/?apikey=${apiKey}`,
Expand All @@ -52,23 +49,21 @@ export const NODE_URL = NODE_URLS[SN_CHAIN_ID](process.env.RPC_NODE_API_KEY!);
export const typedDataValidate = {
types: {
StarkNetDomain: [
{ name: "name", type: "felt" },
{ name: "version", type: "felt" },
{ name: "chainId", type: "felt" },
{ name: 'name', type: 'felt' },
{ name: 'version', type: 'felt' },
{ name: 'chainId', type: 'felt' },
],
Message: [{ name: "message", type: "felt" }],
Message: [{ name: 'message', type: 'felt' }],
},
primaryType: "Message",
primaryType: 'Message',
domain: {
name: "Afk",
chainId: shortString.encodeShortString(
process.env.EXPO_PUBLIC_NETWORK || "SN_MAIN"
),
version: "1",
name: 'Afk',
chainId: shortString.encodeShortString(process.env.EXPO_PUBLIC_NETWORK || 'SN_MAIN'),
version: '1',
},
message: {
message: {
message: "Sign Signature",
message: 'Sign Signature',
},
},
};
13 changes: 6 additions & 7 deletions apps/data-backend/src/constants/funkit.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
export const FUNKIT_STARKNET_CHAIN_ID = "23448594291968334";
export const SOURCE_OF_FUND_KEY = "card|stripe";
export const FUNKIT_STRIPE_SOURCE_CURRENCY = "usd";
export const FUNKIT_STARKNET_CHAIN_ID = '23448594291968334';
export const SOURCE_OF_FUND_KEY = 'card|stripe';
export const FUNKIT_STRIPE_SOURCE_CURRENCY = 'usd';

export const TOKEN_INFO = {
STARKNET_USDC: {
address:
"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
address: '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8',
decimals: 6,
symbol: "usdc",
network: "starknet",
symbol: 'usdc',
network: 'starknet',
networkId: FUNKIT_STARKNET_CHAIN_ID,
},
};
4 changes: 2 additions & 2 deletions apps/data-backend/src/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApolloServer, gql } from "apollo-server";
const { prisma } = require("indexer-prisma");
import { ApolloServer, gql } from 'apollo-server';
const { prisma } = require('indexer-prisma');

//GraphQL schema definitions

Expand Down
Loading

0 comments on commit 0181d10

Please sign in to comment.