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
Add ERC20 token support #531
Conversation
ede9055
to
cb7e8fc
Compare
This reverts commit 6db5f87.
@keplr-wallet/store-etc is uploaded in npm, and also used in other projects as well. We cannot merge this PR when @keplr-wallet/store-etc is deleted |
To be honest, showing only balance (without support transfer) to the user has alot of parts that we need to think about. Also, as of right now, this feature is only for evmos and if features being added start becoming domain specific, it becomes harder and harder to manage code. Current code needs to go through refactoring in the near future, so implementing a special feature is a huge burden in terms of code management. Also, I do think that current PR cycle is very slow, and that you might be unhappy about it. |
packages/hooks/src/ibc/amount.ts
Outdated
const type = new DenomHelper(cur.coinMinimalDenom).type; | ||
return ( | ||
type === "native" || | ||
(type === "erc20" && this.initialChainId.includes("evmos")) |
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.
Please take off the restriction on the chain ID, unless there is a specific reason.
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.
Refactored to use the evmos-erc20
feature flag. The purpose for this condition is that Evmos supports sending ERC-20 tokens in IBC transactions, but other ERC-20 chains may not.
Let me know if this is not a concern, and we can remove the check.
} | ||
} | ||
|
||
protected createSignableEthereumTx( |
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.
Move this to account store
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 not sure what you mean. account/ethereum
uses createERC20TokenTransferTx
in transaction client, and createERC20TokenTransferTx
uses createSignableEthereumTx
.
Are you suggesting that account/ethereum
calls createERC20TokenTransferTx
in transaction client, which calls createSignableEthereumTx
once again in account/ethereum
?
@austinchandra Thank you for contribution! |
Add capability to:
Details
This PR builds infrastructure for ERC-20 tokens, similar to CW20 tokens, with a few distinctions. ERC20 queries differ from CW20 and Secret queries in that they query a JSON-RPC endpoint, rather than an HTTP endpoint. The infrastructure is built around this difference, while maintaining principles from the CW20 and Secret implementations.
Architecture
erc20/contract-query.ts
ObservableQueryERC20ContractData
class parallels theObservableCosmwasmContractChainQuery
class for CW20s, and serves as an extendable object to fulfill contract requests.ObservableJsonRPCQuery
classerc20/erc20-balance.ts
BalanceRegistry
by wrappingObservableQueryERC20ContractData
, as a parallel tocw20-balance.ts
erc20/erc20-contract-info.ts
ObservableQueryERC20ContractData
to provide atokenInfo()
response, to match the behavior provided incw20-contract-info.ts
erc20/queries.ts
ObservableQueryERC20ContractData
to provide a root query object, similar tocosmwasm/queries.ts
erc20/transaction-client.ts
erc20/types.ts
accounts/ethereum.ts
signEthereum
and theerc20/transaction-client
to do so.Notes
Support has not yet been implemented for mobile.
Demo
Token Management
https://user-images.githubusercontent.com/11379797/194942357-f0efaefc-16cb-4107-99ab-a5fadf78dacc.mov
Token Transfer via EVM
https://user-images.githubusercontent.com/11379797/208807580-c6fedd5d-e972-443a-bdf4-b682abcb4f92.mov
IBC Transfer of ERC-20 Token
https://user-images.githubusercontent.com/11379797/209244773-860ebca7-4e4b-4e70-82ee-2c083f8d023c.mov