Skip to content

Commit

Permalink
Merge branch 'main' into feat/enable-08-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang authored Oct 31, 2024
2 parents 68db735 + bf70839 commit dccee9c
Show file tree
Hide file tree
Showing 34 changed files with 8,869 additions and 4,687 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ throwing an error and (2) ERC20 transfers with other operations that don't bring
about the expected resulting balance for the transfer recipient.
- [#2092](https://github.com/NibiruChain/nibiru/pull/2092) - feat(evm): add validation for wasm multi message execution
- [#2068](https://github.com/NibiruChain/nibiru/pull/2068) - feat: enable wasm light clients on IBC (08-wasm)
- [#2101](https://github.com/NibiruChain/nibiru/pull/2101) - fix(evm): tx receipt proper marshalling

#### Nibiru EVM | Before Audit 1 - 2024-10-18

Expand Down
36 changes: 33 additions & 3 deletions eth/rpc/backend/tx_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package backend

import (
"encoding/json"
"fmt"
"math"
"math/big"
Expand Down Expand Up @@ -134,10 +135,39 @@ func (b *Backend) getTransactionByHashPending(txHash gethcommon.Hash) (*rpc.EthT
type TransactionReceipt struct {
gethcore.Receipt

ContractAddress *gethcommon.Address `json:"contractAddress,omitempty"`
ContractAddress *gethcommon.Address
From gethcommon.Address
To *gethcommon.Address
EffectiveGasPrice *big.Int
EffectiveGasPrice *hexutil.Big
}

// MarshalJSON is necessary because without it non gethcore.Receipt fields are omitted
func (r *TransactionReceipt) MarshalJSON() ([]byte, error) {
// Marshal / unmarshal gethcore.Receipt to produce map[string]interface{}
receiptJson, err := json.Marshal(r.Receipt)
if err != nil {
return nil, err
}

var output map[string]interface{}
if err := json.Unmarshal(receiptJson, &output); err != nil {
return nil, err
}

// Add extra (non gethcore.Receipt) fields:
if r.ContractAddress != nil && *r.ContractAddress != (gethcommon.Address{}) {
output["contractAddress"] = r.ContractAddress
}
if r.From != (gethcommon.Address{}) {
output["from"] = r.From
}
if r.To != nil {
output["to"] = r.To
}
if r.EffectiveGasPrice != nil {
output["effectiveGasPrice"] = r.EffectiveGasPrice
}
return json.Marshal(output)
}

// GetTransactionReceipt returns the transaction receipt identified by hash.
Expand Down Expand Up @@ -253,7 +283,7 @@ func (b *Backend) GetTransactionReceipt(hash gethcommon.Hash) (*TransactionRecei
// tolerate the error for pruned node.
b.logger.Error("fetch basefee failed, node is pruned?", "height", res.Height, "error", err)
} else {
receipt.EffectiveGasPrice = dynamicTx.EffectiveGasPriceWeiPerGas(baseFeeWei)
receipt.EffectiveGasPrice = (*hexutil.Big)(dynamicTx.EffectiveGasPriceWeiPerGas(baseFeeWei))
}
}
return &receipt, nil
Expand Down
4 changes: 2 additions & 2 deletions eth/rpc/backend/tx_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ func (s *BackendSuite) TestReceiptMarshalJson() {
ContractAddress: nil,
From: evmtest.NewEthPrivAcc().EthAddr,
To: &toAddr,
EffectiveGasPrice: big.NewInt(1),
EffectiveGasPrice: (*hexutil.Big)(big.NewInt(1)),
}

jsonBz, err := json.Marshal(tr)
jsonBz, err := tr.MarshalJSON()
s.Require().NoError(err)

gethReceipt := new(gethcore.Receipt)
Expand Down
10 changes: 10 additions & 0 deletions evm-e2e/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2,
"importOrder": ["^@core/(.*)$", "^@server/(.*)$", "^@ui/(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
}
10 changes: 10 additions & 0 deletions evm-e2e/contracts/EventsEmitter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract EventsEmitter {
event TestEvent(address indexed sender, uint256 value);

function emitEvent(uint256 value) public {
emit TestEvent(msg.sender, value);
}
}
31 changes: 0 additions & 31 deletions evm-e2e/contracts/InfiniteLoopGasCompiled.json

This file was deleted.

32 changes: 0 additions & 32 deletions evm-e2e/contracts/ReceiveNibiCompiled.json

This file was deleted.

50 changes: 0 additions & 50 deletions evm-e2e/contracts/SendNibiCompiled.json

This file was deleted.

Loading

0 comments on commit dccee9c

Please sign in to comment.