@@ -297,6 +297,8 @@ func (a *SolanaAdapter) DeployToken() *cldf_ops.Sequence[tokenapi.DeployTokenInp
297297 var result sequences.OnChainOutput
298298 b .Logger .Info ("SVM Deploying token:" , input )
299299 chain := chains .SolanaChains ()[input .ChainSelector ]
300+ needsTokenDeploy := true
301+ var rawTokenAddr string
300302
301303 tokenAddr , err := datastore_utils .FindAndFormatRef (input .ExistingDataStore , datastore.AddressRef {
302304 ChainSelector : chain .Selector ,
@@ -305,36 +307,41 @@ func (a *SolanaAdapter) DeployToken() *cldf_ops.Sequence[tokenapi.DeployTokenInp
305307 }, chain .Selector , datastore_utils .FullRef )
306308 if err == nil {
307309 b .Logger .Info ("Token already deployed at address:" , tokenAddr .Address )
308- return result , nil
309- }
310-
311- var privateKey solana.PrivateKey
312- if input .TokenPrivKey != "" {
313- privateKey = solana .MustPrivateKeyFromBase58 (input .TokenPrivKey )
314- }
315- ataList := []solana.PublicKey {}
316- for _ , sender := range input .Senders {
317- ataList = append (ataList , solana .MustPublicKeyFromBase58 (sender ))
318- }
319- var premint uint64 = 0
320- if input .PreMint != nil {
321- premint = input .PreMint .Uint64 ()
322- }
323- deployOut , err := operations .ExecuteOperation (b , tokensops .DeploySolanaToken , chains .SolanaChains ()[chain .Selector ], tokensops.Params {
324- ExistingAddresses : input .ExistingDataStore .Addresses ().Filter (),
325- TokenProgramName : input .Type ,
326- TokenPrivKey : privateKey ,
327- TokenSymbol : input .Symbol ,
328- ATAList : ataList ,
329- PreMint : premint ,
330- DisableFreezeAuthority : input .DisableFreezeAuthority ,
331- TokenDecimals : input .Decimals ,
332- })
333- if err != nil {
334- return sequences.OnChainOutput {}, fmt .Errorf ("failed to deploy token: %w" , err )
310+ needsTokenDeploy = false
311+ rawTokenAddr = tokenAddr .Address
312+ }
313+ if needsTokenDeploy {
314+ var privateKey solana.PrivateKey
315+ if input .TokenPrivKey != "" {
316+ privateKey = solana .MustPrivateKeyFromBase58 (input .TokenPrivKey )
317+ }
318+ ataList := []solana.PublicKey {}
319+ for _ , sender := range input .Senders {
320+ ataList = append (ataList , solana .MustPublicKeyFromBase58 (sender ))
321+ }
322+ var premint uint64 = 0
323+ if input .PreMint != nil {
324+ premint = input .PreMint .Uint64 ()
325+ }
326+ deployOut , err := operations .ExecuteOperation (b , tokensops .DeploySolanaToken , chains .SolanaChains ()[chain .Selector ], tokensops.Params {
327+ ExistingAddresses : input .ExistingDataStore .Addresses ().Filter (),
328+ TokenProgramName : input .Type ,
329+ TokenPrivKey : privateKey ,
330+ TokenSymbol : input .Symbol ,
331+ ATAList : ataList ,
332+ PreMint : premint ,
333+ DisableFreezeAuthority : input .DisableFreezeAuthority ,
334+ TokenDecimals : input .Decimals ,
335+ })
336+ if err != nil {
337+ return sequences.OnChainOutput {}, fmt .Errorf ("failed to deploy token: %w" , err )
338+ }
339+ result .Addresses = append (result .Addresses , deployOut .Output )
340+ rawTokenAddr = deployOut .Output .Address
335341 }
336- result . Addresses = append ( result . Addresses , deployOut . Output )
342+ // irrrespective of whether the token was just deployed or already existed, we attempt to upload metadata if it was provided, since the metadata might not have been uploaded in a previous deployment
337343 if input .TokenMetadata != nil {
344+ input .TokenMetadata .TokenPubkey = rawTokenAddr
338345 _ , err = operations .ExecuteOperation (b , tokensops .UpsertTokenMetadata , chains .SolanaChains ()[chain .Selector ], tokensops.TokenMetadataInput {
339346 ExistingAddresses : input .ExistingDataStore .Addresses ().Filter (),
340347 Metadata : * input .TokenMetadata ,
0 commit comments