Skip to content

chore: added CI for questbook-analytics-v0 #28

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions src/repos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import grantsContractsUpgradeable from "./grants-contracts-upgradeable";
import grantsFrontend from "./grants-frontend";
import graphNodeDeployment from "./graph-node-deployment";
import qbAPI from "./qb-api";
import questbookAnalyticsV0 from "./questbook-analytics-v0";
import serviceValidator from "./service-validator";
import subgraph from "./subgraph";

Expand All @@ -14,4 +15,5 @@ export default [
subgraph,
grantsFrontend,
qbAPI,
questbookAnalyticsV0
]
56 changes: 56 additions & 0 deletions src/repos/questbook-analytics-v0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { writeFile } from "fs/promises";
import { join } from "path";
import { CIRepo } from "../types";

const CHAINS_DATA_FILE = './src/psuedo-generated/chainInfo.json'

const questbookAnalyticsV0: CIRepo = {
repoName: 'questbook-analytics-v0',
doCI: async(repoPath, chains) => {
// generate the chains.json file
const data = Object.values(chains).reduce(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the code from line number 11 to 47 is being used for other repos (qb-api, etc) as well, can we move this to a common function under a file in utils (create a new file) and use it wherever required? @richikchanda1999

(dict, chain) => {
dict[chain.chainId] = {
id: chain.chainId,
name: chain.userFacingName,
isTestNetwork: chain.isTestNetwork,
wallets: chain.supportedWallets,
explorer: chain.explorer,
supportedCurrencies: chain.supportedCurrencies.reduce(
(dict, currency) => {
dict[currency.address] = {
label: currency.label,
decimal: currency.decimals,
address: currency.address,
}
return dict
}, { } as { [_: string]: any }
),
qbContracts: Object.keys(chain.qbContracts).reduce(
(dict, contract) => {
dict[contract] = chain.qbContracts[contract as keyof typeof chain.qbContracts].address
return dict
}, { } as { [_: string]: string }
),
subgraphClientUrl: getSubgraphUrl(chain.chainName),
rpcUrls: chain.rpcUrls.map(
// replace any templates with empty strings
url => url.replace(/{{[a-z_-]+}}/gi, '')
),
nativeCurrency: chain.nativeCurrency ?? {
name: 'Unsupported Currency',
symbol: 'UNSUP',
decimals: 18,
}
}
return dict
}, { } as { [_: string]: any }
)

await writeFile(join(repoPath, CHAINS_DATA_FILE), JSON.stringify(data, null, '\t'))
}
}

const getSubgraphUrl = (chainName: string) => `https://the-graph.questbook.app/subgraphs/name/qb-subgraph-${chainName}`

export default questbookAnalyticsV0