Skip to content

Commit

Permalink
Improving limit order web3 structure (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanz0rz authored Apr 22, 2024
1 parent f369a22 commit 32b0966
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions constants/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func Get1inchRouterFromChainId(chainId int) (string, error) {
return "", fmt.Errorf("unrecognized chain id: %d", chainId)
}
}

func GetSeriesNonceManagerFromChainId(chainId int) (string, error) {
switch chainId {
case ArbitrumChainId:
Expand Down
4 changes: 2 additions & 2 deletions orderbook/examples/create_order/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This can be done through your environment, or you can directly set them in the v

var (
privateKey = os.Getenv("WALLET_KEY")
nodeUrl = "https://polygon-bor-rpc.publicnode.com"
nodeUrl = os.Getenv("NODE_URL")
devPortalToken = os.Getenv("DEV_PORTAL_TOKEN")
)

Expand Down 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 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 32b0966

Please sign in to comment.