@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
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
-
import { type
|
|
3
|
-
import
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
5
6
|
|
|
6
|
-
import type { Wallet } from '../account/wallet.js';
|
|
7
7
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
8
|
-
import {
|
|
8
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
9
9
|
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -21,10 +21,18 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
21
21
|
private paymentContract: AztecAddress,
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Address of the account that will pay the fee
|
|
25
25
|
*/
|
|
26
|
-
private
|
|
26
|
+
private sender: AztecAddress,
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* A wallet to perform the simulation to get the accepted asset
|
|
30
|
+
*/
|
|
31
|
+
private wallet: Wallet,
|
|
32
|
+
/**
|
|
33
|
+
* Gas settings used to compute the maximum fee the user is willing to pay
|
|
34
|
+
*/
|
|
35
|
+
protected gasSettings: GasSettings,
|
|
28
36
|
/**
|
|
29
37
|
* If true, the max fee will be set to 1.
|
|
30
38
|
* TODO(#7694): Remove this param once the lacking feature in TXE is implemented.
|
|
@@ -36,41 +44,43 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
36
44
|
* The asset used to pay the fee.
|
|
37
45
|
* @returns The asset used to pay the fee.
|
|
38
46
|
*/
|
|
39
|
-
getAsset(): Promise<AztecAddress> {
|
|
47
|
+
async getAsset(): Promise<AztecAddress> {
|
|
40
48
|
if (!this.assetPromise) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
57
|
-
fields: [
|
|
58
|
-
{
|
|
59
|
-
name: 'inner',
|
|
60
|
-
type: {
|
|
61
|
-
kind: 'field',
|
|
62
|
-
},
|
|
49
|
+
const abi = {
|
|
50
|
+
name: 'get_accepted_asset',
|
|
51
|
+
functionType: FunctionType.PRIVATE,
|
|
52
|
+
isOnlySelf: false,
|
|
53
|
+
isStatic: false,
|
|
54
|
+
parameters: [],
|
|
55
|
+
returnTypes: [
|
|
56
|
+
{
|
|
57
|
+
kind: 'struct',
|
|
58
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
59
|
+
fields: [
|
|
60
|
+
{
|
|
61
|
+
name: 'inner',
|
|
62
|
+
type: {
|
|
63
|
+
kind: 'field',
|
|
63
64
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
errorTypes: {},
|
|
70
|
+
isInitializer: false,
|
|
71
|
+
} as FunctionAbi;
|
|
72
|
+
const interaction = new ContractFunctionInteraction(this.wallet, this.paymentContract, abi, []);
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
const executionPayload = await interaction.request();
|
|
75
|
+
this.assetPromise = this.wallet
|
|
76
|
+
.simulateTx(executionPayload, {
|
|
77
|
+
from: AztecAddress.ZERO,
|
|
78
|
+
skipFeeEnforcement: true,
|
|
79
|
+
})
|
|
80
|
+
.then(simulationResult => {
|
|
81
|
+
const rawReturnValues = simulationResult.getPrivateReturnValues().nested[0].values;
|
|
82
|
+
return decodeFromAbi(abi.returnTypes, rawReturnValues!);
|
|
83
|
+
}) as Promise<AztecAddress>;
|
|
74
84
|
}
|
|
75
85
|
return this.assetPromise!;
|
|
76
86
|
}
|
|
@@ -80,39 +90,51 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
/**
|
|
83
|
-
* Creates
|
|
93
|
+
* Creates an execution payload to pay the fee using a private function through an FPC in the desired asset
|
|
84
94
|
* @param gasSettings - The gas settings.
|
|
85
|
-
* @returns
|
|
95
|
+
* @returns An execution payload that contains the required function calls and auth witnesses.
|
|
86
96
|
*/
|
|
87
|
-
async
|
|
97
|
+
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
88
98
|
// We assume 1:1 exchange rate between fee juice and token. But in reality you would need to convert feeLimit
|
|
89
99
|
// (maxFee) to be in token denomination.
|
|
90
|
-
const maxFee = this.setMaxFeeToOne ? Fr.ONE : gasSettings.getFeeLimit();
|
|
91
|
-
const
|
|
100
|
+
const maxFee = this.setMaxFeeToOne ? Fr.ONE : this.gasSettings.getFeeLimit();
|
|
101
|
+
const txNonce = Fr.random();
|
|
92
102
|
|
|
93
|
-
await this.wallet.createAuthWit({
|
|
103
|
+
const witness = await this.wallet.createAuthWit(this.sender, {
|
|
94
104
|
caller: this.paymentContract,
|
|
95
|
-
|
|
105
|
+
call: {
|
|
96
106
|
name: 'transfer_to_public',
|
|
97
|
-
args: [this.
|
|
107
|
+
args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
|
|
98
108
|
selector: await FunctionSelector.fromSignature('transfer_to_public((Field),(Field),u128,Field)'),
|
|
99
109
|
type: FunctionType.PRIVATE,
|
|
110
|
+
hideMsgSender: false,
|
|
100
111
|
isStatic: false,
|
|
101
112
|
to: await this.getAsset(),
|
|
102
113
|
returnTypes: [],
|
|
103
114
|
},
|
|
104
115
|
});
|
|
105
116
|
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
return new ExecutionPayload(
|
|
118
|
+
[
|
|
119
|
+
{
|
|
120
|
+
name: 'fee_entrypoint_private',
|
|
121
|
+
to: this.paymentContract,
|
|
122
|
+
selector: await FunctionSelector.fromSignature('fee_entrypoint_private(u128,Field)'),
|
|
123
|
+
type: FunctionType.PRIVATE,
|
|
124
|
+
hideMsgSender: false,
|
|
125
|
+
isStatic: false,
|
|
126
|
+
args: [maxFee, txNonce],
|
|
127
|
+
returnTypes: [],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
[witness],
|
|
131
|
+
[],
|
|
132
|
+
[],
|
|
133
|
+
this.paymentContract, // feePayer
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
getGasSettings(): GasSettings | undefined {
|
|
138
|
+
return this.gasSettings;
|
|
117
139
|
}
|
|
118
140
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
8
|
+
import { SetPublicAuthwitContractInteraction } from '../utils/authwit.js';
|
|
9
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
10
10
|
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -23,48 +23,58 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
23
23
|
/**
|
|
24
24
|
* An auth witness provider to authorize fee payments
|
|
25
25
|
*/
|
|
26
|
-
protected
|
|
26
|
+
protected sender: AztecAddress,
|
|
27
|
+
/**
|
|
28
|
+
* A wallet to perform the simulation to get the accepted asset
|
|
29
|
+
*/
|
|
30
|
+
protected wallet: Wallet,
|
|
31
|
+
/**
|
|
32
|
+
* Gas settings used to compute the maximum fee the user is willing to pay
|
|
33
|
+
*/
|
|
34
|
+
protected gasSettings: GasSettings,
|
|
27
35
|
) {}
|
|
28
36
|
|
|
29
37
|
/**
|
|
30
38
|
* The asset used to pay the fee.
|
|
31
39
|
* @returns The asset used to pay the fee.
|
|
32
40
|
*/
|
|
33
|
-
getAsset(): Promise<AztecAddress> {
|
|
41
|
+
async getAsset(): Promise<AztecAddress> {
|
|
34
42
|
if (!this.assetPromise) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
51
|
-
fields: [
|
|
52
|
-
{
|
|
53
|
-
name: 'inner',
|
|
54
|
-
type: {
|
|
55
|
-
kind: 'field',
|
|
56
|
-
},
|
|
43
|
+
const abi = {
|
|
44
|
+
name: 'get_accepted_asset',
|
|
45
|
+
functionType: FunctionType.PRIVATE,
|
|
46
|
+
isOnlySelf: false,
|
|
47
|
+
isStatic: false,
|
|
48
|
+
parameters: [],
|
|
49
|
+
returnTypes: [
|
|
50
|
+
{
|
|
51
|
+
kind: 'struct',
|
|
52
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
53
|
+
fields: [
|
|
54
|
+
{
|
|
55
|
+
name: 'inner',
|
|
56
|
+
type: {
|
|
57
|
+
kind: 'field',
|
|
57
58
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
errorTypes: {},
|
|
64
|
+
isInitializer: false,
|
|
65
|
+
} as FunctionAbi;
|
|
66
|
+
const interaction = new ContractFunctionInteraction(this.wallet, this.paymentContract, abi, []);
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
const executionPayload = await interaction.request();
|
|
69
|
+
this.assetPromise = this.wallet
|
|
70
|
+
.simulateTx(executionPayload, {
|
|
71
|
+
from: AztecAddress.ZERO,
|
|
72
|
+
skipFeeEnforcement: true,
|
|
73
|
+
})
|
|
74
|
+
.then(simulationResult => {
|
|
75
|
+
const rawReturnValues = simulationResult.getPrivateReturnValues().nested[0].values;
|
|
76
|
+
return decodeFromAbi(abi.returnTypes, rawReturnValues!);
|
|
77
|
+
}) as Promise<AztecAddress>;
|
|
68
78
|
}
|
|
69
79
|
return this.assetPromise!;
|
|
70
80
|
}
|
|
@@ -74,41 +84,57 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
/**
|
|
77
|
-
* Creates
|
|
87
|
+
* Creates an execution payload to pay the fee using a public function through an FPC in the desired asset
|
|
78
88
|
* @param gasSettings - The gas settings.
|
|
79
|
-
* @returns
|
|
89
|
+
* @returns An execution payload that contains the required function calls.
|
|
80
90
|
*/
|
|
81
|
-
async
|
|
82
|
-
const
|
|
83
|
-
const maxFee = gasSettings.getFeeLimit();
|
|
91
|
+
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
92
|
+
const txNonce = Fr.random();
|
|
93
|
+
const maxFee = this.gasSettings.getFeeLimit();
|
|
84
94
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
const intent = {
|
|
96
|
+
caller: this.paymentContract,
|
|
97
|
+
call: {
|
|
98
|
+
name: 'transfer_in_public',
|
|
99
|
+
args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
|
|
100
|
+
selector: await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),u128,Field)'),
|
|
101
|
+
type: FunctionType.PUBLIC,
|
|
102
|
+
isStatic: false,
|
|
103
|
+
hideMsgSender: false /** The target function performs an authwit check, so msg_sender is needed */,
|
|
104
|
+
to: await this.getAsset(),
|
|
105
|
+
returnTypes: [],
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const setPublicAuthWitInteraction = await SetPublicAuthwitContractInteraction.create(
|
|
110
|
+
this.wallet,
|
|
111
|
+
this.sender,
|
|
112
|
+
intent,
|
|
113
|
+
true,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
return new ExecutionPayload(
|
|
117
|
+
[
|
|
118
|
+
...(await setPublicAuthWitInteraction.request()).calls,
|
|
119
|
+
{
|
|
120
|
+
name: 'fee_entrypoint_public',
|
|
121
|
+
to: this.paymentContract,
|
|
122
|
+
selector: await FunctionSelector.fromSignature('fee_entrypoint_public(u128,Field)'),
|
|
123
|
+
type: FunctionType.PRIVATE,
|
|
124
|
+
hideMsgSender: false,
|
|
93
125
|
isStatic: false,
|
|
94
|
-
|
|
126
|
+
args: [maxFee, txNonce],
|
|
95
127
|
returnTypes: [],
|
|
96
128
|
},
|
|
97
|
-
|
|
98
|
-
|
|
129
|
+
],
|
|
130
|
+
[],
|
|
131
|
+
[],
|
|
132
|
+
[],
|
|
133
|
+
this.paymentContract, // feePayer
|
|
99
134
|
);
|
|
135
|
+
}
|
|
100
136
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
{
|
|
104
|
-
name: 'fee_entrypoint_public',
|
|
105
|
-
to: this.paymentContract,
|
|
106
|
-
selector: await FunctionSelector.fromSignature('fee_entrypoint_public(u128,Field)'),
|
|
107
|
-
type: FunctionType.PRIVATE,
|
|
108
|
-
isStatic: false,
|
|
109
|
-
args: [maxFee, nonce],
|
|
110
|
-
returnTypes: [],
|
|
111
|
-
},
|
|
112
|
-
];
|
|
137
|
+
getGasSettings(): GasSettings | undefined {
|
|
138
|
+
return this.gasSettings;
|
|
113
139
|
}
|
|
114
140
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
2
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
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
|
+
/**
|
|
8
|
+
* A fee payment method that uses a contract that blindly sponsors transactions.
|
|
9
|
+
* This contract is expected to be prefunded in testing environments.
|
|
10
|
+
*/
|
|
11
|
+
export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
12
|
+
constructor(private paymentContract: AztecAddress) {}
|
|
13
|
+
|
|
14
|
+
getAsset(): Promise<AztecAddress> {
|
|
15
|
+
throw new Error('Asset is not required for sponsored fpc.');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getFeePayer() {
|
|
19
|
+
return Promise.resolve(this.paymentContract);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
23
|
+
return new ExecutionPayload(
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
name: 'sponsor_unconditionally',
|
|
27
|
+
to: this.paymentContract,
|
|
28
|
+
selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
|
|
29
|
+
type: FunctionType.PRIVATE,
|
|
30
|
+
hideMsgSender: false,
|
|
31
|
+
isStatic: false,
|
|
32
|
+
args: [],
|
|
33
|
+
returnTypes: [],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
[],
|
|
37
|
+
[],
|
|
38
|
+
[],
|
|
39
|
+
this.paymentContract, // feePayer
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getGasSettings(): GasSettings | undefined {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates type-safe contract wrappers for protocol contracts.
|
|
3
|
+
* These wrappers use a minimal artifact (without bytecode) since PXE already has the full artifacts registered.
|
|
4
|
+
*/
|
|
5
|
+
import { generateTypescriptContractInterface } from '@aztec/builder/codegen';
|
|
6
|
+
import {
|
|
7
|
+
type ContractArtifact,
|
|
8
|
+
type FunctionAbi,
|
|
9
|
+
FunctionType,
|
|
10
|
+
getAllFunctionAbis,
|
|
11
|
+
loadContractArtifact,
|
|
12
|
+
} from '@aztec/stdlib/abi';
|
|
13
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
14
|
+
|
|
15
|
+
import { promises as fs } from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
|
|
18
|
+
const log = console.log;
|
|
19
|
+
|
|
20
|
+
const noirContractsRoot = path.join(import.meta.dirname, '../../../../noir-projects/noir-contracts');
|
|
21
|
+
const srcPath = path.join(noirContractsRoot, 'target');
|
|
22
|
+
const outputDir = path.join(import.meta.dirname, '../contract/protocol_contracts');
|
|
23
|
+
|
|
24
|
+
function toKebabCase(str: string): string {
|
|
25
|
+
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function functionTypeToEnum(type: FunctionType): string {
|
|
29
|
+
switch (type) {
|
|
30
|
+
case FunctionType.PRIVATE:
|
|
31
|
+
return 'FunctionType.PRIVATE';
|
|
32
|
+
case FunctionType.PUBLIC:
|
|
33
|
+
return 'FunctionType.PUBLIC';
|
|
34
|
+
case FunctionType.UTILITY:
|
|
35
|
+
return 'FunctionType.UTILITY';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function generateFunctionAbiJson(abi: FunctionAbi): string {
|
|
40
|
+
const baseObj = {
|
|
41
|
+
name: abi.name,
|
|
42
|
+
isOnlySelf: abi.isOnlySelf,
|
|
43
|
+
isStatic: abi.isStatic,
|
|
44
|
+
isInitializer: abi.isInitializer,
|
|
45
|
+
parameters: abi.parameters,
|
|
46
|
+
returnTypes: abi.returnTypes,
|
|
47
|
+
errorTypes: abi.errorTypes,
|
|
48
|
+
};
|
|
49
|
+
const jsonStr = JSON.stringify(baseObj);
|
|
50
|
+
return jsonStr.replace('{', `{ functionType: ${functionTypeToEnum(abi.functionType)},`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function generateProtocolContractArtifact(input: ContractArtifact): string {
|
|
54
|
+
const allAbis = getAllFunctionAbis(input);
|
|
55
|
+
const functionAbis = input.functions.map(f => allAbis.find(abi => abi.name === f.name)!);
|
|
56
|
+
const nonDispatchAbis = input.nonDispatchPublicFunctions;
|
|
57
|
+
|
|
58
|
+
const functionsArray = functionAbis
|
|
59
|
+
.map(abi => `{ ...${generateFunctionAbiJson(abi)}, bytecode: Buffer.from([]), debugSymbols: '' }`)
|
|
60
|
+
.join(',\n ');
|
|
61
|
+
|
|
62
|
+
const nonDispatchArray = nonDispatchAbis.map(abi => generateFunctionAbiJson(abi)).join(',\n ');
|
|
63
|
+
|
|
64
|
+
return `{
|
|
65
|
+
name: '${input.name}',
|
|
66
|
+
functions: [
|
|
67
|
+
${functionsArray}
|
|
68
|
+
],
|
|
69
|
+
nonDispatchPublicFunctions: [
|
|
70
|
+
${nonDispatchArray}
|
|
71
|
+
],
|
|
72
|
+
outputs: { structs: {}, globals: {} },
|
|
73
|
+
storageLayout: {},
|
|
74
|
+
fileMap: {},
|
|
75
|
+
}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function generateProtocolContractInterface(
|
|
79
|
+
input: ContractArtifact,
|
|
80
|
+
protocolContractName: string,
|
|
81
|
+
): Promise<string> {
|
|
82
|
+
const baseInterface = await generateTypescriptContractInterface(input);
|
|
83
|
+
|
|
84
|
+
// Match everything between "public declare methods: {" and the closing "};"
|
|
85
|
+
const methodsMatch = baseInterface.match(/public declare methods: \{([\s\S]*?)\n \};/);
|
|
86
|
+
if (!methodsMatch) {
|
|
87
|
+
throw new Error('Could not extract methods from generated interface');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const artifactCode = generateProtocolContractArtifact(input);
|
|
91
|
+
const contractName = `${input.name}Contract`;
|
|
92
|
+
|
|
93
|
+
return `
|
|
94
|
+
/* Autogenerated file, do not edit! */
|
|
95
|
+
|
|
96
|
+
/* eslint-disable */
|
|
97
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
98
|
+
import { FunctionType } from '@aztec/stdlib/abi';
|
|
99
|
+
|
|
100
|
+
import type { ContractArtifact } from '../../api/abi.js';
|
|
101
|
+
import { PublicKeys } from '../../api/keys.js';
|
|
102
|
+
import type { AztecAddressLike, EthAddressLike, FieldLike, FunctionSelectorLike, WrappedFieldLike } from '../../utils/abi_types.js';
|
|
103
|
+
import { ContractBase, type ContractMethod } from '../contract_base.js';
|
|
104
|
+
import { ContractFunctionInteraction } from '../contract_function_interaction.js';
|
|
105
|
+
import type { Wallet } from '../../wallet/wallet.js';
|
|
106
|
+
|
|
107
|
+
const ${contractName}Artifact: ContractArtifact = ${artifactCode};
|
|
108
|
+
|
|
109
|
+
export class ${contractName} extends ContractBase {
|
|
110
|
+
private constructor(wallet: Wallet) {
|
|
111
|
+
super(ProtocolContractAddress.${protocolContractName}, ${contractName}Artifact, wallet);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public static at(wallet: Wallet): ${contractName} {
|
|
115
|
+
return new ${contractName}(wallet);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public declare methods: {${methodsMatch[1]}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function main() {
|
|
125
|
+
await fs.rm(outputDir, { recursive: true, force: true });
|
|
126
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
127
|
+
|
|
128
|
+
const srcNames = JSON.parse(
|
|
129
|
+
await fs.readFile(path.join(noirContractsRoot, 'protocol_contracts.json'), 'utf8'),
|
|
130
|
+
) as string[];
|
|
131
|
+
|
|
132
|
+
for (const srcName of srcNames) {
|
|
133
|
+
// srcName is like "auth_registry_contract-AuthRegistry", split to get the contract name
|
|
134
|
+
const name = srcName.split('-')[1];
|
|
135
|
+
const artifactPath = path.join(srcPath, `${srcName}.json`);
|
|
136
|
+
const json = JSON.parse(await fs.readFile(artifactPath, 'utf8')) as NoirCompiledContract;
|
|
137
|
+
const contractArtifact = loadContractArtifact(json);
|
|
138
|
+
|
|
139
|
+
const content = await generateProtocolContractInterface(contractArtifact, name);
|
|
140
|
+
const fileName = `${toKebabCase(name)}.ts`;
|
|
141
|
+
await fs.writeFile(path.join(outputDir, fileName), content);
|
|
142
|
+
|
|
143
|
+
log(`Generated ${fileName}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
main().catch(err => {
|
|
148
|
+
console.error('Error generating protocol contract types:', err);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
});
|
package/src/utils/abi_types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
1
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import type { EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
|