Skip to content

Commit 648da37

Browse files
authored
cleanup and comments
1 parent cc0796b commit 648da37

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scripts/fees.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ async function main() {
3838

3939
let pxe: PXE;
4040
let wallets: AccountWallet[] = [];
41-
let accounts: CompleteAddress[] = [];
4241
let logger: Logger;
4342

4443
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
@@ -51,13 +50,16 @@ async function main() {
5150
const l1ContractAddresses = nodeInfo.l1ContractAddresses;
5251

5352
// Setup Schnorr AccountManager
53+
5454
let secretKey = Fr.random();
5555
let salt = Fr.random();
5656
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
5757

5858
const newWallet = await schnorrAccount.getWallet()
5959
const feeJuiceReceipient = schnorrAccount.getAddress()
6060

61+
// Setup and bridge fee asset to L2 to get fee juice
62+
6163
const feeJuicePortalManager = new L1FeeJuicePortalManager(
6264
l1ContractAddresses.feeJuicePortalAddress,
6365
l1ContractAddresses.feeJuiceAddress,
@@ -67,13 +69,12 @@ async function main() {
6769
logger,
6870
);
6971

70-
let feeJuiceTokenManager = feeJuicePortalManager.getTokenManager()
7172
const claim = await feeJuicePortalManager.bridgeTokensPublic(feeJuiceReceipient, amount, true);
7273

7374
const feeJuice = await FeeJuiceContract.at(nodeInfo.protocolContractAddresses.feeJuice, wallets[0])
7475
logger.info(`Fee Juice minted to ${feeJuiceReceipient} on L2.`)
7576

76-
// Two arbitraty txs to make the message available
77+
// Two arbitraty txs to make the L1 message available on L2
7778
const votingContract = await EasyPrivateVotingContract.deploy(wallets[0], wallets[0].getAddress()).send().deployed();
7879
const bananaCoin = await TokenContract.deploy(wallets[0], wallets[0].getAddress(), "bananaCoin", "BNC", 18).send().deployed()
7980

@@ -87,7 +88,6 @@ async function main() {
8788

8889
// Create a new voting contract instance, interacting from the newWallet
8990
const useFeeJuice = new FeeJuicePaymentMethod(newWallet.getAddress())
90-
// vote for wallets[0]
9191
await votingContract.withWallet(newWallet).methods.cast_vote(wallets[0].getAddress()).send({ fee: { paymentMethod: useFeeJuice }}).wait()
9292
logger.info(`Vote cast from new account, paying fees via newWallet.`)
9393

@@ -100,18 +100,21 @@ async function main() {
100100
const fpc = await FPCContract.deploy(wallets[0], bananaCoin.address, wallets[0].getAddress()).send().deployed()
101101
const fpcClaim = await feeJuicePortalManager.bridgeTokensPublic(fpc.address, amount, true);
102102
// 2 public txs to make the bridged fee juice available
103-
// Mint some bananaCoin and send to the newWallet
103+
// Mint some bananaCoin and send to the newWallet to pay fees privately
104104
await bananaCoin.methods.mint_to_private(wallets[0].getAddress(), newWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send().wait()
105105
// mint some public bananaCoin to the newWallet to pay fees publicly
106106
await bananaCoin.methods.mint_to_public(newWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send().wait()
107107
const bananaBalance = await bananaCoin.withWallet(newWallet).methods.balance_of_private(newWallet.getAddress()).simulate()
108108

109109
logger.info(`BananaCoin balance of newWallet is ${bananaBalance}`)
110+
110111
await feeJuice.methods.claim(fpc.address, fpcClaim.claimAmount, fpcClaim.claimSecret, fpcClaim.messageLeafIndex).send().wait()
111112

112113
logger.info(`Fpc fee juice balance ${await feeJuice.methods.balance_of_public(fpc.address).simulate()}`)
114+
113115
const privateFee = new PrivateFeePaymentMethod(fpc.address, newWallet)
114116
await bananaCoin.withWallet(newWallet).methods.transfer_in_private(newWallet.getAddress(), wallets[0].getAddress(), 10, 0).send({ fee: { paymentMethod: privateFee }}).wait()
117+
115118
logger.info(`Transfer paid with fees via the FPC, privately.`)
116119

117120
// Public Fee Payments via FPC

0 commit comments

Comments
 (0)