Open lukestoltenberg opened 5 months ago
When unmarshalling a transaction from []byte it creates a pointer to the instruction's BaseVariant.Impl but when creating a token.Instruction using a builder like token.NewMintToCheckedInstructionBuilder() the BaseVariant.Impl is a value.
[]byte
BaseVariant.Impl
token.Instruction
token.NewMintToCheckedInstructionBuilder()
For example, token.NewMintToCheckedInstructionBuilder(), the .Build() sets the BaseVariant.Impl to the receiver value of inst MintToChecked https://github.com/gagliardetto/solana-go/blob/a5e17d6253468337b4851105413f827a8b152f5a/programs/token/MintToChecked.go#L135
.Build()
inst MintToChecked
When using UnmarshalBin of a []byte, it sets the BaseVariant.Impl to a pointer, https://github.com/gagliardetto/binary/blob/79f49c5de0e11369897085d761a7e27cbd8eab15/variant.go#L320.
UnmarshalBin
To fix this, I propose changing the instructions' .Build() to take a pointer receiver
func (inst *MintToChecked) Build() *Instruction
When unmarshalling a transaction from
[]byte
it creates a pointer to the instruction'sBaseVariant.Impl
but when creating atoken.Instruction
using a builder liketoken.NewMintToCheckedInstructionBuilder()
theBaseVariant.Impl
is a value.For example,
token.NewMintToCheckedInstructionBuilder()
, the.Build()
sets theBaseVariant.Impl
to the receiver value ofinst MintToChecked
https://github.com/gagliardetto/solana-go/blob/a5e17d6253468337b4851105413f827a8b152f5a/programs/token/MintToChecked.go#L135When using
UnmarshalBin
of a[]byte
, it sets theBaseVariant.Impl
to a pointer, https://github.com/gagliardetto/binary/blob/79f49c5de0e11369897085d761a7e27cbd8eab15/variant.go#L320.To fix this, I propose changing the instructions'
.Build()
to take a pointer receiver