@zebec-network/exchange-card-sdk
Version:
An sdk for purchasing silver card in zebec
74 lines (73 loc) • 2.98 kB
TypeScript
import { Asset, Horizon } from "@stellar/stellar-sdk";
import { APIConfig } from "../helpers/apiHelpers";
import { Quote } from "../types";
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, apiConfig: APIConfig, sdkOptions?: {
sandbox?: boolean;
apiKey?: string;
});
/**
* Fetches a quote for the given amount.
*
* @param {string | number} amount - The amount for which to fetch the quote.
* @returns {Promise<Quote>} A promise that resolves to a Quote object.
*/
fetchQuote(): 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.
*/
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>;
}