@zlattice/lattice-js
Version:
Lattice blockchain TypeScript SDK with dual module support (CJS + ESM)
42 lines • 1.34 kB
TypeScript
import { ResultAsync } from "neverthrow";
/**
* Account lock interface
*/
export interface AccountLock {
/**
* Obtain account lock
* @param chainId Chain ID
* @param address Account address
*/
obtain(chainId: string | number, address: string): Promise<void>;
/**
* Release account lock
* @param chainId Chain ID
* @param address Account address
*/
unlock(chainId: string | number, address: string): void;
/**
* Execute function with lock
* @param chainId Chain ID
* @param address Account address
* @param block Function to execute with lock
* @returns Result of the function
*/
withLock<T>(chainId: string | number, address: string, block: () => Promise<T>): ResultAsync<T, Error>;
}
/**
* Account lock implementation
*/
export declare class AccountLockImpl implements AccountLock {
private locks;
private lockReleases;
obtain(chainId: string | number, address: string): Promise<void>;
unlock(chainId: string | number, address: string): void;
withLock<T>(chainId: string | number, address: string, block: () => Promise<T>): ResultAsync<T, Error>;
}
/**
* Create a new account lock
* @returns Account lock instance
*/
export declare function newAccountLock(): AccountLock;
//# sourceMappingURL=account_lock.d.ts.map