Skip to content

Commit 097bcd4

Browse files
authored
chore!: move protocol contracts out of noir-contracts.js (#24998)
With this change, these files are served instead through the protocol contracts package (where they already existed). I changed the generation of noir-contracts.js so that only non-protocol non-test contracts go there, so it is now ready for the noir side of things to also be split.
1 parent d280b82 commit 097bcd4

22 files changed

Lines changed: 65 additions & 53 deletions

File tree

docs/docs-developers/docs/resources/migration_notes.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,33 @@ Aztec is in active development. Each version may introduce breaking changes that
99

1010
## TBD
1111

12+
### [Aztec.js] Protocol contracts removed from `@aztec/noir-contracts.js`
13+
14+
`@aztec/noir-contracts.js` no longer includes the protocol contracts: the `FeeJuice`, `ContractClassRegistry`, and `ContractInstanceRegistry` artifacts and typed wrappers have been removed from the package, so imports such as `@aztec/noir-contracts.js/FeeJuice` no longer resolve. These names are also no longer available to the `aztec` CLI's contract-name lookup (e.g. in `aztec example-contracts`).
15+
16+
Protocol contracts are distributed via `@aztec/protocol-contracts` (artifacts and canonical deployment data), and typed wrappers for them are exported from `@aztec/aztec.js/protocol`. The `aztec.js` wrappers are bound to the contract's canonical address, so attaching takes only the wallet: there is no address parameter.
17+
18+
**Migration:**
19+
20+
```diff
21+
- import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
22+
+ import { FeeJuiceContract } from '@aztec/aztec.js/protocol';
23+
24+
- const feeJuice = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
25+
+ const feeJuice = FeeJuiceContract.withWallet(wallet);
26+
```
27+
28+
### [Aztec.js] Protocol contract wrappers: `at(wallet)` deprecated in favor of `withWallet(wallet)`
29+
30+
The protocol contract wrappers exported from `@aztec/aztec.js/protocol` (`FeeJuiceContract`, `ContractClassRegistryContract`, `ContractInstanceRegistryContract`) rename their static `at(wallet)` to `withWallet(wallet)`. These wrappers are bound to the contract's canonical address, so their only parameter is the wallet to act through; `withWallet` states that directly and matches the existing `withWallet` instance method, whereas the one-argument `at` read as if it took an address. `at(wallet)` still works but is deprecated and will be removed in a future release.
31+
32+
**Migration:**
33+
34+
```diff
35+
- const feeJuice = FeeJuiceContract.at(wallet);
36+
+ const feeJuice = FeeJuiceContract.withWallet(wallet);
37+
```
38+
1239
### [Aztec.nr] Standard contracts re-pinned at new addresses
1340

1441
The canonical `HandshakeRegistry` now protects handshake shared secrets from recipient forgery and includes the owner's address in its `PrivateMutable` initialization nullifiers, keeping the handshake state of accounts that share keys independent. All standard contracts have been re-pinned and move to new addresses. Handshakes established with a previous registry instance are not visible to the new one and must be re-established.

yarn-project/archiver/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
"@aztec/foundation": "workspace:^",
7474
"@aztec/kv-store": "workspace:^",
7575
"@aztec/l1-artifacts": "0.1.0-dummy",
76-
"@aztec/noir-protocol-circuits-types": "workspace:^",
7776
"@aztec/protocol-contracts": "workspace:^",
7877
"@aztec/standard-contracts": "workspace:^",
7978
"@aztec/stdlib": "workspace:^",

yarn-project/archiver/tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
{
2828
"path": "../kv-store"
2929
},
30-
{
31-
"path": "../noir-protocol-circuits-types"
32-
},
3330
{
3431
"path": "../protocol-contracts"
3532
},

yarn-project/aztec-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"@aztec/l1-artifacts": "0.1.0-dummy",
7979
"@aztec/node-keystore": "workspace:^",
8080
"@aztec/node-lib": "workspace:^",
81-
"@aztec/noir-protocol-circuits-types": "workspace:^",
8281
"@aztec/p2p": "workspace:^",
8382
"@aztec/protocol-contracts": "workspace:^",
8483
"@aztec/prover-client": "workspace:^",
@@ -98,6 +97,7 @@
9897
"viem": "npm:@aztec/viem@2.38.2"
9998
},
10099
"devDependencies": {
100+
"@aztec/noir-protocol-circuits-types": "workspace:^",
101101
"@jest/globals": "^30.0.0",
102102
"@types/jest": "^30.0.0",
103103
"@types/node": "^22.15.17",

yarn-project/aztec-node/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
{
4040
"path": "../node-lib"
4141
},
42-
{
43-
"path": "../noir-protocol-circuits-types"
44-
},
4542
{
4643
"path": "../p2p"
4744
},
@@ -80,6 +77,9 @@
8077
},
8178
{
8279
"path": "../world-state"
80+
},
81+
{
82+
"path": "../noir-protocol-circuits-types"
8383
}
8484
],
8585
"include": ["src"]

