Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Apr 19, 2024
1 parent 72ca505 commit 3da10c1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 40 deletions.
22 changes: 1 addition & 21 deletions yarn-project/aztec/src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
RollupBytecode,
} from '@aztec/l1-artifacts';
import { getCanonicalGasToken } from '@aztec/protocol-contracts/gas-token';
import { getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry';
import { deployCanonicalKeyRegistry, getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry';
import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe';

import {
Expand Down Expand Up @@ -183,26 +183,6 @@ async function deployCanonicalL2GasToken(deployer: Wallet, l1ContractAddresses:
logger.info(`Deployed Gas Token on L2 at ${canonicalGasToken.address}`);
}

/**
* Deploys the contract to pay for gas on L2.
*/
async function deployCanonicalKeyRegistry(deployer: Wallet) {
const canonicalKeyRegistry = getCanonicalKeyRegistry();

if (await deployer.isContractClassPubliclyRegistered(canonicalKeyRegistry.contractClass.id)) {
return;
}

const batch = new BatchCall(deployer, [
(await registerContractClass(deployer, canonicalKeyRegistry.artifact)).request(),
deployInstance(deployer, canonicalKeyRegistry.instance).request(),
]);

await batch.send().wait();

logger.info(`Deployed Key Registry on L2 at ${canonicalKeyRegistry.address}`);
}

/** Sandbox settings. */
export type SandboxConfig = AztecNodeConfig & {
/** Mnemonic used to derive the L1 deployer private key.*/
Expand Down
20 changes: 1 addition & 19 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
RollupBytecode,
} from '@aztec/l1-artifacts';
import { getCanonicalGasToken, getCanonicalGasTokenAddress } from '@aztec/protocol-contracts/gas-token';
import { getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry';
import { deployCanonicalKeyRegistry, getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry';
import { PXEService, type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe';
import { type SequencerClient } from '@aztec/sequencer-client';

Expand Down Expand Up @@ -597,21 +597,3 @@ export async function deployCanonicalGasToken(deployer: Wallet) {
await expect(deployer.isContractClassPubliclyRegistered(canonicalGasToken.contractClass.id)).resolves.toBe(true);
await expect(deployer.getContractInstance(canonicalGasToken.instance.address)).resolves.toBeDefined();
}

export async function deployCanonicalKeyRegistry(deployer: Wallet) {
const canonicalKeyRegistry = getCanonicalKeyRegistry();

if (await deployer.isContractClassPubliclyRegistered(canonicalKeyRegistry.contractClass.id)) {
return;
}

await new BatchCall(deployer, [
(await registerContractClass(deployer, canonicalKeyRegistry.artifact)).request(),
deployInstance(deployer, canonicalKeyRegistry.instance).request(),
])
.send()
.wait();

await expect(deployer.isContractClassPubliclyRegistered(canonicalKeyRegistry.contractClass.id)).resolves.toBe(true);
await expect(deployer.getContractInstance(canonicalKeyRegistry.instance.address)).resolves.toBeDefined();
}
18 changes: 18 additions & 0 deletions yarn-project/protocol-contracts/src/key-registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,21 @@ export function getCanonicalKeyRegistry(): ProtocolContract {
export function getCanonicalKeyRegistryAddress(): AztecAddress {
return getCanonicalKeyRegistry().address;
}

export async function deployCanonicalKeyRegistry(deployer: Wallet) {
const canonicalKeyRegistry = getCanonicalKeyRegistry();

if (await deployer.isContractClassPubliclyRegistered(canonicalKeyRegistry.contractClass.id)) {
return;
}

await new BatchCall(deployer, [
(await registerContractClass(deployer, canonicalKeyRegistry.artifact)).request(),
deployInstance(deployer, canonicalKeyRegistry.instance).request(),
])
.send()
.wait();

await expect(deployer.isContractClassPubliclyRegistered(canonicalKeyRegistry.contractClass.id)).resolves.toBe(true);
await expect(deployer.getContractInstance(canonicalKeyRegistry.instance.address)).resolves.toBeDefined();
}

0 comments on commit 3da10c1

Please sign in to comment.