import { Address, ContractFunctionParameters, Hex, PublicActions } from 'viem';
import { PrexSigner } from './core/sign';
import { PagingOptions, PrexUser, TransferByLinkResponse, CreateWalletResult, LinkTransferHistoryItem, PrexClientOptions, TransferHistoryQuery, TokenActivity } from './types';
import { DutchOrder } from '@prex0/prex-structs';
import { PrexApiService } from './api';
import { Logger } from './utils/logger';
import { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/typescript-types';
import { ProviderInterface } from './providers/base-provider';
import { TransferOptions } from './actions/transfer';
import { DistributeAction } from './actions/distribute';
import { FacilitatorConfig, PrexClientInterface } from './interfaces/prex-client-interface';
import { NonceManager } from './utils/nonce-manager';
import { PumpumAction } from './actions/pumpum';
import { ProfileActionV2 } from './actions/nickname-v2';
export declare class PrexClient extends NonceManager implements PrexClientInterface {
user?: PrexUser;
balances: Record
;
allowances: Record;
apiService: PrexApiService;
evmChainClient: PublicActions;
logger: Logger;
signer: PrexSigner | null;
provider?: ProviderInterface | null;
useExternalWallet: boolean;
private storage;
private swapAction;
/**
* Creates a new instance of the PrexClient.
* @param chainId - The ID of the blockchain network.
* @param policyId - The ID of the policy set to be used.
* @param options - Configuration options for the client.
* @param options.apiKey - Optional API key for authentication.
* @param options.endpoint - Optional custom endpoint URL for the API.
* @param options.debugMode - Optional flag to enable debug log mode.
*/
constructor(chainId: number, policyId: string, { apiKey, endpoint, debugMode, provider, storage, }: PrexClientOptions);
getSigner(): PrexSigner | null;
getPublicClient(): PublicActions;
/**
* Sets the API key for authentication.
* @param apiKey - The API key to be used for requests.
*/
setApiKey(apiKey: string): void;
setProvider(provider: ProviderInterface): void;
startHandler(): Promise;
/**
* Checks if the passkey (WebAuthn) feature is available in the current environment.
* @returns A promise that resolves to a boolean indicating passkey availability.
*/
isPasskeyAvailable(): Promise;
/**
* Get the chain ID from the provider or the API service.
* @returns A promise that resolves to the chain ID.
*/
getChainId(): Promise;
/**
* Switches the chain ID.
* @param chainId - The ID of the blockchain network to switch to.
* @returns A promise that resolves to the chain ID.
*/
switchChain(chainId: number): Promise;
/**
* Creates a new wallet for the user.
* @throws Will throw an error if the wallet creation process fails.
*/
createWallet(options?: {
userName?: string;
withDeploy?: boolean;
}): Promise;
getExistSubKey(): Promise<{
subKey: string;
subSecret: string;
} | null>;
private generateSubKey;
existsSubKey(): Promise;
/**
* Deletes the subkey from the storage.
*/
deleteSubKey(): Promise;
generateOrGetSubKey(): Promise<{
isNew: boolean;
subKey: string;
subSecret: string;
}>;
deployWallet(): Promise;
private createOrGetCredential;
/**
* Attempts to restore a wallet using stored credentials.
* @throws Will throw an error if the restore process fails.
*/
restoreWallet(): Promise;
private restoreWalletInner;
/**
* Logs out the user.
*/
logout(): Promise;
getProfileAction(): ProfileActionV2;
updateNickName({ nickName, from, }: {
nickName: string;
from?: Address;
}): Promise;
uploadAvatar({ image, from }: {
image: File;
from?: Address;
}): Promise<{
path: string;
fullPath: string;
url: string;
}>;
load(): Promise;
/**
* Initiates a token transfer.
* @param token - The address of the token to be transferred.
* @param recipient - The recipient's address.
* @param amount - The amount of tokens to transfer.
* @param metadata - Optional metadata to include with the transfer.
* @throws Will throw an error if the user is not initialized or if the transfer fails.
*/
transfer(params: {
token: Address;
recipient: Address;
amount: bigint;
metadata?: Record;
sender?: Address;
}, options?: TransferOptions): Promise<{
hash: Hex;
}>;
mint(options: {
token?: Address;
recipient: Address;
amount: bigint;
}): Promise;
/**
* Initiates a transfer by creating a secret.
* @param token - The address of the token to be transferred.
* @param amount - The amount of tokens to transfer.
* @param expiration - The expiration time for the transfer link.
* @param metadata - Additional metadata for the transfer.
* @param isRequiredLock - Whether the transfer requires locking.
* @returns A promise that resolves to the transfer link response.
* @throws Will throw an error if the user is not initialized or if the transfer creation fails.
*/
transferByLink({ token, amount, expiration, metadata, sender, }: {
token: Address;
amount: bigint;
expiration: number;
metadata?: Record;
sender?: Address;
}): Promise;
getLinkTransfer(id: string): Promise;
getLinkTransferBySecret(secret: string): Promise;
receiveLinkTransfer(params: {
secret: Hex;
recipient?: Address;
}): Promise<{
hash: Hex;
}>;
approve({ token, amount, from, }: {
token: Address;
amount?: bigint;
from?: Address;
}): Promise;
backupByEOA(backupAddress: Address): Promise;
recoverByEOA(backupPrivateKey: Hex): Promise;
/**
* @description Adds new passkey to Smart Wallet.
* User must register the passkey to Prex service before calling this method.
*/
backupByPasskey(ownerIndex?: number): Promise;
/**
* @description Registers new passkey to Prex service
*/
registerNewPasskey(): Promise;
getSharedWalletAddress(owners: Address[], nonce: number): Promise<`0x${string}`>;
createSharedWallet({ name, owners, nonce, }: {
name: string;
owners: Address[];
nonce: number;
}): Promise<`0x${string}`>;
executeWithCreateSharedWallet(contracts: ContractFunctionParameters, owners: Address[], nonce: number, sharedWalletAddress: Address): Promise<{
hash: `0x${string}`;
}>;
addOwnerAddress({ owner, from, }: {
owner: Address;
from?: Address;
}): Promise;
removeOwnerAtIndex({ index, owner, from, }: {
index: number;
owner: Address;
from?: Address;
}): Promise;
getSharedWallets(): Promise;
private addOwnerPublicKey;
fetchBalance(token: Address, owner?: Address): Promise<{
balance: bigint | undefined;
allowance: bigint | undefined;
}>;
fetchBalanceBatch(tokens: Address[], user?: Address): Promise<{
token: `0x${string}`;
balance: bigint | undefined;
isSuccess: boolean;
}[]>;
/**
* @description Fetches transfer history
* @param token token address
* @param pagingOptions paging options
* @returns transfer history
*/
getHistory(_query?: TransferHistoryQuery, pagingOptions?: PagingOptions): Promise;
getOnetimeLockHistory(_query?: {
user: Address;
} | {
token: Address;
}, pagingOptions?: PagingOptions): Promise;
getTokenHolder(query: {
token: Address;
address?: Address;
}): Promise;
getTokenHolders(_query: {
token: Address;
}, pagingOptions?: PagingOptions): Promise;
executeOperation(contracts: ContractFunctionParameters, from?: Address): Promise<{
hash: `0x${string}`;
}>;
private getExecuteAction;
_executeOperation(target: Address, callData: Hex, from?: Address): Promise<{
hash: `0x${string}`;
}>;
_executeOperationWithoutChainIdValidation(callData: Hex, from?: Address): Promise<{
hash: `0x${string}`;
}>;
authenticate(options: PublicKeyCredentialRequestOptionsJSON): Promise;
quoteSwap(params: {
tokenIn: Address;
tokenOut: Address;
amount: bigint;
tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT';
swapper?: Address;
recipient?: Address;
slippageTolerance?: bigint;
}): Promise<{
quote: bigint;
route: Hex;
order: DutchOrder;
}>;
swap(order: DutchOrder, route: Hex): Promise<{
hash: Hex;
}>;
getSwapHistory(query?: {
user: Address;
}, pagingOptions?: PagingOptions): Promise;
distribute(): DistributeAction;
getPumAction(): PumpumAction;
getTokenDetails(token: Address): Promise<{
name: string;
symbol: string;
decimals: number;
}>;
getTokenActivity(token: Address): Promise;
getUser(): PrexUser | undefined;
private config;
loadConfig(chainId: number): Promise;
getProfile(address: Address): Promise<{}>;
getAddressByName({ baseName, name, }: {
baseName?: string;
name: string;
}): Promise<`0x${string}` | null>;
signWithSubKey({ hash, from }: {
hash: Hex;
from?: Address;
}): Promise<{
signature: Hex;
message: import("./types").SubKeyMessage;
keyType: "main" | "sub";
}>;
}
//# sourceMappingURL=prex-client.d.ts.map