Skip to content

feat: implement multi-token support with token management functions and associated events#178

Merged
Nursca merged 1 commit into
Invoice-Liquidity-Network:mainfrom
bytebinders:main
Jun 1, 2026
Merged

feat: implement multi-token support with token management functions and associated events#178
Nursca merged 1 commit into
Invoice-Liquidity-Network:mainfrom
bytebinders:main

Conversation

@bytebinders
Copy link
Copy Markdown
Contributor

What was done:

  • Event Addition: Defined InvoiceTokenChanged in events.rs to provide an on-chain audit trail for currency switches.
  • Core Implementation: Added convert_invoice_token() to the main contract in lib.rs.
    • Permissions: Restricted to the original invoice submitter (freelancer).
    • State Guard: Only allowed while the invoice is in the Pending state.
    • Allowlist Check: Ensures the new token is approved by governance.
    • Expiry Check: Automatically marks the invoice as Expired if the conversion is attempted after the due date.
  • Unit Testing: Created tests_token_switch.rs with the following test cases:
    • Success: Switching from USDC to EURC.
    • Failure: Switching by a non-submitter.
    • Failure: Switching to a non-allowlisted token.
    • Failure: Switching after the invoice has been funded (even partially).
    • Failure: Switching after the invoice has expired.

Why it was done:

To improve flexibility for both freelancers and payers. This allows a freelancer to adapt to a payer's currency preference (e.g., switching to EURC if the payer holds EURC) as long as the invoice has not yet been funded by a liquidity provider.

How it was verified:

  • Implemented comprehensive unit tests covering success paths and all state/permission guards.
  • Verified that the logic mirrors the security patterns used in update_invoice and fund_invoice.

Summary of Changes:

File Action Description
events.rs Modified Added InvoiceTokenChanged event struct.
lib.rs Modified Implemented convert_invoice_token and registered test module.
tests_token_switch.rs Created Added comprehensive unit tests for the new feature.

Closes #21

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@bytebinders 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

@Nursca Nursca merged commit 526bd2e into Invoice-Liquidity-Network:main Jun 1, 2026
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.

Implement convert_invoice_token() for currency switching before funding

2 participants