Skip to content

Commit

Permalink
Revert "Order => ZOrder renaming to avoid duplicate symbol"
Browse files Browse the repository at this point in the history
This reverts commit 693f945.
  • Loading branch information
albertchon committed Oct 17, 2020
1 parent adc7d9d commit eaec259
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 82 deletions.
2 changes: 1 addition & 1 deletion eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var eip712OrderTypes = gethsigner.Types{
Type: "address",
},
},
"ZOrder": {
"Order": {
{
Name: "makerAddress",
Type: "address",
Expand Down
16 changes: 8 additions & 8 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func DecodeFromTransactionData(data []byte) (txData *ZeroExTransactionData, err

txData = &ZeroExTransactionData{
FunctionName: ExchangeFunctionName(method.Name),
Orders: make([]*ZOrder, 1),
Orders: make([]*Order, 1),
TakerAssetFillAmounts: make([]*big.Int, 1),
Signatures: make([][]byte, 1),
}
Expand All @@ -124,7 +124,7 @@ func DecodeFromTransactionData(data []byte) (txData *ZeroExTransactionData, err

txData = &ZeroExTransactionData{
FunctionName: ExchangeFunctionName(method.Name),
Orders: make([]*ZOrder, len(inputs.Orders)),
Orders: make([]*Order, len(inputs.Orders)),
TakerAssetFillAmounts: make([]*big.Int, len(inputs.TakerAssetFillAmounts)),
Signatures: make([][]byte, len(inputs.Signatures)),
}
Expand Down Expand Up @@ -153,7 +153,7 @@ func DecodeFromTransactionData(data []byte) (txData *ZeroExTransactionData, err

txData = &ZeroExTransactionData{
FunctionName: ExchangeFunctionName(method.Name),
Orders: make([]*ZOrder, len(inputs.Orders)),
Orders: make([]*Order, len(inputs.Orders)),
Signatures: make([][]byte, len(inputs.Signatures)),
}
for idx, order := range inputs.Orders {
Expand All @@ -179,7 +179,7 @@ func DecodeFromTransactionData(data []byte) (txData *ZeroExTransactionData, err

txData = &ZeroExTransactionData{
FunctionName: ExchangeFunctionName(method.Name),
Orders: make([]*ZOrder, len(inputs.Orders)),
Orders: make([]*Order, len(inputs.Orders)),
Signatures: make([][]byte, len(inputs.Signatures)),
}
for idx, order := range inputs.Orders {
Expand All @@ -204,7 +204,7 @@ func DecodeFromTransactionData(data []byte) (txData *ZeroExTransactionData, err

txData = &ZeroExTransactionData{
FunctionName: ExchangeFunctionName(method.Name),
Orders: make([]*ZOrder, 1),
Orders: make([]*Order, 1),
}
txData.Orders[0] = FromTrimmedOrder(inputs.Order)

Expand All @@ -220,7 +220,7 @@ func DecodeFromTransactionData(data []byte) (txData *ZeroExTransactionData, err

txData = &ZeroExTransactionData{
FunctionName: ExchangeFunctionName(method.Name),
Orders: make([]*ZOrder, len(inputs.Orders)),
Orders: make([]*Order, len(inputs.Orders)),
}
for idx, order := range inputs.Orders {
txData.Orders[idx] = FromTrimmedOrder(order)
Expand All @@ -239,8 +239,8 @@ func DecodeFromTransactionData(data []byte) (txData *ZeroExTransactionData, err

txData = &ZeroExTransactionData{
FunctionName: ExchangeFunctionName(method.Name),
LeftOrders: make([]*ZOrder, len(inputs.LeftOrders)),
RightOrders: make([]*ZOrder, len(inputs.RightOrders)),
LeftOrders: make([]*Order, len(inputs.LeftOrders)),
RightOrders: make([]*Order, len(inputs.RightOrders)),
LeftSignatures: make([][]byte, len(inputs.LeftSignatures)),
RightSignatures: make([][]byte, len(inputs.RightSignatures)),
}
Expand Down
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/ethereum/go-ethereum v1.9.1/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY=
github.com/ethereum/go-ethereum v1.9.13 h1:rOPqjSngvs1VSYH2H+PMPiWt4VEulvNRbFgqiGqJM3E=
github.com/ethereum/go-ethereum v1.9.13/go.mod h1:qwN9d1GLyDh0N7Ab8bMGd0H9knaji2jOBm2RrMGjXls=
github.com/ethereum/go-ethereum v1.9.18 h1:+vzvufVD7+OfQa07IJP20Z7AGZsJaw0M6JIA/WQcqy8=
github.com/ethereum/go-ethereum v1.9.18/go.mod h1:JSSTypSMTkGZtAdAChH2wP5dZEvPGh3nUTuDpH+hNrg=
github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc h1:jtW8jbpkO4YirRSyepBOH8E+2HEw6/hKkBvFPwhUN8c=
Expand Down Expand Up @@ -135,7 +134,6 @@ github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26 h1:lMm2hD9Fy0ynom5+85/pbdkiYcBqM1JWmhpAXLmy0fw=
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand All @@ -157,7 +155,6 @@ github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad h1:eMxs9EL0Pv
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/holiman/uint256 v1.1.1 h1:4JywC80b+/hSfljFlEBLHrrh+CIONLDz9NuFl0af4Mw=
github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
Expand Down Expand Up @@ -243,7 +240,6 @@ github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222 h1:goeTyGkArOZIVOMA0d
github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/pierrec/lz4 v2.4.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -283,7 +279,6 @@ github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521 h1:3hxavr+IHMsQBrYUPQM
github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shirou/gopsutil v2.20.5+incompatible h1:tYH07UPoQt0OCQdgWWMgYHy3/a9bcxNpBIysykNIP7I=
github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down Expand Up @@ -330,7 +325,6 @@ golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904 h1:bXoxMPcSLOq08zI3/c5dEBT6lE4eh+jOh886GHrn6V8=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand All @@ -353,7 +347,6 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3ob
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
34 changes: 17 additions & 17 deletions order.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/InjectiveLabs/zeroex-go/wrappers"
)

// ZOrder represents an unsigned 0x order
type ZOrder struct {
// Order represents an unsigned 0x order
type Order struct {
ChainID *big.Int `json:"chainId"`
ExchangeAddress common.Address `json:"exchangeAddress"`
MakerAddress common.Address `json:"makerAddress"`
Expand All @@ -41,17 +41,17 @@ type ZOrder struct {

// SignedOrder represents a signed 0x order
type SignedOrder struct {
ZOrder
Order
Signature []byte `json:"signature"`
}

// ResetHash resets the cached order hash. Usually only required for testing.
func (o *ZOrder) ResetHash() {
func (o *Order) ResetHash() {
o.hash = nil
}

// ComputeOrderHash computes a 0x order hash
func (o *ZOrder) ComputeOrderHash() (common.Hash, error) {
func (o *Order) ComputeOrderHash() (common.Hash, error) {
if o.hash != nil {
return *o.hash, nil
}
Expand Down Expand Up @@ -83,7 +83,7 @@ func (o *ZOrder) ComputeOrderHash() (common.Hash, error) {

var typedData = gethsigner.TypedData{
Types: eip712OrderTypes,
PrimaryType: "ZOrder",
PrimaryType: "Order",
Domain: domain,
Message: message,
}
Expand All @@ -109,7 +109,7 @@ func (o *ZOrder) ComputeOrderHash() (common.Hash, error) {
}

// SignOrder signs the 0x order with the supplied Signer.
func SignOrder(signer Signer, order *ZOrder) (*SignedOrder, error) {
func SignOrder(signer Signer, order *Order) (*SignedOrder, error) {
if order == nil {
return nil, errors.New("cannot sign nil order")
}
Expand All @@ -131,7 +131,7 @@ func SignOrder(signer Signer, order *ZOrder) (*SignedOrder, error) {
copy(signature[33:65], ecSignature.S[:])
signature[65] = byte(EthSignSignature)
signedOrder := &SignedOrder{
ZOrder: *order,
Order: *order,
Signature: signature,
}

Expand Down Expand Up @@ -159,8 +159,8 @@ func (s *SignedOrder) Trim() wrappers.Order {
}
}

func FromTrimmedOrder(order wrappers.Order) *ZOrder {
return &ZOrder{
func FromTrimmedOrder(order wrappers.Order) *Order {
return &Order{
MakerAddress: order.MakerAddress,
MakerAssetData: order.MakerAssetData,
MakerFeeAssetData: order.MakerFeeAssetData,
Expand All @@ -178,7 +178,7 @@ func FromTrimmedOrder(order wrappers.Order) *ZOrder {
}
}

// TrimmedOrderJSON is an unmodified JSON representation of a Trimmed ZOrder
// TrimmedOrderJSON is an unmodified JSON representation of a Trimmed Order
type TrimmedOrderJSON struct {
MakerAddress string `json:"makerAddress"`
MakerAssetData string `json:"makerAssetData"`
Expand All @@ -196,8 +196,8 @@ type TrimmedOrderJSON struct {
Salt string `json:"salt"`
}

// MarshalJSON implements a custom JSON marshaller for the ZOrder type into Trimmed ZOrder
func (o *ZOrder) MarshalIntoTrimmedOrderJSON() ([]byte, error) {
// MarshalJSON implements a custom JSON marshaller for the Order type into Trimmed Order
func (o *Order) MarshalIntoTrimmedOrderJSON() ([]byte, error) {
makerAssetData := "0x"
if len(o.MakerAssetData) != 0 {
makerAssetData = fmt.Sprintf("0x%s", common.Bytes2Hex(o.MakerAssetData))
Expand Down Expand Up @@ -366,13 +366,13 @@ func (s *SignedOrder) UnmarshalJSON(data []byte) error {
return nil
}

// ZOrderStatus represents the status of an order as returned from the 0x smart contracts
// OrderStatus represents the status of an order as returned from the 0x smart contracts
// as part of OrderInfo
type ZOrderStatus uint8
type OrderStatus uint8

// ZOrderStatus values
// OrderStatus values
const (
OSInvalid ZOrderStatus = iota
OSInvalid OrderStatus = iota
OSInvalidMakerAssetAmount
OSInvalidTakerAssetAmount
OSFillable
Expand Down
6 changes: 3 additions & 3 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ func (tx *Transaction) ComputeTransactionHash() (common.Hash, error) {

type ZeroExTransactionData struct {
FunctionName ExchangeFunctionName
Orders []*ZOrder
LeftOrders []*ZOrder
RightOrders []*ZOrder
Orders []*Order
LeftOrders []*Order
RightOrders []*Order
TakerAssetFillAmounts []*big.Int
MakerAssetFillAmount *big.Int
TakerAssetFillAmount *big.Int
Expand Down
Loading

0 comments on commit eaec259

Please sign in to comment.