use a better code comparison

pull/1344/head
yann300 3 years ago committed by joseph izang
parent af4097caa9
commit 3adf7655c1
  1. 6
      libs/remix-lib/src/util.ts
  2. 5
      package-lock.json
  3. 1
      package.json

@ -1,5 +1,6 @@
'use strict' 'use strict'
import { BN, bufferToHex, keccak, setLengthLeft, toBuffer, addHexPrefix } from 'ethereumjs-util' import { BN, bufferToHex, keccak, setLengthLeft, toBuffer, addHexPrefix } from 'ethereumjs-util'
import stringSimilarity from 'string-similarity'
/* /*
contains misc util: @TODO should be splitted contains misc util: @TODO should be splitted
@ -222,8 +223,9 @@ export function compareByteCode (code1, code2) {
code2 = this.extractSwarmHash(code2) code2 = this.extractSwarmHash(code2)
code2 = this.extractcborMetadata(code2) code2 = this.extractcborMetadata(code2)
if (code1 && code2 && code1.indexOf(code2) === 0) { if (code1 && code2) {
return true const compare = stringSimilarity.compareTwoStrings(code1, code2)
return compare > 0.5
} }
return false 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": { "string-width": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",

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

Loading…
Cancel
Save