UNPKG

@zlattice/lattice-js

Version:

Lattice blockchain TypeScript SDK with dual module support (CJS + ESM)

131 lines 6.62 kB
import { Curve } from "../common/constants.js"; import { Receipt } from "../common/types/index.js"; import { AccountLock, BlockCache } from "../lattice/index.js"; import { type RetryStrategy } from "../utils/index.js"; import { ResultAsync } from "neverthrow"; declare class Credentials { private readonly accountAddress; private readonly fileKey?; private readonly passphrase?; private readonly privateKey?; constructor(accountAddress: string, fileKey?: string, passphrase?: string, privateKey?: string); static fromFileKey(accountAddress: string, fileKey: string, passphrase: string): Credentials; static fromPrivateKey(accountAddress: string, privateKey: string): Credentials; getAccountAddress(): string; getPrivateKey(): string; } declare class ChainConfig { curve: Curve; tokenLess: boolean; constructor(curve: Curve, tokenLess: boolean); } declare class NodeConnectionConfig { insecure: boolean; ip: string; httpPort: number; wsPort?: number; ginHttpPort?: number; jwtSecret?: string; jwtTokenExpirationDuration: number; constructor(ip: string, httpPort: number, wsPort?: number, ginHttpPort?: number, jwtSecret?: string, jwtTokenExpirationDuration?: number, // 6 hours insecure?: boolean); } declare class Options { options: Record<string, any>; constructor(options: Record<string, any>); get(key: string): any; } declare class LatticeClient { private readonly httpClient; private readonly chainConfig; private readonly nodeConnectionConfig; private readonly options; private readonly accountLock; private readonly blockCache; constructor(chainConfig: ChainConfig, nodeConnectionConfig: NodeConnectionConfig, options?: Options, accountLock?: AccountLock, blockCache?: BlockCache); /** * Wait for receipt * @param chainId The chain id * @param hash The hash * @param retryStrategy The retry strategy, default is FixedDelayStrategy.default * @param retries The number of retries, default is 10 * @returns E.Either<Receipt, Error>, left is the receipt, right is the error */ waitReceipt(chainId: number, hash: string, retryStrategy?: RetryStrategy, retries?: number): ResultAsync<Receipt, Error>; private handleTransaction; /** * Transfer * @param credentials Your credentials * @param chainId The chain id * @param linker The linker address * @param payload The payload, should be a hex string * @param amount The amount, default is 0 * @param joule The joule, default is 0 * @returns ResultAsync<string, Error>, left is the hash, right is the error */ transfer(credentials: Credentials, chainId: number, linker: string, payload: string, amount?: number, joule?: number): ResultAsync<string, Error>; /** * Transfer and wait for receipt * @param credentials Your credentials * @param chainId The chain id * @param linker The linker address * @param payload The payload, should be a hex string * @param amount The amount, default is 0 * @param joule The joule, default is 0 * @param retryStrategy The retry strategy, default is FixedDelayStrategy.default * @param retries The number of retries, default is 10 * @returns E.Either<Receipt, Error>, left is the receipt, right is the error */ transferWaitReceipt(credentials: Credentials, chainId: number, linker: string, payload: string, amount?: number, joule?: number, retryStrategy?: RetryStrategy, retries?: number): ResultAsync<Receipt, Error>; /** * Deploy contract * @param credentials Your credentials * @param chainId The chain id * @param code The code, should be a hex string * @param payload The payload, should be a hex string, default is 0x * @param amount The amount, default is 0 * @param joule The joule, default is 0 * @returns E.Either<string, Error>, left is the hash, right is the error */ deployContract(credentials: Credentials, chainId: number, code: string, payload?: string, amount?: number, joule?: number): ResultAsync<string, Error>; /** * Deploy contract and wait for receipt * @param credentials Your credentials * @param chainId The chain id * @param code The code, should be a hex string * @param payload The payload, should be a hex string, default is 0x * @param amount The amount, default is 0 * @param joule The joule, default is 0 * @param retryStrategy The retry strategy, default is FixedDelayStrategy.default * @param retries The number of retries, default is 10 * @returns E.Either<Receipt, Error>, left is the receipt, right is the error */ deployContractWaitReceipt(credentials: Credentials, chainId: number, code: string, payload?: string, amount?: number, joule?: number, retryStrategy?: RetryStrategy, retries?: number): ResultAsync<Receipt, Error>; /** * Call contract * @param credentials Your credentials * @param chainId The chain id * @param contractAddress The contract address * @param code The code, should be a hex string * @param payload The payload, should be a hex string, default is 0x * @param amount The amount, default is 0 * @param joule The joule, default is 0 * @returns E.Either<string, Error>, left is the hash, right is the error */ callContract(credentials: Credentials, chainId: number, contractAddress: string, code: string, payload?: string, amount?: number, joule?: number): ResultAsync<string, Error>; /** * Call contract and wait for receipt * @param credentials Your credentials * @param chainId The chain id * @param contractAddress The contract address * @param code The code, should be a hex string * @param payload The payload, should be a hex string, default is 0x * @param amount The amount, default is 0 * @param joule The joule, default is 0 * @returns E.Either<Receipt, Error>, left is the receipt, right is the error */ callContractWaitReceipt(credentials: Credentials, chainId: number, contractAddress: string, code: string, payload?: string, amount?: number, joule?: number, retryStrategy?: RetryStrategy, retries?: number): ResultAsync<Receipt, Error>; preCallContract(credentials: Credentials, chainId: number, contractAddress: string, code: string, payload?: string, amount?: number, joule?: number): ResultAsync<Receipt, Error>; } export { LatticeClient, Credentials, ChainConfig, NodeConnectionConfig, Options }; //# sourceMappingURL=lattice.d.ts.map