Skip to content

Commit

Permalink
Check INFURA_API_KEY value at startup (#1642)
Browse files Browse the repository at this point in the history
Check INFURA_API_KEY value at startup
  • Loading branch information
hectorgomezv authored Jun 12, 2024
1 parent 7a69e4d commit 449ab9c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
# (default is 100)
# NATIVE_COINS_PRICES_TTL_SECONDS=

# RPC Provider
# The RPC provider to be used.
# INFURA_API_KEY=

# Balances Provider - Zerion API
# Chain ids configured to use this provider. (comma-separated numbers)
# (default='')
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ services:
EMAIL_TEMPLATE_UNKNOWN_RECOVERY_TX: ${EMAIL_TEMPLATE_UNKNOWN_RECOVERY_TX-example_template_unknown_recovery_tx}
EMAIL_TEMPLATE_RECOVERY_TX: ${EMAIL_TEMPLATE_RECOVERY_TX-example_template_recovery_tx}
EMAIL_TEMPLATE_VERIFICATION_CODE: ${EMAIL_TEMPLATE_VERIFICATION_CODE-example_template_verification_code}
INFURA_API_KEY: ${INFURA_API_KEY-example_api_key}
JWT_ISSUER: ${JWT_ISSUER-example_issuer}
JWT_TOKEN: ${JWT_TOKEN-example_token}
RELAY_PROVIDER_API_KEY_GNOSIS_CHAIN: ${RELAY_PROVIDER_API_KEY_GNOSIS_CHAIN-example_api_key}
Expand Down
1 change: 1 addition & 0 deletions src/config/configuration.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const RootConfigurationSchema = z.object({
EMAIL_TEMPLATE_RECOVERY_TX: z.string(),
EMAIL_TEMPLATE_UNKNOWN_RECOVERY_TX: z.string(),
EMAIL_TEMPLATE_VERIFICATION_CODE: z.string(),
INFURA_API_KEY: z.string(),
RELAY_PROVIDER_API_KEY_GNOSIS_CHAIN: z.string(),
RELAY_PROVIDER_API_KEY_SEPOLIA: z.string(),
});
3 changes: 3 additions & 0 deletions src/config/configuration.validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('Configuration validator', () => {
EMAIL_TEMPLATE_RECOVERY_TX: faker.string.alphanumeric(),
EMAIL_TEMPLATE_UNKNOWN_RECOVERY_TX: faker.string.alphanumeric(),
EMAIL_TEMPLATE_VERIFICATION_CODE: faker.string.alphanumeric(),
INFURA_API_KEY: faker.string.uuid(),
RELAY_PROVIDER_API_KEY_GNOSIS_CHAIN: faker.string.uuid(),
RELAY_PROVIDER_API_KEY_SEPOLIA: faker.string.uuid(),
};
Expand Down Expand Up @@ -46,6 +47,7 @@ describe('Configuration validator', () => {
{ key: 'EMAIL_TEMPLATE_RECOVERY_TX' },
{ key: 'EMAIL_TEMPLATE_UNKNOWN_RECOVERY_TX' },
{ key: 'EMAIL_TEMPLATE_VERIFICATION_CODE' },
{ key: 'INFURA_API_KEY' },
{ key: 'RELAY_PROVIDER_API_KEY_GNOSIS_CHAIN' },
{ key: 'RELAY_PROVIDER_API_KEY_SEPOLIA' },
])(
Expand Down Expand Up @@ -77,6 +79,7 @@ describe('Configuration validator', () => {
EMAIL_TEMPLATE_RECOVERY_TX: faker.string.alphanumeric(),
EMAIL_TEMPLATE_UNKNOWN_RECOVERY_TX: faker.string.alphanumeric(),
EMAIL_TEMPLATE_VERIFICATION_CODE: faker.string.alphanumeric(),
INFURA_API_KEY: faker.string.uuid(),
RELAY_PROVIDER_API_KEY_GNOSIS_CHAIN: faker.string.uuid(),
RELAY_PROVIDER_API_KEY_SEPOLIA: faker.string.uuid(),
};
Expand Down
1 change: 1 addition & 0 deletions src/datasources/blockchain/blockchain-api.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class BlockchainApiManager implements IBlockchainApiManager {
};
}

// Note: this assumes Infura as provider when using an API key as authentication method.
private formatRpcUri(rpcUri: DomainChain['rpcUri']): string {
return rpcUri.authentication === RpcUriAuthentication.ApiKeyPath
? rpcUri.value + this.infuraApiKey
Expand Down

0 comments on commit 449ab9c

Please sign in to comment.