File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,15 +137,15 @@ var _ bin.EncoderDecoder = &Message{}
137137// SetVersion sets the message version.
138138// This method forces the message to be encoded in the specified version.
139139// NOTE: if you set lookups, the version will default to V0.
140- func (m * Message ) SetVersion (version MessageVersion ) * Message {
140+ func (m * Message ) SetVersion (version MessageVersion ) ( * Message , error ) {
141141 // check if the version is valid
142142 switch version {
143143 case MessageVersionV0 , MessageVersionLegacy :
144144 default :
145- panic ( fmt .Errorf ("invalid message version: %d" , version ) )
145+ return nil , fmt .Errorf ("invalid message version: %d" , version )
146146 }
147147 m .version = version
148- return m
148+ return m , nil
149149}
150150
151151// GetVersion returns the message version.
Original file line number Diff line number Diff line change @@ -329,8 +329,7 @@ func (t Data) String() string {
329329 case EncodingBase64Zstd :
330330 enc , err := zstdEncoderPool .Get (nil )
331331 if err != nil {
332- // TODO: remove panic?
333- panic (err )
332+ return fmt .Sprintf ("<zstd encoder error: %v>" , err )
334333 }
335334 defer zstdEncoderPool .Put (enc )
336335 return base64 .StdEncoding .EncodeToString (enc .EncodeAll (t .Content , nil ))
Original file line number Diff line number Diff line change @@ -14,15 +14,15 @@ import (
1414
1515var ProgramID solana.PublicKey = solana .AddressLookupTableProgramID
1616
17- func SetProgramID (pubkey solana.PublicKey ) {
17+ func SetProgramID (pubkey solana.PublicKey ) error {
1818 ProgramID = pubkey
19- solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
19+ return solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
2020}
2121
2222const ProgramName = "AddressLookupTable"
2323
2424func init () {
25- solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
25+ solana .MustRegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
2626}
2727
2828const (
Original file line number Diff line number Diff line change @@ -27,15 +27,15 @@ import (
2727
2828var ProgramID solana.PublicKey = solana .SPLAssociatedTokenAccountProgramID
2929
30- func SetProgramID (pubkey solana.PublicKey ) {
30+ func SetProgramID (pubkey solana.PublicKey ) error {
3131 ProgramID = pubkey
32- solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
32+ return solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
3333}
3434
3535const ProgramName = "AssociatedTokenAccount"
3636
3737func init () {
38- solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
38+ solana .MustRegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
3939}
4040
4141const (
Original file line number Diff line number Diff line change @@ -27,16 +27,16 @@ import (
2727
2828var ProgramID ag_solanago.PublicKey = ag_solanago .ComputeBudget
2929
30- func SetProgramID (pubkey ag_solanago.PublicKey ) {
30+ func SetProgramID (pubkey ag_solanago.PublicKey ) error {
3131 ProgramID = pubkey
32- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
32+ return ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
3333}
3434
3535const ProgramName = "ComputeBudget"
3636
3737func init () {
3838 if ! ProgramID .IsZero () {
39- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
39+ ag_solanago .MustRegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
4040 }
4141}
4242
Original file line number Diff line number Diff line change @@ -26,13 +26,13 @@ import (
2626
2727var ProgramID = ag_solanago .MemoProgramID
2828
29- func SetProgramID (pubkey ag_solanago.PublicKey ) {
29+ func SetProgramID (pubkey ag_solanago.PublicKey ) error {
3030 ProgramID = pubkey
31- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
31+ return ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
3232}
3333
3434func init () {
35- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
35+ ag_solanago .MustRegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
3636}
3737
3838type MemoInstruction struct {
Original file line number Diff line number Diff line change @@ -29,15 +29,15 @@ import (
2929
3030var ProgramID solana.PublicKey = solana .StakeProgramID
3131
32- func SetProgramID (pubkey solana.PublicKey ) {
32+ func SetProgramID (pubkey solana.PublicKey ) error {
3333 ProgramID = pubkey
34- solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
34+ return solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
3535}
3636
3737const ProgramName = "Stake"
3838
3939func init () {
40- solana .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
40+ solana .MustRegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
4141}
4242
4343const (
Original file line number Diff line number Diff line change @@ -31,15 +31,15 @@ import (
3131
3232var ProgramID ag_solanago.PublicKey = ag_solanago .SystemProgramID
3333
34- func SetProgramID (pubkey ag_solanago.PublicKey ) {
34+ func SetProgramID (pubkey ag_solanago.PublicKey ) error {
3535 ProgramID = pubkey
36- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
36+ return ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
3737}
3838
3939const ProgramName = "System"
4040
4141func init () {
42- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
42+ ag_solanago .MustRegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
4343}
4444
4545const (
Original file line number Diff line number Diff line change @@ -34,16 +34,16 @@ const MAX_SIGNERS = 11
3434
3535var ProgramID ag_solanago.PublicKey = ag_solanago .Token2022ProgramID
3636
37- func SetProgramID (pubkey ag_solanago.PublicKey ) {
37+ func SetProgramID (pubkey ag_solanago.PublicKey ) error {
3838 ProgramID = pubkey
39- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
39+ return ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
4040}
4141
4242const ProgramName = "Token2022"
4343
4444func init () {
4545 if ! ProgramID .IsZero () {
46- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
46+ ag_solanago .MustRegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
4747 }
4848}
4949
Original file line number Diff line number Diff line change @@ -33,16 +33,16 @@ const MAX_SIGNERS = 11
3333
3434var ProgramID ag_solanago.PublicKey = ag_solanago .TokenProgramID
3535
36- func SetProgramID (pubkey ag_solanago.PublicKey ) {
36+ func SetProgramID (pubkey ag_solanago.PublicKey ) error {
3737 ProgramID = pubkey
38- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
38+ return ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
3939}
4040
4141const ProgramName = "Token"
4242
4343func init () {
4444 if ! ProgramID .IsZero () {
45- ag_solanago .RegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
45+ ag_solanago .MustRegisterInstructionDecoder (ProgramID , registryDecodeInstruction )
4646 }
4747}
4848
You can’t perform that action at this time.
0 commit comments