Skip to content

Commit

Permalink
improve: Add new config file
Browse files Browse the repository at this point in the history
Signed-off-by: Evaldo Felipe <[email protected]>
  • Loading branch information
evaldofelipe committed Jan 7, 2025
1 parent 06476e8 commit a904942
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import enabledMainnetRoutesAsJson from "../src/data/routes_1_0xc186fA914353c44b2
import enabledSepoliaRoutesAsJson from "../src/data/routes_11155111_0x14224e63716afAcE30C9a417E0542281869f7d9e.json";
import rpcProvidersJson from "../src/data/rpc-providers.json";

process.env["any-file.env"]

import {
MINIMAL_BALANCER_V2_POOL_ABI,
MINIMAL_BALANCER_V2_VAULT_ABI,
Expand Down
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`
);
}

0 comments on commit a904942

Please sign in to comment.