-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor: use the Failover Provider #28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍 Again, maybe think about copying the changes from app's FallbackProvider into here as well.
.env.template
Outdated
|
||
RPC_URL_MAINNET=string # The RPC URL for the Mainnet provider. | ||
RPC_ACCESS_TOKEN_MAINNET=string # Optional. The access token to use for the RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
FALLBACK_RPC_URL_MAINNET=string # Optional. The fallback RPC URL for the Mainnet provider. If specified, it will be used if the main RPC URL fails. | ||
FALLBACK_RPC_ACCESS_TOKEN_MAINNET=string # Optional. The access token to use for the fallback RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
|
||
RPC_URL_SEPOLIA=string # The RPC URL for the Sepolia provider. | ||
RPC_ACCESS_TOKEN_SEPOLIA=string # Optional. The access token to use for the RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
FALLBACK_RPC_URL_SEPOLIA=string # Optional. The fallback RPC URL for the Sepolia provider. If specified, it will be used if the main RPC URL fails. | ||
FALLBACK_RPC_ACCESS_TOKEN_SEPOLIA=string # Optional. The access token to use for the fallback RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
|
||
RPC_URL_OPTIMISM_SEPOLIA=string # The RPC URL for the Optimism Sepolia provider. | ||
RPC_ACCESS_TOKEN_OPTIMISM_SEPOLIA=string # Optional. The access token to use for the RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
FALLBACK_RPC_URL_OPTIMISM_SEPOLIA=string # Optional. The fallback RPC URL for the Optimism Sepolia provider. If specified, it will be used if the main RPC URL fails. | ||
FALLBACK_RPC_ACCESS_TOKEN_OPTIMISM_SEPOLIA=string # Optional. The access token to use for the fallback RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
|
||
RPC_URL_POLYGON_AMOY=string # The RPC URL for the Polygon Amoy provider. | ||
RPC_ACCESS_TOKEN_POLYGON_AMOY=string # Optional. The access token to use for the RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
FALLBACK_RPC_URL_POLYGON_AMOY=string # Optional. The fallback RPC URL for the Polygon Amoy provider. If specified, it will be used if the main RPC URL fails. | ||
FALLBACK_RPC_ACCESS_TOKEN_POLYGON_AMOY=string # Optional. The access token to use for the fallback RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
|
||
RPC_URL_FILECOIN=string # The RPC URL for the Filecoin provider. | ||
RPC_ACCESS_TOKEN_FILECOIN=string # Optional. The access token to use for the RPC. If specified, it will be used as a bearer token in the `Authorization` header. | ||
FALLBACK_RPC_URL_FILECOIN=string # Optional. The fallback RPC URL for the Filecoin provider. If specified, it will be used if the main RPC URL fails. | ||
FALLBACK_RPC_ACCESS_TOKEN_FILECOIN=string # Optional. The access token to use for the fallback RPC. If specified, it will be used as a bearer token in the `Authorization` header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so many env vars! what do you think about taking a single RPC_CONFIG env var that takes a JSON string with a strict schema that we validate with e.g. zod
in appSettings
?
either way, for now I think this is still OK — gonna get a bit crazy when we add more networks soon though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. Take a look at this commit (67c931d). Was this what you had in mind?
src/common/appSettings.ts
Outdated
url: string; | ||
accessToken?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to this PR, but does anything actually validate that url
exists? if the env var is undefined, it'll be undefined
at runtime too, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before merging make sure to set the env var (or introduce check for env vars in build step)
(partially) resolves: drips-network/app#1181