diff --git a/src/lib/deploy-controller.ts b/src/lib/deploy-controller.ts index f6e7e5d..94c40f1 100644 --- a/src/lib/deploy-controller.ts +++ b/src/lib/deploy-controller.ts @@ -13,8 +13,9 @@ import { } from "./jetton-minter"; import { readJettonMetadata, changeAdminBody, JettonMetaDataKeys } from "./jetton-minter"; import { getClient } from "./get-ton-client"; -import { cellToAddress, makeGetCall } from "./make-get-call"; +import { cellToAddress, makeGetCall, makeGetCall4 } from "./make-get-call"; import { SendTransactionRequest, TonConnectUI } from "@tonconnect/ui-react"; +import { getClient4 } from "./get-ton-client-4"; export const JETTON_DEPLOY_GAS = toNano(0.25); @@ -211,16 +212,19 @@ class JettonDeployController { async getJettonDetails(contractAddr: Address, owner: Address) { const tc = await getClient(); - const minter = await makeGetCall( + const tc4 = await getClient4(); + const minter = await makeGetCall4( contractAddr, "get_jetton_data", [], - async ([totalSupply, __, adminCell, contentCell]) => ({ - ...(await readJettonMetadata(contentCell as unknown as Cell)), - admin: cellToAddress(adminCell), - totalSupply: totalSupply as BN, - }), - tc, + async ([totalSupply, __, adminCell, contentCell]) => { + return { + ...(await readJettonMetadata(contentCell as unknown as Cell)), + admin: cellToAddress(adminCell), + totalSupply: totalSupply as BN, + }; + }, + tc4, ); const jWalletAddress = await makeGetCall( diff --git a/src/lib/get-ton-client-4.ts b/src/lib/get-ton-client-4.ts new file mode 100644 index 0000000..870ed8c --- /dev/null +++ b/src/lib/get-ton-client-4.ts @@ -0,0 +1,23 @@ +import { TonClient4 } from "ton"; +import { getHttpV4Endpoint } from "@orbs-network/ton-access"; +import { getNetwork } from "./hooks/useNetwork"; + +const endpointP = getHttpV4Endpoint({ + network: getNetwork(new URLSearchParams(window.location.search)), +}); + +async function _getClient() { + return new TonClient4({ + endpoint: await endpointP, + }); +} + +const clientP = _getClient(); + +export async function getClient4() { + return clientP; +} + +export async function getEndpoint4() { + return endpointP; +} diff --git a/src/lib/make-get-call.ts b/src/lib/make-get-call.ts index 267c9e0..064fe2d 100644 --- a/src/lib/make-get-call.ts +++ b/src/lib/make-get-call.ts @@ -1,4 +1,4 @@ -import { Address, Cell, TonClient } from "ton"; +import { Address, Cell, TonClient, TonClient4 } from "ton"; import BN from "bn.js"; function _prepareParams(params: any[] = []) { @@ -49,3 +49,19 @@ export async function makeGetCall( return parser(_parseGetMethodCall(stack as [["num" | "cell", any]])); } + +export async function makeGetCall4( + address: Address | undefined, + name: string, + params: any[], + parser: (stack: GetResponseValue[]) => T, + tonClient: TonClient4, +) { + const { + last: { seqno }, + } = await tonClient.getLastBlock(); + const res = await tonClient.runMethod(seqno, address!, name, params); + + // @ts-ignore + return parser(res.result.map(({ value, cell }) => value ?? cell)); +} diff --git a/src/pages/deployer/index.tsx b/src/pages/deployer/index.tsx index 8aeb653..4f83853 100644 --- a/src/pages/deployer/index.tsx +++ b/src/pages/deployer/index.tsx @@ -101,6 +101,7 @@ function DeployerPage() { if (err instanceof Error) { showNotification(<>{err.message}, "error"); } + console.error(err); } finally { setIsLoading(false); } diff --git a/src/store/jetton-store/useJettonStore.ts b/src/store/jetton-store/useJettonStore.ts index 72a2194..afe05b7 100644 --- a/src/store/jetton-store/useJettonStore.ts +++ b/src/store/jetton-store/useJettonStore.ts @@ -116,6 +116,7 @@ function useJettonStore() { : error.message, "error", ); + console.error(error); } } finally { setState((prevState) => ({