Skip to content

Commit

Permalink
Fix nil idlType handling and update test IDL names
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Dec 23, 2024
1 parent 22a3c5f commit 9ae0236
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 0 additions & 1 deletion pkg/solana/chainreader/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func doMethodBatchCall(ctx context.Context, client MultipleAccountGetter, bindin
results[idx].err,
binding.Decode(ctx, data[idx], results[idx].returnVal),
)

continue
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/solana/chainreader/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,12 @@ type accountIDLTypes struct {
}

func (s *SolanaChainReaderService) addAccountRead(namespace string, itemType string, idl codec.IDL, idlType codec.IdlTypeDef, readDefinition config.ReadDefinition) error {
if err := s.addCodecDef(true, namespace, itemType, codec.ChainConfigTypeAccountDef, idl, idlType, readDefinition.InputModifications); err != nil {
inputAccountIDLDef := codec.NilIdlTypeDefTy
// TODO:
// if hasPDA{
// inputAccountIDLDef = pdaType
// }
if err := s.addCodecDef(true, namespace, itemType, codec.ChainConfigTypeAccountDef, idl, inputAccountIDLDef, readDefinition.InputModifications); err != nil {
return err
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/solana/chainreader/chain_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (r *chainReaderInterfaceTester) Setup(t *testing.T) {
ReadType: config.Account,
OutputModifications: codeccommon.ModifiersConfig{
&codeccommon.AddressBytesToStringModifierConfig{
Fields: []string{"Accountstruct.Accountstr"},
Fields: []string{"AccountStruct.AccountStr"},
},
&codeccommon.HardCodeModifierConfig{OffChainValues: map[string]any{"ExtraField": AnyExtraValue}},
},
Expand Down Expand Up @@ -810,20 +810,20 @@ const (
{"name": "nestedStaticStruct","type": {"defined": "MidLevelStaticStruct"}},
{"name": "oracleID","type": "u8"},
{"name": "oracleIDs","type": {"array": ["u8",32]}},
{"name": "accountstruct","type": {"defined": "accountstruct"}},
{"name": "accountStruct","type": {"defined": "accountStruct"}},
{"name": "accounts","type": {"vec": "bytes"}}
]
}
}`

accountStructIDL = `{
"name": "accountstruct",
"name": "accountStruct",
"type": {
"kind": "struct",
"fields": [
{"name": "account", "type": "bytes"},
{"name": "accountstr", "type": {"array": ["u8",32]}}
{"name": "accountStr", "type": {"array": ["u8",32]}}
]
}
}`
Expand Down
5 changes: 5 additions & 0 deletions pkg/solana/codec/anchoridl.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ type IdlTypeDefTyEnum struct {
Variants IdlEnumVariantSlice `json:"variants,omitempty"`
}

var NilIdlTypeDefTy = IdlTypeDef{Type: IdlTypeDefTy{
Kind: "struct",
Fields: &IdlTypeDefStruct{},
}}

type IdlTypeDefTy struct {
Kind IdlTypeDefTyKind `json:"kind"`

Expand Down

0 comments on commit 9ae0236

Please sign in to comment.