-
Notifications
You must be signed in to change notification settings - Fork 893
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
chore(wallet): add GetEthTokenInfo and refactor #21191
Conversation
c3ec878
to
5a76ef8
Compare
components/brave_wallet_ui/components/shared/add-custom-token-form/add-custom-token-form.tsx
Outdated
Show resolved
Hide resolved
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.
Frontend ++
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.
Awesome 🎉.
iOS ++
A Storybook has been deployed to preview UI for the latest push |
mojom::BlockchainTokenPtr ParseTokenInfo(const base::Value& json_value, | ||
const std::string& chain_id, | ||
mojom::CoinType coin) { | ||
auto token_info = api::asset_ratio::TokenInfo::FromValue(json_value); |
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.
Let's also drop TokenInfo
and TokenInfoResult
from asset_ratio.idl
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.
ed535e0
@@ -1335,6 +1328,34 @@ interface JsonRpcService { | |||
string chain_id) => (string decimals, | |||
ProviderError error, | |||
string error_message); | |||
|
|||
// Fetches name of an ERC20 or ERC721 token. | |||
GetEthTokenName(string contract_address, |
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.
Is it possible not to expose GetEthTokenName and GetEthTokenDecimals + GetEthTokenSymbol above in mojom, but reuse GetEthTokenInfo for
brave-core/components/brave_wallet_ui/components/extension/swap/index.tsx
Lines 141 to 181 in c65fcba
const { data: sellTokenDecimals } = useGetEthTokenDecimalsQuery( | |
sellToken && | |
sellToken.coingeckoId === UNKNOWN_TOKEN_COINGECKO_ID && | |
!isNativeToken(sellToken) | |
? { | |
chainId: sellToken.chainId, | |
contractAddress: sellToken.contractAddress | |
} | |
: skipToken | |
) | |
const { data: sellTokenSymbol } = useGetEthTokenSymbolQuery( | |
sellToken && | |
sellToken.coingeckoId === UNKNOWN_TOKEN_COINGECKO_ID && | |
!isNativeToken(sellToken) | |
? { | |
chainId: sellToken.chainId, | |
contractAddress: sellToken.contractAddress | |
} | |
: skipToken | |
) | |
const { data: buyTokenDecimals } = useGetEthTokenDecimalsQuery( | |
buyToken && | |
buyToken.coingeckoId === UNKNOWN_TOKEN_COINGECKO_ID && | |
!isNativeToken(buyToken) | |
? { | |
chainId: buyToken.chainId, | |
contractAddress: buyToken.contractAddress | |
} | |
: skipToken | |
) | |
const { data: buyTokenSymbol } = useGetEthTokenSymbolQuery( | |
buyToken && | |
buyToken.coingeckoId === UNKNOWN_TOKEN_COINGECKO_ID && | |
!isNativeToken(buyToken) | |
? { | |
chainId: buyToken.chainId, | |
contractAddress: buyToken.contractAddress | |
} | |
: skipToken | |
) |
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.
Fixed here: 17a0e1f
Also cc: @StephenHeaps, since he may be using those removed methods.
} | ||
}, [transactionDetails?.recipient, transactionInfo?.txType]) | ||
? { | ||
contractOrMintAddress: transactionDetails.recipient, |
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.
Should it have Solanas term Mint
in contractOrMintAddress
if it is EVM only?
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.
Fixed here: 9549c59
I do intend to add support for Solana as well, but will change back to contractOrMintAddress
once it is done.
d0f58c7
to
a5d245c
Compare
[puLL-Merge] - brave/brave-core@21191 DescriptionThe pull request is a diff from the Brave core repository, specifically for the ChangesRemoved:
Added:
Modified:
Security Hotspots
Overall, most changes seem to be refactoring to simplify the process of retrieving token information for the Brave Wallet, including removing reliance on Etherscan's IPC calls. However, it's crucial to audit these changes for any potential security issues related to network requests and user input handling. |
A Storybook has been deployed to preview UI for the latest push |
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.
wallet core lgtm
c0b57fd
to
70dda32
Compare
[puLL-Merge] - brave/brave-core@21191 DescriptionThe pull request removes the interaction with ChangesChanges
Security HotspotsSecurity hotspots are not directly addressed in the changes; however, the switch to |
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.
👍 AddAssetActivity
will be completely removed soon, so part of the class could be safely commented.
A Storybook has been deployed to preview UI for the latest push |
Removes dependency on Etherscan Pro API (costs us $200/mo), and allows us to pre-fill fields like name, symbol, and decimals for any token on any EVM chain.
Resolves brave/brave-browser#33314
Resolves brave/brave-browser#31062
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: