Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanz0rz committed Jun 25, 2024
1 parent 30ca4b5 commit 5479171
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 69 deletions.
12 changes: 6 additions & 6 deletions sdk-clients/fusion/auctiondetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const (
uint32Max = math.MaxUint32
)

func NewAuctionDetails(startTime, duration, initialRateBump uint32, points []AuctionPointClassFixed, gasCost GasCostConfigClassFixed) (AuctionDetails, error) {
func NewAuctionDetails(startTime, duration, initialRateBump uint32, points []AuctionPointClassFixed, gasCost GasCostConfigClassFixed) (*AuctionDetails, error) {

if gasCost.GasBumpEstimate > uint24Max || gasCost.GasPriceEstimate > uint32Max ||
startTime > uint32Max || duration > uint24Max || initialRateBump > uint24Max {
return AuctionDetails{}, errors.New("values exceed their respective limits")
return nil, errors.New("values exceed their respective limits")
}

return AuctionDetails{
return &AuctionDetails{
StartTime: startTime,
Duration: duration,
InitialRateBump: initialRateBump,
Expand All @@ -28,14 +28,14 @@ func NewAuctionDetails(startTime, duration, initialRateBump uint32, points []Auc
}, nil
}

func DecodeAuctionDetails(data string) (AuctionDetails, error) {
func DecodeAuctionDetails(data string) (*AuctionDetails, error) {
bytes, err := hex.DecodeString(data)
if err != nil {
return AuctionDetails{}, errors.New("invalid hex data")
return nil, errors.New("invalid hex data")
}

if len(bytes) < 15 {
return AuctionDetails{}, errors.New("data too short")
return nil, errors.New("data too short")
}

gasBumpEstimate := binary.BigEndian.Uint32(append([]byte{0x00}, bytes[0:3]...))
Expand Down
2 changes: 1 addition & 1 deletion sdk-clients/fusion/auctiondetails_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAuctionDetails(t *testing.T) {
encoded := tc.details.Encode()
decoded, err := DecodeAuctionDetails(encoded)
require.NoError(t, err)
assert.Equal(t, tc.details, decoded)
assert.Equal(t, tc.details, *decoded)
})
}
}
Expand Down
2 changes: 0 additions & 2 deletions sdk-clients/fusion/bytesiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package fusion

import "math/big"

// Utility structures and functions

type BytesIter struct {
data []byte
pos int
Expand Down
47 changes: 0 additions & 47 deletions sdk-clients/fusion/fusionextension.go

This file was deleted.

5 changes: 0 additions & 5 deletions sdk-clients/fusion/interaction_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fusion

import (
"fmt"
"math/big"
"testing"

Expand All @@ -26,13 +25,9 @@ func TestInteraction(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
interaction := NewInteraction(tc.target, tc.data)
fmt.Printf("interaction: %v\n", interaction)
encoded := interaction.Encode()
fmt.Printf("encoded: %v\n", encoded)
decoded, err := DecodeInteraction(encoded)
require.NoError(t, err)
fmt.Printf("decoded: %v\n", decoded)

assert.Equal(t, interaction.Target, decoded.Target)
assert.Equal(t, interaction.Data, decoded.Data)
})
Expand Down
8 changes: 0 additions & 8 deletions sdk-clients/fusion/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,6 @@ func CreateFusionOrderData(quote GetQuoteOutputFixed, orderParams OrderParams, c
return nil, nil, fmt.Errorf("error creating fusion order: %v", err)
}

//fusionOrderIndented, err := json.MarshalIndent(fusionOrder, "", " ")
//if err != nil {
// panic("Error marshaling fusion order")
//}
//fmt.Printf("Fusion Order indented: %s\n", string(fusionOrderIndented))

// Add a decode makertraits function to avoid the extra return values

limitOrder, err := orderbook.CreateLimitOrderMessage(orderbook.CreateOrderParams{
MakerTraits: makerTraits,
Extension: *fusionOrder.FusionExtension.ConvertToOrderbookExtension(),
Expand Down

0 comments on commit 5479171

Please # to comment.