-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(oracle): add oracle to get portal contract address #1474
Conversation
I'd maybe consider doing this for all of the non-argument inputs to a circuit, or not at all. Injecting some of the call_context as an argument and some via an oracle feels inconsistent to me. #1464 (comment) |
I made the pr misunderstanding the task at hand, rather than injecting the call context, the goal was to have a lookup from contract address to portal address. Ive updated the code and description to reflect this |
getPortalContractAddress: async ([aztecAddress]) => { | ||
const contractAddress = AztecAddress.fromString(aztecAddress); | ||
let portalContactAddress = await this.contractsDb.getPortalContractAddress(contractAddress); | ||
if (!portalContactAddress) portalContactAddress = EthAddress.ZERO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on returning zero here, or throwing. I feel like it should throw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree -> although can you remind me how the error would bubble up to the user? (what would be their experience)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What practically happens if the return value from this.contractsDb.getPortalContractAddress
is zero now? Because I would assume that it is already zero for contracts that don't have portals.
The main thing keeping me from saying that we should throw, would be that you would have trouble if you want to check if something have a portal and it don't have that 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, the user should probably have an explicit zero check,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I'm writing code in a function of contract A, I have access to the contract address and the portal contract address of contract A, via the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it 👀.
getPortalContractAddress: async ([aztecAddress]) => { | ||
const contractAddress = AztecAddress.fromString(aztecAddress); | ||
let portalContactAddress = await this.contractsDb.getPortalContractAddress(contractAddress); | ||
if (!portalContactAddress) portalContactAddress = EthAddress.ZERO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What practically happens if the return value from this.contractsDb.getPortalContractAddress
is zero now? Because I would assume that it is already zero for contracts that don't have portals.
The main thing keeping me from saying that we should throw, would be that you would have trouble if you want to check if something have a portal and it don't have that 🤔
Overview
closes: #1464
Adds an oracle that returns the portal address for a given contract address.
A unit test is added, and the uniswap portal test is altered to use this oracle rather than injecting the portals as function inputs
Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.