@aztec-labs/aztec.js 6.0.0-nightly.20260829
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/account.d.ts +44 -0
- package/dest/account/account.d.ts.map +1 -0
- package/dest/account/account.js +31 -0
- package/dest/account/account_contract.d.ts +49 -0
- package/dest/account/account_contract.d.ts.map +1 -0
- package/dest/account/account_contract.js +20 -0
- package/dest/account/index.d.ts +11 -0
- package/dest/account/index.d.ts.map +1 -0
- package/dest/account/index.js +6 -0
- package/dest/api/abi.d.ts +4 -0
- package/dest/api/abi.d.ts.map +1 -0
- package/dest/api/abi.js +1 -0
- package/dest/api/account.d.ts +5 -0
- package/dest/api/account.d.ts.map +1 -0
- package/dest/api/account.js +3 -0
- package/dest/api/addresses.d.ts +4 -0
- package/dest/api/addresses.d.ts.map +1 -0
- package/dest/api/addresses.js +3 -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/api/contract.d.ts +48 -0
- package/dest/api/contract.d.ts.map +1 -0
- package/dest/api/contract.js +46 -0
- 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 -0
- package/dest/api/deployment.d.ts.map +1 -0
- package/dest/api/deployment.js +3 -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.d.ts +2 -0
- package/dest/api/ethereum.d.ts.map +1 -0
- package/dest/api/ethereum.js +1 -0
- package/dest/api/event_cursor.d.ts +44 -0
- package/dest/api/event_cursor.d.ts.map +1 -0
- package/dest/api/event_cursor.js +42 -0
- package/dest/api/events.d.ts +36 -0
- package/dest/api/events.d.ts.map +1 -0
- package/dest/api/events.js +59 -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/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/fields.d.ts +4 -0
- package/dest/api/fields.d.ts.map +1 -0
- package/dest/api/fields.js +3 -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 +3 -0
- package/dest/api/log.d.ts.map +1 -0
- package/dest/api/log.js +2 -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 +25 -0
- package/dest/api/node.d.ts.map +1 -0
- package/dest/api/node.js +22 -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 +6 -0
- package/dest/api/protocol.d.ts.map +1 -0
- package/dest/api/protocol.js +5 -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 +3 -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 +8 -0
- package/dest/api/wallet.d.ts.map +1 -0
- package/dest/api/wallet.js +7 -0
- package/dest/authorization/call_authorization_request.d.ts +46 -0
- package/dest/authorization/call_authorization_request.d.ts.map +1 -0
- package/dest/authorization/call_authorization_request.js +72 -0
- package/dest/contract/base_contract_interaction.d.ts +32 -0
- package/dest/contract/base_contract_interaction.d.ts.map +1 -0
- package/dest/contract/base_contract_interaction.js +24 -0
- package/dest/contract/batch_call.d.ts +27 -0
- package/dest/contract/batch_call.d.ts.map +1 -0
- package/dest/contract/batch_call.js +152 -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 +33 -0
- package/dest/contract/contract.d.ts.map +1 -0
- package/dest/contract/contract.js +36 -0
- package/dest/contract/contract_base.d.ts +51 -0
- package/dest/contract/contract_base.d.ts.map +1 -0
- package/dest/contract/contract_base.js +38 -0
- package/dest/contract/contract_function_interaction.d.ts +67 -0
- package/dest/contract/contract_function_interaction.d.ts.map +1 -0
- package/dest/contract/contract_function_interaction.js +218 -0
- package/dest/contract/deploy_method.d.ts +433 -0
- package/dest/contract/deploy_method.d.ts.map +1 -0
- package/dest/contract/deploy_method.js +471 -0
- package/dest/contract/fastforward_contract_update.d.ts +25 -0
- package/dest/contract/fastforward_contract_update.d.ts.map +1 -0
- package/dest/contract/fastforward_contract_update.js +57 -0
- package/dest/contract/interaction_options.d.ts +213 -0
- package/dest/contract/interaction_options.d.ts.map +1 -0
- package/dest/contract/interaction_options.js +87 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +18 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +137 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +25 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +366 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +24 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +383 -0
- package/dest/contract/wait_for_proven.d.ts +18 -0
- package/dest/contract/wait_for_proven.d.ts.map +1 -0
- package/dest/contract/wait_for_proven.js +17 -0
- package/dest/contract/wait_opts.d.ts +21 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/deployment/contract_deployer.d.ts +28 -0
- package/dest/deployment/contract_deployer.d.ts.map +1 -0
- package/dest/deployment/contract_deployer.js +35 -0
- 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/ethereum/portal_manager.d.ts +146 -0
- package/dest/ethereum/portal_manager.d.ts.map +1 -0
- package/dest/ethereum/portal_manager.js +415 -0
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +23 -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 +46 -0
- package/dest/fee/fee_payment_method.d.ts +26 -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 +69 -0
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/private_fee_payment_method.js +122 -0
- package/dest/fee/public_fee_payment_method.d.ts +59 -0
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/public_fee_payment_method.js +116 -0
- 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 +33 -0
- package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
- package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
- package/dest/scripts/generate_protocol_contract_types.js +128 -0
- package/dest/test/fixtures.d.ts +13 -0
- package/dest/test/fixtures.d.ts.map +1 -0
- package/dest/test/fixtures.js +185 -0
- package/dest/utils/abi_types.d.ts +32 -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 +119 -0
- package/dest/utils/authwit.d.ts.map +1 -0
- package/dest/utils/authwit.js +266 -0
- package/dest/utils/cross_chain.d.ts +28 -0
- package/dest/utils/cross_chain.d.ts.map +1 -0
- package/dest/utils/cross_chain.js +26 -0
- package/dest/utils/fee_juice.d.ts +8 -0
- package/dest/utils/fee_juice.d.ts.map +1 -0
- package/dest/utils/fee_juice.js +10 -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/node.d.ts +24 -0
- package/dest/utils/node.d.ts.map +1 -0
- package/dest/utils/node.js +80 -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 +8 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +33 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.js +63 -0
- package/dest/wallet/account_manager.d.ts +73 -0
- package/dest/wallet/account_manager.d.ts.map +1 -0
- package/dest/wallet/account_manager.js +102 -0
- package/dest/wallet/capabilities.d.ts +456 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +97 -0
- package/dest/wallet/deploy_account_method.d.ts.map +1 -0
- package/dest/wallet/deploy_account_method.js +127 -0
- package/dest/wallet/index.d.ts +5 -0
- package/dest/wallet/index.d.ts.map +1 -0
- package/dest/wallet/index.js +4 -0
- package/dest/wallet/tx_simulation_result_with_app_offset.d.ts +40 -0
- package/dest/wallet/tx_simulation_result_with_app_offset.d.ts.map +1 -0
- package/dest/wallet/tx_simulation_result_with_app_offset.js +65 -0
- package/dest/wallet/wallet.d.ts +1451 -0
- package/dest/wallet/wallet.d.ts.map +1 -0
- package/dest/wallet/wallet.js +430 -0
- package/package.json +138 -0
- package/src/account/account.ts +72 -0
- package/src/account/account_contract.ts +80 -0
- package/src/account/index.ts +12 -0
- package/src/api/README.md +7 -0
- package/src/api/abi.ts +42 -0
- package/src/api/account.ts +12 -0
- package/src/api/addresses.ts +3 -0
- package/src/api/authorization.ts +15 -0
- package/src/api/block.ts +2 -0
- package/src/api/contract.ts +86 -0
- package/src/api/crypto.ts +1 -0
- package/src/api/deployment.ts +3 -0
- package/src/api/eth_address.ts +1 -0
- package/src/api/ethereum.ts +10 -0
- package/src/api/event_cursor.ts +60 -0
- package/src/api/events.ts +79 -0
- package/src/api/fee.ts +5 -0
- package/src/api/fee_testing.ts +1 -0
- package/src/api/fields.ts +3 -0
- package/src/api/keys.ts +8 -0
- package/src/api/log.ts +2 -0
- package/src/api/messaging.ts +2 -0
- package/src/api/node.ts +30 -0
- package/src/api/note.ts +1 -0
- package/src/api/protocol.ts +6 -0
- package/src/api/trees.ts +2 -0
- package/src/api/tx.ts +20 -0
- package/src/api/utils.ts +14 -0
- package/src/api/wallet.ts +83 -0
- package/src/authorization/call_authorization_request.ts +93 -0
- package/src/contract/base_contract_interaction.ts +62 -0
- package/src/contract/batch_call.ts +188 -0
- package/src/contract/checker.ts +122 -0
- package/src/contract/contract.ts +52 -0
- package/src/contract/contract_base.ts +73 -0
- package/src/contract/contract_function_interaction.ts +297 -0
- package/src/contract/deploy_method.ts +877 -0
- package/src/contract/fastforward_contract_update.ts +71 -0
- package/src/contract/interaction_options.ts +301 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +104 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +241 -0
- package/src/contract/protocol_contracts/fee-juice.ts +257 -0
- package/src/contract/wait_for_proven.ts +43 -0
- package/src/contract/wait_opts.ts +26 -0
- package/src/deployment/contract_deployer.ts +40 -0
- package/src/deployment/publish_class.ts +34 -0
- package/src/deployment/publish_instance.ts +24 -0
- package/src/ethereum/portal_manager.ts +539 -0
- package/src/fee/fee_juice_payment_method_with_claim.ts +63 -0
- package/src/fee/fee_payment_method.ts +26 -0
- package/src/fee/private_fee_payment_method.ts +145 -0
- package/src/fee/public_fee_payment_method.ts +145 -0
- package/src/fee/sponsored_fee_payment.ts +45 -0
- package/src/scripts/generate_protocol_contract_types.ts +160 -0
- package/src/test/fixtures.ts +126 -0
- package/src/utils/abi_types.ts +32 -0
- package/src/utils/authwit.ts +327 -0
- package/src/utils/cross_chain.ts +55 -0
- package/src/utils/fee_juice.ts +14 -0
- package/src/utils/field_compressed_string.ts +27 -0
- package/src/utils/node.ts +110 -0
- package/src/utils/pub_key.ts +12 -0
- package/src/wallet/account_entrypoint_meta_payment_method.ts +76 -0
- package/src/wallet/account_manager.ts +164 -0
- package/src/wallet/capabilities.ts +505 -0
- package/src/wallet/deploy_account_method.ts +234 -0
- package/src/wallet/index.ts +4 -0
- package/src/wallet/tx_simulation_result_with_app_offset.ts +100 -0
- package/src/wallet/wallet.ts +668 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
|
|
2
|
+
import { type L1TxUtils } from '@aztec-labs/ethereum/l1-tx-utils';
|
|
3
|
+
import type { ExtendedViemWalletClient, ViemContract } from '@aztec-labs/ethereum/types';
|
|
4
|
+
import type { EpochNumber } from '@aztec-labs/foundation/branded-types';
|
|
5
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
6
|
+
import { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
7
|
+
import type { Logger } from '@aztec-labs/foundation/log';
|
|
8
|
+
import type { SiblingPath } from '@aztec-labs/foundation/trees';
|
|
9
|
+
import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
10
|
+
import type { AztecNode } from '@aztec-labs/stdlib/interfaces/client';
|
|
11
|
+
import { type Hex } from 'viem';
|
|
12
|
+
/** L1 to L2 message info to claim it on L2. */
|
|
13
|
+
export type L2Claim = {
|
|
14
|
+
/** Secret for claiming. */
|
|
15
|
+
claimSecret: Fr;
|
|
16
|
+
/** Hash of the secret for claiming. */
|
|
17
|
+
claimSecretHash: Fr;
|
|
18
|
+
/** Hash of the message. */
|
|
19
|
+
messageHash: Hex;
|
|
20
|
+
/** Leaf index in the L1 to L2 message tree. */
|
|
21
|
+
messageLeafIndex: bigint;
|
|
22
|
+
};
|
|
23
|
+
/** L1 to L2 message info that corresponds to an amount to claim. */
|
|
24
|
+
export type L2AmountClaim = L2Claim & {
|
|
25
|
+
claimAmount: bigint;
|
|
26
|
+
};
|
|
27
|
+
/** L1 to L2 message info that corresponds to an amount to claim with associated recipient. */
|
|
28
|
+
export type L2AmountClaimWithRecipient = L2AmountClaim & {
|
|
29
|
+
/** Address that will receive the newly minted notes. */ recipient: AztecAddress;
|
|
30
|
+
};
|
|
31
|
+
/** Generates a pair secret and secret hash */
|
|
32
|
+
export declare function generateClaimSecret(logger?: Logger): Promise<[Fr, Fr]>;
|
|
33
|
+
/** Helper for managing an ERC20 on L1. */
|
|
34
|
+
export declare class L1TokenManager {
|
|
35
|
+
/** Address of the ERC20 contract. */
|
|
36
|
+
readonly tokenAddress: EthAddress;
|
|
37
|
+
/** Address of the handler/faucet contract. */
|
|
38
|
+
readonly handlerAddress: EthAddress | undefined;
|
|
39
|
+
private readonly extendedClient;
|
|
40
|
+
private logger;
|
|
41
|
+
private contract;
|
|
42
|
+
private handler;
|
|
43
|
+
private readonly l1TxUtils;
|
|
44
|
+
constructor(
|
|
45
|
+
/** Address of the ERC20 contract. */
|
|
46
|
+
tokenAddress: EthAddress,
|
|
47
|
+
/** Address of the handler/faucet contract. */
|
|
48
|
+
handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
49
|
+
/** Returns the amount of tokens available to mint via the handler.
|
|
50
|
+
* @throws if the handler is not provided.
|
|
51
|
+
*/
|
|
52
|
+
getMintAmount(): Promise<bigint>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the balance of the given address.
|
|
55
|
+
* @param address - Address to get the balance of.
|
|
56
|
+
*/
|
|
57
|
+
getL1TokenBalance(address: Hex): Promise<bigint>;
|
|
58
|
+
/**
|
|
59
|
+
* Mints a fixed amount of tokens for the given address. Returns once the tx has been mined.
|
|
60
|
+
* @param address - Address to mint the tokens for.
|
|
61
|
+
* @param addressName - Optional name of the address for logging.
|
|
62
|
+
*/
|
|
63
|
+
mint(address: Hex, addressName?: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Approves tokens for the given address. Returns once the tx has been mined.
|
|
66
|
+
* @param amount - Amount to approve.
|
|
67
|
+
* @param address - Address to approve the tokens for.
|
|
68
|
+
* @param addressName - Optional name of the address for logging.
|
|
69
|
+
*/
|
|
70
|
+
approve(amount: bigint, address: Hex, addressName?: string): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
/** Helper for interacting with the FeeJuicePortal on L1. */
|
|
73
|
+
export declare class L1FeeJuicePortalManager {
|
|
74
|
+
private readonly extendedClient;
|
|
75
|
+
private readonly logger;
|
|
76
|
+
private readonly tokenManager;
|
|
77
|
+
private readonly contract;
|
|
78
|
+
private readonly l1TxUtils;
|
|
79
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
80
|
+
/** Returns the associated token manager for the L1 ERC20. */
|
|
81
|
+
getTokenManager(): L1TokenManager;
|
|
82
|
+
/**
|
|
83
|
+
* Bridges fee juice from L1 to L2 publicly. Handles L1 ERC20 approvals. Returns once the tx has been mined.
|
|
84
|
+
* @param to - Address to send the tokens to on L2.
|
|
85
|
+
* @param amount - Amount of tokens to send.
|
|
86
|
+
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
87
|
+
*/
|
|
88
|
+
bridgeTokensPublic(to: AztecAddress, amount: bigint | undefined, mint?: boolean): Promise<L2AmountClaim>;
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new instance
|
|
91
|
+
* @param node - Aztec node client used for retrieving the L1 contract addresses.
|
|
92
|
+
* @param extendedClient - Wallet client, extended with public actions.
|
|
93
|
+
* @param logger - Logger.
|
|
94
|
+
*/
|
|
95
|
+
static new(node: AztecNode, extendedClient: ExtendedViemWalletClient, logger: Logger): Promise<L1FeeJuicePortalManager>;
|
|
96
|
+
}
|
|
97
|
+
/** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */
|
|
98
|
+
export declare class L1ToL2TokenPortalManager {
|
|
99
|
+
protected extendedClient: ExtendedViemWalletClient;
|
|
100
|
+
protected logger: Logger;
|
|
101
|
+
protected readonly portal: ViemContract<typeof TokenPortalAbi>;
|
|
102
|
+
protected readonly tokenManager: L1TokenManager;
|
|
103
|
+
protected readonly l1TxUtils: L1TxUtils;
|
|
104
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
105
|
+
/** Returns the token manager for the underlying L1 token. */
|
|
106
|
+
getTokenManager(): L1TokenManager;
|
|
107
|
+
/**
|
|
108
|
+
* Bridges tokens from L1 to L2. Handles token approvals. Returns once the tx has been mined.
|
|
109
|
+
* @param to - Address to send the tokens to on L2.
|
|
110
|
+
* @param amount - Amount of tokens to send.
|
|
111
|
+
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
112
|
+
*/
|
|
113
|
+
bridgeTokensPublic(to: AztecAddress, amount: bigint, mint?: boolean): Promise<L2AmountClaim>;
|
|
114
|
+
/**
|
|
115
|
+
* Bridges tokens from L1 to L2 privately. Handles token approvals. Returns once the tx has been mined.
|
|
116
|
+
* @param to - Address to send the tokens to on L2.
|
|
117
|
+
* @param amount - Amount of tokens to send.
|
|
118
|
+
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
119
|
+
*/
|
|
120
|
+
bridgeTokensPrivate(to: AztecAddress, amount: bigint, mint?: boolean): Promise<L2AmountClaimWithRecipient>;
|
|
121
|
+
private bridgeSetup;
|
|
122
|
+
}
|
|
123
|
+
/** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */
|
|
124
|
+
export declare class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
125
|
+
private readonly outbox;
|
|
126
|
+
constructor(portalAddress: EthAddress, tokenAddress: EthAddress, handlerAddress: EthAddress | undefined, outboxAddress: EthAddress, extendedClient: ExtendedViemWalletClient, logger: Logger);
|
|
127
|
+
/**
|
|
128
|
+
* Withdraws funds from the portal by consuming an L2 to L1 message. Returns once the tx is mined on L1.
|
|
129
|
+
* @param amount - Amount to withdraw.
|
|
130
|
+
* @param recipient - Who will receive the funds.
|
|
131
|
+
* @param epochNumber - Epoch number of the message.
|
|
132
|
+
* @param numCheckpointsInEpoch - The partial-proof depth (1-indexed) the witness was built against.
|
|
133
|
+
* @param messageIndex - Index of the message.
|
|
134
|
+
* @param siblingPath - Sibling path of the message.
|
|
135
|
+
*/
|
|
136
|
+
withdrawFunds(amount: bigint, recipient: EthAddress, epochNumber: EpochNumber, numCheckpointsInEpoch: number, messageIndex: bigint, siblingPath: SiblingPath<number>): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Computes the L2 to L1 message leaf for the given parameters.
|
|
139
|
+
* @param amount - Amount to bridge.
|
|
140
|
+
* @param recipient - Recipient on L1.
|
|
141
|
+
* @param l2Bridge - Address of the L2 bridge.
|
|
142
|
+
* @param callerOnL1 - Caller address on L1.
|
|
143
|
+
*/
|
|
144
|
+
getL2ToL1MessageLeaf(amount: bigint, recipient: EthAddress, l2Bridge: AztecAddress, callerOnL1?: EthAddress): Promise<Fr>;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9ydGFsX21hbmFnZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ldGhlcmV1bS9wb3J0YWxfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxPQUFPLEVBQUUsY0FBYy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
3
|
+
import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
|
|
4
|
+
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
5
|
+
import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
|
|
6
|
+
import { createL1TxUtils, getL1TxUtilsConfigEnvVars } from '@aztec-labs/ethereum/l1-tx-utils';
|
|
7
|
+
import { extractEvent } from '@aztec-labs/ethereum/utils';
|
|
8
|
+
import { sha256ToField } from '@aztec-labs/foundation/crypto/sha256';
|
|
9
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
10
|
+
import { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
11
|
+
import { computeL2ToL1MessageHash, computeSecretHash } from '@aztec-labs/stdlib/hash';
|
|
12
|
+
import { getL2ToL1MessageLeafId } from '@aztec-labs/stdlib/messaging';
|
|
13
|
+
import { encodeFunctionData, getContract, toFunctionSelector } from 'viem';
|
|
14
|
+
/** Stringifies an eth address for logging. */ function stringifyEthAddress(address, name) {
|
|
15
|
+
return name ? `${name} (${address.toString()})` : address.toString();
|
|
16
|
+
}
|
|
17
|
+
/** Generates a pair secret and secret hash */ export async function generateClaimSecret(logger) {
|
|
18
|
+
const secret = Fr.random();
|
|
19
|
+
const secretHash = await computeSecretHash(secret);
|
|
20
|
+
logger?.verbose(`Generated claim secret=${secret.toString()} hash=${secretHash.toString()}`);
|
|
21
|
+
return [
|
|
22
|
+
secret,
|
|
23
|
+
secretHash
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
// `Inbox.sendL2Message` (reached by every `depositToAztec*` call) inserts into a height-10
|
|
27
|
+
// (`L1_TO_L2_MSG_SUBTREE_HEIGHT`) incremental frontier tree. The per-insert cost swings by up to ~10 hash levels
|
|
28
|
+
// (which translates to ~40k gas) depending on where the global message index lands when the tx is mined: inserts that
|
|
29
|
+
// complete a subtree cascade through cold SLOADs + an SSTORE vs cheap inserts that touch one slot. A point-in-time
|
|
30
|
+
// `eth_estimateGas` taken at a cheap index therefore under-sizes a deposit that mines at a subtree boundary. That ~40k
|
|
31
|
+
// swing exceeds the default 20% buffer on a ~100k deposit. That is why we raise the gas-limit buffer to 2x here.
|
|
32
|
+
// Note: a larger operator override via L1_GAS_LIMIT_BUFFER_PERCENTAGE still wins.
|
|
33
|
+
const INBOX_DEPOSIT_GAS_LIMIT_BUFFER_PERCENTAGE = 100;
|
|
34
|
+
/** Per-call gas config for `depositToAztec*`: the Inbox-deposit buffer floor, or a larger operator override. */ function inboxDepositGasConfig() {
|
|
35
|
+
const configuredBuffer = getL1TxUtilsConfigEnvVars().gasLimitBufferPercentage ?? 0;
|
|
36
|
+
return {
|
|
37
|
+
gasLimitBufferPercentage: Math.max(configuredBuffer, INBOX_DEPOSIT_GAS_LIMIT_BUFFER_PERCENTAGE)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Helper for managing an ERC20 on L1. */ export class L1TokenManager {
|
|
41
|
+
tokenAddress;
|
|
42
|
+
handlerAddress;
|
|
43
|
+
extendedClient;
|
|
44
|
+
logger;
|
|
45
|
+
contract;
|
|
46
|
+
handler;
|
|
47
|
+
l1TxUtils;
|
|
48
|
+
constructor(/** Address of the ERC20 contract. */ tokenAddress, /** Address of the handler/faucet contract. */ handlerAddress, extendedClient, logger){
|
|
49
|
+
this.tokenAddress = tokenAddress;
|
|
50
|
+
this.handlerAddress = handlerAddress;
|
|
51
|
+
this.extendedClient = extendedClient;
|
|
52
|
+
this.logger = logger;
|
|
53
|
+
this.contract = getContract({
|
|
54
|
+
address: this.tokenAddress.toString(),
|
|
55
|
+
abi: TestERC20Abi,
|
|
56
|
+
client: this.extendedClient
|
|
57
|
+
});
|
|
58
|
+
if (this.handlerAddress) {
|
|
59
|
+
this.handler = getContract({
|
|
60
|
+
address: this.handlerAddress.toString(),
|
|
61
|
+
abi: FeeAssetHandlerAbi,
|
|
62
|
+
client: this.extendedClient
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
this.l1TxUtils = createL1TxUtils(this.extendedClient, {
|
|
66
|
+
logger
|
|
67
|
+
}, getL1TxUtilsConfigEnvVars());
|
|
68
|
+
}
|
|
69
|
+
/** Returns the amount of tokens available to mint via the handler.
|
|
70
|
+
* @throws if the handler is not provided.
|
|
71
|
+
*/ async getMintAmount() {
|
|
72
|
+
if (!this.handler) {
|
|
73
|
+
throw new Error('Minting handler was not provided');
|
|
74
|
+
}
|
|
75
|
+
return await this.handler.read.mintAmount();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the balance of the given address.
|
|
79
|
+
* @param address - Address to get the balance of.
|
|
80
|
+
*/ async getL1TokenBalance(address) {
|
|
81
|
+
return await this.contract.read.balanceOf([
|
|
82
|
+
address
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Mints a fixed amount of tokens for the given address. Returns once the tx has been mined.
|
|
87
|
+
* @param address - Address to mint the tokens for.
|
|
88
|
+
* @param addressName - Optional name of the address for logging.
|
|
89
|
+
*/ async mint(address, addressName) {
|
|
90
|
+
if (!this.handler) {
|
|
91
|
+
throw new Error('Minting handler was not provided');
|
|
92
|
+
}
|
|
93
|
+
const mintAmount = await this.getMintAmount();
|
|
94
|
+
this.logger.info(`Minting ${mintAmount} tokens for ${stringifyEthAddress(address, addressName)}`);
|
|
95
|
+
// NOTE: the handler mints a fixed amount.
|
|
96
|
+
await this.l1TxUtils.sendAndMonitorTransaction({
|
|
97
|
+
to: this.handler.address,
|
|
98
|
+
abi: FeeAssetHandlerAbi,
|
|
99
|
+
data: encodeFunctionData({
|
|
100
|
+
abi: FeeAssetHandlerAbi,
|
|
101
|
+
functionName: 'mint',
|
|
102
|
+
args: [
|
|
103
|
+
address
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Approves tokens for the given address. Returns once the tx has been mined.
|
|
110
|
+
* @param amount - Amount to approve.
|
|
111
|
+
* @param address - Address to approve the tokens for.
|
|
112
|
+
* @param addressName - Optional name of the address for logging.
|
|
113
|
+
*/ async approve(amount, address, addressName = '') {
|
|
114
|
+
this.logger.info(`Approving ${amount} tokens for ${stringifyEthAddress(address, addressName)}`);
|
|
115
|
+
await this.l1TxUtils.sendAndMonitorTransaction({
|
|
116
|
+
to: this.contract.address,
|
|
117
|
+
abi: TestERC20Abi,
|
|
118
|
+
data: encodeFunctionData({
|
|
119
|
+
abi: TestERC20Abi,
|
|
120
|
+
functionName: 'approve',
|
|
121
|
+
args: [
|
|
122
|
+
address,
|
|
123
|
+
amount
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** Helper for interacting with the FeeJuicePortal on L1. */ export class L1FeeJuicePortalManager {
|
|
130
|
+
extendedClient;
|
|
131
|
+
logger;
|
|
132
|
+
tokenManager;
|
|
133
|
+
contract;
|
|
134
|
+
l1TxUtils;
|
|
135
|
+
constructor(portalAddress, tokenAddress, handlerAddress, extendedClient, logger){
|
|
136
|
+
this.extendedClient = extendedClient;
|
|
137
|
+
this.logger = logger;
|
|
138
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
|
|
139
|
+
this.contract = getContract({
|
|
140
|
+
address: portalAddress.toString(),
|
|
141
|
+
abi: FeeJuicePortalAbi,
|
|
142
|
+
client: extendedClient
|
|
143
|
+
});
|
|
144
|
+
this.l1TxUtils = createL1TxUtils(extendedClient, {
|
|
145
|
+
logger
|
|
146
|
+
}, getL1TxUtilsConfigEnvVars());
|
|
147
|
+
}
|
|
148
|
+
/** Returns the associated token manager for the L1 ERC20. */ getTokenManager() {
|
|
149
|
+
return this.tokenManager;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Bridges fee juice from L1 to L2 publicly. Handles L1 ERC20 approvals. Returns once the tx has been mined.
|
|
153
|
+
* @param to - Address to send the tokens to on L2.
|
|
154
|
+
* @param amount - Amount of tokens to send.
|
|
155
|
+
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
156
|
+
*/ async bridgeTokensPublic(to, amount, mint = false) {
|
|
157
|
+
const [claimSecret, claimSecretHash] = await generateClaimSecret();
|
|
158
|
+
const amountToBridge = amount ?? await this.tokenManager.getMintAmount();
|
|
159
|
+
if (mint) {
|
|
160
|
+
const mintableAmount = await this.tokenManager.getMintAmount();
|
|
161
|
+
if (amountToBridge !== mintableAmount) {
|
|
162
|
+
throw new Error(`Minting amount must be ${mintableAmount}`);
|
|
163
|
+
}
|
|
164
|
+
await this.tokenManager.mint(this.extendedClient.account.address);
|
|
165
|
+
}
|
|
166
|
+
await this.tokenManager.approve(amountToBridge, this.contract.address, 'FeeJuice Portal');
|
|
167
|
+
this.logger.info('Sending L1 Fee Juice to L2 to be claimed publicly');
|
|
168
|
+
const args = [
|
|
169
|
+
to.toString(),
|
|
170
|
+
amountToBridge,
|
|
171
|
+
claimSecretHash.toString()
|
|
172
|
+
];
|
|
173
|
+
await this.contract.simulate.depositToAztecPublic(args);
|
|
174
|
+
const { receipt: txReceipt } = await this.l1TxUtils.sendAndMonitorTransaction({
|
|
175
|
+
to: this.contract.address,
|
|
176
|
+
abi: FeeJuicePortalAbi,
|
|
177
|
+
data: encodeFunctionData({
|
|
178
|
+
abi: FeeJuicePortalAbi,
|
|
179
|
+
functionName: 'depositToAztecPublic',
|
|
180
|
+
args
|
|
181
|
+
})
|
|
182
|
+
}, inboxDepositGasConfig());
|
|
183
|
+
this.logger.info('Deposited to Aztec public successfully', {
|
|
184
|
+
txReceipt
|
|
185
|
+
});
|
|
186
|
+
const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>{
|
|
187
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
188
|
+
const normalizeHex = (val)=>{
|
|
189
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
190
|
+
return hexStr.toLowerCase();
|
|
191
|
+
};
|
|
192
|
+
const secretHashMatch = normalizeHex(log.args.secretHash) === normalizeHex(claimSecretHash.toString());
|
|
193
|
+
const amountMatch = log.args.amount === amountToBridge;
|
|
194
|
+
const toMatch = normalizeHex(log.args.to) === normalizeHex(to.toString());
|
|
195
|
+
this.logger.debug(`Event filter matching: secretHash=${secretHashMatch} (${log.args.secretHash} vs ${claimSecretHash.toString()}), ` + `amount=${amountMatch} (${log.args.amount} vs ${amountToBridge}), ` + `to=${toMatch} (${log.args.to} vs ${to.toString()})`);
|
|
196
|
+
return secretHashMatch && amountMatch && toMatch;
|
|
197
|
+
}, this.logger);
|
|
198
|
+
return {
|
|
199
|
+
claimAmount: amountToBridge,
|
|
200
|
+
claimSecret,
|
|
201
|
+
claimSecretHash,
|
|
202
|
+
messageHash: log.args.key,
|
|
203
|
+
messageLeafIndex: log.args.index
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Creates a new instance
|
|
208
|
+
* @param node - Aztec node client used for retrieving the L1 contract addresses.
|
|
209
|
+
* @param extendedClient - Wallet client, extended with public actions.
|
|
210
|
+
* @param logger - Logger.
|
|
211
|
+
*/ static async new(node, extendedClient, logger) {
|
|
212
|
+
const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress, feeAssetHandlerAddress } } = await node.getNodeInfo();
|
|
213
|
+
if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
|
|
214
|
+
throw new Error('Portal or token not deployed on L1');
|
|
215
|
+
}
|
|
216
|
+
// Handler is optional - it's only needed for minting tokens during testing
|
|
217
|
+
const handlerAddress = feeAssetHandlerAddress && !feeAssetHandlerAddress.isZero() ? feeAssetHandlerAddress : undefined;
|
|
218
|
+
return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, handlerAddress, extendedClient, logger);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */ export class L1ToL2TokenPortalManager {
|
|
222
|
+
extendedClient;
|
|
223
|
+
logger;
|
|
224
|
+
portal;
|
|
225
|
+
tokenManager;
|
|
226
|
+
l1TxUtils;
|
|
227
|
+
constructor(portalAddress, tokenAddress, handlerAddress, extendedClient, logger){
|
|
228
|
+
this.extendedClient = extendedClient;
|
|
229
|
+
this.logger = logger;
|
|
230
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, extendedClient, logger);
|
|
231
|
+
this.portal = getContract({
|
|
232
|
+
address: portalAddress.toString(),
|
|
233
|
+
abi: TokenPortalAbi,
|
|
234
|
+
client: extendedClient
|
|
235
|
+
});
|
|
236
|
+
this.l1TxUtils = createL1TxUtils(extendedClient, {
|
|
237
|
+
logger
|
|
238
|
+
}, getL1TxUtilsConfigEnvVars());
|
|
239
|
+
}
|
|
240
|
+
/** Returns the token manager for the underlying L1 token. */ getTokenManager() {
|
|
241
|
+
return this.tokenManager;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Bridges tokens from L1 to L2. Handles token approvals. Returns once the tx has been mined.
|
|
245
|
+
* @param to - Address to send the tokens to on L2.
|
|
246
|
+
* @param amount - Amount of tokens to send.
|
|
247
|
+
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
248
|
+
*/ async bridgeTokensPublic(to, amount, mint = false) {
|
|
249
|
+
const [claimSecret, claimSecretHash] = await this.bridgeSetup(amount, mint);
|
|
250
|
+
this.logger.info('Sending L1 tokens to L2 to be claimed publicly');
|
|
251
|
+
const args = [
|
|
252
|
+
to.toString(),
|
|
253
|
+
amount,
|
|
254
|
+
claimSecretHash.toString()
|
|
255
|
+
];
|
|
256
|
+
await this.portal.simulate.depositToAztecPublic(args);
|
|
257
|
+
const { receipt: txReceipt } = await this.l1TxUtils.sendAndMonitorTransaction({
|
|
258
|
+
to: this.portal.address,
|
|
259
|
+
abi: TokenPortalAbi,
|
|
260
|
+
data: encodeFunctionData({
|
|
261
|
+
abi: TokenPortalAbi,
|
|
262
|
+
functionName: 'depositToAztecPublic',
|
|
263
|
+
args
|
|
264
|
+
})
|
|
265
|
+
}, inboxDepositGasConfig());
|
|
266
|
+
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPublic', (log)=>{
|
|
267
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
268
|
+
const normalizeHex = (val)=>{
|
|
269
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
270
|
+
return hexStr.toLowerCase();
|
|
271
|
+
};
|
|
272
|
+
return normalizeHex(log.args.secretHash) === normalizeHex(claimSecretHash.toString()) && log.args.amount === amount && normalizeHex(log.args.to) === normalizeHex(to.toString());
|
|
273
|
+
}, this.logger);
|
|
274
|
+
return {
|
|
275
|
+
claimAmount: amount,
|
|
276
|
+
claimSecret,
|
|
277
|
+
claimSecretHash,
|
|
278
|
+
messageHash: log.args.key,
|
|
279
|
+
messageLeafIndex: log.args.index
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Bridges tokens from L1 to L2 privately. Handles token approvals. Returns once the tx has been mined.
|
|
284
|
+
* @param to - Address to send the tokens to on L2.
|
|
285
|
+
* @param amount - Amount of tokens to send.
|
|
286
|
+
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
287
|
+
*/ async bridgeTokensPrivate(to, amount, mint = false) {
|
|
288
|
+
const [claimSecret, claimSecretHash] = await this.bridgeSetup(amount, mint);
|
|
289
|
+
this.logger.info('Sending L1 tokens to L2 to be claimed privately');
|
|
290
|
+
const args = [
|
|
291
|
+
amount,
|
|
292
|
+
claimSecretHash.toString()
|
|
293
|
+
];
|
|
294
|
+
await this.portal.simulate.depositToAztecPrivate(args);
|
|
295
|
+
const { receipt: txReceipt } = await this.l1TxUtils.sendAndMonitorTransaction({
|
|
296
|
+
to: this.portal.address,
|
|
297
|
+
abi: TokenPortalAbi,
|
|
298
|
+
data: encodeFunctionData({
|
|
299
|
+
abi: TokenPortalAbi,
|
|
300
|
+
functionName: 'depositToAztecPrivate',
|
|
301
|
+
args
|
|
302
|
+
})
|
|
303
|
+
}, inboxDepositGasConfig());
|
|
304
|
+
const log = extractEvent(txReceipt.logs, this.portal.address, this.portal.abi, 'DepositToAztecPrivate', (log)=>{
|
|
305
|
+
// Normalize hex strings for comparison (case-insensitive, handle different formats)
|
|
306
|
+
const normalizeHex = (val)=>{
|
|
307
|
+
const hexStr = typeof val === 'string' ? val : `0x${val.toString(16).padStart(64, '0')}`;
|
|
308
|
+
return hexStr.toLowerCase();
|
|
309
|
+
};
|
|
310
|
+
return log.args.amount === amount && normalizeHex(log.args.secretHashForL2MessageConsumption) === normalizeHex(claimSecretHash.toString());
|
|
311
|
+
}, this.logger);
|
|
312
|
+
this.logger.info(`Claim message secret: ${claimSecret.toString()}, claim message secret hash: ${claimSecretHash.toString()}`);
|
|
313
|
+
return {
|
|
314
|
+
claimAmount: amount,
|
|
315
|
+
claimSecret,
|
|
316
|
+
claimSecretHash,
|
|
317
|
+
recipient: to,
|
|
318
|
+
messageHash: log.args.key,
|
|
319
|
+
messageLeafIndex: log.args.index
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
async bridgeSetup(amount, mint) {
|
|
323
|
+
if (mint) {
|
|
324
|
+
const mintableAmount = await this.tokenManager.getMintAmount();
|
|
325
|
+
if (amount !== mintableAmount) {
|
|
326
|
+
throw new Error(`Minting amount must be ${mintableAmount} for testing`);
|
|
327
|
+
}
|
|
328
|
+
await this.tokenManager.mint(this.extendedClient.account.address);
|
|
329
|
+
}
|
|
330
|
+
await this.tokenManager.approve(amount, this.portal.address, 'TokenPortal');
|
|
331
|
+
return generateClaimSecret();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
335
|
+
outbox;
|
|
336
|
+
constructor(portalAddress, tokenAddress, handlerAddress, outboxAddress, extendedClient, logger){
|
|
337
|
+
super(portalAddress, tokenAddress, handlerAddress, extendedClient, logger);
|
|
338
|
+
this.outbox = getContract({
|
|
339
|
+
address: outboxAddress.toString(),
|
|
340
|
+
abi: OutboxAbi,
|
|
341
|
+
client: extendedClient
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Withdraws funds from the portal by consuming an L2 to L1 message. Returns once the tx is mined on L1.
|
|
346
|
+
* @param amount - Amount to withdraw.
|
|
347
|
+
* @param recipient - Who will receive the funds.
|
|
348
|
+
* @param epochNumber - Epoch number of the message.
|
|
349
|
+
* @param numCheckpointsInEpoch - The partial-proof depth (1-indexed) the witness was built against.
|
|
350
|
+
* @param messageIndex - Index of the message.
|
|
351
|
+
* @param siblingPath - Sibling path of the message.
|
|
352
|
+
*/ async withdrawFunds(amount, recipient, epochNumber, numCheckpointsInEpoch, messageIndex, siblingPath) {
|
|
353
|
+
this.logger.info(`Sending L1 tx to consume message at epoch ${epochNumber} numCheckpointsInEpoch ${numCheckpointsInEpoch} index ${messageIndex} to withdraw ${amount}`);
|
|
354
|
+
const messageLeafId = getL2ToL1MessageLeafId({
|
|
355
|
+
leafIndex: messageIndex,
|
|
356
|
+
siblingPath
|
|
357
|
+
});
|
|
358
|
+
const isConsumedBefore = await this.outbox.read.hasMessageBeenConsumedAtEpoch([
|
|
359
|
+
BigInt(epochNumber),
|
|
360
|
+
messageLeafId
|
|
361
|
+
]);
|
|
362
|
+
if (isConsumedBefore) {
|
|
363
|
+
throw new Error(`L2 to L1 message at epoch ${epochNumber} index ${messageIndex} height ${siblingPath.pathSize} has already been consumed`);
|
|
364
|
+
}
|
|
365
|
+
// Call function on L1 contract to consume the message
|
|
366
|
+
const withdrawArgs = [
|
|
367
|
+
recipient.toString(),
|
|
368
|
+
amount,
|
|
369
|
+
false,
|
|
370
|
+
BigInt(epochNumber),
|
|
371
|
+
BigInt(numCheckpointsInEpoch),
|
|
372
|
+
messageIndex,
|
|
373
|
+
siblingPath.toBufferArray().map((buf)=>`0x${buf.toString('hex')}`)
|
|
374
|
+
];
|
|
375
|
+
await this.portal.simulate.withdraw(withdrawArgs);
|
|
376
|
+
await this.l1TxUtils.sendAndMonitorTransaction({
|
|
377
|
+
to: this.portal.address,
|
|
378
|
+
abi: TokenPortalAbi,
|
|
379
|
+
data: encodeFunctionData({
|
|
380
|
+
abi: TokenPortalAbi,
|
|
381
|
+
functionName: 'withdraw',
|
|
382
|
+
args: withdrawArgs
|
|
383
|
+
})
|
|
384
|
+
});
|
|
385
|
+
const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtEpoch([
|
|
386
|
+
BigInt(epochNumber),
|
|
387
|
+
messageLeafId
|
|
388
|
+
]);
|
|
389
|
+
if (!isConsumedAfter) {
|
|
390
|
+
throw new Error(`L2 to L1 message at epoch ${epochNumber} index ${messageIndex} height ${siblingPath.pathSize} not consumed after withdrawal`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Computes the L2 to L1 message leaf for the given parameters.
|
|
395
|
+
* @param amount - Amount to bridge.
|
|
396
|
+
* @param recipient - Recipient on L1.
|
|
397
|
+
* @param l2Bridge - Address of the L2 bridge.
|
|
398
|
+
* @param callerOnL1 - Caller address on L1.
|
|
399
|
+
*/ async getL2ToL1MessageLeaf(amount, recipient, l2Bridge, callerOnL1 = EthAddress.ZERO) {
|
|
400
|
+
const version = await this.outbox.read.VERSION();
|
|
401
|
+
const content = sha256ToField([
|
|
402
|
+
Buffer.from(toFunctionSelector('withdraw(address,uint256,address)').substring(2), 'hex'),
|
|
403
|
+
recipient.toBuffer32(),
|
|
404
|
+
new Fr(amount).toBuffer(),
|
|
405
|
+
callerOnL1.toBuffer32()
|
|
406
|
+
]);
|
|
407
|
+
return computeL2ToL1MessageHash({
|
|
408
|
+
l2Sender: l2Bridge,
|
|
409
|
+
l1Recipient: EthAddress.fromString(this.portal.address),
|
|
410
|
+
content,
|
|
411
|
+
rollupVersion: new Fr(version),
|
|
412
|
+
chainId: new Fr(this.extendedClient.chain.id)
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
2
|
+
import type { GasSettings } from '@aztec-labs/stdlib/gas';
|
|
3
|
+
import { ExecutionPayload } from '@aztec-labs/stdlib/tx';
|
|
4
|
+
import type { L2AmountClaim } from '../ethereum/portal_manager.js';
|
|
5
|
+
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
6
|
+
/**
|
|
7
|
+
* Pay fee directly with Fee Juice claimed in the same tx. Claiming consumes an L1 to L2 message that "contains"
|
|
8
|
+
* the fee juice bridged from L1.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
|
|
11
|
+
private sender;
|
|
12
|
+
private claim;
|
|
13
|
+
constructor(sender: AztecAddress, claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>);
|
|
14
|
+
/**
|
|
15
|
+
* Creates an execution payload to pay the fee in Fee Juice.
|
|
16
|
+
* @returns An execution payload that just contains the `claim_and_end_setup` function call.
|
|
17
|
+
*/
|
|
18
|
+
getExecutionPayload(): Promise<ExecutionPayload>;
|
|
19
|
+
getAsset(): Promise<AztecAddress>;
|
|
20
|
+
getFeePayer(): Promise<AztecAddress>;
|
|
21
|
+
getGasSettings(): GasSettings | undefined;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX2p1aWNlX3BheW1lbnRfbWV0aG9kX3dpdGhfY2xhaW0uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9mZWUvZmVlX2p1aWNlX3BheW1lbnRfbWV0aG9kX3dpdGhfY2xhaW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sa0NBQWtDLENBQUM7QUFDckUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDMUQsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFekQsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDbkUsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUVoRTs7O0dBR0c7QUFDSCxxQkFBYSw4QkFBK0IsWUFBVyxnQkFBZ0I7SUFFbkUsT0FBTyxDQUFDLE1BQU07SUFDZCxPQUFPLENBQUMsS0FBSztJQUZmLFlBQ1UsTUFBTSxFQUFFLFlBQVksRUFDcEIsS0FBSyxFQUFFLElBQUksQ0FBQyxhQUFhLEVBQUUsYUFBYSxHQUFHLGFBQWEsR0FBRyxrQkFBa0IsQ0FBQyxFQUNwRjtJQUVKOzs7T0FHRztJQUNHLG1CQUFtQixJQUFJLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQXlCckQ7SUFFRCxRQUFRLElBQUksT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUVoQztJQUVELFdBQVcsSUFBSSxPQUFPLENBQUMsWUFBWSxDQUFDLENBRW5DO0lBRUQsY0FBYyxJQUFJLFdBQVcsR0FBRyxTQUFTLENBRXhDO0NBQ0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fee_juice_payment_method_with_claim.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method_with_claim.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,qBAAa,8BAA+B,YAAW,gBAAgB;IAEnE,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IAFf,YACU,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC,EACpF;IAEJ;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAyBrD;IAED,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAEhC;IAED,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC,CAEnC;IAED,cAAc,IAAI,WAAW,GAAG,SAAS,CAExC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
|
+
import { ProtocolContractAddress } from '@aztec-labs/protocol-contracts';
|
|
3
|
+
import { FunctionCall, FunctionSelector, FunctionType } from '@aztec-labs/stdlib/abi';
|
|
4
|
+
import { ExecutionPayload } from '@aztec-labs/stdlib/tx';
|
|
5
|
+
/**
|
|
6
|
+
* Pay fee directly with Fee Juice claimed in the same tx. Claiming consumes an L1 to L2 message that "contains"
|
|
7
|
+
* the fee juice bridged from L1.
|
|
8
|
+
*/ export class FeeJuicePaymentMethodWithClaim {
|
|
9
|
+
sender;
|
|
10
|
+
claim;
|
|
11
|
+
constructor(sender, claim){
|
|
12
|
+
this.sender = sender;
|
|
13
|
+
this.claim = claim;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates an execution payload to pay the fee in Fee Juice.
|
|
17
|
+
* @returns An execution payload that just contains the `claim_and_end_setup` function call.
|
|
18
|
+
*/ async getExecutionPayload() {
|
|
19
|
+
const selector = await FunctionSelector.fromSignature('claim_and_end_setup((Field),u128,Field,Field)');
|
|
20
|
+
return new ExecutionPayload([
|
|
21
|
+
FunctionCall.from({
|
|
22
|
+
name: 'claim_and_end_setup',
|
|
23
|
+
to: ProtocolContractAddress.FeeJuice,
|
|
24
|
+
selector,
|
|
25
|
+
type: FunctionType.PRIVATE,
|
|
26
|
+
hideMsgSender: false,
|
|
27
|
+
isStatic: false,
|
|
28
|
+
args: [
|
|
29
|
+
this.sender.toField(),
|
|
30
|
+
new Fr(this.claim.claimAmount),
|
|
31
|
+
this.claim.claimSecret,
|
|
32
|
+
new Fr(this.claim.messageLeafIndex)
|
|
33
|
+
]
|
|
34
|
+
})
|
|
35
|
+
], [], [], [], this.sender);
|
|
36
|
+
}
|
|
37
|
+
getAsset() {
|
|
38
|
+
return Promise.resolve(ProtocolContractAddress.FeeJuice);
|
|
39
|
+
}
|
|
40
|
+
getFeePayer() {
|
|
41
|
+
return Promise.resolve(this.sender);
|
|
42
|
+
}
|
|
43
|
+
getGasSettings() {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|