Skip to content

Commit

Permalink
Upgrade go version to go1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Mar 15, 2024
1 parent 6fe3aea commit e49a571
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 3 deletions.
46 changes: 45 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,55 @@
module github.com/gagliardetto/solana-go

go 1.16
go 1.22

require (
github.com/gagliardetto/binary v0.7.7
github.com/gagliardetto/gofuzz v1.2.2
github.com/gagliardetto/treeout v0.1.4
github.com/google/uuid v1.6.0
)

require (
cloud.google.com/go v0.56.0 // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/daaku/go.zipexe v1.0.0 // indirect
github.com/dfuse-io/logging v0.0.0-20201110202154-26697de88c79 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.11 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tidwall/gjson v1.9.3 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940 // indirect
google.golang.org/grpc v1.28.0 // indirect
google.golang.org/protobuf v1.23.0 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
Expand Down
20 changes: 20 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,26 @@ func (m Message) Account(index uint16) (PublicKey, error) {
return PublicKey{}, fmt.Errorf("account index not found %d", index)
}

// GetAccountIndex returns the index of the given account (first occurrence of the account).
func (m Message) GetAccountIndex(account PublicKey) (uint16, error) {
err := m.checkPreconditions()
if err != nil {
return 0, err
}
accountKeys, err := m.GetAllKeys()
if err != nil {
return 0, err
}

for idx, a := range accountKeys {
if a.Equals(account) {
return uint16(idx), nil
}
}

return 0, fmt.Errorf("account not found: %s", account)
}

func (m Message) HasAccount(account PublicKey) (bool, error) {
err := m.checkPreconditions()
if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions programs/address-lookup-table/address-lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ func (a *AddressLookupTableState) UnmarshalWithDecoder(decoder *bin.Decoder) (er

numSerializedAddresses := serializedAddressesNumBytes / 32
if serializedAddressesNumBytes%32 != 0 {
return fmt.Errorf("lookup table is invalid")
// cut off the remaining bytes
// skip the difference
if err := decoder.Discard(serializedAddressesNumBytes % 32); err != nil {
return fmt.Errorf("failed to discard remaining bytes: %w", err)
}
// return fmt.Errorf("lookup table is invalid; serialized addresses are not a multiple of 32 bytes, with %d bytes remaining", serializedAddressesNumBytes%32)
}
if numSerializedAddresses > LOOKUP_TABLE_MAX_ADDRESSES {
return fmt.Errorf("lookup table is invalid: max addresses exceeded (%d > %d)", numSerializedAddresses, LOOKUP_TABLE_MAX_ADDRESSES)
Expand All @@ -128,7 +133,7 @@ func (a *AddressLookupTableState) UnmarshalWithDecoder(decoder *bin.Decoder) (er
a.Addresses[i] = address
}
if decoder.Remaining() != 0 {
return fmt.Errorf("failed to read all addresses: remaining %d bytes", decoder.Remaining())
// return fmt.Errorf("failed to read all addresses: remaining %d bytes", decoder.Remaining())
}
return nil
}
Expand Down

0 comments on commit e49a571

Please sign in to comment.