@@ -49,6 +49,7 @@ import {
49
49
BPF_LOADER_UPGRADEABLE_PROGRAM_ID ,
50
50
chainToBytes ,
51
51
derivePda ,
52
+ parseVersion ,
52
53
programDataAddress ,
53
54
programVersionLayout ,
54
55
} from "./utils.js" ;
@@ -266,8 +267,9 @@ export namespace NTT {
266
267
} ,
267
268
pdas ?: Pdas
268
269
) {
269
- // if the program is at version 1.0.0, we don't need to initialize the LUT
270
- if ( program . idl . version === "1.0.0" ) return ;
270
+ // if the program is < major version 2.x.x, we don't need to initialize the LUT
271
+ const [ major , , ] = parseVersion ( program . idl . version ) ;
272
+ if ( major < 2 ) return ;
271
273
272
274
pdas = pdas ?? NTT . pdas ( program . programId ) ;
273
275
@@ -318,10 +320,8 @@ export namespace NTT {
318
320
} ;
319
321
const pubkeys = collectPubkeys ( entries ) . map ( ( pk ) => pk . toBase58 ( ) ) ;
320
322
321
- let existingLut : web3 . AddressLookupTableAccount | null = null ;
322
- try {
323
- existingLut = await getAddressLookupTable ( program , pdas ) ;
324
- } catch { }
323
+ let existingLut : web3 . AddressLookupTableAccount | null =
324
+ await getAddressLookupTable ( program , pdas ) ;
325
325
326
326
if ( existingLut !== null ) {
327
327
const existingPubkeys =
@@ -996,9 +996,9 @@ export namespace NTT {
996
996
export async function getAddressLookupTable (
997
997
program : Program < NttBindings . NativeTokenTransfer < IdlVersion > > ,
998
998
pdas ?: Pdas
999
- ) : Promise < AddressLookupTableAccount > {
1000
- if ( program . idl . version === "1.0.0" )
1001
- throw new Error ( "Lookup tables not supported for this version" ) ;
999
+ ) : Promise < AddressLookupTableAccount | null > {
1000
+ const [ major , , ] = parseVersion ( program . idl . version ) ;
1001
+ if ( major < 2 ) return null ;
1002
1002
1003
1003
pdas = pdas ?? NTT . pdas ( program . programId ) ;
1004
1004
const lut = await program . account . lut . fetchNullable ( pdas . lutAccount ( ) ) ;
0 commit comments