8000 feat(werc20): WERC20 transactions by fedekunze · Pull Request #1991 · evmos/evmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

feat(werc20): WERC20 transactions #1991

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

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features

- (p256) [#1922](https://github.com/evmos/evmos/pull/1922) [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212) `secp256r1` curve precompile
- (werc20) [#1991](https://github.com/evmos/evmos/pull/1991) Add WERC-20 Precompile transactions.

### Improvements

Expand Down
46 changes: 46 additions & 0 deletions precompiles/werc20/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

package werc20

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/core/vm"
)

const (
// DepositMethod defines the ABI method name for the IWERC20 deposit
// transaction.
Expand All @@ -11,3 +17,43 @@ const (
// transaction.
WithdrawMethod = "withdraw"
)

// Deposit is a no-op and mock function that provides the same interface as the
// WETH contract to support equality between the native coin and its wrapped
// ERC-20 (eg. EVMOS and WEVMOS). It only emits the Deposit event.
func (p Precompile) Deposit(
ctx sdk.Context,
contract *vm.Contract,
stateDB vm.StateDB,
_ *abi.Method,
_ []interface{},
) ([]byte, error) {
dst := contract.Caller()
amount := contract.Value()

if err := p.EmitDepositEvent(ctx, stateDB, dst, amount); err != nil {
return nil, err
}

return nil, nil
}

// Withdraw is a no-op and mock function that provides the same interface as the
// WETH contract to support equality between the native coin and its wrapped
// ERC-20 (eg. EVMOS and WEVMOS). It only emits the Withdraw event.
func (p Precompile) Withdraw(
ctx sdk.Context,
contract *vm.Contract,
stateDB vm.StateDB,
_ *abi.Method,
_ []interface{},
) ([]byte, error) {
src := contract.Caller()
amount := contract.Value()

if err := p.EmitWithdrawEvent(ctx, stateDB, src, amount); err != nil {
return nil, err
}

return nil, nil
}
0