@aztec/aztec.js 0.0.0-test.1 → 0.0.1-commit.b655e406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dest/account/account.d.ts +60 -0
- package/dest/account/account.d.ts.map +1 -0
- package/dest/account/account.js +59 -0
- package/dest/account/{contract.d.ts → account_contract.d.ts} +16 -10
- package/dest/account/account_contract.d.ts.map +1 -0
- package/dest/account/{contract.js → account_contract.js} +7 -4
- package/dest/{wallet/account_wallet_with_private_key.d.ts → account/account_with_secret_key.d.ts} +7 -8
- package/dest/account/account_with_secret_key.d.ts.map +1 -0
- package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
- package/dest/account/index.d.ts +3 -7
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -6
- package/dest/account/interface.d.ts +1 -13
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/interface.js +1 -0
- package/dest/account/signerless_account.d.ts +24 -0
- package/dest/account/signerless_account.d.ts.map +1 -0
- package/dest/account/signerless_account.js +27 -0
- package/dest/api/abi.d.ts +2 -1
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/abi.js +1 -1
- package/dest/api/account.d.ts +5 -2
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +3 -1
- package/dest/api/addresses.d.ts +1 -0
- package/dest/api/addresses.d.ts.map +1 -1
- package/dest/api/addresses.js +1 -0
- package/dest/api/authorization.d.ts +5 -0
- package/dest/api/authorization.d.ts.map +1 -0
- package/dest/api/authorization.js +4 -0
- package/dest/api/block.d.ts +3 -0
- package/dest/api/block.d.ts.map +1 -0
- package/dest/api/block.js +2 -0
- package/dest/{contract/index.d.ts → api/contract.d.ts} +15 -11
- package/dest/api/contract.d.ts.map +1 -0
- package/dest/{contract/index.js → api/contract.js} +14 -10
- package/dest/api/crypto.d.ts +2 -0
- package/dest/api/crypto.d.ts.map +1 -0
- package/dest/api/crypto.js +1 -0
- package/dest/api/deployment.d.ts +4 -3
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +4 -3
- package/dest/api/ethereum.d.ts +2 -0
- package/dest/api/ethereum.d.ts.map +1 -0
- package/dest/api/ethereum.js +1 -0
- package/dest/api/events.d.ts +12 -0
- package/dest/api/events.d.ts.map +1 -0
- package/dest/api/events.js +30 -0
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +1 -1
- package/dest/api/fee_testing.d.ts +2 -0
- package/dest/api/fee_testing.d.ts.map +1 -0
- package/dest/api/fee_testing.js +1 -0
- package/dest/api/keys.d.ts +4 -0
- package/dest/api/keys.d.ts.map +1 -0
- package/dest/api/keys.js +3 -0
- package/dest/api/log.d.ts +1 -0
- package/dest/api/log.d.ts.map +1 -1
- package/dest/api/log.js +1 -0
- package/dest/api/messaging.d.ts +3 -0
- package/dest/api/messaging.d.ts.map +1 -0
- package/dest/api/messaging.js +2 -0
- package/dest/api/node.d.ts +21 -0
- package/dest/api/node.d.ts.map +1 -0
- package/dest/api/node.js +18 -0
- package/dest/api/note.d.ts +2 -0
- package/dest/api/note.d.ts.map +1 -0
- package/dest/api/note.js +1 -0
- package/dest/api/protocol.d.ts +3 -0
- package/dest/api/protocol.d.ts.map +1 -0
- package/dest/api/protocol.js +2 -0
- package/dest/api/trees.d.ts +3 -0
- package/dest/api/trees.d.ts.map +1 -0
- package/dest/api/trees.js +2 -0
- package/dest/api/tx.d.ts +2 -0
- package/dest/api/tx.d.ts.map +1 -0
- package/dest/api/tx.js +1 -0
- package/dest/api/utils.d.ts +13 -0
- package/dest/api/utils.d.ts.map +1 -0
- package/dest/api/utils.js +12 -0
- package/dest/api/wallet.d.ts +4 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +4 -1
- package/dest/authorization/call_authorization_request.d.ts +67 -0
- package/dest/authorization/call_authorization_request.d.ts.map +1 -0
- package/dest/authorization/call_authorization_request.js +49 -0
- package/dest/contract/base_contract_interaction.d.ts +16 -79
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +15 -128
- package/dest/contract/batch_call.d.ts +13 -14
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +60 -60
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/checker.d.ts.map +1 -1
- package/dest/contract/checker.js +2 -2
- package/dest/contract/contract.d.ts +7 -6
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +7 -16
- package/dest/contract/contract_base.d.ts +3 -9
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +2 -2
- package/dest/contract/contract_function_interaction.d.ts +52 -44
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +75 -74
- package/dest/contract/deploy_method.d.ts +102 -57
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +122 -132
- package/dest/contract/deploy_sent_tx.d.ts +3 -5
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +10 -13
- package/dest/contract/get_gas_limits.d.ts +5 -6
- package/dest/contract/get_gas_limits.d.ts.map +1 -1
- package/dest/contract/get_gas_limits.js +9 -3
- package/dest/contract/interaction_options.d.ts +114 -0
- package/dest/contract/interaction_options.d.ts.map +1 -0
- package/dest/contract/interaction_options.js +52 -0
- package/dest/contract/protocol_contracts.d.ts +6 -6
- package/dest/contract/protocol_contracts.d.ts.map +1 -1
- package/dest/contract/protocol_contracts.js +7 -7
- package/dest/contract/sent_tx.d.ts +8 -18
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +30 -42
- package/dest/contract/unsafe_contract.d.ts +1 -1
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.d.ts +17 -0
- package/dest/contract/wait_for_proven.d.ts.map +1 -0
- package/dest/contract/wait_for_proven.js +17 -0
- package/dest/deployment/broadcast_function.d.ts +3 -3
- package/dest/deployment/broadcast_function.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.js +27 -23
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/publish_class.d.ts +6 -0
- package/dest/deployment/publish_class.d.ts.map +1 -0
- package/dest/deployment/publish_class.js +17 -0
- package/dest/deployment/publish_instance.d.ts +10 -0
- package/dest/deployment/publish_instance.d.ts.map +1 -0
- package/dest/deployment/publish_instance.js +11 -0
- package/dest/{api/ethereum → ethereum}/portal_manager.d.ts +29 -25
- package/dest/ethereum/portal_manager.d.ts.map +1 -0
- package/dest/{api/ethereum → ethereum}/portal_manager.js +106 -73
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +16 -11
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +26 -16
- package/dest/fee/fee_payment_method.d.ts +11 -7
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +25 -8
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +43 -21
- package/dest/fee/public_fee_payment_method.d.ts +26 -9
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +45 -23
- package/dest/fee/sponsored_fee_payment.d.ts +17 -0
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -0
- package/dest/fee/sponsored_fee_payment.js +34 -0
- package/dest/utils/abi_types.d.ts +0 -2
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +81 -24
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +226 -40
- package/dest/utils/cross_chain.d.ts +24 -0
- package/dest/utils/cross_chain.d.ts.map +1 -0
- package/dest/utils/cross_chain.js +30 -0
- package/dest/utils/fee_juice.d.ts +3 -2
- package/dest/utils/fee_juice.d.ts.map +1 -1
- package/dest/utils/fee_juice.js +3 -2
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +1 -1
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +1 -2
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +34 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
- package/dest/wallet/account_manager.d.ts +69 -0
- package/dest/wallet/account_manager.d.ts.map +1 -0
- package/dest/wallet/account_manager.js +113 -0
- package/dest/wallet/base_wallet.d.ts +81 -63
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +221 -106
- package/dest/wallet/deploy_account_method.d.ts +52 -0
- package/dest/wallet/deploy_account_method.d.ts.map +1 -0
- package/dest/wallet/deploy_account_method.js +77 -0
- package/dest/wallet/index.d.ts +3 -16
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +3 -20
- package/dest/wallet/wallet.d.ts +2478 -0
- package/dest/wallet/wallet.d.ts.map +1 -0
- package/dest/wallet/wallet.js +202 -0
- package/package.json +40 -32
- package/src/account/account.ts +97 -0
- package/src/account/{contract.ts → account_contract.ts} +24 -13
- package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +6 -8
- package/src/account/index.ts +3 -7
- package/src/account/interface.ts +1 -12
- package/src/account/signerless_account.ts +46 -0
- package/src/api/abi.ts +26 -0
- package/src/api/account.ts +5 -9
- package/src/api/addresses.ts +1 -0
- package/src/api/authorization.ts +14 -0
- package/src/api/block.ts +2 -0
- package/src/{contract/index.ts → api/contract.ts} +37 -13
- package/src/api/crypto.ts +1 -0
- package/src/api/deployment.ts +4 -3
- package/src/api/ethereum.ts +10 -0
- package/src/api/events.ts +44 -0
- package/src/api/fee.ts +1 -1
- package/src/api/fee_testing.ts +1 -0
- package/src/api/keys.ts +8 -0
- package/src/api/log.ts +1 -0
- package/src/api/messaging.ts +2 -0
- package/src/api/node.ts +20 -0
- package/src/api/note.ts +1 -0
- package/src/api/protocol.ts +2 -0
- package/src/api/trees.ts +2 -0
- package/src/api/tx.ts +11 -0
- package/src/api/utils.ts +14 -0
- package/src/api/wallet.ts +33 -5
- package/src/authorization/call_authorization_request.ts +63 -0
- package/src/contract/base_contract_interaction.ts +24 -166
- package/src/contract/batch_call.ts +81 -49
- package/src/contract/checker.ts +8 -3
- package/src/contract/contract.ts +8 -17
- package/src/contract/contract_base.ts +4 -11
- package/src/contract/contract_function_interaction.ts +136 -106
- package/src/contract/deploy_method.ts +199 -129
- package/src/contract/deploy_sent_tx.ts +9 -15
- package/src/contract/get_gas_limits.ts +15 -8
- package/src/contract/interaction_options.ts +169 -0
- package/src/contract/protocol_contracts.ts +10 -10
- package/src/contract/sent_tx.ts +40 -51
- package/src/contract/unsafe_contract.ts +1 -1
- package/src/contract/wait_for_proven.ts +38 -0
- package/src/deployment/broadcast_function.ts +57 -57
- package/src/deployment/contract_deployer.ts +1 -1
- package/src/deployment/publish_class.ts +34 -0
- package/src/deployment/publish_instance.ts +26 -0
- package/src/{api/ethereum → ethereum}/portal_manager.ts +120 -74
- package/src/fee/fee_juice_payment_method_with_claim.ts +46 -33
- package/src/fee/fee_payment_method.ts +11 -7
- package/src/fee/private_fee_payment_method.ts +77 -57
- package/src/fee/public_fee_payment_method.ts +91 -67
- package/src/fee/sponsored_fee_payment.ts +44 -0
- package/src/utils/authwit.ts +255 -53
- package/src/utils/cross_chain.ts +53 -0
- package/src/utils/fee_juice.ts +4 -4
- package/src/utils/node.ts +1 -1
- package/src/utils/pub_key.ts +1 -2
- package/src/wallet/account_entrypoint_meta_payment_method.ts +105 -0
- package/src/wallet/account_manager.ts +154 -0
- package/src/wallet/base_wallet.ts +295 -143
- package/src/wallet/deploy_account_method.ts +125 -0
- package/src/wallet/index.ts +3 -33
- package/src/wallet/wallet.ts +362 -0
- package/dest/account/contract.d.ts.map +0 -1
- package/dest/account/wallet.d.ts +0 -11
- package/dest/account/wallet.d.ts.map +0 -1
- package/dest/account/wallet.js +0 -3
- package/dest/account_manager/deploy_account_method.d.ts +0 -15
- package/dest/account_manager/deploy_account_method.d.ts.map +0 -1
- package/dest/account_manager/deploy_account_method.js +0 -43
- package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
- package/dest/account_manager/deploy_account_sent_tx.js +0 -29
- package/dest/account_manager/index.d.ts +0 -108
- package/dest/account_manager/index.d.ts.map +0 -1
- package/dest/account_manager/index.js +0 -159
- package/dest/api/cheat_codes.d.ts +0 -26
- package/dest/api/cheat_codes.d.ts.map +0 -1
- package/dest/api/cheat_codes.js +0 -25
- package/dest/api/entrypoint.d.ts +0 -2
- package/dest/api/entrypoint.d.ts.map +0 -1
- package/dest/api/entrypoint.js +0 -1
- package/dest/api/ethereum/anvil_test_watcher.d.ts +0 -32
- package/dest/api/ethereum/anvil_test_watcher.d.ts.map +0 -1
- package/dest/api/ethereum/anvil_test_watcher.js +0 -133
- package/dest/api/ethereum/chain_monitor.d.ts +0 -25
- package/dest/api/ethereum/chain_monitor.d.ts.map +0 -1
- package/dest/api/ethereum/chain_monitor.js +0 -74
- package/dest/api/ethereum/cheat_codes.d.ts +0 -63
- package/dest/api/ethereum/cheat_codes.d.ts.map +0 -1
- package/dest/api/ethereum/cheat_codes.js +0 -162
- package/dest/api/ethereum/index.d.ts +0 -7
- package/dest/api/ethereum/index.d.ts.map +0 -1
- package/dest/api/ethereum/index.js +0 -6
- package/dest/api/ethereum/l1_contracts.d.ts +0 -3
- package/dest/api/ethereum/l1_contracts.d.ts.map +0 -1
- package/dest/api/ethereum/l1_contracts.js +0 -13
- package/dest/api/ethereum/portal_manager.d.ts.map +0 -1
- package/dest/api/interfaces/pxe.d.ts +0 -2
- package/dest/api/interfaces/pxe.d.ts.map +0 -1
- package/dest/api/interfaces/pxe.js +0 -1
- package/dest/api/log_id.d.ts +0 -2
- package/dest/api/log_id.d.ts.map +0 -1
- package/dest/api/log_id.js +0 -1
- package/dest/api/tx_hash.d.ts +0 -2
- package/dest/api/tx_hash.d.ts.map +0 -1
- package/dest/api/tx_hash.js +0 -1
- package/dest/contract/deploy_proven_tx.d.ts +0 -21
- package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
- package/dest/contract/deploy_proven_tx.js +0 -19
- package/dest/contract/index.d.ts.map +0 -1
- package/dest/contract/proven_tx.d.ts +0 -17
- package/dest/contract/proven_tx.d.ts.map +0 -1
- package/dest/contract/proven_tx.js +0 -22
- package/dest/deployment/deploy_instance.d.ts +0 -10
- package/dest/deployment/deploy_instance.d.ts.map +0 -1
- package/dest/deployment/deploy_instance.js +0 -14
- package/dest/deployment/index.d.ts +0 -2
- package/dest/deployment/index.d.ts.map +0 -1
- package/dest/deployment/index.js +0 -1
- package/dest/deployment/register_class.d.ts +0 -6
- package/dest/deployment/register_class.d.ts.map +0 -1
- package/dest/deployment/register_class.js +0 -22
- package/dest/entrypoint/default_entrypoint.d.ts +0 -12
- package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/default_entrypoint.js +0 -28
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +0 -15
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +0 -130
- package/dest/entrypoint/entrypoint.d.ts +0 -35
- package/dest/entrypoint/entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/entrypoint.js +0 -4
- package/dest/entrypoint/payload.d.ts +0 -128
- package/dest/entrypoint/payload.d.ts.map +0 -1
- package/dest/entrypoint/payload.js +0 -143
- package/dest/fee/fee_juice_payment_method.d.ts +0 -14
- package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
- package/dest/fee/fee_juice_payment_method.js +0 -20
- package/dest/index.d.ts +0 -66
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -69
- package/dest/rpc_clients/index.d.ts +0 -3
- package/dest/rpc_clients/index.d.ts.map +0 -1
- package/dest/rpc_clients/index.js +0 -2
- package/dest/rpc_clients/node/index.d.ts +0 -12
- package/dest/rpc_clients/node/index.d.ts.map +0 -1
- package/dest/rpc_clients/node/index.js +0 -78
- package/dest/rpc_clients/pxe_client.d.ts +0 -10
- package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
- package/dest/rpc_clients/pxe_client.js +0 -23
- package/dest/utils/aztec_cheatcodes.d.ts +0 -59
- package/dest/utils/aztec_cheatcodes.d.ts.map +0 -1
- package/dest/utils/aztec_cheatcodes.js +0 -62
- package/dest/utils/index.d.ts +0 -8
- package/dest/utils/index.d.ts.map +0 -1
- package/dest/utils/index.js +0 -6
- package/dest/utils/pxe.d.ts +0 -4
- package/dest/utils/pxe.d.ts.map +0 -1
- package/dest/utils/pxe.js +0 -14
- package/dest/wallet/account_wallet.d.ts +0 -76
- package/dest/wallet/account_wallet.d.ts.map +0 -1
- package/dest/wallet/account_wallet.js +0 -231
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.d.ts +0 -25
- package/dest/wallet/signerless_wallet.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.js +0 -36
- package/src/account/wallet.ts +0 -13
- package/src/account_manager/deploy_account_method.ts +0 -86
- package/src/account_manager/deploy_account_sent_tx.ts +0 -42
- package/src/account_manager/index.ts +0 -229
- package/src/api/cheat_codes.ts +0 -35
- package/src/api/entrypoint.ts +0 -1
- package/src/api/ethereum/anvil_test_watcher.ts +0 -158
- package/src/api/ethereum/chain_monitor.ts +0 -88
- package/src/api/ethereum/cheat_codes.ts +0 -184
- package/src/api/ethereum/index.ts +0 -19
- package/src/api/ethereum/l1_contracts.ts +0 -21
- package/src/api/interfaces/pxe.ts +0 -1
- package/src/api/log_id.ts +0 -1
- package/src/api/tx_hash.ts +0 -1
- package/src/contract/deploy_proven_tx.ts +0 -34
- package/src/contract/proven_tx.ts +0 -42
- package/src/deployment/deploy_instance.ts +0 -31
- package/src/deployment/index.ts +0 -1
- package/src/deployment/register_class.ts +0 -44
- package/src/entrypoint/default_entrypoint.ts +0 -39
- package/src/entrypoint/default_multi_call_entrypoint.ts +0 -93
- package/src/entrypoint/entrypoint.ts +0 -39
- package/src/entrypoint/payload.ts +0 -238
- package/src/fee/fee_juice_payment_method.ts +0 -26
- package/src/index.ts +0 -106
- package/src/rpc_clients/index.ts +0 -2
- package/src/rpc_clients/node/index.ts +0 -77
- package/src/rpc_clients/pxe_client.ts +0 -25
- package/src/utils/aztec_cheatcodes.ts +0 -77
- package/src/utils/index.ts +0 -21
- package/src/utils/pxe.ts +0 -17
- package/src/wallet/account_wallet.ts +0 -242
- package/src/wallet/signerless_wallet.ts +0 -52
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtendedViemWalletClient, ViemContract } from '@aztec/ethereum';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
5
5
|
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
6
|
-
import { TokenPortalAbi } from '@aztec/l1-artifacts';
|
|
6
|
+
import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
|
|
7
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import type {
|
|
9
|
-
import { type
|
|
8
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
9
|
+
import { type Hex } from 'viem';
|
|
10
10
|
/** L1 to L2 message info to claim it on L2. */
|
|
11
11
|
export type L2Claim = {
|
|
12
12
|
/** Secret for claiming. */
|
|
@@ -31,26 +31,33 @@ export declare function generateClaimSecret(logger?: Logger): Promise<[Fr, Fr]>;
|
|
|
31
31
|
/** Helper for managing an ERC20 on L1. */
|
|
32
32
|
export declare class L1TokenManager {
|
|
33
33
|
/** Address of the ERC20 contract. */
|
|
34
|
-
readonly
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
readonly tokenAddress: EthAddress;
|
|
35
|
+
/** Address of the handler/faucet contract. */
|
|
36
|
+
readonly handlerAddress: EthAddress | undefined;
|
|
37
|
+
private readonly extendedClient;
|
|
37
38
|
private logger;
|
|
38
39
|
private contract;
|
|
40
|
+
private handler;
|
|
39
41
|
constructor(
|
|
40
42
|
/** Address of the ERC20 contract. */
|
|
41
|
-
|
|
43
|
+
tokenAddress: EthAddress,
|
|
44
|
+
/** Address of the handler/faucet contract. */
|
|
45
|
+
handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
46
|
+
/** Returns the amount of tokens available to mint via the handler.
|
|
47
|
+
* @throws if the handler is not provided.
|
|
48
|
+
*/
|
|
49
|
+
getMintAmount(): Promise<bigint>;
|
|
42
50
|
/**
|
|
43
51
|
* Returns the balance of the given address.
|
|
44
52
|
* @param address - Address to get the balance of.
|
|
45
53
|
*/
|
|
46
54
|
getL1TokenBalance(address: Hex): Promise<bigint>;
|
|
47
55
|
/**
|
|
48
|
-
* Mints tokens for the given address. Returns once the tx has been mined.
|
|
49
|
-
* @param amount - Amount to mint.
|
|
56
|
+
* Mints a fixed amount of tokens for the given address. Returns once the tx has been mined.
|
|
50
57
|
* @param address - Address to mint the tokens for.
|
|
51
58
|
* @param addressName - Optional name of the address for logging.
|
|
52
59
|
*/
|
|
53
|
-
mint(
|
|
60
|
+
mint(address: Hex, addressName?: string): Promise<void>;
|
|
54
61
|
/**
|
|
55
62
|
* Approves tokens for the given address. Returns once the tx has been mined.
|
|
56
63
|
* @param amount - Amount to approve.
|
|
@@ -61,12 +68,11 @@ export declare class L1TokenManager {
|
|
|
61
68
|
}
|
|
62
69
|
/** Helper for interacting with the FeeJuicePortal on L1. */
|
|
63
70
|
export declare class L1FeeJuicePortalManager {
|
|
64
|
-
private readonly
|
|
65
|
-
private readonly walletClient;
|
|
71
|
+
private readonly extendedClient;
|
|
66
72
|
private readonly logger;
|
|
67
73
|
private readonly tokenManager;
|
|
68
74
|
private readonly contract;
|
|
69
|
-
constructor(portalAddress: EthAddress, tokenAddress: EthAddress,
|
|
75
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
70
76
|
/** Returns the associated token manager for the L1 ERC20. */
|
|
71
77
|
getTokenManager(): L1TokenManager;
|
|
72
78
|
/**
|
|
@@ -75,24 +81,22 @@ export declare class L1FeeJuicePortalManager {
|
|
|
75
81
|
* @param amount - Amount of tokens to send.
|
|
76
82
|
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
77
83
|
*/
|
|
78
|
-
bridgeTokensPublic(to: AztecAddress, amount: bigint, mint?: boolean): Promise<L2AmountClaim>;
|
|
84
|
+
bridgeTokensPublic(to: AztecAddress, amount: bigint | undefined, mint?: boolean): Promise<L2AmountClaim>;
|
|
79
85
|
/**
|
|
80
86
|
* Creates a new instance
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
83
|
-
* @param walletClient - L1 wallet client.
|
|
87
|
+
* @param node - Aztec node client used for retrieving the L1 contract addresses.
|
|
88
|
+
* @param extendedClient - Wallet client, extended with public actions.
|
|
84
89
|
* @param logger - Logger.
|
|
85
90
|
*/
|
|
86
|
-
static new(
|
|
91
|
+
static new(node: AztecNode, extendedClient: ExtendedViemWalletClient, logger: Logger): Promise<L1FeeJuicePortalManager>;
|
|
87
92
|
}
|
|
88
93
|
/** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */
|
|
89
94
|
export declare class L1ToL2TokenPortalManager {
|
|
90
|
-
protected
|
|
91
|
-
protected walletClient: ViemWalletClient;
|
|
95
|
+
protected extendedClient: ExtendedViemWalletClient;
|
|
92
96
|
protected logger: Logger;
|
|
93
|
-
protected readonly portal:
|
|
97
|
+
protected readonly portal: ViemContract<typeof TokenPortalAbi>;
|
|
94
98
|
protected readonly tokenManager: L1TokenManager;
|
|
95
|
-
constructor(portalAddress: EthAddress, tokenAddress: EthAddress,
|
|
99
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
96
100
|
/** Returns the token manager for the underlying L1 token. */
|
|
97
101
|
getTokenManager(): L1TokenManager;
|
|
98
102
|
/**
|
|
@@ -114,7 +118,7 @@ export declare class L1ToL2TokenPortalManager {
|
|
|
114
118
|
/** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */
|
|
115
119
|
export declare class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
116
120
|
private readonly outbox;
|
|
117
|
-
constructor(portalAddress: EthAddress, tokenAddress: EthAddress,
|
|
121
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, outboxAddress: EthAddress, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
118
122
|
/**
|
|
119
123
|
* Withdraws funds from the portal by consuming an L2 to L1 message. Returns once the tx is mined on L1.
|
|
120
124
|
* @param amount - Amount to withdraw.
|
|
@@ -131,6 +135,6 @@ export declare class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
|
131
135
|
* @param l2Bridge - Address of the L2 bridge.
|
|
132
136
|
* @param callerOnL1 - Caller address on L1.
|
|
133
137
|
*/
|
|
134
|
-
getL2ToL1MessageLeaf(amount: bigint, recipient: EthAddress, l2Bridge: AztecAddress, callerOnL1?: EthAddress): Fr
|
|
138
|
+
getL2ToL1MessageLeaf(amount: bigint, recipient: EthAddress, l2Bridge: AztecAddress, callerOnL1?: EthAddress): Promise<Fr>;
|
|
135
139
|
}
|
|
136
140
|
//# sourceMappingURL=portal_manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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tB,UAAU,GAAE,UAA4B,GACvC,OAAO,CAAC,EAAE,CAAC;CAkBf"}
|
|
@@ -2,8 +2,13 @@ import { extractEvent } from '@aztec/ethereum/utils';
|
|
|
2
2
|
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts/FeeAssetHandlerAbi';
|
|
6
|
+
import { FeeJuicePortalAbi } from '@aztec/l1-artifacts/FeeJuicePortalAbi';
|
|
7
|
+
import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
|
|
8
|
+
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
9
|
+
import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
|
|
10
|
+
import { computeL2ToL1MessageHash, computeSecretHash } from '@aztec/stdlib/hash';
|
|
11
|
+
import { getL2ToL1MessageLeafId } from '@aztec/stdlib/messaging';
|
|
7
12
|
import { getContract, toFunctionSelector } from 'viem';
|
|
8
13
|
/** Stringifies an eth address for logging. */ function stringifyEthAddress(address, name) {
|
|
9
14
|
return name ? `${name} (${address.toString()})` : address.toString();
|
|
@@ -18,21 +23,37 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
18
23
|
];
|
|
19
24
|
}
|
|
20
25
|
/** Helper for managing an ERC20 on L1. */ export class L1TokenManager {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
tokenAddress;
|
|
27
|
+
handlerAddress;
|
|
28
|
+
extendedClient;
|
|
24
29
|
logger;
|
|
25
30
|
contract;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
31
|
+
handler;
|
|
32
|
+
constructor(/** Address of the ERC20 contract. */ tokenAddress, /** Address of the handler/faucet contract. */ handlerAddress, extendedClient, logger){
|
|
33
|
+
this.tokenAddress = tokenAddress;
|
|
34
|
+
this.handlerAddress = handlerAddress;
|
|
35
|
+
this.extendedClient = extendedClient;
|
|
30
36
|
this.logger = logger;
|
|
31
37
|
this.contract = getContract({
|
|
32
|
-
address: this.
|
|
38
|
+
address: this.tokenAddress.toString(),
|
|
33
39
|
abi: TestERC20Abi,
|
|
34
|
-
client: this.
|
|
40
|
+
client: this.extendedClient
|
|
35
41
|
});
|
|
42
|
+
if (this.handlerAddress) {
|
|
43
|
+
this.handler = getContract({
|
|
44
|
+
address: this.handlerAddress.toString(),
|
|
45
|
+
abi: FeeAssetHandlerAbi,
|
|
46
|
+
client: this.extendedClient
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Returns the amount of tokens available to mint via the handler.
|
|
51
|
+
* @throws if the handler is not provided.
|
|
52
|
+
*/ async getMintAmount() {
|
|
53
|
+
if (!this.handler) {
|
|
54
|
+
throw new Error('Minting handler was not provided');
|
|
55
|
+
}
|
|
56
|
+
return await this.handler.read.mintAmount();
|
|
36
57
|
}
|
|
37
58
|
/**
|
|
38
59
|
* Returns the balance of the given address.
|
|
@@ -43,18 +64,19 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
43
64
|
]);
|
|
44
65
|
}
|
|
45
66
|
/**
|
|
46
|
-
* Mints tokens for the given address. Returns once the tx has been mined.
|
|
47
|
-
* @param amount - Amount to mint.
|
|
67
|
+
* Mints a fixed amount of tokens for the given address. Returns once the tx has been mined.
|
|
48
68
|
* @param address - Address to mint the tokens for.
|
|
49
69
|
* @param addressName - Optional name of the address for logging.
|
|
50
|
-
*/ async mint(
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
*/ async mint(address, addressName) {
|
|
71
|
+
if (!this.handler) {
|
|
72
|
+
throw new Error('Minting handler was not provided');
|
|
73
|
+
}
|
|
74
|
+
const mintAmount = await this.getMintAmount();
|
|
75
|
+
this.logger.info(`Minting ${mintAmount} tokens for ${stringifyEthAddress(address, addressName)}`);
|
|
76
|
+
// NOTE: the handler mints a fixed amount.
|
|
77
|
+
await this.handler.write.mint([
|
|
78
|
+
address
|
|
79
|
+
]);
|
|
58
80
|
}
|
|
59
81
|
/**
|
|
60
82
|
* Approves tokens for the given address. Returns once the tx has been mined.
|
|
@@ -63,7 +85,7 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
63
85
|
* @param addressName - Optional name of the address for logging.
|
|
64
86
|
*/ async approve(amount, address, addressName = '') {
|
|
65
87
|
this.logger.info(`Approving ${amount} tokens for ${stringifyEthAddress(address, addressName)}`);
|
|
66
|
-
await this.
|
|
88
|
+
await this.extendedClient.waitForTransactionReceipt({
|
|
67
89
|
hash: await this.contract.write.approve([
|
|
68
90
|
address,
|
|
69
91
|
amount
|
|
@@ -72,20 +94,18 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
72
94
|
}
|
|
73
95
|
}
|
|
74
96
|
/** Helper for interacting with the FeeJuicePortal on L1. */ export class L1FeeJuicePortalManager {
|
|
75
|
-
|
|
76
|
-
walletClient;
|
|
97
|
+
extendedClient;
|
|
77
98
|
logger;
|
|
78
99
|
tokenManager;
|
|
79
100
|
contract;
|
|
80
|
-
constructor(portalAddress, tokenAddress,
|
|
81
|
-
this.
|
|
82
|
-
this.walletClient = walletClient;
|
|
101
|
+
constructor(portalAddress, tokenAddress, handlerAddress, extendedClient, logger){
|
|
102
|
+
this.extendedClient = extendedClient;
|
|
83
103
|
this.logger = logger;
|
|
84
|
-
this.tokenManager = new L1TokenManager(tokenAddress,
|
|
104
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
|
|
85
105
|
this.contract = getContract({
|
|
86
106
|
address: portalAddress.toString(),
|
|
87
107
|
abi: FeeJuicePortalAbi,
|
|
88
|
-
client:
|
|
108
|
+
client: extendedClient
|
|
89
109
|
});
|
|
90
110
|
}
|
|
91
111
|
/** Returns the associated token manager for the L1 ERC20. */ getTokenManager() {
|
|
@@ -98,24 +118,29 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
98
118
|
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
99
119
|
*/ async bridgeTokensPublic(to, amount, mint = false) {
|
|
100
120
|
const [claimSecret, claimSecretHash] = await generateClaimSecret();
|
|
121
|
+
const mintableAmount = await this.tokenManager.getMintAmount();
|
|
122
|
+
const amountToBridge = amount ?? mintableAmount;
|
|
101
123
|
if (mint) {
|
|
102
|
-
|
|
124
|
+
if (amountToBridge !== mintableAmount) {
|
|
125
|
+
throw new Error(`Minting amount must be ${mintableAmount}`);
|
|
126
|
+
}
|
|
127
|
+
await this.tokenManager.mint(this.extendedClient.account.address);
|
|
103
128
|
}
|
|
104
|
-
await this.tokenManager.approve(
|
|
129
|
+
await this.tokenManager.approve(amountToBridge, this.contract.address, 'FeeJuice Portal');
|
|
105
130
|
this.logger.info('Sending L1 Fee Juice to L2 to be claimed publicly');
|
|
106
131
|
const args = [
|
|
107
132
|
to.toString(),
|
|
108
|
-
|
|
133
|
+
amountToBridge,
|
|
109
134
|
claimSecretHash.toString()
|
|
110
135
|
];
|
|
111
136
|
await this.contract.simulate.depositToAztecPublic(args);
|
|
112
|
-
const txReceipt = await this.
|
|
137
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
113
138
|
hash: await this.contract.write.depositToAztecPublic(args)
|
|
114
139
|
});
|
|
115
140
|
this.logger.info('Deposited to Aztec public successfully');
|
|
116
|
-
const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount ===
|
|
141
|
+
const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amountToBridge && log.args.to === to.toString(), this.logger);
|
|
117
142
|
return {
|
|
118
|
-
claimAmount:
|
|
143
|
+
claimAmount: amountToBridge,
|
|
119
144
|
claimSecret,
|
|
120
145
|
claimSecretHash,
|
|
121
146
|
messageHash: log.args.key,
|
|
@@ -124,33 +149,33 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
124
149
|
}
|
|
125
150
|
/**
|
|
126
151
|
* Creates a new instance
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
* @param walletClient - L1 wallet client.
|
|
152
|
+
* @param node - Aztec node client used for retrieving the L1 contract addresses.
|
|
153
|
+
* @param extendedClient - Wallet client, extended with public actions.
|
|
130
154
|
* @param logger - Logger.
|
|
131
|
-
*/ static async new(
|
|
132
|
-
const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress } } = await
|
|
155
|
+
*/ static async new(node, extendedClient, logger) {
|
|
156
|
+
const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress, feeAssetHandlerAddress } } = await node.getNodeInfo();
|
|
133
157
|
if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
|
|
134
158
|
throw new Error('Portal or token not deployed on L1');
|
|
135
159
|
}
|
|
136
|
-
|
|
160
|
+
if (!feeAssetHandlerAddress || feeAssetHandlerAddress.isZero()) {
|
|
161
|
+
throw new Error('Handler not deployed on L1, or handler address is zero');
|
|
162
|
+
}
|
|
163
|
+
return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, feeAssetHandlerAddress, extendedClient, logger);
|
|
137
164
|
}
|
|
138
165
|
}
|
|
139
166
|
/** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */ export class L1ToL2TokenPortalManager {
|
|
140
|
-
|
|
141
|
-
walletClient;
|
|
167
|
+
extendedClient;
|
|
142
168
|
logger;
|
|
143
169
|
portal;
|
|
144
170
|
tokenManager;
|
|
145
|
-
constructor(portalAddress, tokenAddress,
|
|
146
|
-
this.
|
|
147
|
-
this.walletClient = walletClient;
|
|
171
|
+
constructor(portalAddress, tokenAddress, handlerAddress, extendedClient, logger){
|
|
172
|
+
this.extendedClient = extendedClient;
|
|
148
173
|
this.logger = logger;
|
|
149
|
-
this.tokenManager = new L1TokenManager(tokenAddress,
|
|
174
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
|
|
150
175
|
this.portal = getContract({
|
|
151
176
|
address: portalAddress.toString(),
|
|
152
177
|
abi: TokenPortalAbi,
|
|
153
|
-
client:
|
|
178
|
+
client: extendedClient
|
|
154
179
|
});
|
|
155
180
|
}
|
|
156
181
|
/** Returns the token manager for the underlying L1 token. */ getTokenManager() {
|
|
@@ -169,8 +194,8 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
169
194
|
amount,
|
|
170
195
|
claimSecretHash.toString()
|
|
171
196
|
]);
|
|
172
|
-
const txReceipt = await this.
|
|
173
|
-
hash: await this.
|
|
197
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
198
|
+
hash: await this.extendedClient.writeContract(request)
|
|
174
199
|
});
|
|
175
200
|
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amount && log.args.to === to.toString(), this.logger);
|
|
176
201
|
return {
|
|
@@ -193,8 +218,8 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
193
218
|
amount,
|
|
194
219
|
claimSecretHash.toString()
|
|
195
220
|
]);
|
|
196
|
-
const txReceipt = await this.
|
|
197
|
-
hash: await this.
|
|
221
|
+
const txReceipt = await this.extendedClient.waitForTransactionReceipt({
|
|
222
|
+
hash: await this.extendedClient.writeContract(request)
|
|
198
223
|
});
|
|
199
224
|
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPrivate', (log)=>log.args.amount === amount && log.args.secretHashForL2MessageConsumption === claimSecretHash.toString(), this.logger);
|
|
200
225
|
this.logger.info(`Claim message secret: ${claimSecret.toString()}, claim message secret hash: ${claimSecretHash.toString()}`);
|
|
@@ -209,7 +234,11 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
209
234
|
}
|
|
210
235
|
async bridgeSetup(amount, mint) {
|
|
211
236
|
if (mint) {
|
|
212
|
-
await this.tokenManager.
|
|
237
|
+
const mintableAmount = await this.tokenManager.getMintAmount();
|
|
238
|
+
if (amount !== mintableAmount) {
|
|
239
|
+
throw new Error(`Minting amount must be ${mintableAmount} for testing`);
|
|
240
|
+
}
|
|
241
|
+
await this.tokenManager.mint(this.extendedClient.account.address);
|
|
213
242
|
}
|
|
214
243
|
await this.tokenManager.approve(amount, this.portal.address, 'TokenPortal');
|
|
215
244
|
return generateClaimSecret();
|
|
@@ -217,12 +246,12 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
217
246
|
}
|
|
218
247
|
/** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
219
248
|
outbox;
|
|
220
|
-
constructor(portalAddress, tokenAddress,
|
|
221
|
-
super(portalAddress, tokenAddress,
|
|
249
|
+
constructor(portalAddress, tokenAddress, handlerAddress, outboxAddress, extendedClient, logger){
|
|
250
|
+
super(portalAddress, tokenAddress, handlerAddress, extendedClient, logger);
|
|
222
251
|
this.outbox = getContract({
|
|
223
252
|
address: outboxAddress.toString(),
|
|
224
253
|
abi: OutboxAbi,
|
|
225
|
-
client:
|
|
254
|
+
client: extendedClient
|
|
226
255
|
});
|
|
227
256
|
}
|
|
228
257
|
/**
|
|
@@ -234,12 +263,16 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
234
263
|
* @param siblingPath - Sibling path of the message.
|
|
235
264
|
*/ async withdrawFunds(amount, recipient, blockNumber, messageIndex, siblingPath) {
|
|
236
265
|
this.logger.info(`Sending L1 tx to consume message at block ${blockNumber} index ${messageIndex} to withdraw ${amount}`);
|
|
237
|
-
const
|
|
266
|
+
const messageLeafId = getL2ToL1MessageLeafId({
|
|
267
|
+
leafIndex: messageIndex,
|
|
268
|
+
siblingPath
|
|
269
|
+
});
|
|
270
|
+
const isConsumedBefore = await this.outbox.read.hasMessageBeenConsumedAtBlock([
|
|
238
271
|
blockNumber,
|
|
239
|
-
|
|
272
|
+
messageLeafId
|
|
240
273
|
]);
|
|
241
274
|
if (isConsumedBefore) {
|
|
242
|
-
throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} has already been consumed`);
|
|
275
|
+
throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} height ${siblingPath.pathSize} has already been consumed`);
|
|
243
276
|
}
|
|
244
277
|
// Call function on L1 contract to consume the message
|
|
245
278
|
const { request: withdrawRequest } = await this.portal.simulate.withdraw([
|
|
@@ -250,15 +283,15 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
250
283
|
messageIndex,
|
|
251
284
|
siblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
252
285
|
]);
|
|
253
|
-
await this.
|
|
254
|
-
hash: await this.
|
|
286
|
+
await this.extendedClient.waitForTransactionReceipt({
|
|
287
|
+
hash: await this.extendedClient.writeContract(withdrawRequest)
|
|
255
288
|
});
|
|
256
|
-
const isConsumedAfter = await this.outbox.read.
|
|
289
|
+
const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtBlock([
|
|
257
290
|
blockNumber,
|
|
258
|
-
|
|
291
|
+
messageLeafId
|
|
259
292
|
]);
|
|
260
293
|
if (!isConsumedAfter) {
|
|
261
|
-
throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} not consumed after withdrawal`);
|
|
294
|
+
throw new Error(`L1 to L2 message at block ${blockNumber} index ${messageIndex} height ${siblingPath.pathSize} not consumed after withdrawal`);
|
|
262
295
|
}
|
|
263
296
|
}
|
|
264
297
|
/**
|
|
@@ -267,20 +300,20 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
267
300
|
* @param recipient - Recipient on L1.
|
|
268
301
|
* @param l2Bridge - Address of the L2 bridge.
|
|
269
302
|
* @param callerOnL1 - Caller address on L1.
|
|
270
|
-
*/ getL2ToL1MessageLeaf(amount, recipient, l2Bridge, callerOnL1 = EthAddress.ZERO) {
|
|
303
|
+
*/ async getL2ToL1MessageLeaf(amount, recipient, l2Bridge, callerOnL1 = EthAddress.ZERO) {
|
|
304
|
+
const version = await this.outbox.read.VERSION();
|
|
271
305
|
const content = sha256ToField([
|
|
272
306
|
Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
|
|
273
307
|
recipient.toBuffer32(),
|
|
274
308
|
new Fr(amount).toBuffer(),
|
|
275
309
|
callerOnL1.toBuffer32()
|
|
276
310
|
]);
|
|
277
|
-
|
|
278
|
-
l2Bridge
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
new Fr(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
return leaf;
|
|
311
|
+
return computeL2ToL1MessageHash({
|
|
312
|
+
l2Sender: l2Bridge,
|
|
313
|
+
l1Recipient: EthAddress.fromString(this.portal.address),
|
|
314
|
+
content,
|
|
315
|
+
rollupVersion: new Fr(version),
|
|
316
|
+
chainId: new Fr(this.extendedClient.chain.id)
|
|
317
|
+
});
|
|
285
318
|
}
|
|
286
319
|
}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
4
|
+
import type { L2AmountClaim } from '../ethereum/portal_manager.js';
|
|
5
|
+
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
5
6
|
/**
|
|
6
|
-
* Pay fee directly with Fee Juice claimed
|
|
7
|
+
* Pay fee directly with Fee Juice claimed in the same tx. Claiming consumes an L1 to L2 message that "contains"
|
|
8
|
+
* the fee juice bridged from L1.
|
|
7
9
|
*/
|
|
8
|
-
export declare class FeeJuicePaymentMethodWithClaim
|
|
9
|
-
private
|
|
10
|
+
export declare class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
|
|
11
|
+
private sender;
|
|
10
12
|
private claim;
|
|
11
|
-
constructor(
|
|
13
|
+
constructor(sender: AztecAddress, claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>);
|
|
12
14
|
/**
|
|
13
|
-
* Creates
|
|
14
|
-
* @returns
|
|
15
|
+
* Creates an execution payload to pay the fee in Fee Juice.
|
|
16
|
+
* @returns An execution payload that just contains the `claim_and_end_setup` function call.
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
getExecutionPayload(): Promise<ExecutionPayload>;
|
|
19
|
+
getAsset(): Promise<AztecAddress>;
|
|
20
|
+
getFeePayer(): Promise<AztecAddress>;
|
|
21
|
+
getGasSettings(): GasSettings | undefined;
|
|
17
22
|
}
|
|
18
23
|
//# sourceMappingURL=fee_juice_payment_method_with_claim.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee_juice_payment_method_with_claim.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method_with_claim.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fee_juice_payment_method_with_claim.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method_with_claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,qBAAa,8BAA+B,YAAW,gBAAgB;IAEnE,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;gBADL,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAGxF;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA0BtD,QAAQ;IAIR,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC,cAAc,IAAI,WAAW,GAAG,SAAS;CAG1C"}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
4
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
4
|
-
import { getFeeJuice } from '../contract/protocol_contracts.js';
|
|
5
|
-
import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
|
|
6
5
|
/**
|
|
7
|
-
* Pay fee directly with Fee Juice claimed
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
* Pay fee directly with Fee Juice claimed in the same tx. Claiming consumes an L1 to L2 message that "contains"
|
|
7
|
+
* the fee juice bridged from L1.
|
|
8
|
+
*/ export class FeeJuicePaymentMethodWithClaim {
|
|
9
|
+
sender;
|
|
10
10
|
claim;
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
11
|
+
constructor(sender, claim){
|
|
12
|
+
this.sender = sender;
|
|
13
|
+
this.claim = claim;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
|
-
* Creates
|
|
16
|
-
* @returns
|
|
17
|
-
*/ async
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
return Promise.resolve([
|
|
16
|
+
* Creates an execution payload to pay the fee in Fee Juice.
|
|
17
|
+
* @returns An execution payload that just contains the `claim_and_end_setup` function call.
|
|
18
|
+
*/ async getExecutionPayload() {
|
|
19
|
+
const selector = await FunctionSelector.fromSignature('claim_and_end_setup((Field),u128,Field,Field)');
|
|
20
|
+
return new ExecutionPayload([
|
|
21
21
|
{
|
|
22
22
|
to: ProtocolContractAddress.FeeJuice,
|
|
23
|
-
name: '
|
|
23
|
+
name: 'claim_and_end_setup',
|
|
24
24
|
selector,
|
|
25
|
+
hideMsgSender: false,
|
|
25
26
|
isStatic: false,
|
|
26
27
|
args: [
|
|
27
|
-
this.
|
|
28
|
+
this.sender.toField(),
|
|
28
29
|
new Fr(this.claim.claimAmount),
|
|
29
30
|
this.claim.claimSecret,
|
|
30
31
|
new Fr(this.claim.messageLeafIndex)
|
|
@@ -32,6 +33,15 @@ import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
|
|
|
32
33
|
returnTypes: [],
|
|
33
34
|
type: FunctionType.PRIVATE
|
|
34
35
|
}
|
|
35
|
-
]);
|
|
36
|
+
], [], []);
|
|
37
|
+
}
|
|
38
|
+
getAsset() {
|
|
39
|
+
return Promise.resolve(ProtocolContractAddress.FeeJuice);
|
|
40
|
+
}
|
|
41
|
+
getFeePayer() {
|
|
42
|
+
return Promise.resolve(this.sender);
|
|
43
|
+
}
|
|
44
|
+
getGasSettings() {
|
|
45
|
+
return;
|
|
36
46
|
}
|
|
37
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
4
4
|
/**
|
|
@@ -8,15 +8,19 @@ export interface FeePaymentMethod {
|
|
|
8
8
|
/** The asset used to pay the fee. */
|
|
9
9
|
getAsset(): Promise<AztecAddress>;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @returns The function
|
|
11
|
+
* Returns the data to be added to the final execution request
|
|
12
|
+
* to pay the fee in the given asset
|
|
13
|
+
* @returns The function calls to pay the fee.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
getExecutionPayload(): Promise<ExecutionPayload>;
|
|
16
16
|
/**
|
|
17
17
|
* The expected fee payer for this tx.
|
|
18
|
-
* @param gasSettings - The gas limits and max fees.
|
|
19
18
|
*/
|
|
20
|
-
getFeePayer(
|
|
19
|
+
getFeePayer(): Promise<AztecAddress>;
|
|
20
|
+
/**
|
|
21
|
+
* The gas settings (if any) used to compute the
|
|
22
|
+
* execution payload of the payment method
|
|
23
|
+
*/
|
|
24
|
+
getGasSettings(): GasSettings | undefined;
|
|
21
25
|
}
|
|
22
26
|
//# sourceMappingURL=fee_payment_method.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAClC;;;;OAIG;IACH,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjD;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC;;;OAGG;IACH,cAAc,IAAI,WAAW,GAAG,SAAS,CAAC;CAC3C"}
|