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

Add Host::has_frame #1244

Merged
merged 11 commits into from
Nov 22, 2023
Merged

Add Host::has_frame #1244

merged 11 commits into from
Nov 22, 2023

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Nov 22, 2023

What

Add a method to the host for determining if the host currently has a frame on the stack.

Why

In several places in the SDK it would be ideal if we could error if a function is used inside or outside of a contract function, because doing so would be invalid.

In some code being added or auth tracking in the SDK I need to reliable know if we are inside a contract function or not.

I tried to do this using top invocation hooks, but the way native contract functions get called in the SDK doesn't pass through anything from the Env that is available outside of the contract. We can sort of know if we're in a contract, but it isn't guaranteed to be correct in edge cases. We might change that some day, but at the moment that limitation exists.

Exposing whether the host currently has a frame is a simple way the host can indicate to SDK test utilities if it is currently in a contract function or not.

Close stellar/rs-soroban-sdk#1084

@leighmcculloch leighmcculloch marked this pull request as ready for review November 22, 2023 04:55
leighmcculloch added a commit to stellar/rs-soroban-sdk that referenced this pull request Nov 22, 2023
@leighmcculloch leighmcculloch added this pull request to the merge queue Nov 22, 2023
Merged via the queue into main with commit c26e8a9 Nov 22, 2023
10 checks passed
@leighmcculloch leighmcculloch deleted the is-in-contract branch November 22, 2023 20:15
github-merge-queue bot pushed a commit to stellar/rs-soroban-sdk that referenced this pull request Nov 22, 2023
### What
Restore previous auth state in client after client finishes invoke.

### Why
The client is presented in such a way that it looks like invocations
with a client that has been configured with certain auth will apply the
auth only during invocations with it.

It's unintuitive that the auths from the client apply forever after the
invocation.

Close #1084

Dependent on:
- stellar/rs-soroban-env#1244
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.

Restore previous auth state after client modifies it
2 participants