@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,238 +0,0 @@
|
|
|
1
|
-
import { GeneratorIndex } from '@aztec/constants';
|
|
2
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
6
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
7
|
-
import { FunctionCall, FunctionType } from '@aztec/stdlib/abi';
|
|
8
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
10
|
-
import { HashedValues } from '@aztec/stdlib/tx';
|
|
11
|
-
|
|
12
|
-
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Fee payment options for a transaction.
|
|
16
|
-
*/
|
|
17
|
-
export type FeeOptions = {
|
|
18
|
-
/** The fee payment method to use */
|
|
19
|
-
paymentMethod: FeePaymentMethod;
|
|
20
|
-
/** The gas settings */
|
|
21
|
-
gasSettings: GasSettings;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// docs:start:user_fee_options
|
|
25
|
-
/** Fee options as set by a user. */
|
|
26
|
-
export type UserFeeOptions = {
|
|
27
|
-
/** The fee payment method to use */
|
|
28
|
-
paymentMethod?: FeePaymentMethod;
|
|
29
|
-
/** The gas settings */
|
|
30
|
-
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
31
|
-
/** Percentage to pad the base fee by, if empty, defaults to 0.5 */
|
|
32
|
-
baseFeePadding?: number;
|
|
33
|
-
/** Whether to run an initial simulation of the tx with high gas limit to figure out actual gas settings. */
|
|
34
|
-
estimateGas?: boolean;
|
|
35
|
-
/** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
|
|
36
|
-
estimatedGasPadding?: number;
|
|
37
|
-
};
|
|
38
|
-
// docs:end:user_fee_options
|
|
39
|
-
|
|
40
|
-
// These must match the values defined in:
|
|
41
|
-
// - noir-projects/aztec-nr/aztec/src/entrypoint/app.nr
|
|
42
|
-
const APP_MAX_CALLS = 4;
|
|
43
|
-
// - and noir-projects/aztec-nr/aztec/src/entrypoint/fee.nr
|
|
44
|
-
const FEE_MAX_CALLS = 2;
|
|
45
|
-
|
|
46
|
-
/* eslint-disable camelcase */
|
|
47
|
-
/** Encoded function call for account contract entrypoint */
|
|
48
|
-
type EncodedFunctionCall = {
|
|
49
|
-
/** Arguments hash for the call */
|
|
50
|
-
args_hash: Fr;
|
|
51
|
-
/** Selector of the function to call */
|
|
52
|
-
function_selector: Fr;
|
|
53
|
-
/** Address of the contract to call */
|
|
54
|
-
target_address: Fr;
|
|
55
|
-
/** Whether the function is public or private */
|
|
56
|
-
is_public: boolean;
|
|
57
|
-
/** Whether the function can alter state */
|
|
58
|
-
is_static: boolean;
|
|
59
|
-
};
|
|
60
|
-
/* eslint-enable camelcase */
|
|
61
|
-
|
|
62
|
-
/** Assembles an entrypoint payload */
|
|
63
|
-
export abstract class EntrypointPayload {
|
|
64
|
-
protected constructor(
|
|
65
|
-
private functionCalls: EncodedFunctionCall[],
|
|
66
|
-
private _hashedArguments: HashedValues[],
|
|
67
|
-
private generatorIndex: number,
|
|
68
|
-
private _nonce: Fr,
|
|
69
|
-
) {}
|
|
70
|
-
|
|
71
|
-
protected static async create(functionCalls: FunctionCall[]) {
|
|
72
|
-
const hashedArguments: HashedValues[] = [];
|
|
73
|
-
for (const call of functionCalls) {
|
|
74
|
-
hashedArguments.push(await HashedValues.fromValues(call.args));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* eslint-disable camelcase */
|
|
78
|
-
const encodedFunctionCalls = functionCalls.map((call, index) => ({
|
|
79
|
-
args_hash: hashedArguments[index].hash,
|
|
80
|
-
function_selector: call.selector.toField(),
|
|
81
|
-
target_address: call.to.toField(),
|
|
82
|
-
is_public: call.type == FunctionType.PUBLIC,
|
|
83
|
-
is_static: call.isStatic,
|
|
84
|
-
}));
|
|
85
|
-
/* eslint-enable camelcase */
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
encodedFunctionCalls,
|
|
89
|
-
hashedArguments,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* eslint-disable camelcase */
|
|
94
|
-
/**
|
|
95
|
-
* The function calls to execute. This uses snake_case naming so that it is compatible with Noir encoding
|
|
96
|
-
* @internal
|
|
97
|
-
*/
|
|
98
|
-
get function_calls() {
|
|
99
|
-
return this.functionCalls;
|
|
100
|
-
}
|
|
101
|
-
/* eslint-enable camelcase */
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* The nonce
|
|
105
|
-
* @internal
|
|
106
|
-
*/
|
|
107
|
-
get nonce() {
|
|
108
|
-
return this._nonce;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* The hashed arguments for the function calls
|
|
113
|
-
*/
|
|
114
|
-
get hashedArguments() {
|
|
115
|
-
return this._hashedArguments;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Serializes the payload to an array of fields
|
|
120
|
-
* @returns The fields of the payload
|
|
121
|
-
*/
|
|
122
|
-
abstract toFields(): Fr[];
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Hashes the payload
|
|
126
|
-
* @returns The hash of the payload
|
|
127
|
-
*/
|
|
128
|
-
hash() {
|
|
129
|
-
return poseidon2HashWithSeparator(this.toFields(), this.generatorIndex);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Serializes the function calls to an array of fields. */
|
|
133
|
-
protected functionCallsToFields() {
|
|
134
|
-
return this.functionCalls.flatMap(call => [
|
|
135
|
-
call.args_hash,
|
|
136
|
-
call.function_selector,
|
|
137
|
-
call.target_address,
|
|
138
|
-
new Fr(call.is_public),
|
|
139
|
-
new Fr(call.is_static),
|
|
140
|
-
]);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Creates an execution payload for a dapp from a set of function calls
|
|
145
|
-
* @param functionCalls - The function calls to execute
|
|
146
|
-
* @returns The execution payload
|
|
147
|
-
*/
|
|
148
|
-
static async fromFunctionCalls(functionCalls: FunctionCall[]) {
|
|
149
|
-
const { encodedFunctionCalls, hashedArguments } = await this.create(functionCalls);
|
|
150
|
-
return new AppEntrypointPayload(encodedFunctionCalls, hashedArguments, 0, Fr.random());
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Creates an execution payload for the app-portion of a transaction from a set of function calls
|
|
155
|
-
* @param functionCalls - The function calls to execute
|
|
156
|
-
* @param nonce - The nonce for the payload, used to emit a nullifier identifying the call
|
|
157
|
-
* @returns The execution payload
|
|
158
|
-
*/
|
|
159
|
-
static async fromAppExecution(functionCalls: FunctionCall[] | Tuple<FunctionCall, 4>, nonce = Fr.random()) {
|
|
160
|
-
if (functionCalls.length > APP_MAX_CALLS) {
|
|
161
|
-
throw new Error(`Expected at most ${APP_MAX_CALLS} function calls, got ${functionCalls.length}`);
|
|
162
|
-
}
|
|
163
|
-
const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), APP_MAX_CALLS);
|
|
164
|
-
const { encodedFunctionCalls, hashedArguments } = await this.create(paddedCalls);
|
|
165
|
-
return new AppEntrypointPayload(encodedFunctionCalls, hashedArguments, GeneratorIndex.SIGNATURE_PAYLOAD, nonce);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Creates an execution payload to pay the fee for a transaction
|
|
170
|
-
* @param sender - The address sending this payload
|
|
171
|
-
* @param feeOpts - The fee payment options
|
|
172
|
-
* @returns The execution payload
|
|
173
|
-
*/
|
|
174
|
-
static async fromFeeOptions(sender: AztecAddress, feeOpts?: FeeOptions) {
|
|
175
|
-
const calls = (await feeOpts?.paymentMethod.getFunctionCalls(feeOpts?.gasSettings)) ?? [];
|
|
176
|
-
const feePayer = await feeOpts?.paymentMethod.getFeePayer(feeOpts?.gasSettings);
|
|
177
|
-
const isFeePayer = !!feePayer && feePayer.equals(sender);
|
|
178
|
-
const paddedCalls = padArrayEnd(calls, FunctionCall.empty(), FEE_MAX_CALLS);
|
|
179
|
-
const { encodedFunctionCalls, hashedArguments } = await this.create(paddedCalls);
|
|
180
|
-
return new FeeEntrypointPayload(
|
|
181
|
-
encodedFunctionCalls,
|
|
182
|
-
hashedArguments,
|
|
183
|
-
GeneratorIndex.FEE_PAYLOAD,
|
|
184
|
-
Fr.random(),
|
|
185
|
-
isFeePayer,
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** Entrypoint payload for app phase execution. */
|
|
191
|
-
class AppEntrypointPayload extends EntrypointPayload {
|
|
192
|
-
override toFields(): Fr[] {
|
|
193
|
-
return [...this.functionCallsToFields(), this.nonce];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/** Entrypoint payload for fee payment to be run during setup phase. */
|
|
198
|
-
class FeeEntrypointPayload extends EntrypointPayload {
|
|
199
|
-
#isFeePayer: boolean;
|
|
200
|
-
|
|
201
|
-
constructor(
|
|
202
|
-
functionCalls: EncodedFunctionCall[],
|
|
203
|
-
hashedArguments: HashedValues[],
|
|
204
|
-
generatorIndex: number,
|
|
205
|
-
nonce: Fr,
|
|
206
|
-
isFeePayer: boolean,
|
|
207
|
-
) {
|
|
208
|
-
super(functionCalls, hashedArguments, generatorIndex, nonce);
|
|
209
|
-
this.#isFeePayer = isFeePayer;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
override toFields(): Fr[] {
|
|
213
|
-
return [...this.functionCallsToFields(), this.nonce, new Fr(this.#isFeePayer)];
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/* eslint-disable camelcase */
|
|
217
|
-
/** Whether the sender should be appointed as fee payer. */
|
|
218
|
-
get is_fee_payer() {
|
|
219
|
-
return this.#isFeePayer;
|
|
220
|
-
}
|
|
221
|
-
/* eslint-enable camelcase */
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Computes a hash of a combined payload.
|
|
226
|
-
* @param appPayload - An app payload.
|
|
227
|
-
* @param feePayload - A fee payload.
|
|
228
|
-
* @returns A hash of a combined payload.
|
|
229
|
-
*/
|
|
230
|
-
export async function computeCombinedPayloadHash(
|
|
231
|
-
appPayload: AppEntrypointPayload,
|
|
232
|
-
feePayload: FeeEntrypointPayload,
|
|
233
|
-
): Promise<Fr> {
|
|
234
|
-
return poseidon2HashWithSeparator(
|
|
235
|
-
[await appPayload.hash(), await feePayload.hash()],
|
|
236
|
-
GeneratorIndex.COMBINED_PAYLOAD,
|
|
237
|
-
);
|
|
238
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
|
-
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
|
|
5
|
-
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
6
|
-
|
|
7
|
-
// docs:start:fee_juice_method
|
|
8
|
-
/**
|
|
9
|
-
* Pay fee directly in the Fee Juice.
|
|
10
|
-
*/
|
|
11
|
-
export class FeeJuicePaymentMethod implements FeePaymentMethod {
|
|
12
|
-
// docs:end:fee_juice_method
|
|
13
|
-
constructor(protected sender: AztecAddress) {}
|
|
14
|
-
|
|
15
|
-
getAsset() {
|
|
16
|
-
return Promise.resolve(ProtocolContractAddress.FeeJuice);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getFunctionCalls(): Promise<FunctionCall[]> {
|
|
20
|
-
return Promise.resolve([]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getFeePayer(): Promise<AztecAddress> {
|
|
24
|
-
return Promise.resolve(this.sender);
|
|
25
|
-
}
|
|
26
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is our public api.
|
|
3
|
-
* Do NOT "export * from ..." here.
|
|
4
|
-
* Everything here should be explicit, to ensure we can clearly see everything we're exposing to the world.
|
|
5
|
-
* If it's exposed, people will use it, and then we can't remove/change the api without breaking client code.
|
|
6
|
-
* At the time of writing we overexpose things that should only be internal.
|
|
7
|
-
*
|
|
8
|
-
* TODO: Review and narrow scope of public api.
|
|
9
|
-
* We should also consider exposing subsections of the api via package.json exports, like we do with foundation.
|
|
10
|
-
* This can allow consumers to import much smaller parts of the library to incur less overhead.
|
|
11
|
-
* It will also allow web bundlers do perform intelligent chunking of bundles etc.
|
|
12
|
-
* Some work as been done on this within the api folder, providing the alternative import style of e.g.:
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { TxHash } from '@aztec.js/tx_hash'
|
|
15
|
-
* import { type ContractArtifact, type FunctionArtifact, FunctionSelector } from '@aztec/aztec.js/abi';
|
|
16
|
-
* import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
17
|
-
* import { EthAddress } from '@aztec/aztec.js/eth_address';
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* TODO: Ultimately reimplement this mega exporter by mega exporting a granular api (then deprecate it).
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export { ContractDeployer } from './deployment/index.js';
|
|
24
|
-
|
|
25
|
-
export { NoteSelector } from '@aztec/stdlib/abi';
|
|
26
|
-
|
|
27
|
-
export { createCompatibleClient, createPXEClient } from './rpc_clients/index.js';
|
|
28
|
-
|
|
29
|
-
export { type DeployAccountOptions } from './account_manager/index.js';
|
|
30
|
-
|
|
31
|
-
export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet } from './wallet/index.js';
|
|
32
|
-
|
|
33
|
-
export { EthAddress } from '@aztec/foundation/eth-address';
|
|
34
|
-
|
|
35
|
-
export { Fq, Fr, Point, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
36
|
-
|
|
37
|
-
export { SiblingPath } from '@aztec/foundation/trees';
|
|
38
|
-
|
|
39
|
-
export { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
type PartialAddress,
|
|
43
|
-
type ContractClassWithId,
|
|
44
|
-
type ContractInstanceWithAddress,
|
|
45
|
-
getContractClassFromArtifact,
|
|
46
|
-
getContractInstanceFromDeployParams,
|
|
47
|
-
type NodeInfo,
|
|
48
|
-
} from '@aztec/stdlib/contract';
|
|
49
|
-
export { MerkleTreeId, merkleTreeIds } from '@aztec/stdlib/trees';
|
|
50
|
-
export { type PublicKey, PublicKeys } from '@aztec/stdlib/keys';
|
|
51
|
-
export { computeSecretHash } from '@aztec/stdlib/hash';
|
|
52
|
-
export {
|
|
53
|
-
computeAppNullifierSecretKey,
|
|
54
|
-
deriveKeys,
|
|
55
|
-
deriveMasterIncomingViewingSecretKey,
|
|
56
|
-
deriveMasterNullifierSecretKey,
|
|
57
|
-
} from '@aztec/stdlib/keys';
|
|
58
|
-
export { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
59
|
-
export { getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
60
|
-
export { FunctionCall } from '@aztec/stdlib/abi';
|
|
61
|
-
export {
|
|
62
|
-
Tx,
|
|
63
|
-
TxExecutionRequest,
|
|
64
|
-
TxHash,
|
|
65
|
-
TxReceipt,
|
|
66
|
-
TxStatus,
|
|
67
|
-
Capsule,
|
|
68
|
-
HashedValues,
|
|
69
|
-
GlobalVariables,
|
|
70
|
-
} from '@aztec/stdlib/tx';
|
|
71
|
-
export { Body, L2Block } from '@aztec/stdlib/block';
|
|
72
|
-
export { L1NotePayload, LogId, type LogFilter, EncryptedLogPayload } from '@aztec/stdlib/logs';
|
|
73
|
-
export { L1EventPayload, EventMetadata } from '@aztec/stdlib/event';
|
|
74
|
-
export { L1ToL2Message, L2Actor, L1Actor } from '@aztec/stdlib/messaging';
|
|
75
|
-
export { UniqueNote, ExtendedNote, Comparator, Note } from '@aztec/stdlib/note';
|
|
76
|
-
export { type PXE, EventType } from '@aztec/stdlib/interfaces/client';
|
|
77
|
-
|
|
78
|
-
export { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
79
|
-
|
|
80
|
-
// TODO: These kinds of things have no place on our public api.
|
|
81
|
-
// External devs will almost certainly have their own methods of doing these things.
|
|
82
|
-
// If we want to use them in our own "aztec.js consuming code", import them from foundation as needed.
|
|
83
|
-
export { decodeFromAbi, encodeArguments, type AbiType } from '@aztec/stdlib/abi';
|
|
84
|
-
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
85
|
-
export { sha256, Grumpkin, Schnorr } from '@aztec/foundation/crypto';
|
|
86
|
-
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
87
|
-
export { retry, retryUntil } from '@aztec/foundation/retry';
|
|
88
|
-
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
89
|
-
export { sleep } from '@aztec/foundation/sleep';
|
|
90
|
-
export { elapsed } from '@aztec/foundation/timer';
|
|
91
|
-
export { type FieldsOf } from '@aztec/foundation/types';
|
|
92
|
-
export { fileURLToPath } from '@aztec/foundation/url';
|
|
93
|
-
|
|
94
|
-
// Start of section that exports public api via granular api.
|
|
95
|
-
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
|
|
96
|
-
// This entire index file will be deprecated at some point after we're satisfied.
|
|
97
|
-
export * from './api/abi.js';
|
|
98
|
-
export * from './api/account.js';
|
|
99
|
-
export * from './api/addresses.js';
|
|
100
|
-
export * from './api/cheat_codes.js';
|
|
101
|
-
export * from './api/ethereum/index.js';
|
|
102
|
-
export * from './api/fee.js';
|
|
103
|
-
export * from './api/log.js';
|
|
104
|
-
// Granular export, even if not in the api folder
|
|
105
|
-
export * from './contract/index.js';
|
|
106
|
-
export * from './utils/index.js';
|
package/src/rpc_clients/index.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { NoRetryError, makeBackoff, retry } from '@aztec/foundation/retry';
|
|
4
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
6
|
-
|
|
7
|
-
import { Axios, type AxiosError } from 'axios';
|
|
8
|
-
import { inspect } from 'util';
|
|
9
|
-
|
|
10
|
-
import { createPXEClient } from '../pxe_client.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A fetch implementation using axios.
|
|
14
|
-
* @param host - The URL of the host.
|
|
15
|
-
* @param rpcMethod - The RPC method to call.
|
|
16
|
-
* @param body - The body of the request.
|
|
17
|
-
* @param useApiEndpoints - Whether to use the API endpoints or inject the method in the body.
|
|
18
|
-
* @returns The response data.
|
|
19
|
-
*/
|
|
20
|
-
async function axiosFetch(host: string, rpcMethod: string, body: any, useApiEndpoints: boolean) {
|
|
21
|
-
const request = new Axios({
|
|
22
|
-
headers: { 'content-type': 'application/json' },
|
|
23
|
-
transformRequest: [(data: any) => jsonStringify(data)],
|
|
24
|
-
transformResponse: [(data: any) => JSON.parse(data)],
|
|
25
|
-
});
|
|
26
|
-
const [url, content] = useApiEndpoints ? [`${host}/${rpcMethod}`, body] : [host, { ...body, method: rpcMethod }];
|
|
27
|
-
const resp = await request.post(url, content).catch((error: AxiosError) => {
|
|
28
|
-
if (error.response) {
|
|
29
|
-
return error.response;
|
|
30
|
-
}
|
|
31
|
-
const errorMessage = `Error fetching from host ${host} with method ${rpcMethod}: ${inspect(error)}`;
|
|
32
|
-
throw new Error(errorMessage);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const isOK = resp.status >= 200 && resp.status < 300;
|
|
36
|
-
if (isOK) {
|
|
37
|
-
const headers = {
|
|
38
|
-
get: (header: string) =>
|
|
39
|
-
typeof resp.headers.get === 'function' ? resp.headers.get(header)?.toString() : undefined,
|
|
40
|
-
};
|
|
41
|
-
return { response: resp.data, headers };
|
|
42
|
-
} else {
|
|
43
|
-
const errorMessage = `Error ${resp.status} from json-rpc server ${host} on ${rpcMethod}: ${resp.data.error.message}`;
|
|
44
|
-
if (resp.status >= 400 && resp.status < 500) {
|
|
45
|
-
throw new NoRetryError(errorMessage);
|
|
46
|
-
} else {
|
|
47
|
-
throw new Error(errorMessage);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Creates a PXE client with a given set of retries on non-server errors.
|
|
54
|
-
* Checks that PXE matches the expected version, and warns if not.
|
|
55
|
-
* @param rpcUrl - URL of the RPC server wrapping the PXE.
|
|
56
|
-
* @param _logger - Debug logger to warn version incompatibilities.
|
|
57
|
-
* @returns A PXE client.
|
|
58
|
-
*/
|
|
59
|
-
export function createCompatibleClient(
|
|
60
|
-
rpcUrl: string,
|
|
61
|
-
logger: Logger = createLogger('aztecjs:pxe_client'),
|
|
62
|
-
versions: Partial<ComponentsVersions> = {},
|
|
63
|
-
): Promise<PXE> {
|
|
64
|
-
// Use axios due to timeout issues with fetch when proving TXs.
|
|
65
|
-
const fetch = async (host: string, rpcMethod: string, body: any, useApiEndpoints: boolean) => {
|
|
66
|
-
return await retry(
|
|
67
|
-
() => axiosFetch(host, rpcMethod, body, useApiEndpoints),
|
|
68
|
-
`JsonRpcClient request ${rpcMethod} to ${host}`,
|
|
69
|
-
makeBackoff([1, 2, 3]),
|
|
70
|
-
logger,
|
|
71
|
-
false,
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
const pxe = createPXEClient(rpcUrl, versions, fetch);
|
|
75
|
-
|
|
76
|
-
return Promise.resolve(pxe);
|
|
77
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
2
|
-
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
3
|
-
import { type PXE, PXESchema } from '@aztec/stdlib/interfaces/client';
|
|
4
|
-
import { type ComponentsVersions, getVersioningResponseHandler } from '@aztec/stdlib/versioning';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates a JSON-RPC client to remotely talk to PXE.
|
|
8
|
-
* @param url - The URL of the PXE.
|
|
9
|
-
* @param fetch - The fetch implementation to use.
|
|
10
|
-
* @returns A JSON-RPC client of PXE.
|
|
11
|
-
*/
|
|
12
|
-
export function createPXEClient(
|
|
13
|
-
url: string,
|
|
14
|
-
versions: Partial<ComponentsVersions> = {},
|
|
15
|
-
fetch = makeFetch([1, 2, 3], false),
|
|
16
|
-
): PXE {
|
|
17
|
-
return createSafeJsonRpcClient<PXE>(url, PXESchema, {
|
|
18
|
-
namespaceMethods: 'pxe',
|
|
19
|
-
fetch,
|
|
20
|
-
onResponse: getVersioningResponseHandler({
|
|
21
|
-
l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString(),
|
|
22
|
-
...versions,
|
|
23
|
-
}),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
|
|
5
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
6
|
-
import type { Note } from '@aztec/stdlib/note';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A class that provides utility functions for interacting with the aztec chain.
|
|
10
|
-
*/
|
|
11
|
-
export class AztecCheatCodes {
|
|
12
|
-
constructor(
|
|
13
|
-
/**
|
|
14
|
-
* The PXE Service to use for interacting with the chain
|
|
15
|
-
*/
|
|
16
|
-
public pxe: PXE,
|
|
17
|
-
/**
|
|
18
|
-
* The logger to use for the aztec cheatcodes
|
|
19
|
-
*/
|
|
20
|
-
public logger = createLogger('aztecjs:cheat_codes'),
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Computes the slot value for a given map and key.
|
|
25
|
-
* @param mapSlot - The slot of the map (specified in Aztec.nr contract)
|
|
26
|
-
* @param key - The key to lookup in the map
|
|
27
|
-
* @returns The storage slot of the value in the map
|
|
28
|
-
*/
|
|
29
|
-
public computeSlotInMap(mapSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Promise<Fr> {
|
|
30
|
-
const keyFr = typeof key === 'bigint' ? new Fr(key) : key.toField();
|
|
31
|
-
return deriveStorageSlotInMap(mapSlot, keyFr);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Get the current blocknumber
|
|
36
|
-
* @returns The current block number
|
|
37
|
-
*/
|
|
38
|
-
public async blockNumber(): Promise<number> {
|
|
39
|
-
return await this.pxe.getBlockNumber();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get the current timestamp
|
|
44
|
-
* @returns The current timestamp
|
|
45
|
-
*/
|
|
46
|
-
public async timestamp(): Promise<number> {
|
|
47
|
-
const res = await this.pxe.getBlock(await this.blockNumber());
|
|
48
|
-
return res?.header.globalVariables.timestamp.toNumber() ?? 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Loads the value stored at the given slot in the public storage of the given contract.
|
|
53
|
-
* @param who - The address of the contract
|
|
54
|
-
* @param slot - The storage slot to lookup
|
|
55
|
-
* @returns The value stored at the given slot
|
|
56
|
-
*/
|
|
57
|
-
public async loadPublic(who: AztecAddress, slot: Fr | bigint): Promise<Fr> {
|
|
58
|
-
const storageValue = await this.pxe.getPublicStorageAt(who, new Fr(slot));
|
|
59
|
-
return storageValue;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Loads the value stored at the given slot in the private storage of the given contract.
|
|
64
|
-
* @param contract - The address of the contract
|
|
65
|
-
* @param owner - The owner for whom the notes are encrypted
|
|
66
|
-
* @param slot - The storage slot to lookup
|
|
67
|
-
* @returns The notes stored at the given slot
|
|
68
|
-
*/
|
|
69
|
-
public async loadPrivate(owner: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<Note[]> {
|
|
70
|
-
const extendedNotes = await this.pxe.getNotes({
|
|
71
|
-
owner,
|
|
72
|
-
contractAddress: contract,
|
|
73
|
-
storageSlot: new Fr(slot),
|
|
74
|
-
});
|
|
75
|
-
return extendedNotes.map(extendedNote => extendedNote.note);
|
|
76
|
-
}
|
|
77
|
-
}
|
package/src/utils/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export { generatePublicKey } from './pub_key.js';
|
|
2
|
-
export {
|
|
3
|
-
type AztecAddressLike,
|
|
4
|
-
type EthAddressLike,
|
|
5
|
-
type EventSelectorLike,
|
|
6
|
-
type FieldLike,
|
|
7
|
-
type FunctionSelectorLike,
|
|
8
|
-
type U128Like,
|
|
9
|
-
type WrappedFieldLike,
|
|
10
|
-
} from './abi_types.js';
|
|
11
|
-
export {
|
|
12
|
-
computeAuthWitMessageHash,
|
|
13
|
-
computeInnerAuthWitHash,
|
|
14
|
-
computeInnerAuthWitHashFromAction,
|
|
15
|
-
type IntentAction,
|
|
16
|
-
type IntentInnerHash,
|
|
17
|
-
} from './authwit.js';
|
|
18
|
-
export { waitForPXE } from './pxe.js';
|
|
19
|
-
export { waitForNode, createAztecNodeClient, type AztecNode } from './node.js';
|
|
20
|
-
export { getFeeJuiceBalance } from './fee_juice.js';
|
|
21
|
-
export { readFieldCompressedString } from './field_compressed_string.js';
|
package/src/utils/pxe.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
|
-
|
|
5
|
-
export const waitForPXE = async (pxe: PXE, logger?: Logger) => {
|
|
6
|
-
await retryUntil(async () => {
|
|
7
|
-
try {
|
|
8
|
-
logger?.verbose('Attempting to contact PXE...');
|
|
9
|
-
await pxe.getNodeInfo();
|
|
10
|
-
logger?.verbose('Contacted PXE');
|
|
11
|
-
return true;
|
|
12
|
-
} catch (error) {
|
|
13
|
-
logger?.verbose('Failed to contact PXE');
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
}, 'RPC Get Node Info');
|
|
17
|
-
};
|