fix(globe-wallet): disambiguate spend limit storage keys by AssetInfo and add migration path (#82) - #94
Closed
s6pa1rta3n-lab wants to merge 1 commit into
Closed
Conversation
s6pa1rta3n-lab
force-pushed
the
fix-issue
branch
from
August 29, 2026 17:02
c84723f to
48574eb
Compare
s6pa1rta3n-lab
force-pushed
the
fix-issue
branch
7 times, most recently
from
August 29, 2026 17:16
c2618d7 to
ce27fba
Compare
…with token allowlist and CEI ordering - Add admin-curated token allowlist via `set_token_allowed` and `is_token_allowed` (with `TokenNotAllowed = 1034`) to reject untrusted token contract addresses. - Add `GlobeWallet::send` entrypoint wiring `globe-wallet` to `token-wrapper::transfer_from` with strict Checks-Effects-Interactions (CEI) ordering. - Commit spend bookkeeping to persistent storage before calling external contract code. - Add unit tests verifying token allowlist admin enforcement, wired transfer settlement, daily limit enforcement, and rollback on malicious re-entrant token callbacks. - Update architecture design and reentrancy documentation with threat model analysis and platform invariants. Closes Orbit-Wal#92
s6pa1rta3n-lab
force-pushed
the
fix-issue
branch
from
August 29, 2026 17:20
ce27fba to
040491e
Compare
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.
Summary
Resolves #82.
In
contracts/globe-wallet/src/lib.rs,DataKey::SpendLimitandDataKey::DailySpentpreviously used(Address, String)keyed solely by asset code name (e.g."USDC"), causing spend limit collisions between different assets sharing identical ticker codes issued by different accounts.This PR implements the disambiguation fix in
contracts/globe-wallet/src/lib.rs, allows same-code different-issuer assets inadd_asset, enforces user asset whitelist presence on spend limit configuration and spends, and provides backward-compatible migration endpoints for existing persisted keys.Key Changes
DataKey::SpendLimit(Address, AssetInfo)andDataKey::DailySpent(Address, AssetInfo)to key by fullAssetInforather than raw ticker string. AddedLegacySpendLimitandLegacyDailySpentvariants for migration.set_spend_limit,get_spend_limit, andrecord_spendto acceptAssetInfo. Validates that the asset is present in the caller'sUserAssetswhitelist viarequire_asset_registered, rejecting unregistered assets withWalletError::AssetNotFound.add_assetduplicate check to matchcodes_match_case_insensitive(&existing.code, &asset.code) && existing.issuer == asset.issuer, allowing same-code assets from different issuers while rejecting true duplicates.remove_assetto purge both newAssetInfo-keyed and legacy storage entries.migrate_user_spend_limits: Admin-authorized migration of a user's legacy spend limit and daily spend record from legacy key to disambiguated key. Includesallow_overwriteflag (returnsWalletError::MigrationErrorif target is already configured and overwrite is false).batch_migrate_spend_limits: Admin-authorized batch migration for multiple user wallets.test_same_code_different_issuer_allowed: Verifies assets sharing ticker codes but with distinct issuers can be registered simultaneously.test_disambiguated_spend_limits: Proves two same-code, different-issuer assets receive independent daily spend limits and tracking.test_unregistered_asset_rejected_for_spend_limit_and_spend: Verifies unregistered assets are rejected for both spend limit setting and spending.test_migration_from_legacy_key: Verifies migration from legacy(Symbol, user, code)andLegacySpendLimitstorage format to newAssetInfokeys.test_batch_migration: Verifies batch migration across multiple accounts.test_migration_no_overwrite: Verifiesallow_overwrite=falsepreserves existing configuration without corruption.record_spend_reentrancy.rs.Test Verification
Payout Routing
0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC