UNPKG

@zebec-network/exchange-card-sdk

Version:
65 lines (64 loc) 2.62 kB
import { Asset, Horizon } from "@zebec-fintech/stellar-sdk"; export interface StellarWallet { address: string; signTransaction: (txXdr: string) => Promise<string>; } export declare class StellarService { readonly wallet: StellarWallet; private apiService; readonly server: Horizon.Server; private sandbox; /** * Constructs an instance of the service. * * @param {DigitalBitsSdk.Keypair} signer - The signer keypair for the DigitalBits wallet. * @param {APIConfig} apiConfig - The configuration object for the API. * @param sdkOptions - Optional configuration for the SDK. */ constructor(wallet: StellarWallet, sdkOptions?: { sandbox?: boolean; apiKey?: string; }); /** * Fetches the Vault address. * * @returns {Promise<string>} A promise that resolves to the Vault address. */ fetchVault(symbol?: string): Promise<{ address: string; tag?: string; }>; /** * Purchases a card by transferring XDB tokens. * * @param params - The parameters required to purchase a card. * @returns A promise that resolves to an array containing the transaction details and the API response. * @throws {InvalidEmailError} If the recipient's email address is invalid. * @throws {Error} If the quote is invalid or expired, if there is not enough balance, or if the transaction fails. */ transferXLM(amount: string): Promise<string>; /** * Transfers USDC tokens. * * @param {string} amount - The amount of USDC to transfer. * @returns {Promise<string>} A promise that resolves to the transaction hash. * @throws {Error} If there is not enough USDC balance or if the transaction fails. */ transferUSDC(amount: string): Promise<string>; /** * Retrieves the balance of the specified wallet. * * @param {string} wallet - The public key of the wallet to get the balance for. * @returns {Promise<string>} - A promise that resolves to the balance of the wallet. */ getWalletBalance(wallet: string): Promise<string>; /** * Retrieves the balance of a specific token for the specified wallet. * * @param {string} wallet - The public key of the wallet to get the token balance for. * @param {Asset} asset - The asset object representing the token. * @returns {Promise<string>} - A promise that resolves to the balance of the token. */ getTokenBalance(wallet: string, asset: Asset): Promise<string>; getAsset(assetCode: string, assetIssuer: string): Promise<Asset>; }