Skip to content

feat: Implement deposit_fiat and withdraw_fiat Functions for Fiat Tr…#11

Merged
caxtonacollins merged 2 commits intocaxtonacollins:mainfrom
Olowodarey:deposit
Jun 9, 2025
Merged

feat: Implement deposit_fiat and withdraw_fiat Functions for Fiat Tr…#11
caxtonacollins merged 2 commits intocaxtonacollins:mainfrom
Olowodarey:deposit

Conversation

@Olowodarey
Copy link
Contributor

@Olowodarey Olowodarey commented Jun 8, 2025

Add Fiat Deposit and Withdrawal Functionality

Description

This PR implements fiat currency deposit and withdrawal functionality in the Account contract, including comprehensive test coverage.

Changes

  • Added deposit_fiat and withdraw_fiat functions to handle fiat currency operations
  • Added storage for tracking fiat balances using a mapping of (user, currency) → amount
  • Implemented event emission for both deposit and withdrawal operations
  • Added input validation for zero amounts, zero addresses, and sufficient balances

Test Coverage

  • test_deposit_fiat: Verifies basic deposit functionality
  • test_withdraw_fiat_insufficient_balance: Ensures withdrawals can't exceed balance
  • test_multiple_deposits: Tests multiple deposits to the same currency
  • test_different_currencies: Verifies isolation between different currency balances
  • test_deposit_zero_amount: Validates zero-amount deposit prevention

Security Considerations

  • All operations are protected with assert_only_self()
  • Input validation for zero values and addresses
  • Balance checks before withdrawals
  • Events emitted for all state changes

Notes

  • Uses u128 for amounts to support large values
  • Currency is represented as felt252 for flexibility
  • Includes proper error messages for all failure cases

closes #3

@Olowodarey Olowodarey marked this pull request as ready for review June 9, 2025 06:53
@caxtonacollins caxtonacollins merged commit 10d4735 into caxtonacollins:main Jun 9, 2025
2 checks passed
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 deposit_fiat and withdraw_fiat Functions for Fiat Transactions

2 participants

Comments