Skip to content

Commit

Permalink
fix: store address in result.target as documented
Browse files Browse the repository at this point in the history
  • Loading branch information
jfschwarz committed Apr 29, 2024
1 parent 2a5db6c commit 80e8edd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
32 changes: 16 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const detectProxy = (
})
.then(parse1167Bytecode)
.then(readAddress)
.then((address) => ({
address,
.then((target) => ({
target,
type: ProxyType.Eip1167,
immutable: true,
})),
Expand All @@ -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,
})),
Expand Down Expand Up @@ -109,8 +109,8 @@ const detectProxy = (
)
)
.then(readAddress)
.then((address) => ({
address,
.then((target) => ({
target,
type: ProxyType.Eip1967Beacon,
immutable: false,
})),
Expand All @@ -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,
})),
Expand All @@ -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,
})),
Expand All @@ -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:
Expand Down Expand Up @@ -181,8 +181,8 @@ const detectProxy = (
],
})
.then(readAddress)
.then((address) => ({
address,
.then((target) => ({
target,
type: ProxyType.Safe,
immutable: false,
})),
Expand All @@ -199,8 +199,8 @@ const detectProxy = (
],
})
.then(readAddress)
.then((address) => ({
address,
.then((target) => ({
target,
type: ProxyType.Comptroller,
immutable: false,
})),
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export enum ProxyType {
}

export interface Result {
address: `0x${string}`
target: `0x${string}`
type: ProxyType
immutable: boolean
}
Expand Down
18 changes: 9 additions & 9 deletions test/detectProxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0x4bd844f72a8edd323056130a86fc624d0dbcf5b0',
target: '0x4bd844f72a8edd323056130a86fc624d0dbcf5b0',
immutable: false,
type: 'Eip1967Direct',
})
Expand All @@ -32,7 +32,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0xe5c048792dcf2e4a56000c8b6a47f21df22752d1',
target: '0xe5c048792dcf2e4a56000c8b6a47f21df22752d1',
immutable: false,
type: 'Eip1967Beacon',
})
Expand All @@ -46,7 +46,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0x0fa0fd98727c443dd5275774c44d27cff9d279ed',
target: '0x0fa0fd98727c443dd5275774c44d27cff9d279ed',
immutable: false,
type: 'Eip1967Beacon',
})
Expand All @@ -60,7 +60,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0x0656368c4934e56071056da375d4a691d22161f8',
target: '0x0656368c4934e56071056da375d4a691d22161f8',
immutable: false,
type: 'OpenZeppelin',
})
Expand All @@ -74,7 +74,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0xe4e4003afe3765aca8149a82fc064c0b125b9e5a',
target: '0xe4e4003afe3765aca8149a82fc064c0b125b9e5a',
immutable: false,
type: 'Eip1967Direct',
})
Expand All @@ -88,7 +88,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0x210ff9ced719e9bf2444dbc3670bac99342126fa',
target: '0x210ff9ced719e9bf2444dbc3670bac99342126fa',
immutable: true,
type: 'Eip1167',
})
Expand All @@ -102,7 +102,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0x0000000010fd301be3200e67978e3cc67c962f48',
target: '0x0000000010fd301be3200e67978e3cc67c962f48',
immutable: true,
type: 'Eip1167',
})
Expand All @@ -116,7 +116,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0xd9db270c1b5e3bd161e8c8503c55ceabee709552',
target: '0xd9db270c1b5e3bd161e8c8503c55ceabee709552',
immutable: false,
type: 'Safe',
})
Expand All @@ -130,7 +130,7 @@ describe('detectProxy', () => {
BLOCK_TAG
)
).toEqual({
address: '0xbafe01ff935c7305907c33bf824352ee5979b526',
target: '0xbafe01ff935c7305907c33bf824352ee5979b526',
immutable: false,
type: 'Comptroller',
})
Expand Down

0 comments on commit 80e8edd

Please sign in to comment.