@zebec-network/exchange-card-sdk
Version:
An sdk for purchasing silver card in zebec
91 lines (90 loc) • 3.05 kB
TypeScript
import algosdk from "algosdk";
import { AlgorandClient } from "@algorandfoundation/algokit-utils";
import { APIConfig } from "../helpers/apiHelpers";
import { Quote } from "../types";
/**
* Configuration interface for algo transfers
* */
export interface TransferConfig {
amount: number | string;
note?: string;
}
/**
* Configuration interface for USDC transfers
* */
export interface TokenTransferConfig {
/** Asset ID for Asset (e.g. for USDC 31566704) */
assetId: number;
amount: number | string;
note?: string;
}
export interface AlgorandWallet {
address: string;
signAndSendTransaction: (txn: algosdk.Transaction) => Promise<string>;
}
export declare class AlgorandService {
readonly wallet: AlgorandWallet;
readonly apiConfig: APIConfig;
readonly algodClient: algosdk.Algodv2;
readonly algorandClient: AlgorandClient;
private apiService;
private readonly network;
constructor(wallet: AlgorandWallet, apiConfig: APIConfig, sdkOptions?: {
sandbox?: boolean;
});
/**
* Fetches a quote for Bitcoin transfer.
*
* @returns {Promise<Quote>} A promise that resolves to a Quote object.
*/
fetchQuote(symbol?: string): Promise<Quote>;
/**
* Fetches the Bitcoin vault address.
*
* @returns {Promise<{ address: string }>} A promise that resolves to the vault address.
*/
fetchVault(symbol?: string): Promise<{
address: string;
tag?: string;
}>;
/**
* Transfer Algorand currency from one wallet to another
* @param config Transfer configuration
* @returns Transaction ID if successful
*/
transferAlgo(config: TransferConfig): Promise<string>;
/**
* Transfer USDC (ASA token) from wallet to vault
* @param config USDC transfer configuration
* @returns Transaction ID if successful
*/
transferAsset(config: TokenTransferConfig): Promise<string>;
/**
* Check if an account is opted into a specific asset
* @param address Account address
* @param assetId Asset ID to check
* @returns Whether the account is opted into the asset
*/
isOptedIntoAsset(address: string, assetId: number): Promise<boolean>;
/**
* Get asset balance for a specific account in microAsset (base units)
* @param address Account address
* @param assetId Asset ID
* @returns Asset balance in base units
*/
private getAssetBalanceInMicroUnit;
getAssetBalance(walletAddress: string, assetId: number): Promise<string>;
getAssetsBalance(walletAddress: string, assetIds: number[]): Promise<Map<number, string>>;
/**
* Get account balance in Algos
* @param address Account address
* @returns Balance in ALGO
*/
getAccountBalance(address: string | algosdk.Address): Promise<string>;
/**
* Get account balance in microAlgos (for internal calculations)
* @param address Account address
* @returns Balance in microAlgos
*/
private getAccountBalanceInMicroAlgo;
}