diff --git a/sdk-clients/fusion/auctiondetails.go b/sdk-clients/fusion/auctiondetails.go index 71c3970c..7589e57c 100644 --- a/sdk-clients/fusion/auctiondetails.go +++ b/sdk-clients/fusion/auctiondetails.go @@ -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, @@ -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]...)) diff --git a/sdk-clients/fusion/auctiondetails_test.go b/sdk-clients/fusion/auctiondetails_test.go index 294be418..b8d2dde8 100644 --- a/sdk-clients/fusion/auctiondetails_test.go +++ b/sdk-clients/fusion/auctiondetails_test.go @@ -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) }) } } diff --git a/sdk-clients/fusion/bytesiter.go b/sdk-clients/fusion/bytesiter.go index 06ba4e15..498ac888 100644 --- a/sdk-clients/fusion/bytesiter.go +++ b/sdk-clients/fusion/bytesiter.go @@ -2,8 +2,6 @@ package fusion import "math/big" -// Utility structures and functions - type BytesIter struct { data []byte pos int diff --git a/sdk-clients/fusion/fusionextension.go b/sdk-clients/fusion/fusionextension.go deleted file mode 100644 index 38472841..00000000 --- a/sdk-clients/fusion/fusionextension.go +++ /dev/null @@ -1,47 +0,0 @@ -package fusion - -import ( - "encoding/hex" - "fmt" - "math/big" - "strings" - "time" - - "github.com/ethereum/go-ethereum/crypto" -) - -func stringToHexBytes(hexStr string) ([]byte, error) { - // Strip the "0x" prefix if it exists - cleanedStr := strings.TrimPrefix(hexStr, "0x") - - // Ensure the string has an even length by padding with a zero if it's odd - if len(cleanedStr)%2 != 0 { - cleanedStr = "0" + cleanedStr - } - - // Decode the string into bytes - bytes, err := hex.DecodeString(cleanedStr) - if err != nil { - return nil, err - } - - return bytes, nil -} - -func BuildSalt(extension string) string { - if extension == "0x" { - return fmt.Sprintf("%d", time.Now().UnixNano()/int64(time.Millisecond)) - } - - byteConverted, err := stringToHexBytes(extension) - if err != nil { - panic(err) - } - - keccakHash := crypto.Keccak256Hash(byteConverted) - salt := new(big.Int).SetBytes(keccakHash.Bytes()) - // We need to keccak256 the extension and then bitwise & it with uint_160_max - var uint160Max = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 160), big.NewInt(1)) - salt.And(salt, uint160Max) - return fmt.Sprintf("0x%x", salt) -} diff --git a/sdk-clients/fusion/interaction_test.go b/sdk-clients/fusion/interaction_test.go index 496c6057..f867c32a 100644 --- a/sdk-clients/fusion/interaction_test.go +++ b/sdk-clients/fusion/interaction_test.go @@ -1,7 +1,6 @@ package fusion import ( - "fmt" "math/big" "testing" @@ -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) }) diff --git a/sdk-clients/fusion/order.go b/sdk-clients/fusion/order.go index 4b54e614..1d797671 100644 --- a/sdk-clients/fusion/order.go +++ b/sdk-clients/fusion/order.go @@ -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(),