@aztec/aztec.js 0.0.0-test.0
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/README.md +44 -0
- package/dest/account/contract.d.ts +37 -0
- package/dest/account/contract.d.ts.map +1 -0
- package/dest/account/contract.js +16 -0
- package/dest/account/index.d.ts +15 -0
- package/dest/account/index.d.ts.map +1 -0
- package/dest/account/index.js +9 -0
- package/dest/account/interface.d.ts +31 -0
- package/dest/account/interface.d.ts.map +1 -0
- package/dest/account/interface.js +4 -0
- package/dest/account/wallet.d.ts +11 -0
- package/dest/account/wallet.d.ts.map +1 -0
- package/dest/account/wallet.js +3 -0
- package/dest/account_manager/deploy_account_method.d.ts +15 -0
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -0
- package/dest/account_manager/deploy_account_method.js +43 -0
- package/dest/account_manager/deploy_account_sent_tx.d.ts +30 -0
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -0
- package/dest/account_manager/deploy_account_sent_tx.js +29 -0
- package/dest/account_manager/index.d.ts +108 -0
- package/dest/account_manager/index.d.ts.map +1 -0
- package/dest/account_manager/index.js +159 -0
- package/dest/api/abi.d.ts +3 -0
- package/dest/api/abi.d.ts.map +1 -0
- package/dest/api/abi.js +1 -0
- package/dest/api/account.d.ts +3 -0
- package/dest/api/account.d.ts.map +1 -0
- package/dest/api/account.js +2 -0
- package/dest/api/addresses.d.ts +3 -0
- package/dest/api/addresses.d.ts.map +1 -0
- package/dest/api/addresses.js +2 -0
- package/dest/api/cheat_codes.d.ts +26 -0
- package/dest/api/cheat_codes.d.ts.map +1 -0
- package/dest/api/cheat_codes.js +25 -0
- package/dest/api/deployment.d.ts +4 -0
- package/dest/api/deployment.d.ts.map +1 -0
- package/dest/api/deployment.js +3 -0
- package/dest/api/entrypoint.d.ts +2 -0
- package/dest/api/entrypoint.d.ts.map +1 -0
- package/dest/api/entrypoint.js +1 -0
- package/dest/api/eth_address.d.ts +2 -0
- package/dest/api/eth_address.d.ts.map +1 -0
- package/dest/api/eth_address.js +1 -0
- package/dest/api/ethereum/anvil_test_watcher.d.ts +32 -0
- package/dest/api/ethereum/anvil_test_watcher.d.ts.map +1 -0
- package/dest/api/ethereum/anvil_test_watcher.js +133 -0
- package/dest/api/ethereum/chain_monitor.d.ts +25 -0
- package/dest/api/ethereum/chain_monitor.d.ts.map +1 -0
- package/dest/api/ethereum/chain_monitor.js +74 -0
- package/dest/api/ethereum/cheat_codes.d.ts +63 -0
- package/dest/api/ethereum/cheat_codes.d.ts.map +1 -0
- package/dest/api/ethereum/cheat_codes.js +162 -0
- package/dest/api/ethereum/index.d.ts +7 -0
- package/dest/api/ethereum/index.d.ts.map +1 -0
- package/dest/api/ethereum/index.js +6 -0
- package/dest/api/ethereum/l1_contracts.d.ts +3 -0
- package/dest/api/ethereum/l1_contracts.d.ts.map +1 -0
- package/dest/api/ethereum/l1_contracts.js +13 -0
- package/dest/api/ethereum/portal_manager.d.ts +136 -0
- package/dest/api/ethereum/portal_manager.d.ts.map +1 -0
- package/dest/api/ethereum/portal_manager.js +286 -0
- package/dest/api/fee.d.ts +6 -0
- package/dest/api/fee.d.ts.map +1 -0
- package/dest/api/fee.js +4 -0
- package/dest/api/fields.d.ts +2 -0
- package/dest/api/fields.d.ts.map +1 -0
- package/dest/api/fields.js +1 -0
- package/dest/api/interfaces/pxe.d.ts +2 -0
- package/dest/api/interfaces/pxe.d.ts.map +1 -0
- package/dest/api/interfaces/pxe.js +1 -0
- package/dest/api/log.d.ts +2 -0
- package/dest/api/log.d.ts.map +1 -0
- package/dest/api/log.js +1 -0
- package/dest/api/log_id.d.ts +2 -0
- package/dest/api/log_id.d.ts.map +1 -0
- package/dest/api/log_id.js +1 -0
- package/dest/api/tx_hash.d.ts +2 -0
- package/dest/api/tx_hash.d.ts.map +1 -0
- package/dest/api/tx_hash.js +1 -0
- package/dest/api/wallet.d.ts +2 -0
- package/dest/api/wallet.d.ts.map +1 -0
- package/dest/api/wallet.js +1 -0
- package/dest/contract/base_contract_interaction.d.ts +98 -0
- package/dest/contract/base_contract_interaction.d.ts.map +1 -0
- package/dest/contract/base_contract_interaction.js +149 -0
- package/dest/contract/batch_call.d.ts +28 -0
- package/dest/contract/batch_call.d.ts.map +1 -0
- package/dest/contract/batch_call.js +91 -0
- package/dest/contract/checker.d.ts +11 -0
- package/dest/contract/checker.d.ts.map +1 -0
- package/dest/contract/checker.js +107 -0
- package/dest/contract/contract.d.ts +41 -0
- package/dest/contract/contract.d.ts.map +1 -0
- package/dest/contract/contract.js +52 -0
- package/dest/contract/contract_base.d.ts +61 -0
- package/dest/contract/contract_base.d.ts.map +1 -0
- package/dest/contract/contract_base.js +45 -0
- package/dest/contract/contract_function_interaction.d.ts +68 -0
- package/dest/contract/contract_function_interaction.d.ts.map +1 -0
- package/dest/contract/contract_function_interaction.js +122 -0
- package/dest/contract/deploy_method.d.ts +113 -0
- package/dest/contract/deploy_method.d.ts.map +1 -0
- package/dest/contract/deploy_method.js +212 -0
- package/dest/contract/deploy_proven_tx.d.ts +21 -0
- package/dest/contract/deploy_proven_tx.d.ts.map +1 -0
- package/dest/contract/deploy_proven_tx.js +19 -0
- package/dest/contract/deploy_sent_tx.d.ts +45 -0
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -0
- package/dest/contract/deploy_sent_tx.js +43 -0
- package/dest/contract/get_gas_limits.d.ts +18 -0
- package/dest/contract/get_gas_limits.d.ts.map +1 -0
- package/dest/contract/get_gas_limits.js +10 -0
- package/dest/contract/index.d.ts +45 -0
- package/dest/contract/index.d.ts.map +1 -0
- package/dest/contract/index.js +43 -0
- package/dest/contract/protocol_contracts.d.ts +9 -0
- package/dest/contract/protocol_contracts.d.ts.map +1 -0
- package/dest/contract/protocol_contracts.js +26 -0
- package/dest/contract/proven_tx.d.ts +17 -0
- package/dest/contract/proven_tx.d.ts.map +1 -0
- package/dest/contract/proven_tx.js +22 -0
- package/dest/contract/sent_tx.d.ts +61 -0
- package/dest/contract/sent_tx.d.ts.map +1 -0
- package/dest/contract/sent_tx.js +102 -0
- package/dest/contract/unsafe_contract.d.ts +15 -0
- package/dest/contract/unsafe_contract.d.ts.map +1 -0
- package/dest/contract/unsafe_contract.js +6 -0
- package/dest/deployment/broadcast_function.d.ts +24 -0
- package/dest/deployment/broadcast_function.d.ts.map +1 -0
- package/dest/deployment/broadcast_function.js +70 -0
- package/dest/deployment/contract_deployer.d.ts +27 -0
- package/dest/deployment/contract_deployer.d.ts.map +1 -0
- package/dest/deployment/contract_deployer.js +30 -0
- package/dest/deployment/deploy_instance.d.ts +10 -0
- package/dest/deployment/deploy_instance.d.ts.map +1 -0
- package/dest/deployment/deploy_instance.js +14 -0
- package/dest/deployment/index.d.ts +2 -0
- package/dest/deployment/index.d.ts.map +1 -0
- package/dest/deployment/index.js +1 -0
- package/dest/deployment/register_class.d.ts +6 -0
- package/dest/deployment/register_class.d.ts.map +1 -0
- package/dest/deployment/register_class.js +22 -0
- package/dest/entrypoint/default_entrypoint.d.ts +12 -0
- package/dest/entrypoint/default_entrypoint.d.ts.map +1 -0
- package/dest/entrypoint/default_entrypoint.js +28 -0
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +15 -0
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -0
- package/dest/entrypoint/default_multi_call_entrypoint.js +130 -0
- package/dest/entrypoint/entrypoint.d.ts +35 -0
- package/dest/entrypoint/entrypoint.d.ts.map +1 -0
- package/dest/entrypoint/entrypoint.js +4 -0
- package/dest/entrypoint/payload.d.ts +128 -0
- package/dest/entrypoint/payload.d.ts.map +1 -0
- package/dest/entrypoint/payload.js +143 -0
- package/dest/fee/fee_juice_payment_method.d.ts +14 -0
- package/dest/fee/fee_juice_payment_method.d.ts.map +1 -0
- package/dest/fee/fee_juice_payment_method.js +20 -0
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +18 -0
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -0
- package/dest/fee/fee_juice_payment_method_with_claim.js +37 -0
- package/dest/fee/fee_payment_method.d.ts +22 -0
- package/dest/fee/fee_payment_method.d.ts.map +1 -0
- package/dest/fee/fee_payment_method.js +3 -0
- package/dest/fee/private_fee_payment_method.d.ts +51 -0
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/private_fee_payment_method.js +103 -0
- package/dest/fee/public_fee_payment_method.d.ts +41 -0
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/public_fee_payment_method.js +97 -0
- package/dest/index.d.ts +66 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +69 -0
- package/dest/rpc_clients/index.d.ts +3 -0
- package/dest/rpc_clients/index.d.ts.map +1 -0
- package/dest/rpc_clients/index.js +2 -0
- package/dest/rpc_clients/node/index.d.ts +12 -0
- package/dest/rpc_clients/node/index.d.ts.map +1 -0
- package/dest/rpc_clients/node/index.js +78 -0
- package/dest/rpc_clients/pxe_client.d.ts +10 -0
- package/dest/rpc_clients/pxe_client.d.ts.map +1 -0
- package/dest/rpc_clients/pxe_client.js +23 -0
- package/dest/utils/abi_types.d.ts +29 -0
- package/dest/utils/abi_types.d.ts.map +1 -0
- package/dest/utils/abi_types.js +1 -0
- package/dest/utils/authwit.d.ts +60 -0
- package/dest/utils/authwit.d.ts.map +1 -0
- package/dest/utils/authwit.js +74 -0
- package/dest/utils/aztec_cheatcodes.d.ts +59 -0
- package/dest/utils/aztec_cheatcodes.d.ts.map +1 -0
- package/dest/utils/aztec_cheatcodes.js +62 -0
- package/dest/utils/fee_juice.d.ts +7 -0
- package/dest/utils/fee_juice.d.ts.map +1 -0
- package/dest/utils/fee_juice.js +9 -0
- package/dest/utils/field_compressed_string.d.ts +17 -0
- package/dest/utils/field_compressed_string.d.ts.map +1 -0
- package/dest/utils/field_compressed_string.js +15 -0
- package/dest/utils/index.d.ts +8 -0
- package/dest/utils/index.d.ts.map +1 -0
- package/dest/utils/index.js +6 -0
- package/dest/utils/node.d.ts +5 -0
- package/dest/utils/node.d.ts.map +1 -0
- package/dest/utils/node.js +15 -0
- package/dest/utils/pub_key.d.ts +9 -0
- package/dest/utils/pub_key.d.ts.map +1 -0
- package/dest/utils/pub_key.js +9 -0
- package/dest/utils/pxe.d.ts +4 -0
- package/dest/utils/pxe.d.ts.map +1 -0
- package/dest/utils/pxe.js +14 -0
- package/dest/wallet/account_wallet.d.ts +76 -0
- package/dest/wallet/account_wallet.d.ts.map +1 -0
- package/dest/wallet/account_wallet.js +231 -0
- package/dest/wallet/account_wallet_with_private_key.d.ts +26 -0
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +1 -0
- package/dest/wallet/account_wallet_with_private_key.js +22 -0
- package/dest/wallet/base_wallet.d.ts +73 -0
- package/dest/wallet/base_wallet.d.ts.map +1 -0
- package/dest/wallet/base_wallet.js +123 -0
- package/dest/wallet/index.d.ts +17 -0
- package/dest/wallet/index.d.ts.map +1 -0
- package/dest/wallet/index.js +20 -0
- package/dest/wallet/signerless_wallet.d.ts +25 -0
- package/dest/wallet/signerless_wallet.d.ts.map +1 -0
- package/dest/wallet/signerless_wallet.js +36 -0
- package/package.json +116 -0
- package/src/account/contract.ts +56 -0
- package/src/account/index.ts +16 -0
- package/src/account/interface.ts +36 -0
- package/src/account/wallet.ts +13 -0
- package/src/account_manager/deploy_account_method.ts +86 -0
- package/src/account_manager/deploy_account_sent_tx.ts +42 -0
- package/src/account_manager/index.ts +229 -0
- package/src/api/README.md +7 -0
- package/src/api/abi.ts +10 -0
- package/src/api/account.ts +10 -0
- package/src/api/addresses.ts +2 -0
- package/src/api/cheat_codes.ts +35 -0
- package/src/api/deployment.ts +3 -0
- package/src/api/entrypoint.ts +1 -0
- package/src/api/eth_address.ts +1 -0
- package/src/api/ethereum/anvil_test_watcher.ts +158 -0
- package/src/api/ethereum/chain_monitor.ts +88 -0
- package/src/api/ethereum/cheat_codes.ts +184 -0
- package/src/api/ethereum/index.ts +19 -0
- package/src/api/ethereum/l1_contracts.ts +21 -0
- package/src/api/ethereum/portal_manager.ts +410 -0
- package/src/api/fee.ts +5 -0
- package/src/api/fields.ts +1 -0
- package/src/api/interfaces/pxe.ts +1 -0
- package/src/api/log.ts +1 -0
- package/src/api/log_id.ts +1 -0
- package/src/api/tx_hash.ts +1 -0
- package/src/api/wallet.ts +7 -0
- package/src/contract/base_contract_interaction.ts +192 -0
- package/src/contract/batch_call.ts +95 -0
- package/src/contract/checker.ts +117 -0
- package/src/contract/contract.ts +69 -0
- package/src/contract/contract_base.ts +90 -0
- package/src/contract/contract_function_interaction.ts +173 -0
- package/src/contract/deploy_method.ts +271 -0
- package/src/contract/deploy_proven_tx.ts +34 -0
- package/src/contract/deploy_sent_tx.ts +74 -0
- package/src/contract/get_gas_limits.ts +26 -0
- package/src/contract/index.ts +48 -0
- package/src/contract/protocol_contracts.ts +35 -0
- package/src/contract/proven_tx.ts +42 -0
- package/src/contract/sent_tx.ts +141 -0
- package/src/contract/unsafe_contract.ts +19 -0
- package/src/deployment/broadcast_function.ts +148 -0
- package/src/deployment/contract_deployer.ts +41 -0
- package/src/deployment/deploy_instance.ts +31 -0
- package/src/deployment/index.ts +1 -0
- package/src/deployment/register_class.ts +44 -0
- package/src/entrypoint/default_entrypoint.ts +39 -0
- package/src/entrypoint/default_multi_call_entrypoint.ts +93 -0
- package/src/entrypoint/entrypoint.ts +39 -0
- package/src/entrypoint/payload.ts +238 -0
- package/src/fee/fee_juice_payment_method.ts +26 -0
- package/src/fee/fee_juice_payment_method_with_claim.ts +49 -0
- package/src/fee/fee_payment_method.ts +22 -0
- package/src/fee/private_fee_payment_method.ts +118 -0
- package/src/fee/public_fee_payment_method.ts +114 -0
- package/src/index.ts +106 -0
- package/src/rpc_clients/index.ts +2 -0
- package/src/rpc_clients/node/index.ts +77 -0
- package/src/rpc_clients/pxe_client.ts +25 -0
- package/src/utils/abi_types.ts +25 -0
- package/src/utils/authwit.ts +110 -0
- package/src/utils/aztec_cheatcodes.ts +77 -0
- package/src/utils/fee_juice.ts +14 -0
- package/src/utils/field_compressed_string.ts +27 -0
- package/src/utils/index.ts +21 -0
- package/src/utils/node.ts +19 -0
- package/src/utils/pub_key.ts +13 -0
- package/src/utils/pxe.ts +17 -0
- package/src/wallet/account_wallet.ts +242 -0
- package/src/wallet/account_wallet_with_private_key.ts +40 -0
- package/src/wallet/base_wallet.ts +198 -0
- package/src/wallet/index.ts +33 -0
- package/src/wallet/signerless_wallet.ts +52 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type FunctionAbi, FunctionCall } from '@aztec/stdlib/abi';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { PrivateKernelProverProfileResult } from '@aztec/stdlib/kernel';
|
|
4
|
+
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { Wallet } from '../account/wallet.js';
|
|
6
|
+
import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
|
|
7
|
+
export type { SendMethodOptions };
|
|
8
|
+
/**
|
|
9
|
+
* Represents the options for simulating a contract function interaction.
|
|
10
|
+
* Allows specifying the address from which the view method should be called.
|
|
11
|
+
* Disregarded for simulation of public functions
|
|
12
|
+
*/
|
|
13
|
+
export type SimulateMethodOptions = Pick<SendMethodOptions, 'fee'> & {
|
|
14
|
+
/** The sender's Aztec address. */
|
|
15
|
+
from?: AztecAddress;
|
|
16
|
+
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
17
|
+
skipTxValidation?: boolean;
|
|
18
|
+
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
19
|
+
skipFeeEnforcement?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The result of a profile() call.
|
|
23
|
+
*/
|
|
24
|
+
export type ProfileResult = PrivateKernelProverProfileResult & {
|
|
25
|
+
/** The result of the transaction as returned by the contract function. */
|
|
26
|
+
returnValues: any;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* This is the class that is returned when calling e.g. `contract.methods.myMethod(arg0, arg1)`.
|
|
30
|
+
* It contains available interactions one can call on a method, including view.
|
|
31
|
+
*/
|
|
32
|
+
export declare class ContractFunctionInteraction extends BaseContractInteraction {
|
|
33
|
+
protected contractAddress: AztecAddress;
|
|
34
|
+
protected functionDao: FunctionAbi;
|
|
35
|
+
protected args: any[];
|
|
36
|
+
constructor(wallet: Wallet, contractAddress: AztecAddress, functionDao: FunctionAbi, args: any[]);
|
|
37
|
+
/**
|
|
38
|
+
* Create a transaction execution request that represents this call, encoded and authenticated by the
|
|
39
|
+
* user's wallet, ready to be simulated.
|
|
40
|
+
* @param opts - An optional object containing additional configuration for the transaction.
|
|
41
|
+
* @returns A Promise that resolves to a transaction instance.
|
|
42
|
+
*/
|
|
43
|
+
create(opts?: SendMethodOptions): Promise<TxExecutionRequest>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns an execution request that represents this operation. Useful as a building
|
|
46
|
+
* block for constructing batch requests.
|
|
47
|
+
* @returns An execution request wrapped in promise.
|
|
48
|
+
*/
|
|
49
|
+
request(): Promise<FunctionCall>;
|
|
50
|
+
/**
|
|
51
|
+
* Simulate a transaction and get its return values
|
|
52
|
+
* Differs from prove in a few important ways:
|
|
53
|
+
* 1. It returns the values of the function execution
|
|
54
|
+
* 2. It supports `unconstrained`, `private` and `public` functions
|
|
55
|
+
*
|
|
56
|
+
* @param options - An optional object containing additional configuration for the transaction.
|
|
57
|
+
* @returns The result of the transaction as returned by the contract function.
|
|
58
|
+
*/
|
|
59
|
+
simulate(options?: SimulateMethodOptions): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* Simulate a transaction and profile the gate count for each function in the transaction.
|
|
62
|
+
* @param options - Same options as `simulate`.
|
|
63
|
+
*
|
|
64
|
+
* @returns An object containing the function return value and profile result.
|
|
65
|
+
*/
|
|
66
|
+
simulateWithProfile(options?: SimulateMethodOptions): Promise<ProfileResult>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=contract_function_interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract_function_interaction.d.ts","sourceRoot":"","sources":["../../src/contract/contract_function_interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,YAAY,EAKb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEjG,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,GAAG;IACnE,kCAAkC;IAClC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,8HAA8H;IAC9H,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,8FAA8F;IAC9F,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,gCAAgC,GAAG;IAC7D,0EAA0E;IAC1E,YAAY,EAAE,GAAG,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,uBAAuB;IAGpE,SAAS,CAAC,eAAe,EAAE,YAAY;IACvC,SAAS,CAAC,WAAW,EAAE,WAAW;IAClC,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE;gBAHrB,MAAM,EAAE,MAAM,EACJ,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,GAAG,EAAE;IASvB;;;;;OAKG;IACU,MAAM,CAAC,IAAI,GAAE,iBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAa9E;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;IAe7C;;;;;;;;OAQG;IACU,QAAQ,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;IAkCxE;;;;;OAKG;IACU,mBAAmB,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,aAAa,CAAC;CA0B9F"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { FunctionSelector, FunctionType, decodeFromAbi, encodeArguments } from '@aztec/stdlib/abi';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { FeeJuicePaymentMethod } from '../fee/fee_juice_payment_method.js';
|
|
4
|
+
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
5
|
+
/**
|
|
6
|
+
* This is the class that is returned when calling e.g. `contract.methods.myMethod(arg0, arg1)`.
|
|
7
|
+
* It contains available interactions one can call on a method, including view.
|
|
8
|
+
*/ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
9
|
+
contractAddress;
|
|
10
|
+
functionDao;
|
|
11
|
+
args;
|
|
12
|
+
constructor(wallet, contractAddress, functionDao, args){
|
|
13
|
+
super(wallet), this.contractAddress = contractAddress, this.functionDao = functionDao, this.args = args;
|
|
14
|
+
if (args.some((arg)=>arg === undefined || arg === null)) {
|
|
15
|
+
throw new Error('All function interaction arguments must be defined and not null. Received: ' + args);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// docs:start:create
|
|
19
|
+
/**
|
|
20
|
+
* Create a transaction execution request that represents this call, encoded and authenticated by the
|
|
21
|
+
* user's wallet, ready to be simulated.
|
|
22
|
+
* @param opts - An optional object containing additional configuration for the transaction.
|
|
23
|
+
* @returns A Promise that resolves to a transaction instance.
|
|
24
|
+
*/ async create(opts = {}) {
|
|
25
|
+
// docs:end:create
|
|
26
|
+
if (this.functionDao.functionType === FunctionType.UNCONSTRAINED) {
|
|
27
|
+
throw new Error("Can't call `create` on an unconstrained function.");
|
|
28
|
+
}
|
|
29
|
+
const calls = [
|
|
30
|
+
await this.request()
|
|
31
|
+
];
|
|
32
|
+
const capsules = this.getCapsules();
|
|
33
|
+
const fee = await this.getFeeOptions({
|
|
34
|
+
calls,
|
|
35
|
+
capsules,
|
|
36
|
+
...opts
|
|
37
|
+
});
|
|
38
|
+
const { nonce, cancellable } = opts;
|
|
39
|
+
return await this.wallet.createTxExecutionRequest({
|
|
40
|
+
calls,
|
|
41
|
+
fee,
|
|
42
|
+
nonce,
|
|
43
|
+
cancellable,
|
|
44
|
+
capsules
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// docs:start:request
|
|
48
|
+
/**
|
|
49
|
+
* Returns an execution request that represents this operation. Useful as a building
|
|
50
|
+
* block for constructing batch requests.
|
|
51
|
+
* @returns An execution request wrapped in promise.
|
|
52
|
+
*/ async request() {
|
|
53
|
+
// docs:end:request
|
|
54
|
+
const args = encodeArguments(this.functionDao, this.args);
|
|
55
|
+
return {
|
|
56
|
+
name: this.functionDao.name,
|
|
57
|
+
args,
|
|
58
|
+
selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
|
|
59
|
+
type: this.functionDao.functionType,
|
|
60
|
+
to: this.contractAddress,
|
|
61
|
+
isStatic: this.functionDao.isStatic,
|
|
62
|
+
returnTypes: this.functionDao.returnTypes
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// docs:start:simulate
|
|
66
|
+
/**
|
|
67
|
+
* Simulate a transaction and get its return values
|
|
68
|
+
* Differs from prove in a few important ways:
|
|
69
|
+
* 1. It returns the values of the function execution
|
|
70
|
+
* 2. It supports `unconstrained`, `private` and `public` functions
|
|
71
|
+
*
|
|
72
|
+
* @param options - An optional object containing additional configuration for the transaction.
|
|
73
|
+
* @returns The result of the transaction as returned by the contract function.
|
|
74
|
+
*/ async simulate(options = {}) {
|
|
75
|
+
// docs:end:simulate
|
|
76
|
+
if (this.functionDao.functionType == FunctionType.UNCONSTRAINED) {
|
|
77
|
+
return this.wallet.simulateUnconstrained(this.functionDao.name, this.args, this.contractAddress, options?.from);
|
|
78
|
+
}
|
|
79
|
+
const fee = options.fee ?? {
|
|
80
|
+
paymentMethod: new FeeJuicePaymentMethod(AztecAddress.ZERO)
|
|
81
|
+
};
|
|
82
|
+
const txRequest = await this.create({
|
|
83
|
+
fee
|
|
84
|
+
});
|
|
85
|
+
const simulatedTx = await this.wallet.simulateTx(txRequest, true, options.from, options.skipTxValidation, options.skipFeeEnforcement ?? true);
|
|
86
|
+
let rawReturnValues;
|
|
87
|
+
if (this.functionDao.functionType == FunctionType.PRIVATE) {
|
|
88
|
+
if (simulatedTx.getPrivateReturnValues().nested.length > 0) {
|
|
89
|
+
// The function invoked is private and it was called via an account contract
|
|
90
|
+
// TODO(#10631): There is a bug here: this branch might be triggered when there is no-account contract as well
|
|
91
|
+
rawReturnValues = simulatedTx.getPrivateReturnValues().nested[0].values;
|
|
92
|
+
} else {
|
|
93
|
+
// The function invoked is private and it was called directly (without account contract)
|
|
94
|
+
rawReturnValues = simulatedTx.getPrivateReturnValues().values;
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
// For public functions we retrieve the first values directly from the public output.
|
|
98
|
+
rawReturnValues = simulatedTx.getPublicReturnValues()?.[0].values;
|
|
99
|
+
}
|
|
100
|
+
return rawReturnValues ? decodeFromAbi(this.functionDao.returnTypes, rawReturnValues) : [];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Simulate a transaction and profile the gate count for each function in the transaction.
|
|
104
|
+
* @param options - Same options as `simulate`.
|
|
105
|
+
*
|
|
106
|
+
* @returns An object containing the function return value and profile result.
|
|
107
|
+
*/ async simulateWithProfile(options = {}) {
|
|
108
|
+
if (this.functionDao.functionType == FunctionType.UNCONSTRAINED) {
|
|
109
|
+
throw new Error("Can't profile an unconstrained function.");
|
|
110
|
+
}
|
|
111
|
+
const txRequest = await this.create({
|
|
112
|
+
fee: options.fee
|
|
113
|
+
});
|
|
114
|
+
const simulatedTx = await this.wallet.simulateTx(txRequest, true, options?.from, options?.skipTxValidation, undefined, true);
|
|
115
|
+
const rawReturnValues = this.functionDao.functionType == FunctionType.PRIVATE ? simulatedTx.getPrivateReturnValues().nested?.[0].values : simulatedTx.getPublicReturnValues()?.[0].values;
|
|
116
|
+
const rawReturnValuesDecoded = rawReturnValues ? decodeFromAbi(this.functionDao.returnTypes, rawReturnValues) : [];
|
|
117
|
+
return {
|
|
118
|
+
returnValues: rawReturnValuesDecoded,
|
|
119
|
+
gateCounts: simulatedTx.profileResult.gateCounts
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { type ContractArtifact, type FunctionArtifact } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
|
+
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
7
|
+
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
8
|
+
import type { Wallet } from '../account/index.js';
|
|
9
|
+
import type { ExecutionRequestInit } from '../entrypoint/entrypoint.js';
|
|
10
|
+
import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
|
|
11
|
+
import type { Contract } from './contract.js';
|
|
12
|
+
import type { ContractBase } from './contract_base.js';
|
|
13
|
+
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
14
|
+
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
15
|
+
/**
|
|
16
|
+
* Options for deploying a contract on the Aztec network.
|
|
17
|
+
* Allows specifying a contract address salt, and additional send method options.
|
|
18
|
+
*/
|
|
19
|
+
export type DeployOptions = {
|
|
20
|
+
/** An optional salt value used to deterministically calculate the contract address. */
|
|
21
|
+
contractAddressSalt?: Fr;
|
|
22
|
+
/** Set to true to *not* include the sender in the address computation. */
|
|
23
|
+
universalDeploy?: boolean;
|
|
24
|
+
/** Skip contract class registration. */
|
|
25
|
+
skipClassRegistration?: boolean;
|
|
26
|
+
/** Skip public deployment, instead just privately initialize the contract. */
|
|
27
|
+
skipPublicDeployment?: boolean;
|
|
28
|
+
/** Skip contract initialization. */
|
|
29
|
+
skipInitialization?: boolean;
|
|
30
|
+
} & SendMethodOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Contract interaction for deployment. Handles class registration, public instance deployment,
|
|
33
|
+
* and initialization of the contract. Extends the BaseContractInteraction class.
|
|
34
|
+
*/
|
|
35
|
+
export declare class DeployMethod<TContract extends ContractBase = Contract> extends BaseContractInteraction {
|
|
36
|
+
private publicKeys;
|
|
37
|
+
private artifact;
|
|
38
|
+
private postDeployCtor;
|
|
39
|
+
private args;
|
|
40
|
+
/** The contract instance to be deployed. */
|
|
41
|
+
private instance?;
|
|
42
|
+
/** Constructor function to call. */
|
|
43
|
+
private constructorArtifact;
|
|
44
|
+
constructor(publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>, args?: any[], constructorNameOrArtifact?: string | FunctionArtifact);
|
|
45
|
+
/**
|
|
46
|
+
* Create a contract deployment transaction, given the deployment options.
|
|
47
|
+
* This function internally calls `request()` and `sign()` methods to prepare
|
|
48
|
+
* the transaction for deployment. The resulting signed transaction can be
|
|
49
|
+
* later sent using the `send()` method.
|
|
50
|
+
*
|
|
51
|
+
* @param options - An object containing optional deployment settings, contractAddressSalt, and from.
|
|
52
|
+
* @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
|
|
53
|
+
*/
|
|
54
|
+
create(options?: DeployOptions): Promise<TxExecutionRequest>;
|
|
55
|
+
/**
|
|
56
|
+
* Returns an array of function calls that represent this operation. Useful as a building
|
|
57
|
+
* block for constructing batch requests.
|
|
58
|
+
* @param options - Deployment options.
|
|
59
|
+
* @returns An array of function calls.
|
|
60
|
+
* @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
|
|
61
|
+
* it returns a promise for an array instead of a function call directly.
|
|
62
|
+
*/
|
|
63
|
+
request(options?: DeployOptions): Promise<ExecutionRequestInit>;
|
|
64
|
+
/**
|
|
65
|
+
* Register this contract in the PXE and returns the Contract object.
|
|
66
|
+
* @param options - Deployment options.
|
|
67
|
+
*/
|
|
68
|
+
register(options?: DeployOptions): Promise<TContract>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns calls for registration of the class and deployment of the instance, depending on the provided options.
|
|
71
|
+
* @param options - Deployment options.
|
|
72
|
+
* @returns A function call array with potentially requests to the class registerer and instance deployer.
|
|
73
|
+
*/
|
|
74
|
+
protected getDeploymentFunctionCalls(options?: DeployOptions): Promise<Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'hashedArguments' | 'capsules'>>;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the calls necessary to initialize the contract.
|
|
77
|
+
* @param options - Deployment options.
|
|
78
|
+
* @returns - An array of function calls.
|
|
79
|
+
*/
|
|
80
|
+
protected getInitializeFunctionCalls(options: DeployOptions): Promise<Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'hashedArguments' | 'capsules'>>;
|
|
81
|
+
/**
|
|
82
|
+
* Send the contract deployment transaction using the provided options.
|
|
83
|
+
* This function extends the 'send' method from the ContractFunctionInteraction class,
|
|
84
|
+
* allowing us to send a transaction specifically for contract deployment.
|
|
85
|
+
*
|
|
86
|
+
* @param options - An object containing various deployment options such as contractAddressSalt and from.
|
|
87
|
+
* @returns A SentTx object that returns the receipt and the deployed contract instance.
|
|
88
|
+
*/
|
|
89
|
+
send(options?: DeployOptions): DeploySentTx<TContract>;
|
|
90
|
+
/**
|
|
91
|
+
* Builds the contract instance to be deployed and returns it.
|
|
92
|
+
*
|
|
93
|
+
* @param options - An object containing various deployment options.
|
|
94
|
+
* @returns An instance object.
|
|
95
|
+
*/
|
|
96
|
+
getInstance(options?: DeployOptions): Promise<ContractInstanceWithAddress>;
|
|
97
|
+
/**
|
|
98
|
+
* Prove the request.
|
|
99
|
+
* @param options - Deployment options.
|
|
100
|
+
* @returns The proven tx.
|
|
101
|
+
*/
|
|
102
|
+
prove(options: DeployOptions): Promise<DeployProvenTx<TContract>>;
|
|
103
|
+
/**
|
|
104
|
+
* Estimates gas cost for this deployment operation.
|
|
105
|
+
* @param options - Options.
|
|
106
|
+
*/
|
|
107
|
+
estimateGas(options?: Omit<DeployOptions, 'estimateGas' | 'skipPublicSimulation'>): Promise<Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>>;
|
|
108
|
+
/** Return this deployment address. */
|
|
109
|
+
get address(): AztecAddress | undefined;
|
|
110
|
+
/** Returns the partial address for this deployment. */
|
|
111
|
+
get partialAddress(): Promise<Fr> | undefined;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=deploy_method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy_method.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAqC,MAAM,mBAAmB,CAAC;AACpH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAW,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,KAAK,E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
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { computePartialAddress, getContractClassFromArtifact, getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
|
|
4
|
+
import { deployInstance } from '../deployment/deploy_instance.js';
|
|
5
|
+
import { registerContractClass } from '../deployment/register_class.js';
|
|
6
|
+
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
7
|
+
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
8
|
+
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
9
|
+
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
10
|
+
// docs:end:deploy_options
|
|
11
|
+
// TODO(@spalladino): Add unit tests for this class!
|
|
12
|
+
/**
|
|
13
|
+
* Contract interaction for deployment. Handles class registration, public instance deployment,
|
|
14
|
+
* and initialization of the contract. Extends the BaseContractInteraction class.
|
|
15
|
+
*/ export class DeployMethod extends BaseContractInteraction {
|
|
16
|
+
publicKeys;
|
|
17
|
+
artifact;
|
|
18
|
+
postDeployCtor;
|
|
19
|
+
args;
|
|
20
|
+
/** The contract instance to be deployed. */ instance;
|
|
21
|
+
/** Constructor function to call. */ constructorArtifact;
|
|
22
|
+
constructor(publicKeys, wallet, artifact, postDeployCtor, args = [], constructorNameOrArtifact){
|
|
23
|
+
super(wallet), this.publicKeys = publicKeys, this.artifact = artifact, this.postDeployCtor = postDeployCtor, this.args = args, this.instance = undefined;
|
|
24
|
+
this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a contract deployment transaction, given the deployment options.
|
|
28
|
+
* This function internally calls `request()` and `sign()` methods to prepare
|
|
29
|
+
* the transaction for deployment. The resulting signed transaction can be
|
|
30
|
+
* later sent using the `send()` method.
|
|
31
|
+
*
|
|
32
|
+
* @param options - An object containing optional deployment settings, contractAddressSalt, and from.
|
|
33
|
+
* @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
|
|
34
|
+
*/ async create(options = {}) {
|
|
35
|
+
return this.wallet.createTxExecutionRequest(await this.request(options));
|
|
36
|
+
}
|
|
37
|
+
// REFACTOR: Having a `request` method with different semantics than the ones in the other
|
|
38
|
+
// derived ContractInteractions is confusing. We should unify the flow of all ContractInteractions.
|
|
39
|
+
/**
|
|
40
|
+
* Returns an array of function calls that represent this operation. Useful as a building
|
|
41
|
+
* block for constructing batch requests.
|
|
42
|
+
* @param options - Deployment options.
|
|
43
|
+
* @returns An array of function calls.
|
|
44
|
+
* @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
|
|
45
|
+
* it returns a promise for an array instead of a function call directly.
|
|
46
|
+
*/ async request(options = {}) {
|
|
47
|
+
const deployment = await this.getDeploymentFunctionCalls(options);
|
|
48
|
+
// NOTE: MEGA HACK. Remove with #10007
|
|
49
|
+
// register the contract after generating deployment function calls in order to publicly register the class and (optioanlly) emit its bytecode
|
|
50
|
+
//
|
|
51
|
+
// TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
|
|
52
|
+
// Note that we need to run this registerContract here so it's available when computeFeeOptionsFromEstimatedGas
|
|
53
|
+
// runs, since it needs the contract to have been registered in order to estimate gas for its initialization,
|
|
54
|
+
// in case the initializer is public. This hints at the need of having "transient" contracts scoped to a
|
|
55
|
+
// simulation, so we can run the simulation with a set of contracts, but only "commit" them to the wallet
|
|
56
|
+
// once this tx has gone through.
|
|
57
|
+
await this.wallet.registerContract({
|
|
58
|
+
artifact: this.artifact,
|
|
59
|
+
instance: await this.getInstance(options)
|
|
60
|
+
});
|
|
61
|
+
const bootstrap = await this.getInitializeFunctionCalls(options);
|
|
62
|
+
if (deployment.calls.length + bootstrap.calls.length === 0) {
|
|
63
|
+
throw new Error(`No function calls needed to deploy contract ${this.artifact.name}`);
|
|
64
|
+
}
|
|
65
|
+
const calls = [
|
|
66
|
+
...deployment.calls,
|
|
67
|
+
...bootstrap.calls
|
|
68
|
+
];
|
|
69
|
+
const authWitnesses = [
|
|
70
|
+
...deployment.authWitnesses ?? [],
|
|
71
|
+
...bootstrap.authWitnesses ?? []
|
|
72
|
+
];
|
|
73
|
+
const hashedArguments = [
|
|
74
|
+
...deployment.hashedArguments ?? [],
|
|
75
|
+
...bootstrap.hashedArguments ?? []
|
|
76
|
+
];
|
|
77
|
+
const capsules = [
|
|
78
|
+
...deployment.capsules ?? [],
|
|
79
|
+
...bootstrap.capsules ?? []
|
|
80
|
+
];
|
|
81
|
+
const { cancellable, nonce, fee: userFee } = options;
|
|
82
|
+
const request = {
|
|
83
|
+
calls,
|
|
84
|
+
authWitnesses,
|
|
85
|
+
hashedArguments,
|
|
86
|
+
capsules,
|
|
87
|
+
cancellable,
|
|
88
|
+
fee: userFee,
|
|
89
|
+
nonce
|
|
90
|
+
};
|
|
91
|
+
const fee = await this.getFeeOptions(request);
|
|
92
|
+
return {
|
|
93
|
+
...request,
|
|
94
|
+
fee
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Register this contract in the PXE and returns the Contract object.
|
|
99
|
+
* @param options - Deployment options.
|
|
100
|
+
*/ async register(options = {}) {
|
|
101
|
+
const instance = await this.getInstance(options);
|
|
102
|
+
await this.wallet.registerContract({
|
|
103
|
+
artifact: this.artifact,
|
|
104
|
+
instance
|
|
105
|
+
});
|
|
106
|
+
return this.postDeployCtor(instance.address, this.wallet);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Returns calls for registration of the class and deployment of the instance, depending on the provided options.
|
|
110
|
+
* @param options - Deployment options.
|
|
111
|
+
* @returns A function call array with potentially requests to the class registerer and instance deployer.
|
|
112
|
+
*/ async getDeploymentFunctionCalls(options = {}) {
|
|
113
|
+
const calls = [];
|
|
114
|
+
const capsules = [];
|
|
115
|
+
// Set contract instance object so it's available for populating the DeploySendTx object
|
|
116
|
+
const instance = await this.getInstance(options);
|
|
117
|
+
// Obtain contract class from artifact and check it matches the reported one by the instance.
|
|
118
|
+
// TODO(@spalladino): We're unnecessarily calculating the contract class multiple times here.
|
|
119
|
+
const contractClass = await getContractClassFromArtifact(this.artifact);
|
|
120
|
+
if (!instance.currentContractClassId.equals(contractClass.id)) {
|
|
121
|
+
throw new Error(`Contract class mismatch when deploying contract: got ${instance.currentContractClassId.toString()} from instance and ${contractClass.id.toString()} from artifact`);
|
|
122
|
+
}
|
|
123
|
+
// Register the contract class if it hasn't been published already.
|
|
124
|
+
if (!options.skipClassRegistration) {
|
|
125
|
+
if ((await this.wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
126
|
+
this.log.debug(`Skipping registration of already registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`);
|
|
127
|
+
} else {
|
|
128
|
+
this.log.info(`Creating request for registering contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`);
|
|
129
|
+
const registerContractClassInteraction = await registerContractClass(this.wallet, this.artifact);
|
|
130
|
+
calls.push(await registerContractClassInteraction.request());
|
|
131
|
+
capsules.push(...registerContractClassInteraction.getCapsules());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Deploy the contract via the instance deployer.
|
|
135
|
+
if (!options.skipPublicDeployment) {
|
|
136
|
+
const deploymentInteraction = await deployInstance(this.wallet, instance);
|
|
137
|
+
calls.push(await deploymentInteraction.request());
|
|
138
|
+
capsules.push(...deploymentInteraction.getCapsules());
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
calls,
|
|
142
|
+
capsules
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Returns the calls necessary to initialize the contract.
|
|
147
|
+
* @param options - Deployment options.
|
|
148
|
+
* @returns - An array of function calls.
|
|
149
|
+
*/ async getInitializeFunctionCalls(options) {
|
|
150
|
+
const { address } = await this.getInstance(options);
|
|
151
|
+
const calls = [];
|
|
152
|
+
const capsules = [];
|
|
153
|
+
if (this.constructorArtifact && !options.skipInitialization) {
|
|
154
|
+
const constructorCall = new ContractFunctionInteraction(this.wallet, address, this.constructorArtifact, this.args);
|
|
155
|
+
calls.push(await constructorCall.request());
|
|
156
|
+
capsules.push(...constructorCall.getCapsules());
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
calls,
|
|
160
|
+
capsules
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Send the contract deployment transaction using the provided options.
|
|
165
|
+
* This function extends the 'send' method from the ContractFunctionInteraction class,
|
|
166
|
+
* allowing us to send a transaction specifically for contract deployment.
|
|
167
|
+
*
|
|
168
|
+
* @param options - An object containing various deployment options such as contractAddressSalt and from.
|
|
169
|
+
* @returns A SentTx object that returns the receipt and the deployed contract instance.
|
|
170
|
+
*/ send(options = {}) {
|
|
171
|
+
const txHashPromise = super.send(options).getTxHash();
|
|
172
|
+
this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
|
|
173
|
+
return new DeploySentTx(this.wallet, txHashPromise, this.postDeployCtor, ()=>this.getInstance(options));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Builds the contract instance to be deployed and returns it.
|
|
177
|
+
*
|
|
178
|
+
* @param options - An object containing various deployment options.
|
|
179
|
+
* @returns An instance object.
|
|
180
|
+
*/ async getInstance(options = {}) {
|
|
181
|
+
if (!this.instance) {
|
|
182
|
+
this.instance = await getContractInstanceFromDeployParams(this.artifact, {
|
|
183
|
+
constructorArgs: this.args,
|
|
184
|
+
salt: options.contractAddressSalt,
|
|
185
|
+
publicKeys: this.publicKeys,
|
|
186
|
+
constructorArtifact: this.constructorArtifact,
|
|
187
|
+
deployer: options.universalDeploy ? AztecAddress.ZERO : this.wallet.getAddress()
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return this.instance;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Prove the request.
|
|
194
|
+
* @param options - Deployment options.
|
|
195
|
+
* @returns The proven tx.
|
|
196
|
+
*/ async prove(options) {
|
|
197
|
+
const txProvingResult = await this.proveInternal(options);
|
|
198
|
+
return new DeployProvenTx(this.wallet, txProvingResult.toTx(), this.postDeployCtor, ()=>this.getInstance(options));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Estimates gas cost for this deployment operation.
|
|
202
|
+
* @param options - Options.
|
|
203
|
+
*/ estimateGas(options) {
|
|
204
|
+
return super.estimateGas(options);
|
|
205
|
+
}
|
|
206
|
+
/** Return this deployment address. */ get address() {
|
|
207
|
+
return this.instance?.address;
|
|
208
|
+
}
|
|
209
|
+
/** Returns the partial address for this deployment. */ get partialAddress() {
|
|
210
|
+
return this.instance && computePartialAddress(this.instance);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { Wallet } from '../account/index.js';
|
|
6
|
+
import type { Contract } from './contract.js';
|
|
7
|
+
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
8
|
+
import { ProvenTx } from './proven_tx.js';
|
|
9
|
+
/**
|
|
10
|
+
* A proven transaction that can be sent to the network. Returned by the `prove` method of a contract deployment.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DeployProvenTx<TContract extends Contract = Contract> extends ProvenTx {
|
|
13
|
+
private postDeployCtor;
|
|
14
|
+
private instanceGetter;
|
|
15
|
+
constructor(wallet: PXE | Wallet, tx: Tx, postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>, instanceGetter: () => Promise<ContractInstanceWithAddress>);
|
|
16
|
+
/**
|
|
17
|
+
* Sends the transaction to the network via the provided wallet.
|
|
18
|
+
*/
|
|
19
|
+
send(): DeploySentTx<TContract>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=deploy_proven_tx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy_proven_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_proven_tx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;GAEG;AACH,qBAAa,cAAc,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ,CAAE,SAAQ,QAAQ;IAI/E,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;gBAHtB,MAAM,EAAE,GAAG,GAAG,MAAM,EACpB,EAAE,EAAE,EAAE,EACE,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,EAC7E,cAAc,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC;IAKpE;;OAEG;IACa,IAAI,IAAI,YAAY,CAAC,SAAS,CAAC;CAOhD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
2
|
+
import { ProvenTx } from './proven_tx.js';
|
|
3
|
+
/**
|
|
4
|
+
* A proven transaction that can be sent to the network. Returned by the `prove` method of a contract deployment.
|
|
5
|
+
*/ export class DeployProvenTx extends ProvenTx {
|
|
6
|
+
postDeployCtor;
|
|
7
|
+
instanceGetter;
|
|
8
|
+
constructor(wallet, tx, postDeployCtor, instanceGetter){
|
|
9
|
+
super(wallet, tx), this.postDeployCtor = postDeployCtor, this.instanceGetter = instanceGetter;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Sends the transaction to the network via the provided wallet.
|
|
13
|
+
*/ send() {
|
|
14
|
+
const promise = (()=>{
|
|
15
|
+
return this.wallet.sendTx(this.getPlainDataTx());
|
|
16
|
+
})();
|
|
17
|
+
return new DeploySentTx(this.wallet, promise, this.postDeployCtor, this.instanceGetter);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { Wallet } from '../account/index.js';
|
|
7
|
+
import type { Contract } from './contract.js';
|
|
8
|
+
import type { ContractBase } from './contract_base.js';
|
|
9
|
+
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
10
|
+
/** Options related to waiting for a deployment tx. */
|
|
11
|
+
export type DeployedWaitOpts = WaitOpts & {
|
|
12
|
+
/** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
|
|
13
|
+
wallet?: Wallet;
|
|
14
|
+
};
|
|
15
|
+
/** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
|
|
16
|
+
export type DeployTxReceipt<TContract extends ContractBase = Contract> = FieldsOf<TxReceipt> & {
|
|
17
|
+
/** Instance of the newly deployed contract. */
|
|
18
|
+
contract: TContract;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A contract deployment transaction sent to the network, extending SentTx with methods to create a contract instance.
|
|
22
|
+
*/
|
|
23
|
+
export declare class DeploySentTx<TContract extends Contract = Contract> extends SentTx {
|
|
24
|
+
private postDeployCtor;
|
|
25
|
+
/** A getter for the deployed contract instance */
|
|
26
|
+
instanceGetter: () => Promise<ContractInstanceWithAddress>;
|
|
27
|
+
private log;
|
|
28
|
+
constructor(pxeOrWallet: PXE | Wallet, txHashPromise: Promise<TxHash>, postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
|
|
29
|
+
/** A getter for the deployed contract instance */
|
|
30
|
+
instanceGetter: () => Promise<ContractInstanceWithAddress>);
|
|
31
|
+
/**
|
|
32
|
+
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
33
|
+
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
34
|
+
* @returns The deployed contract instance.
|
|
35
|
+
*/
|
|
36
|
+
deployed(opts?: DeployedWaitOpts): Promise<TContract>;
|
|
37
|
+
/**
|
|
38
|
+
* Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
|
|
39
|
+
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
40
|
+
* @returns The transaction receipt with the deployed contract instance.
|
|
41
|
+
*/
|
|
42
|
+
wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>>;
|
|
43
|
+
protected getContractObject(wallet?: Wallet): Promise<TContract>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=deploy_sent_tx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy_sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_sent_tx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAa,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KA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