location added and two type of warnings for ERC20

pull/7/head
aniket-engg 5 years ago
parent 742b91bd8f
commit e56e520360
  1. 17
      remix-analyzer/src/solidity-analyzer/modules/erc20Decimals.ts
  2. 9
      remix-analyzer/src/types.ts

@ -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 {
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
} }

Loading…
Cancel
Save