Skip to content

Commit 7032e6e

Browse files
committed
gomod
1 parent ded70eb commit 7032e6e

File tree

5 files changed

+713
-28
lines changed

5 files changed

+713
-28
lines changed

chains/solana/deployment/v1_6_0/sequences/tokens.go

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

devenv/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ require (
152152
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
153153
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
154154
github.com/gagliardetto/binary v0.8.0 // indirect
155+
github.com/gagliardetto/metaplex-go v0.2.1 // indirect
155156
github.com/gagliardetto/treeout v0.1.4 // indirect
156157
github.com/getsentry/sentry-go v0.27.0 // indirect
157158
github.com/gin-contrib/sse v1.1.0 // indirect

0 commit comments

Comments
 (0)