@eczodex/issuers-sdk
Version:
SDK for interacting with Eczodex issuer APIs.
44 lines (43 loc) • 1.83 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.linkBraleWallet = linkBraleWallet;
exports.getBraleWalletBalance = getBraleWalletBalance;
exports.listBraleWallets = listBraleWallets;
// src/adapters/braleWalletAdapter.ts
const axios_1 = __importDefault(require("axios"));
const BASE_URL = "https://api.brale.xyz";
/**
* Link a new external (non-custodial) wallet address to an account.
*/
async function linkBraleWallet(accountId, walletData, token, idempotencyKey) {
const url = `${BASE_URL}/accounts/${accountId}/addresses/external`;
const headers = {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
"Idempotency-Key": idempotencyKey,
};
const response = await axios_1.default.post(url, walletData, { headers });
return response.data;
}
/**
* Fetch balances for a given custodial wallet address.
* Requires `transfer_type` and `value_type` as query params.
*/
async function getBraleWalletBalance(accountId, addressId, token, transferType, valueType) {
const url = `${BASE_URL}/accounts/${accountId}/addresses/${addressId}/balances?transfer_type=${transferType}&value_type=${valueType}`;
const headers = { Authorization: `Bearer ${token}` };
const response = await axios_1.default.get(url, { headers });
return response.data;
}
/**
* Fetch all wallet addresses linked to the specified account.
*/
async function listBraleWallets(accountId, token) {
const url = `${BASE_URL}/accounts/${accountId}/addresses`;
const headers = { Authorization: `Bearer ${token}` };
const response = await axios_1.default.get(url, { headers });
return response.data;
}