@aztec/aztec.js 0.81.0 → 0.82.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/dest/account/{contract.d.ts → account_contract.d.ts} +3 -2
- package/dest/account/account_contract.d.ts.map +1 -0
- package/dest/account/index.d.ts +2 -3
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +1 -2
- package/dest/account/interface.d.ts +1 -13
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/interface.js +1 -0
- package/dest/account_manager/account_manager.d.ts +105 -0
- package/dest/account_manager/account_manager.d.ts.map +1 -0
- package/dest/account_manager/account_manager.js +165 -0
- package/dest/account_manager/deploy_account_method.d.ts +4 -4
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.js +28 -13
- package/dest/account_manager/deploy_account_sent_tx.d.ts +3 -3
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_sent_tx.js +2 -2
- package/dest/account_manager/index.d.ts +1 -104
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +1 -165
- package/dest/api/account.d.ts +2 -1
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/contract.d.ts +4 -1
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +3 -0
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/utils.d.ts +2 -1
- package/dest/api/utils.d.ts.map +1 -1
- package/dest/api/utils.js +2 -1
- package/dest/api/wallet.d.ts +1 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +22 -57
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +12 -67
- package/dest/contract/batch_call.d.ts +6 -18
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +25 -54
- package/dest/contract/contract.d.ts +1 -1
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract_base.d.ts +1 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +38 -18
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +34 -41
- package/dest/contract/deploy_method.d.ts +7 -8
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +27 -32
- package/dest/contract/deploy_proven_tx.d.ts +2 -3
- package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.d.ts +2 -3
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +4 -4
- package/dest/contract/protocol_contracts.d.ts +1 -1
- package/dest/contract/protocol_contracts.d.ts.map +1 -1
- package/dest/contract/proven_tx.d.ts +3 -4
- package/dest/contract/proven_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.d.ts +4 -16
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +6 -37
- package/dest/contract/unsafe_contract.d.ts +1 -1
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.d.ts +17 -0
- package/dest/contract/wait_for_proven.d.ts.map +1 -0
- package/dest/contract/wait_for_proven.js +17 -0
- package/dest/deployment/broadcast_function.js +12 -8
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/register_class.d.ts +1 -1
- package/dest/deployment/register_class.d.ts.map +1 -1
- package/dest/deployment/register_class.js +6 -11
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +3 -2
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +12 -8
- package/dest/ethereum/portal_manager.d.ts +20 -11
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +64 -30
- package/dest/fee/fee_juice_payment_method.d.ts +3 -3
- package/dest/fee/fee_juice_payment_method.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method.js +3 -2
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +4 -4
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -5
- package/dest/fee/private_fee_payment_method.d.ts +6 -6
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +13 -12
- package/dest/fee/public_fee_payment_method.d.ts +7 -7
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +10 -11
- package/dest/fee/utils.d.ts +13 -0
- package/dest/fee/utils.d.ts.map +1 -0
- package/dest/fee/utils.js +32 -0
- package/dest/utils/authwit.d.ts +16 -9
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +26 -35
- package/dest/wallet/account_wallet.d.ts +6 -6
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +15 -17
- package/dest/wallet/base_wallet.d.ts +12 -35
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +11 -64
- package/dest/wallet/index.d.ts +2 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -1
- package/dest/wallet/signerless_wallet.d.ts +3 -3
- package/dest/wallet/signerless_wallet.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.js +3 -6
- package/dest/wallet/wallet.d.ts +11 -0
- package/dest/wallet/wallet.d.ts.map +1 -0
- package/package.json +8 -7
- package/src/account/{contract.ts → account_contract.ts} +2 -1
- package/src/account/index.ts +2 -3
- package/src/account/interface.ts +1 -12
- package/src/account_manager/account_manager.ts +235 -0
- package/src/account_manager/deploy_account_method.ts +35 -15
- package/src/account_manager/deploy_account_sent_tx.ts +4 -4
- package/src/account_manager/index.ts +1 -236
- package/src/api/account.ts +2 -8
- package/src/api/contract.ts +5 -5
- package/src/api/fee.ts +1 -1
- package/src/api/utils.ts +1 -1
- package/src/api/wallet.ts +7 -1
- package/src/contract/base_contract_interaction.ts +32 -88
- package/src/contract/batch_call.ts +40 -43
- package/src/contract/contract.ts +1 -1
- package/src/contract/contract_base.ts +1 -1
- package/src/contract/contract_function_interaction.ts +85 -56
- package/src/contract/deploy_method.ts +24 -26
- package/src/contract/deploy_proven_tx.ts +2 -3
- package/src/contract/deploy_sent_tx.ts +6 -6
- package/src/contract/protocol_contracts.ts +1 -1
- package/src/contract/proven_tx.ts +2 -3
- package/src/contract/sent_tx.ts +6 -47
- package/src/contract/unsafe_contract.ts +1 -1
- package/src/contract/wait_for_proven.ts +38 -0
- package/src/deployment/broadcast_function.ts +40 -40
- package/src/deployment/contract_deployer.ts +1 -1
- package/src/deployment/register_class.ts +9 -22
- package/src/entrypoint/default_multi_call_entrypoint.ts +14 -7
- package/src/ethereum/portal_manager.ts +73 -24
- package/src/fee/fee_juice_payment_method.ts +4 -5
- package/src/fee/fee_juice_payment_method_with_claim.ts +24 -20
- package/src/fee/private_fee_payment_method.ts +29 -28
- package/src/fee/public_fee_payment_method.ts +29 -29
- package/src/fee/utils.ts +39 -0
- package/src/utils/authwit.ts +32 -35
- package/src/wallet/account_wallet.ts +18 -17
- package/src/wallet/base_wallet.ts +27 -88
- package/src/wallet/index.ts +2 -2
- package/src/wallet/signerless_wallet.ts +9 -8
- package/src/wallet/wallet.ts +34 -0
- package/dest/account/contract.d.ts.map +0 -1
- package/dest/account/wallet.d.ts +0 -11
- package/dest/account/wallet.d.ts.map +0 -1
- package/dest/api/entrypoint.d.ts +0 -2
- package/dest/api/entrypoint.d.ts.map +0 -1
- package/dest/api/entrypoint.js +0 -1
- package/dest/entrypoint/default_entrypoint.d.ts +0 -12
- package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/default_entrypoint.js +0 -28
- package/dest/entrypoint/entrypoint.d.ts +0 -39
- package/dest/entrypoint/entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/entrypoint.js +0 -20
- package/dest/entrypoint/payload.d.ts +0 -128
- package/dest/entrypoint/payload.d.ts.map +0 -1
- package/dest/entrypoint/payload.js +0 -143
- package/dest/fee/fee_payment_method.d.ts +0 -22
- package/dest/fee/fee_payment_method.d.ts.map +0 -1
- package/dest/fee/fee_payment_method.js +0 -3
- package/src/account/wallet.ts +0 -13
- package/src/api/entrypoint.ts +0 -1
- package/src/entrypoint/default_entrypoint.ts +0 -39
- package/src/entrypoint/entrypoint.ts +0 -60
- package/src/entrypoint/payload.ts +0 -238
- package/src/fee/fee_payment_method.ts +0 -22
- /package/dest/account/{contract.js → account_contract.js} +0 -0
- /package/dest/{account → wallet}/wallet.js +0 -0
|
@@ -2,6 +2,7 @@ import { extractEvent } from '@aztec/ethereum/utils';
|
|
|
2
2
|
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
+
import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts/FeeAssetHandlerAbi';
|
|
5
6
|
import { FeeJuicePortalAbi } from '@aztec/l1-artifacts/FeeJuicePortalAbi';
|
|
6
7
|
import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
|
|
7
8
|
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
@@ -21,21 +22,39 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
21
22
|
];
|
|
22
23
|
}
|
|
23
24
|
/** Helper for managing an ERC20 on L1. */ export class L1TokenManager {
|
|
24
|
-
|
|
25
|
+
tokenAddress;
|
|
26
|
+
handlerAddress;
|
|
25
27
|
publicClient;
|
|
26
28
|
walletClient;
|
|
27
29
|
logger;
|
|
28
30
|
contract;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
handler;
|
|
32
|
+
constructor(/** Address of the ERC20 contract. */ tokenAddress, /** Address of the handler/faucet contract. */ handlerAddress, publicClient, walletClient, logger){
|
|
33
|
+
this.tokenAddress = tokenAddress;
|
|
34
|
+
this.handlerAddress = handlerAddress;
|
|
31
35
|
this.publicClient = publicClient;
|
|
32
36
|
this.walletClient = walletClient;
|
|
33
37
|
this.logger = logger;
|
|
34
38
|
this.contract = getContract({
|
|
35
|
-
address: this.
|
|
39
|
+
address: this.tokenAddress.toString(),
|
|
36
40
|
abi: TestERC20Abi,
|
|
37
41
|
client: this.walletClient
|
|
38
42
|
});
|
|
43
|
+
if (this.handlerAddress) {
|
|
44
|
+
this.handler = getContract({
|
|
45
|
+
address: this.handlerAddress.toString(),
|
|
46
|
+
abi: FeeAssetHandlerAbi,
|
|
47
|
+
client: this.walletClient
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Returns the amount of tokens available to mint via the handler.
|
|
52
|
+
* @throws if the handler is not provided.
|
|
53
|
+
*/ async getMintAmount() {
|
|
54
|
+
if (!this.handler) {
|
|
55
|
+
throw new Error('Minting handler was not provided');
|
|
56
|
+
}
|
|
57
|
+
return await this.handler.read.mintAmount();
|
|
39
58
|
}
|
|
40
59
|
/**
|
|
41
60
|
* Returns the balance of the given address.
|
|
@@ -46,18 +65,19 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
46
65
|
]);
|
|
47
66
|
}
|
|
48
67
|
/**
|
|
49
|
-
* Mints tokens for the given address. Returns once the tx has been mined.
|
|
50
|
-
* @param amount - Amount to mint.
|
|
68
|
+
* Mints a fixed amount of tokens for the given address. Returns once the tx has been mined.
|
|
51
69
|
* @param address - Address to mint the tokens for.
|
|
52
70
|
* @param addressName - Optional name of the address for logging.
|
|
53
|
-
*/ async mint(
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
*/ async mint(address, addressName) {
|
|
72
|
+
if (!this.handler) {
|
|
73
|
+
throw new Error('Minting handler was not provided');
|
|
74
|
+
}
|
|
75
|
+
const mintAmount = await this.getMintAmount();
|
|
76
|
+
this.logger.info(`Minting ${mintAmount} tokens for ${stringifyEthAddress(address, addressName)}`);
|
|
77
|
+
// NOTE: the handler mints a fixed amount.
|
|
78
|
+
await this.handler.write.mint([
|
|
79
|
+
address
|
|
80
|
+
]);
|
|
61
81
|
}
|
|
62
82
|
/**
|
|
63
83
|
* Approves tokens for the given address. Returns once the tx has been mined.
|
|
@@ -80,11 +100,11 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
80
100
|
logger;
|
|
81
101
|
tokenManager;
|
|
82
102
|
contract;
|
|
83
|
-
constructor(portalAddress, tokenAddress, publicClient, walletClient, logger){
|
|
103
|
+
constructor(portalAddress, tokenAddress, handlerAddress, publicClient, walletClient, logger){
|
|
84
104
|
this.publicClient = publicClient;
|
|
85
105
|
this.walletClient = walletClient;
|
|
86
106
|
this.logger = logger;
|
|
87
|
-
this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
|
|
107
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, publicClient, walletClient, logger);
|
|
88
108
|
this.contract = getContract({
|
|
89
109
|
address: portalAddress.toString(),
|
|
90
110
|
abi: FeeJuicePortalAbi,
|
|
@@ -101,14 +121,19 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
101
121
|
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
102
122
|
*/ async bridgeTokensPublic(to, amount, mint = false) {
|
|
103
123
|
const [claimSecret, claimSecretHash] = await generateClaimSecret();
|
|
124
|
+
const mintableAmount = await this.tokenManager.getMintAmount();
|
|
125
|
+
const amountToBridge = amount ?? mintableAmount;
|
|
104
126
|
if (mint) {
|
|
105
|
-
|
|
127
|
+
if (amountToBridge !== mintableAmount) {
|
|
128
|
+
throw new Error(`Minting amount must be ${mintableAmount}`);
|
|
129
|
+
}
|
|
130
|
+
await this.tokenManager.mint(this.walletClient.account.address);
|
|
106
131
|
}
|
|
107
|
-
await this.tokenManager.approve(
|
|
132
|
+
await this.tokenManager.approve(amountToBridge, this.contract.address, 'FeeJuice Portal');
|
|
108
133
|
this.logger.info('Sending L1 Fee Juice to L2 to be claimed publicly');
|
|
109
134
|
const args = [
|
|
110
135
|
to.toString(),
|
|
111
|
-
|
|
136
|
+
amountToBridge,
|
|
112
137
|
claimSecretHash.toString()
|
|
113
138
|
];
|
|
114
139
|
await this.contract.simulate.depositToAztecPublic(args);
|
|
@@ -116,9 +141,9 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
116
141
|
hash: await this.contract.write.depositToAztecPublic(args)
|
|
117
142
|
});
|
|
118
143
|
this.logger.info('Deposited to Aztec public successfully');
|
|
119
|
-
const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount ===
|
|
144
|
+
const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amountToBridge && log.args.to === to.toString(), this.logger);
|
|
120
145
|
return {
|
|
121
|
-
claimAmount:
|
|
146
|
+
claimAmount: amountToBridge,
|
|
122
147
|
claimSecret,
|
|
123
148
|
claimSecretHash,
|
|
124
149
|
messageHash: log.args.key,
|
|
@@ -127,16 +152,19 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
127
152
|
}
|
|
128
153
|
/**
|
|
129
154
|
* Creates a new instance
|
|
130
|
-
* @param
|
|
155
|
+
* @param walletOrPxe - Wallet or PXE client used for retrieving the L1 contract addresses.
|
|
131
156
|
* @param publicClient - L1 public client.
|
|
132
157
|
* @param walletClient - L1 wallet client.
|
|
133
158
|
* @param logger - Logger.
|
|
134
|
-
*/ static async new(
|
|
135
|
-
const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress } } = await
|
|
159
|
+
*/ static async new(walletOrPxe, publicClient, walletClient, logger) {
|
|
160
|
+
const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress, feeAssetHandlerAddress } } = await walletOrPxe.getNodeInfo();
|
|
136
161
|
if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
|
|
137
162
|
throw new Error('Portal or token not deployed on L1');
|
|
138
163
|
}
|
|
139
|
-
|
|
164
|
+
if (!feeAssetHandlerAddress || feeAssetHandlerAddress.isZero()) {
|
|
165
|
+
throw new Error('Handler not deployed on L1, or handler address is zero');
|
|
166
|
+
}
|
|
167
|
+
return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, feeAssetHandlerAddress, publicClient, walletClient, logger);
|
|
140
168
|
}
|
|
141
169
|
}
|
|
142
170
|
/** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */ export class L1ToL2TokenPortalManager {
|
|
@@ -145,11 +173,11 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
145
173
|
logger;
|
|
146
174
|
portal;
|
|
147
175
|
tokenManager;
|
|
148
|
-
constructor(portalAddress, tokenAddress, publicClient, walletClient, logger){
|
|
176
|
+
constructor(portalAddress, tokenAddress, handlerAddress, publicClient, walletClient, logger){
|
|
149
177
|
this.publicClient = publicClient;
|
|
150
178
|
this.walletClient = walletClient;
|
|
151
179
|
this.logger = logger;
|
|
152
|
-
this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
|
|
180
|
+
this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, publicClient, walletClient, logger);
|
|
153
181
|
this.portal = getContract({
|
|
154
182
|
address: portalAddress.toString(),
|
|
155
183
|
abi: TokenPortalAbi,
|
|
@@ -184,12 +212,14 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
184
212
|
messageLeafIndex: log.args.index
|
|
185
213
|
};
|
|
186
214
|
}
|
|
215
|
+
// docs:start:bridge_tokens_private
|
|
187
216
|
/**
|
|
188
217
|
* Bridges tokens from L1 to L2 privately. Handles token approvals. Returns once the tx has been mined.
|
|
189
218
|
* @param to - Address to send the tokens to on L2.
|
|
190
219
|
* @param amount - Amount of tokens to send.
|
|
191
220
|
* @param mint - Whether to mint the tokens before sending (only during testing).
|
|
192
221
|
*/ async bridgeTokensPrivate(to, amount, mint = false) {
|
|
222
|
+
// docs:end:bridge_tokens_private
|
|
193
223
|
const [claimSecret, claimSecretHash] = await this.bridgeSetup(amount, mint);
|
|
194
224
|
this.logger.info('Sending L1 tokens to L2 to be claimed privately');
|
|
195
225
|
const { request } = await this.portal.simulate.depositToAztecPrivate([
|
|
@@ -212,7 +242,11 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
212
242
|
}
|
|
213
243
|
async bridgeSetup(amount, mint) {
|
|
214
244
|
if (mint) {
|
|
215
|
-
await this.tokenManager.
|
|
245
|
+
const mintableAmount = await this.tokenManager.getMintAmount();
|
|
246
|
+
if (amount !== mintableAmount) {
|
|
247
|
+
throw new Error(`Minting amount must be ${mintableAmount} for testing`);
|
|
248
|
+
}
|
|
249
|
+
await this.tokenManager.mint(this.walletClient.account.address);
|
|
216
250
|
}
|
|
217
251
|
await this.tokenManager.approve(amount, this.portal.address, 'TokenPortal');
|
|
218
252
|
return generateClaimSecret();
|
|
@@ -220,8 +254,8 @@ import { getContract, toFunctionSelector } from 'viem';
|
|
|
220
254
|
}
|
|
221
255
|
/** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
222
256
|
outbox;
|
|
223
|
-
constructor(portalAddress, tokenAddress, outboxAddress, publicClient, walletClient, logger){
|
|
224
|
-
super(portalAddress, tokenAddress, publicClient, walletClient, logger);
|
|
257
|
+
constructor(portalAddress, tokenAddress, handlerAddress, outboxAddress, publicClient, walletClient, logger){
|
|
258
|
+
super(portalAddress, tokenAddress, handlerAddress, publicClient, walletClient, logger);
|
|
225
259
|
this.outbox = getContract({
|
|
226
260
|
address: outboxAddress.toString(),
|
|
227
261
|
abi: OutboxAbi,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FeePaymentMethod } from '@aztec/entrypoints/interfaces';
|
|
2
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
4
4
|
/**
|
|
5
5
|
* Pay fee directly in the Fee Juice.
|
|
6
6
|
*/
|
|
@@ -8,7 +8,7 @@ export declare class FeeJuicePaymentMethod implements FeePaymentMethod {
|
|
|
8
8
|
protected sender: AztecAddress;
|
|
9
9
|
constructor(sender: AztecAddress);
|
|
10
10
|
getAsset(): Promise<AztecAddress>;
|
|
11
|
-
|
|
11
|
+
getExecutionPayload(): Promise<ExecutionPayload>;
|
|
12
12
|
getFeePayer(): Promise<AztecAddress>;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=fee_juice_payment_method.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee_juice_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fee_juice_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;GAEG;AACH,qBAAa,qBAAsB,YAAW,gBAAgB;IAEhD,SAAS,CAAC,MAAM,EAAE,YAAY;gBAApB,MAAM,EAAE,YAAY;IAE1C,QAAQ;IAIR,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIhD,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;CAGrC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
3
|
// docs:start:fee_juice_method
|
|
3
4
|
/**
|
|
@@ -11,8 +12,8 @@ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
|
11
12
|
getAsset() {
|
|
12
13
|
return Promise.resolve(ProtocolContractAddress.FeeJuice);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
return Promise.resolve(
|
|
15
|
+
getExecutionPayload() {
|
|
16
|
+
return Promise.resolve(ExecutionPayload.empty());
|
|
16
17
|
}
|
|
17
18
|
getFeePayer() {
|
|
18
19
|
return Promise.resolve(this.sender);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
2
|
import type { L2AmountClaim } from '../ethereum/portal_manager.js';
|
|
3
3
|
import type { Wallet } from '../wallet/index.js';
|
|
4
4
|
import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
|
|
@@ -10,9 +10,9 @@ export declare class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMetho
|
|
|
10
10
|
private claim;
|
|
11
11
|
constructor(senderWallet: Wallet, claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>);
|
|
12
12
|
/**
|
|
13
|
-
* Creates
|
|
14
|
-
* @returns
|
|
13
|
+
* Creates an execution payload to pay the fee in Fee Juice.
|
|
14
|
+
* @returns An execution payload that just contains the claim function call.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
getExecutionPayload(): Promise<ExecutionPayload>;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=fee_juice_payment_method_with_claim.d.ts.map
|
|
@@ -1 +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":"
|
|
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":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAM9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,qBAAqB;IAErE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,KAAK;gBADL,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAKxF;;;OAGG;IACY,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CA2BhE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
4
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
@@ -12,12 +13,12 @@ import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
|
|
|
12
13
|
super(senderWallet.getAddress()), this.senderWallet = senderWallet, this.claim = claim;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
|
-
* Creates
|
|
16
|
-
* @returns
|
|
17
|
-
*/ async
|
|
16
|
+
* Creates an execution payload to pay the fee in Fee Juice.
|
|
17
|
+
* @returns An execution payload that just contains the claim function call.
|
|
18
|
+
*/ async getExecutionPayload() {
|
|
18
19
|
const canonicalFeeJuice = await getFeeJuice(this.senderWallet);
|
|
19
20
|
const selector = await FunctionSelector.fromNameAndParameters(canonicalFeeJuice.artifact.functions.find((f)=>f.name === 'claim'));
|
|
20
|
-
return
|
|
21
|
+
return new ExecutionPayload([
|
|
21
22
|
{
|
|
22
23
|
to: ProtocolContractAddress.FeeJuice,
|
|
23
24
|
name: 'claim',
|
|
@@ -32,6 +33,6 @@ import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
|
|
|
32
33
|
returnTypes: [],
|
|
33
34
|
type: FunctionType.PRIVATE
|
|
34
35
|
}
|
|
35
|
-
]);
|
|
36
|
+
], [], []);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FeePaymentMethod } from '@aztec/entrypoints/interfaces';
|
|
2
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
4
|
-
import type { Wallet } from '../
|
|
5
|
-
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
5
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
6
6
|
/**
|
|
7
7
|
* Holds information about how the fee for a transaction is to be paid.
|
|
8
8
|
*/
|
|
@@ -42,10 +42,10 @@ export declare class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
42
42
|
getAsset(): Promise<AztecAddress>;
|
|
43
43
|
getFeePayer(): Promise<AztecAddress>;
|
|
44
44
|
/**
|
|
45
|
-
* Creates
|
|
45
|
+
* Creates an execution payload to pay the fee using a private function through an FPC in the desired asset
|
|
46
46
|
* @param gasSettings - The gas settings.
|
|
47
|
-
* @returns
|
|
47
|
+
* @returns An execution payload that contains the required function calls and auth witnesses.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload>;
|
|
50
50
|
}
|
|
51
51
|
//# sourceMappingURL=private_fee_payment_method.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/private_fee_payment_method.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/private_fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;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;IAoCjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC;;;;OAIG;IACG,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAmC/E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
-
import {
|
|
4
|
-
import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
4
|
+
import { simulateWithoutSignature } from './utils.js';
|
|
5
5
|
/**
|
|
6
6
|
* Holds information about how the fee for a transaction is to be paid.
|
|
7
7
|
*/ export class PrivateFeePaymentMethod {
|
|
@@ -27,9 +27,9 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
27
27
|
* @returns The asset used to pay the fee.
|
|
28
28
|
*/ getAsset() {
|
|
29
29
|
if (!this.assetPromise) {
|
|
30
|
-
// We use
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
// We use the utility method to avoid a signature because this function could be triggered
|
|
31
|
+
// before the associated account is deployed.
|
|
32
|
+
this.assetPromise = simulateWithoutSignature(this.wallet, this.paymentContract, {
|
|
33
33
|
name: 'get_accepted_asset',
|
|
34
34
|
functionType: FunctionType.PRIVATE,
|
|
35
35
|
isInternal: false,
|
|
@@ -52,7 +52,6 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
52
52
|
errorTypes: {},
|
|
53
53
|
isInitializer: false
|
|
54
54
|
}, []);
|
|
55
|
-
this.assetPromise = interaction.simulate();
|
|
56
55
|
}
|
|
57
56
|
return this.assetPromise;
|
|
58
57
|
}
|
|
@@ -60,15 +59,15 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
60
59
|
return Promise.resolve(this.paymentContract);
|
|
61
60
|
}
|
|
62
61
|
/**
|
|
63
|
-
* Creates
|
|
62
|
+
* Creates an execution payload to pay the fee using a private function through an FPC in the desired asset
|
|
64
63
|
* @param gasSettings - The gas settings.
|
|
65
|
-
* @returns
|
|
66
|
-
*/ async
|
|
64
|
+
* @returns An execution payload that contains the required function calls and auth witnesses.
|
|
65
|
+
*/ async getExecutionPayload(gasSettings) {
|
|
67
66
|
// We assume 1:1 exchange rate between fee juice and token. But in reality you would need to convert feeLimit
|
|
68
67
|
// (maxFee) to be in token denomination.
|
|
69
68
|
const maxFee = this.setMaxFeeToOne ? Fr.ONE : gasSettings.getFeeLimit();
|
|
70
69
|
const nonce = Fr.random();
|
|
71
|
-
await this.wallet.createAuthWit({
|
|
70
|
+
const witness = await this.wallet.createAuthWit({
|
|
72
71
|
caller: this.paymentContract,
|
|
73
72
|
action: {
|
|
74
73
|
name: 'transfer_to_public',
|
|
@@ -85,7 +84,7 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
85
84
|
returnTypes: []
|
|
86
85
|
}
|
|
87
86
|
});
|
|
88
|
-
return [
|
|
87
|
+
return new ExecutionPayload([
|
|
89
88
|
{
|
|
90
89
|
name: 'fee_entrypoint_private',
|
|
91
90
|
to: this.paymentContract,
|
|
@@ -98,6 +97,8 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
98
97
|
],
|
|
99
98
|
returnTypes: []
|
|
100
99
|
}
|
|
101
|
-
]
|
|
100
|
+
], [
|
|
101
|
+
witness
|
|
102
|
+
], []);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import type { FeePaymentMethod } from '@aztec/entrypoints/interfaces';
|
|
2
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
4
5
|
import type { AccountWallet } from '../wallet/account_wallet.js';
|
|
5
|
-
import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
6
6
|
/**
|
|
7
7
|
* Holds information about how the fee for a transaction is to be paid.
|
|
8
8
|
*/
|
|
@@ -32,10 +32,10 @@ export declare class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
32
32
|
getAsset(): Promise<AztecAddress>;
|
|
33
33
|
getFeePayer(): Promise<AztecAddress>;
|
|
34
34
|
/**
|
|
35
|
-
* Creates
|
|
35
|
+
* Creates an execution payload to pay the fee using a public function through an FPC in the desired asset
|
|
36
36
|
* @param gasSettings - The gas settings.
|
|
37
|
-
* @returns
|
|
37
|
+
* @returns An execution payload that contains the required function calls.
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload>;
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=public_fee_payment_method.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/public_fee_payment_method.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"public_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/public_fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjE;;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;IAoCjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC;;;;OAIG;IACG,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAqC/E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
-
import {
|
|
4
|
-
import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
4
|
+
import { simulateWithoutSignature } from './utils.js';
|
|
5
5
|
/**
|
|
6
6
|
* Holds information about how the fee for a transaction is to be paid.
|
|
7
7
|
*/ export class PublicFeePaymentMethod {
|
|
@@ -22,9 +22,9 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
22
22
|
* @returns The asset used to pay the fee.
|
|
23
23
|
*/ getAsset() {
|
|
24
24
|
if (!this.assetPromise) {
|
|
25
|
-
// We use
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// We use the utility method to avoid a signature because this function could be triggered
|
|
26
|
+
// before the associated account is deployed.
|
|
27
|
+
this.assetPromise = simulateWithoutSignature(this.wallet, this.paymentContract, {
|
|
28
28
|
name: 'get_accepted_asset',
|
|
29
29
|
functionType: FunctionType.PRIVATE,
|
|
30
30
|
isInternal: false,
|
|
@@ -47,7 +47,6 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
47
47
|
errorTypes: {},
|
|
48
48
|
isInitializer: false
|
|
49
49
|
}, []);
|
|
50
|
-
this.assetPromise = interaction.simulate();
|
|
51
50
|
}
|
|
52
51
|
return this.assetPromise;
|
|
53
52
|
}
|
|
@@ -55,10 +54,10 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
55
54
|
return Promise.resolve(this.paymentContract);
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
|
-
* Creates
|
|
57
|
+
* Creates an execution payload to pay the fee using a public function through an FPC in the desired asset
|
|
59
58
|
* @param gasSettings - The gas settings.
|
|
60
|
-
* @returns
|
|
61
|
-
*/ async
|
|
59
|
+
* @returns An execution payload that contains the required function calls.
|
|
60
|
+
*/ async getExecutionPayload(gasSettings) {
|
|
62
61
|
const nonce = Fr.random();
|
|
63
62
|
const maxFee = gasSettings.getFeeLimit();
|
|
64
63
|
const setPublicAuthWitInteraction = await this.wallet.setPublicAuthWit({
|
|
@@ -78,7 +77,7 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
78
77
|
returnTypes: []
|
|
79
78
|
}
|
|
80
79
|
}, true);
|
|
81
|
-
return [
|
|
80
|
+
return new ExecutionPayload([
|
|
82
81
|
...(await setPublicAuthWitInteraction.request()).calls,
|
|
83
82
|
{
|
|
84
83
|
name: 'fee_entrypoint_public',
|
|
@@ -92,6 +91,6 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
|
|
|
92
91
|
],
|
|
93
92
|
returnTypes: []
|
|
94
93
|
}
|
|
95
|
-
];
|
|
94
|
+
], [], []);
|
|
96
95
|
}
|
|
97
96
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FunctionAbi } from '@aztec/stdlib/abi';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
4
|
+
/**
|
|
5
|
+
* Use a wallet to simulate a function avoiding the wallet's entrypoint, as a SignerlessWallet would do
|
|
6
|
+
* @param wallet - The wallet to use for the simulation.
|
|
7
|
+
* @param contractAddress - The address of the contract to call.
|
|
8
|
+
* @param abi - The ABI of the function to simulate.
|
|
9
|
+
* @param args - The arguments to pass to the function.
|
|
10
|
+
* @returns The return values of the function call.
|
|
11
|
+
*/
|
|
12
|
+
export declare function simulateWithoutSignature(wallet: Wallet, contractAddress: AztecAddress, abi: FunctionAbi, args: any[]): Promise<import("@aztec/stdlib/abi").AbiDecoded>;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fee/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAI3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,GAAG,EAAE,mDAiBZ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
2
|
+
import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
6
|
+
import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
|
|
7
|
+
/**
|
|
8
|
+
* Use a wallet to simulate a function avoiding the wallet's entrypoint, as a SignerlessWallet would do
|
|
9
|
+
* @param wallet - The wallet to use for the simulation.
|
|
10
|
+
* @param contractAddress - The address of the contract to call.
|
|
11
|
+
* @param abi - The ABI of the function to simulate.
|
|
12
|
+
* @param args - The arguments to pass to the function.
|
|
13
|
+
* @returns The return values of the function call.
|
|
14
|
+
*/ export async function simulateWithoutSignature(wallet, contractAddress, abi, args) {
|
|
15
|
+
const interaction = new ContractFunctionInteraction(wallet, contractAddress, abi, args);
|
|
16
|
+
const request = await interaction.request();
|
|
17
|
+
const maxFeesPerGas = (await wallet.getCurrentBaseFees()).mul(1.5);
|
|
18
|
+
const paymentMethod = new FeeJuicePaymentMethod(AztecAddress.ZERO);
|
|
19
|
+
const gasSettings = GasSettings.default({
|
|
20
|
+
maxFeesPerGas
|
|
21
|
+
});
|
|
22
|
+
const fee = {
|
|
23
|
+
gasSettings,
|
|
24
|
+
paymentMethod
|
|
25
|
+
};
|
|
26
|
+
const { l1ChainId: chainId, protocolVersion } = await wallet.getNodeInfo();
|
|
27
|
+
const entrypoint = new DefaultEntrypoint(chainId, protocolVersion);
|
|
28
|
+
const signerlessTxExecutionRequest = await entrypoint.createTxExecutionRequest(request, fee, {});
|
|
29
|
+
const simulationResult = await wallet.simulateTx(signerlessTxExecutionRequest, false, undefined, undefined, true);
|
|
30
|
+
const rawReturnValues = simulationResult.getPrivateReturnValues().values;
|
|
31
|
+
return decodeFromAbi(abi.returnTypes, rawReturnValues);
|
|
32
|
+
}
|
package/dest/utils/authwit.d.ts
CHANGED
|
@@ -47,14 +47,21 @@ export type IntentAction = {
|
|
|
47
47
|
* @returns The message hash for the action
|
|
48
48
|
*/
|
|
49
49
|
export declare const computeAuthWitMessageHash: (intent: IntentInnerHash | IntentAction, metadata: IntentMetadata) => Promise<Fr>;
|
|
50
|
-
export declare const computeInnerAuthWitHashFromAction: (caller: AztecAddress, action: FunctionCall) => Promise<Fr>;
|
|
51
50
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
* Computes the inner authwitness hash for a function call, for it to later be combined with the metadata
|
|
52
|
+
* required for the outer hash and eventually the full AuthWitness.
|
|
53
|
+
* @param caller - Who is going to be calling the function
|
|
54
|
+
* @param fnCall - The function call to compute the inner hash from
|
|
55
|
+
* @returns The inner hash for the function call
|
|
56
|
+
**/
|
|
57
|
+
export declare const computeInnerAuthWitHashFromFunctionCall: (caller: AztecAddress, fnCall: FunctionCall) => Promise<Fr>;
|
|
58
|
+
/**
|
|
59
|
+
* Computes the inner authwitness hash for an action, that can either be a ContractFunctionInteraction
|
|
60
|
+
* or an isolated FunctionCall. Since the former is just a wrapper around the latter, we can just extract
|
|
61
|
+
* the first (and only) call from the ContractFunctionInteraction and use it to compute the inner hash.
|
|
62
|
+
* @param caller - Who is going to be performing the action
|
|
63
|
+
* @param action - The ContractFunctionInteraction or FunctionCall to compute the inner hash for
|
|
64
|
+
* @returns The inner hash for the action
|
|
65
|
+
**/
|
|
66
|
+
export declare const computeInnerAuthWitHashFromAction: (caller: AztecAddress, action: FunctionCall | ContractFunctionInteraction) => Promise<Fr>;
|
|
60
67
|
//# sourceMappingURL=authwit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authwit.d.ts","sourceRoot":"","sources":["../../src/utils/authwit.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"authwit.d.ts","sourceRoot":"","sources":["../../src/utils/authwit.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F,8BAA8B;AAC9B,MAAM,MAAM,cAAc,GAAG;IAC3B,8BAA8B;IAC9B,OAAO,EAAE,EAAE,CAAC;IACZ,8BAA8B;IAC9B,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG;IAC5B,qBAAqB;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,GAAG,EAAE,CAAC;CACxB,CAAC;AAEF,4BAA4B;AAC5B,MAAM,MAAM,YAAY,GAAG;IACzB,6BAA6B;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,4BAA4B;IAC5B,MAAM,EAAE,2BAA2B,GAAG,YAAY,CAAC;CACpD,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,WAAkB,eAAe,GAAG,YAAY,YAAY,cAAc,gBAiB/G,CAAC;AAGF;;;;;;IAMI;AACJ,eAAO,MAAM,uCAAuC,WAAkB,YAAY,UAAU,YAAY,gBAMvG,CAAC;AAEF;;;;;;;IAOI;AACJ,eAAO,MAAM,iCAAiC,WACpC,YAAY,UACZ,YAAY,GAAG,2BAA2B,gBAQnD,CAAC"}
|