yarn-project/aztec.js/src/deployment/publish_class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function publishContractClass(
1919
): Promise<ContractFunctionInteraction> {
2020
const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment, packedBytecode } =
2121
await getContractClassFromArtifact(artifact);
22-
const classRegistry = ContractClassRegistryContract.at(wallet);
22+
const classRegistry = ContractClassRegistryContract.withWallet(wallet);
2323

2424
const encodedBytecode = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);
2525
return classRegistry.methods.publish(artifactHash, privateFunctionsRoot, publicBytecodeCommitment).with({

yarn-project/aztec.js/src/deployment/publish_instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Wallet } from '../wallet/wallet.js';
1010
* @param instance - The instance to publish.
1111
*/
1212
export function publishInstance(wallet: Wallet, instance: ContractInstanceWithAddress): ContractFunctionInteraction {
13-
const contractInstanceRegistry = ContractInstanceRegistryContract.at(wallet);
13+
const contractInstanceRegistry = ContractInstanceRegistryContract.withWallet(wallet);
1414
const { salt, currentContractClassId: contractClassId, publicKeys, deployer: instanceDeployer } = instance;
1515
const isUniversalDeploy = instanceDeployer.isZero();
1616
return contractInstanceRegistry.methods.publish_for_public_execution(

yarn-project/aztec.js/src/scripts/generate_protocol_contract_types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,16 @@ export class ${contractName} extends ContractBase {
112112
super(ProtocolContractAddress.${protocolContractName}, ${contractName}Artifact, wallet);
113113
}
114114
115-
public static at(wallet: Wallet): ${contractName} {
115+
/** Returns an interface to the canonical ${contractName} instance, bound to the given wallet. */
116+
public static withWallet(wallet: Wallet): ${contractName} {
116117
return new ${contractName}(wallet);
117118
}
118119
120+
/** @deprecated Use \`withWallet\` instead. */
121+
public static at(wallet: Wallet): ${contractName} {
122+
return ${contractName}.withWallet(wallet);
123+
}
124+
119125
public declare methods: {${methodsMatch[1]}
120126
};
121127
}

yarn-project/end-to-end/src/bench/client_flows/client_flows_benchmark.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
44
import { type FeePaymentMethod, PrivateFeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
55
import { type Logger, createLogger } from '@aztec/aztec.js/log';
66
import type { AztecNode } from '@aztec/aztec.js/node';
7+
import { FeeJuiceContract } from '@aztec/aztec.js/protocol';
78
import type { Wallet } from '@aztec/aztec.js/wallet';
89
import { CheatCodes, getTokenAllowedSetupFunctions } from '@aztec/aztec/testing';
910
import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -19,11 +20,8 @@ import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
1920
import { TestERC20Bytecode } from '@aztec/l1-artifacts/TestERC20Bytecode';
2021
import { AMMContract } from '@aztec/noir-contracts.js/AMM';
2122
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
22-
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
2323
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
2424
import { TestTokenContract as BananaCoin, TestTokenContract } from '@aztec/noir-test-contracts.js/TestToken';
25-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
26-
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
2725
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
2826
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
2927
import { Gas, GasSettings } from '@aztec/stdlib/gas';
@@ -218,8 +216,7 @@ export class ClientFlowsBenchmark {
218216
this.adminAddress = adminAddress;
219217
this.sequencerAddress = sequencerAddress;
220218

221-
const canonicalFeeJuice = await getCanonicalFeeJuice();
222-
this.feeJuiceContract = FeeJuiceContract.at(canonicalFeeJuice.address, this.adminWallet);
219+
this.feeJuiceContract = FeeJuiceContract.withWallet(this.adminWallet);
223220
this.coinbase = EthAddress.random();
224221

225222
const userPXEConfig = getPXEConfig();
@@ -250,7 +247,7 @@ export class ClientFlowsBenchmark {
250247

251248
async applySetupFeeJuice() {
252249
this.logger.info('Applying fee juice setup');
253-
this.feeJuiceContract = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.adminWallet);
250+
this.feeJuiceContract = FeeJuiceContract.withWallet(this.adminWallet);
254251

255252
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
256253
aztecNode: this.context.aztecNodeService,

yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { L1FeeJuicePortalManager, type L1TokenManager, type L2AmountClaim } from
33
import { Fr } from '@aztec/aztec.js/fields';
44
import type { Logger } from '@aztec/aztec.js/log';
55
import type { AztecNode } from '@aztec/aztec.js/node';
6+
import { FeeJuiceContract } from '@aztec/aztec.js/protocol';
67
import type { Wallet } from '@aztec/aztec.js/wallet';
78
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
89
import { retryUntil } from '@aztec/foundation/retry';
9-
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
10-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
1110
import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
1211

1312
import { testSpan } from '../fixtures/timing.js';
@@ -49,7 +48,7 @@ export class FeeJuicePortalTestingHarnessFactory {
4948
throw new Error('Fee Juice portal not deployed on L1');
5049
}
5150

52-
const gasL2 = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
51+
const gasL2 = FeeJuiceContract.withWallet(wallet);
5352

5453
return new GasBridgingTestHarness(
5554
aztecNode,

0 commit comments

Comments
 (0)