Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check NEP11 methods #777

Closed
wants to merge 10 commits into from
13 changes: 12 additions & 1 deletion src/TokensTracker/Trackers/NEP-11/Nep11Tracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,18 @@ public override void OnPersist(NeoSystem system, Block block, DataCache snapshot
Log($"{state.Hash} is not nft!", LogLevel.Warning);
continue;
}

if (balanceMethod != null &&
!(balanceMethod.Parameters[0].Type == ContractParameterType.Hash160 && balanceMethod.ReturnType == ContractParameterType.Integer))
{
Log($"{state.Hash} is not nft:balance1!", LogLevel.Warning);
continue;
}
if (balanceMethod2 != null &&
Copy link
Member

@cschuchardt88 cschuchardt88 Aug 25, 2023

Choose a reason for hiding this comment

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

should be an else if Because the function is one or the other. Also if the token has both functions you don't check for that either. As the code sits right now, if 1st function exists look for other function. Which isn't valid to what NEP-11 says
https://github.com/neo-project/proposals/blob/master/nep-11.mediawiki#user-content-decimals

You need to get the decimals to determined which function to use.

Edit: this may help you sum up that function into a class
https://github.com/cschuchardt88/neo-modules/blob/RestServer/src/RestServer/Tokens/NEP11Token.cs

Copy link
Member

Choose a reason for hiding this comment

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

I think also balance1 and balance2 is a bad naming.
Let's say something like "balanceInteger" and "balanceDivisible"

Copy link
Member

Choose a reason for hiding this comment

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

Also there is no need to check to abi for these functions.

@vncoelho I think balanceDivisible and balanceNonDivisible would fit better.

!(balanceMethod2.Parameters[0].Type == ContractParameterType.Hash160 && balanceMethod2.Parameters[1].Type == ContractParameterType.ByteArray && balanceMethod2.ReturnType == ContractParameterType.Integer))
{
Log($"{state.Hash} is not nft:balance2!", LogLevel.Warning);
continue;
}
var isDivisible = balanceMethod2 != null;
contracts[transferRecord.asset] = (isDivisible, state);
}
Expand Down