Skip to content

Commit 8bb611e

Browse files
authored
Merge pull request #206 from AztecProtocol/jc/fees-fix
Refactor fee payment handling in fees.ts by streamlining voting contract instance creation and reordering feeJuice initialization. Update gas settings for improved fee management.
2 parents b04cc41 + d5f9d6d commit 8bb611e

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

scripts/fees.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,11 @@ async function main() {
8686

8787
// Pay fees yourself
8888

89-
const feeJuiceInstance = await getCanonicalFeeJuice();
90-
wallet.registerContract(feeJuiceInstance.address, FeeJuiceContract.artifact)
91-
const feeJuice = await FeeJuiceContract.at(feeJuiceInstance.address, wallet)
92-
93-
const maxFeesPerGas = (await node.getCurrentBaseFees()).mul(1.5);
94-
const gasSettings = GasSettings.default({ maxFeesPerGas });
95-
96-
// TODO: Fix
97-
// // Create a new voting contract instance, interacting from the newWallet
98-
// const useFeeJuice = new PublicFeePaymentMethod(feeJuiceInstance.address, account2.address, wallet, gasSettings)
99-
// await votingContract.methods.cast_vote(account1.address).send({
100-
// from: account2.address,
101-
// fee: { paymentMethod: useFeeJuice }
102-
// }).wait()
103-
// logger.info(`Vote cast from new account, paying fees via newWallet.`)
89+
// Create a new voting contract instance, interacting from the newWallet
90+
await votingContract.methods.cast_vote(account1.address).send({
91+
from: account2.address,
92+
}).wait()
93+
logger.info(`Vote cast from new account, paying fees via newWallet.`)
10494

10595
// Private Fee Payments via FPC
10696

@@ -130,13 +120,19 @@ async function main() {
130120

131121
logger.info(`BananaCoin balance of newWallet is ${bananaBalance}`)
132122

123+
const feeJuiceInstance = await getCanonicalFeeJuice();
124+
wallet.registerContract(feeJuiceInstance.address, FeeJuiceContract.artifact)
125+
const feeJuice = await FeeJuiceContract.at(feeJuiceInstance.address, wallet)
133126

134127
await feeJuice.methods.claim(fpc.address, fpcClaim.claimAmount, fpcClaim.claimSecret, fpcClaim.messageLeafIndex).send({ from: account2.address }).wait()
135128

136129
logger.info(`Fpc fee juice balance ${await feeJuice.methods.balance_of_public(fpc.address).simulate({
137130
from: account2.address
138131
})}`)
139132

133+
const maxFeesPerGas = (await node.getCurrentBaseFees()).mul(1.5);
134+
const gasSettings = GasSettings.default({ maxFeesPerGas });
135+
140136
const privateFee = new PrivateFeePaymentMethod(fpc.address, account2.address, wallet, gasSettings)
141137
await bananaCoin.methods.transfer_in_private(account2.address, account1.address, 10, 0).send({
142138
from: account2.address,

0 commit comments

Comments
 (0)