@@ -42,10 +42,6 @@ import {
42
42
} from "@wormhole-foundation/sdk-solana-core" ;
43
43
import BN from "bn.js" ;
44
44
import { NTT , NttQuoter , WEI_PER_GWEI } from "../lib/index.js" ;
45
- import {
46
- BPF_LOADER_UPGRADEABLE_PROGRAM_ID ,
47
- programDataAddress ,
48
- } from "./utils.js" ;
49
45
50
46
import { IdlVersion , NttBindings , getNttProgram } from "../lib/bindings.js" ;
51
47
@@ -177,35 +173,17 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
177
173
outboundLimit : bigint ;
178
174
mode : "burning" | "locking" ;
179
175
} ) {
180
- const mode : any =
181
- args . mode === "burning" ? { burning : { } } : { locking : { } } ;
182
- const chainId = toChainId ( args . chain ) ;
183
176
const mintInfo = await this . connection . getAccountInfo ( args . mint ) ;
184
- if ( mintInfo === null ) {
177
+ if ( mintInfo === null )
185
178
throw new Error (
186
179
"Couldn't determine token program. Mint account is null."
187
180
) ;
188
- }
189
181
190
- const tokenProgram = mintInfo . owner ;
191
- const limit = new BN ( args . outboundLimit . toString ( ) ) ;
192
- const ix = await this . program . methods
193
- . initialize ( { chainId, limit : limit , mode } )
194
- . accountsStrict ( {
195
- payer : args . payer ,
196
- deployer : args . owner ,
197
- programData : programDataAddress ( this . program . programId ) ,
198
- config : this . pdas . configAccount ( ) ,
199
- mint : args . mint ,
200
- rateLimit : this . pdas . outboxRateLimitAccount ( ) ,
201
- tokenProgram,
202
- tokenAuthority : this . pdas . tokenAuthority ( ) ,
203
- custody : await this . custodyAccountAddress ( args . mint , tokenProgram ) ,
204
- bpfLoaderUpgradeableProgram : BPF_LOADER_UPGRADEABLE_PROGRAM_ID ,
205
- associatedTokenProgram : splToken . ASSOCIATED_TOKEN_PROGRAM_ID ,
206
- systemProgram : SystemProgram . programId ,
207
- } )
208
- . instruction ( ) ;
182
+ const ix = await NTT . createInitializeInstruction (
183
+ this . program ,
184
+ { ...args , tokenProgram : mintInfo . owner } ,
185
+ this . pdas
186
+ ) ;
209
187
210
188
const tx = new Transaction ( ) ;
211
189
tx . feePayer = args . payer ;
@@ -783,32 +761,6 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
783
761
return xfer ;
784
762
}
785
763
786
- /**
787
- * Returns the address of the custody account. If the config is available
788
- * (i.e. the program is initialised), the mint is derived from the config.
789
- * Otherwise, the mint must be provided.
790
- */
791
- async custodyAccountAddress (
792
- configOrMint : NttBindings . Config < IdlVersion > | PublicKey ,
793
- tokenProgram = splToken . TOKEN_PROGRAM_ID
794
- ) : Promise < PublicKey > {
795
- if ( configOrMint instanceof PublicKey ) {
796
- return splToken . getAssociatedTokenAddress (
797
- configOrMint ,
798
- this . pdas . tokenAuthority ( ) ,
799
- true ,
800
- tokenProgram
801
- ) ;
802
- } else {
803
- return splToken . getAssociatedTokenAddress (
804
- configOrMint . mint ,
805
- this . pdas . tokenAuthority ( ) ,
806
- true ,
807
- configOrMint . tokenProgram
808
- ) ;
809
- }
810
- }
811
-
812
764
async getAddressLookupTable (
813
765
useCache = true
814
766
) : Promise < AddressLookupTableAccount > {
0 commit comments