Skip to content

Commit d3e051d

Browse files
refactor: replace deprecated patterns
1 parent c9270cd commit d3e051d

87 files changed

Lines changed: 362 additions & 357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/slnc/cmd/decoding.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/gagliardetto/solana-go/programs/token"
2424
)
2525

26-
func decode(owner solana.PublicKey, data []byte) (interface{}, error) {
26+
func decode(owner solana.PublicKey, data []byte) (any, error) {
2727
bdx, _ := solana.PublicKeyFromBase58("BdxDnkFufu8tjAE5gdPkWdjGfQ3Lz2v6ozfiBDMKxDFW")
2828
tkn, _ := solana.PublicKeyFromBase58("TokenSVp5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o")
2929
switch owner {
@@ -33,7 +33,7 @@ func decode(owner solana.PublicKey, data []byte) (interface{}, error) {
3333
return nil, nil
3434
}
3535

36-
func decodeAsToken(data []byte) (out interface{}, err error) {
36+
func decodeAsToken(data []byte) (out any, err error) {
3737

3838
switch len(data) {
3939
case 120:

diff/diff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
type Diffeable interface {
28-
Diff(right interface{}, options ...Option)
28+
Diff(right any, options ...Option)
2929
}
3030

3131
type Option interface {
@@ -192,7 +192,7 @@ func reflectValueCanIsNil(value reflect.Value) bool {
192192
}
193193
}
194194

195-
func Diff(left interface{}, right interface{}, opts ...Option) {
195+
func Diff(left any, right any, opts ...Option) {
196196
options := options{}
197197
for _, opt := range opts {
198198
opt.apply(&options)

diff/diff_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424

2525
func TestDiff(t *testing.T) {
2626
type pair struct {
27-
left interface{}
28-
right interface{}
27+
left any
28+
right any
2929
}
3030

3131
tests := []struct {
@@ -159,8 +159,8 @@ func eventToString(event *Event) string {
159159
func TestDiff_EventMatch(t *testing.T) {
160160
tests := []struct {
161161
name string
162-
left interface{}
163-
right interface{}
162+
left any
163+
right any
164164
pattern string
165165
expectedMatch bool
166166
expectedGroups []string
@@ -195,14 +195,14 @@ func TestDiff_EventMatch(t *testing.T) {
195195
// results. I assume it's a Golang thing related to slice and struct as value versus pointers. It works
196196
// only single event but starts to act weirdly when there > 1, like the Event's Path is all wrong. It's
197197
// better to try to avoid it when possible.
198-
func accumulateDiff(left, right interface{}) (out []Event) {
198+
func accumulateDiff(left, right any) (out []Event) {
199199
Diff(left, right, OnEvent(func(event Event) {
200200
out = append(out, event)
201201
}))
202202
return
203203
}
204204

205-
func accumulateDiffStrings(left, right interface{}) (out []string) {
205+
func accumulateDiffStrings(left, right any) (out []string) {
206206
Diff(left, right, OnEvent(func(event Event) {
207207
out = append(out, eventToString(&event))
208208
}))

diff/logging.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func init() {
3030
}
3131

3232
type reflectType struct {
33-
in interface{}
33+
in any
3434
}
3535

3636
func (r reflectType) String() string {

nativetype_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func TestData_base64(t *testing.T) {
135135
)
136136

137137
assert.Equal(t,
138-
[]interface{}{
138+
[]any{
139139
val,
140140
"base64",
141141
},
@@ -162,7 +162,7 @@ func TestData_base64_empty(t *testing.T) {
162162
)
163163

164164
assert.Equal(t,
165-
[]interface{}{
165+
[]any{
166166
val,
167167
"base64",
168168
},
@@ -189,7 +189,7 @@ func TestData_base64_zstd(t *testing.T) {
189189
)
190190

191191
assert.Equal(t,
192-
[]interface{}{
192+
[]any{
193193
val,
194194
"base64+zstd",
195195
},
@@ -215,7 +215,7 @@ func TestData_base64_zstd_empty(t *testing.T) {
215215
)
216216

217217
assert.Equal(t,
218-
[]interface{}{
218+
[]any{
219219
"",
220220
"base64+zstd",
221221
},
@@ -242,7 +242,7 @@ func TestData_base58(t *testing.T) {
242242
)
243243

244244
assert.Equal(t,
245-
[]interface{}{
245+
[]any{
246246
val,
247247
"base58",
248248
},
@@ -269,7 +269,7 @@ func TestData_base58_empty(t *testing.T) {
269269
)
270270

271271
assert.Equal(t,
272-
[]interface{}{
272+
[]any{
273273
val,
274274
"base58",
275275
},
@@ -279,7 +279,7 @@ func TestData_base58_empty(t *testing.T) {
279279

280280
// mustAnyToJSON marshals the provided variable
281281
// to JSON bytes.
282-
func mustAnyToJSON(raw interface{}) []byte {
282+
func mustAnyToJSON(raw any) []byte {
283283
out, err := json.Marshal(raw)
284284
if err != nil {
285285
panic(err)
@@ -289,8 +289,8 @@ func mustAnyToJSON(raw interface{}) []byte {
289289

290290
// mustJSONToInterface unmarshals the provided JSON bytes
291291
// into an `interface{}` type variable, and returns it.
292-
func mustJSONToInterface(rawJSON []byte) interface{} {
293-
var out interface{}
292+
func mustJSONToInterface(rawJSON []byte) any {
293+
var out any
294294
err := json.Unmarshal(rawJSON, &out)
295295
if err != nil {
296296
panic(err)

nativetypes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ type Data struct {
257257

258258
func (t Data) MarshalJSON() ([]byte, error) {
259259
return json.Marshal(
260-
[]interface{}{
260+
[]any{
261261
t.String(),
262262
t.Encoding,
263263
})

programs/address-lookup-table/instructions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (inst Instruction) MarshalWithEncoder(encoder *bin.Encoder) error {
115115
return encoder.Encode(inst.Impl)
116116
}
117117

118-
func registryDecodeInstruction(accounts []*solana.AccountMeta, data []byte) (interface{}, error) {
118+
func registryDecodeInstruction(accounts []*solana.AccountMeta, data []byte) (any, error) {
119119
inst, err := DecodeInstruction(accounts, data)
120120
if err != nil {
121121
return nil, err

programs/associated-token-account/instructions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (inst Instruction) MarshalWithEncoder(encoder *bin.Encoder) error {
120120
return encoder.Encode(inst.Impl)
121121
}
122122

123-
func registryDecodeInstruction(accounts []*solana.AccountMeta, data []byte) (interface{}, error) {
123+
func registryDecodeInstruction(accounts []*solana.AccountMeta, data []byte) (any, error) {
124124
inst, err := DecodeInstruction(accounts, data)
125125
if err != nil {
126126
return nil, err

programs/compute-budget/instruction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (inst Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error {
145145
return encoder.Encode(inst.Impl)
146146
}
147147

148-
func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) {
148+
func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (any, error) {
149149
inst, err := DecodeInstruction(accounts, data)
150150
if err != nil {
151151
return nil, err

programs/memo/instructions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (inst MemoInstruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error
8484
return encoder.Encode(inst.Impl)
8585
}
8686

87-
func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) {
87+
func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (any, error) {
8888
inst, err := DecodeInstruction(accounts, data)
8989
if err != nil {
9090
return nil, err

0 commit comments

Comments
 (0)