@zebec-network/exchange-card-sdk
Version:
An sdk for purchasing silver card in zebec
65 lines (64 loc) • 2.63 kB
TypeScript
import { Asset, Horizon } from "@stellar/stellar-sdk";
import { APIConfig, ZebecCardAPIService } from "../helpers/apiHelpers";
import { Quote } from "../types";
export interface XDBWalletInterface {
address: string;
signTransaction: (txXdr: string) => Promise<string>;
}
export declare class XDBService {
readonly wallet: XDBWalletInterface;
readonly apiService: ZebecCardAPIService;
readonly server: Horizon.Server;
private readonly 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: XDBWalletInterface, apiConfig: APIConfig, sdkOptions?: {
sandbox?: boolean;
apiKey?: string;
});
/**
* Fetches a quote for the given amount.
*
* @returns {Promise<Quote>} A promise that resolves to a Quote object.
*/
fetchQuote(symbol?: string): Promise<Quote>;
/**
* 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.
*/
transferXDB(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.
*/
getNativeBalance(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): Asset;
}