-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
noir-projects/noir-contracts/contracts/router_contract/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { loadContractArtifact } from '@aztec/types/abi'; | ||
import { type NoirCompiledContract } from '@aztec/types/noir'; | ||
|
||
import RouterJson from '../../artifacts/Router.json' assert { type: 'json' }; | ||
|
||
export const RouterArtifact = loadContractArtifact(RouterJson as NoirCompiledContract); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { | ||
AztecAddress, | ||
ROUTER_ADDRESS, | ||
computeContractAddressFromInstance, | ||
getContractClassFromArtifact, | ||
} from '@aztec/circuits.js'; | ||
|
||
import { getCanonicalRouter } from './index.js'; | ||
|
||
describe('Router', () => { | ||
it('returns canonical protocol contract', () => { | ||
const contract = getCanonicalRouter(); | ||
expect(computeContractAddressFromInstance(contract.instance)).toEqual(contract.address); | ||
expect(getContractClassFromArtifact(contract.artifact).id).toEqual(contract.contractClass.id); | ||
expect(contract.address).toEqual(AztecAddress.fromBigInt(ROUTER_ADDRESS)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { AztecAddress, ROUTER_ADDRESS } from '@aztec/circuits.js'; | ||
|
||
import { type ProtocolContract, getCanonicalProtocolContract } from '../protocol_contract.js'; | ||
import { RouterArtifact } from './artifact.js'; | ||
|
||
/** Returns the canonical deployment of the auth registry. */ | ||
export function getCanonicalRouter(): ProtocolContract { | ||
const contract = getCanonicalProtocolContract(RouterArtifact, 1); | ||
|
||
if (!contract.address.equals(RouterAddress)) { | ||
throw new Error( | ||
`Incorrect address for auth registry (got ${contract.address.toString()} but expected ${RouterAddress.toString()}). Check ROUTER_ADDRESS is set to the correct value in the constants files and run the protocol-contracts package tests.`, | ||
); | ||
} | ||
return contract; | ||
} | ||
|
||
export function getCanonicalRouterAddress(): AztecAddress { | ||
return getCanonicalRouter().address; | ||
} | ||
|
||
export const RouterAddress = AztecAddress.fromBigInt(ROUTER_ADDRESS); |