vasku
Version:
TVM-Solidity contract development framework
148 lines • 4.73 kB
TypeScript
import { type AbiContract, type DecodedMessageBody, type KeyPair, type ResultOfProcessMessage, type TonClient } from '@eversdk/core';
import { type Giver } from '../giver';
export declare enum AccountType {
notFound = "-1",
unInit = "0",
active = "1",
frozen = "2",
nonExist = "3"
}
export type CompiledContractConfig = {
address?: string;
initial?: Record<string, any>;
keys?: KeyPair;
};
export type ContractOptions = {
client?: TonClient;
giver?: Giver;
};
export interface ResultOfCall {
out: any;
result: ResultOfProcessMessage;
}
export declare class Contract {
private readonly abi;
private readonly initial?;
private readonly tvc?;
private readonly client?;
private readonly giver?;
private _address?;
private _keys?;
private _lastTransactionLogicTime;
constructor(config: {
address: string;
keys?: KeyPair;
abi?: AbiContract;
initial?: Record<string, any>;
tvc?: string;
} | {
address?: string;
keys?: KeyPair;
abi: AbiContract;
initial: Record<string, any>;
tvc: string;
}, options?: {
client?: TonClient;
giver?: Giver;
});
/**
* Calculates the address only once. Next time returns the already calculated address
* You can use this if you want to know the address of the contract before deploying
* @example
* const contract = new Contract(...)
* const address = await contract.address()
* @return
* '0:97b53be2604579e89bd0077a5456456857792eb2ff09849d14321fc2c167f29e'
*/
address(): Promise<string>;
/**
* Generates a random key pair if no keys are given. Next time returns the already generated key pair
* @example
* const contract = new Contract(...)
* const address = await contract.keyPair()
* @return
* '0:97b53be2604579e89bd0077a5456456857792eb2ff09849d14321fc2c167f29e'
*/
keys(): Promise<KeyPair>;
/**
* Return contract balance
* @example
* const contract = new Contract(...)
* const address = await contract.balance()
* @return
* 10000000000n
*/
balance(): Promise<bigint>;
/**
* Return contract account type
* @example
* const contract = new Contract(...)
* const address = await contract.accountType()
* @return
* 1
*/
accountType(): Promise<AccountType>;
/**
* Run contract locally
* @param method Method name
* @param input
* @example
* const contract = new Contract(...)
* const address = await contract.runMethod('getHistory', { offset: 1 })
* @return { DecodedMessageBody }
*/
runMethod(method: string, input?: any): Promise<DecodedMessageBody>;
/**
* External call
* @param method Method name
* @param input
* @param [keys] Use it if you want to call contact with keys. `this.keys` used by default.
* @example
* const contract = new Contract(...)
* const address = await contract.runMethod('getHistory', { offset: 1 })
*/
callMethod(method: string, input?: any, keys?: KeyPair): Promise<{
out: any;
result: ResultOfProcessMessage;
}>;
/**
* Return last transaction logic time
* @example
* const contract = new Contract(...)
* contract.lastTransactionLogicTime
* @return
* '0'
*/
get lastTransactionLogicTime(): string;
/**
* Deploy
* @param value Deployment in nano coins
* @param input constructor data
* @param useGiver Send coins from giver before deployment if true
* @param timeout How long to wait coins from giver on contract in milliseconds
*/
_deploy(value: string | number | bigint, input?: any, useGiver?: boolean, timeout?: number): Promise<ResultOfProcessMessage>;
/**
* Use this if you want to wait for a transaction from one contract to another
* @example
* const sender = new SenderContract(...)
* const receiver = new ReceiverContract(...)
* const to = await receiver.address()
* await sender.call.send({to, value: 1_000_000_000})
* const waitingResult = await receiver.wait(5000)
* @param timeout Time in milliseconds
* @return
* true
*/
wait(timeout?: number): Promise<boolean>;
/**
* Create payload
* @example
* const contract = new Contract(...)
* const payload = await contract.createPayload('bet', { luckyNumber: 5})
* @param method Method name
* @param input
*/
createPayload(method: string, input?: any): Promise<string>;
}
//# sourceMappingURL=index.d.ts.map