File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
yarn-project/ethereum/src/contracts Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,10 @@ describe('Registry', () => {
81
81
const address = await registry . getRollupAddress ( deployedVersion ) ;
82
82
expect ( address ) . toEqual ( rollupAddress ) ;
83
83
}
84
+ {
85
+ const address = await registry . getRollupAddress ( 0 ) ;
86
+ expect ( address ) . toEqual ( rollupAddress ) ;
87
+ }
84
88
} ) ;
85
89
86
90
it ( 'handles non-existent versions' , async ( ) => {
Original file line number Diff line number Diff line change 1
1
import { EthAddress } from '@aztec/foundation/eth-address' ;
2
+ import { createLogger } from '@aztec/foundation/log' ;
2
3
import { RegistryAbi } from '@aztec/l1-artifacts/RegistryAbi' ;
3
4
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi' ;
4
5
@@ -18,6 +19,8 @@ import { RollupContract } from './rollup.js';
18
19
19
20
export class RegistryContract {
20
21
public address : EthAddress ;
22
+
23
+ private readonly log = createLogger ( 'ethereum:contracts:registry' ) ;
21
24
private readonly registry : GetContractReturnType < typeof RegistryAbi , PublicClient < HttpTransport , Chain > > ;
22
25
23
26
constructor ( public readonly client : L1Clients [ 'publicClient' ] , address : Hex | EthAddress ) {
@@ -44,6 +47,14 @@ export class RegistryContract {
44
47
45
48
try {
46
49
return EthAddress . fromString ( await this . registry . read . getRollup ( [ version ] ) ) ;
50
+ } catch ( e ) {
51
+ this . log . warn ( `Failed fetching rollup address for version ${ version } . Retrying as index.` ) ;
52
+ }
53
+
54
+ try {
55
+ const actualVersion = await this . registry . read . getVersion ( [ version ] ) ;
56
+ const rollupAddress = await this . registry . read . getRollup ( [ actualVersion ] ) ;
57
+ return EthAddress . fromString ( rollupAddress ) ;
47
58
} catch ( e ) {
48
59
throw new Error ( 'Rollup address is undefined' ) ;
49
60
}
You can’t perform that action at this time.
0 commit comments