@aztec/aztec.js 0.0.0-test.0
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 +44 -0
- package/dest/account/contract.d.ts +37 -0
- package/dest/account/contract.d.ts.map +1 -0
- package/dest/account/contract.js +16 -0
- package/dest/account/index.d.ts +15 -0
- package/dest/account/index.d.ts.map +1 -0
- package/dest/account/index.js +9 -0
- package/dest/account/interface.d.ts +31 -0
- package/dest/account/interface.d.ts.map +1 -0
- package/dest/account/interface.js +4 -0
- package/dest/account/wallet.d.ts +11 -0
- package/dest/account/wallet.d.ts.map +1 -0
- package/dest/account/wallet.js +3 -0
- package/dest/account_manager/deploy_account_method.d.ts +15 -0
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -0
- package/dest/account_manager/deploy_account_method.js +43 -0
- package/dest/account_manager/deploy_account_sent_tx.d.ts +30 -0
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -0
- package/dest/account_manager/deploy_account_sent_tx.js +29 -0
- package/dest/account_manager/index.d.ts +108 -0
- package/dest/account_manager/index.d.ts.map +1 -0
- package/dest/account_manager/index.js +159 -0
- package/dest/api/abi.d.ts +3 -0
- package/dest/api/abi.d.ts.map +1 -0
- package/dest/api/abi.js +1 -0
- package/dest/api/account.d.ts +3 -0
- package/dest/api/account.d.ts.map +1 -0
- package/dest/api/account.js +2 -0
- package/dest/api/addresses.d.ts +3 -0
- package/dest/api/addresses.d.ts.map +1 -0
- package/dest/api/addresses.js +2 -0
- package/dest/api/cheat_codes.d.ts +26 -0
- package/dest/api/cheat_codes.d.ts.map +1 -0
- package/dest/api/cheat_codes.js +25 -0
- package/dest/api/deployment.d.ts +4 -0
- package/dest/api/deployment.d.ts.map +1 -0
- package/dest/api/deployment.js +3 -0
- package/dest/api/entrypoint.d.ts +2 -0
- package/dest/api/entrypoint.d.ts.map +1 -0
- package/dest/api/entrypoint.js +1 -0
- package/dest/api/eth_address.d.ts +2 -0
- package/dest/api/eth_address.d.ts.map +1 -0
- package/dest/api/eth_address.js +1 -0
- package/dest/api/ethereum/anvil_test_watcher.d.ts +32 -0
- package/dest/api/ethereum/anvil_test_watcher.d.ts.map +1 -0
- package/dest/api/ethereum/anvil_test_watcher.js +133 -0
- package/dest/api/ethereum/chain_monitor.d.ts +25 -0
- package/dest/api/ethereum/chain_monitor.d.ts.map +1 -0
- package/dest/api/ethereum/chain_monitor.js +74 -0
- package/dest/api/ethereum/cheat_codes.d.ts +63 -0
- package/dest/api/ethereum/cheat_codes.d.ts.map +1 -0
- package/dest/api/ethereum/cheat_codes.js +162 -0
- package/dest/api/ethereum/index.d.ts +7 -0
- package/dest/api/ethereum/index.d.ts.map +1 -0
- package/dest/api/ethereum/index.js +6 -0
- package/dest/api/ethereum/l1_contracts.d.ts +3 -0
- package/dest/api/ethereum/l1_contracts.d.ts.map +1 -0
- package/dest/api/ethereum/l1_contracts.js +13 -0
- package/dest/api/ethereum/portal_manager.d.ts +136 -0
- package/dest/api/ethereum/portal_manager.d.ts.map +1 -0
- package/dest/api/ethereum/portal_manager.js +286 -0
- package/dest/api/fee.d.ts +6 -0
- package/dest/api/fee.d.ts.map +1 -0
- package/dest/api/fee.js +4 -0
- package/dest/api/fields.d.ts +2 -0
- package/dest/api/fields.d.ts.map +1 -0
- package/dest/api/fields.js +1 -0
- package/dest/api/interfaces/pxe.d.ts +2 -0
- package/dest/api/interfaces/pxe.d.ts.map +1 -0
- package/dest/api/interfaces/pxe.js +1 -0
- package/dest/api/log.d.ts +2 -0
- package/dest/api/log.d.ts.map +1 -0
- package/dest/api/log.js +1 -0
- package/dest/api/log_id.d.ts +2 -0
- package/dest/api/log_id.d.ts.map +1 -0
- package/dest/api/log_id.js +1 -0
- package/dest/api/tx_hash.d.ts +2 -0
- package/dest/api/tx_hash.d.ts.map +1 -0
- package/dest/api/tx_hash.js +1 -0
- package/dest/api/wallet.d.ts +2 -0
- package/dest/api/wallet.d.ts.map +1 -0
- package/dest/api/wallet.js +1 -0
- package/dest/contract/base_contract_interaction.d.ts +98 -0
- package/dest/contract/base_contract_interaction.d.ts.map +1 -0
- package/dest/contract/base_contract_interaction.js +149 -0
- package/dest/contract/batch_call.d.ts +28 -0
- package/dest/contract/batch_call.d.ts.map +1 -0
- package/dest/contract/batch_call.js +91 -0
- package/dest/contract/checker.d.ts +11 -0
- package/dest/contract/checker.d.ts.map +1 -0
- package/dest/contract/checker.js +107 -0
- package/dest/contract/contract.d.ts +41 -0
- package/dest/contract/contract.d.ts.map +1 -0
- package/dest/contract/contract.js +52 -0
- package/dest/contract/contract_base.d.ts +61 -0
- package/dest/contract/contract_base.d.ts.map +1 -0
- package/dest/contract/contract_base.js +45 -0
- package/dest/contract/contract_function_interaction.d.ts +68 -0
- package/dest/contract/contract_function_interaction.d.ts.map +1 -0
- package/dest/contract/contract_function_interaction.js +122 -0
- package/dest/contract/deploy_method.d.ts +113 -0
- package/dest/contract/deploy_method.d.ts.map +1 -0
- package/dest/contract/deploy_method.js +212 -0
- package/dest/contract/deploy_proven_tx.d.ts +21 -0
- package/dest/contract/deploy_proven_tx.d.ts.map +1 -0
- package/dest/contract/deploy_proven_tx.js +19 -0
- package/dest/contract/deploy_sent_tx.d.ts +45 -0
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -0
- package/dest/contract/deploy_sent_tx.js +43 -0
- package/dest/contract/get_gas_limits.d.ts +18 -0
- package/dest/contract/get_gas_limits.d.ts.map +1 -0
- package/dest/contract/get_gas_limits.js +10 -0
- package/dest/contract/index.d.ts +45 -0
- package/dest/contract/index.d.ts.map +1 -0
- package/dest/contract/index.js +43 -0
- package/dest/contract/protocol_contracts.d.ts +9 -0
- package/dest/contract/protocol_contracts.d.ts.map +1 -0
- package/dest/contract/protocol_contracts.js +26 -0
- package/dest/contract/proven_tx.d.ts +17 -0
- package/dest/contract/proven_tx.d.ts.map +1 -0
- package/dest/contract/proven_tx.js +22 -0
- package/dest/contract/sent_tx.d.ts +61 -0
- package/dest/contract/sent_tx.d.ts.map +1 -0
- package/dest/contract/sent_tx.js +102 -0
- package/dest/contract/unsafe_contract.d.ts +15 -0
- package/dest/contract/unsafe_contract.d.ts.map +1 -0
- package/dest/contract/unsafe_contract.js +6 -0
- package/dest/deployment/broadcast_function.d.ts +24 -0
- package/dest/deployment/broadcast_function.d.ts.map +1 -0
- package/dest/deployment/broadcast_function.js +70 -0
- package/dest/deployment/contract_deployer.d.ts +27 -0
- package/dest/deployment/contract_deployer.d.ts.map +1 -0
- package/dest/deployment/contract_deployer.js +30 -0
- package/dest/deployment/deploy_instance.d.ts +10 -0
- package/dest/deployment/deploy_instance.d.ts.map +1 -0
- package/dest/deployment/deploy_instance.js +14 -0
- package/dest/deployment/index.d.ts +2 -0
- package/dest/deployment/index.d.ts.map +1 -0
- package/dest/deployment/index.js +1 -0
- package/dest/deployment/register_class.d.ts +6 -0
- package/dest/deployment/register_class.d.ts.map +1 -0
- package/dest/deployment/register_class.js +22 -0
- package/dest/entrypoint/default_entrypoint.d.ts +12 -0
- package/dest/entrypoint/default_entrypoint.d.ts.map +1 -0
- package/dest/entrypoint/default_entrypoint.js +28 -0
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +15 -0
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -0
- package/dest/entrypoint/default_multi_call_entrypoint.js +130 -0
- package/dest/entrypoint/entrypoint.d.ts +35 -0
- package/dest/entrypoint/entrypoint.d.ts.map +1 -0
- package/dest/entrypoint/entrypoint.js +4 -0
- package/dest/entrypoint/payload.d.ts +128 -0
- package/dest/entrypoint/payload.d.ts.map +1 -0
- package/dest/entrypoint/payload.js +143 -0
- package/dest/fee/fee_juice_payment_method.d.ts +14 -0
- package/dest/fee/fee_juice_payment_method.d.ts.map +1 -0
- package/dest/fee/fee_juice_payment_method.js +20 -0
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +18 -0
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -0
- package/dest/fee/fee_juice_payment_method_with_claim.js +37 -0
- package/dest/fee/fee_payment_method.d.ts +22 -0
- package/dest/fee/fee_payment_method.d.ts.map +1 -0
- package/dest/fee/fee_payment_method.js +3 -0
- package/dest/fee/private_fee_payment_method.d.ts +51 -0
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/private_fee_payment_method.js +103 -0
- package/dest/fee/public_fee_payment_method.d.ts +41 -0
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/public_fee_payment_method.js +97 -0
- package/dest/index.d.ts +66 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +69 -0
- package/dest/rpc_clients/index.d.ts +3 -0
- package/dest/rpc_clients/index.d.ts.map +1 -0
- package/dest/rpc_clients/index.js +2 -0
- package/dest/rpc_clients/node/index.d.ts +12 -0
- package/dest/rpc_clients/node/index.d.ts.map +1 -0
- package/dest/rpc_clients/node/index.js +78 -0
- package/dest/rpc_clients/pxe_client.d.ts +10 -0
- package/dest/rpc_clients/pxe_client.d.ts.map +1 -0
- package/dest/rpc_clients/pxe_client.js +23 -0
- package/dest/utils/abi_types.d.ts +29 -0
- package/dest/utils/abi_types.d.ts.map +1 -0
- package/dest/utils/abi_types.js +1 -0
- package/dest/utils/authwit.d.ts +60 -0
- package/dest/utils/authwit.d.ts.map +1 -0
- package/dest/utils/authwit.js +74 -0
- package/dest/utils/aztec_cheatcodes.d.ts +59 -0
- package/dest/utils/aztec_cheatcodes.d.ts.map +1 -0
- package/dest/utils/aztec_cheatcodes.js +62 -0
- package/dest/utils/fee_juice.d.ts +7 -0
- package/dest/utils/fee_juice.d.ts.map +1 -0
- package/dest/utils/fee_juice.js +9 -0
- package/dest/utils/field_compressed_string.d.ts +17 -0
- package/dest/utils/field_compressed_string.d.ts.map +1 -0
- package/dest/utils/field_compressed_string.js +15 -0
- package/dest/utils/index.d.ts +8 -0
- package/dest/utils/index.d.ts.map +1 -0
- package/dest/utils/index.js +6 -0
- package/dest/utils/node.d.ts +5 -0
- package/dest/utils/node.d.ts.map +1 -0
- package/dest/utils/node.js +15 -0
- package/dest/utils/pub_key.d.ts +9 -0
- package/dest/utils/pub_key.d.ts.map +1 -0
- package/dest/utils/pub_key.js +9 -0
- package/dest/utils/pxe.d.ts +4 -0
- package/dest/utils/pxe.d.ts.map +1 -0
- package/dest/utils/pxe.js +14 -0
- package/dest/wallet/account_wallet.d.ts +76 -0
- package/dest/wallet/account_wallet.d.ts.map +1 -0
- package/dest/wallet/account_wallet.js +231 -0
- package/dest/wallet/account_wallet_with_private_key.d.ts +26 -0
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +1 -0
- package/dest/wallet/account_wallet_with_private_key.js +22 -0
- package/dest/wallet/base_wallet.d.ts +73 -0
- package/dest/wallet/base_wallet.d.ts.map +1 -0
- package/dest/wallet/base_wallet.js +123 -0
- package/dest/wallet/index.d.ts +17 -0
- package/dest/wallet/index.d.ts.map +1 -0
- package/dest/wallet/index.js +20 -0
- package/dest/wallet/signerless_wallet.d.ts +25 -0
- package/dest/wallet/signerless_wallet.d.ts.map +1 -0
- package/dest/wallet/signerless_wallet.js +36 -0
- package/package.json +116 -0
- package/src/account/contract.ts +56 -0
- package/src/account/index.ts +16 -0
- package/src/account/interface.ts +36 -0
- package/src/account/wallet.ts +13 -0
- package/src/account_manager/deploy_account_method.ts +86 -0
- package/src/account_manager/deploy_account_sent_tx.ts +42 -0
- package/src/account_manager/index.ts +229 -0
- package/src/api/README.md +7 -0
- package/src/api/abi.ts +10 -0
- package/src/api/account.ts +10 -0
- package/src/api/addresses.ts +2 -0
- package/src/api/cheat_codes.ts +35 -0
- package/src/api/deployment.ts +3 -0
- package/src/api/entrypoint.ts +1 -0
- package/src/api/eth_address.ts +1 -0
- package/src/api/ethereum/anvil_test_watcher.ts +158 -0
- package/src/api/ethereum/chain_monitor.ts +88 -0
- package/src/api/ethereum/cheat_codes.ts +184 -0
- package/src/api/ethereum/index.ts +19 -0
- package/src/api/ethereum/l1_contracts.ts +21 -0
- package/src/api/ethereum/portal_manager.ts +410 -0
- package/src/api/fee.ts +5 -0
- package/src/api/fields.ts +1 -0
- package/src/api/interfaces/pxe.ts +1 -0
- package/src/api/log.ts +1 -0
- package/src/api/log_id.ts +1 -0
- package/src/api/tx_hash.ts +1 -0
- package/src/api/wallet.ts +7 -0
- package/src/contract/base_contract_interaction.ts +192 -0
- package/src/contract/batch_call.ts +95 -0
- package/src/contract/checker.ts +117 -0
- package/src/contract/contract.ts +69 -0
- package/src/contract/contract_base.ts +90 -0
- package/src/contract/contract_function_interaction.ts +173 -0
- package/src/contract/deploy_method.ts +271 -0
- package/src/contract/deploy_proven_tx.ts +34 -0
- package/src/contract/deploy_sent_tx.ts +74 -0
- package/src/contract/get_gas_limits.ts +26 -0
- package/src/contract/index.ts +48 -0
- package/src/contract/protocol_contracts.ts +35 -0
- package/src/contract/proven_tx.ts +42 -0
- package/src/contract/sent_tx.ts +141 -0
- package/src/contract/unsafe_contract.ts +19 -0
- package/src/deployment/broadcast_function.ts +148 -0
- package/src/deployment/contract_deployer.ts +41 -0
- package/src/deployment/deploy_instance.ts +31 -0
- package/src/deployment/index.ts +1 -0
- package/src/deployment/register_class.ts +44 -0
- package/src/entrypoint/default_entrypoint.ts +39 -0
- package/src/entrypoint/default_multi_call_entrypoint.ts +93 -0
- package/src/entrypoint/entrypoint.ts +39 -0
- package/src/entrypoint/payload.ts +238 -0
- package/src/fee/fee_juice_payment_method.ts +26 -0
- package/src/fee/fee_juice_payment_method_with_claim.ts +49 -0
- package/src/fee/fee_payment_method.ts +22 -0
- package/src/fee/private_fee_payment_method.ts +118 -0
- package/src/fee/public_fee_payment_method.ts +114 -0
- package/src/index.ts +106 -0
- package/src/rpc_clients/index.ts +2 -0
- package/src/rpc_clients/node/index.ts +77 -0
- package/src/rpc_clients/pxe_client.ts +25 -0
- package/src/utils/abi_types.ts +25 -0
- package/src/utils/authwit.ts +110 -0
- package/src/utils/aztec_cheatcodes.ts +77 -0
- package/src/utils/fee_juice.ts +14 -0
- package/src/utils/field_compressed_string.ts +27 -0
- package/src/utils/index.ts +21 -0
- package/src/utils/node.ts +19 -0
- package/src/utils/pub_key.ts +13 -0
- package/src/utils/pxe.ts +17 -0
- package/src/wallet/account_wallet.ts +242 -0
- package/src/wallet/account_wallet_with_private_key.ts +40 -0
- package/src/wallet/base_wallet.ts +198 -0
- package/src/wallet/index.ts +33 -0
- package/src/wallet/signerless_wallet.ts +52 -0
|
@@ -0,0 +1,238 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
+
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
4
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
5
|
+
|
|
6
|
+
import type { L2AmountClaim } from '../api/ethereum/portal_manager.js';
|
|
7
|
+
import { getFeeJuice } from '../contract/protocol_contracts.js';
|
|
8
|
+
import type { Wallet } from '../wallet/index.js';
|
|
9
|
+
import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Pay fee directly with Fee Juice claimed on the same tx.
|
|
13
|
+
*/
|
|
14
|
+
export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
|
|
15
|
+
constructor(
|
|
16
|
+
private senderWallet: Wallet,
|
|
17
|
+
private claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>,
|
|
18
|
+
) {
|
|
19
|
+
super(senderWallet.getAddress());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates a function call to pay the fee in Fee Juice.
|
|
24
|
+
* @returns A function call
|
|
25
|
+
*/
|
|
26
|
+
override async getFunctionCalls(): Promise<FunctionCall[]> {
|
|
27
|
+
const canonicalFeeJuice = await getFeeJuice(this.senderWallet);
|
|
28
|
+
const selector = await FunctionSelector.fromNameAndParameters(
|
|
29
|
+
canonicalFeeJuice.artifact.functions.find(f => f.name === 'claim')!,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return Promise.resolve([
|
|
33
|
+
{
|
|
34
|
+
to: ProtocolContractAddress.FeeJuice,
|
|
35
|
+
name: 'claim',
|
|
36
|
+
selector,
|
|
37
|
+
isStatic: false,
|
|
38
|
+
args: [
|
|
39
|
+
this.senderWallet.getAddress().toField(),
|
|
40
|
+
new Fr(this.claim.claimAmount),
|
|
41
|
+
this.claim.claimSecret,
|
|
42
|
+
new Fr(this.claim.messageLeafIndex),
|
|
43
|
+
],
|
|
44
|
+
returnTypes: [],
|
|
45
|
+
type: FunctionType.PRIVATE,
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
7
|
+
*/
|
|
8
|
+
export interface FeePaymentMethod {
|
|
9
|
+
/** The asset used to pay the fee. */
|
|
10
|
+
getAsset(): Promise<AztecAddress>;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a function call to pay the fee in the given asset.
|
|
13
|
+
* @param gasSettings - The gas limits and max fees.
|
|
14
|
+
* @returns The function call to pay the fee.
|
|
15
|
+
*/
|
|
16
|
+
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
|
|
17
|
+
/**
|
|
18
|
+
* The expected fee payer for this tx.
|
|
19
|
+
* @param gasSettings - The gas limits and max fees.
|
|
20
|
+
*/
|
|
21
|
+
getFeePayer(gasSettings: GasSettings): Promise<AztecAddress>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { type FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
|
|
6
|
+
import type { Wallet } from '../account/wallet.js';
|
|
7
|
+
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
8
|
+
import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
9
|
+
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
13
|
+
*/
|
|
14
|
+
export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
15
|
+
private assetPromise: Promise<AztecAddress> | null = null;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
/**
|
|
19
|
+
* Address which will hold the fee payment.
|
|
20
|
+
*/
|
|
21
|
+
private paymentContract: AztecAddress,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An auth witness provider to authorize fee payments
|
|
25
|
+
*/
|
|
26
|
+
private wallet: Wallet,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* If true, the max fee will be set to 1.
|
|
30
|
+
* TODO(#7694): Remove this param once the lacking feature in TXE is implemented.
|
|
31
|
+
*/
|
|
32
|
+
private setMaxFeeToOne = false,
|
|
33
|
+
) {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The asset used to pay the fee.
|
|
37
|
+
* @returns The asset used to pay the fee.
|
|
38
|
+
*/
|
|
39
|
+
getAsset(): Promise<AztecAddress> {
|
|
40
|
+
if (!this.assetPromise) {
|
|
41
|
+
// We use signer-less wallet because this function could be triggered before the associated account is deployed.
|
|
42
|
+
const signerlessWallet = new SignerlessWallet(this.wallet);
|
|
43
|
+
|
|
44
|
+
const interaction = new ContractFunctionInteraction(
|
|
45
|
+
signerlessWallet,
|
|
46
|
+
this.paymentContract,
|
|
47
|
+
{
|
|
48
|
+
name: 'get_accepted_asset',
|
|
49
|
+
functionType: FunctionType.PRIVATE,
|
|
50
|
+
isInternal: false,
|
|
51
|
+
isStatic: false,
|
|
52
|
+
parameters: [],
|
|
53
|
+
returnTypes: [
|
|
54
|
+
{
|
|
55
|
+
kind: 'struct',
|
|
56
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
57
|
+
fields: [
|
|
58
|
+
{
|
|
59
|
+
name: 'inner',
|
|
60
|
+
type: {
|
|
61
|
+
kind: 'field',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
errorTypes: {},
|
|
68
|
+
isInitializer: false,
|
|
69
|
+
},
|
|
70
|
+
[],
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
this.assetPromise = interaction.simulate();
|
|
74
|
+
}
|
|
75
|
+
return this.assetPromise!;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
79
|
+
return Promise.resolve(this.paymentContract);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Creates a function call to pay the fee in the given asset.
|
|
84
|
+
* @param gasSettings - The gas settings.
|
|
85
|
+
* @returns The function call to pay the fee.
|
|
86
|
+
*/
|
|
87
|
+
async getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
|
|
88
|
+
// We assume 1:1 exchange rate between fee juice and token. But in reality you would need to convert feeLimit
|
|
89
|
+
// (maxFee) to be in token denomination.
|
|
90
|
+
const maxFee = this.setMaxFeeToOne ? Fr.ONE : gasSettings.getFeeLimit();
|
|
91
|
+
const nonce = Fr.random();
|
|
92
|
+
|
|
93
|
+
await this.wallet.createAuthWit({
|
|
94
|
+
caller: this.paymentContract,
|
|
95
|
+
action: {
|
|
96
|
+
name: 'transfer_to_public',
|
|
97
|
+
args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), maxFee, nonce],
|
|
98
|
+
selector: await FunctionSelector.fromSignature('transfer_to_public((Field),(Field),u128,Field)'),
|
|
99
|
+
type: FunctionType.PRIVATE,
|
|
100
|
+
isStatic: false,
|
|
101
|
+
to: await this.getAsset(),
|
|
102
|
+
returnTypes: [],
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
name: 'fee_entrypoint_private',
|
|
109
|
+
to: this.paymentContract,
|
|
110
|
+
selector: await FunctionSelector.fromSignature('fee_entrypoint_private(u128,Field)'),
|
|
111
|
+
type: FunctionType.PRIVATE,
|
|
112
|
+
isStatic: false,
|
|
113
|
+
args: [maxFee, nonce],
|
|
114
|
+
returnTypes: [],
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
3
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
|
+
|
|
7
|
+
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
8
|
+
import type { AccountWallet } from '../wallet/account_wallet.js';
|
|
9
|
+
import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
10
|
+
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
14
|
+
*/
|
|
15
|
+
export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
16
|
+
private assetPromise: Promise<AztecAddress> | null = null;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
/**
|
|
20
|
+
* Address which will hold the fee payment.
|
|
21
|
+
*/
|
|
22
|
+
protected paymentContract: AztecAddress,
|
|
23
|
+
/**
|
|
24
|
+
* An auth witness provider to authorize fee payments
|
|
25
|
+
*/
|
|
26
|
+
protected wallet: AccountWallet,
|
|
27
|
+
) {}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The asset used to pay the fee.
|
|
31
|
+
* @returns The asset used to pay the fee.
|
|
32
|
+
*/
|
|
33
|
+
getAsset(): Promise<AztecAddress> {
|
|
34
|
+
if (!this.assetPromise) {
|
|
35
|
+
// We use signer-less wallet because this function could be triggered before the associated account is deployed.
|
|
36
|
+
const signerlessWallet = new SignerlessWallet(this.wallet);
|
|
37
|
+
|
|
38
|
+
const interaction = new ContractFunctionInteraction(
|
|
39
|
+
signerlessWallet,
|
|
40
|
+
this.paymentContract,
|
|
41
|
+
{
|
|
42
|
+
name: 'get_accepted_asset',
|
|
43
|
+
functionType: FunctionType.PRIVATE,
|
|
44
|
+
isInternal: false,
|
|
45
|
+
isStatic: false,
|
|
46
|
+
parameters: [],
|
|
47
|
+
returnTypes: [
|
|
48
|
+
{
|
|
49
|
+
kind: 'struct',
|
|
50
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
51
|
+
fields: [
|
|
52
|
+
{
|
|
53
|
+
name: 'inner',
|
|
54
|
+
type: {
|
|
55
|
+
kind: 'field',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
errorTypes: {},
|
|
62
|
+
isInitializer: false,
|
|
63
|
+
},
|
|
64
|
+
[],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
this.assetPromise = interaction.simulate();
|
|
68
|
+
}
|
|
69
|
+
return this.assetPromise!;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
73
|
+
return Promise.resolve(this.paymentContract);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Creates a function call to pay the fee in the given asset.
|
|
78
|
+
* @param gasSettings - The gas settings.
|
|
79
|
+
* @returns The function call to pay the fee.
|
|
80
|
+
*/
|
|
81
|
+
async getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
|
|
82
|
+
const nonce = Fr.random();
|
|
83
|
+
const maxFee = gasSettings.getFeeLimit();
|
|
84
|
+
|
|
85
|
+
const setPublicAuthWitInteraction = await this.wallet.setPublicAuthWit(
|
|
86
|
+
{
|
|
87
|
+
caller: this.paymentContract,
|
|
88
|
+
action: {
|
|
89
|
+
name: 'transfer_in_public',
|
|
90
|
+
args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), maxFee, nonce],
|
|
91
|
+
selector: await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),u128,Field)'),
|
|
92
|
+
type: FunctionType.PUBLIC,
|
|
93
|
+
isStatic: false,
|
|
94
|
+
to: await this.getAsset(),
|
|
95
|
+
returnTypes: [],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
true,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return [
|
|
102
|
+
await setPublicAuthWitInteraction.request(),
|
|
103
|
+
{
|
|
104
|
+
name: 'fee_entrypoint_public',
|
|
105
|
+
to: this.paymentContract,
|
|
106
|
+
selector: await FunctionSelector.fromSignature('fee_entrypoint_public(u128,Field)'),
|
|
107
|
+
type: FunctionType.PRIVATE,
|
|
108
|
+
isStatic: false,
|
|
109
|
+
args: [maxFee, nonce],
|
|
110
|
+
returnTypes: [],
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
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';
|