Skip to content

Commit

Permalink
improving web3 limit order structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanz0rz committed Apr 22, 2024
1 parent 74a6827 commit 4758c99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions orderbook/examples/create_order/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func main() {
publicKey := ecdsaPrivateKey.Public()
publicAddress := crypto.PubkeyToAddress(*publicKey.(*ecdsa.PublicKey))

seriesNonce, err := orderbook.GetSeriesNonce(ctx, client.Wallet, publicAddress)
seriesNonce, err := client.GetSeriesNonce(ctx, publicAddress)
if err != nil {
log.Fatal(fmt.Errorf("failed to get series nonce: %v", err))
}
Expand All @@ -60,7 +60,7 @@ func main() {
ChainId: chainId,
SeriesNonce: seriesNonce,
PrivateKey: privateKey,
ExpireAfter: time.Now().Add(time.Minute * 10).Unix(), // TODO update the field name to have "unix" suffix
ExpireAfter: time.Now().Add(time.Hour * 10).Unix(), // TODO update the field name to have "unix" suffix
Maker: publicAddress.Hex(),
MakerAsset: wmatic,
TakerAsset: usdc,
Expand Down
7 changes: 3 additions & 4 deletions orderbook/web3data.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
gethCommon "github.com/ethereum/go-ethereum/common"

"github.com/1inch/1inch-sdk-go/common"
"github.com/1inch/1inch-sdk-go/constants"
)

func GetSeriesNonce(ctx context.Context, wallet common.Wallet, publicAddress gethCommon.Address) (*big.Int, error) {
func (c *Client) GetSeriesNonce(ctx context.Context, publicAddress gethCommon.Address) (*big.Int, error) {

seriesNonceManager, err := constants.GetSeriesNonceManagerFromChainId(int(wallet.ChainId()))
seriesNonceManager, err := constants.GetSeriesNonceManagerFromChainId(int(c.Wallet.ChainId()))
if err != nil {
log.Fatal(fmt.Errorf("failed to get series nonce manager address: %v", err))
}
Expand All @@ -33,7 +32,7 @@ func GetSeriesNonce(ctx context.Context, wallet common.Wallet, publicAddress get
return nil, err
}

result, err := wallet.Call(ctx, gethCommon.HexToAddress(seriesNonceManager), seriesNonceData)
result, err := c.Wallet.Call(ctx, gethCommon.HexToAddress(seriesNonceManager), seriesNonceData)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4758c99

Please sign in to comment.