From bb8b440828f7a17be35df6ceb9cb475e88af4c54 Mon Sep 17 00:00:00 2001 From: Shahar Yakir Date: Tue, 23 Jan 2024 14:15:03 +0000 Subject: [PATCH 1/4] testing v4 --- src/lib/deploy-controller.ts | 16 +++++++++------- src/lib/make-get-call.ts | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/lib/deploy-controller.ts b/src/lib/deploy-controller.ts index f6e7e5d..cdfdaab 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,7 +212,8 @@ 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", [], @@ -220,22 +222,22 @@ class JettonDeployController { admin: cellToAddress(adminCell), totalSupply: totalSupply as BN, }), - tc, + tc4, ); - const jWalletAddress = await makeGetCall( + const jWalletAddress = await makeGetCall4( contractAddr, "get_wallet_address", [beginCell().storeAddress(owner).endCell()], ([addressCell]) => cellToAddress(addressCell), - tc, + tc4, ); const isDeployed = await tc.isContractDeployed(jWalletAddress); let jettonWallet; if (isDeployed) { - jettonWallet = await makeGetCall( + jettonWallet = await makeGetCall4( jWalletAddress, "get_wallet_data", [], @@ -244,7 +246,7 @@ class JettonDeployController { jWalletAddress, jettonMasterAddress: cellToAddress(jettonMasterAddressCell), }), - tc, + tc4, ); } else { jettonWallet = null; diff --git a/src/lib/make-get-call.ts b/src/lib/make-get-call.ts index 267c9e0..7f9b3bb 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,23 @@ 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); + // const some = await tonClient.runMethod(seqno, address!, name, _prepareParams(params)); + + // @ts-ignore + console.log(res.result.map(({ value, cell }) => value ?? cell)); + + // @ts-ignore + return parser(_parseGetMethodCall(res.result.map(({ value, cell }) => value ?? cell))); +} From 5377ec209dc1e9a050c8614035fbe897e59d22de Mon Sep 17 00:00:00 2001 From: Shahar Yakir Date: Tue, 23 Jan 2024 14:15:06 +0000 Subject: [PATCH 2/4] testing v4 --- src/lib/get-ton-client-4.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/lib/get-ton-client-4.ts 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; +} From 3b761d9a6536856ff04918854cfebcee02ba1e8f Mon Sep 17 00:00:00 2001 From: Shahar Yakir Date: Tue, 23 Jan 2024 14:19:48 +0000 Subject: [PATCH 3/4] v4 reads for jetton minter --- src/lib/deploy-controller.ts | 22 +++++++++++++--------- src/lib/make-get-call.ts | 5 +---- src/pages/deployer/index.tsx | 1 + src/store/jetton-store/useJettonStore.ts | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/lib/deploy-controller.ts b/src/lib/deploy-controller.ts index cdfdaab..cf43f23 100644 --- a/src/lib/deploy-controller.ts +++ b/src/lib/deploy-controller.ts @@ -217,27 +217,31 @@ class JettonDeployController { contractAddr, "get_jetton_data", [], - async ([totalSupply, __, adminCell, contentCell]) => ({ - ...(await readJettonMetadata(contentCell as unknown as Cell)), - admin: cellToAddress(adminCell), - totalSupply: totalSupply as BN, - }), + async ([totalSupply, __, adminCell, contentCell]) => { + return { + ...(await readJettonMetadata(contentCell as unknown as Cell)), + admin: cellToAddress(adminCell), + totalSupply: totalSupply as BN, + }; + }, tc4, ); - const jWalletAddress = await makeGetCall4( + console.log(minter); + + const jWalletAddress = await makeGetCall( contractAddr, "get_wallet_address", [beginCell().storeAddress(owner).endCell()], ([addressCell]) => cellToAddress(addressCell), - tc4, + tc, ); const isDeployed = await tc.isContractDeployed(jWalletAddress); let jettonWallet; if (isDeployed) { - jettonWallet = await makeGetCall4( + jettonWallet = await makeGetCall( jWalletAddress, "get_wallet_data", [], @@ -246,7 +250,7 @@ class JettonDeployController { jWalletAddress, jettonMasterAddress: cellToAddress(jettonMasterAddressCell), }), - tc4, + tc, ); } else { jettonWallet = null; diff --git a/src/lib/make-get-call.ts b/src/lib/make-get-call.ts index 7f9b3bb..2e4d113 100644 --- a/src/lib/make-get-call.ts +++ b/src/lib/make-get-call.ts @@ -64,8 +64,5 @@ export async function makeGetCall4( // const some = await tonClient.runMethod(seqno, address!, name, _prepareParams(params)); // @ts-ignore - console.log(res.result.map(({ value, cell }) => value ?? cell)); - - // @ts-ignore - return parser(_parseGetMethodCall(res.result.map(({ value, cell }) => value ?? cell))); + 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) => ({ From 14f15379f4679f12b466c7fec4b0108806baa4b3 Mon Sep 17 00:00:00 2001 From: Shahar Yakir Date: Tue, 23 Jan 2024 14:21:14 +0000 Subject: [PATCH 4/4] v4 load --- src/lib/deploy-controller.ts | 2 -- src/lib/make-get-call.ts | 1 - 2 files changed, 3 deletions(-) diff --git a/src/lib/deploy-controller.ts b/src/lib/deploy-controller.ts index cf43f23..94c40f1 100644 --- a/src/lib/deploy-controller.ts +++ b/src/lib/deploy-controller.ts @@ -227,8 +227,6 @@ class JettonDeployController { tc4, ); - console.log(minter); - const jWalletAddress = await makeGetCall( contractAddr, "get_wallet_address", diff --git a/src/lib/make-get-call.ts b/src/lib/make-get-call.ts index 2e4d113..064fe2d 100644 --- a/src/lib/make-get-call.ts +++ b/src/lib/make-get-call.ts @@ -61,7 +61,6 @@ export async function makeGetCall4( last: { seqno }, } = await tonClient.getLastBlock(); const res = await tonClient.runMethod(seqno, address!, name, params); - // const some = await tonClient.runMethod(seqno, address!, name, _prepareParams(params)); // @ts-ignore return parser(res.result.map(({ value, cell }) => value ?? cell));