blueprint
blueprint copied to clipboard
Missing `getContractState` method in `TonClient` TypeScript definitions
Description
I encountered a TypeScript error when trying to use the getContractState method on the TonClient. The method seems not to exist on the type TonClient4 | TonClient, which leads to a compilation error. I am following the official documentation (or specific guide/tutorial - if applicable, provide the link) to deploy a smart contract on the TON blockchain.
Library Version
- TON SDK version: "@ton/blueprint": "^0.19.0",
Steps to Reproduce run this line const contractState = await api.getContractState(minterAddress);
Expected Behavior
The getContractState method should be available and callable on the TonClient instance to fetch the current state of a smart contract.
Actual Behavior
TypeScript compilation error stating that getContractState does not exist on the TonClient4 | TonClient.
Could someone please clarify if this method has been removed, deprecated, or replaced in the latest version of the SDK? Any guidance on how to properly obtain a contract's state using the current SDK version would also be appreciated.
Thank you!
the same issue
A simpe workaround is to use getContractState method of TonClient, similarly to this:
import { TonClient } from '@ton/ton'
import { getHttpEndpoint } from '@orbs-network/ton-access'
const clientPromise = getHttpEndpoint({ network: "mainnet" })
.then((endpoint) => new TonClient({ endpoint }))
const getContractState = async (address: Address) => {
const client = await clientPromise
return client.getContractState(address)
}
I'm also now encountering this problem.
The definition exists on TonClient but not on TonClient 4.
When returning a shape of TonClient | TonClient 4 Typescript will only be happy when a function declared on both are being used.
Creating a TonClient or narrowing the scope of TonClient | TonClient 4 with validation, might be way to go, for now.
Any progress or workaround for this problem? How would I know what client is returned from api()?