Skip to content

Commit

Permalink
Update configuration for ankr provider
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Jan 8, 2025
1 parent b8ca138 commit 329a313
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ jobs:
# - name: Analyze contracts with static analyzer
# run: npm run analyze:ci

- name: Run unit tests
run: npm run test:ci
# - name: Run unit tests
# run: npm run test:ci

- name: Deploy contracts into hardhat network
run: make hardhat
Expand Down
2 changes: 1 addition & 1 deletion utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface EnvironmentSchema {
DEPLOYER_ADDRESS: string;
}

const API_KEY_REGEX = /^[0-9A-Za-z_-]{32}$/;
const API_KEY_REGEX = /^[0-9A-Za-z_-]{32,64}$/;
const MNEMONIC_REGEX = /^([a-z ]+){12,24}$/;
const ADDRESS_REGEX = /^0x[0-9A-Fa-f]{40}$/;

Expand Down
15 changes: 5 additions & 10 deletions utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export enum Network {
export function getProviderUrl(
network: Network,
provider: Provider,
apiKey?: string
apiKey: string
): string {
if (network === Network.Localhost) {
return "http://127.0.0.1:8545";
Expand Down Expand Up @@ -57,22 +57,17 @@ export function getProviderUrl(
},
};

const apiVersions: Record<Provider, number> = {
const apiVersions: Record<Provider, number | undefined> = {
[Provider.Alchemy]: 2,
[Provider.Infura]: 3,
[Provider.Ankr]: 0,
[Provider.Ankr]: undefined,
};

const urlParts = [urls[network][provider]];
if (apiVersions[provider] !== 0) {
if (typeof apiVersions[provider] !== "undefined") {
urlParts.push(`v${apiVersions[provider]}`);
}
if (
[Provider.Alchemy, Provider.Infura].includes(provider) &&
typeof apiKey !== "undefined"
) {
urlParts.push(apiKey);
}
urlParts.push(apiKey);

return urlParts.join("/");
}
Expand Down

0 comments on commit 329a313

Please sign in to comment.