Skip to content

Commit 4501a9d

Browse files
authored
Merge pull request #947 from BuilderOSS/fix/mainnet-manager-v2
fix: prefer latest upgrade path and remove legacy version address map
2 parents 4669d32 + 436c76c commit 4501a9d

2 files changed

Lines changed: 41 additions & 37 deletions

File tree

packages/constants/src/versions.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const versions = ['1.1.0', '1.2.0'] as const
1+
export const versions = ['1.1.0', '1.2.0', '2.0.0'] as const
22

33
export type VersionType = (typeof versions)[number]
44

@@ -9,42 +9,6 @@ type ContractVersion = {
99
}
1010
}
1111

12-
// Note: This is meant to keep record of implementations for several intermediary versions. These are also subject to change.
13-
export const CONTRACT_VERSION_ADDRESSES = {
14-
1: {
15-
'1.2.0': {
16-
auction: '0x785708d09b89c470ad7b5b3f8ac804ce72b6b282',
17-
token: '0xaed75d1e5c1821e2ec29d5d24b794b13c34c5d63',
18-
metadata: '0x5a28eef0ed8cce44cda9d7097ecce041bb51b9d4',
19-
treasury: '0x3bdafe0d299168f6ebb6e1b4e1e9702a30f6364d',
20-
governor: '0x46ea3fd17deb7b291aea60e67e5cb3a104fea11d',
21-
},
22-
'1.1.0': {
23-
auction: '0x2661fe1a882abfd28ae0c2769a90f327850397c6',
24-
token: '0xe6322201ced0a4d6595968411285a39ccf9d5989',
25-
metadata: '0x26f494af990123154e7cc067da7a311b07d54ae1',
26-
treasury: '0x0b6d2473f54de3f1d80b27c92b22d13050da289a',
27-
governor: '0x9eefef0891b1895af967fe48c5d7d96e984b96a3',
28-
},
29-
},
30-
5: {
31-
'1.2.0': {
32-
auction: '0xa6a2956fa075d50b021385478A99f3642dAfCc2C',
33-
token: '0xe26CA51f2daeE681F2802237D51c6a7982858345',
34-
metadata: '0x419074d73Cf0852e46b8531b430B1230C348C291',
35-
treasury: '0x243f389eB3E0505FC2857a1b7025789AB500E2d1',
36-
governor: '0xdA48f625903547Dc7B70Ad8E019e7dFc55d0aA96',
37-
},
38-
'1.1.0': {
39-
auction: '0x5bde6cf41cd7aa5b6e522ffa491f1bf6c6607bd3',
40-
token: '0xac193e2126f0e7734f2ac8da9d4002935b3c1d75',
41-
metadata: '0x94d792e07216796cb235e328823199fb8da3c911',
42-
treasury: '0x935522cf33ae425187aeec69737bd30ab56bd16e',
43-
governor: '0x04b2c0ea4ea3e9c92f0555fd0fb9c9564e25c52e',
44-
},
45-
},
46-
}
47-
4812
export const CONTRACT_VERSION_DETAILS: ContractVersion = {
4913
'2.0.0': {
5014
description:

packages/hooks/src/useAvailableUpgrade.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,4 +602,44 @@ describe('Use available upgrade hook', () => {
602602
},
603603
])
604604
})
605+
606+
it('shows only latest version when multiple upgrades are available', async () => {
607+
vi.mocked(useReadContracts).mockReturnValue({
608+
data: [
609+
false,
610+
'2.0.0',
611+
{
612+
governor: '2.0.0',
613+
treasury: '2.0.0',
614+
metadata: '2.0.0',
615+
auction: '2.0.0',
616+
token: '2.0.0',
617+
},
618+
{
619+
governor: '1.1.0',
620+
treasury: '1.1.0',
621+
metadata: '1.1.0',
622+
auction: '1.1.0',
623+
token: '1.1.0',
624+
},
625+
'0x1111111111111111111111111111111111111111',
626+
'0x2222222222222222222222222222222222222222',
627+
'0x3333333333333333333333333333333333333333',
628+
'0x4444444444444444444444444444444444444444',
629+
'0x5555555555555555555555555555555555555555',
630+
],
631+
isError: false,
632+
isLoading: false,
633+
} as any)
634+
635+
const { result } = renderHook(() =>
636+
useAvailableUpgrade({ chainId, addresses, contractVersion: '1.2.0' })
637+
)
638+
639+
await waitFor(() => expect(result.current.latest).toBeTruthy())
640+
641+
expect(result.current.latest).toBe('2.0.0')
642+
expect(result.current.shouldUpgrade).toBe(true)
643+
expect(result.current.totalContractUpgrades).toBe(5)
644+
})
605645
})

0 commit comments

Comments
 (0)