Skip to content

Conversation

@h1teshtr1path1
Copy link

I can see assertion in 2nd last line in icrc2_approve method will always throw err, am I missing something?

@h1teshtr1path1 h1teshtr1path1 changed the title fixed/icrc2_approve-method fix/icrc2_approve-method Jun 6, 2023
@h1teshtr1path1 h1teshtr1path1 deleted the fix/icrc2_approve-method-assertion branch June 6, 2023 14:50
@roman-kashitsyn
Copy link
Contributor

roman-kashitsyn commented Jun 6, 2023

The assertion states that the approver balance goes down by effectiveFee once the ledger records the Approve transaction. Do you observe this assertion failing?

@h1teshtr1path1
Copy link
Author

h1teshtr1path1 commented Jun 6, 2023

Ahhh I see. In that case, in Motoko implementation, balance function doesn't handle #Approve case.

func balance(account : Account, log : TxLog) : Nat { var sum = 0; for (tx in log.vals()) { switch (tx.operation) { case (#Burn(args)) { if (accountsEqual(args.from, account)) { sum -= args.amount }; }; case (#Mint(args)) { if (accountsEqual(args.to, account)) { sum += args.amount }; }; case (#Transfer(args)) { if (accountsEqual(args.from, account)) { sum -= args.amount + tx.fee; }; if (accountsEqual(args.to, account)) { sum += args.amount }; }; case (#Approve(_)) {}; }; }; sum; };

I think this is the reason assertion throwing error in all cases.

@h1teshtr1path1 h1teshtr1path1 restored the fix/icrc2_approve-method-assertion branch June 6, 2023 21:08
@h1teshtr1path1 h1teshtr1path1 reopened this Jun 6, 2023
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