@0xobelisk/rooch-client
Version:
Tookit for interacting with rooch move framework
105 lines (104 loc) • 5.68 kB
TypeScript
import { Args, TypeTag, Secp256k1Keypair, ExecuteTransactionResponseView, ModuleABIView, BalanceInfoView, Transaction, GetStatesParams, ObjectStateView, ListStatesParams, PaginatedStateKVViews, GetEventsByEventHandleParams, PaginatedEventViews, address, TypeArgs } from '@roochnetwork/rooch-sdk';
import { RoochAccountManager } from './libs/roochAccountManager';
import { RoochInteractor } from './libs/roochInteractor';
import { RoochContractFactory } from './libs/roochContractFactory';
import { DubheParams, DerivePathParams, MapModuleFuncQuery, MapModuleFuncTx, MoveModuleFuncType } from './types';
export declare function isUndefined(value?: unknown): value is undefined;
export declare function withMeta<T extends {
meta: MoveModuleFuncType;
}>(meta: MoveModuleFuncType, creator: Omit<T, 'meta'>): T;
/**
* @class Dubhe
* @description This class is used to aggregate the tools that used to interact with SUI network.
*/
export declare class Dubhe {
#private;
accountManager: RoochAccountManager;
roochInteractor: RoochInteractor;
contractFactory: RoochContractFactory;
packageId: string | undefined;
metadata: ModuleABIView[] | undefined;
/**
* Support the following ways to init the DubheClient:
* 1. mnemonics
* 2. secretKey (base64 or hex)
* If none of them is provided, will generate a random mnemonics with 24 words.
*
* @param mnemonics, 12 or 24 mnemonics words, separated by space
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet'
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
* @param packageId
*/
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, }?: DubheParams);
get query(): MapModuleFuncQuery;
get tx(): MapModuleFuncTx;
/**
* if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
* else:
* it will generate signer from the mnemonic with the given derivePathParams.
* @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
*/
getKeypair(derivePathParams?: DerivePathParams): Secp256k1Keypair;
/**
* if derivePathParams is not provided or mnemonics is empty, it will return the currentSigner.
* else:
* it will generate signer from the mnemonic with the given derivePathParams.
* @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
*/
getSigner(derivePathParams?: DerivePathParams): Secp256k1Keypair;
/**
* @description Switch the current account with the given derivePathParams
* @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
*/
switchAccount(derivePathParams: DerivePathParams): void;
/**
* @description Get the address of the account for the given derivePathParams
* @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
*/
getBech32Address(derivePathParams?: DerivePathParams): string;
getRoochAddress(derivePathParams?: DerivePathParams): import("@roochnetwork/rooch-sdk").RoochAddress;
getHexAddress(derivePathParams?: DerivePathParams): string;
getBitcoinAddress(derivePathParams?: DerivePathParams): import("@roochnetwork/rooch-sdk").BitcoinAddress;
currentAddress(): import("@roochnetwork/rooch-sdk").RoochAddress;
client(): import("@roochnetwork/rooch-sdk").RoochClient;
getPackageId(): string;
getMetadata(): ModuleABIView[] | undefined;
getNetwork(): import("@roochnetwork/rooch-sdk").NetworkType | undefined;
getFullNodeUrl(): string;
getRpcApiVersion(): Promise<string | undefined>;
getChainId(): Promise<bigint>;
getBalance(accountAddress?: string, coinType?: string, outputOnly?: boolean): Promise<BalanceInfoView | string>;
signAndExecuteTransaction(transaction: Transaction, signer?: Secp256k1Keypair, derivePathParams?: DerivePathParams): Promise<any>;
signAndSendTransaction(tx: Transaction, derivePathParams?: DerivePathParams): Promise<any>;
createSession(sessionArgs: {
appName: string;
appUrl: string;
scopes: string[];
}, signer?: Secp256k1Keypair, derivePathParams?: DerivePathParams): Promise<import("@roochnetwork/rooch-sdk").Session>;
moveCall(callParams: {
target: string;
params?: Args[];
typeArguments?: TypeTag[];
signer?: Secp256k1Keypair;
derivePathParams?: DerivePathParams;
}): Promise<any>;
publishPackage(callParams: {
packageBytes: Uint8Array;
signer?: Secp256k1Keypair;
derivePathParams?: DerivePathParams;
}): Promise<any>;
getStates(params: GetStatesParams): Promise<ObjectStateView[]>;
listStates(params: ListStatesParams): Promise<PaginatedStateKVViews>;
getEvents(input: GetEventsByEventHandleParams): Promise<PaginatedEventViews>;
transfer(input: {
recipient: address;
amount: number | bigint;
coinType: TypeArgs;
}, signer?: Secp256k1Keypair, derivePathParams?: DerivePathParams): Promise<ExecuteTransactionResponseView>;
transferObject(input: {
recipient: address;
objectId: string;
objectType: TypeArgs;
}, signer?: Secp256k1Keypair, derivePathParams?: DerivePathParams): Promise<ExecuteTransactionResponseView>;
}