Token Approval and Spending Limits System#101
Merged
Miracle656 merged 1 commit intoMiracle656:mainfrom Apr 24, 2026
Merged
Conversation
|
@Tybravo is attempting to deploy a commit to the miracle656's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Tybravo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #99
Description
This PR introduces granular token spending limits to the Veil wallet contract, bringing ERC-20 style
approve/allowancefunctionality to the Soroban authorization flow. Previously, any passkey-authorized transaction could transfer any amount of tokens. This update allows users to approve specific spenders (e.g., a DEX) for a specific token up to a maximum amount, with an optional expiration, removing the need for a passkey signature on every individual transaction.Key Changes
🧱 Smart Contract (
contracts/invisible_wallet)StorageKeywith anAllowance { spender, token }variant to securely store allowance state.approve(spender, token, amount, expiry): Allows the wallet owner to set an allowance. Requires strict passkey authentication.get_allowance(spender, token): Read-only method to query current allowances.__check_auth): Updated to intercept and authorize spender-initiated transfers. Validates that the allowance exists, is not expired, and has sufficient balance. Safely and atomically deducts the spent amount upon authorization.🧩 TypeScript SDK (
sdk/src/useInvisibleWallet.ts)approve()API: Exposed a clean developer API that handles WebAuthn payload generation, passkey signing, and transaction building for setting allowances.getAllowance()API: Exposed a read-only method to fetch active limits via simulated RPC calls.🔐 Security & Validation
approve()operations are secured behind the contract's passkeyrequire_auth()flow.