-
Notifications
You must be signed in to change notification settings - Fork 36
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
Ethereum/Solana: Support additional tokens from info server #826
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.
I only have questions and comments
src/common/innerPlugin.ts
Outdated
// Merge token maps | ||
for (const [tokenId, incomingToken] of Object.entries(cleanTokens)) { | ||
if (builtinTokens[tokenId] != null) continue | ||
if (currencyInfo.currencyCode === incomingToken.currencyCode) continue // TODO: Remove after migrating away from currencyCode keyed objects |
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.
This TODO comment confuses me. Is this for line 151 or 152?
src/common/innerPlugin.ts
Outdated
const matchingToken = Object.values(builtinTokens).find( | ||
token => token.currencyCode === incomingToken.currencyCode | ||
) |
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 we don't allow for info server tokens to stomp on our built-in list if a currency code is already in-use. So, info server can only provide additional tokens and no updates to existing token information.
src/ethereum/EthereumTools.ts
Outdated
export const createEvmToken = ( | ||
rawToken: unknown | ||
): { tokenId: string; token: EdgeToken } => { | ||
const token = asEdgeToken(rawToken) | ||
const cleanLocation = asMaybeContractLocation(token.networkLocation) | ||
if ( | ||
cleanLocation == null || | ||
!EthereumUtil.isValidAddress(cleanLocation.contractAddress) | ||
) { | ||
throw new Error('ErrorInvalidContractAddress') | ||
} | ||
|
||
return { | ||
tokenId: cleanLocation.contractAddress.toLowerCase().replace(/^0x/, ''), | ||
token | ||
} | ||
} |
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 isn't this function in tokenHelpers.ts? Does it belong in the tools file?
src/ethereum/info/amoyInfo.ts
Outdated
@@ -5,6 +5,7 @@ import { makeMetaTokens } from '../../common/tokenHelpers' | |||
import type { EthereumTools } from '../EthereumTools' | |||
import { | |||
asEthereumInfoPayload, | |||
createEvmToken, |
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.
How is it possible to be importing this function from ethereumTypes.ts
if it's defined in EthereumTools.ts
?
src/solana/solanaInfo.ts
Outdated
@@ -5,6 +5,7 @@ import { makeMetaTokens } from '../common/tokenHelpers' | |||
import type { SolanaTools } from './SolanaTools' | |||
import { | |||
asSolanaInfoPayload, | |||
createSolanaToken, |
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.
How is this possible?
04a7824
to
ebf313a
Compare
@@ -91,3 +93,7 @@ export const createTokenIdFromContractAddress = (token: EdgeToken): string => { | |||
} | |||
return cleanLocation.contractAddress | |||
} | |||
|
|||
export const createEvmTokenId = (token: EdgeToken): string => { | |||
return normalizeAddress(createTokenIdFromContractAddress(token)) |
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.
This function is named normalizeAddress yet we're using it to get a "token ID". Weird. Oh well.
ebf313a
to
7705dbb
Compare
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneDescription
none