Skip to content

Commit 5a89972

Browse files
committed
Migrate e2e_dapp_subscription into e2e_fees
1 parent 9a4f9bf commit 5a89972

8 files changed

Lines changed: 336 additions & 294 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ contract AppSubscription {
3131
subscription_price: SharedImmutable<Field>,
3232
subscriptions: Map<AztecAddress, PrivateMutable<SubscriptionNote>>,
3333
gas_token_address: SharedImmutable<AztecAddress>,
34+
gas_token_limit_per_tx: SharedImmutable<Field>,
3435
}
3536

3637
global SUBSCRIPTION_DURATION_IN_BLOCKS = 5;
@@ -47,7 +48,8 @@ contract AppSubscription {
4748
note.remaining_txs -= 1;
4849
storage.subscriptions.at(user_address).replace(&mut note, true);
4950

50-
GasToken::at(storage.gas_token_address.read_private()).pay_fee(42).enqueue(&mut context);
51+
let gas_limit = storage.gas_token_limit_per_tx.read_private();
52+
GasToken::at(storage.gas_token_address.read_private()).pay_fee(gas_limit).enqueue(&mut context);
5153

5254
context.end_setup();
5355

@@ -63,14 +65,15 @@ contract AppSubscription {
6365
subscription_recipient_address: AztecAddress,
6466
subscription_token_address: AztecAddress,
6567
subscription_price: Field,
66-
gas_token_address: AztecAddress
68+
gas_token_address: AztecAddress,
69+
gas_token_limit_per_tx: Field
6770
) {
6871
storage.target_address.initialize(target_address);
6972
storage.subscription_token_address.initialize(subscription_token_address);
7073
storage.subscription_recipient_address.initialize(subscription_recipient_address);
7174
storage.subscription_price.initialize(subscription_price);
72-
7375
storage.gas_token_address.initialize(gas_token_address);
76+
storage.gas_token_limit_per_tx.initialize(gas_token_limit_per_tx);
7477
}
7578

7679
#[aztec(public)]

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ contract GasToken {
5555
fn pay_fee(fee_limit: Field) -> Field {
5656
let fee_limit_u128 = U128::from_integer(fee_limit);
5757
let fee = U128::from_integer(calculate_fee(context));
58+
dep::aztec::oracle::debug_log::debug_log_format(
59+
"Gas token: paying fee {0} (limit {1})",
60+
[fee.to_field(), fee_limit]
61+
);
5862
assert(fee <= fee_limit_u128, "Fee too high");
5963

6064
let sender_new_balance = storage.balances.at(context.msg_sender()).read() - fee;

yarn-project/end-to-end/src/e2e_dapp_subscription.test.ts

Lines changed: 0 additions & 262 deletions
This file was deleted.

0 commit comments

Comments
 (0)