Skip to content

Commit

Permalink
refactor: final token cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Nov 11, 2024
1 parent 1beaa2d commit 7267578
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,7 @@ contract Token {
storage.total_supply.write(supply);
}
// docs:end:mint_public
// docs:start:mint_private
// TODO(benesjan): To be nuked in a followup PR.
#[public]
fn mint_private_old(amount: Field, secret_hash: Field) {
assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter");
let pending_shields = storage.pending_shields;
let mut note = TransparentNote::new(amount, secret_hash);
let supply = storage.total_supply.read().add(U128::from_integer(amount));
storage.total_supply.write(supply);
// docs:start:insert_from_public
pending_shields.insert_from_public(&mut note);
// docs:end:insert_from_public
}
// docs:end:mint_private

// docs:start:shield
#[public]
fn shield(from: AztecAddress, amount: Field, secret_hash: Field, nonce: Field) {
Expand Down
24 changes: 1 addition & 23 deletions yarn-project/end-to-end/src/e2e_synching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { getSchnorrAccount } from '@aztec/accounts/schnorr';
import { createArchiver } from '@aztec/archiver';
import { AztecNodeService } from '@aztec/aztec-node';
import {
type AccountWallet,
type AccountWalletWithSecretKey,
AnvilTestWatcher,
BatchCall,
Expand All @@ -48,7 +47,7 @@ import {
sleep,
} from '@aztec/aztec.js';
// eslint-disable-next-line no-restricted-imports
import { ExtendedNote, L2Block, LogType, Note, type TxHash } from '@aztec/circuit-types';
import { L2Block, LogType } from '@aztec/circuit-types';
import { type AztecAddress } from '@aztec/circuits.js';
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum';
import { Timer } from '@aztec/foundation/timer';
Expand Down Expand Up @@ -184,27 +183,6 @@ class TestVariant {
}
}

private async addPendingShieldNoteToPXE(args: {
amount: bigint;
secretHash: Fr;
txHash: TxHash;
accountAddress: AztecAddress;
assetAddress: AztecAddress;
wallet: AccountWallet;
}) {
const { accountAddress, assetAddress, amount, secretHash, txHash, wallet } = args;
const note = new Note([new Fr(amount), secretHash]);
const extendedNote = new ExtendedNote(
note,
accountAddress,
assetAddress,
TokenContract.storage.pending_shields.slot,
TokenContract.notes.TransparentNote.id,
txHash,
);
await wallet.addNote(extendedNote);
}

async createAndSendTxs() {
if (!this.pxe) {
throw new Error('Undefined PXE');
Expand Down
17 changes: 0 additions & 17 deletions yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import {
type AztecNode,
type DebugLogger,
EthAddress,
ExtendedNote,
type FieldsOf,
Fr,
type L1TokenManager,
L1TokenPortalManager,
type L2AmountClaim,
type L2RedeemableAmountClaim,
Note,
type PXE,
type SiblingPath,
type TxHash,
type TxReceipt,
type Wallet,
deployL1Contract,
Expand Down Expand Up @@ -343,20 +340,6 @@ export class CrossChainTestHarness {
await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send().wait();
}

async addPendingShieldNoteToPXE(shieldAmount: bigint, secretHash: Fr, txHash: TxHash) {
this.logger.info('Adding note to PXE');
const note = new Note([new Fr(shieldAmount), secretHash]);
const extendedNote = new ExtendedNote(
note,
this.ownerAddress,
this.l2Token.address,
TokenContract.storage.pending_shields.slot,
TokenContract.notes.TransparentNote.id,
txHash,
);
await this.ownerWallet.addNote(extendedNote);
}

async transferToPublicOnL2(amount: bigint, nonce = Fr.ZERO) {
this.logger.info('Transferring tokens to public');
await this.l2Token.methods.transfer_to_public(this.ownerAddress, this.ownerAddress, amount, nonce).send().wait();
Expand Down

0 comments on commit 7267578

Please sign in to comment.