solo
solo copied to clipboard
api.getAccountBalances AccountNotFoundError (400)
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.
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.
Hello, I also encountered the same problem, have you solved it? How was it resolved?
@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.
Is it convenient to show the relevant code?
This method is available on the mainnet. How should I obtain the mainnet of the fork?
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;
ok, thanks