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

Improve: Add new config file #1357

Open
wants to merge 2 commits into
base: master
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
12 changes: 12 additions & 0 deletions scripts/pre-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
fetchExclusiveRelayersDynamicWeights,
fetchExclusiveRelayersFixedWeights,
fetchExclusivityConfig,
fetchGitEnvConfig,
getRemoteConfigCommitHash,
getBqReaderRemoteBaseUrl,
remoteConfigTypes,
getAcrossConfigsRemoteBaseUrl,
getRelayerConfigsRemoteBaseUrl,
getGitEnvConfigsRemoteBaseUrl,
} from "./remote-configs/utils";

dotenv.config({
Expand Down Expand Up @@ -101,6 +103,16 @@ const remoteConfigs = {
),
localFilePath: "src/data/exclusivity-strategy.json",
},
[remoteConfigTypes.GIT_ENV_CONFIGS]: {
fetchFn: () =>
fetchGitEnvConfig(
// Using invalid URL will cause the fetch to fail and fallback to the local file for now.
getGitEnvConfigsRemoteBaseUrl(),
"projects/across/frontend/outputs/output.env",
getRemoteConfigCommitHash(remoteConfigTypes.GIT_ENV_CONFIGS)
),
localFilePath: "src/data/output.env",
},
};

(async () => {
Expand Down
14 changes: 14 additions & 0 deletions scripts/remote-configs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const remoteConfigTypes = {
EXCLUSIVE_RELAYERS_FIXED_WEIGHTS: "EXCLUSIVE_RELAYER_WEIGHTS",
EXCLUSIVITY_STRATEGY: "EXCLUSIVITY_STRATEGY",
RPC_PROVIDERS: "RPC_PROVIDERS",
GIT_ENV_CONFIGS: "GIT_ENV_CONFIGS",
} as const;

export type RemoteConfig =
Expand Down Expand Up @@ -117,6 +118,12 @@ export const fetchExclusivityConfig = makeFetchRemoteConfig(
exclusivityStrategyFallbackData
);

export const fetchGitEnvConfig = makeFetchRemoteConfig(
type({
default: string(),
}),
);

function makeFetchRemoteConfig<T>(schema: Struct<T>, fallbackData?: T) {
return async (
remoteBaseUrl: string,
Expand Down Expand Up @@ -208,3 +215,10 @@ export function getAcrossConfigsRemoteBaseUrl() {
`https://${GITHUB_HOST}/UMAprotocol/across-configs`
);
}

export function getGitEnvConfigsRemoteBaseUrl() {
return getRemoteConfigBaseUrl(
"GIT_ENV_CONFIGS",
`https://${GITHUB_HOST}/UMAprotocol/git-env`
);
}
Loading