Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #579 from 0xProject/fix/null-fee-asset-data
Browse files Browse the repository at this point in the history
Handle null fee asset data in browser bindings
  • Loading branch information
albrow authored Dec 12, 2019
2 parents 2a29376 + 9d46ed3 commit e881b7d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This changelog is a work in progress and may contain notes for versions which have not actually been released. Check the [Releases](https://github.com/0xProject/0x-mesh/releases) page to see full release notes and more information about the latest released versions.

## v7.2.2-beta-0xv3

### Bug fixes 🐞

- Fixed a bug where `makerAssetFeeData` or `takerAssetFeeData` were sometimes being set to an empty string instead of `0x` in the browser ([#579](https://github.com/0xProject/0x-mesh/pull/579)).

## v7.2.1-beta-0xv3

### Bug fixes 🐞
Expand Down
3 changes: 3 additions & 0 deletions zeroex/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ func (s SignedOrder) MarshalJSON() ([]byte, error) {
if len(s.MakerAssetData) != 0 {
makerAssetData = fmt.Sprintf("0x%s", common.Bytes2Hex(s.MakerAssetData))
}
// Note(albrow): Because of how our smart contracts work, most fields of an
// order cannot be null. However, makerAssetFeeData and takerAssetFeeData are
// the exception. For these fields, "0x" is used to indicate a null value.
makerFeeAssetData := "0x"
if len(s.MakerFeeAssetData) != 0 {
makerFeeAssetData = fmt.Sprintf("0x%s", common.Bytes2Hex(s.MakerFeeAssetData))
Expand Down
22 changes: 13 additions & 9 deletions zeroex/order_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"strings"
"syscall/js"

"github.com/ethereum/go-ethereum/common"
)

Expand All @@ -17,7 +18,7 @@ func (o OrderEvent) JSValue() js.Value {
return js.ValueOf(map[string]interface{}{
"orderHash": o.OrderHash.Hex(),
"signedOrder": o.SignedOrder.JSValue(),
"endState": string(o.EndState),
"endState": string(o.EndState),
"fillableTakerAssetAmount": o.FillableTakerAssetAmount.String(),
"contractEvents": contractEventsJS,
})
Expand All @@ -28,15 +29,18 @@ func (s SignedOrder) JSValue() js.Value {
if len(s.MakerAssetData) != 0 {
makerAssetData = fmt.Sprintf("0x%s", common.Bytes2Hex(s.MakerAssetData))
}
makerFeeAssetData := ""
// Note(albrow): Because of how our smart contracts work, most fields of an
// order cannot be null. However, makerAssetFeeData and takerAssetFeeData are
// the exception. For these fields, "0x" is used to indicate a null value.
makerFeeAssetData := "0x"
if len(s.MakerFeeAssetData) != 0 {
makerFeeAssetData = fmt.Sprintf("0x%s", common.Bytes2Hex(s.MakerFeeAssetData))
}
takerAssetData := ""
if len(s.TakerAssetData) != 0 {
takerAssetData = fmt.Sprintf("0x%s", common.Bytes2Hex(s.TakerAssetData))
}
takerFeeAssetData := ""
takerFeeAssetData := "0x"
if len(s.TakerFeeAssetData) != 0 {
takerFeeAssetData = fmt.Sprintf("0x%s", common.Bytes2Hex(s.TakerFeeAssetData))
}
Expand Down Expand Up @@ -68,12 +72,12 @@ func (s SignedOrder) JSValue() js.Value {

func (c ContractEvent) JSValue() js.Value {
m := map[string]interface{}{
"blockHash": c.BlockHash.Hex(),
"txHash": c.TxHash.Hex(),
"txIndex": c.TxIndex,
"logIndex": c.LogIndex,
"isRemoved": c.IsRemoved,
"kind": c.Kind,
"blockHash": c.BlockHash.Hex(),
"txHash": c.TxHash.Hex(),
"txIndex": c.TxIndex,
"logIndex": c.LogIndex,
"isRemoved": c.IsRemoved,
"kind": c.Kind,
"parameters": c.Parameters.(js.Wrapper).JSValue(),
}
return js.ValueOf(m)
Expand Down

0 comments on commit e881b7d

Please sign in to comment.