use a better code comparison

pull/5370/head
yann300 3 years ago
parent a3424ad2a9
commit a9c77582b9
  1. 6
      libs/remix-lib/src/util.ts
  2. 5
      package-lock.json
  3. 1
      package.json

@ -1,5 +1,6 @@
'use strict'
import { BN, bufferToHex, keccak, setLengthLeft, toBuffer, addHexPrefix } from 'ethereumjs-util'
import stringSimilarity from 'string-similarity'
/*
contains misc util: @TODO should be splitted
@ -222,8 +223,9 @@ export function compareByteCode (code1, code2) {
code2 = this.extractSwarmHash(code2)
code2 = this.extractcborMetadata(code2)
if (code1 && code2 && code1.indexOf(code2) === 0) {
return true
if (code1 && code2) {
const compare = stringSimilarity.compareTwoStrings(code1, code2)
return compare > 0.5
}
return false
}

5
package-lock.json generated

@ -36072,6 +36072,11 @@
}
}
},
"string-similarity": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz",
"integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ=="
},
"string-width": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",

@ -172,6 +172,7 @@
"react-dom": "16.13.1",
"selenium": "^2.20.0",
"signale": "^1.4.0",
"string-similarity": "^4.0.4",
"time-stamp": "^2.2.0",
"tslib": "^2.3.0",
"web3": "1.2.4",

Loading…
Cancel
Save