Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Nov 8, 2024
1 parent 53cabb4 commit ff23639
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ contract FPC {
}

#[private]
fn fee_entrypoint_private(amount: Field, asset: AztecAddress) {
fn fee_entrypoint_private(amount: Field, asset: AztecAddress, nonce: Field) {
// TODO(PR #8022): Once SharedImmutable performs only 1 merkle proof here, we'll save ~4k gates
let settings = storage.settings.read_private();

assert(asset == settings.other_asset);

Token::at(asset).setup_refund(settings.admin, context.msg_sender(), amount).call(
Token::at(asset).setup_refund(settings.admin, context.msg_sender(), amount, nonce).call(
&mut context,
);
context.set_as_fee_payer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ contract Token {
fee_payer: AztecAddress, // Address of the entity which will receive the fee note.
user: AztecAddress, // A user for which we are setting up the fee refund.
funded_amount: Field, // The amount the user funded the fee payer with (represents fee limit).
nonce: Field // A nonce to make authwitness unique.
) {
// 1. This function is called by fee paying contract (fee_payer) when setting up a refund so we need to support
// the authwit flow here and check that the user really permitted fee_payer to set up a refund on their behalf.
Expand Down
9 changes: 5 additions & 4 deletions yarn-project/aztec.js/src/fee/private_fee_payment_method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
// We assume 1:1 exchange rate between fee juice and token. But in reality you would need to convert feeLimit
// (maxFee) to be in token denomination.
const maxFee = this.setMaxFeeToOne ? Fr.ONE : gasSettings.getFeeLimit();
const nonce = Fr.random();

await this.wallet.createAuthWit({
caller: this.paymentContract,
action: {
name: 'setup_refund',
args: [this.feeRecipient, this.wallet.getAddress(), maxFee],
selector: FunctionSelector.fromSignature('setup_refund((Field),(Field),Field)'),
args: [this.feeRecipient, this.wallet.getAddress(), maxFee, nonce],
selector: FunctionSelector.fromSignature('setup_refund((Field),(Field),Field,Field)'),
type: FunctionType.PRIVATE,
isStatic: false,
to: this.asset,
Expand All @@ -77,10 +78,10 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
{
name: 'fee_entrypoint_private',
to: this.paymentContract,
selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,(Field))'),
selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,(Field),Field)'),
type: FunctionType.PRIVATE,
isStatic: false,
args: [maxFee, this.asset],
args: [maxFee, this.asset, nonce],
returnTypes: [],
},
];
Expand Down

0 comments on commit ff23639

Please sign in to comment.