UNPKG

@akashicpay/sdk

Version:

SDK to interact with the Akashic ecosystem

164 lines (163 loc) 5.12 kB
import type { IKey } from '@activeledger/sdk'; import type { NodeStatus } from './APACTypes'; import type { ACDevNode, ACNode, AkashicBaseUrl, AkashicBaseUrlDev, AkashicPayBaseUrl, AkashicPayBaseUrlDev, Environment } from './constants'; import type { AkashicErrorCode } from './error'; export interface IBaseAcTransaction { $selfsign?: boolean; $sigs: any; $tx: IAcTxBody; } interface IAcTxBody { $entry?: string; $contract: string; $namespace: string; $i: any; $o?: any; $r?: any; _dbIndex?: number; $expire?: string; metadata?: IMetadata; } export interface IMetadata { initiatedToNonL2?: string; identifier?: string; feesEstimate?: string; } export type Otk = Required<IKey>; export interface KeyBackup { l2Address: string; privateKey: string; raw: Otk; } export interface HTTPResponse<ResponseDataT = unknown> { data: ResponseDataT; status: number; } export interface IHttpClient { post: <ResponseDataT = unknown>(url: string, payload: unknown) => Promise<HTTPResponse<ResponseDataT>>; get: <ResponseDataT = unknown>(url: string) => Promise<HTTPResponse<ResponseDataT>>; } export declare enum TronSymbol { Tron = "TRX", Tron_Shasta = "TRX-SHASTA" } export declare enum EthereumSymbol { Ethereum_Mainnet = "ETH", Ethereum_Sepolia = "SEP" } export declare const NetworkSymbol: { Ethereum_Mainnet: EthereumSymbol.Ethereum_Mainnet; Ethereum_Sepolia: EthereumSymbol.Ethereum_Sepolia; Tron: TronSymbol.Tron; Tron_Shasta: TronSymbol.Tron_Shasta; }; export type NetworkSymbol = TronSymbol | EthereumSymbol; export declare const MainNets: (TronSymbol | EthereumSymbol)[]; export declare const TestNets: (TronSymbol | EthereumSymbol)[]; export declare enum TokenSymbol { USDT = "USDT", TETHER = "Tether" } export interface IGetTransactions { page?: number; limit?: number; startDate?: Date; endDate?: Date; layer?: TransactionLayer; status?: TransactionStatus; type?: TransactionType; hideSmallTransactions?: boolean; } export interface IDepositAddress { address: string; identifier: string; } export interface IBalance { readonly networkSymbol: NetworkSymbol; readonly tokenSymbol?: TokenSymbol; readonly balance: string; } export interface ILookForL2AddressResult { readonly l2Address?: string; readonly alias?: string; } export interface IPayoutResponse { error?: AkashicErrorCode; l2Hash?: string; } export interface IGetByOwnerAndIdentifier { identifier: string; coinSymbol: NetworkSymbol; } export interface IGetKeysByOwnerAndIdentifier { identifier: string; } export interface ICreateDepositOrder { identity: string; expires: number; referenceId: string; identifier: string; toAddress?: string; coinSymbol?: NetworkSymbol; signature: string; } export interface ITransaction { readonly fromAddress: string; readonly toAddress: string; readonly layer: TransactionLayer; readonly initiatedAt: string; readonly confirmededAt: string; readonly amount: string; readonly coinSymbol: NetworkSymbol; readonly status: TransactionStatus; readonly txHash?: string; readonly feesPaid?: string; readonly l2TxnHash?: string; readonly tokenSymbol?: TokenSymbol; readonly reason?: string; readonly internalFee?: IInternalFee; readonly identifier?: string; } export declare enum TransactionLayer { L1 = "L1Transaction", L2 = "L2Transaction" } export declare enum TransactionStatus { PENDING = "Pending", CONFIRMED = "Confirmed", FAILED = "Failed" } export declare enum TransactionResult { SUCCESS = "Success", FAILURE = "Failure" } export declare enum TransactionType { DEPOSIT = "Deposit", WITHDRAWAL = "Withdrawal" } export interface IInternalFee { deposit?: string; withdraw?: string; } export type ACNodeT<Env extends Environment> = Env extends Environment.Production ? ACNode : ACDevNode; export type AkashicUrlT<Env extends Environment> = Env extends Environment.Production ? typeof AkashicBaseUrl : typeof AkashicBaseUrlDev; export type AkashicPayUrlT<Env extends Environment> = Env extends Environment.Production ? typeof AkashicPayBaseUrl : typeof AkashicPayBaseUrlDev; export type APConstructorArgs<Env extends Environment = Environment.Production> = { environment?: Env; targetNode?: Env extends Environment.Production ? ACNode : ACDevNode; akashicUrl?: Env extends Environment.Production ? typeof AkashicBaseUrl : typeof AkashicBaseUrlDev; }; type OTKPair = { l2Address: string; } & ({ recoveryPhrase: string; } | { privateKey: string; }); export type APInitialisationArgs<Env extends Environment = Environment.Production> = Env extends Environment.Production ? OTKPair : Partial<OTKPair>; export type APBuilderArgs<Env extends Environment = Environment.Production> = APConstructorArgs<Env> & APInitialisationArgs<Env>; export interface NodeResponsiveness<Env extends Environment> extends NodeStatus { ping: number; node: ACNodeT<Env>; } export {};