UNPKG

@arcana/ca-sdk

Version:

Arcana Network's chain abstraction SDK for unified balance in Web3 apps

87 lines (86 loc) 4.66 kB
import { ArcanaVault, Environment, EVMRFF, Universe } from "@arcana/ca-common"; import { DirectSecp256k1Wallet } from "@cosmjs/proto-signing"; import Decimal from "decimal.js"; import { FuelConnector, Provider } from "fuels"; import Long from "long"; import { ByteArray, Hex, PublicClient, WalletClient, WebSocketTransport } from "viem"; import { ChainList } from "../chains"; import { EthereumProvider, Intent, NetworkConfig, OraclePriceResponse, ReadableIntent, SDKConfig, TokenInfo, TxOptions, UnifiedBalanceResponseData, UserAssets } from "../typings"; import { fetchBalances } from "./api.utils"; declare function convertAddressByUniverse(input: Hex, universe: Universe): Hex; declare function convertAddressByUniverse(input: ByteArray, universe: Universe): ByteArray; declare const minutesToMs: (min: number) => number; declare const balancesToAssets: (balances: UnifiedBalanceResponseData[], chainList: ChainList) => { assets: UserAssets; balanceInFiat: number; }; type IntentD = { createdAt: number; id: number; }; declare const storeIntentHashToStore: (address: string, id: number, createdAt?: number) => void; declare const removeIntentHashFromStore: (address: string, id: Long) => void; declare const getExpiredIntents: (address: string) => IntentD[]; declare const refundExpiredIntents: (address: string, cosmosURL: string, wallet: DirectSecp256k1Wallet) => Promise<void>; declare const equalFold: (a?: string, b?: string) => boolean; declare const createRequestFuelSignature: (fuelVaultAddress: string, provider: Provider, connector: FuelConnector, fuelRFF: Parameters<ArcanaVault["functions"]["deposit"]>[0]) => Promise<{ requestHash: Hex; signature: Uint8Array<ArrayBufferLike>; }>; declare const getExplorerURL: (baseURL: string, id: Long) => string; /** * @param input * @param decimals * @returns input / (10**decimals) */ declare const divDecimals: (input: bigint | number | string, decimals: number) => Decimal; /** * @param input * @param decimals * @returns BigInt(input * (10**decimals)) */ declare const mulDecimals: (input: Decimal | number | string, decimals: number) => bigint; declare const convertIntent: (intent: Intent, token: TokenInfo, chainList: ChainList) => ReadableIntent; declare const hexTo0xString: (hex: string) => `0x${string}`; declare const getSupportedChains: (env?: Environment) => { id: number; logo: string; name: string; tokens: TokenInfo[]; }[]; declare const isArcanaWallet: (p: EthereumProvider) => boolean; declare const createRequestEVMSignature: (evmRFF: EVMRFF, evmAddress: `0x${string}`, client: WalletClient) => Promise<{ requestHash: `0x${string}`; signature: ByteArray; }>; declare const convertGasToToken: (token: TokenInfo, oraclePrices: OraclePriceResponse, destinationChainID: number, gas: Decimal) => Decimal; declare const evmWaitForFill: (vaultContractAddress: `0x${string}`, publicClient: PublicClient<WebSocketTransport>, requestHash: `0x${string}`, intentID: Long, grpcURL: string, cosmosURL: string) => Promise<void>; declare const convertBalance: (balances: Awaited<ReturnType<typeof fetchBalances>>) => { abstracted: boolean | undefined; balance: string; balanceInFiat: number; breakdown: { balance: string; balanceInFiat: number; chain: { id: number; logo: string; name: string; }; contractAddress: `0x${string}`; decimals: number; isNative: boolean | undefined; }[]; icon: string | undefined; symbol: string; }[]; declare const convertTo32Bytes: (value: bigint | Hex | number) => ByteArray; declare const convertTo32BytesHex: (value: Hex) => `0x${string}`; declare const convertToHexAddressByUniverse: (address: Uint8Array, universe: Universe) => `0x${string}`; declare const createDepositDoubleCheckTx: (chainID: Uint8Array, cosmos: { address: string; wallet: DirectSecp256k1Wallet; }, intentID: Long, network: NetworkConfig) => () => Promise<void>; declare const getSDKConfig: (c: SDKConfig) => Required<SDKConfig>; declare const getTxOptions: (options?: Partial<TxOptions>) => TxOptions; export { balancesToAssets, convertAddressByUniverse, convertBalance, convertGasToToken, convertIntent, convertTo32Bytes, convertTo32BytesHex, convertToHexAddressByUniverse, createDepositDoubleCheckTx, createRequestEVMSignature, createRequestFuelSignature, divDecimals, equalFold, evmWaitForFill, getExpiredIntents, getExplorerURL, getSDKConfig, getSupportedChains, getTxOptions, hexTo0xString, isArcanaWallet, minutesToMs, mulDecimals, refundExpiredIntents, removeIntentHashFromStore, storeIntentHashToStore, };