Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
11 changes: 5 additions & 6 deletions yarn-project/aztec.js/src/account_manager/account_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class AccountManager {
if (deployWallet) {
// If deploying using an existing wallet/account, treat it like regular contract deployment.
const thisWallet = await this.getWallet();
new DeployMethod(
return new DeployMethod(
this.getPublicKeys(),
deployWallet,
artifact,
Expand Down Expand Up @@ -246,12 +246,11 @@ export class AccountManager {
}

/**
* Deploys the account contract that backs this account.
* Does not register the associated class nor publicly deploy the instance by default.
* Uses the salt provided in the constructor or a randomly generated one.
* Registers the account in the PXE Service before deploying the contract.
* Estimates the gas needed to deploy the account contract that backs this account.
* This method is here to ensure that the fee payment method is correctly set up in case
* the account contract needs to pay for its own deployment.
* @param opts - Fee options to be used for the deployment.
* @returns A SentTx object that can be waited to get the associated Wallet.
* @returns The gas estimations for the account contract deployment and initialization.
*/
public async estimateDeploymentGas(
opts?: DeployAccountOptions,
Expand Down
1 change: 1 addition & 0 deletions yarn-project/aztec.js/src/api/fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { FeeJuicePaymentMethod } from '../fee/fee_juice_payment_method.js';
export { PrivateFeePaymentMethod } from '../fee/private_fee_payment_method.js';
export { PublicFeePaymentMethod } from '../fee/public_fee_payment_method.js';
export { FeeJuicePaymentMethodWithClaim } from '../fee/fee_juice_payment_method_with_claim.js';
export { SponsoredFeePaymentMethod } from '../fee/sponsored_fee_payment.js';
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ import type { GasSettings } from '@aztec/stdlib/gas';
* Fee payment method that allows a contract to pay for its own deployment
* It works by rerouting the provided fee payment method through the account's entrypoint,
* which sets itself as fee payer.
*
* Usually, in order to pay fees it is necessary to obtain an ExecutionPayload that encodes the necessary information
* That is sent to the user's account entrypoint, that has plumbing to handle a fee payload.
* If there's no account contract yet (it's being deployed) a MultiCallContract is used, which doesn't have a concept of fees or
* how to handle this payload.
* HOWEVER,the account contract entrypoint does, so this method reshapes that fee payload into a call to the account contract entrypoint
* being deployed with the original fee payload.
*
* This class can be seen in action in AccountManager.ts#getSelfPaymentMethod
*/
export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
constructor(
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/cli/src/utils/setup_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Fr,
type PXE,
SignerlessWallet,
SponsoredFeePaymentMethod,
type WaitForProvenOpts,
getContractInstanceFromDeployParams,
waitForProven,
Expand Down Expand Up @@ -71,9 +72,9 @@ export async function setupSponsoredFPC(
const sponsoredFPCInstance = await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, {
salt: new Fr(SPONSORED_FPC_SALT),
});
const paymentMethod = new FeeJuicePaymentMethod(sponsoredFPCInstance.address);
const paymentMethod = new SponsoredFeePaymentMethod(sponsoredFPCInstance.address);

const deployTx = await SponsoredFPCContract.deploy(deployer).send({
const deployTx = SponsoredFPCContract.deploy(deployer).send({
contractAddressSalt: new Fr(SPONSORED_FPC_SALT),
universalDeploy: true,
fee: { paymentMethod },
Expand Down
Loading