@aztec/aztec.js 0.0.1-commit.03f7ef2 → 0.0.1-commit.04852196a
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/account.d.ts +25 -40
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +8 -9
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +19 -7
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.js +21 -4
- package/dest/account/index.d.ts +3 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +5 -6
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/abi.d.ts +2 -2
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/account.d.ts +2 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -3
- package/dest/api/authorization.d.ts +2 -2
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +1 -1
- package/dest/api/contract.d.ts +18 -12
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +16 -10
- package/dest/api/deployment.d.ts +1 -2
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +0 -1
- package/dest/api/events.d.ts +18 -6
- package/dest/api/events.d.ts.map +1 -1
- package/dest/api/events.js +37 -22
- package/dest/api/fields.d.ts +2 -1
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +1 -0
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/keys.js +1 -1
- package/dest/api/node.d.ts +8 -4
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +7 -3
- package/dest/api/protocol.d.ts +7 -1
- package/dest/api/protocol.d.ts.map +1 -1
- package/dest/api/protocol.js +6 -0
- package/dest/api/tx.d.ts +2 -2
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/wallet.d.ts +3 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -1
- package/dest/authorization/call_authorization_request.d.ts +22 -1
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -10
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/batch_call.d.ts +3 -3
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +20 -9
- package/dest/contract/contract_base.d.ts +4 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +7 -16
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +107 -18
- package/dest/contract/deploy_method.d.ts +91 -19
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +73 -34
- package/dest/contract/get_gas_limits.js +3 -3
- package/dest/contract/interaction_options.d.ts +99 -21
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +41 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +1005 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +15 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +139 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +434 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +601 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/public-checks.js +609 -0
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/deployment/publish_class.js +2 -2
- package/dest/deployment/publish_instance.d.ts +2 -2
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +3 -3
- package/dest/ethereum/portal_manager.d.ts +7 -4
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +15 -16
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
- package/dest/fee/private_fee_payment_method.d.ts +2 -1
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +11 -10
- package/dest/fee/public_fee_payment_method.d.ts +2 -1
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +11 -10
- package/dest/fee/sponsored_fee_payment.js +3 -3
- 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 +120 -0
- package/dest/utils/abi_types.d.ts +6 -1
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/abi_types.js +1 -1
- package/dest/utils/authwit.d.ts +8 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +15 -15
- package/dest/utils/cross_chain.d.ts +3 -8
- package/dest/utils/cross_chain.d.ts.map +1 -1
- package/dest/utils/cross_chain.js +8 -15
- package/dest/utils/node.d.ts +12 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
- package/dest/wallet/account_manager.d.ts +5 -8
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +5 -11
- package/dest/wallet/capabilities.d.ts +452 -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 +46 -7
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +33 -5
- package/dest/wallet/index.d.ts +2 -1
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -0
- package/dest/wallet/wallet.d.ts +1810 -2493
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +230 -108
- package/package.json +25 -14
- package/src/account/account.ts +34 -58
- package/src/account/account_contract.ts +6 -7
- package/src/account/account_with_secret_key.ts +33 -8
- package/src/account/index.ts +2 -1
- package/src/account/signerless_account.ts +13 -12
- package/src/api/abi.ts +1 -0
- package/src/api/account.ts +9 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +31 -9
- package/src/api/deployment.ts +0 -1
- package/src/api/events.ts +50 -32
- package/src/api/fields.ts +1 -0
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +48 -3
- package/src/contract/base_contract_interaction.ts +28 -15
- package/src/contract/batch_call.ts +20 -15
- package/src/contract/contract_function_interaction.ts +114 -26
- package/src/contract/deploy_method.ts +179 -41
- package/src/contract/get_gas_limits.ts +3 -3
- package/src/contract/interaction_options.ts +141 -23
- package/src/contract/protocol_contracts/auth-registry.ts +553 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +99 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
- package/src/contract/protocol_contracts/fee-juice.ts +266 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +336 -0
- package/src/contract/protocol_contracts/public-checks.ts +320 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/publish_class.ts +2 -2
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +17 -21
- package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
- package/src/fee/private_fee_payment_method.ts +8 -7
- package/src/fee/public_fee_payment_method.ts +9 -8
- package/src/fee/sponsored_fee_payment.ts +3 -3
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +7 -0
- package/src/utils/authwit.ts +34 -24
- package/src/utils/cross_chain.ts +9 -18
- package/src/utils/node.ts +62 -0
- package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
- package/src/wallet/account_manager.ts +5 -13
- package/src/wallet/capabilities.ts +500 -0
- package/src/wallet/deploy_account_method.ts +74 -13
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +367 -128
- package/dest/account/interface.d.ts +0 -19
- package/dest/account/interface.d.ts.map +0 -1
- package/dest/account/interface.js +0 -5
- package/dest/contract/deploy_sent_tx.d.ts +0 -48
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -46
- package/dest/contract/protocol_contracts.d.ts +0 -9
- package/dest/contract/protocol_contracts.d.ts.map +0 -1
- package/dest/contract/protocol_contracts.js +0 -26
- package/dest/contract/sent_tx.d.ts +0 -50
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -90
- package/dest/contract/unsafe_contract.d.ts +0 -15
- package/dest/contract/unsafe_contract.d.ts.map +0 -1
- package/dest/contract/unsafe_contract.js +0 -6
- package/dest/deployment/broadcast_function.d.ts +0 -24
- package/dest/deployment/broadcast_function.d.ts.map +0 -1
- package/dest/deployment/broadcast_function.js +0 -74
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -75
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/sent_tx.ts +0 -129
- package/src/contract/unsafe_contract.ts +0 -19
- package/src/deployment/broadcast_function.ts +0 -148
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TxStatus } from '@aztec/stdlib/tx';
|
|
2
|
+
|
|
3
|
+
/** Options related to waiting for a tx. */
|
|
4
|
+
export type WaitOpts = {
|
|
5
|
+
/** The amount of time to ignore TxStatus.DROPPED receipts (in seconds) due to the presumption that it is being propagated by the p2p network. Defaults to 5. */
|
|
6
|
+
ignoreDroppedReceiptsFor?: number;
|
|
7
|
+
/** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
|
|
10
|
+
interval?: number;
|
|
11
|
+
/** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
|
|
12
|
+
dontThrowOnRevert?: boolean;
|
|
13
|
+
/** The minimum inclusion status to wait for. If set, waits until the receipt reaches this status or higher. Defaults to CHECKPOINTED. */
|
|
14
|
+
waitForStatus?: TxStatus;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const DefaultWaitOpts: WaitOpts = {
|
|
18
|
+
ignoreDroppedReceiptsFor: 5,
|
|
19
|
+
timeout: 300,
|
|
20
|
+
interval: 1,
|
|
21
|
+
};
|
|
@@ -9,7 +9,7 @@ import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
|
9
9
|
import { Capsule } from '@aztec/stdlib/tx';
|
|
10
10
|
|
|
11
11
|
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
12
|
-
import {
|
|
12
|
+
import { ContractClassRegistryContract } from '../contract/protocol_contracts/contract-class-registry.js';
|
|
13
13
|
import type { Wallet } from '../wallet/index.js';
|
|
14
14
|
|
|
15
15
|
/** Sets up a call to publish a contract class given its artifact. */
|
|
@@ -19,7 +19,7 @@ export async function publishContractClass(
|
|
|
19
19
|
): Promise<ContractFunctionInteraction> {
|
|
20
20
|
const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment, packedBytecode } =
|
|
21
21
|
await getContractClassFromArtifact(artifact);
|
|
22
|
-
const classRegistry =
|
|
22
|
+
const classRegistry = ContractClassRegistryContract.at(wallet);
|
|
23
23
|
|
|
24
24
|
const encodedBytecode = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);
|
|
25
25
|
return classRegistry.methods.publish(artifactHash, privateFunctionsRoot, publicBytecodeCommitment).with({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
2
2
|
|
|
3
3
|
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ContractInstanceRegistryContract } from '../contract/protocol_contracts/contract-instance-registry.js';
|
|
5
5
|
import type { Wallet } from '../wallet/wallet.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,11 +9,8 @@ import type { Wallet } from '../wallet/wallet.js';
|
|
|
9
9
|
* @param wallet - The wallet to use for the publication (setup) tx.
|
|
10
10
|
* @param instance - The instance to publish.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
wallet
|
|
14
|
-
instance: ContractInstanceWithAddress,
|
|
15
|
-
): Promise<ContractFunctionInteraction> {
|
|
16
|
-
const contractInstanceRegistry = await getInstanceRegistryContract(wallet);
|
|
12
|
+
export function publishInstance(wallet: Wallet, instance: ContractInstanceWithAddress): ContractFunctionInteraction {
|
|
13
|
+
const contractInstanceRegistry = ContractInstanceRegistryContract.at(wallet);
|
|
17
14
|
const { salt, currentContractClassId: contractClassId, publicKeys, deployer: instanceDeployer } = instance;
|
|
18
15
|
const isUniversalDeploy = instanceDeployer.isZero();
|
|
19
16
|
return contractInstanceRegistry.methods.publish_for_public_execution(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExtendedViemWalletClient, ViemContract } from '@aztec/ethereum/types';
|
|
2
2
|
import { extractEvent } from '@aztec/ethereum/utils';
|
|
3
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import { sha256ToField } from '@aztec/foundation/crypto/sha256';
|
|
4
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -132,7 +133,7 @@ export class L1FeeJuicePortalManager {
|
|
|
132
133
|
constructor(
|
|
133
134
|
portalAddress: EthAddress,
|
|
134
135
|
tokenAddress: EthAddress,
|
|
135
|
-
handlerAddress: EthAddress,
|
|
136
|
+
handlerAddress: EthAddress | undefined,
|
|
136
137
|
private readonly extendedClient: ExtendedViemWalletClient,
|
|
137
138
|
private readonly logger: Logger,
|
|
138
139
|
) {
|
|
@@ -157,9 +158,9 @@ export class L1FeeJuicePortalManager {
|
|
|
157
158
|
*/
|
|
158
159
|
public async bridgeTokensPublic(to: AztecAddress, amount: bigint | undefined, mint = false): Promise<L2AmountClaim> {
|
|
159
160
|
const [claimSecret, claimSecretHash] = await generateClaimSecret();
|
|
160
|
-
const
|
|
161
|
-
const amountToBridge = amount ?? mintableAmount;
|
|
161
|
+
const amountToBridge = amount ?? (await this.tokenManager.getMintAmount());
|
|
162
162
|
if (mint) {
|
|
163
|
+
const mintableAmount = await this.tokenManager.getMintAmount();
|
|
163
164
|
if (amountToBridge !== mintableAmount) {
|
|
164
165
|
throw new Error(`Minting amount must be ${mintableAmount}`);
|
|
165
166
|
}
|
|
@@ -233,17 +234,12 @@ export class L1FeeJuicePortalManager {
|
|
|
233
234
|
if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
|
|
234
235
|
throw new Error('Portal or token not deployed on L1');
|
|
235
236
|
}
|
|
236
|
-
if (!feeAssetHandlerAddress || feeAssetHandlerAddress.isZero()) {
|
|
237
|
-
throw new Error('Handler not deployed on L1, or handler address is zero');
|
|
238
|
-
}
|
|
239
237
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
logger,
|
|
246
|
-
);
|
|
238
|
+
// Handler is optional - it's only needed for minting tokens during testing
|
|
239
|
+
const handlerAddress =
|
|
240
|
+
feeAssetHandlerAddress && !feeAssetHandlerAddress.isZero() ? feeAssetHandlerAddress : undefined;
|
|
241
|
+
|
|
242
|
+
return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, handlerAddress, extendedClient, logger);
|
|
247
243
|
}
|
|
248
244
|
}
|
|
249
245
|
|
|
@@ -413,26 +409,26 @@ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
|
413
409
|
* Withdraws funds from the portal by consuming an L2 to L1 message. Returns once the tx is mined on L1.
|
|
414
410
|
* @param amount - Amount to withdraw.
|
|
415
411
|
* @param recipient - Who will receive the funds.
|
|
416
|
-
* @param
|
|
412
|
+
* @param epochNumber - Epoch number of the message.
|
|
417
413
|
* @param messageIndex - Index of the message.
|
|
418
414
|
* @param siblingPath - Sibling path of the message.
|
|
419
415
|
*/
|
|
420
416
|
public async withdrawFunds(
|
|
421
417
|
amount: bigint,
|
|
422
418
|
recipient: EthAddress,
|
|
423
|
-
|
|
419
|
+
epochNumber: EpochNumber,
|
|
424
420
|
messageIndex: bigint,
|
|
425
421
|
siblingPath: SiblingPath<number>,
|
|
426
422
|
) {
|
|
427
423
|
this.logger.info(
|
|
428
|
-
`Sending L1 tx to consume message at
|
|
424
|
+
`Sending L1 tx to consume message at epoch ${epochNumber} index ${messageIndex} to withdraw ${amount}`,
|
|
429
425
|
);
|
|
430
426
|
|
|
431
427
|
const messageLeafId = getL2ToL1MessageLeafId({ leafIndex: messageIndex, siblingPath });
|
|
432
|
-
const isConsumedBefore = await this.outbox.read.
|
|
428
|
+
const isConsumedBefore = await this.outbox.read.hasMessageBeenConsumedAtEpoch([BigInt(epochNumber), messageLeafId]);
|
|
433
429
|
if (isConsumedBefore) {
|
|
434
430
|
throw new Error(
|
|
435
|
-
`
|
|
431
|
+
`L2 to L1 message at epoch ${epochNumber} index ${messageIndex} height ${siblingPath.pathSize} has already been consumed`,
|
|
436
432
|
);
|
|
437
433
|
}
|
|
438
434
|
|
|
@@ -441,7 +437,7 @@ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
|
441
437
|
recipient.toString(),
|
|
442
438
|
amount,
|
|
443
439
|
false,
|
|
444
|
-
BigInt(
|
|
440
|
+
BigInt(epochNumber),
|
|
445
441
|
messageIndex,
|
|
446
442
|
siblingPath.toBufferArray().map((buf: Buffer): Hex => `0x${buf.toString('hex')}`),
|
|
447
443
|
]);
|
|
@@ -450,10 +446,10 @@ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
|
|
|
450
446
|
hash: await this.extendedClient.writeContract(withdrawRequest),
|
|
451
447
|
});
|
|
452
448
|
|
|
453
|
-
const isConsumedAfter = await this.outbox.read.
|
|
449
|
+
const isConsumedAfter = await this.outbox.read.hasMessageBeenConsumedAtEpoch([BigInt(epochNumber), messageLeafId]);
|
|
454
450
|
if (!isConsumedAfter) {
|
|
455
451
|
throw new Error(
|
|
456
|
-
`
|
|
452
|
+
`L2 to L1 message at epoch ${epochNumber} index ${messageIndex} height ${siblingPath.pathSize} not consumed after withdrawal`,
|
|
457
453
|
);
|
|
458
454
|
}
|
|
459
455
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
+
import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
6
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -27,10 +27,11 @@ export class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
|
|
|
27
27
|
|
|
28
28
|
return new ExecutionPayload(
|
|
29
29
|
[
|
|
30
|
-
{
|
|
31
|
-
to: ProtocolContractAddress.FeeJuice,
|
|
30
|
+
FunctionCall.from({
|
|
32
31
|
name: 'claim_and_end_setup',
|
|
32
|
+
to: ProtocolContractAddress.FeeJuice,
|
|
33
33
|
selector,
|
|
34
|
+
type: FunctionType.PRIVATE,
|
|
34
35
|
hideMsgSender: false,
|
|
35
36
|
isStatic: false,
|
|
36
37
|
args: [
|
|
@@ -40,8 +41,7 @@ export class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
|
|
|
40
41
|
new Fr(this.claim.messageLeafIndex),
|
|
41
42
|
],
|
|
42
43
|
returnTypes: [],
|
|
43
|
-
|
|
44
|
-
},
|
|
44
|
+
}),
|
|
45
45
|
],
|
|
46
46
|
[],
|
|
47
47
|
[],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
+
import { type FunctionAbi, FunctionCall, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -10,6 +10,7 @@ import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Holds information about how the fee for a transaction is to be paid.
|
|
13
|
+
* @deprecated Is not supported on mainnet. Use {@link FeeJuicePaymentMethodWithClaim} or `SponsoredFeePaymentMethod` instead.
|
|
13
14
|
*/
|
|
14
15
|
export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
15
16
|
private assetPromise: Promise<AztecAddress> | null = null;
|
|
@@ -102,21 +103,21 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
102
103
|
|
|
103
104
|
const witness = await this.wallet.createAuthWit(this.sender, {
|
|
104
105
|
caller: this.paymentContract,
|
|
105
|
-
call: {
|
|
106
|
+
call: FunctionCall.from({
|
|
106
107
|
name: 'transfer_to_public',
|
|
107
|
-
|
|
108
|
+
to: await this.getAsset(),
|
|
108
109
|
selector: await FunctionSelector.fromSignature('transfer_to_public((Field),(Field),u128,Field)'),
|
|
109
110
|
type: FunctionType.PRIVATE,
|
|
110
111
|
hideMsgSender: false,
|
|
111
112
|
isStatic: false,
|
|
112
|
-
|
|
113
|
+
args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
|
|
113
114
|
returnTypes: [],
|
|
114
|
-
},
|
|
115
|
+
}),
|
|
115
116
|
});
|
|
116
117
|
|
|
117
118
|
return new ExecutionPayload(
|
|
118
119
|
[
|
|
119
|
-
{
|
|
120
|
+
FunctionCall.from({
|
|
120
121
|
name: 'fee_entrypoint_private',
|
|
121
122
|
to: this.paymentContract,
|
|
122
123
|
selector: await FunctionSelector.fromSignature('fee_entrypoint_private(u128,Field)'),
|
|
@@ -125,7 +126,7 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
125
126
|
isStatic: false,
|
|
126
127
|
args: [maxFee, txNonce],
|
|
127
128
|
returnTypes: [],
|
|
128
|
-
},
|
|
129
|
+
}),
|
|
129
130
|
],
|
|
130
131
|
[witness],
|
|
131
132
|
[],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
+
import { type FunctionAbi, FunctionCall, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -11,6 +11,7 @@ import type { FeePaymentMethod } from './fee_payment_method.js';
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Holds information about how the fee for a transaction is to be paid.
|
|
14
|
+
* @deprecated Is not supported on mainnet. Use {@link FeeJuicePaymentMethodWithClaim} or `SponsoredFeePaymentMethod` instead.
|
|
14
15
|
*/
|
|
15
16
|
export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
16
17
|
private assetPromise: Promise<AztecAddress> | null = null;
|
|
@@ -94,16 +95,16 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
94
95
|
|
|
95
96
|
const intent = {
|
|
96
97
|
caller: this.paymentContract,
|
|
97
|
-
call: {
|
|
98
|
+
call: FunctionCall.from({
|
|
98
99
|
name: 'transfer_in_public',
|
|
99
|
-
|
|
100
|
+
to: await this.getAsset(),
|
|
100
101
|
selector: await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),u128,Field)'),
|
|
101
102
|
type: FunctionType.PUBLIC,
|
|
102
|
-
isStatic: false,
|
|
103
103
|
hideMsgSender: false /** The target function performs an authwit check, so msg_sender is needed */,
|
|
104
|
-
|
|
104
|
+
isStatic: false,
|
|
105
|
+
args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
|
|
105
106
|
returnTypes: [],
|
|
106
|
-
},
|
|
107
|
+
}),
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
const setPublicAuthWitInteraction = await SetPublicAuthwitContractInteraction.create(
|
|
@@ -116,7 +117,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
116
117
|
return new ExecutionPayload(
|
|
117
118
|
[
|
|
118
119
|
...(await setPublicAuthWitInteraction.request()).calls,
|
|
119
|
-
{
|
|
120
|
+
FunctionCall.from({
|
|
120
121
|
name: 'fee_entrypoint_public',
|
|
121
122
|
to: this.paymentContract,
|
|
122
123
|
selector: await FunctionSelector.fromSignature('fee_entrypoint_public(u128,Field)'),
|
|
@@ -125,7 +126,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
125
126
|
isStatic: false,
|
|
126
127
|
args: [maxFee, txNonce],
|
|
127
128
|
returnTypes: [],
|
|
128
|
-
},
|
|
129
|
+
}),
|
|
129
130
|
],
|
|
130
131
|
[],
|
|
131
132
|
[],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
2
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
2
|
+
import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -22,7 +22,7 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
|
22
22
|
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
23
23
|
return new ExecutionPayload(
|
|
24
24
|
[
|
|
25
|
-
{
|
|
25
|
+
FunctionCall.from({
|
|
26
26
|
name: 'sponsor_unconditionally',
|
|
27
27
|
to: this.paymentContract,
|
|
28
28
|
selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
|
|
@@ -31,7 +31,7 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
|
31
31
|
isStatic: false,
|
|
32
32
|
args: [],
|
|
33
33
|
returnTypes: [],
|
|
34
|
-
},
|
|
34
|
+
}),
|
|
35
35
|
],
|
|
36
36
|
[],
|
|
37
37
|
[],
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates type-safe contract wrappers for protocol contracts.
|
|
3
|
+
* These wrappers use a minimal artifact (without bytecode) since PXE already has the full artifacts registered.
|
|
4
|
+
*/
|
|
5
|
+
import { generateTypescriptContractInterface } from '@aztec/builder/codegen';
|
|
6
|
+
import {
|
|
7
|
+
type ContractArtifact,
|
|
8
|
+
type FunctionAbi,
|
|
9
|
+
FunctionType,
|
|
10
|
+
getAllFunctionAbis,
|
|
11
|
+
loadContractArtifact,
|
|
12
|
+
} from '@aztec/stdlib/abi';
|
|
13
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
14
|
+
|
|
15
|
+
import { promises as fs } from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
|
|
18
|
+
const log = console.log;
|
|
19
|
+
|
|
20
|
+
const noirContractsRoot = path.join(import.meta.dirname, '../../../../noir-projects/noir-contracts');
|
|
21
|
+
const srcPath = path.join(noirContractsRoot, 'target');
|
|
22
|
+
const outputDir = path.join(import.meta.dirname, '../contract/protocol_contracts');
|
|
23
|
+
|
|
24
|
+
function toKebabCase(str: string): string {
|
|
25
|
+
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function functionTypeToEnum(type: FunctionType): string {
|
|
29
|
+
switch (type) {
|
|
30
|
+
case FunctionType.PRIVATE:
|
|
31
|
+
return 'FunctionType.PRIVATE';
|
|
32
|
+
case FunctionType.PUBLIC:
|
|
33
|
+
return 'FunctionType.PUBLIC';
|
|
34
|
+
case FunctionType.UTILITY:
|
|
35
|
+
return 'FunctionType.UTILITY';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function generateFunctionAbiJson(abi: FunctionAbi): string {
|
|
40
|
+
const baseObj = {
|
|
41
|
+
name: abi.name,
|
|
42
|
+
isOnlySelf: abi.isOnlySelf,
|
|
43
|
+
isStatic: abi.isStatic,
|
|
44
|
+
isInitializer: abi.isInitializer,
|
|
45
|
+
parameters: abi.parameters,
|
|
46
|
+
returnTypes: abi.returnTypes,
|
|
47
|
+
errorTypes: abi.errorTypes,
|
|
48
|
+
};
|
|
49
|
+
const jsonStr = JSON.stringify(baseObj);
|
|
50
|
+
return jsonStr.replace('{', `{ functionType: ${functionTypeToEnum(abi.functionType)},`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function generateProtocolContractArtifact(input: ContractArtifact): string {
|
|
54
|
+
const allAbis = getAllFunctionAbis(input);
|
|
55
|
+
const functionAbis = input.functions.map(f => allAbis.find(abi => abi.name === f.name)!);
|
|
56
|
+
const nonDispatchAbis = input.nonDispatchPublicFunctions;
|
|
57
|
+
|
|
58
|
+
const functionsArray = functionAbis
|
|
59
|
+
.map(abi => `{ ...${generateFunctionAbiJson(abi)}, bytecode: Buffer.from([]), debugSymbols: '' }`)
|
|
60
|
+
.join(',\n ');
|
|
61
|
+
|
|
62
|
+
const nonDispatchArray = nonDispatchAbis.map(abi => generateFunctionAbiJson(abi)).join(',\n ');
|
|
63
|
+
|
|
64
|
+
return `{
|
|
65
|
+
name: '${input.name}',
|
|
66
|
+
functions: [
|
|
67
|
+
${functionsArray}
|
|
68
|
+
],
|
|
69
|
+
nonDispatchPublicFunctions: [
|
|
70
|
+
${nonDispatchArray}
|
|
71
|
+
],
|
|
72
|
+
outputs: { structs: {}, globals: {} },
|
|
73
|
+
storageLayout: {},
|
|
74
|
+
fileMap: {},
|
|
75
|
+
}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function generateProtocolContractInterface(
|
|
79
|
+
input: ContractArtifact,
|
|
80
|
+
protocolContractName: string,
|
|
81
|
+
): Promise<string> {
|
|
82
|
+
const baseInterface = await generateTypescriptContractInterface(input);
|
|
83
|
+
|
|
84
|
+
// Match everything between "public declare methods: {" and the closing "};"
|
|
85
|
+
const methodsMatch = baseInterface.match(/public declare methods: \{([\s\S]*?)\n \};/);
|
|
86
|
+
if (!methodsMatch) {
|
|
87
|
+
throw new Error('Could not extract methods from generated interface');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const artifactCode = generateProtocolContractArtifact(input);
|
|
91
|
+
const contractName = `${input.name}Contract`;
|
|
92
|
+
|
|
93
|
+
return `
|
|
94
|
+
/* Autogenerated file, do not edit! */
|
|
95
|
+
|
|
96
|
+
/* eslint-disable */
|
|
97
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
98
|
+
import { FunctionType } from '@aztec/stdlib/abi';
|
|
99
|
+
|
|
100
|
+
import type { ContractArtifact } from '../../api/abi.js';
|
|
101
|
+
import { PublicKeys } from '../../api/keys.js';
|
|
102
|
+
import type { AztecAddressLike, EthAddressLike, FieldLike, FunctionSelectorLike, WrappedFieldLike } from '../../utils/abi_types.js';
|
|
103
|
+
import { ContractBase, type ContractMethod } from '../contract_base.js';
|
|
104
|
+
import { ContractFunctionInteraction } from '../contract_function_interaction.js';
|
|
105
|
+
import type { Wallet } from '../../wallet/wallet.js';
|
|
106
|
+
|
|
107
|
+
const ${contractName}Artifact: ContractArtifact = ${artifactCode};
|
|
108
|
+
|
|
109
|
+
export class ${contractName} extends ContractBase {
|
|
110
|
+
private constructor(wallet: Wallet) {
|
|
111
|
+
super(ProtocolContractAddress.${protocolContractName}, ${contractName}Artifact, wallet);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public static at(wallet: Wallet): ${contractName} {
|
|
115
|
+
return new ${contractName}(wallet);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public declare methods: {${methodsMatch[1]}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function main() {
|
|
125
|
+
await fs.rm(outputDir, { recursive: true, force: true });
|
|
126
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
127
|
+
|
|
128
|
+
const srcNames = JSON.parse(
|
|
129
|
+
await fs.readFile(path.join(noirContractsRoot, 'protocol_contracts.json'), 'utf8'),
|
|
130
|
+
) as string[];
|
|
131
|
+
|
|
132
|
+
for (const srcName of srcNames) {
|
|
133
|
+
// srcName is like "auth_registry_contract-AuthRegistry", split to get the contract name
|
|
134
|
+
const name = srcName.split('-')[1];
|
|
135
|
+
const artifactPath = path.join(srcPath, `${srcName}.json`);
|
|
136
|
+
const json = JSON.parse(await fs.readFile(artifactPath, 'utf8')) as NoirCompiledContract;
|
|
137
|
+
const contractArtifact = loadContractArtifact(json);
|
|
138
|
+
|
|
139
|
+
const content = await generateProtocolContractInterface(contractArtifact, name);
|
|
140
|
+
const fileName = `${toKebabCase(name)}.ts`;
|
|
141
|
+
await fs.writeFile(path.join(outputDir, fileName), content);
|
|
142
|
+
|
|
143
|
+
log(`Generated ${fileName}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
main().catch(err => {
|
|
148
|
+
console.error('Error generating protocol contract types:', err);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
});
|
package/src/utils/abi_types.ts
CHANGED
|
@@ -23,3 +23,10 @@ export type U128Like = bigint | number;
|
|
|
23
23
|
|
|
24
24
|
/** Any type that can be converted into a struct with a single `inner` field. */
|
|
25
25
|
export type WrappedFieldLike = { /** Wrapped value */ inner: FieldLike } | FieldLike;
|
|
26
|
+
|
|
27
|
+
/** Noir `Option<T>` lowered ABI shape, plus ergonomic direct `T | null | undefined` inputs. */
|
|
28
|
+
export type OptionLike<T> =
|
|
29
|
+
| T
|
|
30
|
+
| null
|
|
31
|
+
| undefined
|
|
32
|
+
| { /** Whether the option is populated */ _is_some: boolean; /** Wrapped value */ _value: T };
|
package/src/utils/authwit.ts
CHANGED
|
@@ -9,12 +9,15 @@ import type { TxProfileResult } from '@aztec/stdlib/tx';
|
|
|
9
9
|
|
|
10
10
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
11
11
|
import type {
|
|
12
|
+
InteractionWaitOptions,
|
|
12
13
|
ProfileInteractionOptions,
|
|
13
14
|
SendInteractionOptions,
|
|
15
|
+
SendInteractionOptionsWithoutWait,
|
|
16
|
+
SendReturn,
|
|
14
17
|
SimulateInteractionOptions,
|
|
15
|
-
|
|
18
|
+
SimulationResult,
|
|
19
|
+
TxSendResultMined,
|
|
16
20
|
} from '../contract/interaction_options.js';
|
|
17
|
-
import type { SentTx } from '../contract/sent_tx.js';
|
|
18
21
|
import type { Wallet } from '../wallet/index.js';
|
|
19
22
|
|
|
20
23
|
/** Intent with an inner hash */
|
|
@@ -42,7 +45,7 @@ export type ContractFunctionInteractionCallIntent = {
|
|
|
42
45
|
};
|
|
43
46
|
|
|
44
47
|
/** Identifies ContractFunctionInteractionCallIntents */
|
|
45
|
-
function
|
|
48
|
+
export function isContractFunctionInteractionCallIntent(
|
|
46
49
|
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
47
50
|
): messageHashOrIntent is ContractFunctionInteractionCallIntent {
|
|
48
51
|
return (
|
|
@@ -81,7 +84,7 @@ export const computeAuthWitMessageHash = async (
|
|
|
81
84
|
const version = metadata.version;
|
|
82
85
|
|
|
83
86
|
if ('caller' in intent) {
|
|
84
|
-
const call =
|
|
87
|
+
const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
|
|
85
88
|
return computeOuterAuthWitHash(
|
|
86
89
|
call.to,
|
|
87
90
|
chainId,
|
|
@@ -154,7 +157,7 @@ export async function lookupValidity(
|
|
|
154
157
|
}> {
|
|
155
158
|
let innerHash, consumer;
|
|
156
159
|
if ('caller' in intent) {
|
|
157
|
-
const call =
|
|
160
|
+
const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
|
|
158
161
|
innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
|
|
159
162
|
consumer = call.to;
|
|
160
163
|
} else {
|
|
@@ -187,10 +190,12 @@ export async function lookupValidity(
|
|
|
187
190
|
errorTypes: {},
|
|
188
191
|
} as FunctionAbi;
|
|
189
192
|
try {
|
|
190
|
-
results.isValidInPrivate = (
|
|
191
|
-
consumer,
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
results.isValidInPrivate = (
|
|
194
|
+
await new ContractFunctionInteraction(wallet, onBehalfOf, lookupValidityAbi, [consumer, innerHash]).simulate({
|
|
195
|
+
from: onBehalfOf,
|
|
196
|
+
authWitnesses: [witness],
|
|
197
|
+
})
|
|
198
|
+
).result as boolean;
|
|
194
199
|
// TODO: Narrow down the error to make sure simulation failed due to an invalid authwit
|
|
195
200
|
// eslint-disable-next-line no-empty
|
|
196
201
|
} catch {}
|
|
@@ -217,12 +222,12 @@ export async function lookupValidity(
|
|
|
217
222
|
returnTypes: [{ kind: 'boolean' }],
|
|
218
223
|
errorTypes: {},
|
|
219
224
|
} as FunctionAbi;
|
|
220
|
-
results.isValidInPublic = (
|
|
221
|
-
wallet,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
).
|
|
225
|
+
results.isValidInPublic = (
|
|
226
|
+
await new ContractFunctionInteraction(wallet, ProtocolContractAddress.AuthRegistry, isConsumableAbi, [
|
|
227
|
+
onBehalfOf,
|
|
228
|
+
messageHash,
|
|
229
|
+
]).simulate({ from: onBehalfOf })
|
|
230
|
+
).result as boolean;
|
|
226
231
|
|
|
227
232
|
return results;
|
|
228
233
|
}
|
|
@@ -260,14 +265,10 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
260
265
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
261
266
|
* @returns The result of the transaction as returned by the contract function.
|
|
262
267
|
*/
|
|
263
|
-
public override simulate<T extends SimulateInteractionOptions>(
|
|
264
|
-
options: Omit<T, 'from'>,
|
|
265
|
-
): Promise<SimulationReturn<T['includeMetadata']>>;
|
|
266
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
267
268
|
public override simulate(
|
|
268
|
-
options: Omit<SimulateInteractionOptions, 'from'> = {},
|
|
269
|
-
): Promise<
|
|
270
|
-
return super.simulate({ ...options, from: this.from });
|
|
269
|
+
options: Omit<SimulateInteractionOptions, 'from'> = {} as Omit<SimulateInteractionOptions, 'from'>,
|
|
270
|
+
): Promise<SimulationResult> {
|
|
271
|
+
return super.simulate({ ...options, from: this.from } as SimulateInteractionOptions);
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
/**
|
|
@@ -286,9 +287,18 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
286
287
|
* Overrides the send method, adding the sender of the authwit (authorizer) as from
|
|
287
288
|
* and preventing misuse
|
|
288
289
|
* @param options - An optional object containing 'fee' options information
|
|
289
|
-
* @returns A
|
|
290
|
+
* @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
|
|
290
291
|
*/
|
|
291
|
-
public override send(options
|
|
292
|
+
public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxSendResultMined>;
|
|
293
|
+
// Generic overload for explicit wait values
|
|
294
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
295
|
+
public override send<W extends InteractionWaitOptions>(
|
|
296
|
+
options?: Omit<SendInteractionOptions<W>, 'from'>,
|
|
297
|
+
): Promise<SendReturn<W>>;
|
|
298
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
299
|
+
public override send(
|
|
300
|
+
options?: Omit<SendInteractionOptions<InteractionWaitOptions>, 'from'>,
|
|
301
|
+
): Promise<SendReturn<InteractionWaitOptions>> {
|
|
292
302
|
return super.send({ ...options, from: this.from });
|
|
293
303
|
}
|
|
294
304
|
|
package/src/utils/cross_chain.ts
CHANGED
|
@@ -8,17 +8,15 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
8
8
|
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
9
9
|
* @param opts - Options
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
12
|
-
node: Pick<AztecNode, '
|
|
11
|
+
export function waitForL1ToL2MessageReady(
|
|
12
|
+
node: Pick<AztecNode, 'getBlock' | 'getL1ToL2MessageCheckpoint'>,
|
|
13
13
|
l1ToL2MessageHash: Fr,
|
|
14
14
|
opts: {
|
|
15
15
|
/** Timeout for the operation in seconds */ timeoutSeconds: number;
|
|
16
|
-
/** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
|
|
17
16
|
},
|
|
18
17
|
) {
|
|
19
|
-
const messageBlockNumber = await node.getL1ToL2MessageBlock(l1ToL2MessageHash);
|
|
20
18
|
return retryUntil(
|
|
21
|
-
() => isL1ToL2MessageReady(node, l1ToL2MessageHash
|
|
19
|
+
() => isL1ToL2MessageReady(node, l1ToL2MessageHash),
|
|
22
20
|
`L1 to L2 message ${l1ToL2MessageHash.toString()} ready`,
|
|
23
21
|
opts.timeoutSeconds,
|
|
24
22
|
1,
|
|
@@ -29,25 +27,18 @@ export async function waitForL1ToL2MessageReady(
|
|
|
29
27
|
* Returns whether the L1 to L2 message is ready to be consumed.
|
|
30
28
|
* @param node - Aztec node instance used to obtain the information about the message
|
|
31
29
|
* @param l1ToL2MessageHash - Hash of the L1 to L2 message
|
|
32
|
-
* @param opts - Options
|
|
33
30
|
* @returns True if the message is ready to be consumed, false otherwise
|
|
34
31
|
*/
|
|
35
32
|
export async function isL1ToL2MessageReady(
|
|
36
|
-
node: Pick<AztecNode, '
|
|
33
|
+
node: Pick<AztecNode, 'getBlock' | 'getL1ToL2MessageCheckpoint'>,
|
|
37
34
|
l1ToL2MessageHash: Fr,
|
|
38
|
-
opts: {
|
|
39
|
-
/** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
|
|
40
|
-
/** Cached synced block number for the message (will be fetched from PXE otherwise) */ messageBlockNumber?: number;
|
|
41
|
-
},
|
|
42
35
|
): Promise<boolean> {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
if (messageBlockNumber === undefined) {
|
|
36
|
+
const messageCheckpointNumber = await node.getL1ToL2MessageCheckpoint(l1ToL2MessageHash);
|
|
37
|
+
if (messageCheckpointNumber === undefined) {
|
|
46
38
|
return false;
|
|
47
39
|
}
|
|
48
40
|
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return opts.forPublicConsumption ? blockNumber + 1 >= messageBlockNumber : blockNumber >= messageBlockNumber;
|
|
41
|
+
// L1 to L2 messages are included in the first block of a checkpoint
|
|
42
|
+
const latestBlock = await node.getBlock('latest');
|
|
43
|
+
return latestBlock !== undefined && latestBlock.checkpointNumber >= messageCheckpointNumber;
|
|
53
44
|
}
|