From 36f00fcc87996c009ec33f93ef633e19deb6faaa Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Fri, 23 Feb 2024 14:37:00 +0000 Subject: [PATCH] Fix boxes (again) --- boxes/react/src/hooks/useContract.tsx | 6 +++--- boxes/react/src/index.tsx | 12 +++++------- boxes/react/src/pages/contract.tsx | 25 ++++++++---------------- boxes/react/src/pages/home.tsx | 4 ++-- boxes/react/tests/blank.contract.test.ts | 6 ++---- boxes/vanilla-js/src/index.ts | 7 +++---- 6 files changed, 23 insertions(+), 37 deletions(-) diff --git a/boxes/react/src/hooks/useContract.tsx b/boxes/react/src/hooks/useContract.tsx index 0174c205d395..8082005867c5 100644 --- a/boxes/react/src/hooks/useContract.tsx +++ b/boxes/react/src/hooks/useContract.tsx @@ -14,17 +14,17 @@ export function useContract() { e.preventDefault(); setWait(true); - const contractDeployer = new ContractDeployer(artifact, deployerEnv.pxe); const wallet = await deployerEnv.getWallet(); + const contractDeployer = new ContractDeployer(artifact, wallet); const salt = Fr.random(); const tx = contractDeployer .deploy(Fr.random(), wallet.getCompleteAddress().address) .send({ contractAddressSalt: salt }); - const { contractAddress } = await toast.promise(tx.wait(), { + const { address: contractAddress } = await toast.promise(tx.deployed(), { pending: 'Deploying contract...', success: { - render: ({ data }) => `Address: ${data.contractAddress}`, + render: ({ data }) => `Address: ${data.address}`, }, error: 'Error deploying contract', }); diff --git a/boxes/react/src/index.tsx b/boxes/react/src/index.tsx index e71d6ce7dcfe..3c657332834c 100644 --- a/boxes/react/src/index.tsx +++ b/boxes/react/src/index.tsx @@ -1,11 +1,9 @@ -import { Home } from "./pages/home"; -import "react-toastify/dist/ReactToastify.css"; -import * as ReactDOM from "react-dom/client"; -import { ToastContainer } from "react-toastify"; +import { Home } from './pages/home'; +import 'react-toastify/dist/ReactToastify.css'; +import * as ReactDOM from 'react-dom/client'; +import { ToastContainer } from 'react-toastify'; -const root = ReactDOM.createRoot( - document.getElementById("root") as HTMLElement, -); +const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); root.render( <> diff --git a/boxes/react/src/pages/contract.tsx b/boxes/react/src/pages/contract.tsx index 1310eae0c485..93d398ef1f4a 100644 --- a/boxes/react/src/pages/contract.tsx +++ b/boxes/react/src/pages/contract.tsx @@ -1,7 +1,7 @@ -import { useState } from "react"; -import { Contract } from "@aztec/aztec.js"; -import { useNumber } from "../hooks/useNumber"; -import { filteredInterface } from "../config"; +import { useState } from 'react'; +import { Contract } from '@aztec/aztec.js'; +import { useNumber } from '../hooks/useNumber'; +import { filteredInterface } from '../config'; export function ContractComponent({ contract }: { contract: Contract }) { const [showInput, setShowInput] = useState(true); @@ -15,7 +15,7 @@ export function ContractComponent({ contract }: { contract: Contract }) { setShowInput(true)} - > + - + diff --git a/boxes/react/src/pages/home.tsx b/boxes/react/src/pages/home.tsx index 8c0fb1236671..ba41f15cebf2 100644 --- a/boxes/react/src/pages/home.tsx +++ b/boxes/react/src/pages/home.tsx @@ -1,5 +1,5 @@ -import { ContractComponent } from "./contract"; -import { useContract } from "../hooks/useContract"; +import { ContractComponent } from './contract'; +import { useContract } from '../hooks/useContract'; export function Home() { const { contract, deploy, wait } = useContract(); diff --git a/boxes/react/tests/blank.contract.test.ts b/boxes/react/tests/blank.contract.test.ts index 9887ccc7f0ba..40c43ef8acc7 100644 --- a/boxes/react/tests/blank.contract.test.ts +++ b/boxes/react/tests/blank.contract.test.ts @@ -13,11 +13,9 @@ describe('BoxReact Contract Tests', () => { beforeAll(async () => { wallet = await deployerEnv.getWallet(); const pxe = deployerEnv.pxe; - const deployer = new ContractDeployer(artifact, pxe); + const deployer = new ContractDeployer(artifact, wallet); const salt = Fr.random(); - const tx = deployer.deploy(Fr.random(), wallet.getCompleteAddress().address).send({ contractAddressSalt: salt }); - await tx.wait(); - const { contractAddress } = await tx.getReceipt(); + const { address: contractAddress } = await deployer.deploy(Fr.random(), wallet.getCompleteAddress().address).send({ contractAddressSalt: salt }).deployed(); contract = await BoxReactContract.at(contractAddress!, wallet); logger(`L2 contract deployed at ${contractAddress}`); diff --git a/boxes/vanilla-js/src/index.ts b/boxes/vanilla-js/src/index.ts index f81720a1a26d..53e0f92099f5 100644 --- a/boxes/vanilla-js/src/index.ts +++ b/boxes/vanilla-js/src/index.ts @@ -6,7 +6,6 @@ import { Fr, AccountWalletWithPrivateKey, } from '@aztec/aztec.js'; -import { BlankContractArtifact } from './artifacts/Blank.js'; import { SingleKeyAccountContract } from '@aztec/accounts/single_key'; import { VanillaContract } from '../artifacts/Vanilla'; @@ -28,11 +27,11 @@ document.querySelector('#deploy').addEventListener('click', async ({ target }: a wallet = await account.register(); const { artifact, at } = VanillaContract; - const contractDeployer = new ContractDeployer(artifact, pxe); - const { contractAddress } = await contractDeployer + const contractDeployer = new ContractDeployer(artifact, wallet); + const { address: contractAddress } = await contractDeployer .deploy(Fr.random(), wallet.getCompleteAddress().address) .send({ contractAddressSalt: Fr.random() }) - .wait(); + .deployed(); contract = await at(contractAddress, wallet); alert(`Contract deployed at ${contractAddress}`);