@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,37 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
4
|
+
import { getFeeJuice } from '../contract/protocol_contracts.js';
|
|
5
|
+
import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
|
|
6
|
+
/**
|
|
7
|
+
* Pay fee directly with Fee Juice claimed on the same tx.
|
|
8
|
+
*/ export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
|
|
9
|
+
senderWallet;
|
|
10
|
+
claim;
|
|
11
|
+
constructor(senderWallet, claim){
|
|
12
|
+
super(senderWallet.getAddress()), this.senderWallet = senderWallet, this.claim = claim;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a function call to pay the fee in Fee Juice.
|
|
16
|
+
* @returns A function call
|
|
17
|
+
*/ async getFunctionCalls() {
|
|
18
|
+
const canonicalFeeJuice = await getFeeJuice(this.senderWallet);
|
|
19
|
+
const selector = await FunctionSelector.fromNameAndParameters(canonicalFeeJuice.artifact.functions.find((f)=>f.name === 'claim'));
|
|
20
|
+
return Promise.resolve([
|
|
21
|
+
{
|
|
22
|
+
to: ProtocolContractAddress.FeeJuice,
|
|
23
|
+
name: 'claim',
|
|
24
|
+
selector,
|
|
25
|
+
isStatic: false,
|
|
26
|
+
args: [
|
|
27
|
+
this.senderWallet.getAddress().toField(),
|
|
28
|
+
new Fr(this.claim.claimAmount),
|
|
29
|
+
this.claim.claimSecret,
|
|
30
|
+
new Fr(this.claim.messageLeafIndex)
|
|
31
|
+
],
|
|
32
|
+
returnTypes: [],
|
|
33
|
+
type: FunctionType.PRIVATE
|
|
34
|
+
}
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -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
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
6
|
+
*/
|
|
7
|
+
export interface FeePaymentMethod {
|
|
8
|
+
/** The asset used to pay the fee. */
|
|
9
|
+
getAsset(): Promise<AztecAddress>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a function call to pay the fee in the given asset.
|
|
12
|
+
* @param gasSettings - The gas limits and max fees.
|
|
13
|
+
* @returns The function call to pay the fee.
|
|
14
|
+
*/
|
|
15
|
+
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
|
|
16
|
+
/**
|
|
17
|
+
* The expected fee payer for this tx.
|
|
18
|
+
* @param gasSettings - The gas limits and max fees.
|
|
19
|
+
*/
|
|
20
|
+
getFeePayer(gasSettings: GasSettings): Promise<AztecAddress>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=fee_payment_method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAClC;;;;OAIG;IACH,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACpE;;;OAGG;IACH,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
import type { Wallet } from '../account/wallet.js';
|
|
5
|
+
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
6
|
+
/**
|
|
7
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
10
|
+
/**
|
|
11
|
+
* Address which will hold the fee payment.
|
|
12
|
+
*/
|
|
13
|
+
private paymentContract;
|
|
14
|
+
/**
|
|
15
|
+
* An auth witness provider to authorize fee payments
|
|
16
|
+
*/
|
|
17
|
+
private wallet;
|
|
18
|
+
/**
|
|
19
|
+
* If true, the max fee will be set to 1.
|
|
20
|
+
* TODO(#7694): Remove this param once the lacking feature in TXE is implemented.
|
|
21
|
+
*/
|
|
22
|
+
private setMaxFeeToOne;
|
|
23
|
+
private assetPromise;
|
|
24
|
+
constructor(
|
|
25
|
+
/**
|
|
26
|
+
* Address which will hold the fee payment.
|
|
27
|
+
*/
|
|
28
|
+
paymentContract: AztecAddress,
|
|
29
|
+
/**
|
|
30
|
+
* An auth witness provider to authorize fee payments
|
|
31
|
+
*/
|
|
32
|
+
wallet: Wallet,
|
|
33
|
+
/**
|
|
34
|
+
* If true, the max fee will be set to 1.
|
|
35
|
+
* TODO(#7694): Remove this param once the lacking feature in TXE is implemented.
|
|
36
|
+
*/
|
|
37
|
+
setMaxFeeToOne?: boolean);
|
|
38
|
+
/**
|
|
39
|
+
* The asset used to pay the fee.
|
|
40
|
+
* @returns The asset used to pay the fee.
|
|
41
|
+
*/
|
|
42
|
+
getAsset(): Promise<AztecAddress>;
|
|
43
|
+
getFeePayer(): Promise<AztecAddress>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a function call to pay the fee in the given asset.
|
|
46
|
+
* @param gasSettings - The gas settings.
|
|
47
|
+
* @returns The function call to pay the fee.
|
|
48
|
+
*/
|
|
49
|
+
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=private_fee_payment_method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/private_fee_payment_method.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAkC,MAAM,mBAAmB,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAI5D;;OAEG;IACH,OAAO,CAAC,eAAe;IAEvB;;OAEG;IACH,OAAO,CAAC,MAAM;IAEd;;;OAGG;IACH,OAAO,CAAC,cAAc;IAjBxB,OAAO,CAAC,YAAY,CAAsC;;IAGxD;;OAEG;IACK,eAAe,EAAE,YAAY;IAErC;;OAEG;IACK,MAAM,EAAE,MAAM;IAEtB;;;OAGG;IACK,cAAc,UAAQ;IAGhC;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAuCjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC;;;;OAIG;IACG,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CA+B1E"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
+
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
4
|
+
import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
5
|
+
/**
|
|
6
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
7
|
+
*/ export class PrivateFeePaymentMethod {
|
|
8
|
+
paymentContract;
|
|
9
|
+
wallet;
|
|
10
|
+
setMaxFeeToOne;
|
|
11
|
+
assetPromise;
|
|
12
|
+
constructor(/**
|
|
13
|
+
* Address which will hold the fee payment.
|
|
14
|
+
*/ paymentContract, /**
|
|
15
|
+
* An auth witness provider to authorize fee payments
|
|
16
|
+
*/ wallet, /**
|
|
17
|
+
* If true, the max fee will be set to 1.
|
|
18
|
+
* TODO(#7694): Remove this param once the lacking feature in TXE is implemented.
|
|
19
|
+
*/ setMaxFeeToOne = false){
|
|
20
|
+
this.paymentContract = paymentContract;
|
|
21
|
+
this.wallet = wallet;
|
|
22
|
+
this.setMaxFeeToOne = setMaxFeeToOne;
|
|
23
|
+
this.assetPromise = null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The asset used to pay the fee.
|
|
27
|
+
* @returns The asset used to pay the fee.
|
|
28
|
+
*/ getAsset() {
|
|
29
|
+
if (!this.assetPromise) {
|
|
30
|
+
// We use signer-less wallet because this function could be triggered before the associated account is deployed.
|
|
31
|
+
const signerlessWallet = new SignerlessWallet(this.wallet);
|
|
32
|
+
const interaction = new ContractFunctionInteraction(signerlessWallet, this.paymentContract, {
|
|
33
|
+
name: 'get_accepted_asset',
|
|
34
|
+
functionType: FunctionType.PRIVATE,
|
|
35
|
+
isInternal: false,
|
|
36
|
+
isStatic: false,
|
|
37
|
+
parameters: [],
|
|
38
|
+
returnTypes: [
|
|
39
|
+
{
|
|
40
|
+
kind: 'struct',
|
|
41
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
42
|
+
fields: [
|
|
43
|
+
{
|
|
44
|
+
name: 'inner',
|
|
45
|
+
type: {
|
|
46
|
+
kind: 'field'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
errorTypes: {},
|
|
53
|
+
isInitializer: false
|
|
54
|
+
}, []);
|
|
55
|
+
this.assetPromise = interaction.simulate();
|
|
56
|
+
}
|
|
57
|
+
return this.assetPromise;
|
|
58
|
+
}
|
|
59
|
+
getFeePayer() {
|
|
60
|
+
return Promise.resolve(this.paymentContract);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates a function call to pay the fee in the given asset.
|
|
64
|
+
* @param gasSettings - The gas settings.
|
|
65
|
+
* @returns The function call to pay the fee.
|
|
66
|
+
*/ async getFunctionCalls(gasSettings) {
|
|
67
|
+
// We assume 1:1 exchange rate between fee juice and token. But in reality you would need to convert feeLimit
|
|
68
|
+
// (maxFee) to be in token denomination.
|
|
69
|
+
const maxFee = this.setMaxFeeToOne ? Fr.ONE : gasSettings.getFeeLimit();
|
|
70
|
+
const nonce = Fr.random();
|
|
71
|
+
await this.wallet.createAuthWit({
|
|
72
|
+
caller: this.paymentContract,
|
|
73
|
+
action: {
|
|
74
|
+
name: 'transfer_to_public',
|
|
75
|
+
args: [
|
|
76
|
+
this.wallet.getAddress().toField(),
|
|
77
|
+
this.paymentContract.toField(),
|
|
78
|
+
maxFee,
|
|
79
|
+
nonce
|
|
80
|
+
],
|
|
81
|
+
selector: await FunctionSelector.fromSignature('transfer_to_public((Field),(Field),u128,Field)'),
|
|
82
|
+
type: FunctionType.PRIVATE,
|
|
83
|
+
isStatic: false,
|
|
84
|
+
to: await this.getAsset(),
|
|
85
|
+
returnTypes: []
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return [
|
|
89
|
+
{
|
|
90
|
+
name: 'fee_entrypoint_private',
|
|
91
|
+
to: this.paymentContract,
|
|
92
|
+
selector: await FunctionSelector.fromSignature('fee_entrypoint_private(u128,Field)'),
|
|
93
|
+
type: FunctionType.PRIVATE,
|
|
94
|
+
isStatic: false,
|
|
95
|
+
args: [
|
|
96
|
+
maxFee,
|
|
97
|
+
nonce
|
|
98
|
+
],
|
|
99
|
+
returnTypes: []
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import type { AccountWallet } from '../wallet/account_wallet.js';
|
|
5
|
+
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
6
|
+
/**
|
|
7
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
10
|
+
/**
|
|
11
|
+
* Address which will hold the fee payment.
|
|
12
|
+
*/
|
|
13
|
+
protected paymentContract: AztecAddress;
|
|
14
|
+
/**
|
|
15
|
+
* An auth witness provider to authorize fee payments
|
|
16
|
+
*/
|
|
17
|
+
protected wallet: AccountWallet;
|
|
18
|
+
private assetPromise;
|
|
19
|
+
constructor(
|
|
20
|
+
/**
|
|
21
|
+
* Address which will hold the fee payment.
|
|
22
|
+
*/
|
|
23
|
+
paymentContract: AztecAddress,
|
|
24
|
+
/**
|
|
25
|
+
* An auth witness provider to authorize fee payments
|
|
26
|
+
*/
|
|
27
|
+
wallet: AccountWallet);
|
|
28
|
+
/**
|
|
29
|
+
* The asset used to pay the fee.
|
|
30
|
+
* @returns The asset used to pay the fee.
|
|
31
|
+
*/
|
|
32
|
+
getAsset(): Promise<AztecAddress>;
|
|
33
|
+
getFeePayer(): Promise<AztecAddress>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a function call to pay the fee in the given asset.
|
|
36
|
+
* @param gasSettings - The gas settings.
|
|
37
|
+
* @returns The function call to pay the fee.
|
|
38
|
+
*/
|
|
39
|
+
getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=public_fee_payment_method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/public_fee_payment_method.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IAI3D;;OAEG;IACH,SAAS,CAAC,eAAe,EAAE,YAAY;IACvC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,aAAa;IAVjC,OAAO,CAAC,YAAY,CAAsC;;IAGxD;;OAEG;IACO,eAAe,EAAE,YAAY;IACvC;;OAEG;IACO,MAAM,EAAE,aAAa;IAGjC;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAuCjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC;;;;OAIG;IACG,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAiC1E"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
+
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
4
|
+
import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
5
|
+
/**
|
|
6
|
+
* Holds information about how the fee for a transaction is to be paid.
|
|
7
|
+
*/ export class PublicFeePaymentMethod {
|
|
8
|
+
paymentContract;
|
|
9
|
+
wallet;
|
|
10
|
+
assetPromise;
|
|
11
|
+
constructor(/**
|
|
12
|
+
* Address which will hold the fee payment.
|
|
13
|
+
*/ paymentContract, /**
|
|
14
|
+
* An auth witness provider to authorize fee payments
|
|
15
|
+
*/ wallet){
|
|
16
|
+
this.paymentContract = paymentContract;
|
|
17
|
+
this.wallet = wallet;
|
|
18
|
+
this.assetPromise = null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The asset used to pay the fee.
|
|
22
|
+
* @returns The asset used to pay the fee.
|
|
23
|
+
*/ getAsset() {
|
|
24
|
+
if (!this.assetPromise) {
|
|
25
|
+
// We use signer-less wallet because this function could be triggered before the associated account is deployed.
|
|
26
|
+
const signerlessWallet = new SignerlessWallet(this.wallet);
|
|
27
|
+
const interaction = new ContractFunctionInteraction(signerlessWallet, this.paymentContract, {
|
|
28
|
+
name: 'get_accepted_asset',
|
|
29
|
+
functionType: FunctionType.PRIVATE,
|
|
30
|
+
isInternal: false,
|
|
31
|
+
isStatic: false,
|
|
32
|
+
parameters: [],
|
|
33
|
+
returnTypes: [
|
|
34
|
+
{
|
|
35
|
+
kind: 'struct',
|
|
36
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
37
|
+
fields: [
|
|
38
|
+
{
|
|
39
|
+
name: 'inner',
|
|
40
|
+
type: {
|
|
41
|
+
kind: 'field'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
errorTypes: {},
|
|
48
|
+
isInitializer: false
|
|
49
|
+
}, []);
|
|
50
|
+
this.assetPromise = interaction.simulate();
|
|
51
|
+
}
|
|
52
|
+
return this.assetPromise;
|
|
53
|
+
}
|
|
54
|
+
getFeePayer() {
|
|
55
|
+
return Promise.resolve(this.paymentContract);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a function call to pay the fee in the given asset.
|
|
59
|
+
* @param gasSettings - The gas settings.
|
|
60
|
+
* @returns The function call to pay the fee.
|
|
61
|
+
*/ async getFunctionCalls(gasSettings) {
|
|
62
|
+
const nonce = Fr.random();
|
|
63
|
+
const maxFee = gasSettings.getFeeLimit();
|
|
64
|
+
const setPublicAuthWitInteraction = await this.wallet.setPublicAuthWit({
|
|
65
|
+
caller: this.paymentContract,
|
|
66
|
+
action: {
|
|
67
|
+
name: 'transfer_in_public',
|
|
68
|
+
args: [
|
|
69
|
+
this.wallet.getAddress().toField(),
|
|
70
|
+
this.paymentContract.toField(),
|
|
71
|
+
maxFee,
|
|
72
|
+
nonce
|
|
73
|
+
],
|
|
74
|
+
selector: await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),u128,Field)'),
|
|
75
|
+
type: FunctionType.PUBLIC,
|
|
76
|
+
isStatic: false,
|
|
77
|
+
to: await this.getAsset(),
|
|
78
|
+
returnTypes: []
|
|
79
|
+
}
|
|
80
|
+
}, true);
|
|
81
|
+
return [
|
|
82
|
+
await setPublicAuthWitInteraction.request(),
|
|
83
|
+
{
|
|
84
|
+
name: 'fee_entrypoint_public',
|
|
85
|
+
to: this.paymentContract,
|
|
86
|
+
selector: await FunctionSelector.fromSignature('fee_entrypoint_public(u128,Field)'),
|
|
87
|
+
type: FunctionType.PRIVATE,
|
|
88
|
+
isStatic: false,
|
|
89
|
+
args: [
|
|
90
|
+
maxFee,
|
|
91
|
+
nonce
|
|
92
|
+
],
|
|
93
|
+
returnTypes: []
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
}
|
package/dest/index.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
export { ContractDeployer } from './deployment/index.js';
|
|
23
|
+
export { NoteSelector } from '@aztec/stdlib/abi';
|
|
24
|
+
export { createCompatibleClient, createPXEClient } from './rpc_clients/index.js';
|
|
25
|
+
export { type DeployAccountOptions } from './account_manager/index.js';
|
|
26
|
+
export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet } from './wallet/index.js';
|
|
27
|
+
export { EthAddress } from '@aztec/foundation/eth-address';
|
|
28
|
+
export { Fq, Fr, Point, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
29
|
+
export { SiblingPath } from '@aztec/foundation/trees';
|
|
30
|
+
export { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
31
|
+
export { type PartialAddress, type ContractClassWithId, type ContractInstanceWithAddress, getContractClassFromArtifact, getContractInstanceFromDeployParams, type NodeInfo, } from '@aztec/stdlib/contract';
|
|
32
|
+
export { MerkleTreeId, merkleTreeIds } from '@aztec/stdlib/trees';
|
|
33
|
+
export { type PublicKey, PublicKeys } from '@aztec/stdlib/keys';
|
|
34
|
+
export { computeSecretHash } from '@aztec/stdlib/hash';
|
|
35
|
+
export { computeAppNullifierSecretKey, deriveKeys, deriveMasterIncomingViewingSecretKey, deriveMasterNullifierSecretKey, } from '@aztec/stdlib/keys';
|
|
36
|
+
export { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
37
|
+
export { getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
38
|
+
export { FunctionCall } from '@aztec/stdlib/abi';
|
|
39
|
+
export { Tx, TxExecutionRequest, TxHash, TxReceipt, TxStatus, Capsule, HashedValues, GlobalVariables, } from '@aztec/stdlib/tx';
|
|
40
|
+
export { Body, L2Block } from '@aztec/stdlib/block';
|
|
41
|
+
export { L1NotePayload, LogId, type LogFilter, EncryptedLogPayload } from '@aztec/stdlib/logs';
|
|
42
|
+
export { L1EventPayload, EventMetadata } from '@aztec/stdlib/event';
|
|
43
|
+
export { L1ToL2Message, L2Actor, L1Actor } from '@aztec/stdlib/messaging';
|
|
44
|
+
export { UniqueNote, ExtendedNote, Comparator, Note } from '@aztec/stdlib/note';
|
|
45
|
+
export { type PXE, EventType } from '@aztec/stdlib/interfaces/client';
|
|
46
|
+
export { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
47
|
+
export { decodeFromAbi, encodeArguments, type AbiType } from '@aztec/stdlib/abi';
|
|
48
|
+
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
49
|
+
export { sha256, Grumpkin, Schnorr } from '@aztec/foundation/crypto';
|
|
50
|
+
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
51
|
+
export { retry, retryUntil } from '@aztec/foundation/retry';
|
|
52
|
+
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
53
|
+
export { sleep } from '@aztec/foundation/sleep';
|
|
54
|
+
export { elapsed } from '@aztec/foundation/timer';
|
|
55
|
+
export { type FieldsOf } from '@aztec/foundation/types';
|
|
56
|
+
export { fileURLToPath } from '@aztec/foundation/url';
|
|
57
|
+
export * from './api/abi.js';
|
|
58
|
+
export * from './api/account.js';
|
|
59
|
+
export * from './api/addresses.js';
|
|
60
|
+
export * from './api/cheat_codes.js';
|
|
61
|
+
export * from './api/ethereum/index.js';
|
|
62
|
+
export * from './api/fee.js';
|
|
63
|
+
export * from './api/log.js';
|
|
64
|
+
export * from './contract/index.js';
|
|
65
|
+
export * from './utils/index.js';
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dest/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
*/ export { ContractDeployer } from './deployment/index.js';
|
|
22
|
+
export { NoteSelector } from '@aztec/stdlib/abi';
|
|
23
|
+
export { createCompatibleClient, createPXEClient } from './rpc_clients/index.js';
|
|
24
|
+
export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet } from './wallet/index.js';
|
|
25
|
+
export { EthAddress } from '@aztec/foundation/eth-address';
|
|
26
|
+
export { Fq, Fr, Point, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
27
|
+
export { SiblingPath } from '@aztec/foundation/trees';
|
|
28
|
+
export { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
29
|
+
export { getContractClassFromArtifact, getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
|
|
30
|
+
export { MerkleTreeId, merkleTreeIds } from '@aztec/stdlib/trees';
|
|
31
|
+
export { PublicKeys } from '@aztec/stdlib/keys';
|
|
32
|
+
export { computeSecretHash } from '@aztec/stdlib/hash';
|
|
33
|
+
export { computeAppNullifierSecretKey, deriveKeys, deriveMasterIncomingViewingSecretKey, deriveMasterNullifierSecretKey } from '@aztec/stdlib/keys';
|
|
34
|
+
export { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
35
|
+
export { getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
36
|
+
export { FunctionCall } from '@aztec/stdlib/abi';
|
|
37
|
+
export { Tx, TxExecutionRequest, TxHash, TxReceipt, TxStatus, Capsule, HashedValues, GlobalVariables } from '@aztec/stdlib/tx';
|
|
38
|
+
export { Body, L2Block } from '@aztec/stdlib/block';
|
|
39
|
+
export { L1NotePayload, LogId, EncryptedLogPayload } from '@aztec/stdlib/logs';
|
|
40
|
+
export { L1EventPayload, EventMetadata } from '@aztec/stdlib/event';
|
|
41
|
+
export { L1ToL2Message, L2Actor, L1Actor } from '@aztec/stdlib/messaging';
|
|
42
|
+
export { UniqueNote, ExtendedNote, Comparator, Note } from '@aztec/stdlib/note';
|
|
43
|
+
export { EventType } from '@aztec/stdlib/interfaces/client';
|
|
44
|
+
export { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
45
|
+
// TODO: These kinds of things have no place on our public api.
|
|
46
|
+
// External devs will almost certainly have their own methods of doing these things.
|
|
47
|
+
// If we want to use them in our own "aztec.js consuming code", import them from foundation as needed.
|
|
48
|
+
export { decodeFromAbi, encodeArguments } from '@aztec/stdlib/abi';
|
|
49
|
+
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
50
|
+
export { sha256, Grumpkin, Schnorr } from '@aztec/foundation/crypto';
|
|
51
|
+
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
52
|
+
export { retry, retryUntil } from '@aztec/foundation/retry';
|
|
53
|
+
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
54
|
+
export { sleep } from '@aztec/foundation/sleep';
|
|
55
|
+
export { elapsed } from '@aztec/foundation/timer';
|
|
56
|
+
export { fileURLToPath } from '@aztec/foundation/url';
|
|
57
|
+
// Start of section that exports public api via granular api.
|
|
58
|
+
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
|
|
59
|
+
// This entire index file will be deprecated at some point after we're satisfied.
|
|
60
|
+
export * from './api/abi.js';
|
|
61
|
+
export * from './api/account.js';
|
|
62
|
+
export * from './api/addresses.js';
|
|
63
|
+
export * from './api/cheat_codes.js';
|
|
64
|
+
export * from './api/ethereum/index.js';
|
|
65
|
+
export * from './api/fee.js';
|
|
66
|
+
export * from './api/log.js';
|
|
67
|
+
// Granular export, even if not in the api folder
|
|
68
|
+
export * from './contract/index.js';
|
|
69
|
+
export * from './utils/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpc_clients/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a PXE client with a given set of retries on non-server errors.
|
|
6
|
+
* Checks that PXE matches the expected version, and warns if not.
|
|
7
|
+
* @param rpcUrl - URL of the RPC server wrapping the PXE.
|
|
8
|
+
* @param _logger - Debug logger to warn version incompatibilities.
|
|
9
|
+
* @returns A PXE client.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createCompatibleClient(rpcUrl: string, logger?: Logger, versions?: Partial<ComponentsVersions>): Promise<PXE>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rpc_clients/node/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA+CnE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAA2C,EACnD,QAAQ,GAAE,OAAO,CAAC,kBAAkB,CAAM,GACzC,OAAO,CAAC,GAAG,CAAC,CAcd"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { NoRetryError, makeBackoff, retry } from '@aztec/foundation/retry';
|
|
4
|
+
import { Axios } from 'axios';
|
|
5
|
+
import { inspect } from 'util';
|
|
6
|
+
import { createPXEClient } from '../pxe_client.js';
|
|
7
|
+
/**
|
|
8
|
+
* A fetch implementation using axios.
|
|
9
|
+
* @param host - The URL of the host.
|
|
10
|
+
* @param rpcMethod - The RPC method to call.
|
|
11
|
+
* @param body - The body of the request.
|
|
12
|
+
* @param useApiEndpoints - Whether to use the API endpoints or inject the method in the body.
|
|
13
|
+
* @returns The response data.
|
|
14
|
+
*/ async function axiosFetch(host, rpcMethod, body, useApiEndpoints) {
|
|
15
|
+
const request = new Axios({
|
|
16
|
+
headers: {
|
|
17
|
+
'content-type': 'application/json'
|
|
18
|
+
},
|
|
19
|
+
transformRequest: [
|
|
20
|
+
(data)=>jsonStringify(data)
|
|
21
|
+
],
|
|
22
|
+
transformResponse: [
|
|
23
|
+
(data)=>JSON.parse(data)
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
const [url, content] = useApiEndpoints ? [
|
|
27
|
+
`${host}/${rpcMethod}`,
|
|
28
|
+
body
|
|
29
|
+
] : [
|
|
30
|
+
host,
|
|
31
|
+
{
|
|
32
|
+
...body,
|
|
33
|
+
method: rpcMethod
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
const resp = await request.post(url, content).catch((error)=>{
|
|
37
|
+
if (error.response) {
|
|
38
|
+
return error.response;
|
|
39
|
+
}
|
|
40
|
+
const errorMessage = `Error fetching from host ${host} with method ${rpcMethod}: ${inspect(error)}`;
|
|
41
|
+
throw new Error(errorMessage);
|
|
42
|
+
});
|
|
43
|
+
const isOK = resp.status >= 200 && resp.status < 300;
|
|
44
|
+
if (isOK) {
|
|
45
|
+
const headers = {
|
|
46
|
+
get: (header)=>typeof resp.headers.get === 'function' ? resp.headers.get(header)?.toString() : undefined
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
response: resp.data,
|
|
50
|
+
headers
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
const errorMessage = `Error ${resp.status} from json-rpc server ${host} on ${rpcMethod}: ${resp.data.error.message}`;
|
|
54
|
+
if (resp.status >= 400 && resp.status < 500) {
|
|
55
|
+
throw new NoRetryError(errorMessage);
|
|
56
|
+
} else {
|
|
57
|
+
throw new Error(errorMessage);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates a PXE client with a given set of retries on non-server errors.
|
|
63
|
+
* Checks that PXE matches the expected version, and warns if not.
|
|
64
|
+
* @param rpcUrl - URL of the RPC server wrapping the PXE.
|
|
65
|
+
* @param _logger - Debug logger to warn version incompatibilities.
|
|
66
|
+
* @returns A PXE client.
|
|
67
|
+
*/ export function createCompatibleClient(rpcUrl, logger = createLogger('aztecjs:pxe_client'), versions = {}) {
|
|
68
|
+
// Use axios due to timeout issues with fetch when proving TXs.
|
|
69
|
+
const fetch = async (host, rpcMethod, body, useApiEndpoints)=>{
|
|
70
|
+
return await retry(()=>axiosFetch(host, rpcMethod, body, useApiEndpoints), `JsonRpcClient request ${rpcMethod} to ${host}`, makeBackoff([
|
|
71
|
+
1,
|
|
72
|
+
2,
|
|
73
|
+
3
|
|
74
|
+
]), logger, false);
|
|
75
|
+
};
|
|
76
|
+
const pxe = createPXEClient(rpcUrl, versions, fetch);
|
|
77
|
+
return Promise.resolve(pxe);
|
|
78
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PXE } from '@aztec/stdlib/interfaces/client';
|
|
2
|
+
import { type ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a JSON-RPC client to remotely talk to PXE.
|
|
5
|
+
* @param url - The URL of the PXE.
|
|
6
|
+
* @param fetch - The fetch implementation to use.
|
|
7
|
+
* @returns A JSON-RPC client of PXE.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createPXEClient(url: string, versions?: Partial<ComponentsVersions>, fetch?: typeof import("@aztec/foundation/json-rpc/client").defaultFetch): PXE;
|
|
10
|
+
//# sourceMappingURL=pxe_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pxe_client.d.ts","sourceRoot":"","sources":["../../src/rpc_clients/pxe_client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAa,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,kBAAkB,EAAgC,MAAM,0BAA0B,CAAC;AAEjG;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,OAAO,CAAC,kBAAkB,CAAM,EAC1C,KAAK,kEAA8B,GAClC,GAAG,CASL"}
|