-
Notifications
You must be signed in to change notification settings - Fork 8
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
Improved constants #28
Conversation
26k additions lmao, keyrxng strikes again ofc it's because of the types and consts being generated. Originally I went out and manually collected explorers but in order to support them at a type level I'd need to include them in the base So the best solution was to use the same data source as Previously I was allowing for loose auto-complete but the expectation now is that there isn't a chain we can't support so long as it has RPCs. |
What was the problem with injecting at build? Seems that the codebase was significantly smaller and more maintainable before. You did this to remove the one tsc ignore?
I don't understand this but we shouldn't assume the decimals. Besides USDC/T use six and are very popular tokens to work with.
|
When trying to work with the export from But beyond that, I was not able to coerce the JSON values into literal string types see this issue. The writing of the contents to our TS file let's us create far better type exports. It also dramatically increases the number of chains that are supported by this package because it also includes testnets The generated types and consts make up 25,951 additions, the additional code written is only ~320 odd.
A native token such as While it's possible for a chain's native crypto to be a different decimal it is not EVM standard |
Okay your rationale makes sense. Just as long as we support the chains with permit2 regarding the 18 decimals it's fine. I'm assuming you're referring only to the native token of the networks. |
build/types.ts
Outdated
} | ||
|
||
// Clear the file | ||
await writeFile("types/dynamic.ts", "/* eslint-disable sonarjs/no-duplicate-string */\n\n"); |
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.
Instead of ignoring the duplicate string rule, why don't you assign this to a variable and reuse?
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.
It's not a feasible approach because the file is 29k in length. The duplicates are things like long and short form crypto names, chain names etc.
P.S a cryptocurrency technically speaking is the native crypto (gas token) of that network and all other "cryptos" are tokens on the network or at least that distinction used to be valid.
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.
I'm referring to the file name.
Colloquially the "coin" is the gas token. Everything else refers to erc20 compliant tokens. Cryptocurrency, colloquially refers to both "coins" and "tokens"
Although I haven't heard anybody make a point about distinction since 2018.
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.
Ah I misunderstood, ignoring the rule was for contents of the file but the name would have thrown eslint as well.
I know they are all used interchangeably now, it can be easy to misconstrue sometimes
return this._networkId; | ||
} | ||
|
||
public getNetworkName(): string { | ||
public getNetworkName() { |
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.
why remove the return type ?
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.
because the class values are typed there is no need to explicitly annotate a return type here as nothing is mutated in the function. Removal of string
specifically is because it now uses the NetworkName
union type.
Resolves #27
couple of changes made
In order to improve our exported types I've moved to dynamically generating types and constants
I've also written the
extraRpcs
from/lib/chainlist
into an object, this allows us to work with the list directly withoutesbuild
complaining, likely removes the need fornode-fetch
too (will check)Because the
extraRpcs
list is being written to a local object we no longer need to inject them at buildImproved
RPCHandler
and config with updated typesadded tests covering the two helper functions and the
Records
added a bunch of explorers and native tokens (18 decimals is the standard, it's EVM breaking otherwise, I have not verified each)Programmatically collecting explorers, native crypto info etc from the same source that
chainList
uses. This approach also ensures that we can provide RPC endpoints for testnets because theextraRPCs
object that came from/lib/chainlist
originally had only mainnets.