Skip to content

Implement deposit_fiat and withdraw_fiat functions#7

Closed
jobbykings wants to merge 3 commits intocaxtonacollins:mainfrom
jobbykings:feature/fiat-deposit-withdraw
Closed

Implement deposit_fiat and withdraw_fiat functions#7
jobbykings wants to merge 3 commits intocaxtonacollins:mainfrom
jobbykings:feature/fiat-deposit-withdraw

Conversation

@jobbykings
Copy link

  • Added deposit_fiat function to allow users to deposit fiat currency.
  • Added withdraw_fiat function to enable fiat withdrawal to specified recipient.
  • Both functions update storage and emit appropriate events.
  • Added storage mappings for fiat_balance and token_address.


// -- New functions added here --

fn deposit_fiat(ref self: ContractState, currency: felt252, amount: u128) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert that currency is provided

// -- New functions added here --

fn deposit_fiat(ref self: ContractState, currency: felt252, amount: u128) {
assert(amount > 0, 'Amount must be > 0');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert takes in felt252, therefore you should use single quotes.
your test should cover the whole implementation, test every assertion, insufficient balance and more

fn deposit_fiat(ref self: ContractState, currency: felt252, amount: u128) {
assert(amount > 0, 'Amount must be > 0');
let caller = get_caller_address();
let current_balance = self.fiat_balance.read((caller, currency));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to check if the user have sufficient balance

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I have sir

@caxtonacollins
Copy link
Owner

@jobbykings are yo still working on this?

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.

2 participants

Comments