@aztec/aztec.js 0.0.0-test.1 → 0.0.1-commit.5476d83
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 +59 -0
- package/dest/account/account.d.ts.map +1 -0
- package/dest/account/account.js +59 -0
- package/dest/account/account_contract.d.ts +43 -0
- package/dest/account/account_contract.d.ts.map +1 -0
- package/dest/account/{contract.js → account_contract.js} +7 -4
- package/dest/account/account_with_secret_key.d.ts +24 -0
- 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 +4 -8
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -6
- package/dest/account/interface.d.ts +2 -14
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/interface.js +1 -0
- package/dest/account/signerless_account.d.ts +23 -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 +3 -2
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/abi.js +1 -1
- package/dest/api/account.d.ts +7 -3
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +4 -1
- package/dest/api/addresses.d.ts +2 -1
- 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/api/contract.d.ts +49 -0
- package/dest/api/contract.d.ts.map +1 -0
- package/dest/{contract/index.js → api/contract.js} +15 -11
- 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 +5 -4
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +4 -3
- package/dest/api/eth_address.d.ts +1 -1
- 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 +2 -2
- 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/fields.d.ts +1 -1
- 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 +2 -1
- 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 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +3 -1
- package/dest/authorization/call_authorization_request.d.ts +46 -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 -80
- 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 +19 -21
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +86 -68
- package/dest/contract/checker.d.ts +2 -2
- package/dest/contract/checker.d.ts.map +1 -1
- package/dest/contract/checker.js +2 -2
- package/dest/contract/contract.d.ts +9 -8
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +10 -20
- package/dest/contract/contract_base.d.ts +7 -20
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +7 -14
- package/dest/contract/contract_function_interaction.d.ts +53 -45
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +78 -74
- package/dest/contract/deploy_method.d.ts +106 -60
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +125 -133
- package/dest/contract/deploy_sent_tx.d.ts +14 -11
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +18 -15
- package/dest/contract/get_gas_limits.d.ts +6 -7
- 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 +46 -0
- package/dest/contract/protocol_contracts.d.ts +7 -7
- 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 +9 -19
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +31 -43
- package/dest/contract/unsafe_contract.d.ts +2 -2
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/contract/unsafe_contract.js +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 +4 -4
- 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 +2 -2
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +1 -1
- package/dest/deployment/publish_class.d.ts +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/ethereum/portal_manager.d.ts +138 -0
- package/dest/ethereum/portal_manager.d.ts.map +1 -0
- package/dest/{api/ethereum → ethereum}/portal_manager.js +136 -76
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +17 -12
- 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 +12 -8
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +26 -9
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +44 -22
- package/dest/fee/public_fee_payment_method.d.ts +27 -10
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +46 -24
- 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 +1 -3
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +82 -25
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +237 -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 +4 -3
- 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 +1 -1
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/node.d.ts +2 -2
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +1 -1
- package/dest/utils/pub_key.d.ts +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 +66 -0
- package/dest/wallet/account_manager.d.ts.map +1 -0
- package/dest/wallet/account_manager.js +113 -0
- 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 -17
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +2 -20
- package/dest/wallet/wallet.d.ts +1965 -0
- package/dest/wallet/wallet.d.ts.map +1 -0
- package/dest/wallet/wallet.js +186 -0
- package/package.json +44 -35
- package/src/account/account.ts +96 -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 +45 -0
- package/src/api/abi.ts +26 -0
- package/src/api/account.ts +6 -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} +39 -14
- 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 +13 -0
- package/src/api/utils.ts +14 -0
- package/src/api/wallet.ts +27 -5
- package/src/authorization/call_authorization_request.ts +63 -0
- package/src/contract/base_contract_interaction.ts +23 -166
- package/src/contract/batch_call.ts +106 -57
- package/src/contract/checker.ts +8 -3
- package/src/contract/contract.ts +14 -21
- package/src/contract/contract_base.ts +9 -26
- package/src/contract/contract_function_interaction.ts +135 -106
- package/src/contract/deploy_method.ts +205 -134
- package/src/contract/deploy_sent_tx.ts +24 -23
- package/src/contract/get_gas_limits.ts +15 -8
- package/src/contract/interaction_options.ts +163 -0
- package/src/contract/protocol_contracts.ts +10 -10
- package/src/contract/sent_tx.ts +41 -52
- package/src/contract/unsafe_contract.ts +2 -2
- package/src/contract/wait_for_proven.ts +38 -0
- package/src/deployment/broadcast_function.ts +57 -57
- package/src/deployment/contract_deployer.ts +4 -3
- package/src/deployment/publish_class.ts +34 -0
- package/src/deployment/publish_instance.ts +26 -0
- package/src/{api/ethereum → ethereum}/portal_manager.ts +164 -83
- package/src/fee/fee_juice_payment_method_with_claim.ts +48 -33
- package/src/fee/fee_payment_method.ts +11 -7
- package/src/fee/private_fee_payment_method.ts +79 -57
- package/src/fee/public_fee_payment_method.ts +93 -67
- package/src/fee/sponsored_fee_payment.ts +46 -0
- package/src/utils/authwit.ts +261 -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 +106 -0
- package/src/wallet/account_manager.ts +154 -0
- package/src/wallet/deploy_account_method.ts +126 -0
- package/src/wallet/index.ts +2 -33
- package/src/wallet/wallet.ts +318 -0
- package/dest/account/contract.d.ts +0 -37
- 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 +0 -136
- 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 +0 -45
- 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 +0 -26
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
- package/dest/wallet/base_wallet.d.ts +0 -73
- package/dest/wallet/base_wallet.d.ts.map +0 -1
- package/dest/wallet/base_wallet.js +0 -123
- 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/base_wallet.ts +0 -198
- package/src/wallet/signerless_wallet.ts +0 -52
|
@@ -0,0 +1,163 @@
|
|
|
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
|
+
|
|
7
|
+
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
8
|
+
import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Options used to tweak the simulation and add gas estimation capabilities
|
|
12
|
+
*/
|
|
13
|
+
export type FeeEstimationOptions = {
|
|
14
|
+
/** Whether to modify the fee settings of the simulation with high gas limit to figure out actual gas settings. */
|
|
15
|
+
estimateGas?: boolean;
|
|
16
|
+
/** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
|
|
17
|
+
estimatedGasPadding?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Interactions allow configuring a custom fee payment method that gets bundled with the transaction before
|
|
22
|
+
* sending it to the wallet
|
|
23
|
+
*/
|
|
24
|
+
export type FeePaymentMethodOption = {
|
|
25
|
+
/** Fee payment method to embed in the interaction */
|
|
26
|
+
paymentMethod?: FeePaymentMethod;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* User-defined partial gas settings for the interaction. This type is completely optional since
|
|
31
|
+
* the wallet will fill in the missing options
|
|
32
|
+
*/
|
|
33
|
+
export type GasSettingsOption = {
|
|
34
|
+
/** The gas settings */
|
|
35
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Fee options as set by a user. */
|
|
39
|
+
export type InteractionFeeOptions = GasSettingsOption & FeePaymentMethodOption;
|
|
40
|
+
|
|
41
|
+
/** Fee options that can be set for simulation *only* */
|
|
42
|
+
export type SimulationInteractionFeeOptions = InteractionFeeOptions & FeeEstimationOptions;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Represents the options to configure a request from a contract interaction.
|
|
46
|
+
* Allows specifying additional auth witnesses and capsules to use during execution
|
|
47
|
+
*/
|
|
48
|
+
export type RequestInteractionOptions = {
|
|
49
|
+
/** Extra authwits to use during execution */
|
|
50
|
+
authWitnesses?: AuthWitness[];
|
|
51
|
+
/** Extra capsules to use during execution */
|
|
52
|
+
capsules?: Capsule[];
|
|
53
|
+
/** Fee payment method to embed in the interaction request */
|
|
54
|
+
fee?: FeePaymentMethodOption;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Represents options for calling a (constrained) function in a contract.
|
|
59
|
+
*/
|
|
60
|
+
export type SendInteractionOptions = RequestInteractionOptions & {
|
|
61
|
+
/** The sender's Aztec address. */
|
|
62
|
+
from: AztecAddress;
|
|
63
|
+
/** The fee options for the transaction. */
|
|
64
|
+
fee?: InteractionFeeOptions;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Represents the options for simulating a contract function interaction.
|
|
69
|
+
* Allows specifying the address from which the method should be called.
|
|
70
|
+
* Disregarded for simulation of public functions
|
|
71
|
+
*/
|
|
72
|
+
export type SimulateInteractionOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
73
|
+
/** The fee options for the transaction. */
|
|
74
|
+
fee?: SimulationInteractionFeeOptions;
|
|
75
|
+
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
76
|
+
skipTxValidation?: boolean;
|
|
77
|
+
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
78
|
+
skipFeeEnforcement?: boolean;
|
|
79
|
+
/** Whether to include metadata such as offchain effects and performance statistics (e.g. timing information of the different circuits and oracles) in
|
|
80
|
+
* the simulation result, instead of just the return value of the function */
|
|
81
|
+
includeMetadata?: boolean;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Represents the options for profiling an interaction.
|
|
86
|
+
*/
|
|
87
|
+
export type ProfileInteractionOptions = SimulateInteractionOptions & {
|
|
88
|
+
/** Whether to return gates information or the bytecode/witnesses. */
|
|
89
|
+
profileMode: 'gates' | 'execution-steps' | 'full';
|
|
90
|
+
/** Whether to generate a Chonk proof or not */
|
|
91
|
+
skipProofGeneration?: boolean;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Represents the result type of a simulation.
|
|
96
|
+
* By default, it will just be the return value of the simulated function
|
|
97
|
+
* If `includeMetadata` is set to true in `SimulateInteractionOptions` on the input of `simulate(...)`,
|
|
98
|
+
* it will provide extra information.
|
|
99
|
+
*/
|
|
100
|
+
export type SimulationReturn<T extends boolean | undefined> = T extends true
|
|
101
|
+
? {
|
|
102
|
+
/** Additional stats about the simulation */
|
|
103
|
+
stats: SimulationStats;
|
|
104
|
+
/** Offchain effects generated during the simulation */
|
|
105
|
+
offchainEffects: OffchainEffect[];
|
|
106
|
+
/** Return value of the function */
|
|
107
|
+
result: any;
|
|
108
|
+
/** Gas estimation results */
|
|
109
|
+
estimatedGas: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>;
|
|
110
|
+
}
|
|
111
|
+
: any;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|
|
115
|
+
* SendOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
116
|
+
*/
|
|
117
|
+
export function toSendOptions(options: SendInteractionOptions): SendOptions {
|
|
118
|
+
return {
|
|
119
|
+
...options,
|
|
120
|
+
fee: {
|
|
121
|
+
// If a payment method that includes gas settings was used,
|
|
122
|
+
// try to reuse as much as possible while still allowing
|
|
123
|
+
// manual override. CAREFUL: this can cause mismatches during proving
|
|
124
|
+
gasSettings: {
|
|
125
|
+
...options.fee?.paymentMethod?.getGasSettings(),
|
|
126
|
+
...options.fee?.gasSettings,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
|
|
134
|
+
* SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
135
|
+
*/
|
|
136
|
+
export function toSimulateOptions(options: SimulateInteractionOptions): SimulateOptions {
|
|
137
|
+
return {
|
|
138
|
+
...options,
|
|
139
|
+
fee: {
|
|
140
|
+
// If a payment method that includes gas settings was used,
|
|
141
|
+
// try to reuse as much as possible while still allowing
|
|
142
|
+
// manual override. CAREFUL: this can cause mismatches during proving
|
|
143
|
+
gasSettings: {
|
|
144
|
+
...options.fee?.paymentMethod?.getGasSettings(),
|
|
145
|
+
...options.fee?.gasSettings,
|
|
146
|
+
},
|
|
147
|
+
estimateGas: options.fee?.estimateGas,
|
|
148
|
+
estimatedGasPadding: options.fee?.estimatedGasPadding,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
|
|
155
|
+
* ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
156
|
+
*/
|
|
157
|
+
export function toProfileOptions(options: ProfileInteractionOptions): ProfileOptions {
|
|
158
|
+
return {
|
|
159
|
+
...toSimulateOptions(options),
|
|
160
|
+
profileMode: options.profileMode,
|
|
161
|
+
skipProofGeneration: options.skipProofGeneration,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
2
|
|
|
3
|
-
import type { Wallet } from '../wallet/
|
|
3
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
4
4
|
import { UnsafeContract } from './unsafe_contract.js';
|
|
5
5
|
|
|
6
|
-
/** Returns a Contract wrapper for the class
|
|
7
|
-
export async function
|
|
8
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.
|
|
6
|
+
/** Returns a Contract wrapper for the contract class registry. */
|
|
7
|
+
export async function getClassRegistryContract(wallet: Wallet) {
|
|
8
|
+
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractClassRegistry);
|
|
9
9
|
if (!contractInstance) {
|
|
10
|
-
throw new Error("
|
|
10
|
+
throw new Error("ContractClassRegistry is not registered in this wallet's instance");
|
|
11
11
|
}
|
|
12
12
|
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
13
13
|
|
|
14
14
|
return new UnsafeContract(contractInstance!, artifact!, wallet);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/** Returns a Contract wrapper for the instance
|
|
18
|
-
export async function
|
|
19
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.
|
|
17
|
+
/** Returns a Contract wrapper for the contract instance registry. */
|
|
18
|
+
export async function getInstanceRegistryContract(wallet: Wallet) {
|
|
19
|
+
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractInstanceRegistry);
|
|
20
20
|
if (!contractInstance) {
|
|
21
|
-
throw new Error("
|
|
21
|
+
throw new Error("ContractInstanceRegistry is not registered in this wallet's instance");
|
|
22
22
|
}
|
|
23
23
|
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
24
24
|
return new UnsafeContract(contractInstance!, artifact!, wallet);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/** Returns a Contract wrapper for the fee juice */
|
|
27
|
+
/** Returns a Contract wrapper for the fee juice contract */
|
|
28
28
|
export async function getFeeJuice(wallet: Wallet) {
|
|
29
29
|
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.FeeJuice);
|
|
30
30
|
if (!contractInstance) {
|
package/src/contract/sent_tx.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
1
2
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
3
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
|
-
import type { AztecNode
|
|
4
|
-
import {
|
|
4
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import { TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
6
|
+
|
|
7
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
5
8
|
|
|
6
9
|
/** Options related to waiting for a tx. */
|
|
7
10
|
export type WaitOpts = {
|
|
@@ -9,24 +12,16 @@ export type WaitOpts = {
|
|
|
9
12
|
ignoreDroppedReceiptsFor?: number;
|
|
10
13
|
/** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
|
|
11
14
|
timeout?: number;
|
|
12
|
-
/** The maximum time (in seconds) to wait for the transaction to be proven. Defaults to 600. */
|
|
13
|
-
provenTimeout?: number;
|
|
14
15
|
/** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
|
|
15
16
|
interval?: number;
|
|
16
|
-
/** Whether to wait for the tx to be proven. */
|
|
17
|
-
proven?: boolean;
|
|
18
|
-
/** Whether to include information useful for debugging/testing in the receipt. */
|
|
19
|
-
debug?: boolean;
|
|
20
17
|
/** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
|
|
21
18
|
dontThrowOnRevert?: boolean;
|
|
22
19
|
};
|
|
23
20
|
|
|
24
21
|
export const DefaultWaitOpts: WaitOpts = {
|
|
25
22
|
ignoreDroppedReceiptsFor: 5,
|
|
26
|
-
timeout:
|
|
27
|
-
provenTimeout: 600,
|
|
23
|
+
timeout: 300,
|
|
28
24
|
interval: 1,
|
|
29
|
-
debug: false,
|
|
30
25
|
};
|
|
31
26
|
|
|
32
27
|
/**
|
|
@@ -34,7 +29,27 @@ export const DefaultWaitOpts: WaitOpts = {
|
|
|
34
29
|
* its hash, receipt, and mining status.
|
|
35
30
|
*/
|
|
36
31
|
export class SentTx {
|
|
37
|
-
|
|
32
|
+
protected sendTxPromise: Promise<void>;
|
|
33
|
+
protected sendTxError?: Error;
|
|
34
|
+
protected txHash?: TxHash;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
protected walletOrNode: Wallet | AztecNode,
|
|
38
|
+
sendTx: () => Promise<TxHash>,
|
|
39
|
+
) {
|
|
40
|
+
const { promise, resolve } = promiseWithResolvers<void>();
|
|
41
|
+
this.sendTxPromise = promise;
|
|
42
|
+
sendTx()
|
|
43
|
+
.then(txHash => {
|
|
44
|
+
this.txHash = txHash;
|
|
45
|
+
resolve();
|
|
46
|
+
})
|
|
47
|
+
.catch(err => {
|
|
48
|
+
this.sendTxError = err;
|
|
49
|
+
// Calling resolve instead of reject here because we want to throw the error when getTxHash is called.
|
|
50
|
+
resolve();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
38
53
|
|
|
39
54
|
/**
|
|
40
55
|
* Retrieves the transaction hash of the SentTx instance.
|
|
@@ -43,8 +58,17 @@ export class SentTx {
|
|
|
43
58
|
* @returns A promise that resolves to the transaction hash of the SentTx instance.
|
|
44
59
|
* TODO(#7717): Don't throw here.
|
|
45
60
|
*/
|
|
46
|
-
public getTxHash(): Promise<TxHash> {
|
|
47
|
-
|
|
61
|
+
public async getTxHash(): Promise<TxHash> {
|
|
62
|
+
// Make sure sendTx has been resolved, which can be triggered when it returns a txHash or when it throws an error.
|
|
63
|
+
await this.sendTxPromise;
|
|
64
|
+
|
|
65
|
+
// If sendTx threw an error, throw it.
|
|
66
|
+
if (this.sendTxError) {
|
|
67
|
+
throw this.sendTxError;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// sendTx returned a txHash if it's been resolved and no error was set.
|
|
71
|
+
return Promise.resolve(this.txHash!);
|
|
48
72
|
}
|
|
49
73
|
|
|
50
74
|
/**
|
|
@@ -56,7 +80,7 @@ export class SentTx {
|
|
|
56
80
|
*/
|
|
57
81
|
public async getReceipt(): Promise<TxReceipt> {
|
|
58
82
|
const txHash = await this.getTxHash();
|
|
59
|
-
return await this.
|
|
83
|
+
return await this.walletOrNode.getTxReceipt(txHash);
|
|
60
84
|
}
|
|
61
85
|
|
|
62
86
|
/**
|
|
@@ -68,35 +92,12 @@ export class SentTx {
|
|
|
68
92
|
const receipt = await this.waitForReceipt(opts);
|
|
69
93
|
if (receipt.status !== TxStatus.SUCCESS && !opts?.dontThrowOnRevert) {
|
|
70
94
|
throw new Error(
|
|
71
|
-
`Transaction ${await this.getTxHash()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`,
|
|
95
|
+
`Transaction ${(await this.getTxHash()).toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`,
|
|
72
96
|
);
|
|
73
97
|
}
|
|
74
|
-
if (opts?.proven && receipt.blockNumber !== undefined) {
|
|
75
|
-
await this.waitForProven(receipt.blockNumber, opts);
|
|
76
|
-
}
|
|
77
|
-
if (opts?.debug) {
|
|
78
|
-
const txHash = await this.getTxHash();
|
|
79
|
-
const { data: tx } = (await this.pxeOrNode.getTxEffect(txHash))!;
|
|
80
|
-
receipt.debugInfo = {
|
|
81
|
-
noteHashes: tx.noteHashes,
|
|
82
|
-
nullifiers: tx.nullifiers,
|
|
83
|
-
publicDataWrites: tx.publicDataWrites,
|
|
84
|
-
l2ToL1Msgs: tx.l2ToL1Msgs,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
98
|
return receipt;
|
|
88
99
|
}
|
|
89
100
|
|
|
90
|
-
/**
|
|
91
|
-
* Gets public logs emitted by this tx.
|
|
92
|
-
* @remarks This function will wait for the tx to be mined if it hasn't been already.
|
|
93
|
-
* @returns The requested logs.
|
|
94
|
-
*/
|
|
95
|
-
public async getPublicLogs(): Promise<GetPublicLogsResponse> {
|
|
96
|
-
await this.wait();
|
|
97
|
-
return this.pxeOrNode.getPublicLogs({ txHash: await this.getTxHash() });
|
|
98
|
-
}
|
|
99
|
-
|
|
100
101
|
protected async waitForReceipt(opts?: WaitOpts): Promise<TxReceipt> {
|
|
101
102
|
const txHash = await this.getTxHash();
|
|
102
103
|
const startTime = Date.now();
|
|
@@ -104,7 +105,7 @@ export class SentTx {
|
|
|
104
105
|
|
|
105
106
|
return await retryUntil(
|
|
106
107
|
async () => {
|
|
107
|
-
const txReceipt = await this.
|
|
108
|
+
const txReceipt = await this.walletOrNode.getTxReceipt(txHash);
|
|
108
109
|
// If receipt is not yet available, try again
|
|
109
110
|
if (txReceipt.status === TxStatus.PENDING) {
|
|
110
111
|
return undefined;
|
|
@@ -126,16 +127,4 @@ export class SentTx {
|
|
|
126
127
|
opts?.interval ?? DefaultWaitOpts.interval,
|
|
127
128
|
);
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
-
protected async waitForProven(minedBlock: number, opts?: WaitOpts) {
|
|
131
|
-
return await retryUntil(
|
|
132
|
-
async () => {
|
|
133
|
-
const provenBlock = await this.pxeOrNode.getProvenBlockNumber();
|
|
134
|
-
return provenBlock >= minedBlock ? provenBlock : undefined;
|
|
135
|
-
},
|
|
136
|
-
'isProven',
|
|
137
|
-
opts?.provenTimeout ?? DefaultWaitOpts.provenTimeout,
|
|
138
|
-
opts?.interval ?? DefaultWaitOpts.interval,
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
130
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
3
|
|
|
4
|
-
import type { Wallet } from '../wallet/
|
|
4
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
5
5
|
import { ContractBase } from './contract_base.js';
|
|
6
6
|
|
|
7
7
|
/** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */
|
|
@@ -14,6 +14,6 @@ export class UnsafeContract extends ContractBase {
|
|
|
14
14
|
/** The wallet used for interacting with this contract. */
|
|
15
15
|
wallet: Wallet,
|
|
16
16
|
) {
|
|
17
|
-
super(instance, artifact, wallet);
|
|
17
|
+
super(instance.address, artifact, wallet);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import type { TxReceipt } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
import { DefaultWaitOpts } from './sent_tx.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options for waiting for a transaction to be proven.
|
|
9
|
+
*/
|
|
10
|
+
export type WaitForProvenOpts = {
|
|
11
|
+
/** Time to wait for the tx to be proven before timing out */
|
|
12
|
+
provenTimeout?: number;
|
|
13
|
+
/** Elapsed time between polls to the node */
|
|
14
|
+
interval?: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const DefaultWaitForProvenOpts: WaitForProvenOpts = {
|
|
18
|
+
provenTimeout: 600,
|
|
19
|
+
interval: DefaultWaitOpts.interval,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Wait for a transaction to be proven by polling the node
|
|
24
|
+
*/
|
|
25
|
+
export async function waitForProven(node: AztecNode, receipt: TxReceipt, opts?: WaitForProvenOpts) {
|
|
26
|
+
if (!receipt.blockNumber) {
|
|
27
|
+
throw new Error(`Cannot wait for proven: receipt of tx ${receipt.txHash} does not have a block number`);
|
|
28
|
+
}
|
|
29
|
+
return await retryUntil(
|
|
30
|
+
async () => {
|
|
31
|
+
const provenBlock = await node.getProvenBlockNumber();
|
|
32
|
+
return provenBlock >= receipt.blockNumber! ? provenBlock : undefined;
|
|
33
|
+
},
|
|
34
|
+
'isProven',
|
|
35
|
+
opts?.provenTimeout ?? DefaultWaitForProvenOpts.provenTimeout,
|
|
36
|
+
opts?.interval ?? DefaultWaitForProvenOpts.interval,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
+
CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT,
|
|
3
4
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
4
|
-
REGISTERER_CONTRACT_BYTECODE_CAPSULE_SLOT,
|
|
5
5
|
} from '@aztec/constants';
|
|
6
6
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
7
7
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -10,17 +10,17 @@ import { type ContractArtifact, FunctionSelector, FunctionType, bufferAsFields }
|
|
|
10
10
|
import {
|
|
11
11
|
computeVerificationKeyHash,
|
|
12
12
|
createPrivateFunctionMembershipProof,
|
|
13
|
-
|
|
13
|
+
createUtilityFunctionMembershipProof,
|
|
14
14
|
getContractClassFromArtifact,
|
|
15
15
|
} from '@aztec/stdlib/contract';
|
|
16
16
|
import { Capsule } from '@aztec/stdlib/tx';
|
|
17
17
|
|
|
18
18
|
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
19
|
-
import {
|
|
19
|
+
import { getClassRegistryContract } from '../contract/protocol_contracts.js';
|
|
20
20
|
import type { Wallet } from '../wallet/index.js';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Sets up a call to broadcast a private function's bytecode via the
|
|
23
|
+
* Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
|
|
24
24
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
25
25
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
26
26
|
* @param wallet - Wallet to send the transaction.
|
|
@@ -51,43 +51,43 @@ export async function broadcastPrivateFunction(
|
|
|
51
51
|
artifactTreeLeafIndex,
|
|
52
52
|
artifactMetadataHash,
|
|
53
53
|
functionMetadataHash,
|
|
54
|
-
|
|
54
|
+
utilityFunctionsTreeRoot,
|
|
55
55
|
privateFunctionTreeSiblingPath,
|
|
56
56
|
privateFunctionTreeLeafIndex,
|
|
57
57
|
} = await createPrivateFunctionMembershipProof(selector, artifact);
|
|
58
58
|
|
|
59
59
|
const vkHash = await computeVerificationKeyHash(privateFunctionArtifact);
|
|
60
60
|
|
|
61
|
-
const
|
|
62
|
-
const fn = registerer.methods.broadcast_private_function(
|
|
63
|
-
contractClass.id,
|
|
64
|
-
artifactMetadataHash,
|
|
65
|
-
unconstrainedFunctionsArtifactTreeRoot,
|
|
66
|
-
privateFunctionTreeSiblingPath,
|
|
67
|
-
privateFunctionTreeLeafIndex,
|
|
68
|
-
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
69
|
-
artifactTreeLeafIndex,
|
|
70
|
-
// eslint-disable-next-line camelcase
|
|
71
|
-
{ selector, metadata_hash: functionMetadataHash, vk_hash: vkHash },
|
|
72
|
-
);
|
|
73
|
-
|
|
61
|
+
const classRegistry = await getClassRegistryContract(wallet);
|
|
74
62
|
const bytecode = bufferAsFields(
|
|
75
63
|
privateFunctionArtifact.bytecode,
|
|
76
64
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
77
65
|
);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
return classRegistry.methods
|
|
67
|
+
.broadcast_private_function(
|
|
68
|
+
contractClass.id,
|
|
69
|
+
artifactMetadataHash,
|
|
70
|
+
utilityFunctionsTreeRoot,
|
|
71
|
+
privateFunctionTreeSiblingPath,
|
|
72
|
+
privateFunctionTreeLeafIndex,
|
|
73
|
+
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
74
|
+
artifactTreeLeafIndex,
|
|
75
|
+
// eslint-disable-next-line camelcase
|
|
76
|
+
{ selector, metadata_hash: functionMetadataHash, vk_hash: vkHash },
|
|
77
|
+
)
|
|
78
|
+
.with({
|
|
79
|
+
capsules: [
|
|
80
|
+
new Capsule(
|
|
81
|
+
ProtocolContractAddress.ContractClassRegistry,
|
|
82
|
+
new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT),
|
|
83
|
+
bytecode,
|
|
84
|
+
),
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* Sets up a call to broadcast
|
|
90
|
+
* Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
|
|
91
91
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
92
92
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
93
93
|
* @param wallet - Wallet to send the transaction.
|
|
@@ -95,22 +95,22 @@ export async function broadcastPrivateFunction(
|
|
|
95
95
|
* @param selector - Selector of the function to be broadcast.
|
|
96
96
|
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
97
97
|
*/
|
|
98
|
-
export async function
|
|
98
|
+
export async function broadcastUtilityFunction(
|
|
99
99
|
wallet: Wallet,
|
|
100
100
|
artifact: ContractArtifact,
|
|
101
101
|
selector: FunctionSelector,
|
|
102
102
|
): Promise<ContractFunctionInteraction> {
|
|
103
103
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
104
|
+
const utilityFunctions = artifact.functions.filter(fn => fn.functionType === FunctionType.UTILITY);
|
|
105
|
+
const utilityFunctionsAndSelectors = await Promise.all(
|
|
106
|
+
utilityFunctions.map(async fn => ({
|
|
107
107
|
f: fn,
|
|
108
108
|
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters),
|
|
109
109
|
})),
|
|
110
110
|
);
|
|
111
|
-
const
|
|
112
|
-
if (!
|
|
113
|
-
throw new Error(`
|
|
111
|
+
const utilityFunctionArtifact = utilityFunctionsAndSelectors.find(fn => selector.equals(fn.selector))?.f;
|
|
112
|
+
if (!utilityFunctionArtifact) {
|
|
113
|
+
throw new Error(`Utility function with selector ${selector.toString()} not found`);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
const {
|
|
@@ -119,30 +119,30 @@ export async function broadcastUnconstrainedFunction(
|
|
|
119
119
|
artifactTreeSiblingPath,
|
|
120
120
|
functionMetadataHash,
|
|
121
121
|
privateFunctionsArtifactTreeRoot,
|
|
122
|
-
} = await
|
|
123
|
-
|
|
124
|
-
const registerer = await getRegistererContract(wallet);
|
|
125
|
-
const fn = registerer.methods.broadcast_unconstrained_function(
|
|
126
|
-
contractClass.id,
|
|
127
|
-
artifactMetadataHash,
|
|
128
|
-
privateFunctionsArtifactTreeRoot,
|
|
129
|
-
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
130
|
-
artifactTreeLeafIndex,
|
|
131
|
-
// eslint-disable-next-line camelcase
|
|
132
|
-
{ selector, metadata_hash: functionMetadataHash },
|
|
133
|
-
);
|
|
122
|
+
} = await createUtilityFunctionMembershipProof(selector, artifact);
|
|
134
123
|
|
|
124
|
+
const classRegistry = await getClassRegistryContract(wallet);
|
|
135
125
|
const bytecode = bufferAsFields(
|
|
136
|
-
|
|
126
|
+
utilityFunctionArtifact.bytecode,
|
|
137
127
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
138
128
|
);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
return classRegistry.methods
|
|
130
|
+
.broadcast_utility_function(
|
|
131
|
+
contractClass.id,
|
|
132
|
+
artifactMetadataHash,
|
|
133
|
+
privateFunctionsArtifactTreeRoot,
|
|
134
|
+
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
135
|
+
artifactTreeLeafIndex,
|
|
136
|
+
// eslint-disable-next-line camelcase
|
|
137
|
+
{ selector, metadata_hash: functionMetadataHash },
|
|
138
|
+
)
|
|
139
|
+
.with({
|
|
140
|
+
capsules: [
|
|
141
|
+
new Capsule(
|
|
142
|
+
ProtocolContractAddress.ContractClassRegistry,
|
|
143
|
+
new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT),
|
|
144
|
+
bytecode,
|
|
145
|
+
),
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
148
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import {
|
|
2
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
3
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
4
4
|
|
|
5
|
-
import type { Wallet } from '../account/wallet.js';
|
|
6
5
|
import { Contract } from '../contract/contract.js';
|
|
7
6
|
import { DeployMethod } from '../contract/deploy_method.js';
|
|
7
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A class for deploying contract.
|
|
@@ -28,7 +28,8 @@ export class ContractDeployer {
|
|
|
28
28
|
* @returns A DeployMethod instance configured with the ABI, PXE, and constructor arguments.
|
|
29
29
|
*/
|
|
30
30
|
public deploy(...args: any[]) {
|
|
31
|
-
const postDeployCtor = (
|
|
31
|
+
const postDeployCtor = (instance: ContractInstanceWithAddress, wallet: Wallet) =>
|
|
32
|
+
Contract.at(instance.address, this.artifact, wallet);
|
|
32
33
|
return new DeployMethod(
|
|
33
34
|
this.publicKeys ?? PublicKeys.default(),
|
|
34
35
|
this.wallet,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT,
|
|
3
|
+
MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS,
|
|
4
|
+
} from '@aztec/constants';
|
|
5
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
6
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
7
|
+
import { type ContractArtifact, bufferAsFields } from '@aztec/stdlib/abi';
|
|
8
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
9
|
+
import { Capsule } from '@aztec/stdlib/tx';
|
|
10
|
+
|
|
11
|
+
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
12
|
+
import { getClassRegistryContract } from '../contract/protocol_contracts.js';
|
|
13
|
+
import type { Wallet } from '../wallet/index.js';
|
|
14
|
+
|
|
15
|
+
/** Sets up a call to publish a contract class given its artifact. */
|
|
16
|
+
export async function publishContractClass(
|
|
17
|
+
wallet: Wallet,
|
|
18
|
+
artifact: ContractArtifact,
|
|
19
|
+
): Promise<ContractFunctionInteraction> {
|
|
20
|
+
const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment, packedBytecode } =
|
|
21
|
+
await getContractClassFromArtifact(artifact);
|
|
22
|
+
const classRegistry = await getClassRegistryContract(wallet);
|
|
23
|
+
|
|
24
|
+
const encodedBytecode = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);
|
|
25
|
+
return classRegistry.methods.publish(artifactHash, privateFunctionsRoot, publicBytecodeCommitment).with({
|
|
26
|
+
capsules: [
|
|
27
|
+
new Capsule(
|
|
28
|
+
ProtocolContractAddress.ContractClassRegistry,
|
|
29
|
+
new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT),
|
|
30
|
+
encodedBytecode,
|
|
31
|
+
),
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
}
|