Skip to content

Commit

Permalink
updated comments and slight tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Dec 20, 2024
1 parent 8670824 commit 1242cef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/solana/chainwriter/chain_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestChainWriter_FilterLookupTableAddresses(t *testing.T) {
Name: "DataAccountPDA",
PublicKey: chainwriter.AccountConstant{Name: "WriteTest", Address: programID.String()},
Seeds: []chainwriter.Lookup{
// extract seed2 for PDA lookup
// extract seed1 for PDA lookup
chainwriter.AccountLookup{Name: "seed1", Location: "seed1"},
},
IsSigner: true,
Expand Down
9 changes: 4 additions & 5 deletions pkg/solana/chainwriter/lookups.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ type InternalField struct {
Location string
}

type ValueLookup struct {
Location string
}

// LookupTables represents a list of lookup tables that are used to derive addresses for a program.
type LookupTables struct {
DerivedLookupTables []DerivedLookupTable
Expand Down Expand Up @@ -271,6 +267,8 @@ func (s *SolanaChainWriterService) ResolveLookupTables(ctx context.Context, args

// Read derived lookup tables
for _, derivedLookup := range lookupTables.DerivedLookupTables {
// Load the lookup table - note: This could be multiple tables if the lookup is a PDALookups that resovles to more
// than one address
lookupTableMap, _, err := s.LoadTable(ctx, args, derivedLookup, s.reader, derivedTableMap)
if err != nil {
return nil, nil, fmt.Errorf("error loading derived lookup table: %w", err)
Expand Down Expand Up @@ -312,12 +310,13 @@ func (s *SolanaChainWriterService) LoadTable(ctx context.Context, args any, rlt
return nil, nil, fmt.Errorf("error resolving addresses for lookup table: %w", err)
}

// Nested map in case the lookup table resolves to multiple addresses
resultMap := make(map[string]map[string][]*solana.AccountMeta)
var lookupTableMetas []*solana.AccountMeta

// Iterate over each address of the lookup table
for _, addressMeta := range lookupTableAddresses {
// Fetch account info
// Read the full list of addresses from the lookup table
addresses, err := getLookupTableAddresses(ctx, reader, addressMeta.PublicKey)
if err != nil {
return nil, nil, fmt.Errorf("error fetching lookup table address: %w", err)
Expand Down

0 comments on commit 1242cef

Please sign in to comment.