diff --git a/src/index.ts b/src/index.ts index 61ac094..17d074a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -61,8 +61,8 @@ const detectProxy = ( }) .then(parse1167Bytecode) .then(readAddress) - .then((address) => ({ - address, + .then((target) => ({ + target, type: ProxyType.Eip1167, immutable: true, })), @@ -73,8 +73,8 @@ const detectProxy = ( params: [proxyAddress, EIP_1967_LOGIC_SLOT, blockTag], }) .then(readAddress) - .then((address) => ({ - address, + .then((target) => ({ + target, type: ProxyType.Eip1967Direct, immutable: false, })), @@ -109,8 +109,8 @@ const detectProxy = ( ) ) .then(readAddress) - .then((address) => ({ - address, + .then((target) => ({ + target, type: ProxyType.Eip1967Beacon, immutable: false, })), @@ -121,8 +121,8 @@ const detectProxy = ( params: [proxyAddress, OPEN_ZEPPELIN_IMPLEMENTATION_SLOT, blockTag], }) .then(readAddress) - .then((address) => ({ - address, + .then((target) => ({ + target, type: ProxyType.OpenZeppelin, immutable: false, })), @@ -133,8 +133,8 @@ const detectProxy = ( params: [proxyAddress, EIP_1822_LOGIC_SLOT, blockTag], }) .then(readAddress) - .then((address) => ({ - address, + .then((target) => ({ + target, type: ProxyType.Eip1822, immutable: false, })), @@ -151,8 +151,8 @@ const detectProxy = ( ], }) .then(readAddress) - .then(async (address) => ({ - address, + .then(async (target) => ({ + target, type: ProxyType.Eip897, // proxyType === 1 means that the proxy is immutable immutable: @@ -181,8 +181,8 @@ const detectProxy = ( ], }) .then(readAddress) - .then((address) => ({ - address, + .then((target) => ({ + target, type: ProxyType.Safe, immutable: false, })), @@ -199,8 +199,8 @@ const detectProxy = ( ], }) .then(readAddress) - .then((address) => ({ - address, + .then((target) => ({ + target, type: ProxyType.Comptroller, immutable: false, })), diff --git a/src/types.ts b/src/types.ts index d2794cf..b62bd6e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,7 +10,7 @@ export enum ProxyType { } export interface Result { - address: `0x${string}` + target: `0x${string}` type: ProxyType immutable: boolean } diff --git a/test/detectProxy.spec.ts b/test/detectProxy.spec.ts index ba3453e..fc725e1 100644 --- a/test/detectProxy.spec.ts +++ b/test/detectProxy.spec.ts @@ -18,7 +18,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0x4bd844f72a8edd323056130a86fc624d0dbcf5b0', + target: '0x4bd844f72a8edd323056130a86fc624d0dbcf5b0', immutable: false, type: 'Eip1967Direct', }) @@ -32,7 +32,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0xe5c048792dcf2e4a56000c8b6a47f21df22752d1', + target: '0xe5c048792dcf2e4a56000c8b6a47f21df22752d1', immutable: false, type: 'Eip1967Beacon', }) @@ -46,7 +46,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0x0fa0fd98727c443dd5275774c44d27cff9d279ed', + target: '0x0fa0fd98727c443dd5275774c44d27cff9d279ed', immutable: false, type: 'Eip1967Beacon', }) @@ -60,7 +60,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0x0656368c4934e56071056da375d4a691d22161f8', + target: '0x0656368c4934e56071056da375d4a691d22161f8', immutable: false, type: 'OpenZeppelin', }) @@ -74,7 +74,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0xe4e4003afe3765aca8149a82fc064c0b125b9e5a', + target: '0xe4e4003afe3765aca8149a82fc064c0b125b9e5a', immutable: false, type: 'Eip1967Direct', }) @@ -88,7 +88,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0x210ff9ced719e9bf2444dbc3670bac99342126fa', + target: '0x210ff9ced719e9bf2444dbc3670bac99342126fa', immutable: true, type: 'Eip1167', }) @@ -102,7 +102,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0x0000000010fd301be3200e67978e3cc67c962f48', + target: '0x0000000010fd301be3200e67978e3cc67c962f48', immutable: true, type: 'Eip1167', }) @@ -116,7 +116,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0xd9db270c1b5e3bd161e8c8503c55ceabee709552', + target: '0xd9db270c1b5e3bd161e8c8503c55ceabee709552', immutable: false, type: 'Safe', }) @@ -130,7 +130,7 @@ describe('detectProxy', () => { BLOCK_TAG ) ).toEqual({ - address: '0xbafe01ff935c7305907c33bf824352ee5979b526', + target: '0xbafe01ff935c7305907c33bf824352ee5979b526', immutable: false, type: 'Comptroller', })