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 AuthorizationContext into SDK and add address method #951

Merged
merged 5 commits into from
May 18, 2023

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented May 18, 2023

What

Move AuthorizationContext into the SDK, renamed to AuthContext, and add method AuthContext::contract() that returns the Address for the contract in the context.

Why

I removed BytesN<32> everywhere I could for contract IDs, but AuthorizationContext still has to contain a BytesN<32> because the environment generates the value and the environment hasn't been updated yet to use Address everywhere.

I had changed Address to disallow creating it from BytesN<32> so that we have developers go all in on Address. To have the AuthorizationContext give the user an Address it needs to be in the SDK so it can call the private Address::from_contract_id function.

I renamed the type because we use the term Auth in docs and most places, so the long form seems unnecessary.

Moving the type is probably a good long term move given that auth is a core concept, there's little need to separate auth logic into a separate crate now. I left the auth test utility in the separate crate to address separately.

@leighmcculloch leighmcculloch marked this pull request as ready for review May 18, 2023 17:22
@leighmcculloch leighmcculloch changed the title Keep Address::from_contract_id Move AuthorizationContext into SDK and add address method May 18, 2023
soroban-sdk/src/auth.rs Outdated Show resolved Hide resolved
@leighmcculloch leighmcculloch enabled auto-merge (squash) May 18, 2023 17:58
@leighmcculloch leighmcculloch merged commit 13bb9d2 into main May 18, 2023
@leighmcculloch leighmcculloch deleted the aggregable-scrike branch May 18, 2023 18:03
leighmcculloch added a commit that referenced this pull request May 18, 2023
### What
Move env auth testutils into sdk

### Why
When I moved #951, I was going to leave the auth testutils separate
until a later date, but it is pretty odd having them sit so separately.
Especially if we do #952.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants