Skip to content

Commit

Permalink
reterive value from the msg
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Jun 13, 2024
1 parent 8599d54 commit 0d7716d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions x/evm/keeper/txutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func (u *TxUtils) ConvertEthereumTxToCosmosTx(ctx context.Context, ethTx *corety
Type: ethTx.Type(),
GasFeeCap: gasFeeCap.String(),
GasTipCap: gasTipCap.String(),
Value: ethTx.Value().String(),
})
if err != nil {
return nil, err
Expand All @@ -172,7 +171,6 @@ type metadata struct {
Type uint8 `json:"type"`
GasFeeCap string `json:"gas_fee_cap"`
GasTipCap string `json:"gas_tip_cap"`
Value string `json:"value"`
}

// ConvertCosmosTxToEthereumTx converts a Cosmos SDK transaction to an Ethereum transaction.
Expand Down Expand Up @@ -206,6 +204,10 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx)
if err != nil {
return nil, nil, err
}

Check warning on line 206 in x/evm/keeper/txutils.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/txutils.go#L205-L206

Added lines #L205 - L206 were not covered by tests
decimals, err := u.ERC20Keeper().GetDecimals(ctx, params.FeeDenom)
if err != nil {
return nil, nil, err
}

Check warning on line 210 in x/evm/keeper/txutils.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/txutils.go#L209-L210

Added lines #L209 - L210 were not covered by tests

if len(fees) > 0 && fees[0].Denom != params.FeeDenom {
return nil, nil, nil
Expand Down Expand Up @@ -253,13 +255,9 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx)
return nil, nil, err
}

Check warning on line 256 in x/evm/keeper/txutils.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/txutils.go#L255-L256

Added lines #L255 - L256 were not covered by tests

value, ok := new(big.Int).SetString(md.Value, 10)
if !ok {
return nil, nil, err
}

var to *common.Address
var input []byte
var value *big.Int
switch typeUrl {
case "/minievm.evm.v1.MsgCall":
callMsg := msg.(*types.MsgCall)
Expand All @@ -275,6 +273,7 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx)

to = &contractAddr
input = data
value = types.FromEthersUnit(decimals, callMsg.Value.BigInt())
case "/minievm.evm.v1.MsgCreate":
createMsg := msg.(*types.MsgCreate)
data, err := hexutil.Decode(createMsg.Code)
Expand All @@ -284,7 +283,7 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx)

to = nil
input = data

value = types.FromEthersUnit(decimals, createMsg.Value.BigInt())
case "/minievm.evm.v1.MsgCreate2":
// create2 is not supported
return nil, nil, nil

Check warning on line 289 in x/evm/keeper/txutils.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/txutils.go#L284-L289

Added lines #L284 - L289 were not covered by tests
Expand Down

0 comments on commit 0d7716d

Please sign in to comment.