Unverified Commit 075051e9 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #1484 from ethereum/erc-module-location

location added and two type of warnings for ERC20
parents 742b91bd e56e5203
...@@ -29,15 +29,24 @@ export default class erc20Decimals implements AnalyzerModule { ...@@ -29,15 +29,24 @@ export default class erc20Decimals implements AnalyzerModule {
(f.returns.length === 1 && (f.returns[0].type !== 'uint8' || f.node.visibility !== 'public')) (f.returns.length === 1 && (f.returns[0].type !== 'uint8' || f.node.visibility !== 'public'))
) )
) )
if (decimalsVar.length > 0) {
if (decimalsVar.length > 0 || decimalsFun.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({ warnings.push({
warning: 'ERC20 Contracts decimals function should have uint8 as return type', warning: `ERC20 contract's 'decimals' function should have 'uint8' as return type`,
location: null, location: fn.node.src,
more: ' https://eips.ethereum.org/EIPS/eip-20' more: ' https://eips.ethereum.org/EIPS/eip-20'
}) })
} }
} }
}
}) })
return warnings return warnings
} }
......
...@@ -24,6 +24,15 @@ export interface ReportObj { ...@@ -24,6 +24,15 @@ export interface ReportObj {
more?: string 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 { export interface AnalysisReportObj extends ReportObj {
error? : string 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