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

refactor: use the Failover Provider #28

Merged
merged 5 commits into from
Oct 15, 2024
Merged

refactor: use the Failover Provider #28

merged 5 commits into from
Oct 15, 2024

Conversation

jtourkos
Copy link
Contributor

@jtourkos jtourkos commented Sep 25, 2024

(partially) resolves: drips-network/app#1181

@jtourkos jtourkos requested a review from efstajas September 25, 2024 08:57
@jtourkos jtourkos mentioned this pull request Sep 25, 2024
5 tasks
Copy link
Contributor

@efstajas efstajas left a 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
Comment on lines 6 to 30

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.
Copy link
Contributor

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.

Copy link
Contributor Author

@jtourkos jtourkos Oct 14, 2024

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?

Comment on lines 7 to 8
url: string;
accessToken?: string;
Copy link
Contributor

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?

Base automatically changed from multi-chain-api to main October 10, 2024 13:43
@jtourkos jtourkos requested a review from efstajas October 14, 2024 12:23
Copy link
Contributor

@efstajas efstajas left a 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)

@jtourkos jtourkos merged commit a871221 into main Oct 15, 2024
1 check failed
@railway-app railway-app bot requested a deployment to app-pr-1262 October 15, 2024 10:21 Abandoned
@railway-app railway-app bot requested a deployment to app-pr-1260 October 15, 2024 10:21 Abandoned
@railway-app railway-app bot requested a deployment to app-pr-1263 October 15, 2024 10:21 Abandoned
@jtourkos jtourkos deleted the use-failover-provider branch October 15, 2024 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RPC redundancy
2 participants