From 24e4c06ca223227d376ed2f2fcd66c1b5d36587a Mon Sep 17 00:00:00 2001 From: Ilan Date: Wed, 3 Aug 2022 21:03:05 -0300 Subject: [PATCH] Revert "adding proxy EIP1167 validation (#17)" This reverts commit 9f8fb7ffab6307228e5d21fbf57e2a5266ba0e8e. --- src/index.js | 4 +--- src/lib/Constants.js | 2 -- src/lib/ContractParser.js | 15 +-------------- src/lib/types.js | 3 +-- test/ContractParser.spec.js | 11 ----------- test/interfaces.spec.js | 3 +-- 6 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 src/lib/Constants.js diff --git a/src/index.js b/src/index.js index b92a6ea..bcf3c36 100644 --- a/src/index.js +++ b/src/index.js @@ -2,8 +2,6 @@ import { ContractParser } from './lib/ContractParser' import { BcSearch } from './lib/BcSearch' import Contract from './lib/Contract' import bridge from './lib/nativeContracts/bridgeAbi' -import { contractsInterfaces } from './lib/types' const abi = { bridge } -const types = { contractsInterfaces } -export { ContractParser, BcSearch, Contract, abi, types } +export { ContractParser, BcSearch, Contract, abi } export default ContractParser diff --git a/src/lib/Constants.js b/src/lib/Constants.js deleted file mode 100644 index 84b961c..0000000 --- a/src/lib/Constants.js +++ /dev/null @@ -1,2 +0,0 @@ -export const EIP_1167_PREFIX='363d3d373d3d3d363d73'; -export const EIP_1167_SUFFIX='5af43d82803e903d91602b57fd5bf3'; diff --git a/src/lib/ContractParser.js b/src/lib/ContractParser.js index 10f8173..3161296 100755 --- a/src/lib/ContractParser.js +++ b/src/lib/ContractParser.js @@ -13,8 +13,6 @@ import { soliditySelector, soliditySignature } from './utils' -import { remove0x } from '@rsksmart/rsk-utils/dist/strings' -import { EIP_1167_PREFIX, EIP_1167_SUFFIX } from './Constants'; export class ContractParser { constructor ({ abi, log, initConfig, nod3 } = {}) { @@ -162,7 +160,6 @@ export class ContractParser { } let interfaces if (isErc165) interfaces = await this.getInterfacesERC165(contract) - else if (this.isEIP1167(txInputData)) interfaces = { EIP1167: true }; else interfaces = this.getInterfacesByMethods(methods) interfaces = Object.keys(interfaces) .filter(k => interfaces[k] === true) @@ -170,17 +167,7 @@ export class ContractParser { return { methods, interfaces } } - getEip1167MasterCopy (bytecode) { - const implementationAddress = bytecode.replace(EIP_1167_PREFIX, '').replace(EIP_1167_SUFFIX, ''); - return implementationAddress; - } - - isEIP1167(bytecode) { - const re = new RegExp(`^${EIP_1167_PREFIX}[a-f0-9]{40}${EIP_1167_SUFFIX}$`, 'i'); - return re.test(remove0x(bytecode)); - } - - async getInterfacesERC165(contract) { + async getInterfacesERC165 (contract) { let ifaces = {} let keys = Object.keys(interfacesIds) for (let i of keys) { diff --git a/src/lib/types.js b/src/lib/types.js index 34425ce..12fff35 100755 --- a/src/lib/types.js +++ b/src/lib/types.js @@ -18,8 +18,7 @@ export const contractsInterfaces = { ERC20: 'ERC20', ERC677: 'ERC677', ERC165: 'ERC165', - ERC721: 'ERC721', - EIP1167: 'EIP1167' + ERC721: 'ERC721' } const ci = contractsInterfaces diff --git a/test/ContractParser.spec.js b/test/ContractParser.spec.js index e8b60de..13ff2c8 100644 --- a/test/ContractParser.spec.js +++ b/test/ContractParser.spec.js @@ -5,9 +5,6 @@ import nod3 from '../src/lib/nod3Connect' const contracts = [ '0xebea27d994371cd0cb9896ae4c926bc5221f6317'] -const proxyContract = "0xc7bC8A9523e04CD82cb19f5D95E38d0258EEf810"; -const masterProxyContract = "0x2a37eedf9724f1c748b5cf88594bd1d29612b7f9"; - const parser = new ContractParser({ nod3 }) describe('# Network', function () { @@ -27,12 +24,4 @@ describe('Contract parser', function () { console.log({ info }) }) } - - it('should return the master of proxy contract',async ()=>{ - const code = await nod3.eth.getCode(proxyContract) - //let info = await parser.getContractInfo(code, contract) - const masterCopy = parser.getMasterCopy(code); - assert.equal(masterCopy,masterProxyContract); - //assert.includeMembers(interfaces, addresses[address]) - }); }) diff --git a/test/interfaces.spec.js b/test/interfaces.spec.js index 314b4d2..7a23408 100755 --- a/test/interfaces.spec.js +++ b/test/interfaces.spec.js @@ -23,8 +23,7 @@ const addresses = { '0x4626f072c42afed36d7aad7f2ab9fa9e16bdb72a': ['ERC165', 'ERC721', 'ERC721Enumerable', 'ERC721Metadata'], '0x1e6d0bad215c6407f552e4d1260e7bae90005ab2': ['ERC165', 'ERC721', 'ERC721Enumerable', 'ERC721Metadata'], '0xe59f2877a51e570fbf751a07d50899838e6b6cc7': ['ERC721'], - '0x7974f2971e0b5d68f30513615fafec5c451da4d1': ['ERC20', 'ERC677'], - '0xc7bc8a9523e04cd82cb19f5d95e38d0258eef810': ['EIP1167'] + '0x7974f2971e0b5d68f30513615fafec5c451da4d1': ['ERC20', 'ERC677'] } const parser = new ContractParser({ nod3 })