@aztec/aztec.js 0.0.0-test.1 → 0.0.1-commit.b655e406
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 +1 -1
- package/dest/account/account.d.ts +60 -0
- package/dest/account/account.d.ts.map +1 -0
- package/dest/account/account.js +59 -0
- package/dest/account/{contract.d.ts → account_contract.d.ts} +16 -10
- package/dest/account/account_contract.d.ts.map +1 -0
- package/dest/account/{contract.js → account_contract.js} +7 -4
- package/dest/{wallet/account_wallet_with_private_key.d.ts → account/account_with_secret_key.d.ts} +7 -8
- package/dest/account/account_with_secret_key.d.ts.map +1 -0
- package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
- package/dest/account/index.d.ts +3 -7
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -6
- package/dest/account/interface.d.ts +1 -13
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/interface.js +1 -0
- package/dest/account/signerless_account.d.ts +24 -0
- package/dest/account/signerless_account.d.ts.map +1 -0
- package/dest/account/signerless_account.js +27 -0
- package/dest/api/abi.d.ts +2 -1
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/abi.js +1 -1
- package/dest/api/account.d.ts +5 -2
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +3 -1
- package/dest/api/addresses.d.ts +1 -0
- package/dest/api/addresses.d.ts.map +1 -1
- package/dest/api/addresses.js +1 -0
- package/dest/api/authorization.d.ts +5 -0
- package/dest/api/authorization.d.ts.map +1 -0
- package/dest/api/authorization.js +4 -0
- package/dest/api/block.d.ts +3 -0
- package/dest/api/block.d.ts.map +1 -0
- package/dest/api/block.js +2 -0
- package/dest/{contract/index.d.ts → api/contract.d.ts} +15 -11
- package/dest/api/contract.d.ts.map +1 -0
- package/dest/{contract/index.js → api/contract.js} +14 -10
- package/dest/api/crypto.d.ts +2 -0
- package/dest/api/crypto.d.ts.map +1 -0
- package/dest/api/crypto.js +1 -0
- package/dest/api/deployment.d.ts +4 -3
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +4 -3
- package/dest/api/ethereum.d.ts +2 -0
- package/dest/api/ethereum.d.ts.map +1 -0
- package/dest/api/ethereum.js +1 -0
- package/dest/api/events.d.ts +12 -0
- package/dest/api/events.d.ts.map +1 -0
- package/dest/api/events.js +30 -0
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +1 -1
- package/dest/api/fee_testing.d.ts +2 -0
- package/dest/api/fee_testing.d.ts.map +1 -0
- package/dest/api/fee_testing.js +1 -0
- package/dest/api/keys.d.ts +4 -0
- package/dest/api/keys.d.ts.map +1 -0
- package/dest/api/keys.js +3 -0
- package/dest/api/log.d.ts +1 -0
- package/dest/api/log.d.ts.map +1 -1
- package/dest/api/log.js +1 -0
- package/dest/api/messaging.d.ts +3 -0
- package/dest/api/messaging.d.ts.map +1 -0
- package/dest/api/messaging.js +2 -0
- package/dest/api/node.d.ts +21 -0
- package/dest/api/node.d.ts.map +1 -0
- package/dest/api/node.js +18 -0
- package/dest/api/note.d.ts +2 -0
- package/dest/api/note.d.ts.map +1 -0
- package/dest/api/note.js +1 -0
- package/dest/api/protocol.d.ts +3 -0
- package/dest/api/protocol.d.ts.map +1 -0
- package/dest/api/protocol.js +2 -0
- package/dest/api/trees.d.ts +3 -0
- package/dest/api/trees.d.ts.map +1 -0
- package/dest/api/trees.js +2 -0
- package/dest/api/tx.d.ts +2 -0
- package/dest/api/tx.d.ts.map +1 -0
- package/dest/api/tx.js +1 -0
- package/dest/api/utils.d.ts +13 -0
- package/dest/api/utils.d.ts.map +1 -0
- package/dest/api/utils.js +12 -0
- package/dest/api/wallet.d.ts +4 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +4 -1
- package/dest/authorization/call_authorization_request.d.ts +67 -0
- package/dest/authorization/call_authorization_request.d.ts.map +1 -0
- package/dest/authorization/call_authorization_request.js +49 -0
- package/dest/contract/base_contract_interaction.d.ts +16 -79
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +15 -128
- package/dest/contract/batch_call.d.ts +13 -14
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +60 -60
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/checker.d.ts.map +1 -1
- package/dest/contract/checker.js +2 -2
- package/dest/contract/contract.d.ts +7 -6
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +7 -16
- package/dest/contract/contract_base.d.ts +3 -9
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +2 -2
- package/dest/contract/contract_function_interaction.d.ts +52 -44
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +75 -74
- package/dest/contract/deploy_method.d.ts +102 -57
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +122 -132
- package/dest/contract/deploy_sent_tx.d.ts +3 -5
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +10 -13
- package/dest/contract/get_gas_limits.d.ts +5 -6
- package/dest/contract/get_gas_limits.d.ts.map +1 -1
- package/dest/contract/get_gas_limits.js +9 -3
- package/dest/contract/interaction_options.d.ts +114 -0
- package/dest/contract/interaction_options.d.ts.map +1 -0
- package/dest/contract/interaction_options.js +52 -0
- package/dest/contract/protocol_contracts.d.ts +6 -6
- package/dest/contract/protocol_contracts.d.ts.map +1 -1
- package/dest/contract/protocol_contracts.js +7 -7
- package/dest/contract/sent_tx.d.ts +8 -18
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +30 -42
- package/dest/contract/unsafe_contract.d.ts +1 -1
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.d.ts +17 -0
- package/dest/contract/wait_for_proven.d.ts.map +1 -0
- package/dest/contract/wait_for_proven.js +17 -0
- package/dest/deployment/broadcast_function.d.ts +3 -3
- package/dest/deployment/broadcast_function.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.js +27 -23
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/publish_class.d.ts +6 -0
- package/dest/deployment/publish_class.d.ts.map +1 -0
- package/dest/deployment/publish_class.js +17 -0
- package/dest/deployment/publish_instance.d.ts +10 -0
- package/dest/deployment/publish_instance.d.ts.map +1 -0
- package/dest/deployment/publish_instance.js +11 -0
- package/dest/{api/ethereum → ethereum}/portal_manager.d.ts +29 -25
- package/dest/ethereum/portal_manager.d.ts.map +1 -0
- package/dest/{api/ethereum → ethereum}/portal_manager.js +106 -73
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +16 -11
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +26 -16
- package/dest/fee/fee_payment_method.d.ts +11 -7
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +25 -8
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +43 -21
- package/dest/fee/public_fee_payment_method.d.ts +26 -9
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +45 -23
- package/dest/fee/sponsored_fee_payment.d.ts +17 -0
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -0
- package/dest/fee/sponsored_fee_payment.js +34 -0
- package/dest/utils/abi_types.d.ts +0 -2
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +81 -24
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +226 -40
- package/dest/utils/cross_chain.d.ts +24 -0
- package/dest/utils/cross_chain.d.ts.map +1 -0
- package/dest/utils/cross_chain.js +30 -0
- package/dest/utils/fee_juice.d.ts +3 -2
- package/dest/utils/fee_juice.d.ts.map +1 -1
- package/dest/utils/fee_juice.js +3 -2
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +1 -1
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +1 -2
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +34 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
- package/dest/wallet/account_manager.d.ts +69 -0
- package/dest/wallet/account_manager.d.ts.map +1 -0
- package/dest/wallet/account_manager.js +113 -0
- package/dest/wallet/base_wallet.d.ts +81 -63
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +221 -106
- package/dest/wallet/deploy_account_method.d.ts +52 -0
- package/dest/wallet/deploy_account_method.d.ts.map +1 -0
- package/dest/wallet/deploy_account_method.js +77 -0
- package/dest/wallet/index.d.ts +3 -16
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +3 -20
- package/dest/wallet/wallet.d.ts +2478 -0
- package/dest/wallet/wallet.d.ts.map +1 -0
- package/dest/wallet/wallet.js +202 -0
- package/package.json +40 -32
- package/src/account/account.ts +97 -0
- package/src/account/{contract.ts → account_contract.ts} +24 -13
- package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +6 -8
- package/src/account/index.ts +3 -7
- package/src/account/interface.ts +1 -12
- package/src/account/signerless_account.ts +46 -0
- package/src/api/abi.ts +26 -0
- package/src/api/account.ts +5 -9
- package/src/api/addresses.ts +1 -0
- package/src/api/authorization.ts +14 -0
- package/src/api/block.ts +2 -0
- package/src/{contract/index.ts → api/contract.ts} +37 -13
- package/src/api/crypto.ts +1 -0
- package/src/api/deployment.ts +4 -3
- package/src/api/ethereum.ts +10 -0
- package/src/api/events.ts +44 -0
- package/src/api/fee.ts +1 -1
- package/src/api/fee_testing.ts +1 -0
- package/src/api/keys.ts +8 -0
- package/src/api/log.ts +1 -0
- package/src/api/messaging.ts +2 -0
- package/src/api/node.ts +20 -0
- package/src/api/note.ts +1 -0
- package/src/api/protocol.ts +2 -0
- package/src/api/trees.ts +2 -0
- package/src/api/tx.ts +11 -0
- package/src/api/utils.ts +14 -0
- package/src/api/wallet.ts +33 -5
- package/src/authorization/call_authorization_request.ts +63 -0
- package/src/contract/base_contract_interaction.ts +24 -166
- package/src/contract/batch_call.ts +81 -49
- package/src/contract/checker.ts +8 -3
- package/src/contract/contract.ts +8 -17
- package/src/contract/contract_base.ts +4 -11
- package/src/contract/contract_function_interaction.ts +136 -106
- package/src/contract/deploy_method.ts +199 -129
- package/src/contract/deploy_sent_tx.ts +9 -15
- package/src/contract/get_gas_limits.ts +15 -8
- package/src/contract/interaction_options.ts +169 -0
- package/src/contract/protocol_contracts.ts +10 -10
- package/src/contract/sent_tx.ts +40 -51
- package/src/contract/unsafe_contract.ts +1 -1
- package/src/contract/wait_for_proven.ts +38 -0
- package/src/deployment/broadcast_function.ts +57 -57
- package/src/deployment/contract_deployer.ts +1 -1
- package/src/deployment/publish_class.ts +34 -0
- package/src/deployment/publish_instance.ts +26 -0
- package/src/{api/ethereum → ethereum}/portal_manager.ts +120 -74
- package/src/fee/fee_juice_payment_method_with_claim.ts +46 -33
- package/src/fee/fee_payment_method.ts +11 -7
- package/src/fee/private_fee_payment_method.ts +77 -57
- package/src/fee/public_fee_payment_method.ts +91 -67
- package/src/fee/sponsored_fee_payment.ts +44 -0
- package/src/utils/authwit.ts +255 -53
- package/src/utils/cross_chain.ts +53 -0
- package/src/utils/fee_juice.ts +4 -4
- package/src/utils/node.ts +1 -1
- package/src/utils/pub_key.ts +1 -2
- package/src/wallet/account_entrypoint_meta_payment_method.ts +105 -0
- package/src/wallet/account_manager.ts +154 -0
- package/src/wallet/base_wallet.ts +295 -143
- package/src/wallet/deploy_account_method.ts +125 -0
- package/src/wallet/index.ts +3 -33
- package/src/wallet/wallet.ts +362 -0
- package/dest/account/contract.d.ts.map +0 -1
- package/dest/account/wallet.d.ts +0 -11
- package/dest/account/wallet.d.ts.map +0 -1
- package/dest/account/wallet.js +0 -3
- package/dest/account_manager/deploy_account_method.d.ts +0 -15
- package/dest/account_manager/deploy_account_method.d.ts.map +0 -1
- package/dest/account_manager/deploy_account_method.js +0 -43
- package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
- package/dest/account_manager/deploy_account_sent_tx.js +0 -29
- package/dest/account_manager/index.d.ts +0 -108
- package/dest/account_manager/index.d.ts.map +0 -1
- package/dest/account_manager/index.js +0 -159
- package/dest/api/cheat_codes.d.ts +0 -26
- package/dest/api/cheat_codes.d.ts.map +0 -1
- package/dest/api/cheat_codes.js +0 -25
- package/dest/api/entrypoint.d.ts +0 -2
- package/dest/api/entrypoint.d.ts.map +0 -1
- package/dest/api/entrypoint.js +0 -1
- package/dest/api/ethereum/anvil_test_watcher.d.ts +0 -32
- package/dest/api/ethereum/anvil_test_watcher.d.ts.map +0 -1
- package/dest/api/ethereum/anvil_test_watcher.js +0 -133
- package/dest/api/ethereum/chain_monitor.d.ts +0 -25
- package/dest/api/ethereum/chain_monitor.d.ts.map +0 -1
- package/dest/api/ethereum/chain_monitor.js +0 -74
- package/dest/api/ethereum/cheat_codes.d.ts +0 -63
- package/dest/api/ethereum/cheat_codes.d.ts.map +0 -1
- package/dest/api/ethereum/cheat_codes.js +0 -162
- package/dest/api/ethereum/index.d.ts +0 -7
- package/dest/api/ethereum/index.d.ts.map +0 -1
- package/dest/api/ethereum/index.js +0 -6
- package/dest/api/ethereum/l1_contracts.d.ts +0 -3
- package/dest/api/ethereum/l1_contracts.d.ts.map +0 -1
- package/dest/api/ethereum/l1_contracts.js +0 -13
- package/dest/api/ethereum/portal_manager.d.ts.map +0 -1
- package/dest/api/interfaces/pxe.d.ts +0 -2
- package/dest/api/interfaces/pxe.d.ts.map +0 -1
- package/dest/api/interfaces/pxe.js +0 -1
- package/dest/api/log_id.d.ts +0 -2
- package/dest/api/log_id.d.ts.map +0 -1
- package/dest/api/log_id.js +0 -1
- package/dest/api/tx_hash.d.ts +0 -2
- package/dest/api/tx_hash.d.ts.map +0 -1
- package/dest/api/tx_hash.js +0 -1
- package/dest/contract/deploy_proven_tx.d.ts +0 -21
- package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
- package/dest/contract/deploy_proven_tx.js +0 -19
- package/dest/contract/index.d.ts.map +0 -1
- package/dest/contract/proven_tx.d.ts +0 -17
- package/dest/contract/proven_tx.d.ts.map +0 -1
- package/dest/contract/proven_tx.js +0 -22
- package/dest/deployment/deploy_instance.d.ts +0 -10
- package/dest/deployment/deploy_instance.d.ts.map +0 -1
- package/dest/deployment/deploy_instance.js +0 -14
- package/dest/deployment/index.d.ts +0 -2
- package/dest/deployment/index.d.ts.map +0 -1
- package/dest/deployment/index.js +0 -1
- package/dest/deployment/register_class.d.ts +0 -6
- package/dest/deployment/register_class.d.ts.map +0 -1
- package/dest/deployment/register_class.js +0 -22
- package/dest/entrypoint/default_entrypoint.d.ts +0 -12
- package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/default_entrypoint.js +0 -28
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +0 -15
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +0 -130
- package/dest/entrypoint/entrypoint.d.ts +0 -35
- package/dest/entrypoint/entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/entrypoint.js +0 -4
- package/dest/entrypoint/payload.d.ts +0 -128
- package/dest/entrypoint/payload.d.ts.map +0 -1
- package/dest/entrypoint/payload.js +0 -143
- package/dest/fee/fee_juice_payment_method.d.ts +0 -14
- package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
- package/dest/fee/fee_juice_payment_method.js +0 -20
- package/dest/index.d.ts +0 -66
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -69
- package/dest/rpc_clients/index.d.ts +0 -3
- package/dest/rpc_clients/index.d.ts.map +0 -1
- package/dest/rpc_clients/index.js +0 -2
- package/dest/rpc_clients/node/index.d.ts +0 -12
- package/dest/rpc_clients/node/index.d.ts.map +0 -1
- package/dest/rpc_clients/node/index.js +0 -78
- package/dest/rpc_clients/pxe_client.d.ts +0 -10
- package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
- package/dest/rpc_clients/pxe_client.js +0 -23
- package/dest/utils/aztec_cheatcodes.d.ts +0 -59
- package/dest/utils/aztec_cheatcodes.d.ts.map +0 -1
- package/dest/utils/aztec_cheatcodes.js +0 -62
- package/dest/utils/index.d.ts +0 -8
- package/dest/utils/index.d.ts.map +0 -1
- package/dest/utils/index.js +0 -6
- package/dest/utils/pxe.d.ts +0 -4
- package/dest/utils/pxe.d.ts.map +0 -1
- package/dest/utils/pxe.js +0 -14
- package/dest/wallet/account_wallet.d.ts +0 -76
- package/dest/wallet/account_wallet.d.ts.map +0 -1
- package/dest/wallet/account_wallet.js +0 -231
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.d.ts +0 -25
- package/dest/wallet/signerless_wallet.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.js +0 -36
- package/src/account/wallet.ts +0 -13
- package/src/account_manager/deploy_account_method.ts +0 -86
- package/src/account_manager/deploy_account_sent_tx.ts +0 -42
- package/src/account_manager/index.ts +0 -229
- package/src/api/cheat_codes.ts +0 -35
- package/src/api/entrypoint.ts +0 -1
- package/src/api/ethereum/anvil_test_watcher.ts +0 -158
- package/src/api/ethereum/chain_monitor.ts +0 -88
- package/src/api/ethereum/cheat_codes.ts +0 -184
- package/src/api/ethereum/index.ts +0 -19
- package/src/api/ethereum/l1_contracts.ts +0 -21
- package/src/api/interfaces/pxe.ts +0 -1
- package/src/api/log_id.ts +0 -1
- package/src/api/tx_hash.ts +0 -1
- package/src/contract/deploy_proven_tx.ts +0 -34
- package/src/contract/proven_tx.ts +0 -42
- package/src/deployment/deploy_instance.ts +0 -31
- package/src/deployment/index.ts +0 -1
- package/src/deployment/register_class.ts +0 -44
- package/src/entrypoint/default_entrypoint.ts +0 -39
- package/src/entrypoint/default_multi_call_entrypoint.ts +0 -93
- package/src/entrypoint/entrypoint.ts +0 -39
- package/src/entrypoint/payload.ts +0 -238
- package/src/fee/fee_juice_payment_method.ts +0 -26
- package/src/index.ts +0 -106
- package/src/rpc_clients/index.ts +0 -2
- package/src/rpc_clients/node/index.ts +0 -77
- package/src/rpc_clients/pxe_client.ts +0 -25
- package/src/utils/aztec_cheatcodes.ts +0 -77
- package/src/utils/index.ts +0 -21
- package/src/utils/pxe.ts +0 -17
- package/src/wallet/account_wallet.ts +0 -242
- package/src/wallet/signerless_wallet.ts +0 -52
|
@@ -1,17 +1,27 @@
|
|
|
1
|
+
import { mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
1
3
|
import { getInitializer } from '@aztec/stdlib/abi';
|
|
2
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import { computePartialAddress, getContractClassFromArtifact,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { computePartialAddress, getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
6
|
+
import { collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
7
|
+
import { publishContractClass } from '../deployment/publish_class.js';
|
|
8
|
+
import { publishInstance } from '../deployment/publish_instance.js';
|
|
6
9
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
7
10
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
8
|
-
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
9
11
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
import { getGasLimits } from './get_gas_limits.js';
|
|
13
|
+
import { toProfileOptions, toSendOptions, toSimulateOptions } from './interaction_options.js';
|
|
12
14
|
/**
|
|
13
|
-
* Contract interaction for deployment.
|
|
14
|
-
* and initialization of the contract.
|
|
15
|
+
* Contract interaction for deployment.
|
|
16
|
+
* Handles class publication, instance publication, and initialization of the contract.
|
|
17
|
+
*
|
|
18
|
+
* Note that for some contracts, a tx is not required as part of its "creation":
|
|
19
|
+
* If there are no public functions, and if there are no initialization functions,
|
|
20
|
+
* then technically the contract has already been "created", and all of the contract's
|
|
21
|
+
* functions (private and utility) can be interacted-with immediately, without any
|
|
22
|
+
* "deployment tx".
|
|
23
|
+
*
|
|
24
|
+
* Extends the BaseContractInteraction class.
|
|
15
25
|
*/ export class DeployMethod extends BaseContractInteraction {
|
|
16
26
|
publicKeys;
|
|
17
27
|
artifact;
|
|
@@ -19,99 +29,55 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
19
29
|
args;
|
|
20
30
|
/** The contract instance to be deployed. */ instance;
|
|
21
31
|
/** 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;
|
|
32
|
+
constructor(publicKeys, wallet, artifact, postDeployCtor, args = [], constructorNameOrArtifact, authWitnesses = [], capsules = []){
|
|
33
|
+
super(wallet, authWitnesses, capsules), this.publicKeys = publicKeys, this.artifact = artifact, this.postDeployCtor = postDeployCtor, this.args = args, this.instance = undefined;
|
|
24
34
|
this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact);
|
|
25
35
|
}
|
|
26
36
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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}`);
|
|
37
|
+
* Returns the execution payload that allows this operation to happen on chain.
|
|
38
|
+
* @param options - Configuration options.
|
|
39
|
+
* @returns The execution payload for this operation
|
|
40
|
+
*/ async request(options) {
|
|
41
|
+
const publication = await this.getPublicationExecutionPayload(options);
|
|
42
|
+
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
43
|
+
const initialization = await this.getInitializationExecutionPayload(options);
|
|
44
|
+
const feeExecutionPayload = options?.fee?.paymentMethod ? await options.fee.paymentMethod.getExecutionPayload() : undefined;
|
|
45
|
+
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
46
|
+
feeExecutionPayload,
|
|
47
|
+
publication,
|
|
48
|
+
initialization
|
|
49
|
+
]) : mergeExecutionPayloads([
|
|
50
|
+
publication,
|
|
51
|
+
initialization
|
|
52
|
+
]);
|
|
53
|
+
if (!finalExecutionPayload.calls.length) {
|
|
54
|
+
throw new Error(`No transactions are needed to publish or initialize contract ${this.artifact.name}`);
|
|
64
55
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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);
|
|
56
|
+
return finalExecutionPayload;
|
|
57
|
+
}
|
|
58
|
+
convertDeployOptionsToRequestOptions(options) {
|
|
92
59
|
return {
|
|
93
|
-
...
|
|
94
|
-
|
|
60
|
+
...options,
|
|
61
|
+
deployer: !options?.universalDeploy ? options.from : undefined
|
|
95
62
|
};
|
|
96
63
|
}
|
|
97
64
|
/**
|
|
98
|
-
*
|
|
65
|
+
* Adds this contract to the wallet and returns the Contract object.
|
|
99
66
|
* @param options - Deployment options.
|
|
100
|
-
*/ async register(options
|
|
67
|
+
*/ async register(options) {
|
|
101
68
|
const instance = await this.getInstance(options);
|
|
102
|
-
await this.wallet.registerContract(
|
|
103
|
-
artifact: this.artifact,
|
|
104
|
-
instance
|
|
105
|
-
});
|
|
69
|
+
await this.wallet.registerContract(instance, this.artifact);
|
|
106
70
|
return this.postDeployCtor(instance.address, this.wallet);
|
|
107
71
|
}
|
|
108
72
|
/**
|
|
109
|
-
* Returns
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
|
|
73
|
+
* Returns an execution payload for:
|
|
74
|
+
* - publication of the contract class and
|
|
75
|
+
* - publication of the contract instance to enable public execution
|
|
76
|
+
* depending on the provided options.
|
|
77
|
+
* @param options - Contract creation options.
|
|
78
|
+
* @returns An execution payload with potentially calls (and bytecode capsule) to the class registry and instance registry.
|
|
79
|
+
*/ async getPublicationExecutionPayload(options) {
|
|
113
80
|
const calls = [];
|
|
114
|
-
const capsules = [];
|
|
115
81
|
// Set contract instance object so it's available for populating the DeploySendTx object
|
|
116
82
|
const instance = await this.getInstance(options);
|
|
117
83
|
// Obtain contract class from artifact and check it matches the reported one by the instance.
|
|
@@ -120,88 +86,105 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
120
86
|
if (!instance.currentContractClassId.equals(contractClass.id)) {
|
|
121
87
|
throw new Error(`Contract class mismatch when deploying contract: got ${instance.currentContractClassId.toString()} from instance and ${contractClass.id.toString()} from artifact`);
|
|
122
88
|
}
|
|
123
|
-
//
|
|
124
|
-
if (!options
|
|
89
|
+
// Publish the contract class if it hasn't been published already.
|
|
90
|
+
if (!options?.skipClassPublication) {
|
|
125
91
|
if ((await this.wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
126
|
-
this.log.debug(`Skipping
|
|
92
|
+
this.log.debug(`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`);
|
|
127
93
|
} else {
|
|
128
|
-
this.log.info(`Creating request for
|
|
129
|
-
const registerContractClassInteraction = await
|
|
94
|
+
this.log.info(`Creating request for publishing contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`);
|
|
95
|
+
const registerContractClassInteraction = await publishContractClass(this.wallet, this.artifact);
|
|
130
96
|
calls.push(await registerContractClassInteraction.request());
|
|
131
|
-
capsules.push(...registerContractClassInteraction.getCapsules());
|
|
132
97
|
}
|
|
133
98
|
}
|
|
134
|
-
//
|
|
135
|
-
if (!options
|
|
136
|
-
|
|
99
|
+
// Publish the contract instance:
|
|
100
|
+
if (!options?.skipInstancePublication) {
|
|
101
|
+
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
|
|
102
|
+
// Read the artifact, and if there are no public functions, warn the caller that publication of the
|
|
103
|
+
// contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
|
|
104
|
+
const deploymentInteraction = await publishInstance(this.wallet, instance);
|
|
137
105
|
calls.push(await deploymentInteraction.request());
|
|
138
|
-
capsules.push(...deploymentInteraction.getCapsules());
|
|
139
106
|
}
|
|
140
|
-
return
|
|
141
|
-
calls,
|
|
142
|
-
capsules
|
|
143
|
-
};
|
|
107
|
+
return mergeExecutionPayloads(calls);
|
|
144
108
|
}
|
|
145
109
|
/**
|
|
146
110
|
* Returns the calls necessary to initialize the contract.
|
|
147
111
|
* @param options - Deployment options.
|
|
148
112
|
* @returns - An array of function calls.
|
|
149
|
-
*/ async
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (this.constructorArtifact && !options.skipInitialization) {
|
|
113
|
+
*/ async getInitializationExecutionPayload(options) {
|
|
114
|
+
const executionsPayloads = [];
|
|
115
|
+
if (this.constructorArtifact && !options?.skipInitialization) {
|
|
116
|
+
const { address } = await this.getInstance(options);
|
|
154
117
|
const constructorCall = new ContractFunctionInteraction(this.wallet, address, this.constructorArtifact, this.args);
|
|
155
|
-
|
|
156
|
-
capsules.push(...constructorCall.getCapsules());
|
|
118
|
+
executionsPayloads.push(await constructorCall.request());
|
|
157
119
|
}
|
|
158
|
-
return
|
|
159
|
-
calls,
|
|
160
|
-
capsules
|
|
161
|
-
};
|
|
120
|
+
return mergeExecutionPayloads(executionsPayloads);
|
|
162
121
|
}
|
|
163
122
|
/**
|
|
164
|
-
* Send
|
|
123
|
+
* Send a contract deployment transaction (initialize and/or publish) using the provided options.
|
|
165
124
|
* This function extends the 'send' method from the ContractFunctionInteraction class,
|
|
166
125
|
* allowing us to send a transaction specifically for contract deployment.
|
|
167
126
|
*
|
|
168
127
|
* @param options - An object containing various deployment options such as contractAddressSalt and from.
|
|
169
128
|
* @returns A SentTx object that returns the receipt and the deployed contract instance.
|
|
170
|
-
*/ send(options
|
|
171
|
-
const
|
|
129
|
+
*/ send(options) {
|
|
130
|
+
const sendTx = async ()=>{
|
|
131
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
132
|
+
const sendOptions = await toSendOptions(options);
|
|
133
|
+
return this.wallet.sendTx(executionPayload, sendOptions);
|
|
134
|
+
};
|
|
172
135
|
this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
|
|
173
|
-
return new DeploySentTx(this.wallet,
|
|
136
|
+
return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, ()=>this.getInstance(options));
|
|
174
137
|
}
|
|
175
138
|
/**
|
|
176
|
-
* Builds the contract instance
|
|
139
|
+
* Builds the contract instance and returns it.
|
|
177
140
|
*
|
|
178
|
-
* @param options - An object containing various
|
|
141
|
+
* @param options - An object containing various initialization and publication options.
|
|
179
142
|
* @returns An instance object.
|
|
180
|
-
*/ async getInstance(options
|
|
143
|
+
*/ async getInstance(options) {
|
|
181
144
|
if (!this.instance) {
|
|
182
|
-
this.instance = await
|
|
145
|
+
this.instance = await getContractInstanceFromInstantiationParams(this.artifact, {
|
|
183
146
|
constructorArgs: this.args,
|
|
184
|
-
salt: options.
|
|
147
|
+
salt: options?.contractAddressSalt ?? Fr.random(),
|
|
185
148
|
publicKeys: this.publicKeys,
|
|
186
149
|
constructorArtifact: this.constructorArtifact,
|
|
187
|
-
deployer: options
|
|
150
|
+
deployer: options?.deployer ? options.deployer : AztecAddress.ZERO
|
|
188
151
|
});
|
|
189
152
|
}
|
|
190
153
|
return this.instance;
|
|
191
154
|
}
|
|
192
155
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* @
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
156
|
+
* Simulate the deployment
|
|
157
|
+
*
|
|
158
|
+
* @param options - An optional object containing additional configuration for the simulation.
|
|
159
|
+
* @returns A simulation result object containing metadata of the execution, including gas
|
|
160
|
+
* estimations (if requested via options), execution statistics and emitted offchain effects
|
|
161
|
+
*/ async simulate(options) {
|
|
162
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
163
|
+
const simulatedTx = await this.wallet.simulateTx(executionPayload, await toSimulateOptions(options));
|
|
164
|
+
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
165
|
+
this.log.verbose(`Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`);
|
|
166
|
+
return {
|
|
167
|
+
stats: simulatedTx.stats,
|
|
168
|
+
offchainEffects: collectOffchainEffects(simulatedTx.privateExecutionResult),
|
|
169
|
+
result: undefined,
|
|
170
|
+
estimatedGas: {
|
|
171
|
+
gasLimits,
|
|
172
|
+
teardownGasLimits
|
|
173
|
+
}
|
|
174
|
+
};
|
|
199
175
|
}
|
|
200
176
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @param options -
|
|
203
|
-
|
|
204
|
-
|
|
177
|
+
* Simulate a deployment and profile the gate count for each function in the transaction.
|
|
178
|
+
* @param options - Same options as `send`, plus extra profiling options.
|
|
179
|
+
*
|
|
180
|
+
* @returns An object containing the function return value and profile result.
|
|
181
|
+
*/ async profile(options) {
|
|
182
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
183
|
+
return await this.wallet.profileTx(executionPayload, {
|
|
184
|
+
...await toProfileOptions(options),
|
|
185
|
+
profileMode: options.profileMode,
|
|
186
|
+
skipProofGeneration: options.skipProofGeneration
|
|
187
|
+
});
|
|
205
188
|
}
|
|
206
189
|
/** Return this deployment address. */ get address() {
|
|
207
190
|
return this.instance?.address;
|
|
@@ -209,4 +192,11 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
209
192
|
/** Returns the partial address for this deployment. */ get partialAddress() {
|
|
210
193
|
return this.instance && computePartialAddress(this.instance);
|
|
211
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Augments this DeployMethod with additional metadata, such as authWitnesses and capsules.
|
|
197
|
+
* @param options - An object containing the metadata to add to the interaction
|
|
198
|
+
* @returns A new DeployMethod with the added metadata, but calling the same original function in the same manner
|
|
199
|
+
*/ with({ authWitnesses = [], capsules = [] }) {
|
|
200
|
+
return new DeployMethod(this.publicKeys, this.wallet, this.artifact, this.postDeployCtor, this.args, this.constructorArtifact?.name, this.authWitnesses.concat(authWitnesses), this.capsules.concat(capsules));
|
|
201
|
+
}
|
|
212
202
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
4
|
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
6
|
-
import type { Wallet } from '../
|
|
5
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
7
6
|
import type { Contract } from './contract.js';
|
|
8
7
|
import type { ContractBase } from './contract_base.js';
|
|
9
8
|
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
@@ -18,14 +17,14 @@ export type DeployTxReceipt<TContract extends ContractBase = Contract> = FieldsO
|
|
|
18
17
|
contract: TContract;
|
|
19
18
|
};
|
|
20
19
|
/**
|
|
21
|
-
* A contract deployment transaction sent to the network, extending SentTx with methods to
|
|
20
|
+
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
22
21
|
*/
|
|
23
22
|
export declare class DeploySentTx<TContract extends Contract = Contract> extends SentTx {
|
|
24
23
|
private postDeployCtor;
|
|
25
24
|
/** A getter for the deployed contract instance */
|
|
26
25
|
instanceGetter: () => Promise<ContractInstanceWithAddress>;
|
|
27
26
|
private log;
|
|
28
|
-
constructor(
|
|
27
|
+
constructor(wallet: Wallet, sendTx: () => Promise<TxHash>, postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
|
|
29
28
|
/** A getter for the deployed contract instance */
|
|
30
29
|
instanceGetter: () => Promise<ContractInstanceWithAddress>);
|
|
31
30
|
/**
|
|
@@ -40,6 +39,5 @@ export declare class DeploySentTx<TContract extends Contract = Contract> extends
|
|
|
40
39
|
* @returns The transaction receipt with the deployed contract instance.
|
|
41
40
|
*/
|
|
42
41
|
wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>>;
|
|
43
|
-
protected getContractObject(wallet?: Wallet): Promise<TContract>;
|
|
44
42
|
}
|
|
45
43
|
//# sourceMappingURL=deploy_sent_tx.d.ts.map
|
|
@@ -1 +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,
|
|
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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,CAAC;IAOlE;;;;OAIG;IACmB,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;CAWzF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { SentTx } from './sent_tx.js';
|
|
3
3
|
/**
|
|
4
|
-
* A contract deployment transaction sent to the network, extending SentTx with methods to
|
|
4
|
+
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
5
5
|
*/ export class DeploySentTx extends SentTx {
|
|
6
6
|
postDeployCtor;
|
|
7
7
|
instanceGetter;
|
|
8
8
|
log;
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
9
|
+
constructor(wallet, sendTx, postDeployCtor, /** A getter for the deployed contract instance */ instanceGetter){
|
|
10
|
+
super(wallet, sendTx), this.postDeployCtor = postDeployCtor, this.instanceGetter = instanceGetter, this.log = createLogger('aztecjs:deploy_sent_tx');
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
@@ -25,19 +25,16 @@ import { SentTx } from './sent_tx.js';
|
|
|
25
25
|
* @returns The transaction receipt with the deployed contract instance.
|
|
26
26
|
*/ async wait(opts) {
|
|
27
27
|
const receipt = await super.wait(opts);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
...receipt,
|
|
31
|
-
contract
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
async getContractObject(wallet) {
|
|
35
|
-
const isWallet = (pxeOrWallet)=>!!pxeOrWallet.createTxExecutionRequest;
|
|
36
|
-
const contractWallet = wallet ?? (isWallet(this.pxeOrNode) && this.pxeOrNode);
|
|
28
|
+
// In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
|
|
29
|
+
const contractWallet = opts?.wallet ?? this.walletOrNode;
|
|
37
30
|
if (!contractWallet) {
|
|
38
31
|
throw new Error(`A wallet is required for creating a contract instance`);
|
|
39
32
|
}
|
|
40
33
|
const instance = await this.instanceGetter();
|
|
41
|
-
|
|
34
|
+
const contract = await this.postDeployCtor(instance.address, contractWallet);
|
|
35
|
+
return {
|
|
36
|
+
...receipt,
|
|
37
|
+
contract
|
|
38
|
+
};
|
|
42
39
|
}
|
|
43
40
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
2
2
|
import type { TxSimulationResult } from '@aztec/stdlib/tx';
|
|
3
3
|
/**
|
|
4
4
|
* Returns suggested total and teardown gas limits for a simulated tx.
|
|
5
|
-
* Note that public gas usage is only accounted for if the publicOutput is present.
|
|
6
5
|
* @param pad - Percentage to pad the suggested gas limits by, (as decimal, e.g., 0.10 for 10%).
|
|
7
6
|
*/
|
|
8
7
|
export declare function getGasLimits(simulationResult: TxSimulationResult, pad?: number): {
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* Gas limit for the tx, excluding teardown gas
|
|
11
10
|
*/
|
|
12
|
-
|
|
11
|
+
gasLimits: Gas;
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Gas limit for the teardown phase
|
|
15
14
|
*/
|
|
16
|
-
|
|
15
|
+
teardownGasLimits: Gas;
|
|
17
16
|
};
|
|
18
17
|
//# sourceMappingURL=get_gas_limits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_gas_limits.d.ts","sourceRoot":"","sources":["../../src/contract/get_gas_limits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_gas_limits.d.ts","sourceRoot":"","sources":["../../src/contract/get_gas_limits.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,gBAAgB,EAAE,kBAAkB,EACpC,GAAG,SAAM,GACR;IACD;;OAEG;IACH,SAAS,EAAE,GAAG,CAAC;IACf;;OAEG;IACH,iBAAiB,EAAE,GAAG,CAAC;CACxB,CAYA"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
1
2
|
/**
|
|
2
3
|
* Returns suggested total and teardown gas limits for a simulated tx.
|
|
3
|
-
* Note that public gas usage is only accounted for if the publicOutput is present.
|
|
4
4
|
* @param pad - Percentage to pad the suggested gas limits by, (as decimal, e.g., 0.10 for 10%).
|
|
5
5
|
*/ export function getGasLimits(simulationResult, pad = 0.1) {
|
|
6
|
+
// Total gas does not use the teardown gas limit, but the actual total gas used by the tx.
|
|
7
|
+
const gasLimits = simulationResult.gasUsed.totalGas.mul(1 + pad);
|
|
8
|
+
const teardownGasLimits = simulationResult.gasUsed.teardownGas.mul(1 + pad);
|
|
9
|
+
if (gasLimits.l2Gas > AVM_MAX_PROCESSABLE_L2_GAS) {
|
|
10
|
+
throw new Error('Transaction consumes more gas than the AVM maximum processable gas');
|
|
11
|
+
}
|
|
6
12
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
gasLimits,
|
|
14
|
+
teardownGasLimits
|
|
9
15
|
};
|
|
10
16
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import type { Capsule, OffchainEffect, SimulationStats } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
7
|
+
import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Options used to tweak the simulation and add gas estimation capabilities
|
|
10
|
+
*/
|
|
11
|
+
export type FeeEstimationOptions = {
|
|
12
|
+
/** Whether to modify the fee settings of the simulation with high gas limit to figure out actual gas settings. */
|
|
13
|
+
estimateGas?: boolean;
|
|
14
|
+
/** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
|
|
15
|
+
estimatedGasPadding?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Interactions allow configuring a custom fee payment method that gets bundled with the transaction before
|
|
19
|
+
* sending it to the wallet
|
|
20
|
+
*/
|
|
21
|
+
export type FeePaymentMethodOption = {
|
|
22
|
+
/** Fee payment method to embed in the interaction */
|
|
23
|
+
paymentMethod?: FeePaymentMethod;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* User-defined partial gas settings for the interaction. This type is completely optional since
|
|
27
|
+
* the wallet will fill in the missing options
|
|
28
|
+
*/
|
|
29
|
+
export type GasSettingsOption = {
|
|
30
|
+
/** The gas settings */
|
|
31
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
32
|
+
};
|
|
33
|
+
/** Fee options as set by a user. */
|
|
34
|
+
export type InteractionFeeOptions = GasSettingsOption & FeePaymentMethodOption;
|
|
35
|
+
/** Fee options that can be set for simulation *only* */
|
|
36
|
+
export type SimulationInteractionFeeOptions = InteractionFeeOptions & FeeEstimationOptions;
|
|
37
|
+
/**
|
|
38
|
+
* Represents the options to configure a request from a contract interaction.
|
|
39
|
+
* Allows specifying additional auth witnesses and capsules to use during execution
|
|
40
|
+
*/
|
|
41
|
+
export type RequestInteractionOptions = {
|
|
42
|
+
/** Extra authwits to use during execution */
|
|
43
|
+
authWitnesses?: AuthWitness[];
|
|
44
|
+
/** Extra capsules to use during execution */
|
|
45
|
+
capsules?: Capsule[];
|
|
46
|
+
/** Fee payment method to embed in the interaction request */
|
|
47
|
+
fee?: FeePaymentMethodOption;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Represents options for calling a (constrained) function in a contract.
|
|
51
|
+
*/
|
|
52
|
+
export type SendInteractionOptions = RequestInteractionOptions & {
|
|
53
|
+
/** The sender's Aztec address. */
|
|
54
|
+
from: AztecAddress;
|
|
55
|
+
/** The fee options for the transaction. */
|
|
56
|
+
fee?: InteractionFeeOptions;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Represents the options for simulating a contract function interaction.
|
|
60
|
+
* Allows specifying the address from which the method should be called.
|
|
61
|
+
* Disregarded for simulation of public functions
|
|
62
|
+
*/
|
|
63
|
+
export type SimulateInteractionOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
64
|
+
/** The fee options for the transaction. */
|
|
65
|
+
fee?: SimulationInteractionFeeOptions;
|
|
66
|
+
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
67
|
+
skipTxValidation?: boolean;
|
|
68
|
+
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
69
|
+
skipFeeEnforcement?: boolean;
|
|
70
|
+
/** Whether to include metadata such as offchain effects and performance statistics (e.g. timing information of the different circuits and oracles) in
|
|
71
|
+
* the simulation result, instead of just the return value of the function */
|
|
72
|
+
includeMetadata?: boolean;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Represents the options for profiling an interaction.
|
|
76
|
+
*/
|
|
77
|
+
export type ProfileInteractionOptions = SimulateInteractionOptions & {
|
|
78
|
+
/** Whether to return gates information or the bytecode/witnesses. */
|
|
79
|
+
profileMode: 'gates' | 'execution-steps' | 'full';
|
|
80
|
+
/** Whether to generate a Chonk proof or not */
|
|
81
|
+
skipProofGeneration?: boolean;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Represents the result type of a simulation.
|
|
85
|
+
* By default, it will just be the return value of the simulated function
|
|
86
|
+
* If `includeMetadata` is set to true in `SimulateInteractionOptions` on the input of `simulate(...)`,
|
|
87
|
+
* it will provide extra information.
|
|
88
|
+
*/
|
|
89
|
+
export type SimulationReturn<T extends boolean | undefined> = T extends true ? {
|
|
90
|
+
/** Additional stats about the simulation */
|
|
91
|
+
stats: SimulationStats;
|
|
92
|
+
/** Offchain effects generated during the simulation */
|
|
93
|
+
offchainEffects: OffchainEffect[];
|
|
94
|
+
/** Return value of the function */
|
|
95
|
+
result: any;
|
|
96
|
+
/** Gas estimation results */
|
|
97
|
+
estimatedGas: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>;
|
|
98
|
+
} : any;
|
|
99
|
+
/**
|
|
100
|
+
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|
|
101
|
+
* SendOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
102
|
+
*/
|
|
103
|
+
export declare function toSendOptions(options: SendInteractionOptions): Promise<SendOptions>;
|
|
104
|
+
/**
|
|
105
|
+
* Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
|
|
106
|
+
* SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
107
|
+
*/
|
|
108
|
+
export declare function toSimulateOptions(options: SimulateInteractionOptions): Promise<SimulateOptions>;
|
|
109
|
+
/**
|
|
110
|
+
* Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
|
|
111
|
+
* ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
112
|
+
*/
|
|
113
|
+
export declare function toProfileOptions(options: ProfileInteractionOptions): Promise<ProfileOptions>;
|
|
114
|
+
//# sourceMappingURL=interaction_options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction_options.d.ts","sourceRoot":"","sources":["../../src/contract/interaction_options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CA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