@aztec/aztec.js 0.0.1-commit.b655e406 → 0.0.1-commit.c0b82b2
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 +26 -42
- 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 +20 -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 +7 -9
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/abi.d.ts +1 -1
- package/dest/api/account.d.ts +3 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +2 -3
- package/dest/api/addresses.d.ts +1 -1
- 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/block.d.ts +1 -1
- package/dest/api/contract.d.ts +19 -13
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +17 -11
- package/dest/api/crypto.d.ts +1 -1
- package/dest/api/deployment.d.ts +1 -2
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +0 -1
- package/dest/api/eth_address.d.ts +1 -1
- package/dest/api/ethereum.d.ts +1 -1
- package/dest/api/events.d.ts +10 -6
- package/dest/api/events.d.ts.map +1 -1
- package/dest/api/events.js +30 -20
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee_testing.d.ts +1 -1
- package/dest/api/fields.d.ts +4 -2
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +3 -1
- package/dest/api/keys.d.ts +2 -2
- package/dest/api/keys.js +1 -1
- package/dest/api/log.d.ts +1 -1
- package/dest/api/messaging.d.ts +1 -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/note.d.ts +2 -2
- package/dest/api/note.d.ts.map +1 -1
- package/dest/api/note.js +1 -1
- 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/trees.d.ts +1 -1
- 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/utils.d.ts +1 -1
- package/dest/api/wallet.d.ts +3 -3
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -2
- package/dest/authorization/call_authorization_request.d.ts +2 -2
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -11
- 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 +8 -9
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +59 -36
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/contract.d.ts +2 -2
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +4 -5
- package/dest/contract/contract_base.d.ts +6 -10
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +5 -12
- package/dest/contract/contract_function_interaction.d.ts +5 -14
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +18 -12
- package/dest/contract/deploy_method.d.ts +85 -24
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +71 -36
- package/dest/contract/get_gas_limits.d.ts +1 -1
- package/dest/contract/get_gas_limits.js +3 -3
- package/dest/contract/interaction_options.d.ts +51 -7
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +12 -11
- 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 +1005 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +15 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +139 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +434 -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 +601 -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 +609 -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/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +1 -1
- package/dest/deployment/publish_class.d.ts +1 -1
- 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 +7 -6
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +48 -22
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +9 -9
- package/dest/fee/fee_payment_method.d.ts +2 -2
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +2 -2
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +14 -14
- package/dest/fee/public_fee_payment_method.d.ts +2 -2
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +14 -14
- package/dest/fee/sponsored_fee_payment.d.ts +2 -2
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +5 -5
- 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 +14 -12
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +27 -20
- package/dest/utils/cross_chain.d.ts +2 -2
- package/dest/utils/cross_chain.d.ts.map +1 -1
- package/dest/utils/fee_juice.d.ts +2 -2
- package/dest/utils/fee_juice.js +2 -2
- package/dest/utils/field_compressed_string.d.ts +1 -1
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/field_compressed_string.js +1 -1
- package/dest/utils/node.d.ts +13 -2
- 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 +6 -9
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +29 -44
- package/dest/wallet/account_manager.d.ts +3 -9
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +6 -12
- package/dest/wallet/capabilities.d.ts +452 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +49 -10
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +35 -7
- package/dest/wallet/index.d.ts +2 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -1
- package/dest/wallet/wallet.d.ts +1853 -1533
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +223 -124
- package/package.json +27 -15
- package/src/account/account.ts +35 -60
- 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 +15 -15
- package/src/api/account.ts +10 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +26 -10
- package/src/api/deployment.ts +0 -1
- package/src/api/events.ts +35 -27
- package/src/api/fields.ts +3 -1
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/note.ts +1 -1
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +4 -0
- package/src/api/wallet.ts +52 -9
- package/src/authorization/call_authorization_request.ts +1 -1
- package/src/contract/base_contract_interaction.ts +27 -16
- package/src/contract/batch_call.ts +62 -48
- package/src/contract/contract.ts +7 -5
- package/src/contract/contract_base.ts +5 -15
- package/src/contract/contract_function_interaction.ts +26 -17
- package/src/contract/deploy_method.ts +175 -47
- package/src/contract/get_gas_limits.ts +3 -3
- package/src/contract/interaction_options.ts +59 -13
- package/src/contract/protocol_contracts/auth-registry.ts +553 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +99 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
- package/src/contract/protocol_contracts/fee-juice.ts +266 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +336 -0
- package/src/contract/protocol_contracts/public-checks.ts +320 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/contract_deployer.ts +3 -2
- package/src/deployment/publish_class.ts +3 -3
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +65 -34
- package/src/fee/fee_juice_payment_method_with_claim.ts +9 -7
- package/src/fee/fee_payment_method.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +12 -10
- package/src/fee/public_fee_payment_method.ts +13 -11
- package/src/fee/sponsored_fee_payment.ts +6 -4
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +1 -1
- package/src/utils/authwit.ts +40 -22
- package/src/utils/cross_chain.ts +1 -1
- package/src/utils/fee_juice.ts +2 -2
- 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 +29 -60
- package/src/wallet/account_manager.ts +7 -15
- package/src/wallet/capabilities.ts +500 -0
- package/src/wallet/deploy_account_method.ts +78 -16
- package/src/wallet/index.ts +1 -1
- package/src/wallet/wallet.ts +387 -166
- 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 -43
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -40
- 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/dest/deployment/broadcast_function.d.ts +0 -24
- package/dest/deployment/broadcast_function.d.ts.map +0 -1
- package/dest/deployment/broadcast_function.js +0 -74
- package/dest/wallet/base_wallet.d.ts +0 -91
- package/dest/wallet/base_wallet.d.ts.map +0 -1
- package/dest/wallet/base_wallet.js +0 -238
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -68
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/sent_tx.ts +0 -130
- package/src/contract/unsafe_contract.ts +0 -19
- package/src/deployment/broadcast_function.ts +0 -148
- package/src/wallet/base_wallet.ts +0 -350
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import { type ContractArtifact, type FunctionAbi, type FunctionArtifact, getInitializer } from '@aztec/stdlib/abi';
|
|
4
3
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -10,27 +9,53 @@ import {
|
|
|
10
9
|
getContractInstanceFromInstantiationParams,
|
|
11
10
|
} from '@aztec/stdlib/contract';
|
|
12
11
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
13
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
type Capsule,
|
|
14
|
+
HashedValues,
|
|
15
|
+
TxHash,
|
|
16
|
+
type TxProfileResult,
|
|
17
|
+
type TxReceipt,
|
|
18
|
+
collectOffchainEffects,
|
|
19
|
+
} from '@aztec/stdlib/tx';
|
|
20
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
14
21
|
|
|
15
22
|
import { publishContractClass } from '../deployment/publish_class.js';
|
|
16
23
|
import { publishInstance } from '../deployment/publish_instance.js';
|
|
17
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
24
|
+
import type { ProfileOptions, SendOptions, SimulateOptions, Wallet } from '../wallet/wallet.js';
|
|
18
25
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
19
|
-
import type { Contract } from './contract.js';
|
|
20
26
|
import type { ContractBase } from './contract_base.js';
|
|
21
27
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
22
|
-
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
23
28
|
import { getGasLimits } from './get_gas_limits.js';
|
|
24
29
|
import {
|
|
30
|
+
NO_WAIT,
|
|
31
|
+
type NoWait,
|
|
25
32
|
type ProfileInteractionOptions,
|
|
26
33
|
type RequestInteractionOptions,
|
|
27
|
-
type
|
|
34
|
+
type SendInteractionOptionsWithoutWait,
|
|
28
35
|
type SimulationInteractionFeeOptions,
|
|
29
36
|
type SimulationReturn,
|
|
30
37
|
toProfileOptions,
|
|
31
38
|
toSendOptions,
|
|
32
39
|
toSimulateOptions,
|
|
33
40
|
} from './interaction_options.js';
|
|
41
|
+
import type { WaitOpts } from './wait_opts.js';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Wait options specific to deployment transactions.
|
|
45
|
+
* Extends WaitOpts with a flag to return the full receipt instead of just the contract.
|
|
46
|
+
*/
|
|
47
|
+
export type DeployWaitOptions = WaitOpts & {
|
|
48
|
+
/** If true, return the full DeployTxReceipt instead of just the contract. Defaults to false. */
|
|
49
|
+
returnReceipt?: boolean;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Type for wait options in deployment interactions.
|
|
54
|
+
* - NO_WAIT symbol: Don't wait, return TxHash immediately
|
|
55
|
+
* - DeployWaitOptions: Wait with custom options
|
|
56
|
+
* - undefined: Wait with default options
|
|
57
|
+
*/
|
|
58
|
+
export type DeployInteractionWaitOptions = NoWait | DeployWaitOptions | undefined;
|
|
34
59
|
|
|
35
60
|
/**
|
|
36
61
|
* Options for deploying a contract on the Aztec network.
|
|
@@ -51,26 +76,39 @@ export type RequestDeployOptions = RequestInteractionOptions & {
|
|
|
51
76
|
skipInstancePublication?: boolean;
|
|
52
77
|
/** Skip contract initialization. */
|
|
53
78
|
skipInitialization?: boolean;
|
|
79
|
+
/** Skip contract registration in the wallet */
|
|
80
|
+
skipRegistration?: boolean;
|
|
54
81
|
};
|
|
55
82
|
|
|
56
83
|
/**
|
|
57
|
-
*
|
|
84
|
+
* Base deployment options without wait parameter.
|
|
58
85
|
*/
|
|
59
|
-
export type
|
|
86
|
+
export type DeployOptionsWithoutWait = Omit<RequestDeployOptions, 'deployer'> & {
|
|
60
87
|
/**
|
|
61
88
|
* Set to true to *not* include the sender in the address computation. This option
|
|
62
89
|
* is mutually exclusive with "deployer"
|
|
63
90
|
*/
|
|
64
91
|
universalDeploy?: boolean;
|
|
65
|
-
} & Pick<
|
|
66
|
-
|
|
67
|
-
|
|
92
|
+
} & Pick<SendInteractionOptionsWithoutWait, 'from' | 'fee' | 'additionalScopes'>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Extends the deployment options with the required parameters to send the transaction.
|
|
96
|
+
*/
|
|
97
|
+
export type DeployOptions<W extends DeployInteractionWaitOptions = undefined> = DeployOptionsWithoutWait & {
|
|
98
|
+
/**
|
|
99
|
+
* Options for waiting for the transaction to be mined.
|
|
100
|
+
* - undefined (default): wait with default options and return the contract instance
|
|
101
|
+
* - DeployWaitOptions: wait with custom options and return contract or receipt based on returnReceipt flag
|
|
102
|
+
* - NO_WAIT: return TxHash immediately without waiting
|
|
103
|
+
*/
|
|
104
|
+
wait?: W;
|
|
105
|
+
};
|
|
68
106
|
|
|
69
107
|
/**
|
|
70
108
|
* Options for simulating the deployment of a contract
|
|
71
109
|
* Allows skipping certain validations and computing gas estimations
|
|
72
110
|
*/
|
|
73
|
-
export type SimulateDeployOptions = Omit<
|
|
111
|
+
export type SimulateDeployOptions = Omit<DeployOptionsWithoutWait, 'fee'> & {
|
|
74
112
|
/** The fee options for the transaction. */
|
|
75
113
|
fee?: SimulationInteractionFeeOptions;
|
|
76
114
|
/** Simulate without checking for the validity of the resulting transaction,
|
|
@@ -84,6 +122,29 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
84
122
|
includeMetadata?: boolean;
|
|
85
123
|
};
|
|
86
124
|
|
|
125
|
+
/** Receipt for a deployment transaction with the deployed contract instance. */
|
|
126
|
+
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = TxReceipt & {
|
|
127
|
+
/** Type-safe wrapper around the deployed contract instance, linked to the deployment wallet */
|
|
128
|
+
contract: TContract;
|
|
129
|
+
/** The deployed contract instance with address and metadata. */
|
|
130
|
+
instance: ContractInstanceWithAddress;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Represents the result type of deploying a contract.
|
|
135
|
+
* - If wait is NO_WAIT, returns TxHash immediately.
|
|
136
|
+
* - If wait has returnReceipt: true, returns DeployTxReceipt after waiting.
|
|
137
|
+
* - Otherwise (undefined or DeployWaitOptions without returnReceipt), returns TContract after waiting.
|
|
138
|
+
*/
|
|
139
|
+
export type DeployReturn<TContract extends ContractBase, W extends DeployInteractionWaitOptions> = W extends NoWait
|
|
140
|
+
? TxHash
|
|
141
|
+
: W extends {
|
|
142
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
143
|
+
returnReceipt: true;
|
|
144
|
+
}
|
|
145
|
+
? DeployTxReceipt<TContract>
|
|
146
|
+
: TContract;
|
|
147
|
+
|
|
87
148
|
/**
|
|
88
149
|
* Contract interaction for deployment.
|
|
89
150
|
* Handles class publication, instance publication, and initialization of the contract.
|
|
@@ -93,10 +154,8 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
93
154
|
* then technically the contract has already been "created", and all of the contract's
|
|
94
155
|
* functions (private and utility) can be interacted-with immediately, without any
|
|
95
156
|
* "deployment tx".
|
|
96
|
-
*
|
|
97
|
-
* Extends the BaseContractInteraction class.
|
|
98
157
|
*/
|
|
99
|
-
export class DeployMethod<TContract extends ContractBase =
|
|
158
|
+
export class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
|
|
100
159
|
/** The contract instance to be deployed. */
|
|
101
160
|
private instance?: ContractInstanceWithAddress = undefined;
|
|
102
161
|
|
|
@@ -107,11 +166,12 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
107
166
|
private publicKeys: PublicKeys,
|
|
108
167
|
wallet: Wallet,
|
|
109
168
|
protected artifact: ContractArtifact,
|
|
110
|
-
protected postDeployCtor: (
|
|
169
|
+
protected postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
111
170
|
private args: any[] = [],
|
|
112
171
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
113
172
|
authWitnesses: AuthWitness[] = [],
|
|
114
173
|
capsules: Capsule[] = [],
|
|
174
|
+
private extraHashedArgs: HashedValues[] = [],
|
|
115
175
|
) {
|
|
116
176
|
super(wallet, authWitnesses, capsules);
|
|
117
177
|
this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact);
|
|
@@ -122,18 +182,29 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
122
182
|
* @param options - Configuration options.
|
|
123
183
|
* @returns The execution payload for this operation
|
|
124
184
|
*/
|
|
125
|
-
public async request(options
|
|
185
|
+
public async request(options: RequestDeployOptions = {}): Promise<ExecutionPayload> {
|
|
126
186
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
127
187
|
|
|
128
|
-
|
|
188
|
+
if (!options?.skipRegistration) {
|
|
189
|
+
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
190
|
+
}
|
|
191
|
+
const { authWitnesses, capsules } = options;
|
|
129
192
|
|
|
193
|
+
// Propagates the included authwitnesses, capsules, and extraHashedArgs
|
|
194
|
+
// potentially baked into the interaction
|
|
195
|
+
const initialExecutionPayload = new ExecutionPayload(
|
|
196
|
+
[],
|
|
197
|
+
this.authWitnesses.concat(authWitnesses ?? []),
|
|
198
|
+
this.capsules.concat(capsules ?? []),
|
|
199
|
+
this.extraHashedArgs,
|
|
200
|
+
);
|
|
130
201
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
131
202
|
const feeExecutionPayload = options?.fee?.paymentMethod
|
|
132
203
|
? await options.fee.paymentMethod.getExecutionPayload()
|
|
133
204
|
: undefined;
|
|
134
205
|
const finalExecutionPayload = feeExecutionPayload
|
|
135
|
-
? mergeExecutionPayloads([feeExecutionPayload, publication, initialization])
|
|
136
|
-
: mergeExecutionPayloads([publication, initialization]);
|
|
206
|
+
? mergeExecutionPayloads([initialExecutionPayload, feeExecutionPayload, publication, initialization])
|
|
207
|
+
: mergeExecutionPayloads([initialExecutionPayload, publication, initialization]);
|
|
137
208
|
if (!finalExecutionPayload.calls.length) {
|
|
138
209
|
throw new Error(`No transactions are needed to publish or initialize contract ${this.artifact.name}`);
|
|
139
210
|
}
|
|
@@ -141,13 +212,48 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
141
212
|
return finalExecutionPayload;
|
|
142
213
|
}
|
|
143
214
|
|
|
144
|
-
convertDeployOptionsToRequestOptions(options:
|
|
215
|
+
convertDeployOptionsToRequestOptions(options: DeployOptionsWithoutWait): RequestDeployOptions {
|
|
145
216
|
return {
|
|
146
217
|
...options,
|
|
147
218
|
deployer: !options?.universalDeploy ? options.from : undefined,
|
|
148
219
|
};
|
|
149
220
|
}
|
|
150
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Converts DeployOptions to SendOptions, stripping out the returnReceipt flag if present.
|
|
224
|
+
* @param options - Deploy options with wait parameter
|
|
225
|
+
* @returns Send options with wait parameter
|
|
226
|
+
*/
|
|
227
|
+
protected convertDeployOptionsToSendOptions<W extends DeployInteractionWaitOptions>(
|
|
228
|
+
options: DeployOptions<W>,
|
|
229
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
230
|
+
): SendOptions<W extends { returnReceipt: true } ? WaitOpts : W> {
|
|
231
|
+
return {
|
|
232
|
+
...toSendOptions({
|
|
233
|
+
...options,
|
|
234
|
+
wait: options.wait as any,
|
|
235
|
+
}),
|
|
236
|
+
} as any;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Converts deploy simulation options into wallet-level simulate options.
|
|
241
|
+
* @param options - The deploy simulation options to convert.
|
|
242
|
+
*/
|
|
243
|
+
protected convertDeployOptionsToSimulateOptions(options: SimulateDeployOptions): SimulateOptions {
|
|
244
|
+
return toSimulateOptions(options);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Converts deploy profile options into wallet-level profile options.
|
|
249
|
+
* @param options - The deploy profile options to convert.
|
|
250
|
+
*/
|
|
251
|
+
protected convertDeployOptionsToProfileOptions(
|
|
252
|
+
options: DeployOptionsWithoutWait & ProfileInteractionOptions,
|
|
253
|
+
): ProfileOptions {
|
|
254
|
+
return toProfileOptions(options);
|
|
255
|
+
}
|
|
256
|
+
|
|
151
257
|
/**
|
|
152
258
|
* Adds this contract to the wallet and returns the Contract object.
|
|
153
259
|
* @param options - Deployment options.
|
|
@@ -155,7 +261,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
155
261
|
public async register(options?: RequestDeployOptions): Promise<TContract> {
|
|
156
262
|
const instance = await this.getInstance(options);
|
|
157
263
|
await this.wallet.registerContract(instance, this.artifact);
|
|
158
|
-
return this.postDeployCtor(instance
|
|
264
|
+
return this.postDeployCtor(instance, this.wallet);
|
|
159
265
|
}
|
|
160
266
|
|
|
161
267
|
/**
|
|
@@ -183,16 +289,17 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
183
289
|
|
|
184
290
|
// Publish the contract class if it hasn't been published already.
|
|
185
291
|
if (!options?.skipClassPublication) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`,
|
|
189
|
-
);
|
|
190
|
-
} else {
|
|
292
|
+
const classMetadata = await this.wallet.getContractClassMetadata(contractClass.id);
|
|
293
|
+
if (!classMetadata.isContractClassPubliclyRegistered) {
|
|
191
294
|
this.log.info(
|
|
192
295
|
`Creating request for publishing contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`,
|
|
193
296
|
);
|
|
194
297
|
const registerContractClassInteraction = await publishContractClass(this.wallet, this.artifact);
|
|
195
298
|
calls.push(await registerContractClassInteraction.request());
|
|
299
|
+
} else {
|
|
300
|
+
this.log.debug(
|
|
301
|
+
`Skipping contract class publication for ${contractClass.id.toString()} as it is already registered`,
|
|
302
|
+
);
|
|
196
303
|
}
|
|
197
304
|
}
|
|
198
305
|
|
|
@@ -201,7 +308,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
201
308
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
|
|
202
309
|
// Read the artifact, and if there are no public functions, warn the caller that publication of the
|
|
203
310
|
// contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
|
|
204
|
-
const deploymentInteraction =
|
|
311
|
+
const deploymentInteraction = publishInstance(this.wallet, instance);
|
|
205
312
|
calls.push(await deploymentInteraction.request());
|
|
206
313
|
}
|
|
207
314
|
|
|
@@ -230,20 +337,42 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
230
337
|
|
|
231
338
|
/**
|
|
232
339
|
* Send a contract deployment transaction (initialize and/or publish) using the provided options.
|
|
233
|
-
*
|
|
234
|
-
* allowing us to send a transaction specifically for contract deployment.
|
|
340
|
+
* By default, waits for the transaction to be mined and returns the deployed contract instance.
|
|
235
341
|
*
|
|
236
342
|
* @param options - An object containing various deployment options such as contractAddressSalt and from.
|
|
237
|
-
* @returns
|
|
343
|
+
* @returns TxHash (if wait is NO_WAIT), TContract (if wait is undefined or doesn't have returnReceipt), or DeployTxReceipt (if wait.returnReceipt is true)
|
|
238
344
|
*/
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
345
|
+
// Overload for when wait is not specified at all - returns the contract
|
|
346
|
+
public override send(options: DeployOptionsWithoutWait): Promise<TContract>;
|
|
347
|
+
// Generic overload for explicit wait values
|
|
348
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
349
|
+
public override send<W extends DeployInteractionWaitOptions>(
|
|
350
|
+
options: DeployOptions<W>,
|
|
351
|
+
): Promise<DeployReturn<TContract, W>>;
|
|
352
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
353
|
+
public override async send(options: DeployOptions<DeployInteractionWaitOptions>): Promise<any> {
|
|
354
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
355
|
+
const sendOptions = this.convertDeployOptionsToSendOptions(options);
|
|
356
|
+
|
|
357
|
+
if (options.wait === NO_WAIT) {
|
|
358
|
+
const txHash = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<NoWait>);
|
|
359
|
+
this.log.debug(`Sent deployment tx ${txHash.hash} of ${this.artifact.name} contract`);
|
|
360
|
+
return txHash;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const receipt = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<WaitOpts | undefined>);
|
|
364
|
+
this.log.debug(`Deployed ${this.artifact.name} contract in tx ${receipt.txHash}`);
|
|
365
|
+
|
|
366
|
+
// Attach contract instance
|
|
367
|
+
const instance = await this.getInstance(options);
|
|
368
|
+
const contract = this.postDeployCtor(instance, this.wallet) as TContract;
|
|
369
|
+
|
|
370
|
+
// Return full receipt if requested, otherwise just the contract
|
|
371
|
+
if (options.wait && typeof options.wait === 'object' && options.wait.returnReceipt) {
|
|
372
|
+
return { ...receipt, contract, instance };
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return contract;
|
|
247
376
|
}
|
|
248
377
|
|
|
249
378
|
/**
|
|
@@ -274,7 +403,10 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
274
403
|
*/
|
|
275
404
|
public async simulate(options: SimulateDeployOptions): Promise<SimulationReturn<true>> {
|
|
276
405
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
277
|
-
const simulatedTx = await this.wallet.simulateTx(
|
|
406
|
+
const simulatedTx = await this.wallet.simulateTx(
|
|
407
|
+
executionPayload,
|
|
408
|
+
this.convertDeployOptionsToSimulateOptions(options),
|
|
409
|
+
);
|
|
278
410
|
|
|
279
411
|
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
280
412
|
this.log.verbose(
|
|
@@ -294,13 +426,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
294
426
|
*
|
|
295
427
|
* @returns An object containing the function return value and profile result.
|
|
296
428
|
*/
|
|
297
|
-
public async profile(options:
|
|
429
|
+
public async profile(options: DeployOptionsWithoutWait & ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
298
430
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
299
|
-
return await this.wallet.profileTx(executionPayload,
|
|
300
|
-
...(await toProfileOptions(options)),
|
|
301
|
-
profileMode: options.profileMode,
|
|
302
|
-
skipProofGeneration: options.skipProofGeneration,
|
|
303
|
-
});
|
|
431
|
+
return await this.wallet.profileTx(executionPayload, this.convertDeployOptionsToProfileOptions(options));
|
|
304
432
|
}
|
|
305
433
|
|
|
306
434
|
/** Return this deployment address. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
2
|
import { Gas } from '@aztec/stdlib/gas';
|
|
3
3
|
import type { TxSimulationResult } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
@@ -23,8 +23,8 @@ export function getGasLimits(
|
|
|
23
23
|
const gasLimits = simulationResult.gasUsed.totalGas.mul(1 + pad);
|
|
24
24
|
const teardownGasLimits = simulationResult.gasUsed.teardownGas.mul(1 + pad);
|
|
25
25
|
|
|
26
|
-
if (gasLimits.l2Gas >
|
|
27
|
-
throw new Error('Transaction consumes more gas than the
|
|
26
|
+
if (gasLimits.l2Gas > MAX_PROCESSABLE_L2_GAS) {
|
|
27
|
+
throw new Error('Transaction consumes more l2 gas than the maximum processable gas');
|
|
28
28
|
}
|
|
29
29
|
return {
|
|
30
30
|
gasLimits,
|
|
@@ -2,10 +2,11 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
2
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
-
import type { Capsule, OffchainEffect, SimulationStats } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { Capsule, OffchainEffect, SimulationStats, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
8
8
|
import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
|
|
9
|
+
import type { WaitOpts } from './wait_opts.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Options used to tweak the simulation and add gas estimation capabilities
|
|
@@ -55,13 +56,52 @@ export type RequestInteractionOptions = {
|
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
|
-
*
|
|
59
|
+
* Constant for explicitly not waiting for transaction confirmation.
|
|
60
|
+
* We use this instead of false to avoid confusion with falsy checks.
|
|
61
|
+
*/
|
|
62
|
+
export const NO_WAIT = 'NO_WAIT' as const;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Type for the NO_WAIT constant.
|
|
66
|
+
*/
|
|
67
|
+
export type NoWait = typeof NO_WAIT;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Type for wait options in interactions.
|
|
71
|
+
* - NO_WAIT symbol: Don't wait for confirmation, return TxHash immediately
|
|
72
|
+
* - WaitOpts object: Wait with custom options and return receipt/result
|
|
73
|
+
* - undefined: Wait with default options and return receipt/result
|
|
74
|
+
*/
|
|
75
|
+
export type InteractionWaitOptions = NoWait | WaitOpts | undefined;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Base options for calling a (constrained) function in a contract, without wait parameter.
|
|
59
79
|
*/
|
|
60
|
-
export type
|
|
80
|
+
export type SendInteractionOptionsWithoutWait = RequestInteractionOptions & {
|
|
61
81
|
/** The sender's Aztec address. */
|
|
62
82
|
from: AztecAddress;
|
|
63
83
|
/** The fee options for the transaction. */
|
|
64
84
|
fee?: InteractionFeeOptions;
|
|
85
|
+
/**
|
|
86
|
+
* Additional addresses whose private state and keys should be accessible during execution,
|
|
87
|
+
* beyond the sender's. Required when the transaction needs to access private state or keys
|
|
88
|
+
* belonging to an address other than `from`, e.g. withdrawing from an escrow that holds
|
|
89
|
+
* its own private notes.
|
|
90
|
+
*/
|
|
91
|
+
additionalScopes?: AztecAddress[];
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Represents options for calling a (constrained) function in a contract.
|
|
96
|
+
*/
|
|
97
|
+
export type SendInteractionOptions<W extends InteractionWaitOptions = undefined> = SendInteractionOptionsWithoutWait & {
|
|
98
|
+
/**
|
|
99
|
+
* Whether to wait for the transaction to be mined.
|
|
100
|
+
* - undefined (default): wait with default options and return TxReceipt
|
|
101
|
+
* - WaitOpts object: wait with custom options and return TxReceipt
|
|
102
|
+
* - NO_WAIT: return txHash immediately without waiting
|
|
103
|
+
*/
|
|
104
|
+
wait?: W;
|
|
65
105
|
};
|
|
66
106
|
|
|
67
107
|
/**
|
|
@@ -110,17 +150,25 @@ export type SimulationReturn<T extends boolean | undefined> = T extends true
|
|
|
110
150
|
}
|
|
111
151
|
: any;
|
|
112
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Represents the result type of sending a transaction.
|
|
155
|
+
* If `wait` is NO_WAIT, returns TxHash immediately without waiting.
|
|
156
|
+
* If `wait` is undefined or WaitOpts, returns TReturn (defaults to TxReceipt) after waiting.
|
|
157
|
+
*/
|
|
158
|
+
export type SendReturn<T extends InteractionWaitOptions, TReturn = TxReceipt> = T extends NoWait ? TxHash : TReturn;
|
|
159
|
+
|
|
113
160
|
/**
|
|
114
161
|
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|
|
115
162
|
* SendOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
163
|
+
* @param options - The send interaction options with optional wait parameter
|
|
164
|
+
* @returns The send options to forward to the wallet
|
|
116
165
|
*/
|
|
117
|
-
export
|
|
166
|
+
export function toSendOptions<W extends InteractionWaitOptions = undefined>(
|
|
167
|
+
options: SendInteractionOptions<W>,
|
|
168
|
+
): SendOptions<W> {
|
|
118
169
|
return {
|
|
119
170
|
...options,
|
|
120
171
|
fee: {
|
|
121
|
-
// If this interaction includes a fee payment method, pass the fee payer
|
|
122
|
-
// as a hint to the wallet
|
|
123
|
-
embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
|
|
124
172
|
// If a payment method that includes gas settings was used,
|
|
125
173
|
// try to reuse as much as possible while still allowing
|
|
126
174
|
// manual override. CAREFUL: this can cause mismatches during proving
|
|
@@ -129,6 +177,7 @@ export async function toSendOptions(options: SendInteractionOptions): Promise<Se
|
|
|
129
177
|
...options.fee?.gasSettings,
|
|
130
178
|
},
|
|
131
179
|
},
|
|
180
|
+
wait: options.wait, // Pass through wait option
|
|
132
181
|
};
|
|
133
182
|
}
|
|
134
183
|
|
|
@@ -136,13 +185,10 @@ export async function toSendOptions(options: SendInteractionOptions): Promise<Se
|
|
|
136
185
|
* Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
|
|
137
186
|
* SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
138
187
|
*/
|
|
139
|
-
export
|
|
188
|
+
export function toSimulateOptions(options: SimulateInteractionOptions): SimulateOptions {
|
|
140
189
|
return {
|
|
141
190
|
...options,
|
|
142
191
|
fee: {
|
|
143
|
-
// If this interaction includes a fee payment method, pass the fee payer
|
|
144
|
-
// as a hint to the wallet
|
|
145
|
-
embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
|
|
146
192
|
// If a payment method that includes gas settings was used,
|
|
147
193
|
// try to reuse as much as possible while still allowing
|
|
148
194
|
// manual override. CAREFUL: this can cause mismatches during proving
|
|
@@ -160,9 +206,9 @@ export async function toSimulateOptions(options: SimulateInteractionOptions): Pr
|
|
|
160
206
|
* Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
|
|
161
207
|
* ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
162
208
|
*/
|
|
163
|
-
export
|
|
209
|
+
export function toProfileOptions(options: ProfileInteractionOptions): ProfileOptions {
|
|
164
210
|
return {
|
|
165
|
-
...
|
|
211
|
+
...toSimulateOptions(options),
|
|
166
212
|
profileMode: options.profileMode,
|
|
167
213
|
skipProofGeneration: options.skipProofGeneration,
|
|
168
214
|
};
|