Skip to content

Add SetAccounts implementation to be able to access accounts for Create instruction after decoding#337

Merged
jacobcreech merged 5 commits into
solana-foundation:mainfrom
marcin-cb:main
Sep 27, 2025
Merged

Add SetAccounts implementation to be able to access accounts for Create instruction after decoding#337
jacobcreech merged 5 commits into
solana-foundation:mainfrom
marcin-cb:main

Conversation

@marcin-cb
Copy link
Copy Markdown
Contributor

@marcin-cb marcin-cb commented Sep 2, 2025

Adding some logic to be able to retrieve the accounts from the ATA instruction after decoding.

I also removed the SysVarRentPubkey in the account list for Create. According to the Rust implementation, Create only expects 6 accounts, not 7.
source.

This PR also includes changes from #308

Copy link
Copy Markdown

@gitteri gitteri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread message.go
Comment on lines +353 to +354
buf = append(buf, byte(len(mx.AddressTableLookups)))
for _, lookup := range mx.AddressTableLookups {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice clean up

Comment on lines -49 to -51
//
// [6] = [] SysVarRent
// ··········· SysVarRentPubkey
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm so confused why this was here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it wasn't clear to me either 😅

func (inst *Create) Validate() error {
if inst.Payer.IsZero() {
return errors.New("Payer not set")
return errors.New("payer not set")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty for thinking of go

Comment thread transaction.go
for _, sig := range tx.Signatures {
output = append(output, sig[:]...)
signatures := tx.Signatures
for i := len(signatures); i < int(tx.Message.Header.NumRequiredSignatures); i++ {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If len(tx.Signatures) > tx.Message.Header.NumRequiredSignatures, you’ll serialize too many signatures below in the binaryTx. The wire format is expected to match the header exactly. You can return an error early to let the user know:

if len(signatures) > tx.Message.Header.NumRequiredSignatures {
    return nil, fmt.Errorf("invalid signature length for NumRequiredSignatures header value")
}

@jacobcreech jacobcreech merged commit ac7125b into solana-foundation:main Sep 27, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants