-
Notifications
You must be signed in to change notification settings - Fork 60
add ATA creation utils #1396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
add ATA creation utils #1396
Conversation
|
| func GetOrCreateATAIx( | ||
| ctx context.Context, | ||
| client client.MultiClient, | ||
| mint, owner, payer solana.PublicKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll also want a tokenProgram solana.PublicKey in the signature too
| mint, owner, payer solana.PublicKey, | ||
| ) (ata solana.PublicKey, ix solana.Instruction, err error) { | ||
| // Derive ATA | ||
| ata, _, err = solana.FindAssociatedTokenAddress(owner, mint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming is kind of confusing but I think we'll want the tokens.FindAssociatedTokenAddress here instead. The import being "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/tokens"
| client client.MultiClient, | ||
| mint, owner, payer solana.PublicKey, | ||
| ) (ata solana.PublicKey, ix solana.Instruction, err error) { | ||
| // Derive ATA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's overkill but in our existing ChainWriter code we also validate that the mint is a valid one before continuing. Maybe we can add that here too for safety.
chainlink-solana/pkg/solana/chainwriter/ata_creation.go
Lines 61 to 69 in acc1c8e
| accountInfo, err := client.GetAccountInfoWithOpts(ctx, mint.PublicKey, &rpc.GetAccountInfoOpts{ | |
| Commitment: rpc.CommitmentFinalized, | |
| }) | |
| if err != nil { | |
| return nil, fmt.Errorf("failed to fetch account info for token mint %s: %w", mint.PublicKey.String(), err) | |
| } | |
| if accountInfo == nil || accountInfo.Value == nil { | |
| return nil, fmt.Errorf("failed to fetch account info for token mint %s", mint.PublicKey.String()) | |
| } |
| } | ||
|
|
||
| // Build ATA creation since Probe doesn't exists | ||
| ix = associatedtokenaccount.NewCreateInstruction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to stick to the tokens package and use tokens.CreateAssociatedTokenAccount here instead also
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |


Description
Requires Dependencies
Resolves Dependencies