Skip to content

feat(contracts): add multi-asset payment support with decimal normalization - #1266

Merged
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
itzsoftwaredevops-sys:feat/multi-asset-payment
Nov 25, 2026
Merged

Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
itzsoftwaredevops-sys:feat/multi-asset-payment

Conversation

@itzsoftwaredevops-sys

Copy link
Copy Markdown
Contributor

Summary

  • Adds allowlisted payment assets with decimal normalization to support key purchases in multi-asset denominations (e.g. 6, 7, and 18-decimal tokens).
  • Exposes \�dd_payment_asset(admin, token, decimals, rate_oracle)\ and
    emove_payment_asset(admin, token).
  • Normalizes internal accounting to 7 decimals via \ o_internal(amount, decimals)\ and \ rom_internal(amount, decimals).
  • Adds \�uy_with(buyer, key_id, amount, token, max_pay)\ converting through the configured rate with oracle staleness guard.
  • Rounds conversions in favor of the protocol and reverts when required token payment exceeds \max_pay.
  • Maintains per-asset and base reserve accounting in storage, allowing existing balances to be redeemed via
    edeem_payment_asset\ even if an asset is deactivated.
  • Exposes \payment_assets()\ view returning active allowlisted tokens and decimals.
  • Emits \payment_asset_added, \payment_asset_removed, and \�ought_with\ events.

Why

Trading was previously tied to a single payment asset, restricting market participation. This change introduces multi-asset payment allowlisting and decimal normalization so keys can be purchased with multiple tokens while protecting buyers from rate movement with \max_pay\ and protecting the protocol with staleness and rounding guards.

Implementation

  • Created \creator-keys/src/multi_asset_payment.rs\ containing storage keys, asset configurations, decimal normalization math, rate oracle querying with staleness threshold check, protocol-favorable rounding, reserve tracking, and event emission.
  • Integrated public entrypoints into #[contractimpl] impl CreatorKeysContract\ in \creator-keys/src/lib.rs.
  • Configured [profile.test]\ndebug = 0\ in \Cargo.toml\ to eliminate MSVC linker PDB exhaustion on Windows.
  • Implemented comprehensive unit tests in \creator-keys/src/test_issue_1259.rs\ testing 6, 7, and 18-decimal tokens, allowlist rejection, staleness enforcement, \max_pay\ protection, removal semantics, and reserve redemption.

Testing

  • Executed targeted unit tests:
    \\ ext
    cargo test -p creator-keys --lib test_issue_1259
    running 7 tests
    test test_issue_1259::test_decimal_normalization_conversions ... ok
    test test_issue_1259::test_tokens_not_on_allowlist_are_rejected ... ok
    test test_issue_1259::test_allowlist_management_and_views ... ok
    test test_issue_1259::test_max_pay_protection_reverts_on_rate_movement ... ok
    test test_issue_1259::test_removing_asset_blocks_new_buys_but_allows_reserve_redemption ... ok
    test test_issue_1259::test_oracle_staleness_guard ... ok
    test test_issue_1259::test_buy_with_6_7_and_18_decimal_tokens ... ok

test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 531 filtered out; finished in 0.31s
\\

Scope / Risk

  • Affected area: \creator-keys\ contract.
  • Non-breaking change; existing \�uy_keys\ and base-currency workflows remain unaffected.

Issue

Closes #1259

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@itzsoftwaredevops-sys 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! 🚀

Learn more about application limits

@Chucks1093

Copy link
Copy Markdown
Member

✅ PR Ready for Review

Due to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging.

This PR has passed all automated checks:

  • ✅ Security scan — no malicious code detected
  • ✅ No merge conflicts
  • ✅ CI checks passed

Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514

@Chucks1093
Chucks1093 merged commit 7930da8 into accesslayerorg:main Nov 25, 2026
1 check failed
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.

Add multi-asset payment support with allowlisted tokens and decimal normalization

2 participants