fix(factory): validate the staking asset token in create_pool - #434
Merged
ritaifeoluwa merged 1 commit intoSep 29, 2026
Merged
ritaifeoluwa merged 1 commit into
ritaifeoluwa merged 1 commit into
Conversation
|
@Awwal-dev34 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! 🚀 |
✅ Deploy Preview for sdcontracts ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Overview
Factory::create_pooldid not actually reject a staking asset that is not a token contract.validate_assetprobedbalancebut treated an unanswerable probe (Err(_)) as success, so any plain address — or an unrelated deployed contract — could be registered as a pool's staking asset. This change makes validation strict: the asset must answer the SEP-41 interface.Related Issue
Implements the strict SEP-41 asset validation requested in #430.
Changes
[MODIFY]
soroban/contracts/factory/src/lib.rsvalidate_assetnow probes the read-only SEP-41 entry pointsymboland requires the call to succeed, returningFactoryError::InvalidAssetotherwise. The previous permissiveErr(_) => Ok(())fallback — which accepted an address that never answered — is removed.[MODIFY]
soroban/contracts/factory/src/test.rstest_assethelper that registers a real SEP-41 (Stellar asset) contract, and routedcreate_pool/create_pools_batchtest call sites through it so they pass a deployed token.test_create_pool_rejects_non_token_asset: a bare generated address is rejected withInvalidAssetand no pool is registered.test_create_pool_rejects_contract_without_sep41_interface: a real deployed contract that does not expose SEP-41 is rejected.test_create_pool_accepts_sep41_token_asset: a genuine token is accepted and recorded on the pool.test_create_pools_batch_rejects_non_token_asset: an invalid asset in a batch reverts the whole batch (including the leading valid pool).[MODIFY]
soroban/contracts/factory/tests/factory_pool_integration.rstest_assethelper so the factory integration suite creates pools with a real token asset.Verification Results
The new rejection tests fail against the previous permissive check and pass with the strict SEP-41 probe.
create_poolrejects a non-token staking assetInvalidAsset, no pool registeredcreate_poolrejects an unrelated contracttest_create_pool_rejects_contract_without_sep41_interfacetest_create_pools_batch_rejects_non_token_assetCloses #430