@dojima-wallet/connection
Version:
Initialise and connection for layer 1&2 blockchain
51 lines (50 loc) • 2.75 kB
TypeScript
import { ChainClientParams, Network } from "../client";
import { SwapAssetList } from "@dojima-wallet/utils";
import * as web3 from "@solana/web3.js";
import { GasfeeResult, SolTxData, SolTxParams, SolTxs, SolTxsHistoryParams } from "./types";
import { Provider } from "@project-serum/anchor";
import { PoolData, SwapFeeResult } from "../swap_utils";
export interface SolanaChainClient {
getCluster(): web3.Cluster;
getAddress(index?: number): Promise<string>;
getBalance(address: string): Promise<number>;
getFees(): Promise<GasfeeResult>;
transfer(params: SolTxParams): Promise<string>;
getTransactionData(txId: string, state?: web3.Finality): Promise<SolTxData>;
getTransactionsHistory(params?: SolTxsHistoryParams): Promise<SolTxs>;
}
export type ChainEndpointParams = {
endpoint: string;
apiKey?: string;
};
export declare const defaultSolEndpoint = "mainnet-beta";
export declare const alchemySolRpcUrl = "https://solana-mainnet.g.alchemy.com/v2/";
declare class SolanaClient implements SolanaChainClient {
protected network: Network;
protected cluster: web3.Cluster;
protected connection: web3.Connection;
private phrase;
constructor({ phrase, network, endpoint, apiKey, }: ChainClientParams & ChainEndpointParams);
getCluster(): web3.Cluster;
private getKeypair;
getAddress(index?: number): Promise<string>;
requestSolTokens(faucetEndpoint: string, address: string): Promise<string>;
getBalance(address: string): Promise<number>;
getFees(): Promise<GasfeeResult>;
transfer({ walletIndex, recipient, amount, }: SolTxParams): Promise<string>;
dummyTx(recipient: string, amount: number): Promise<string>;
getTransactionData(txId: string, state?: web3.Finality): Promise<SolTxData>;
getTransactionsHistory(params?: SolTxsHistoryParams): Promise<SolTxs>;
getSwapOutput(inputAmount: number, pool: PoolData, toDoj: boolean): number;
getDoubleSwapOutput(inputAmount: number, pool1: PoolData, pool2: PoolData): number;
getSwapSlip(inputAmount: number, pool: PoolData, toDoj: boolean): number;
getDoubleSwapSlip(inputAmount: number, pool1: PoolData, pool2: PoolData): number;
getSwapFeesData(): Promise<SwapFeeResult>;
getSolanaInboundAddress(hermesApiUrl: string): Promise<string>;
getDefaultLiquidityPoolGasFee(hermesApiUrl: string): Promise<number>;
getProvider(): Promise<Provider>;
solanaBatchTxsToHermes(amount: number, recipient: string, memo: string): Promise<string>;
addLiquidityPool(amount: number, inboundAddress: string, hermesAddress?: string): Promise<string>;
swap(amount: number, token: SwapAssetList, inboundAddress: string, recipient: string): Promise<string>;
}
export { SolanaClient };