const BaseChecker = require('./../base-checker')

const ruleId = 'not-rely-on-block-hash'
const meta = {
  type: 'security',

  docs: {
    description: `Do not rely on "block.blockhash". Miners can influence its value.`,
    category: 'Security Rules'
  },

  isDefault: false,
  recommended: true,
  defaultSetup: 'warn',

  schema: []
}

class NotRelyOnBlockHashChecker extends BaseChecker {
  constructor(reporter) {
    super(reporter, ruleId, meta)
  }

  exitExpression(ctx) {
    if (ctx.getText() === 'block.blockhash') {
      this._warn(ctx)
    }
  }

  _warn(ctx) {
    this.warn(ctx, 'Do not rely on "block.blockhash". Miners can influence its value.')
  }
}

module.exports = NotRelyOnBlockHashChecker

@@ -459,72 +459,103 @@
 %0A%0A  
-exitExpression(ctx) %7B%0A    if (ctx.getText() === 'block.
+MemberAccess(node) %7B%0A    if (node.memberName === 'blockhash' && node.expression.name === '
 block
-hash
 ') %7B
@@ -572,19 +572,20 @@
 s._warn(
-ctx
+node
 )%0A    %7D%0A
@@ -597,19 +597,20 @@
   _warn(
-ctx
+node
 ) %7B%0A    
@@ -623,11 +623,12 @@
 arn(
-ctx
+node
 , 'D

Update rule: `not-rely-on-block-hash`