You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The FlamingoSwapPairContract.Nep5 contract implements the Transfer() function following the NEP-5 standard.
However, the current implementation has two minor issues which violate the NEP-5 standard.
privatestaticboolTransfer(byte[]from,byte[]to,BigIntegeramount,byte[]callscript){//Check parameters
Assert(from.Length ==20&& to.Length ==20,"The parameters from and to SHOULD be 20-byte addresses.");
Assert(amount>0,"The parameter amount MUST be greater than 0.");if(!Runtime.CheckWitness(from)&&from.AsBigInteger()!= callscript.AsBigInteger())returnfalse;StorageMapasset= Storage.CurrentContext.CreateMap(BalanceMapKey);varfromAmount= asset.Get(from).AsBigInteger();if(fromAmount<amount)returnfalse;if(from==to)returntrue;
...}
Transfer() should allow zero amount transfers with corresponding event emitted, but the assertion Assert(amount > 0, "...") forbids this, which violates the NEP-5.
When the from and to addresses are the same, current implementation fails to fire the event but simply return true.
Recommendation
Fix the violations
privatestaticboolTransfer(byte[]from,byte[]to,BigIntegeramount,byte[]callscript){//Check parameters
Assert(from.Length ==20&& to.Length ==20,"The parameters from and to SHOULD be 20-byte addresses.");
Assert(amount >= 0,"The parameter amount MUST be greater than 0.");if(!Runtime.CheckWitness(from)&&from.AsBigInteger()!= callscript.AsBigInteger())returnfalse;StorageMapasset= Storage.CurrentContext.CreateMap(BalanceMapKey);varfromAmount= asset.Get(from).AsBigInteger();if(fromAmount<amount)returnfalse;if(from==to){
Transferred(from, to, amount);returntrue;}
...}
The text was updated successfully, but these errors were encountered:
Description
The FlamingoSwapPairContract.Nep5 contract implements the
Transfer()
function following the NEP-5 standard.However, the current implementation has two minor issues which violate the NEP-5 standard.
Transfer()
should allow zero amount transfers with corresponding event emitted, but the assertionAssert(amount > 0, "...")
forbids this, which violates the NEP-5.from
andto
addresses are the same, current implementation fails to fire the event but simply return true.Recommendation
Fix the violations
The text was updated successfully, but these errors were encountered: