@renegade-fi/core
Version:
VanillaJS library for Renegade
22 lines • 901 B
JavaScript
import { GET_WALLET_ROUTE } from '../constants.js';
import { BaseError } from '../errors/base.js';
import { getRelayerWithAuth } from '../utils/http.js';
import { getWalletId } from './getWalletId.js';
export async function getWalletFromRelayer(config, parameters = {}) {
const { filterDefaults } = parameters;
const { getBaseUrl } = config;
const walletId = getWalletId(config);
const res = await getRelayerWithAuth(config, getBaseUrl(GET_WALLET_ROUTE(walletId)));
if (!res.wallet) {
throw new BaseError('Wallet not found');
}
if (filterDefaults) {
return {
...res.wallet,
balances: res.wallet.balances.filter((b) => b.amount || b.protocol_fee_balance || b.relayer_fee_balance),
orders: res.wallet.orders.filter((o) => o.amount),
};
}
return res.wallet;
}
//# sourceMappingURL=getWalletFromRelayer.js.map