@aztec/aztec.js 0.0.0-test.0 → 0.0.1-commit.023c3e5
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 +44 -0
- package/dest/account/account.d.ts.map +1 -0
- package/dest/account/account.js +31 -0
- package/dest/account/account_contract.d.ts +42 -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 +36 -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} +22 -5
- package/dest/account/index.d.ts +6 -9
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +4 -6
- package/dest/account/signerless_account.d.ts +22 -0
- package/dest/account/signerless_account.d.ts.map +1 -0
- package/dest/account/signerless_account.js +24 -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 +5 -3
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +3 -2
- 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 +55 -0
- package/dest/api/contract.d.ts.map +1 -0
- package/dest/api/contract.js +53 -0
- 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 +3 -2
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +2 -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 +25 -0
- package/dest/api/node.d.ts.map +1 -0
- package/dest/api/node.js +22 -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 +9 -0
- package/dest/api/protocol.d.ts.map +1 -0
- package/dest/api/protocol.js +8 -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 +5 -2
- 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 +18 -84
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +11 -136
- 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 +89 -69
- 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 +8 -18
- 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 +155 -62
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +152 -142
- 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 +151 -0
- package/dest/contract/interaction_options.d.ts.map +1 -0
- package/dest/contract/interaction_options.js +53 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts +27 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +558 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +26 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +385 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +426 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +575 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/public-checks.js +583 -0
- 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/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/deployment/broadcast_function.d.ts +4 -4
- package/dest/deployment/broadcast_function.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.js +28 -24
- 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 +141 -0
- package/dest/ethereum/portal_manager.d.ts.map +1 -0
- package/dest/ethereum/portal_manager.js +345 -0
- 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 +27 -17
- 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 +45 -23
- 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 +47 -25
- 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/scripts/generate_protocol_contract_types.d.ts +2 -0
- package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
- package/dest/scripts/generate_protocol_contract_types.js +120 -0
- package/dest/utils/abi_types.d.ts +2 -4
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +85 -26
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +234 -41
- 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 +4 -3
- package/dest/utils/field_compressed_string.d.ts +1 -1
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/field_compressed_string.js +1 -1
- package/dest/utils/node.d.ts +13 -2
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +47 -1
- package/dest/utils/pub_key.d.ts +2 -2
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +2 -3
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +31 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.js +61 -0
- package/dest/wallet/account_manager.d.ts +63 -0
- package/dest/wallet/account_manager.d.ts.map +1 -0
- package/dest/wallet/account_manager.js +107 -0
- package/dest/wallet/capabilities.d.ts +444 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +80 -0
- package/dest/wallet/deploy_account_method.d.ts.map +1 -0
- package/dest/wallet/deploy_account_method.js +79 -0
- package/dest/wallet/index.d.ts +4 -17
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +3 -20
- package/dest/wallet/wallet.d.ts +2590 -0
- package/dest/wallet/wallet.d.ts.map +1 -0
- package/dest/wallet/wallet.js +291 -0
- package/package.json +47 -36
- package/src/account/account.ts +72 -0
- package/src/account/account_contract.ts +66 -0
- package/src/account/account_with_secret_key.ts +63 -0
- package/src/account/index.ts +5 -8
- package/src/account/signerless_account.ts +46 -0
- package/src/api/abi.ts +26 -0
- package/src/api/account.ts +8 -5
- package/src/api/addresses.ts +1 -0
- package/src/api/authorization.ts +15 -0
- package/src/api/block.ts +2 -0
- package/src/api/contract.ts +88 -0
- 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/fields.ts +2 -1
- 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 +24 -0
- package/src/api/note.ts +1 -0
- package/src/api/protocol.ts +9 -0
- package/src/api/trees.ts +2 -0
- package/src/api/tx.ts +15 -0
- package/src/api/utils.ts +14 -0
- package/src/api/wallet.ts +72 -5
- package/src/authorization/call_authorization_request.ts +63 -0
- package/src/contract/base_contract_interaction.ts +40 -171
- package/src/contract/batch_call.ts +108 -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 +307 -143
- package/src/contract/get_gas_limits.ts +15 -8
- package/src/contract/interaction_options.ts +208 -0
- package/src/contract/protocol_contracts/auth-registry.ts +351 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +241 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
- package/src/contract/protocol_contracts/fee-juice.ts +264 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +332 -0
- package/src/contract/protocol_contracts/public-checks.ts +316 -0
- package/src/contract/wait_for_proven.ts +38 -0
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/broadcast_function.ts +58 -58
- package/src/deployment/contract_deployer.ts +4 -3
- package/src/deployment/publish_class.ts +34 -0
- package/src/deployment/publish_instance.ts +23 -0
- package/src/{api/ethereum → ethereum}/portal_manager.ts +166 -89
- package/src/fee/fee_juice_payment_method_with_claim.ts +49 -34
- package/src/fee/fee_payment_method.ts +11 -7
- package/src/fee/private_fee_payment_method.ts +80 -58
- package/src/fee/public_fee_payment_method.ts +94 -68
- package/src/fee/sponsored_fee_payment.ts +46 -0
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +1 -1
- package/src/utils/authwit.ts +274 -54
- package/src/utils/cross_chain.ts +53 -0
- package/src/utils/fee_juice.ts +5 -5
- package/src/utils/field_compressed_string.ts +1 -1
- package/src/utils/node.ts +63 -1
- package/src/utils/pub_key.ts +3 -4
- package/src/wallet/account_entrypoint_meta_payment_method.ts +74 -0
- package/src/wallet/account_manager.ts +146 -0
- package/src/wallet/capabilities.ts +491 -0
- package/src/wallet/deploy_account_method.ts +150 -0
- package/src/wallet/index.ts +3 -33
- package/src/wallet/wallet.ts +533 -0
- package/dest/account/contract.d.ts +0 -37
- package/dest/account/contract.d.ts.map +0 -1
- package/dest/account/interface.d.ts +0 -31
- package/dest/account/interface.d.ts.map +0 -1
- package/dest/account/interface.js +0 -4
- 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/ethereum/portal_manager.js +0 -286
- 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/deploy_sent_tx.d.ts +0 -45
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -43
- package/dest/contract/index.d.ts +0 -45
- package/dest/contract/index.d.ts.map +0 -1
- package/dest/contract/index.js +0 -43
- package/dest/contract/protocol_contracts.d.ts +0 -9
- package/dest/contract/protocol_contracts.d.ts.map +0 -1
- package/dest/contract/protocol_contracts.js +0 -26
- package/dest/contract/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/contract/sent_tx.d.ts +0 -61
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -102
- package/dest/contract/unsafe_contract.d.ts +0 -15
- package/dest/contract/unsafe_contract.d.ts.map +0 -1
- package/dest/contract/unsafe_contract.js +0 -6
- package/dest/deployment/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/contract.ts +0 -56
- package/src/account/interface.ts +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/deploy_sent_tx.ts +0 -74
- package/src/contract/index.ts +0 -48
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/proven_tx.ts +0 -42
- package/src/contract/sent_tx.ts +0 -141
- package/src/contract/unsafe_contract.ts +0 -19
- 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/account_wallet_with_private_key.ts +0 -40
- package/src/wallet/base_wallet.ts +0 -198
- package/src/wallet/signerless_wallet.ts +0 -52
package/src/utils/authwit.ts
CHANGED
|
@@ -1,37 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
1
|
+
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
|
+
import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, FunctionType } from '@aztec/stdlib/abi';
|
|
5
|
+
import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
|
|
5
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import {
|
|
7
|
+
import { computeVarArgsHash } from '@aztec/stdlib/hash';
|
|
8
|
+
import type { TxHash, TxProfileResult, TxReceipt } from '@aztec/stdlib/tx';
|
|
7
9
|
|
|
8
10
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
import type {
|
|
12
|
+
InteractionWaitOptions,
|
|
13
|
+
ProfileInteractionOptions,
|
|
14
|
+
SendInteractionOptions,
|
|
15
|
+
SendInteractionOptionsWithoutWait,
|
|
16
|
+
SendReturn,
|
|
17
|
+
SimulateInteractionOptions,
|
|
18
|
+
SimulationReturn,
|
|
19
|
+
} from '../contract/interaction_options.js';
|
|
20
|
+
import type { Wallet } from '../wallet/index.js';
|
|
17
21
|
|
|
18
22
|
/** Intent with an inner hash */
|
|
19
23
|
export type IntentInnerHash = {
|
|
20
24
|
/** The consumer */
|
|
21
25
|
consumer: AztecAddress;
|
|
22
26
|
/** The action to approve */
|
|
23
|
-
innerHash:
|
|
27
|
+
innerHash: Fr;
|
|
24
28
|
};
|
|
25
29
|
|
|
26
|
-
/** Intent with
|
|
27
|
-
export type
|
|
30
|
+
/** Intent with a call */
|
|
31
|
+
export type CallIntent = {
|
|
32
|
+
/** The caller to approve */
|
|
33
|
+
caller: AztecAddress;
|
|
34
|
+
/** The call to approve */
|
|
35
|
+
call: FunctionCall;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Intent with a ContractFunctionInteraction */
|
|
39
|
+
export type ContractFunctionInteractionCallIntent = {
|
|
28
40
|
/** The caller to approve */
|
|
29
41
|
caller: AztecAddress;
|
|
30
42
|
/** The action to approve */
|
|
31
|
-
action: ContractFunctionInteraction
|
|
43
|
+
action: ContractFunctionInteraction;
|
|
32
44
|
};
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
/** Identifies ContractFunctionInteractionCallIntents */
|
|
47
|
+
export function isContractFunctionInteractionCallIntent(
|
|
48
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
49
|
+
): messageHashOrIntent is ContractFunctionInteractionCallIntent {
|
|
50
|
+
return (
|
|
51
|
+
'caller' in messageHashOrIntent &&
|
|
52
|
+
'action' in messageHashOrIntent &&
|
|
53
|
+
messageHashOrIntent.action instanceof ContractFunctionInteraction
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
35
57
|
/**
|
|
36
58
|
* Compute an authentication witness message hash from an intent and metadata
|
|
37
59
|
*
|
|
@@ -42,7 +64,7 @@ export type IntentAction = {
|
|
|
42
64
|
* and use it for the authentication check.
|
|
43
65
|
* Therefore, any allowed `innerHash` will therefore also have information around where it can be spent (version, chainId) and who can spend it (consumer).
|
|
44
66
|
*
|
|
45
|
-
* If using the `
|
|
67
|
+
* If using the `CallIntent`, the caller is the address that is making the call, for a token approval from Alice to Bob, this would be Bob.
|
|
46
68
|
* The action is then used along with the `caller` to compute the `innerHash` and the consumer.
|
|
47
69
|
*
|
|
48
70
|
*
|
|
@@ -53,58 +75,256 @@ export type IntentAction = {
|
|
|
53
75
|
* @param metadata - The metadata for the intent (chainId, version)
|
|
54
76
|
* @returns The message hash for the action
|
|
55
77
|
*/
|
|
56
|
-
export const computeAuthWitMessageHash = async (
|
|
78
|
+
export const computeAuthWitMessageHash = async (
|
|
79
|
+
intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
80
|
+
metadata: ChainInfo,
|
|
81
|
+
) => {
|
|
57
82
|
const chainId = metadata.chainId;
|
|
58
83
|
const version = metadata.version;
|
|
59
84
|
|
|
60
85
|
if ('caller' in intent) {
|
|
61
|
-
const
|
|
86
|
+
const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
|
|
62
87
|
return computeOuterAuthWitHash(
|
|
63
|
-
|
|
88
|
+
call.to,
|
|
64
89
|
chainId,
|
|
65
90
|
version,
|
|
66
|
-
await computeInnerAuthWitHashFromAction(intent.caller,
|
|
91
|
+
await computeInnerAuthWitHashFromAction(intent.caller, call),
|
|
67
92
|
);
|
|
68
93
|
} else {
|
|
69
94
|
const inner = Buffer.isBuffer(intent.innerHash) ? Fr.fromBuffer(intent.innerHash) : intent.innerHash;
|
|
70
95
|
return computeOuterAuthWitHash(intent.consumer, chainId, version, inner);
|
|
71
96
|
}
|
|
72
97
|
};
|
|
73
|
-
// docs:end:authwit_computeAuthWitMessageHash
|
|
74
|
-
|
|
75
|
-
export const computeInnerAuthWitHashFromAction = async (caller: AztecAddress, action: FunctionCall) =>
|
|
76
|
-
computeInnerAuthWitHash([
|
|
77
|
-
caller.toField(),
|
|
78
|
-
action.selector.toField(),
|
|
79
|
-
(await HashedValues.fromValues(action.args)).hash,
|
|
80
|
-
]);
|
|
81
98
|
|
|
82
99
|
/**
|
|
83
|
-
* Compute
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @
|
|
88
|
-
* @returns The inner hash for the witness
|
|
100
|
+
* Compute an authentication witness message hash from an intent and metadata. This is just
|
|
101
|
+
* a wrapper around computeAuthwitMessageHash that allows receiving an already computed messageHash as input
|
|
102
|
+
* @param messageHashOrIntent - The precomputed messageHash or intent to approve (consumer and innerHash or caller and call/action)
|
|
103
|
+
* @param metadata - The metadata for the intent (chainId, version)
|
|
104
|
+
* @returns The message hash for the intent
|
|
89
105
|
*/
|
|
90
|
-
export
|
|
91
|
-
|
|
106
|
+
export async function getMessageHashFromIntent(
|
|
107
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
108
|
+
chainInfo: ChainInfo,
|
|
109
|
+
) {
|
|
110
|
+
let messageHash: Fr;
|
|
111
|
+
const { chainId, version } = chainInfo;
|
|
112
|
+
if (messageHashOrIntent instanceof Fr) {
|
|
113
|
+
messageHash = messageHashOrIntent;
|
|
114
|
+
} else {
|
|
115
|
+
messageHash = await computeAuthWitMessageHash(messageHashOrIntent, { chainId, version });
|
|
116
|
+
}
|
|
117
|
+
return messageHash;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Computes the inner authwitness hash for either a function call or an action, for it to later be combined with the metadata
|
|
122
|
+
* required for the outer hash and eventually the full AuthWitness.
|
|
123
|
+
* @param caller - Who is going to be calling the function
|
|
124
|
+
* @param action - The action to compute the inner hash from
|
|
125
|
+
* @returns The inner hash for the action
|
|
126
|
+
**/
|
|
127
|
+
export const computeInnerAuthWitHashFromAction = async (
|
|
128
|
+
caller: AztecAddress,
|
|
129
|
+
action: FunctionCall | ContractFunctionInteraction,
|
|
130
|
+
) => {
|
|
131
|
+
const call = action instanceof ContractFunctionInteraction ? await action.getFunctionCall() : action;
|
|
132
|
+
return computeInnerAuthWitHash([caller.toField(), call.selector.toField(), await computeVarArgsHash(call.args)]);
|
|
92
133
|
};
|
|
93
134
|
|
|
94
135
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @param
|
|
103
|
-
* @
|
|
104
|
-
* @param version - The version that can "consume" the authwit
|
|
105
|
-
* @param innerHash - The inner hash for the witness
|
|
106
|
-
* @returns The outer hash for the witness
|
|
136
|
+
* Lookup the validity of an authwit in private and public contexts.
|
|
137
|
+
*
|
|
138
|
+
* Uses the chain id and version of the wallet.
|
|
139
|
+
*
|
|
140
|
+
* @param wallet - The wallet use to simulate and read the public data
|
|
141
|
+
* @param onBehalfOf - The address of the "approver"
|
|
142
|
+
* @param intent - The consumer and inner hash or the caller and action to lookup
|
|
143
|
+
* @param witness - The computed authentication witness to check
|
|
144
|
+
* @returns - A struct containing the validity of the authwit in private and public contexts.
|
|
107
145
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
146
|
+
export async function lookupValidity(
|
|
147
|
+
wallet: Wallet,
|
|
148
|
+
onBehalfOf: AztecAddress,
|
|
149
|
+
intent: IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
150
|
+
witness: AuthWitness,
|
|
151
|
+
): Promise<{
|
|
152
|
+
/** boolean flag indicating if the authwit is valid in private context */
|
|
153
|
+
isValidInPrivate: boolean;
|
|
154
|
+
/** boolean flag indicating if the authwit is valid in public context */
|
|
155
|
+
isValidInPublic: boolean;
|
|
156
|
+
}> {
|
|
157
|
+
let innerHash, consumer;
|
|
158
|
+
if ('caller' in intent) {
|
|
159
|
+
const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
|
|
160
|
+
innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
|
|
161
|
+
consumer = call.to;
|
|
162
|
+
} else {
|
|
163
|
+
({ innerHash, consumer } = intent);
|
|
164
|
+
}
|
|
165
|
+
const chainInfo = await wallet.getChainInfo();
|
|
166
|
+
const messageHash = await getMessageHashFromIntent(intent, chainInfo);
|
|
167
|
+
const results = { isValidInPrivate: false, isValidInPublic: false };
|
|
168
|
+
|
|
169
|
+
// Check private
|
|
170
|
+
const lookupValidityAbi = {
|
|
171
|
+
name: 'lookup_validity',
|
|
172
|
+
isInitializer: false,
|
|
173
|
+
functionType: FunctionType.UTILITY,
|
|
174
|
+
isOnlySelf: false,
|
|
175
|
+
isStatic: false,
|
|
176
|
+
parameters: [
|
|
177
|
+
{
|
|
178
|
+
name: 'consumer',
|
|
179
|
+
type: {
|
|
180
|
+
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
181
|
+
kind: 'struct',
|
|
182
|
+
path: 'aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
183
|
+
},
|
|
184
|
+
visibility: 'private' as ABIParameterVisibility,
|
|
185
|
+
},
|
|
186
|
+
{ name: 'inner_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
|
|
187
|
+
],
|
|
188
|
+
returnTypes: [{ kind: 'boolean' }],
|
|
189
|
+
errorTypes: {},
|
|
190
|
+
} as FunctionAbi;
|
|
191
|
+
try {
|
|
192
|
+
results.isValidInPrivate = (await new ContractFunctionInteraction(wallet, onBehalfOf, lookupValidityAbi, [
|
|
193
|
+
consumer,
|
|
194
|
+
innerHash,
|
|
195
|
+
]).simulate({ from: onBehalfOf, authWitnesses: [witness] })) as boolean;
|
|
196
|
+
// TODO: Narrow down the error to make sure simulation failed due to an invalid authwit
|
|
197
|
+
// eslint-disable-next-line no-empty
|
|
198
|
+
} catch {}
|
|
199
|
+
|
|
200
|
+
// check public
|
|
201
|
+
const isConsumableAbi = {
|
|
202
|
+
name: 'utility_is_consumable',
|
|
203
|
+
isInitializer: false,
|
|
204
|
+
functionType: FunctionType.UTILITY,
|
|
205
|
+
isOnlySelf: false,
|
|
206
|
+
isStatic: false,
|
|
207
|
+
parameters: [
|
|
208
|
+
{
|
|
209
|
+
name: 'address',
|
|
210
|
+
type: {
|
|
211
|
+
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
212
|
+
kind: 'struct',
|
|
213
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
214
|
+
},
|
|
215
|
+
visibility: 'private' as ABIParameterVisibility,
|
|
216
|
+
},
|
|
217
|
+
{ name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
|
|
218
|
+
],
|
|
219
|
+
returnTypes: [{ kind: 'boolean' }],
|
|
220
|
+
errorTypes: {},
|
|
221
|
+
} as FunctionAbi;
|
|
222
|
+
results.isValidInPublic = (await new ContractFunctionInteraction(
|
|
223
|
+
wallet,
|
|
224
|
+
ProtocolContractAddress.AuthRegistry,
|
|
225
|
+
isConsumableAbi,
|
|
226
|
+
[onBehalfOf, messageHash],
|
|
227
|
+
).simulate({ from: onBehalfOf })) as boolean;
|
|
228
|
+
|
|
229
|
+
return results;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Convenience class designed to wrap the very common interaction of setting a public authwit in the AuthRegistry contract
|
|
234
|
+
*/
|
|
235
|
+
export class SetPublicAuthwitContractInteraction extends ContractFunctionInteraction {
|
|
236
|
+
private constructor(
|
|
237
|
+
wallet: Wallet,
|
|
238
|
+
private from: AztecAddress,
|
|
239
|
+
messageHash: Fr,
|
|
240
|
+
authorized: boolean,
|
|
241
|
+
) {
|
|
242
|
+
super(wallet, ProtocolContractAddress.AuthRegistry, SetPublicAuthwitContractInteraction.getSetAuthorizedAbi(), [
|
|
243
|
+
messageHash,
|
|
244
|
+
authorized,
|
|
245
|
+
]);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static async create(
|
|
249
|
+
wallet: Wallet,
|
|
250
|
+
from: AztecAddress,
|
|
251
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
252
|
+
authorized: boolean,
|
|
253
|
+
) {
|
|
254
|
+
const chainInfo = await wallet.getChainInfo();
|
|
255
|
+
const messageHash = await getMessageHashFromIntent(messageHashOrIntent, chainInfo);
|
|
256
|
+
return new SetPublicAuthwitContractInteraction(wallet, from, messageHash, authorized);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Overrides the simulate method, adding the sender of the authwit (authorizer) as from
|
|
261
|
+
* and preventing misuse
|
|
262
|
+
* @param options - An optional object containing additional configuration for the transaction.
|
|
263
|
+
* @returns The result of the transaction as returned by the contract function.
|
|
264
|
+
*/
|
|
265
|
+
public override simulate<T extends SimulateInteractionOptions>(
|
|
266
|
+
options: Omit<T, 'from'>,
|
|
267
|
+
): Promise<SimulationReturn<T['includeMetadata']>>;
|
|
268
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
269
|
+
public override simulate(
|
|
270
|
+
options: Omit<SimulateInteractionOptions, 'from'> = {},
|
|
271
|
+
): Promise<SimulationReturn<typeof options.includeMetadata>> {
|
|
272
|
+
return super.simulate({ ...options, from: this.from });
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Overrides the profile method, adding the sender of the authwit (authorizer) as from
|
|
277
|
+
* and preventing misuse
|
|
278
|
+
* @param options - Same options as `simulate`, plus profiling method
|
|
279
|
+
* @returns An object containing the function return value and profile result.
|
|
280
|
+
*/
|
|
281
|
+
public override profile(
|
|
282
|
+
options: Omit<ProfileInteractionOptions, 'from'> = { profileMode: 'gates' },
|
|
283
|
+
): Promise<TxProfileResult> {
|
|
284
|
+
return super.profile({ ...options, from: this.from });
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Overrides the send method, adding the sender of the authwit (authorizer) as from
|
|
289
|
+
* and preventing misuse
|
|
290
|
+
* @param options - An optional object containing 'fee' options information
|
|
291
|
+
* @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
|
|
292
|
+
*/
|
|
293
|
+
// Overload for when wait is not specified at all - returns TxReceipt
|
|
294
|
+
public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxReceipt>;
|
|
295
|
+
// Generic overload for explicit wait values
|
|
296
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
297
|
+
public override send<W extends InteractionWaitOptions>(
|
|
298
|
+
options?: Omit<SendInteractionOptions<W>, 'from'>,
|
|
299
|
+
): Promise<SendReturn<W>>;
|
|
300
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
301
|
+
public override send(
|
|
302
|
+
options?: Omit<SendInteractionOptions<InteractionWaitOptions>, 'from'>,
|
|
303
|
+
): Promise<TxReceipt | TxHash> {
|
|
304
|
+
return super.send({ ...options, from: this.from });
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private static getSetAuthorizedAbi(): FunctionAbi {
|
|
308
|
+
return {
|
|
309
|
+
name: 'set_authorized',
|
|
310
|
+
isInitializer: false,
|
|
311
|
+
functionType: FunctionType.PUBLIC,
|
|
312
|
+
isOnlySelf: true,
|
|
313
|
+
isStatic: false,
|
|
314
|
+
parameters: [
|
|
315
|
+
{
|
|
316
|
+
name: 'message_hash',
|
|
317
|
+
type: { kind: 'field' },
|
|
318
|
+
visibility: 'private' as ABIParameterVisibility,
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: 'authorize',
|
|
322
|
+
type: { kind: 'boolean' },
|
|
323
|
+
visibility: 'private' as ABIParameterVisibility,
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
returnTypes: [],
|
|
327
|
+
errorTypes: {},
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Waits for the L1 to L2 message to be ready to be consumed.
|
|
7
|
+
* @param node - Aztec node instance used to obtain the information about the message
|
|
8
|
+
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
9
|
+
* @param opts - Options
|
|
10
|
+
*/
|
|
11
|
+
export async function waitForL1ToL2MessageReady(
|
|
12
|
+
node: Pick<AztecNode, 'getBlockNumber' | 'getL1ToL2MessageBlock'>,
|
|
13
|
+
l1ToL2MessageHash: Fr,
|
|
14
|
+
opts: {
|
|
15
|
+
/** Timeout for the operation in seconds */ timeoutSeconds: number;
|
|
16
|
+
/** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
|
|
17
|
+
},
|
|
18
|
+
) {
|
|
19
|
+
const messageBlockNumber = await node.getL1ToL2MessageBlock(l1ToL2MessageHash);
|
|
20
|
+
return retryUntil(
|
|
21
|
+
() => isL1ToL2MessageReady(node, l1ToL2MessageHash, { ...opts, messageBlockNumber }),
|
|
22
|
+
`L1 to L2 message ${l1ToL2MessageHash.toString()} ready`,
|
|
23
|
+
opts.timeoutSeconds,
|
|
24
|
+
1,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns whether the L1 to L2 message is ready to be consumed.
|
|
30
|
+
* @param node - Aztec node instance used to obtain the information about the message
|
|
31
|
+
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
32
|
+
* @param opts - Options
|
|
33
|
+
* @returns True if the message is ready to be consumed, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
export async function isL1ToL2MessageReady(
|
|
36
|
+
node: Pick<AztecNode, 'getBlockNumber' | 'getL1ToL2MessageBlock'>,
|
|
37
|
+
l1ToL2MessageHash: Fr,
|
|
38
|
+
opts: {
|
|
39
|
+
/** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
|
|
40
|
+
/** Cached synced block number for the message (will be fetched from PXE otherwise) */ messageBlockNumber?: number;
|
|
41
|
+
},
|
|
42
|
+
): Promise<boolean> {
|
|
43
|
+
const blockNumber = await node.getBlockNumber();
|
|
44
|
+
const messageBlockNumber = opts.messageBlockNumber ?? (await node.getL1ToL2MessageBlock(l1ToL2MessageHash));
|
|
45
|
+
if (messageBlockNumber === undefined) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Note that public messages can be consumed 1 block earlier, since the sequencer will include the messages
|
|
50
|
+
// in the L1 to L2 message tree before executing the txs for the block. In private, however, we need to wait
|
|
51
|
+
// until the message is included so we can make use of the membership witness.
|
|
52
|
+
return opts.forPublicConsumption ? blockNumber + 1 >= messageBlockNumber : blockNumber >= messageBlockNumber;
|
|
53
|
+
}
|
package/src/utils/fee_juice.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
|
|
5
|
-
|
|
6
|
-
import type { PXE } from '../api/interfaces/pxe.js';
|
|
5
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Returns the owner's fee juice balance.
|
|
9
|
+
* Note: This is used only e2e_local_network_example test. TODO: Consider nuking.
|
|
10
10
|
*/
|
|
11
|
-
export async function getFeeJuiceBalance(owner: AztecAddress,
|
|
11
|
+
export async function getFeeJuiceBalance(owner: AztecAddress, node: AztecNode): Promise<bigint> {
|
|
12
12
|
const slot = await deriveStorageSlotInMap(new Fr(1), owner);
|
|
13
|
-
return (await
|
|
13
|
+
return (await node.getPublicStorageAt('latest', ProtocolContractAddress.FeeJuice, slot)).toBigInt();
|
|
14
14
|
}
|
package/src/utils/node.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
2
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
3
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
5
|
+
import { SortedTxStatuses, TxStatus } from '@aztec/stdlib/tx';
|
|
6
|
+
|
|
7
|
+
import { DefaultWaitOpts, type WaitOpts } from '../contract/wait_opts.js';
|
|
4
8
|
|
|
5
9
|
export const waitForNode = async (node: AztecNode, logger?: Logger) => {
|
|
6
10
|
await retryUntil(async () => {
|
|
@@ -9,11 +13,69 @@ export const waitForNode = async (node: AztecNode, logger?: Logger) => {
|
|
|
9
13
|
await node.getNodeInfo();
|
|
10
14
|
logger?.verbose('Contacted Aztec node');
|
|
11
15
|
return true;
|
|
12
|
-
} catch
|
|
16
|
+
} catch {
|
|
13
17
|
logger?.verbose('Failed to contact Aztec Node');
|
|
14
18
|
}
|
|
15
19
|
return undefined;
|
|
16
20
|
}, 'RPC Get Node Info');
|
|
17
21
|
};
|
|
18
22
|
|
|
23
|
+
/** Returns true if the receipt status is at least the desired status level. */
|
|
24
|
+
function hasReachedStatus(receipt: TxReceipt, desiredStatus: TxStatus): boolean {
|
|
25
|
+
return SortedTxStatuses.indexOf(receipt.status) >= SortedTxStatuses.indexOf(desiredStatus);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Waits for a transaction to be mined and returns its receipt.
|
|
30
|
+
* @param node - The Aztec node to query for transaction status
|
|
31
|
+
* @param txHash - The hash of the transaction to wait for
|
|
32
|
+
* @param opts - Optional configuration for waiting behavior
|
|
33
|
+
* @returns The transaction receipt
|
|
34
|
+
* @throws If the transaction fails and dontThrowOnRevert is not set
|
|
35
|
+
*/
|
|
36
|
+
export async function waitForTx(node: AztecNode, txHash: TxHash, opts?: WaitOpts): Promise<TxReceipt> {
|
|
37
|
+
const startTime = Date.now();
|
|
38
|
+
const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
|
|
39
|
+
const waitForStatus = opts?.waitForStatus ?? TxStatus.CHECKPOINTED;
|
|
40
|
+
|
|
41
|
+
const receipt = await retryUntil(
|
|
42
|
+
async () => {
|
|
43
|
+
const txReceipt = await node.getTxReceipt(txHash);
|
|
44
|
+
// If receipt is not yet available, try again
|
|
45
|
+
if (txReceipt.isPending()) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
// If the tx was "dropped", either return it or ignore based on timing.
|
|
49
|
+
// We can ignore it at first because the transaction may have been sent to node 1, and now we're asking node 2 for the receipt.
|
|
50
|
+
// If we don't allow a short grace period, we could incorrectly return a TxReceipt with status DROPPED.
|
|
51
|
+
if (txReceipt.isDropped()) {
|
|
52
|
+
const elapsedSeconds = (Date.now() - startTime) / 1000;
|
|
53
|
+
if (!ignoreDroppedReceiptsFor || elapsedSeconds > ignoreDroppedReceiptsFor) {
|
|
54
|
+
return txReceipt;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
// Check if the receipt has reached the desired status level
|
|
59
|
+
if (!hasReachedStatus(txReceipt, waitForStatus)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return txReceipt;
|
|
63
|
+
},
|
|
64
|
+
'isMined',
|
|
65
|
+
opts?.timeout ?? DefaultWaitOpts.timeout,
|
|
66
|
+
opts?.interval ?? DefaultWaitOpts.interval,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (!receipt.isMined()) {
|
|
70
|
+
throw new Error(`Transaction ${txHash.toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
|
|
71
|
+
}
|
|
72
|
+
if (!receipt.hasExecutionSucceeded() && !opts?.dontThrowOnRevert) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`Transaction ${txHash.toString()} reverted: ${receipt.executionResult}. Reason: ${receipt.error ?? 'unknown'}`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return receipt;
|
|
79
|
+
}
|
|
80
|
+
|
|
19
81
|
export { createAztecNodeClient, type AztecNode } from '@aztec/stdlib/interfaces/client';
|
package/src/utils/pub_key.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Grumpkin } from '@aztec/foundation/crypto';
|
|
2
|
-
import type { GrumpkinScalar } from '@aztec/foundation/
|
|
1
|
+
import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
|
|
2
|
+
import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
3
3
|
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -8,6 +8,5 @@ import type { PublicKey } from '@aztec/stdlib/keys';
|
|
|
8
8
|
* @returns The generated public key.
|
|
9
9
|
*/
|
|
10
10
|
export function generatePublicKey(privateKey: GrumpkinScalar): Promise<PublicKey> {
|
|
11
|
-
|
|
12
|
-
return grumpkin.mul(grumpkin.generator(), privateKey);
|
|
11
|
+
return Grumpkin.mul(Grumpkin.generator, privateKey);
|
|
13
12
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
2
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
|
+
|
|
7
|
+
import type { Account } from '../account/account.js';
|
|
8
|
+
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Fee payment method that allows an account contract to pay for its own deployment
|
|
12
|
+
* It works by rerouting the provided fee payment method through the account's entrypoint,
|
|
13
|
+
* which sets itself as fee payer. If no payment method is provided, it is assumed the
|
|
14
|
+
* account will pay with its own fee juice balance.
|
|
15
|
+
*
|
|
16
|
+
* Usually, in order to pay fees it is necessary to obtain an ExecutionPayload that encodes the necessary information
|
|
17
|
+
* that is sent to the user's account entrypoint, that has plumbing to handle it.
|
|
18
|
+
* If there's no account contract yet (it's being deployed) a MultiCallContract is used, which doesn't have a concept of fees or
|
|
19
|
+
* how to handle this payload.
|
|
20
|
+
* HOWEVER, the account contract's entrypoint does, so this method reshapes that fee payload into a call to the account contract entrypoint
|
|
21
|
+
* being deployed with the original fee payload.
|
|
22
|
+
*
|
|
23
|
+
* This class can be seen in action in DeployAccountMethod.ts#getSelfPaymentMethod
|
|
24
|
+
*/
|
|
25
|
+
export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
|
|
26
|
+
constructor(
|
|
27
|
+
private account: Account,
|
|
28
|
+
private paymentMethod?: FeePaymentMethod,
|
|
29
|
+
private feeEntrypointOptions?: any,
|
|
30
|
+
) {}
|
|
31
|
+
|
|
32
|
+
getAsset(): Promise<AztecAddress> {
|
|
33
|
+
return this.paymentMethod?.getAsset() ?? Promise.resolve(ProtocolContractAddress.FeeJuice);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
37
|
+
// Get the execution payload for the fee
|
|
38
|
+
const innerPayload = (await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
|
|
39
|
+
|
|
40
|
+
// If no fee entrypoint options were provided, compute them based on the wrapped payment method
|
|
41
|
+
// This mimics how the actual account contract works when invoked directly:
|
|
42
|
+
// - If we are the fee payer, are there calls in the inner payload? In that case, those calls can
|
|
43
|
+
// only be claiming fee juice, so we use FEE_JUICE_WITH_CLAIM
|
|
44
|
+
// - If we are the fee payer, but there are no calls, then we assume the account already has
|
|
45
|
+
// fee juice and can pay directly with PREEXISTING_FEE_JUICE
|
|
46
|
+
// - If we are not the fee payer, then EXTERNAL is used
|
|
47
|
+
let options = this.feeEntrypointOptions;
|
|
48
|
+
if (!options) {
|
|
49
|
+
const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.account.getAddress();
|
|
50
|
+
const isFeePayer = feePayer.equals(this.account.getAddress());
|
|
51
|
+
|
|
52
|
+
let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
|
|
53
|
+
if (isFeePayer) {
|
|
54
|
+
accountFeePaymentMethodOptions =
|
|
55
|
+
innerPayload.calls.length === 0
|
|
56
|
+
? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
|
|
57
|
+
: AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
options = { feePaymentMethodOptions: accountFeePaymentMethodOptions };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Use the generic wrapping mechanism from the account interface
|
|
64
|
+
return this.account.wrapExecutionPayload(innerPayload, options);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
68
|
+
return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.account.getAddress());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getGasSettings(): GasSettings | undefined {
|
|
72
|
+
return this.paymentMethod?.getGasSettings();
|
|
73
|
+
}
|
|
74
|
+
}
|