Skip to content

Migrate smart account SDK to OZ contracts v0.7.0-rc.2 - #13

Merged
christian-rogobete merged 5 commits into
mainfrom
smart-accounts-v7
Apr 3, 2026
Merged

Migrate smart account SDK to OZ contracts v0.7.0-rc.2#13
christian-rogobete merged 5 commits into
mainfrom
smart-accounts-v7

Conversation

@christian-rogobete

Copy link
Copy Markdown
Member

Description

Migrates the smart account SDK layer, demo app, and documentation to the OpenZeppelin smart account contracts v0.7.0-rc.2. Updates testnet contract addresses, signing flow, and context rule management.

Auth payload and signing

  • AuthPayload format changed from Vec-based to Map-based with context_rule_ids and signers fields
  • Signing digest now binds context rule IDs: sha256(payloadHash || contextRuleIds.toXDR())
  • New SmartAccountAuthPayload data class and SmartAccountAuthPayloadCodec for reading/writing the v0.7.0-rc.2 format
  • signAuthEntry() accepts contextRuleIds parameter
  • addRawSignatureMapEntry() accepts contextRuleIds parameter

Context rule resolution

  • 4-tier resolution algorithm: context type match, exact signer match, rule-signers-subset, selected-signers-subset (handles threshold scenarios)
  • resolveContextRuleIdsForEntry() with overload accepting pre-fetched rules to avoid N+1 RPC calls
  • listContextRules() returns fully parsed ParsedContextRule with signerIds and policyIds
  • ResolveContextRuleIds callback on submit(), executeAndSubmit(), and multiSignerTransfer() for explicit per-entry rule selection
  • Removed MAX_CONTEXT_RULES pre-validation in addContextRule() (no upper limit in v0.7.0-rc.2 contract)
  • addContextRule() allows zero signers when at least one policy is present

New APIs

  • executeAndSubmit() for generic single-signer contract calls via the OZ execute entry point
  • ResolveContextRuleIds type alias for per-entry context rule callbacks

API changes

  • removeSigner() takes signerId: UInt instead of SmartAccountSigner
  • removePolicy() takes policyId: UInt instead of policy address string
  • signAuthEntries() removed (unused public method with no equivalent in the TS SDK)
  • ParsedContextRule includes signerIds and policyIds (positionally aligned)
  • Contract error codes added: MathOverflow, KeyDataTooLarge, ContextRuleIdsLengthMismatch, NameTooLong, UnauthorizedSigner

Transaction assembly and polling

  • Use SDK prepareTransaction() instead of manual fee calculation in submit(), submitMultiSignerTransaction(), and fundWallet()
  • Use SDK pollTransaction() with 30 attempts and 3-second intervals
  • Proper SendTransactionStatus checks for ERROR and TRY_AGAIN_LATER
  • Re-fetch deployer account before re-simulation to prevent tx_bad_seq
  • Graceful fallback to on-chain signer lookup when storage read fails

Demo app

  • Updated contract addresses and WASM hash to v0.7.0-rc.2 testnet deployments
  • Demo parsing delegated to SDK listContextRules(), removed dead parsing code
  • Fixed Android WebAuthn allowCredentials to correctly constrain passkey selection
  • Fixed macOS Account Signers screen to show credential ID instead of hex key data

Tests and documentation

  • Updated unit tests for new AuthPayload Map format
  • Added tests for buildAuthDigest, contextRuleIds preservation, and execute function usage
  • Updated API reference with new method signatures, ResolveContextRuleIds type, and examples

- AuthPayload format changed from Vec-based to Map-based with context_rule_ids and signers fields
- Signing digest now binds context rule IDs: sha256(payloadHash || contextRuleIds.toXDR())
- Context rule resolution algorithm with 4-tier disambiguation (context type, exact signer, rule subset, selected subset)
- Signer and policy removal now uses ID-based API (remove_signer/remove_policy take u32 IDs)
- ParsedContextRule includes signerIds and policyIds (positionally aligned)
- Pre-fetch context rules per submit/multiSignerTransfer call to avoid N+1 RPC calls
- multiSignerTransfer accepts optional contextRuleId for explicit rule selection
- Android WebAuthn allowCredentials now correctly constrains passkey selection
- Updated demo config with v0.7.0 testnet contract addresses and WASM hash
- Removed dead parsing code from demo ContextRuleParser (SDK handles parsing)
- Updated unit tests for new AuthPayload format, added buildAuthDigest tests
- Replace static contextRuleIds parameter with ResolveContextRuleIds callback on submit(), executeAndSubmit(), and multiSignerTransfer() for per-entry context rule selection
- Add executeAndSubmit() for generic single-signer contract calls via the OZ execute entry point
- Improve error messages to differentiate ambiguous matches from invalid signer combinations
- Update API reference documentation and unit tests
@codecov-commenter

codecov-commenter commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 23.40909% with 337 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.25%. Comparing base (fc50a5b) to head (578270d).

Files with missing lines Patch % Lines
...tellar/sdk/smartaccount/oz/OZContextRuleManager.kt 0.00% 183 Missing and 1 partial ⚠️
...lar/sdk/smartaccount/oz/OZTransactionOperations.kt 0.00% 74 Missing ⚠️
...r/sdk/smartaccount/core/SmartAccountAuthPayload.kt 65.30% 18 Missing and 16 partials ⚠️
...tellar/sdk/smartaccount/oz/OZMultiSignerManager.kt 0.00% 32 Missing ⚠️
.../stellar/sdk/smartaccount/core/SmartAccountAuth.kt 79.59% 9 Missing and 1 partial ⚠️
...eso/stellar/sdk/smartaccount/oz/OZPolicyManager.kt 0.00% 2 Missing ⚠️
...eso/stellar/sdk/smartaccount/oz/OZSignerManager.kt 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (23.40%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project status has failed because the head coverage (77.25%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
- Coverage   77.85%   77.25%   -0.60%     
==========================================
  Files         830      831       +1     
  Lines       23664    23937     +273     
  Branches     3108     3164      +56     
==========================================
+ Hits        18424    18493      +69     
- Misses       3975     4164     +189     
- Partials     1265     1280      +15     
Files with missing lines Coverage Δ
...tellar/sdk/smartaccount/core/SmartAccountErrors.kt 98.40% <ø> (ø)
...eso/stellar/sdk/smartaccount/oz/OZSignerManager.kt 45.74% <0.00%> (+0.48%) ⬆️
...eso/stellar/sdk/smartaccount/oz/OZPolicyManager.kt 57.89% <0.00%> (+0.60%) ⬆️
.../stellar/sdk/smartaccount/core/SmartAccountAuth.kt 75.43% <79.59%> (-2.45%) ⬇️
...tellar/sdk/smartaccount/oz/OZMultiSignerManager.kt 0.00% <0.00%> (ø)
...r/sdk/smartaccount/core/SmartAccountAuthPayload.kt 65.30% <65.30%> (ø)
...lar/sdk/smartaccount/oz/OZTransactionOperations.kt 1.30% <0.00%> (+0.05%) ⬆️
...tellar/sdk/smartaccount/oz/OZContextRuleManager.kt 5.14% <0.00%> (-6.45%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@christian-rogobete
christian-rogobete merged commit 17d6764 into main Apr 3, 2026
5 checks passed
@christian-rogobete
christian-rogobete deleted the smart-accounts-v7 branch April 28, 2026 02:23
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