@@ -10,6 +10,7 @@ import (
1010 "github.com/ethereum/go-ethereum/accounts/abi/bind"
1111 "github.com/ethereum/go-ethereum/common"
1212 "github.com/gagliardetto/solana-go"
13+ solToken "github.com/gagliardetto/solana-go/programs/token"
1314
1415 cldf_solana "github.com/smartcontractkit/chainlink-deployments-framework/chain/solana"
1516
@@ -233,19 +234,36 @@ func AddTokenPoolAndLookupTable(e cldf.Environment, cfg AddTokenPoolAndLookupTab
233234
234235 instructions = append (instructions , poolInitI )
235236
237+ // fetch current token mint authority
238+ var tokenMint solToken.Mint
239+ err = chain .GetAccountDataBorshInto (context .Background (), tokenPubKey , & tokenMint )
240+ if err != nil {
241+ return cldf.ChangesetOutput {}, fmt .Errorf ("failed to get token mint account data: %w" , err )
242+ }
243+
236244 // make pool mint_authority for token
237245 if tokenPoolCfg .PoolType == shared .BurnMintTokenPool && tokenPubKey != solana .SolMint {
238- authI , err := solTokenUtil .SetTokenMintAuthority (
239- tokenprogramID ,
240- poolSigner ,
241- tokenPubKey ,
242- chain .DeployerKey .PublicKey (),
243- )
244- if err != nil {
245- return cldf.ChangesetOutput {}, fmt .Errorf ("failed to generate instructions: %w" , err )
246+ if tokenMint .MintAuthority != nil && tokenMint .MintAuthority .String () == chain .DeployerKey .PublicKey ().String () {
247+ authI , err := solTokenUtil .SetTokenMintAuthority (
248+ tokenprogramID ,
249+ poolSigner ,
250+ tokenPubKey ,
251+ chain .DeployerKey .PublicKey (),
252+ )
253+ if err != nil {
254+ return cldf.ChangesetOutput {}, fmt .Errorf ("failed to generate instructions: %w" , err )
255+ }
256+ instructions = append (instructions , authI )
257+ e .Logger .Infow ("Setting mint authority" , "poolSigner" , poolSigner .String ())
258+ } else {
259+ e .Logger .Warnw ("Token's mint authority is not with deployer key, skipping setting poolSigner as mint authority" ,
260+ "poolType" , tokenPoolCfg .PoolType , "mintAuthority" , tokenMint .MintAuthority .String (),
261+ "deployer" , chain .DeployerKey .PublicKey ().String (), "poolSigner" , poolSigner .String ())
246262 }
247- instructions = append (instructions , authI )
248- e .Logger .Infow ("Setting mint authority" , "poolSigner" , poolSigner .String ())
263+ } else {
264+ e .Logger .Warnw ("PoolType is not a BurnMintTokenPool, skipping setting poolSigner as mint authority" ,
265+ "poolType" , tokenPoolCfg .PoolType , "mintAuthority" , tokenMint .MintAuthority .String (),
266+ "deployer" , chain .DeployerKey .PublicKey ().String (), "poolSigner" , poolSigner .String ())
249267 }
250268
251269 // confirm instructions
0 commit comments