Skip to content

feat: authorization lock methods - #66

Merged
edo-chan merged 7 commits into
mainfrom
feat/authorization-locks
Nov 9, 2026
Merged

edo-chan merged 7 commits into
mainfrom
feat/authorization-locks

Conversation

@austbot

@austbot austbot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Adds authorization-lock preparation and inspection to the TypeScript and Python SDKs, rebased onto current main. Both clients expose add, remove, and list methods; captured locks remain visible as amount zero/inactive when requested.

The signing helpers recognize AddAuthorizationLockV1 (25; 88-byte args) and RemoveAuthorizationLockV1 (26; 16-byte args), preserving k1 prefixes, r1 precompile signatures and ParticipantSet approval compilation. Request validation enforces expiry exclusivity, integer ranges and supported authorities. Response validation rejects malformed uint32 IDs and uint64 amounts/slots.

Prepared kind numbers are now 10/11 to match rebased swig-dev-portal#1170; main's Yield kinds 7/8/9 are not misidentified as locks. Protocol compatibility was checked against swig-wallet#226 at 4628591963a1f6d9196bae67b25fba6c4a9fb0ab. Upstream-removed documentation stays removed; the package README updates are preserved.

Validation on b956b7e:

  • TypeScript format, lint, types, build and full suite: 153 passed, one intentional inapplicable add/rent-claimer case skipped.
  • Python format, lint, mypy and wheel/sdist build; full final CI suite: 209 passed.
  • Real k1 recovery and P-256 raw/WebAuthn signature verification for add/remove, including changed-args rejection.
  • Packed TypeScript ESM/CommonJS runtime and type consumers; installed Python wheel runtime and strict-mypy consumer.
  • Independent final review: no remaining blockers. Both required CI jobs pass on b956b7e. No local integration/E2E or chain submission.

Deployment dependency remains swig-dev-portal#1170 routes plus the authorization-lock program from swig-wallet#226. This update does not merge or deploy either dependency.

@austbot
austbot marked this pull request as ready for review November 2, 2026 17:10
austbot and others added 6 commits November 3, 2026 15:00
Add authorization-lock preparation and read methods to both SDKs, targeting
the new dev portal routes:

- POST /transaction/wallet/authorization-lock/add
- POST /transaction/wallet/authorization-lock/remove
- GET /transaction/wallet/{swig_address}/authorization-locks

TypeScript: wallet.addAuthorizationLock, wallet.removeAuthorizationLock,
wallet.getAuthorizationLocks. Python: wallet.add_authorization_lock,
wallet.remove_authorization_lock, wallet.get_authorization_locks. Both
recognize the add-authorization-lock and remove-authorization-lock prepared
transaction kinds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lock requesters may now be Ed25519 (direct or session key), Secp256k1, or
Secp256r1 in both SDKs; ProgramExec and ParticipantSet are rejected before
any request is sent.

The Swig signing helpers previously located the authority payload only in
SignV2. They now also recognize AddAuthorizationLockV1 (discriminator 25,
88-byte args) and RemoveAuthorizationLockV1 (26, 16-byte args), so secp256k1
signatures and prefixes, and secp256r1 passkey prefixes, are written into
lock instructions the same way. Raw secp256r1 signatures already worked
through the precompile path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow swig-dev-portal#1170 (104b34dd):

- Allow ParticipantSet requesters (optional roleId) on add/remove lock in
  both SDKs; keep rejecting programExecProof. The response's approval plan
  compiles through the existing compileParticipantSetApprovals flow.
- TypeScript compileParticipantSetApprovals now sends the lock prepared
  kinds instead of dropping them, so the compiled transaction keeps its kind
  (Python already did).
- Update lock signing tests to the new account order (wallet address at
  index 1) and the server-placed EIP-191 prefix, and verify SDK-produced
  secp256k1 signatures recover the requester under the program's
  keccak256(prefix || hex(sha256(payload))) algorithm, including a rent
  claimer that is also the fee payer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow swig-wallet authlock-v3 9c1e0be. Other roles, All and the owner
included, spend only the balance minus locks they don't hold; the holder
spends its locked funds and each spend captures its lock amount. Locking
charges no spend limit; spending does. Fully captured locks stay stored
with amount 0, inactive, prunable, and returned only with include_expired.

Update READMEs, CHANGELOG, PARITY.md, ENGINEERING_CONTRACT.md, JSDoc and
docstrings accordingly. The lock normalizers already accept a zero amount;
add tests that a zero-amount inactive lock normalizes in both SDKs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@edo-chan
edo-chan merged commit 0c0a00d into main Nov 9, 2026
2 checks passed
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