diff --git a/remix-analyzer/src/solidity-analyzer/modules/erc20Decimals.ts b/remix-analyzer/src/solidity-analyzer/modules/erc20Decimals.ts index c89b5f2d3f..261b6afc32 100644 --- a/remix-analyzer/src/solidity-analyzer/modules/erc20Decimals.ts +++ b/remix-analyzer/src/solidity-analyzer/modules/erc20Decimals.ts @@ -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' + }) + } } } }) diff --git a/remix-analyzer/src/types.ts b/remix-analyzer/src/types.ts index 704c129d74..4ba19b23a7 100644 --- a/remix-analyzer/src/types.ts +++ b/remix-analyzer/src/types.ts @@ -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 }