Commit e56e5203 authored by aniket-engg's avatar aniket-engg

location added and two type of warnings for ERC20

parent 742b91bd
......@@ -29,13 +29,22 @@ export default class erc20Decimals implements AnalyzerModule {
(f.returns.length === 1 && (f.returns[0].type !== 'uint8' || f.node.visibility !== 'public'))
)
)
if (decimalsVar.length > 0 || decimalsFun.length > 0) {
warnings.push({
warning: 'ERC20 Contracts decimals function should have uint8 as return type',
location: null,
more: ' https://eips.ethereum.org/EIPS/eip-20'
})
if (decimalsVar.length > 0) {
for (const node of decimalsVar) {
warnings.push({
warning: `ERC20 contract's 'decimals' variable should be 'uint8' type`,
location: node.src,
more: ' https://eips.ethereum.org/EIPS/eip-20'
})
}
} else if (decimalsFun.length > 0) {
for (const fn of decimalsFun) {
warnings.push({
warning: `ERC20 contract's 'decimals' function should have 'uint8' as return type`,
location: fn.node.src,
more: ' https://eips.ethereum.org/EIPS/eip-20'
})
}
}
}
})
......
......@@ -24,6 +24,15 @@ export interface ReportObj {
more?: string
}
// Regarding location, she source mappings inside the AST use the following notation:
// s:l:f
// Where,
// s is the byte-offset to the start of the range in the source file,
// l is the length of the source range in bytes and
// f is the source index mentioned above.
export interface AnalysisReportObj extends ReportObj {
error? : string
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment