Skip to content
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

Move Context into Noir interfaces initialiser #2075

Open
spalladino opened this issue Sep 6, 2023 · 3 comments
Open

Move Context into Noir interfaces initialiser #2075

spalladino opened this issue Sep 6, 2023 · 3 comments
Labels
T-refactor Type: this code needs refactoring

Comments

@spalladino
Copy link
Collaborator

spalladino commented Sep 6, 2023

Today, the autogenerated Noir interfaces take a private or public context on every call as their first parameter. We can take a page out of the refactor that @benesjan did for storage in #1926, and do the same for interfaces.

So instead of doing:

let token = Token::at(address);
token.transfer(&mut context, to, amount);

We'd be doing:

let token = Token::at(address, Context::private(&mut context));
token.transfer(to, amount);

Note that we should wait until #2074 is implemented before moving forward though. Also, note that Context::private(&mut context) can probably be autogenerated by a macro.

@github-project-automation github-project-automation bot moved this to Todo in A3 Sep 6, 2023
@spalladino spalladino changed the title Move Context into interface initialiser Move Context into Noir interfaces initialiser Sep 6, 2023
@iAmMichaelConnor
Copy link
Contributor

Great suggestion!

@iAmMichaelConnor
Copy link
Contributor

let token = Token::at(address, Context::private(&mut context));

Can we instead do:
let token = Token::at(address, &mut context);?

@spalladino
Copy link
Collaborator Author

Definitely. I forgot I had split the interfaces into public and private, and each of them takes a public context or private context respectively, so there's no need to use the Context union from #2074.

@iAmMichaelConnor iAmMichaelConnor added the T-refactor Type: this code needs refactoring label Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-refactor Type: this code needs refactoring
Projects
Status: Todo
Development

No branches or pull requests

2 participants