Skip to content

Commit bf53f5e

Browse files
authored
refactor: nuking Token::privately_mint_private_note(...) (#9616)
1 parent 737c573 commit bf53f5e

File tree

7 files changed

+12
-29
lines changed

7 files changed

+12
-29
lines changed

noir-projects/noir-contracts/contracts/token_contract/src/main.nr

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,6 @@ contract Token {
221221
// docs:end:insert_from_public
222222
}
223223
// docs:end:mint_private
224-
// TODO: Nuke this - test functions do not belong to token contract!
225-
#[private]
226-
fn privately_mint_private_note(amount: Field) {
227-
let caller = context.msg_sender();
228-
let caller_ovpk_m = get_public_keys(caller).ovpk_m;
229-
storage.balances.at(caller).add(caller, U128::from_integer(amount)).emit(
230-
encode_and_encrypt_note(&mut context, caller_ovpk_m, caller, caller),
231-
);
232-
Token::at(context.this_address())
233-
.assert_minter_and_mint(context.msg_sender(), amount)
234-
.enqueue(&mut context);
235-
}
236-
#[public]
237-
#[internal]
238-
fn assert_minter_and_mint(minter: AztecAddress, amount: Field) {
239-
assert(storage.minters.at(minter).read(), "caller is not minter");
240-
let supply = storage.total_supply.read() + U128::from_integer(amount);
241-
storage.total_supply.write(supply);
242-
}
243224
// docs:start:shield
244225
#[public]
245226
fn shield(from: AztecAddress, amount: Field, secret_hash: Field, nonce: Field) {

yarn-project/bot/src/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class BotFactory {
149149

150150
calls.push(
151151
isStandardToken
152-
? token.methods.privately_mint_private_note(MINT_BALANCE).request()
152+
? token.methods.mint_to_private(sender, MINT_BALANCE).request()
153153
: token.methods.mint(MINT_BALANCE, sender, sender).request(),
154154
);
155155
}

yarn-project/end-to-end/src/benchmarks/bench_prover.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('benchmarks/proving', () => {
108108
await Promise.all([
109109
initialGasContract.methods.claim(initialFpContract.address, 1e12, claimSecret, messageLeafIndex).send().wait(),
110110
initialTokenContract.methods.mint_public(initialSchnorrWallet.getAddress(), 1e12).send().wait(),
111-
initialTokenContract.methods.privately_mint_private_note(1e12).send().wait(),
111+
initialTokenContract.methods.mint_to_private(initialSchnorrWallet.getAddress(), 1e12).send().wait(),
112112
]);
113113

114114
recipient = CompleteAddress.random();

yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('benchmarks/tx_size_fees', () => {
7171
feeJuice.methods.claim(fpc.address, 100e9, fpcSecret, fpcLeafIndex).send().wait(),
7272
feeJuice.methods.claim(aliceWallet.getAddress(), 100e9, aliceSecret, aliceLeafIndex).send().wait(),
7373
]);
74-
await token.methods.privately_mint_private_note(100e9).send().wait();
74+
await token.methods.mint_to_private(aliceWallet.getAddress(), 100e9).send().wait();
7575
await token.methods.mint_public(aliceWallet.getAddress(), 100e9).send().wait();
7676
});
7777

yarn-project/end-to-end/src/e2e_fees/fees_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class FeesTest {
116116
/** Alice mints Token */
117117
async mintToken(amount: bigint) {
118118
const balanceBefore = await this.token.methods.balance_of_private(this.aliceAddress).simulate();
119-
await this.token.methods.privately_mint_private_note(amount).send().wait();
119+
await this.token.methods.mint_to_private(this.aliceAddress, amount).send().wait();
120120
const balanceAfter = await this.token.methods.balance_of_private(this.aliceAddress).simulate();
121121
expect(balanceAfter).toEqual(balanceBefore + amount);
122122
}

yarn-project/end-to-end/src/e2e_fees/private_payments.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ describe('e2e_fees private_payment', () => {
196196
*/
197197
const newlyMintedBananas = 10n;
198198
const tx = await bananaCoin.methods
199-
.privately_mint_private_note(newlyMintedBananas)
199+
.mint_to_private(aliceAddress, newlyMintedBananas)
200200
.send({
201201
fee: {
202202
gasSettings,
@@ -373,7 +373,7 @@ describe('e2e_fees private_payment', () => {
373373

374374
await expect(
375375
bananaCoin.methods
376-
.privately_mint_private_note(10)
376+
.mint_to_private(aliceAddress, 10)
377377
.send({
378378
// we need to skip public simulation otherwise the PXE refuses to accept the TX
379379
skipPublicSimulation: true,

yarn-project/end-to-end/src/e2e_token_contract/private_transfer_recursion.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ describe('e2e_token_contract private transfer recursion', () => {
1818
});
1919

2020
async function mintNotes(noteAmounts: bigint[]): Promise<bigint> {
21-
// Mint all notes, 4 at a time
22-
for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += 4) {
23-
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + 4); // We mint 4 notes at a time
24-
const actions = toMint.map(amt => asset.methods.privately_mint_private_note(amt).request());
21+
// We mint only 3 notes in 1 transaction as that is the maximum public data writes we can squeeze into a tx.
22+
// --> Minting one note requires 19 public data writes (16 for the note encrypted log, 3 for note hiding point).
23+
const notesPerIteration = 3;
24+
for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
25+
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
26+
const actions = toMint.map(amt => asset.methods.mint_to_private(wallets[0].getAddress(), amt).request());
2527
await new BatchCall(wallets[0], actions).send().wait();
2628
}
2729

0 commit comments

Comments
 (0)