Skip to content

Commit

Permalink
Revert "adding proxy EIP1167 validation (#17)"
Browse files Browse the repository at this point in the history
This reverts commit 9f8fb7f.
  • Loading branch information
ilanolkies committed Aug 4, 2022
1 parent 034638c commit 24e4c06
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 34 deletions.
4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/lib/Constants.js

This file was deleted.

15 changes: 1 addition & 14 deletions src/lib/ContractParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } = {}) {
Expand Down Expand Up @@ -162,25 +160,14 @@ 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)
.map(t => contractsInterfaces[t] || t)
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) {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export const contractsInterfaces = {
ERC20: 'ERC20',
ERC677: 'ERC677',
ERC165: 'ERC165',
ERC721: 'ERC721',
EIP1167: 'EIP1167'
ERC721: 'ERC721'
}

const ci = contractsInterfaces
Expand Down
11 changes: 0 additions & 11 deletions test/ContractParser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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])
});
})
3 changes: 1 addition & 2 deletions test/interfaces.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit 24e4c06

Please sign in to comment.