diff --git a/yarn-project/end-to-end/src/sample-dapp/contracts.mjs b/yarn-project/end-to-end/src/sample-dapp/contracts.mjs index 4d718097d85..9560c2508af 100644 --- a/yarn-project/end-to-end/src/sample-dapp/contracts.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/contracts.mjs @@ -7,8 +7,8 @@ import { readFileSync } from 'fs'; // docs:end:imports // docs:start:get-tokens -export async function getToken(client) { +export async function getToken(wallet) { const addresses = JSON.parse(readFileSync('addresses.json')); - return TokenContract.at(AztecAddress.fromString(addresses.token), client); + return TokenContract.at(AztecAddress.fromString(addresses.token), wallet); } // docs:end:get-tokens diff --git a/yarn-project/end-to-end/src/sample-dapp/index.mjs b/yarn-project/end-to-end/src/sample-dapp/index.mjs index 167cfec2dd8..5b0d6822a4c 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.mjs @@ -1,6 +1,6 @@ // docs:start:imports import { getInitialTestAccountsWallets } from '@aztec/accounts/testing'; -import { createPXEClient, waitForPXE } from '@aztec/aztec.js'; +import { BatchCall, createPXEClient, waitForPXE } from '@aztec/aztec.js'; import { fileURLToPath } from '@aztec/foundation/url'; import { getToken } from './contracts.mjs'; @@ -33,13 +33,20 @@ async function showPrivateBalances(pxe) { // docs:start:mintPrivateFunds async function mintPrivateFunds(pxe) { - const [owner] = await getInitialTestAccountsWallets(pxe); - const token = await getToken(owner); + const [ownerWallet] = await getInitialTestAccountsWallets(pxe); + const token = await getToken(ownerWallet); await showPrivateBalances(pxe); const mintAmount = 20n; - await mintTokensToPrivate(token, owner, owner.getAddress(), mintAmount); + // We don't have the functionality to mint to private so we mint to the owner address in public and transfer + // the tokens to the recipient in private. We use BatchCall to speed the process up. + await new BatchCall(ownerWallet, [ + token.methods.mint_public(ownerWallet.getAddress(), mintAmount).request(), + token.methods.transfer_to_private(ownerWallet.getAddress(), mintAmount).request(), + ]) + .send() + .wait(); await showPrivateBalances(pxe); }