@aztec/aztec.js 0.0.1-commit.d3ec352c → 0.0.1-commit.e61ad554
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account/account.d.ts +25 -40
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +9 -10
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +21 -9
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.js +21 -4
- package/dest/account/index.d.ts +4 -3
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +6 -7
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/account.d.ts +2 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -3
- package/dest/api/authorization.d.ts +2 -2
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +1 -1
- package/dest/api/contract.d.ts +16 -10
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +14 -8
- package/dest/api/fields.d.ts +3 -2
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +2 -1
- package/dest/api/node.d.ts +8 -4
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +7 -3
- package/dest/api/protocol.d.ts +7 -1
- package/dest/api/protocol.d.ts.map +1 -1
- package/dest/api/protocol.js +6 -0
- package/dest/api/tx.d.ts +2 -2
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/wallet.d.ts +2 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +1 -1
- package/dest/authorization/call_authorization_request.d.ts +23 -2
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -10
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/batch_call.d.ts +1 -1
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +3 -1
- package/dest/contract/contract_base.d.ts +4 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +1 -1
- package/dest/contract/deploy_method.d.ts +64 -17
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +42 -24
- package/dest/contract/interaction_options.d.ts +42 -5
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +8 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +963 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +784 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +858 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +827 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +563 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/public-checks.js +579 -0
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/deployment/broadcast_function.js +4 -4
- package/dest/deployment/publish_class.js +3 -3
- package/dest/deployment/publish_instance.d.ts +2 -2
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +3 -3
- package/dest/ethereum/portal_manager.d.ts +9 -6
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +17 -18
- package/dest/fee/fee_juice_payment_method_with_claim.js +1 -1
- package/dest/fee/private_fee_payment_method.js +1 -1
- package/dest/fee/public_fee_payment_method.js +1 -1
- package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
- package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
- package/dest/scripts/generate_protocol_contract_types.js +120 -0
- package/dest/utils/abi_types.d.ts +2 -2
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +9 -7
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +6 -10
- package/dest/utils/cross_chain.d.ts +2 -2
- package/dest/utils/cross_chain.d.ts.map +1 -1
- package/dest/utils/fee_juice.js +1 -1
- package/dest/utils/field_compressed_string.js +1 -1
- package/dest/utils/node.d.ts +12 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- package/dest/utils/pub_key.d.ts +2 -2
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
- package/dest/wallet/account_manager.d.ts +6 -9
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +6 -12
- package/dest/wallet/deploy_account_method.d.ts +35 -7
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +8 -6
- package/dest/wallet/wallet.d.ts +292 -960
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +76 -90
- package/package.json +14 -12
- package/src/account/account.ts +34 -58
- package/src/account/account_contract.ts +7 -8
- package/src/account/account_with_secret_key.ts +34 -9
- package/src/account/index.ts +3 -2
- package/src/account/signerless_account.ts +14 -13
- package/src/api/account.ts +9 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +22 -7
- package/src/api/fields.ts +2 -1
- package/src/api/node.ts +7 -3
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +9 -2
- package/src/authorization/call_authorization_request.ts +1 -1
- package/src/contract/base_contract_interaction.ts +27 -15
- package/src/contract/batch_call.ts +4 -2
- package/src/contract/deploy_method.ts +123 -30
- package/src/contract/interaction_options.ts +49 -4
- package/src/contract/protocol_contracts/auth-registry.ts +545 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +433 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +493 -0
- package/src/contract/protocol_contracts/fee-juice.ts +457 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +329 -0
- package/src/contract/protocol_contracts/public-checks.ts +315 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/broadcast_function.ts +4 -4
- package/src/deployment/publish_class.ts +3 -3
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +20 -24
- package/src/fee/fee_juice_payment_method_with_claim.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +1 -1
- package/src/fee/public_fee_payment_method.ts +1 -1
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +1 -1
- package/src/utils/authwit.ts +20 -8
- package/src/utils/cross_chain.ts +1 -1
- package/src/utils/fee_juice.ts +1 -1
- package/src/utils/field_compressed_string.ts +1 -1
- package/src/utils/node.ts +62 -0
- package/src/utils/pub_key.ts +2 -2
- package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
- package/src/wallet/account_manager.ts +6 -14
- package/src/wallet/deploy_account_method.ts +38 -14
- package/src/wallet/wallet.ts +192 -93
- package/dest/account/interface.d.ts +0 -19
- package/dest/account/interface.d.ts.map +0 -1
- package/dest/account/interface.js +0 -5
- package/dest/contract/deploy_sent_tx.d.ts +0 -48
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -46
- package/dest/contract/protocol_contracts.d.ts +0 -9
- package/dest/contract/protocol_contracts.d.ts.map +0 -1
- package/dest/contract/protocol_contracts.js +0 -26
- package/dest/contract/sent_tx.d.ts +0 -51
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -90
- package/dest/contract/unsafe_contract.d.ts +0 -15
- package/dest/contract/unsafe_contract.d.ts.map +0 -1
- package/dest/contract/unsafe_contract.js +0 -6
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -75
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/sent_tx.ts +0 -130
- package/src/contract/unsafe_contract.ts +0 -19
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
2
|
-
import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
|
|
3
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
|
-
import {
|
|
5
|
-
type ContractArtifact,
|
|
6
|
-
type FunctionArtifact,
|
|
7
|
-
FunctionCall,
|
|
8
|
-
FunctionSelector,
|
|
9
|
-
encodeArguments,
|
|
10
|
-
getFunctionArtifactByName,
|
|
11
|
-
} from '@aztec/stdlib/abi';
|
|
12
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
14
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
15
6
|
|
|
7
|
+
import type { Account } from '../account/account.js';
|
|
16
8
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
17
|
-
import type { Wallet } from './index.js';
|
|
18
9
|
|
|
19
10
|
/**
|
|
20
11
|
* Fee payment method that allows an account contract to pay for its own deployment
|
|
@@ -33,11 +24,9 @@ import type { Wallet } from './index.js';
|
|
|
33
24
|
*/
|
|
34
25
|
export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
|
|
35
26
|
constructor(
|
|
36
|
-
private
|
|
37
|
-
private artifact: ContractArtifact,
|
|
38
|
-
private feePaymentNameOrArtifact: string | FunctionArtifact,
|
|
39
|
-
private accountAddress: AztecAddress,
|
|
27
|
+
private account: Account,
|
|
40
28
|
private paymentMethod?: FeePaymentMethod,
|
|
29
|
+
private feeEntrypointOptions?: any,
|
|
41
30
|
) {}
|
|
42
31
|
|
|
43
32
|
getAsset(): Promise<AztecAddress> {
|
|
@@ -45,59 +34,38 @@ export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
|
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
48
|
-
// Get the execution payload for the fee
|
|
49
|
-
|
|
50
|
-
// FeeJuice balance
|
|
51
|
-
const { calls: feeCalls, authWitnesses: feeAuthwitnesses } =
|
|
52
|
-
(await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
|
|
53
|
-
// Encode the calls for the fee
|
|
54
|
-
const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.accountAddress;
|
|
55
|
-
const isFeePayer = feePayer.equals(this.accountAddress);
|
|
56
|
-
let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
|
|
57
|
-
if (isFeePayer) {
|
|
58
|
-
// If the account is the fee payer, and the incoming fee payload has calls
|
|
59
|
-
// it can only be FeeJuicePaymentMethodWithClaim
|
|
60
|
-
// If the payload has no calls, it's paying using
|
|
61
|
-
// its own fee juice balance
|
|
62
|
-
accountFeePaymentMethodOptions =
|
|
63
|
-
feeCalls.length === 0
|
|
64
|
-
? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
|
|
65
|
-
: AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
|
|
66
|
-
}
|
|
67
|
-
const feeEncodedCalls = await EncodedAppEntrypointCalls.create(feeCalls);
|
|
37
|
+
// Get the execution payload for the fee
|
|
38
|
+
const innerPayload = (await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
|
|
68
39
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
40
|
+
// If no fee entrypoint options were provided, compute them based on the wrapped payment method
|
|
41
|
+
// This mimics how the actual account contract works when invoked directly:
|
|
42
|
+
// - If we are the fee payer, are there calls in the inner payload? In that case, those calls can
|
|
43
|
+
// only be claiming fee juice, so we use FEE_JUICE_WITH_CLAIM
|
|
44
|
+
// - If we are the fee payer, but there are no calls, then we assume the account already has
|
|
45
|
+
// fee juice and can pay directly with PREEXISTING_FEE_JUICE
|
|
46
|
+
// - If we are not the fee payer, then EXTERNAL is used
|
|
47
|
+
let options = this.feeEntrypointOptions;
|
|
48
|
+
if (!options) {
|
|
49
|
+
const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.account.getAddress();
|
|
50
|
+
const isFeePayer = feePayer.equals(this.account.getAddress());
|
|
75
51
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
encodeArguments(feePaymentArtifact, args),
|
|
84
|
-
feePaymentArtifact.returnTypes,
|
|
85
|
-
);
|
|
52
|
+
let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
|
|
53
|
+
if (isFeePayer) {
|
|
54
|
+
accountFeePaymentMethodOptions =
|
|
55
|
+
innerPayload.calls.length === 0
|
|
56
|
+
? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
|
|
57
|
+
: AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
|
|
58
|
+
}
|
|
86
59
|
|
|
87
|
-
|
|
88
|
-
|
|
60
|
+
options = { feePaymentMethodOptions: accountFeePaymentMethodOptions };
|
|
61
|
+
}
|
|
89
62
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
[payloadAuthWitness, ...feeAuthwitnesses],
|
|
93
|
-
[],
|
|
94
|
-
feeEncodedCalls.hashedArguments,
|
|
95
|
-
feePayer,
|
|
96
|
-
);
|
|
63
|
+
// Use the generic wrapping mechanism from the account interface
|
|
64
|
+
return this.account.wrapExecutionPayload(innerPayload, options);
|
|
97
65
|
}
|
|
98
66
|
|
|
99
67
|
getFeePayer(): Promise<AztecAddress> {
|
|
100
|
-
return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.
|
|
68
|
+
return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.account.getAddress());
|
|
101
69
|
}
|
|
102
70
|
|
|
103
71
|
getGasSettings(): GasSettings | undefined {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import {
|
|
3
3
|
CompleteAddress,
|
|
4
4
|
type ContractInstanceWithAddress,
|
|
@@ -9,7 +9,6 @@ import { deriveKeys } from '@aztec/stdlib/keys';
|
|
|
9
9
|
import type { AccountContract } from '../account/account_contract.js';
|
|
10
10
|
import { AccountWithSecretKey } from '../account/account_with_secret_key.js';
|
|
11
11
|
import type { Salt } from '../account/index.js';
|
|
12
|
-
import type { AccountInterface } from '../account/interface.js';
|
|
13
12
|
import { Contract } from '../contract/contract.js';
|
|
14
13
|
import { DeployAccountMethod } from './deploy_account_method.js';
|
|
15
14
|
import type { Wallet } from './wallet.js';
|
|
@@ -58,16 +57,6 @@ export class AccountManager {
|
|
|
58
57
|
return this.getPublicKeys().hash();
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
/**
|
|
62
|
-
* Returns the entrypoint for this account as defined by its account contract.
|
|
63
|
-
* @returns An entrypoint.
|
|
64
|
-
*/
|
|
65
|
-
public async getAccountInterface(): Promise<AccountInterface> {
|
|
66
|
-
const chainInfo = await this.wallet.getChainInfo();
|
|
67
|
-
const completeAddress = await this.getCompleteAddress();
|
|
68
|
-
return this.accountContract.getInterface(completeAddress, chainInfo);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
60
|
/**
|
|
72
61
|
* Gets the calculated complete address associated with this account.
|
|
73
62
|
* Does not require the account to have been published for public execution.
|
|
@@ -103,8 +92,9 @@ export class AccountManager {
|
|
|
103
92
|
* @returns A Wallet instance.
|
|
104
93
|
*/
|
|
105
94
|
public async getAccount(): Promise<AccountWithSecretKey> {
|
|
106
|
-
const
|
|
107
|
-
|
|
95
|
+
const completeAddress = await this.getCompleteAddress();
|
|
96
|
+
const account = this.accountContract.getAccount(completeAddress);
|
|
97
|
+
return new AccountWithSecretKey(account, this.secretKey, this.salt);
|
|
108
98
|
}
|
|
109
99
|
|
|
110
100
|
/**
|
|
@@ -134,12 +124,14 @@ export class AccountManager {
|
|
|
134
124
|
constructorArgs: undefined,
|
|
135
125
|
};
|
|
136
126
|
|
|
127
|
+
const account = await this.getAccount();
|
|
137
128
|
return new DeployAccountMethod(
|
|
138
129
|
this.getPublicKeys(),
|
|
139
130
|
this.wallet,
|
|
140
131
|
artifact,
|
|
141
132
|
instance => Contract.at(instance.address, artifact, this.wallet),
|
|
142
133
|
new Fr(this.salt),
|
|
134
|
+
account,
|
|
143
135
|
constructorArgs,
|
|
144
136
|
constructorName,
|
|
145
137
|
);
|
|
@@ -1,34 +1,62 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
6
6
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
7
7
|
|
|
8
|
+
import type { Account } from '../account/account.js';
|
|
8
9
|
import type { Contract } from '../contract/contract.js';
|
|
9
10
|
import type { ContractBase } from '../contract/contract_base.js';
|
|
10
11
|
import {
|
|
11
12
|
DeployMethod,
|
|
12
|
-
type
|
|
13
|
+
type DeployOptionsWithoutWait,
|
|
13
14
|
type RequestDeployOptions,
|
|
14
15
|
type SimulateDeployOptions,
|
|
15
16
|
} from '../contract/deploy_method.js';
|
|
17
|
+
import type { FeePaymentMethodOption, InteractionWaitOptions } from '../contract/interaction_options.js';
|
|
16
18
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
17
19
|
import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
|
|
18
20
|
import type { Wallet } from './index.js';
|
|
19
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Extended fee payment method option for account deployments that includes entrypoint wrapping options
|
|
24
|
+
*/
|
|
25
|
+
export type DeployAccountFeePaymentMethodOption = FeePaymentMethodOption & {
|
|
26
|
+
/** Optional entrypoint-specific options for wrapping execution payloads */
|
|
27
|
+
feeEntrypointOptions?: unknown;
|
|
28
|
+
};
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
31
|
* The configuration options for the request method. Omits the contractAddressSalt, since
|
|
22
32
|
* for account contracts that is fixed in the constructor
|
|
23
33
|
*/
|
|
24
|
-
export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt'
|
|
34
|
+
export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt' | 'fee'> & {
|
|
35
|
+
/** Fee options specific to account deployment */
|
|
36
|
+
fee?: DeployAccountFeePaymentMethodOption;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Base configuration options for the send/prove methods without wait parameter. Omits:
|
|
41
|
+
* - The contractAddressSalt, since for account contracts that is fixed in the constructor.
|
|
42
|
+
* - UniversalDeployment flag, since account contracts are always deployed with it set to true
|
|
43
|
+
*/
|
|
44
|
+
export type DeployAccountOptionsWithoutWait = Omit<DeployOptionsWithoutWait, 'contractAddressSalt' | 'universalDeploy'>;
|
|
25
45
|
|
|
26
46
|
/**
|
|
27
47
|
* The configuration options for the send/prove methods. Omits:
|
|
28
48
|
* - The contractAddressSalt, since for account contracts that is fixed in the constructor.
|
|
29
49
|
* - UniversalDeployment flag, since account contracts are always deployed with it set to true
|
|
30
50
|
*/
|
|
31
|
-
export type DeployAccountOptions =
|
|
51
|
+
export type DeployAccountOptions<W extends InteractionWaitOptions = undefined> = DeployAccountOptionsWithoutWait & {
|
|
52
|
+
/**
|
|
53
|
+
* Whether to wait for the transaction to be mined.
|
|
54
|
+
* - undefined (default): wait with default options and return TxReceipt
|
|
55
|
+
* - WaitOpts object: wait with custom options and return TxReceipt
|
|
56
|
+
* - false: return txHash immediately without waiting
|
|
57
|
+
*/
|
|
58
|
+
wait?: W;
|
|
59
|
+
};
|
|
32
60
|
|
|
33
61
|
/**
|
|
34
62
|
* The configuration options for the simulate method. Omits the contractAddressSalt, since
|
|
@@ -47,6 +75,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
47
75
|
artifact: ContractArtifact,
|
|
48
76
|
postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
49
77
|
private salt: Fr,
|
|
78
|
+
private account: Account,
|
|
50
79
|
args: any[] = [],
|
|
51
80
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
52
81
|
) {
|
|
@@ -61,19 +90,14 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
61
90
|
* For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
|
|
62
91
|
*
|
|
63
92
|
* @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
|
|
93
|
+
* @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
|
|
64
94
|
* @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
|
|
65
95
|
*/
|
|
66
|
-
private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod) {
|
|
96
|
+
private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod, feeEntrypointOptions?: any) {
|
|
67
97
|
if (!this.address) {
|
|
68
98
|
throw new Error('Instance is not yet constructed. This is a bug!');
|
|
69
99
|
}
|
|
70
|
-
return new AccountEntrypointMetaPaymentMethod(
|
|
71
|
-
this.wallet,
|
|
72
|
-
this.artifact,
|
|
73
|
-
'entrypoint',
|
|
74
|
-
this.address,
|
|
75
|
-
originalPaymentMethod,
|
|
76
|
-
);
|
|
100
|
+
return new AccountEntrypointMetaPaymentMethod(this.account, originalPaymentMethod, feeEntrypointOptions);
|
|
77
101
|
}
|
|
78
102
|
|
|
79
103
|
/**
|
|
@@ -97,7 +121,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
97
121
|
const executionPayloads = [deploymentExecutionPayload];
|
|
98
122
|
// If this is a self-deployment, manage the fee accordingly
|
|
99
123
|
if (opts?.deployer?.equals(AztecAddress.ZERO)) {
|
|
100
|
-
const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod);
|
|
124
|
+
const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod, opts?.fee?.feeEntrypointOptions);
|
|
101
125
|
const feeExecutionPayload = await feePaymentMethod.getExecutionPayload();
|
|
102
126
|
// Notice they are reversed (fee payment usually goes first):
|
|
103
127
|
// this is because we need to construct the contract BEFORE it can pay for its own fee
|
|
@@ -113,7 +137,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
113
137
|
return mergeExecutionPayloads(executionPayloads);
|
|
114
138
|
}
|
|
115
139
|
|
|
116
|
-
override convertDeployOptionsToRequestOptions(options:
|
|
140
|
+
override convertDeployOptionsToRequestOptions(options: DeployAccountOptionsWithoutWait): RequestDeployOptions {
|
|
117
141
|
return {
|
|
118
142
|
...options,
|
|
119
143
|
// Deployer is handled in the request method and forcibly set to undefined,
|