UNPKG

@zebec-fintech/silver-card-sdk

Version:
98 lines (97 loc) 3.48 kB
import { AxiosResponse } from "axios"; import { ethers } from "ethers"; import { KeyringPair } from "@polkadot/keyring/types"; import { Signer } from "@polkadot/types/types"; import { ERC20, ZebecCard } from "./artifacts"; import { SupportedChain } from "./chains"; import { Quote, Recipient } from "./types"; type APIConfig = { apiKey: string; encryptionKey: string; }; export declare class ZebecCardService { readonly signer: ethers.Signer; readonly zebecCard: ZebecCard; readonly usdcToken: ERC20; readonly chainId: SupportedChain; private readonly apiService; constructor(signer: ethers.Signer, chainId: number, apiConfig: APIConfig, sdkOptions?: { sandbox?: boolean; }); /** * 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(amount: string | number): Promise<Quote>; /** * Transfer specified amount from user's vault balance to card vault with some fee amount for card purchase. * @param params * @returns */ purchaseCard(params: { amount: string; recipient: Recipient; quote: Quote; }): Promise<[ ethers.ContractTransactionResponse, ethers.ContractTransactionResponse, AxiosResponse ]>; } export declare class ZebecCardTAOService { readonly signer: Signer | KeyringPair; private apiService; private taoRPC; private chainId; /** * Constructs an instance of the service. * * @param {Signer} signer - The signer which can be either a PolkadotJs Signer or a KeyringPair. * @param {APIConfig} apiConfig - The configuration object for the API. * @param sdkOptions - Optional configuration for the SDK. */ constructor(signer: Signer | KeyringPair, apiConfig: APIConfig, sdkOptions?: { sandbox?: boolean; }); /** * 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(amount: string | number): Promise<Quote>; /** * Fetches the TAO Vault address. * * @returns {Promise<string>} A promise that resolves to the TAO Vault address. */ fetchTAOVault(): Promise<string>; /** * Purchases a card by transferring TAO tokens. * * @param params - The parameters required to purchase a card. * @param params.walletAddress - The wallet address from which TAO tokens will be transferred. * @param params.amount - The amount of TAO tokens to transfer. * @param {Recipient} params.recipient - The recipient details. * @param {Quote} params.quote - The quote details. * * @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. */ purchaseCard(params: { walletAddress: string; amount: string; recipient: Recipient; quote: Quote; }): Promise<[ { txHash: string; blockHash: string; }, AxiosResponse ]>; } export {};