Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 30, 2024
1 parent fba5141 commit 938d8a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/sample-dapp/contracts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 11 additions & 4 deletions yarn-project/end-to-end/src/sample-dapp/index.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 938d8a7

Please sign in to comment.