Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

api.getAccountBalances AccountNotFoundError (400) #507

Open
aaronmboyd opened this issue Jan 16, 2021 · 7 comments
Open

api.getAccountBalances AccountNotFoundError (400) #507

aaronmboyd opened this issue Jan 16, 2021 · 7 comments

Comments

@aaronmboyd
Copy link

Solo api.getAccountBalances facade to the API does not work, always returns 400.

Using the example account from the documentation, the following works and returns an empty account:

curl https://api.dydx.exchange/v1/accounts/0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5
{
    "owner": "0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5",
    "accountUuids": [],
    "accounts": []
}

Using solo, for example:

const account : ApiAccount = await solo.api.getAccountBalances(
    {accountOwner:"0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5", accountNumber: "0"});

Always fails with

{"response":{"data":{"errors":[{"name":"AccountNotFoundError"}]},"status":400,"statusText":"Bad Request"}}

I have tried using accountNumber: new BigNumber("0") which also fails, have also tried using my own account which does have some balances, and also returns a full JSON response simply hitting the API directly.

@aaronmboyd
Copy link
Author

Further inspection of the code shows the axios call as:
${this.endpoint}/v1/accounts/${accountOwner}?number=${numberStr}

Trying this directly with Postman and adding in the number query parameter replicates the error.

What is this number meant to be? It defaults to zero if not provided, but even zero just returns a "AccountNotFoundError" / 400.

@wzzYtu
Copy link

wzzYtu commented Mar 16, 2021

Hello, I also encountered the same problem, have you solved it? How was it resolved?

@aaronmboyd
Copy link
Author

@wzzYtu I got around it by not using the solo SDK and calling the API directly: /v1/accounts/<address> and then retrieving balances from the balances object.

@wzzYtu
Copy link

wzzYtu commented Mar 17, 2021

Is it convenient to show the relevant code?

@wzzYtu
Copy link

wzzYtu commented Mar 18, 2021

This method is available on the mainnet. How should I obtain the mainnet of the fork?

@aaronmboyd
Copy link
Author

Is it convenient to show the relevant code?

Here's the approximate code I used to get the account without going through the solo SDK:

    const TIMEOUT = 10000;
    const HEADERS = {
      "Content-Type": "application/json;charset=utf-8",
      Accept: "*/*",
    };
    const HOST = "https://api.dydx.exchange";

    const instance = axios.create({
      baseURL: HOST,
      timeout: TIMEOUT,
      headers: HEADERS,
    });

    const response = await instance.get(
      HOST + "/v1/accounts/" + wallet.address
    );
    const account = response.data;
    return account;

@wzzYtu
Copy link

wzzYtu commented Mar 19, 2021

ok, thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants