@zebec-network/exchange-card-sdk
Version:
An sdk for purchasing silver card in zebec
137 lines (136 loc) • 3.82 kB
TypeScript
import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
import { AleoNetworkClient as TestnetAleoNetworkClient } from "@provablehq/sdk/testnet.js";
import { ZebecCardAPIService } from "../helpers/apiHelpers";
/**
* Supported Aleo networks
*/
export declare enum Network {
MAINNET = "mainnet",
TESTNET = "testnet",
CANARY = "canary"
}
/**
* Transaction creation options
*/
export interface TransactionOptions {
/**
* The program to execute
*/
program: string;
/**
* The function to call
*/
function: string;
/**
* The function inputs
*/
inputs: string[];
/**
* The transaction fee to pay
*/
fee?: number;
/**
* Record indices to use
*/
recordIndices?: number[];
/**
* Whether the fee is private
*/
privateFee?: boolean;
}
interface AleoNetworkClientOptions {
headers?: {
[key: string]: string;
};
proverUri?: string;
recordScannerUri?: string;
}
export interface AleoWallet {
address: string;
decrypt: (cipherText: string) => Promise<string>;
requestRecords: (program: string, includePlaintext?: boolean | undefined) => Promise<unknown[]>;
executeTransaction: (options: TransactionOptions) => Promise<{
transactionId: string;
}>;
}
export type AleoTransferCreditParams = {
amount: number | string;
transferType?: "public" | "private";
fee?: number;
privateFee?: boolean;
recipient?: string;
};
export type AleoTransferStableCoinParams = {
programId: "usad_stablecoin.aleo" | "usdcx_stablecoin.aleo";
amount: number | string;
transferType?: "public" | "private";
fee?: number;
privateFee?: boolean;
recipient?: string;
};
export declare const NETWORK_CONFIG: {
mainnet: {
explorer: string;
stablecoins: {
usad: string;
usdcx: string;
};
freezeListApi: {
usad: string;
usdcx: string;
};
};
testnet: {
explorer: string;
stablecoins: {
usad: string;
usdcx: string;
};
freezeListApi: {
usad: string;
usdcx: string;
};
};
};
export declare class AleoService {
readonly wallet: AleoWallet;
readonly sandbox: boolean;
readonly apiService: ZebecCardAPIService;
readonly networkClient: AleoNetworkClient | TestnetAleoNetworkClient;
constructor(wallet: AleoWallet, aleoNetworkClientOptions?: AleoNetworkClientOptions, sdkOptions?: {
sandbox?: boolean;
});
/**
* 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;
}>;
/**
* Fetch unspent records for a program, decrypt them, and return the one
* with the highest non-zero balance as a single-line plaintext string.
*/
private _getRecord;
/**
* Build a Sealance Merkle exclusion proof proving the sender is NOT on the
* program's freeze list. Required for compliant stablecoin transfers.
*/
private _getComplianceProof;
/**
* Transfer native Aleo credits to the specified recipient.
*/
transferCredit(params: AleoTransferCreditParams): Promise<{
transactionId: string;
}>;
transferStableCoin(params: AleoTransferStableCoinParams): Promise<{
transactionId: string;
}>;
getPublicBalance(): Promise<string>;
getPublicTokenBalance(tokenProgramId: string, tokenSymbol: string): Promise<string>;
getPrivateBalance(): Promise<string>;
getPrivateTokenBalance(tokenProgramId: string, tokenSymbol: string): Promise<string>;
}
export {};