Move AuthorizationContext into SDK and add address method #951
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Move AuthorizationContext into the SDK, renamed to AuthContext, and add method
AuthContext::contract()
that returns theAddress
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 fromBytesN<32>
so that we have developers go all in onAddress
. To have theAuthorizationContext
give the user anAddress
it needs to be in the SDK so it can call the privateAddress::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.