Skip to content

Add service keys for evm currencies #946

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tomatrow
Copy link

@tomatrow tomatrow commented Jun 12, 2025

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

@samholmes samholmes self-requested a review June 12, 2025 22:44
Copy link
Collaborator

@samholmes samholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR! Thanks for giving this a stab.

I'd recommend squashing the wip commit with the first commit since it makes sense as one atomic change together.

I'd also recommend setting up your editor to catch ESLint errors for you following the project's rules. Some of the requested changes in the PR would have been caught by tooling which is why it's recommended to use a good integrated linter/type-checker.

I can't wait to test this out and give it a go once the PR fixups are in place. 🔥

quiknodeApiKey?: string
serviceKeys?: Record<string, string | string[]>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with serviceKeys: { [host: string]: string[] } as the type. Using this type annotation style allows us to document the key with a name for semantics, and also we want it to always be an array which supports single and multiple items just as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not addressed.

@tomatrow tomatrow force-pushed the aj/add-service-keys-for-evm-currencies branch from e3c5453 to 35d8645 Compare June 17, 2025 04:39

return await this.serialServers(async baseUrl => {
const url = `${base58ToHexAddress}${path}`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samholmes So, was this a bug?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what happened here. Though I notice that fetchGetAmberdataApi is dead code, so maybe this just needs to be deleted. I think we're no longer using Amberdata altogether, so maybe this entire adapter should be removed so we cleanup tech-debt. Though, I don't know for sure if we want to make that move before we re-support Amberdata as an adapter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answer: Amberdata and Blockcypher adapters are deprecated and will be removed in a follow-up PR/task.

Copy link
Collaborator

@samholmes samholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't fully finished my re-review. But here's some immediate feedback.

@tomatrow tomatrow force-pushed the aj/add-service-keys-for-evm-currencies branch from 35d8645 to df65d34 Compare June 30, 2025 20:34
Copy link
Collaborator

@samholmes samholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. Pull my fixup commit on the branch of the same name on this repo.

Comment on lines 1 to 5
export function getServiceKeyIndex(url: string): string | undefined {
try {
return new URL(url).host
} catch {}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.host is never undefined so omit it in the return type.

I see that you're using undefined as a case at the call-site. It seems like what you want is a utility that does a lookup and returns a string or undefined if the lookup succeeds or fails. I made a fixup commit to aj/add-service-keys-for-evm-currencies branch which you can pull from that has the suggested solution.


return await this.serialServers(async baseUrl => {
const url = `${base58ToHexAddress}${path}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answer: Amberdata and Blockcypher adapters are deprecated and will be removed in a follow-up PR/task.

@tomatrow tomatrow force-pushed the aj/add-service-keys-for-evm-currencies branch from df65d34 to 31b8831 Compare July 8, 2025 03:59
Comment on lines 13 to 16
export function getServiceKeyIndex(url: string): string {
const host = new URL(url, `scheme://${url}`).host
return host
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samholmes This handles a host being passed in now

@@ -11,6 +11,6 @@ export function getRandomServiceKey(
}

export function getServiceKeyIndex(url: string): string {
const host = new URL(url).host
const host = new URL(url, `scheme://${url}`).host
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use https as the default scheme that is assumed. Also make this commit a "fixup!" commit to the relevant commit where getServiceKeyIndex was introduced.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be resolved by 5716bf6

@tomatrow tomatrow force-pushed the aj/add-service-keys-for-evm-currencies branch from bdf7b9a to 5716bf6 Compare July 9, 2025 19:59
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.

2 participants