Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dapp sub test #4938

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ jobs:
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_authwit.test.ts
aztec_manifest_key: end-to-end


e2e-blacklist-token-contract:
docker:
- image: aztecprotocol/alpine-build-image
Expand Down Expand Up @@ -1025,6 +1024,18 @@ jobs:
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_fees.test.ts
aztec_manifest_key: end-to-end

e2e-dapp-subscription:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Test"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_dapp_subscription.test.ts
aztec_manifest_key: end-to-end

pxe:
docker:
- image: aztecprotocol/alpine-build-image
Expand Down Expand Up @@ -1496,6 +1507,7 @@ workflows:
- e2e-card-game: *e2e_test
- e2e-avm-simulator: *e2e_test
- e2e-fees: *e2e_test
- e2e-dapp-subscription: *e2e_test
- pxe: *e2e_test
- cli-docs-sandbox: *e2e_test
- e2e-docs-examples: *e2e_test
Expand Down Expand Up @@ -1542,6 +1554,7 @@ workflows:
- e2e-card-game
- e2e-avm-simulator
- e2e-fees
- e2e-dapp-subscription
- pxe
- boxes-vanilla
- boxes-react
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/fee/public_fee_payment_method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr } from '@aztec/foundation/fields';

import { computeAuthWitMessageHash } from '../utils/authwit.js';
import { AccountWalletWithPrivateKey } from '../wallet/account_wallet_with_private_key.js';
import { AccountWallet } from '../wallet/account_wallet.js';
import { FeePaymentMethod } from './fee_payment_method.js';

/**
Expand All @@ -25,7 +25,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
/**
* An auth witness provider to authorize fee payments
*/
private wallet: AccountWalletWithPrivateKey,
private wallet: AccountWallet,
) {}

/**
Expand Down
11 changes: 10 additions & 1 deletion yarn-project/end-to-end/src/e2e_dapp_subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ import {

import { jest } from '@jest/globals';

import { BalancesFn, EndToEndContext, expectMapping, getBalancesFn, setup } from './fixtures/utils.js';
import {
BalancesFn,
EndToEndContext,
expectMapping,
getBalancesFn,
publicDeployAccounts,
setup,
} from './fixtures/utils.js';
import { GasPortalTestingHarnessFactory, IGasBridgingTestHarness } from './shared/gas_portal_test_harness.js';

jest.setTimeout(1_000_000);
Expand Down Expand Up @@ -118,6 +125,8 @@ describe('e2e_dapp_subscription', () => {
[aliceAddress, sequencerAddress, subscriptionContract.address, bananaFPC.address],
[0n, 0n, BRIDGED_GAS_BALANCE, BRIDGED_GAS_BALANCE],
);

await publicDeployAccounts(e2eContext.wallet, e2eContext.accounts);
});

it('should allow Alice to subscribe by paying privately with bananas', async () => {
Expand Down
18 changes: 6 additions & 12 deletions yarn-project/entrypoints/src/dapp_entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/aztec.js';
import { AuthWitnessProvider, EntrypointInterface } from '@aztec/aztec.js/account';
import { FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types';
import { AztecAddress, Fr, FunctionData, GeneratorIndex, TxContext } from '@aztec/circuits.js';
import { AztecAddress, Fr, FunctionData, TxContext } from '@aztec/circuits.js';
import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi';
import { pedersenHash } from '@aztec/foundation/crypto';

import { DEFAULT_CHAIN_ID, DEFAULT_VERSION } from './constants.js';
import { buildDappPayload } from './entrypoint_payload.js';
Expand Down Expand Up @@ -30,17 +30,11 @@ export class DefaultDappEntrypoint implements EntrypointInterface {
const entrypointPackedArgs = PackedArguments.fromArgs(encodeArguments(abi, [payload, this.userAddress]));

const functionData = FunctionData.fromAbi(abi);
const hash = pedersenHash(
[
Fr.ZERO.toBuffer(),
this.dappEntrypointAddress.toBuffer(),
functionData.selector.toBuffer(),
entrypointPackedArgs.hash.toBuffer(),
],
GeneratorIndex.SIGNATURE_PAYLOAD,
);

const authWitness = await this.userAuthWitnessProvider.createAuthWitness(hash);
const innerHash = computeInnerAuthWitHash([Fr.ZERO, functionData.selector.toField(), entrypointPackedArgs.hash]);
const outerHash = computeOuterAuthWitHash(this.dappEntrypointAddress, innerHash);

const authWitness = await this.userAuthWitnessProvider.createAuthWitness(outerHash);

const txRequest = TxExecutionRequest.from({
argsHash: entrypointPackedArgs.hash,
Expand Down
Loading