Skip to content

Document constructor auth for register/register_at#2666

Open
leighmcculloch wants to merge 6 commits into
mainfrom
document-register-at-auth-fix
Open

Document constructor auth for register/register_at#2666
leighmcculloch wants to merge 6 commits into
mainfrom
document-register-at-auth-fix

Conversation

@leighmcculloch

@leighmcculloch leighmcculloch commented Jul 21, 2026

Copy link
Copy Markdown
Member

What

Add a new "Authorization in constructors" section to the Test Authorization guide explaining that both env.register(...) and env.register_at(...) switch the test environment to recording-auth mode for the duration of a Wasm contract's constructor invocation, so a constructor calling require_auth() succeeds without mock_all_auths(), and note the current caveat that this does not apply to native/mock contracts registered for testing.

Why

As a result of the following issue and related changes its good to discuss this here:

@stellar-jenkins-ci

Copy link
Copy Markdown

Clarify the behavior of authorization in constructors and note the version consistency of the soroban-sdk.
@stellar-jenkins-ci

Copy link
Copy Markdown

1 similar comment
@stellar-jenkins-ci

Copy link
Copy Markdown

Copy link
Copy Markdown
Member Author

Heads up: rs-soroban-sdk#1943 merged today, fixing the remaining gap this section's caveat/version note doesn't yet account for — native (non-Wasm, directly-registered #[contract] struct) contracts now also get recording auth around the constructor for both register and register_at, matching the Wasm path fixed by #1933. Previously native constructors ran under enforcing auth regardless of which function registered them.

So as of the two merged fixes, the behavior is now uniform across register/register_at × Wasm/native — no native-specific caveat needed, and the "deploy in test using standard deployment functions after being built to Wasm" note in this PR's diff may no longer be accurate as a caveat for auth-in-constructors specifically.

Opened #2677 independently with wording that accounts for both fixes (and avoids guessing a specific unreleased version number, since v27.0.1 is still the latest published release). Feel free to take whichever of the two is preferred — happy to close #2677 if you'd rather fold this into #2666, or vice versa.


Generated by Claude Code

@leighmcculloch
leighmcculloch marked this pull request as ready for review July 23, 2026 04:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents constructor authorization behavior in SDK test environments.

Changes:

  • Explains recording-auth behavior for register and register_at.
  • Recommends Wasm deployment for production-faithful testing.
  • Notes consistency beginning with v27.0.2.

Recommendation: MERGE-READY — one non-blocking grammar correction is noted.

Comment thread docs/build/guides/testing/test-contract-auth.mdx Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@stellar-jenkins-ci

Copy link
Copy Markdown

@ElliotFriend ElliotFriend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a great addition!

i added a suggestion that might make the first part of this a little easier to read and understand. feel free to take it or adapt it.

thanks!!

Comment thread docs/build/guides/testing/test-contract-auth.mdx Outdated
Comment thread docs/build/guides/testing/test-contract-auth.mdx
Co-authored-by: Elliot Voris <elliot@stellar.org>
@stellar-jenkins-ci

Copy link
Copy Markdown

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.

register_at does not switch to recording auth for WASM constructors

3 participants