@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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|
|
3
|
+
* SendOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
4
|
+
*/ export async function toSendOptions(options) {
|
|
5
|
+
return {
|
|
6
|
+
...options,
|
|
7
|
+
fee: {
|
|
8
|
+
// If this interaction includes a fee payment method, pass the fee payer
|
|
9
|
+
// as a hint to the wallet
|
|
10
|
+
embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
|
|
11
|
+
// If a payment method that includes gas settings was used,
|
|
12
|
+
// try to reuse as much as possible while still allowing
|
|
13
|
+
// manual override. CAREFUL: this can cause mismatches during proving
|
|
14
|
+
gasSettings: {
|
|
15
|
+
...options.fee?.paymentMethod?.getGasSettings(),
|
|
16
|
+
...options.fee?.gasSettings
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
|
|
23
|
+
* SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
24
|
+
*/ export async function toSimulateOptions(options) {
|
|
25
|
+
return {
|
|
26
|
+
...options,
|
|
27
|
+
fee: {
|
|
28
|
+
// If this interaction includes a fee payment method, pass the fee payer
|
|
29
|
+
// as a hint to the wallet
|
|
30
|
+
embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
|
|
31
|
+
// If a payment method that includes gas settings was used,
|
|
32
|
+
// try to reuse as much as possible while still allowing
|
|
33
|
+
// manual override. CAREFUL: this can cause mismatches during proving
|
|
34
|
+
gasSettings: {
|
|
35
|
+
...options.fee?.paymentMethod?.getGasSettings(),
|
|
36
|
+
...options.fee?.gasSettings
|
|
37
|
+
},
|
|
38
|
+
estimateGas: options.fee?.estimateGas,
|
|
39
|
+
estimatedGasPadding: options.fee?.estimatedGasPadding
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
|
|
45
|
+
* ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
46
|
+
*/ export async function toProfileOptions(options) {
|
|
47
|
+
return {
|
|
48
|
+
...await toSimulateOptions(options),
|
|
49
|
+
profileMode: options.profileMode,
|
|
50
|
+
skipProofGeneration: options.skipProofGeneration
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Wallet } from '../wallet/
|
|
1
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
2
2
|
import { UnsafeContract } from './unsafe_contract.js';
|
|
3
|
-
/** Returns a Contract wrapper for the class
|
|
4
|
-
export declare function
|
|
5
|
-
/** Returns a Contract wrapper for the instance
|
|
6
|
-
export declare function
|
|
7
|
-
/** Returns a Contract wrapper for the fee juice */
|
|
3
|
+
/** Returns a Contract wrapper for the contract class registry. */
|
|
4
|
+
export declare function getClassRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
|
|
5
|
+
/** Returns a Contract wrapper for the contract instance registry. */
|
|
6
|
+
export declare function getInstanceRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
|
|
7
|
+
/** Returns a Contract wrapper for the fee juice contract */
|
|
8
8
|
export declare function getFeeJuice(wallet: Wallet): Promise<UnsafeContract>;
|
|
9
9
|
//# sourceMappingURL=protocol_contracts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol_contracts.d.ts","sourceRoot":"","sources":["../../src/contract/protocol_contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"protocol_contracts.d.ts","sourceRoot":"","sources":["../../src/contract/protocol_contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,kEAAkE;AAClE,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,MAAM,2BAQ5D;AAED,qEAAqE;AACrE,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,MAAM,2BAO/D;AAED,4DAA4D;AAC5D,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,2BAO/C"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
2
|
import { UnsafeContract } from './unsafe_contract.js';
|
|
3
|
-
/** Returns a Contract wrapper for the class
|
|
4
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.
|
|
3
|
+
/** Returns a Contract wrapper for the contract class registry. */ export async function getClassRegistryContract(wallet) {
|
|
4
|
+
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractClassRegistry);
|
|
5
5
|
if (!contractInstance) {
|
|
6
|
-
throw new Error("
|
|
6
|
+
throw new Error("ContractClassRegistry is not registered in this wallet's instance");
|
|
7
7
|
}
|
|
8
8
|
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
9
9
|
return new UnsafeContract(contractInstance, artifact, wallet);
|
|
10
10
|
}
|
|
11
|
-
/** Returns a Contract wrapper for the instance
|
|
12
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.
|
|
11
|
+
/** Returns a Contract wrapper for the contract instance registry. */ export async function getInstanceRegistryContract(wallet) {
|
|
12
|
+
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractInstanceRegistry);
|
|
13
13
|
if (!contractInstance) {
|
|
14
|
-
throw new Error("
|
|
14
|
+
throw new Error("ContractInstanceRegistry is not registered in this wallet's instance");
|
|
15
15
|
}
|
|
16
16
|
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
17
17
|
return new UnsafeContract(contractInstance, artifact, wallet);
|
|
18
18
|
}
|
|
19
|
-
/** Returns a Contract wrapper for the fee juice */ export async function getFeeJuice(wallet) {
|
|
19
|
+
/** Returns a Contract wrapper for the fee juice contract */ export async function getFeeJuice(wallet) {
|
|
20
20
|
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.FeeJuice);
|
|
21
21
|
if (!contractInstance) {
|
|
22
22
|
throw new Error("FeeJuice is not registered in this wallet's instance");
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
-
import type { AztecNode
|
|
3
|
-
import {
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import { TxHash, type TxReceipt } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
4
5
|
/** Options related to waiting for a tx. */
|
|
5
6
|
export type WaitOpts = {
|
|
6
7
|
/** The amount of time to ignore TxStatus.DROPPED receipts (in seconds) due to the presumption that it is being propagated by the p2p network. Defaults to 5. */
|
|
7
8
|
ignoreDroppedReceiptsFor?: number;
|
|
8
9
|
/** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
|
|
9
10
|
timeout?: number;
|
|
10
|
-
/** The maximum time (in seconds) to wait for the transaction to be proven. Defaults to 600. */
|
|
11
|
-
provenTimeout?: number;
|
|
12
11
|
/** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
|
|
13
12
|
interval?: number;
|
|
14
|
-
/** Whether to wait for the tx to be proven. */
|
|
15
|
-
proven?: boolean;
|
|
16
|
-
/** Whether to include information useful for debugging/testing in the receipt. */
|
|
17
|
-
debug?: boolean;
|
|
18
13
|
/** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
|
|
19
14
|
dontThrowOnRevert?: boolean;
|
|
20
15
|
};
|
|
@@ -24,9 +19,11 @@ export declare const DefaultWaitOpts: WaitOpts;
|
|
|
24
19
|
* its hash, receipt, and mining status.
|
|
25
20
|
*/
|
|
26
21
|
export declare class SentTx {
|
|
27
|
-
protected
|
|
28
|
-
protected
|
|
29
|
-
|
|
22
|
+
protected walletOrNode: Wallet | AztecNode;
|
|
23
|
+
protected sendTxPromise: Promise<void>;
|
|
24
|
+
protected sendTxError?: Error;
|
|
25
|
+
protected txHash?: TxHash;
|
|
26
|
+
constructor(walletOrNode: Wallet | AztecNode, sendTx: () => Promise<TxHash>);
|
|
30
27
|
/**
|
|
31
28
|
* Retrieves the transaction hash of the SentTx instance.
|
|
32
29
|
* The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
|
|
@@ -49,13 +46,6 @@ export declare class SentTx {
|
|
|
49
46
|
* @returns The transaction receipt.
|
|
50
47
|
*/
|
|
51
48
|
wait(opts?: WaitOpts): Promise<FieldsOf<TxReceipt>>;
|
|
52
|
-
/**
|
|
53
|
-
* Gets public logs emitted by this tx.
|
|
54
|
-
* @remarks This function will wait for the tx to be mined if it hasn't been already.
|
|
55
|
-
* @returns The requested logs.
|
|
56
|
-
*/
|
|
57
|
-
getPublicLogs(): Promise<GetPublicLogsResponse>;
|
|
58
49
|
protected waitForReceipt(opts?: WaitOpts): Promise<TxReceipt>;
|
|
59
|
-
protected waitForProven(minedBlock: number, opts?: WaitOpts): Promise<number>;
|
|
60
50
|
}
|
|
61
51
|
//# sourceMappingURL=sent_tx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/sent_tx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/sent_tx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAY,MAAM,kBAAkB,CAAC;AAEpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,2CAA2C;AAC3C,MAAM,MAAM,QAAQ,GAAG;IACrB,gKAAgK;IAChK,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0HAA0H;IAC1H,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF;;;GAGG;AACH,qBAAa,MAAM;IAMf,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS;IAL5C,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IAC9B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAGd,YAAY,EAAE,MAAM,GAAG,SAAS,EAC1C,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC;IAgB/B;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAazC;;;;;;OAMG;IACU,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;IAK7C;;;;OAIG;IACU,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;cAUhD,cAAc,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;CA6BpE"}
|
package/dest/contract/sent_tx.js
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
1
2
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
3
|
import { TxStatus } from '@aztec/stdlib/tx';
|
|
3
4
|
export const DefaultWaitOpts = {
|
|
4
5
|
ignoreDroppedReceiptsFor: 5,
|
|
5
6
|
timeout: 60,
|
|
6
|
-
|
|
7
|
-
interval: 1,
|
|
8
|
-
debug: false
|
|
7
|
+
interval: 1
|
|
9
8
|
};
|
|
10
9
|
/**
|
|
11
10
|
* The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
|
|
12
11
|
* its hash, receipt, and mining status.
|
|
13
12
|
*/ export class SentTx {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
walletOrNode;
|
|
14
|
+
sendTxPromise;
|
|
15
|
+
sendTxError;
|
|
16
|
+
txHash;
|
|
17
|
+
constructor(walletOrNode, sendTx){
|
|
18
|
+
this.walletOrNode = walletOrNode;
|
|
19
|
+
const { promise, resolve } = promiseWithResolvers();
|
|
20
|
+
this.sendTxPromise = promise;
|
|
21
|
+
sendTx().then((txHash)=>{
|
|
22
|
+
this.txHash = txHash;
|
|
23
|
+
resolve();
|
|
24
|
+
}).catch((err)=>{
|
|
25
|
+
this.sendTxError = err;
|
|
26
|
+
// Calling resolve instead of reject here because we want to throw the error when getTxHash is called.
|
|
27
|
+
resolve();
|
|
28
|
+
});
|
|
19
29
|
}
|
|
20
30
|
/**
|
|
21
31
|
* Retrieves the transaction hash of the SentTx instance.
|
|
@@ -23,8 +33,15 @@ export const DefaultWaitOpts = {
|
|
|
23
33
|
*
|
|
24
34
|
* @returns A promise that resolves to the transaction hash of the SentTx instance.
|
|
25
35
|
* TODO(#7717): Don't throw here.
|
|
26
|
-
*/ getTxHash() {
|
|
27
|
-
|
|
36
|
+
*/ async getTxHash() {
|
|
37
|
+
// Make sure sendTx has been resolved, which can be triggered when it returns a txHash or when it throws an error.
|
|
38
|
+
await this.sendTxPromise;
|
|
39
|
+
// If sendTx threw an error, throw it.
|
|
40
|
+
if (this.sendTxError) {
|
|
41
|
+
throw this.sendTxError;
|
|
42
|
+
}
|
|
43
|
+
// sendTx returned a txHash if it's been resolved and no error was set.
|
|
44
|
+
return Promise.resolve(this.txHash);
|
|
28
45
|
}
|
|
29
46
|
/**
|
|
30
47
|
* Retrieve the transaction receipt associated with the current SentTx instance.
|
|
@@ -34,7 +51,7 @@ export const DefaultWaitOpts = {
|
|
|
34
51
|
* @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
|
|
35
52
|
*/ async getReceipt() {
|
|
36
53
|
const txHash = await this.getTxHash();
|
|
37
|
-
return await this.
|
|
54
|
+
return await this.walletOrNode.getTxReceipt(txHash);
|
|
38
55
|
}
|
|
39
56
|
/**
|
|
40
57
|
* Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
|
|
@@ -43,39 +60,16 @@ export const DefaultWaitOpts = {
|
|
|
43
60
|
*/ async wait(opts) {
|
|
44
61
|
const receipt = await this.waitForReceipt(opts);
|
|
45
62
|
if (receipt.status !== TxStatus.SUCCESS && !opts?.dontThrowOnRevert) {
|
|
46
|
-
throw new Error(`Transaction ${await this.getTxHash()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
|
|
47
|
-
}
|
|
48
|
-
if (opts?.proven && receipt.blockNumber !== undefined) {
|
|
49
|
-
await this.waitForProven(receipt.blockNumber, opts);
|
|
50
|
-
}
|
|
51
|
-
if (opts?.debug) {
|
|
52
|
-
const txHash = await this.getTxHash();
|
|
53
|
-
const { data: tx } = await this.pxeOrNode.getTxEffect(txHash);
|
|
54
|
-
receipt.debugInfo = {
|
|
55
|
-
noteHashes: tx.noteHashes,
|
|
56
|
-
nullifiers: tx.nullifiers,
|
|
57
|
-
publicDataWrites: tx.publicDataWrites,
|
|
58
|
-
l2ToL1Msgs: tx.l2ToL1Msgs
|
|
59
|
-
};
|
|
63
|
+
throw new Error(`Transaction ${(await this.getTxHash()).toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
|
|
60
64
|
}
|
|
61
65
|
return receipt;
|
|
62
66
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Gets public logs emitted by this tx.
|
|
65
|
-
* @remarks This function will wait for the tx to be mined if it hasn't been already.
|
|
66
|
-
* @returns The requested logs.
|
|
67
|
-
*/ async getPublicLogs() {
|
|
68
|
-
await this.wait();
|
|
69
|
-
return this.pxeOrNode.getPublicLogs({
|
|
70
|
-
txHash: await this.getTxHash()
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
67
|
async waitForReceipt(opts) {
|
|
74
68
|
const txHash = await this.getTxHash();
|
|
75
69
|
const startTime = Date.now();
|
|
76
70
|
const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
|
|
77
71
|
return await retryUntil(async ()=>{
|
|
78
|
-
const txReceipt = await this.
|
|
72
|
+
const txReceipt = await this.walletOrNode.getTxReceipt(txHash);
|
|
79
73
|
// If receipt is not yet available, try again
|
|
80
74
|
if (txReceipt.status === TxStatus.PENDING) {
|
|
81
75
|
return undefined;
|
|
@@ -93,10 +87,4 @@ export const DefaultWaitOpts = {
|
|
|
93
87
|
return txReceipt;
|
|
94
88
|
}, 'isMined', opts?.timeout ?? DefaultWaitOpts.timeout, opts?.interval ?? DefaultWaitOpts.interval);
|
|
95
89
|
}
|
|
96
|
-
async waitForProven(minedBlock, opts) {
|
|
97
|
-
return await retryUntil(async ()=>{
|
|
98
|
-
const provenBlock = await this.pxeOrNode.getProvenBlockNumber();
|
|
99
|
-
return provenBlock >= minedBlock ? provenBlock : undefined;
|
|
100
|
-
}, 'isProven', opts?.provenTimeout ?? DefaultWaitOpts.provenTimeout, opts?.interval ?? DefaultWaitOpts.interval);
|
|
101
|
-
}
|
|
102
90
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { Wallet } from '../wallet/
|
|
3
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
4
4
|
import { ContractBase } from './contract_base.js';
|
|
5
5
|
/** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */
|
|
6
6
|
export declare class UnsafeContract extends ContractBase {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsafe_contract.d.ts","sourceRoot":"","sources":["../../src/contract/unsafe_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"unsafe_contract.d.ts","sourceRoot":"","sources":["../../src/contract/unsafe_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,iHAAiH;AACjH,qBAAa,cAAe,SAAQ,YAAY;;IAE5C,iDAAiD;IACjD,QAAQ,EAAE,2BAA2B;IACrC,yDAAyD;IACzD,QAAQ,EAAE,gBAAgB;IAC1B,0DAA0D;IAC1D,MAAM,EAAE,MAAM;CAIjB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
2
|
+
import type { TxReceipt } from '@aztec/stdlib/tx';
|
|
3
|
+
/**
|
|
4
|
+
* Options for waiting for a transaction to be proven.
|
|
5
|
+
*/
|
|
6
|
+
export type WaitForProvenOpts = {
|
|
7
|
+
/** Time to wait for the tx to be proven before timing out */
|
|
8
|
+
provenTimeout?: number;
|
|
9
|
+
/** Elapsed time between polls to the node */
|
|
10
|
+
interval?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const DefaultWaitForProvenOpts: WaitForProvenOpts;
|
|
13
|
+
/**
|
|
14
|
+
* Wait for a transaction to be proven by polling the node
|
|
15
|
+
*/
|
|
16
|
+
export declare function waitForProven(node: AztecNode, receipt: TxReceipt, opts?: WaitForProvenOpts): Promise<number>;
|
|
17
|
+
//# sourceMappingURL=wait_for_proven.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait_for_proven.d.ts","sourceRoot":"","sources":["../../src/contract/wait_for_proven.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAGtC,CAAC;AAEF;;GAEG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,iBAAiB,mBAahG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
|
+
import { DefaultWaitOpts } from './sent_tx.js';
|
|
3
|
+
export const DefaultWaitForProvenOpts = {
|
|
4
|
+
provenTimeout: 600,
|
|
5
|
+
interval: DefaultWaitOpts.interval
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Wait for a transaction to be proven by polling the node
|
|
9
|
+
*/ export async function waitForProven(node, receipt, opts) {
|
|
10
|
+
if (!receipt.blockNumber) {
|
|
11
|
+
throw new Error(`Cannot wait for proven: receipt of tx ${receipt.txHash} does not have a block number`);
|
|
12
|
+
}
|
|
13
|
+
return await retryUntil(async ()=>{
|
|
14
|
+
const provenBlock = await node.getProvenBlockNumber();
|
|
15
|
+
return provenBlock >= receipt.blockNumber ? provenBlock : undefined;
|
|
16
|
+
}, 'isProven', opts?.provenTimeout ?? DefaultWaitForProvenOpts.provenTimeout, opts?.interval ?? DefaultWaitForProvenOpts.interval);
|
|
17
|
+
}
|
|
@@ -2,7 +2,7 @@ import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
|
2
2
|
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
3
3
|
import type { Wallet } from '../wallet/index.js';
|
|
4
4
|
/**
|
|
5
|
-
* Sets up a call to broadcast a private function's bytecode via the
|
|
5
|
+
* Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
|
|
6
6
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
7
7
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
8
8
|
* @param wallet - Wallet to send the transaction.
|
|
@@ -12,7 +12,7 @@ import type { Wallet } from '../wallet/index.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function broadcastPrivateFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
|
|
14
14
|
/**
|
|
15
|
-
* Sets up a call to broadcast
|
|
15
|
+
* Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
|
|
16
16
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
17
17
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
18
18
|
* @param wallet - Wallet to send the transaction.
|
|
@@ -20,5 +20,5 @@ export declare function broadcastPrivateFunction(wallet: Wallet, artifact: Contr
|
|
|
20
20
|
* @param selector - Selector of the function to be broadcast.
|
|
21
21
|
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
22
22
|
*/
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function broadcastUtilityFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
|
|
24
24
|
//# sourceMappingURL=broadcast_function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast_function.d.ts","sourceRoot":"","sources":["../../src/deployment/broadcast_function.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgC,MAAM,mBAAmB,CAAC;AAS1G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAoDtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,
|
|
1
|
+
{"version":3,"file":"broadcast_function.d.ts","sourceRoot":"","sources":["../../src/deployment/broadcast_function.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgC,MAAM,mBAAmB,CAAC;AAS1G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAoDtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CA8CtC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
1
|
+
import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
5
|
import { FunctionSelector, FunctionType, bufferAsFields } from '@aztec/stdlib/abi';
|
|
6
|
-
import { computeVerificationKeyHash, createPrivateFunctionMembershipProof,
|
|
6
|
+
import { computeVerificationKeyHash, createPrivateFunctionMembershipProof, createUtilityFunctionMembershipProof, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
7
7
|
import { Capsule } from '@aztec/stdlib/tx';
|
|
8
|
-
import {
|
|
8
|
+
import { getClassRegistryContract } from '../contract/protocol_contracts.js';
|
|
9
9
|
/**
|
|
10
|
-
* Sets up a call to broadcast a private function's bytecode via the
|
|
10
|
+
* Sets up a call to broadcast a private function's bytecode via the ClassRegistry contract.
|
|
11
11
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
12
12
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
13
13
|
* @param wallet - Wallet to send the transaction.
|
|
@@ -25,46 +25,50 @@ import { getRegistererContract } from '../contract/protocol_contracts.js';
|
|
|
25
25
|
if (!privateFunctionArtifact) {
|
|
26
26
|
throw new Error(`Private function with selector ${selector.toString()} not found`);
|
|
27
27
|
}
|
|
28
|
-
const { artifactTreeSiblingPath, artifactTreeLeafIndex, artifactMetadataHash, functionMetadataHash,
|
|
28
|
+
const { artifactTreeSiblingPath, artifactTreeLeafIndex, artifactMetadataHash, functionMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex } = await createPrivateFunctionMembershipProof(selector, artifact);
|
|
29
29
|
const vkHash = await computeVerificationKeyHash(privateFunctionArtifact);
|
|
30
|
-
const
|
|
31
|
-
const
|
|
30
|
+
const classRegistry = await getClassRegistryContract(wallet);
|
|
31
|
+
const bytecode = bufferAsFields(privateFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
|
|
32
|
+
return classRegistry.methods.broadcast_private_function(contractClass.id, artifactMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex, padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT), artifactTreeLeafIndex, // eslint-disable-next-line camelcase
|
|
32
33
|
{
|
|
33
34
|
selector,
|
|
34
35
|
metadata_hash: functionMetadataHash,
|
|
35
36
|
vk_hash: vkHash
|
|
37
|
+
}).with({
|
|
38
|
+
capsules: [
|
|
39
|
+
new Capsule(ProtocolContractAddress.ContractClassRegistry, new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT), bytecode)
|
|
40
|
+
]
|
|
36
41
|
});
|
|
37
|
-
const bytecode = bufferAsFields(privateFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
|
|
38
|
-
fn.addCapsule(new Capsule(ProtocolContractAddress.ContractClassRegisterer, new Fr(REGISTERER_CONTRACT_BYTECODE_CAPSULE_SLOT), bytecode));
|
|
39
|
-
return fn;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
|
-
* Sets up a call to broadcast
|
|
44
|
+
* Sets up a call to broadcast a utility function's bytecode via the ClassRegistry contract.
|
|
43
45
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
44
46
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
45
47
|
* @param wallet - Wallet to send the transaction.
|
|
46
48
|
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
47
49
|
* @param selector - Selector of the function to be broadcast.
|
|
48
50
|
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
49
|
-
*/ export async function
|
|
51
|
+
*/ export async function broadcastUtilityFunction(wallet, artifact, selector) {
|
|
50
52
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
+
const utilityFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.UTILITY);
|
|
54
|
+
const utilityFunctionsAndSelectors = await Promise.all(utilityFunctions.map(async (fn)=>({
|
|
53
55
|
f: fn,
|
|
54
56
|
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)
|
|
55
57
|
})));
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
58
|
-
throw new Error(`
|
|
58
|
+
const utilityFunctionArtifact = utilityFunctionsAndSelectors.find((fn)=>selector.equals(fn.selector))?.f;
|
|
59
|
+
if (!utilityFunctionArtifact) {
|
|
60
|
+
throw new Error(`Utility function with selector ${selector.toString()} not found`);
|
|
59
61
|
}
|
|
60
|
-
const { artifactMetadataHash, artifactTreeLeafIndex, artifactTreeSiblingPath, functionMetadataHash, privateFunctionsArtifactTreeRoot } = await
|
|
61
|
-
const
|
|
62
|
-
const
|
|
62
|
+
const { artifactMetadataHash, artifactTreeLeafIndex, artifactTreeSiblingPath, functionMetadataHash, privateFunctionsArtifactTreeRoot } = await createUtilityFunctionMembershipProof(selector, artifact);
|
|
63
|
+
const classRegistry = await getClassRegistryContract(wallet);
|
|
64
|
+
const bytecode = bufferAsFields(utilityFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
|
|
65
|
+
return classRegistry.methods.broadcast_utility_function(contractClass.id, artifactMetadataHash, privateFunctionsArtifactTreeRoot, padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT), artifactTreeLeafIndex, // eslint-disable-next-line camelcase
|
|
63
66
|
{
|
|
64
67
|
selector,
|
|
65
68
|
metadata_hash: functionMetadataHash
|
|
69
|
+
}).with({
|
|
70
|
+
capsules: [
|
|
71
|
+
new Capsule(ProtocolContractAddress.ContractClassRegistry, new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT), bytecode)
|
|
72
|
+
]
|
|
66
73
|
});
|
|
67
|
-
const bytecode = bufferAsFields(unconstrainedFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
|
|
68
|
-
fn.addCapsule(new Capsule(ProtocolContractAddress.ContractClassRegisterer, new Fr(REGISTERER_CONTRACT_BYTECODE_CAPSULE_SLOT), bytecode));
|
|
69
|
-
return fn;
|
|
70
74
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
3
|
-
import type { Wallet } from '../account/wallet.js';
|
|
4
3
|
import { Contract } from '../contract/contract.js';
|
|
5
4
|
import { DeployMethod } from '../contract/deploy_method.js';
|
|
5
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
6
6
|
/**
|
|
7
7
|
* A class for deploying contract.
|
|
8
8
|
* @remarks Keeping this around even though we have Aztec.nr contract types because it can be useful for non-TS users.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_deployer.d.ts","sourceRoot":"","sources":["../../src/deployment/contract_deployer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,
|
|
1
|
+
{"version":3,"file":"contract_deployer.d.ts","sourceRoot":"","sources":["../../src/deployment/contract_deployer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;GAGG;AACH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,UAAU,CAAC;IACnB,OAAO,CAAC,eAAe,CAAC;gBAHhB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,UAAU,YAAA,EACvB,eAAe,CAAC,EAAE,MAAM,YAAA;IAGlC;;;;;;;;OAQG;IACI,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAW7B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
3
|
+
import type { Wallet } from '../wallet/index.js';
|
|
4
|
+
/** Sets up a call to publish a contract class given its artifact. */
|
|
5
|
+
export declare function publishContractClass(wallet: Wallet, artifact: ContractArtifact): Promise<ContractFunctionInteraction>;
|
|
6
|
+
//# sourceMappingURL=publish_class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish_class.d.ts","sourceRoot":"","sources":["../../src/deployment/publish_class.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,gBAAgB,EAAkB,MAAM,mBAAmB,CAAC;AAI1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,qEAAqE;AACrE,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAetC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
|
+
import { bufferAsFields } from '@aztec/stdlib/abi';
|
|
5
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
6
|
+
import { Capsule } from '@aztec/stdlib/tx';
|
|
7
|
+
import { getClassRegistryContract } from '../contract/protocol_contracts.js';
|
|
8
|
+
/** Sets up a call to publish a contract class given its artifact. */ export async function publishContractClass(wallet, artifact) {
|
|
9
|
+
const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment, packedBytecode } = await getContractClassFromArtifact(artifact);
|
|
10
|
+
const classRegistry = await getClassRegistryContract(wallet);
|
|
11
|
+
const encodedBytecode = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);
|
|
12
|
+
return classRegistry.methods.publish(artifactHash, privateFunctionsRoot, publicBytecodeCommitment).with({
|
|
13
|
+
capsules: [
|
|
14
|
+
new Capsule(ProtocolContractAddress.ContractClassRegistry, new Fr(CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT), encodedBytecode)
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
2
|
+
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
3
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
4
|
+
/**
|
|
5
|
+
* Sets up a call to the canonical contract instance registry to publish a contract instance.
|
|
6
|
+
* @param wallet - The wallet to use for the publication (setup) tx.
|
|
7
|
+
* @param instance - The instance to publish.
|
|
8
|
+
*/
|
|
9
|
+
export declare function publishInstance(wallet: Wallet, instance: ContractInstanceWithAddress): Promise<ContractFunctionInteraction>;
|
|
10
|
+
//# sourceMappingURL=publish_instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish_instance.d.ts","sourceRoot":"","sources":["../../src/deployment/publish_instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CAWtC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getInstanceRegistryContract } from '../contract/protocol_contracts.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sets up a call to the canonical contract instance registry to publish a contract instance.
|
|
4
|
+
* @param wallet - The wallet to use for the publication (setup) tx.
|
|
5
|
+
* @param instance - The instance to publish.
|
|
6
|
+
*/ export async function publishInstance(wallet, instance) {
|
|
7
|
+
const contractInstanceRegistry = await getInstanceRegistryContract(wallet);
|
|
8
|
+
const { salt, currentContractClassId: contractClassId, publicKeys, deployer: instanceDeployer } = instance;
|
|
9
|
+
const isUniversalDeploy = instanceDeployer.isZero();
|
|
10
|
+
return contractInstanceRegistry.methods.publish_for_public_execution(salt, contractClassId, instance.initializationHash, publicKeys, isUniversalDeploy);
|
|
11
|
+
}
|