Skip to content

Commit b6f6004

Browse files
committed
alias CR/CW types to pkg/types/solana
1 parent 112165c commit b6f6004

File tree

7 files changed

+157
-725
lines changed

7 files changed

+157
-725
lines changed

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ require (
99
github.com/gagliardetto/gofuzz v1.2.2
1010
github.com/gagliardetto/solana-go v1.12.0
1111
github.com/gagliardetto/treeout v0.1.4
12-
github.com/gagliardetto/utilz v0.1.1
13-
github.com/go-viper/mapstructure/v2 v2.2.1
12+
github.com/go-viper/mapstructure/v2 v2.3.0
1413
github.com/google/uuid v1.6.0
1514
github.com/hashicorp/go-plugin v1.6.3
1615
github.com/jackc/pgx/v4 v4.18.3
@@ -20,8 +19,9 @@ require (
2019
github.com/prometheus/client_model v0.6.1
2120
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250624142741-45c8e9237804
2221
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250609091505-5c8cd74b92ed
23-
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250623175819-a17cdfe27dfd
22+
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250628141348-0408d44794b6
2423
github.com/smartcontractkit/chainlink-common/pkg/monitoring v0.0.0-20250415235644-8703639403c7
24+
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250626141212-e50b2e7ffe2d
2525
github.com/smartcontractkit/chainlink-framework/metrics v0.0.0-20250618135814-7e3f79ab707e
2626
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250522110034-65c54665034a
2727
github.com/smartcontractkit/freeport v0.1.1
@@ -55,6 +55,7 @@ require (
5555
github.com/fatih/color v1.18.0 // indirect
5656
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
5757
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
58+
github.com/gagliardetto/utilz v0.1.3 // indirect
5859
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874 // indirect
5960
github.com/go-kit/log v0.2.1 // indirect
6061
github.com/go-logfmt/logfmt v0.6.0 // indirect

go.sum

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ github.com/gagliardetto/solana-go v1.12.0 h1:rzsbilDPj6p+/DOPXBMLhwMZeBgeRuXjm5z
104104
github.com/gagliardetto/solana-go v1.12.0/go.mod h1:l/qqqIN6qJJPtxW/G1PF4JtcE3Zg2vD2EliZrr9Gn5k=
105105
github.com/gagliardetto/treeout v0.1.4 h1:ozeYerrLCmCubo1TcIjFiOWTTGteOOHND1twdFpgwaw=
106106
github.com/gagliardetto/treeout v0.1.4/go.mod h1:loUefvXTrlRG5rYmJmExNryyBRh8f89VZhmMOyCyqok=
107-
github.com/gagliardetto/utilz v0.1.1 h1:/etW4hl607emKg6R6Lj9jRJ9d6ue2AQOyjhuAwjzs1U=
108-
github.com/gagliardetto/utilz v0.1.1/go.mod h1:b+rGFkRHz3HWJD0RYMzat47JyvbTtpE0iEcYTRJTLLA=
107+
github.com/gagliardetto/utilz v0.1.3 h1:A+asc+6/3a9qNBrgticApj3yW5F7y4TaJd8Ijg+o0zM=
108+
github.com/gagliardetto/utilz v0.1.3/go.mod h1:b+rGFkRHz3HWJD0RYMzat47JyvbTtpE0iEcYTRJTLLA=
109109
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874 h1:F8d1AJ6M9UQCavhwmO6ZsrYLfG8zVFWfEfMS2MXPkSY=
110110
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
111111
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
@@ -132,8 +132,8 @@ github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1
132132
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
133133
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
134134
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
135-
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
136-
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
135+
github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk=
136+
github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
137137
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
138138
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
139139
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
@@ -406,10 +406,12 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250624142741-45c8e9237804 h1
406406
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250624142741-45c8e9237804/go.mod h1:Yw7X+vtR7A9MBI+q5b0k/H2PlKy6cQOa7vAp4cshz2s=
407407
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250609091505-5c8cd74b92ed h1:rjtXQLTCLa/+AmMwMTP5WwJUdPBeBAF3Ivwc1GXetBw=
408408
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250609091505-5c8cd74b92ed/go.mod h1:k3/Z6AvwurPUlfuDFEonRbkkiTSgNSrtVNhJEWNlUZA=
409-
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250623175819-a17cdfe27dfd h1:5AjfcD6373yjIgKbSXHFcJFSEHno4Du1l67TT3Bo6vI=
410-
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250623175819-a17cdfe27dfd/go.mod h1:crejZI9ZpBHfhqghQOG9u7Sri7CBzEUYQ/0lVnN60yg=
409+
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250628141348-0408d44794b6 h1:PfRhnjK+gJMuP3qn3mPx+UQ8DOD9EXHrxM595oCJDBk=
410+
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250628141348-0408d44794b6/go.mod h1:+le3HV9mby9tXT7GE9U3Q0aSBwgmbButML9lNypfaLM=
411411
github.com/smartcontractkit/chainlink-common/pkg/monitoring v0.0.0-20250415235644-8703639403c7 h1:9wh1G+WbXwPVqf0cfSRSgwIcaXTQgvYezylEAfwmrbw=
412412
github.com/smartcontractkit/chainlink-common/pkg/monitoring v0.0.0-20250415235644-8703639403c7/go.mod h1:yaDOAZF6MNB+NGYpxGCUc+owIdKrjvFW0JODdTcQ3V0=
413+
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250626141212-e50b2e7ffe2d h1:86gp4tIXRb6ccSrjcm4gV8iA5wJN6er3rJY9f2UxRLU=
414+
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250626141212-e50b2e7ffe2d/go.mod h1:QUEPHdSkH19Or+E1iMGG+rDQ6jpCTIbm//9Osa6MXDE=
413415
github.com/smartcontractkit/chainlink-framework/metrics v0.0.0-20250618135814-7e3f79ab707e h1:LRT+PltY99+hxZAJn+4nyTfqGVNEM1S6FJ675B9BtJo=
414416
github.com/smartcontractkit/chainlink-framework/metrics v0.0.0-20250618135814-7e3f79ab707e/go.mod h1:jo+cUqNcHwN8IF7SInQNXDZ8qzBsyMpnLdYbDswviFc=
415417
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250522110034-65c54665034a h1:O28vgyHM7QF1YLg1BwkQSIbOYA+t0RiH9+b+k90GPG8=

pkg/solana/chainwriter/ata_creation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func CreateATAs(ctx context.Context, args any, lookups []ATALookup, derivedTable
3939
return nil, fmt.Errorf("error getting values at location: %w", err)
4040
}
4141
}
42-
walletAddresses, err := GetAddresses(ctx, args, []Lookup{lookup.WalletAddress}, derivedTableMap, client)
42+
walletAddresses, err := GetAddresses(ctx, args, []Lookup{Lookup(lookup.WalletAddress)}, derivedTableMap, client)
4343
if lookup.Optional && isIgnorableError(err) {
4444
continue
4545
} else if err != nil {
@@ -50,14 +50,14 @@ func CreateATAs(ctx context.Context, args any, lookups []ATALookup, derivedTable
5050
}
5151
wallet := walletAddresses[0].PublicKey
5252

53-
tokenPrograms, err := GetAddresses(ctx, args, []Lookup{lookup.TokenProgram}, derivedTableMap, client)
53+
tokenPrograms, err := GetAddresses(ctx, args, []Lookup{Lookup(lookup.TokenProgram)}, derivedTableMap, client)
5454
if lookup.Optional && isIgnorableError(err) {
5555
continue
5656
} else if err != nil {
5757
return nil, fmt.Errorf("error resolving token program address: %w", err)
5858
}
5959

60-
mints, err := GetAddresses(ctx, args, []Lookup{lookup.MintAddress}, derivedTableMap, client)
60+
mints, err := GetAddresses(ctx, args, []Lookup{Lookup(lookup.MintAddress)}, derivedTableMap, client)
6161
if lookup.Optional && isIgnorableError(err) {
6262
continue
6363
} else if err != nil {

pkg/solana/chainwriter/chain_writer.go

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
addresslookuptable "github.com/gagliardetto/solana-go/programs/address-lookup-table"
1212
"github.com/gagliardetto/solana-go/rpc"
1313

14-
commoncodec "github.com/smartcontractkit/chainlink-common/pkg/codec"
1514
"github.com/smartcontractkit/chainlink-common/pkg/logger"
1615
"github.com/smartcontractkit/chainlink-common/pkg/services"
1716
"github.com/smartcontractkit/chainlink-common/pkg/types"
17+
soltypes "github.com/smartcontractkit/chainlink-common/pkg/types/solana"
1818

1919
"github.com/smartcontractkit/chainlink-solana/pkg/solana/client"
2020
"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
@@ -47,31 +47,15 @@ var (
4747
_ types.ContractWriter = &SolanaChainWriterService{}
4848
)
4949

50+
// Deprecated
5051
// nolint // ignoring naming suggestion
51-
type ChainWriterConfig struct {
52-
Programs map[string]ProgramConfig `json:"programs"`
53-
}
52+
type ChainWriterConfig = soltypes.ChainWriterConfig
5453

55-
type ProgramConfig struct {
56-
Methods map[string]MethodConfig `json:"methods"`
57-
IDL string `json:"idl"`
58-
}
54+
// Deprecated
55+
type ProgramConfig = soltypes.ProgramConfig
5956

60-
type MethodConfig struct {
61-
FromAddress string `json:"fromAddress"`
62-
InputModifications commoncodec.ModifiersConfig `json:"inputModifications,omitempty"`
63-
ChainSpecificName string `json:"chainSpecificName"`
64-
LookupTables LookupTables `json:"lookupTables,omitempty"`
65-
Accounts []Lookup `json:"accounts"`
66-
ATAs []ATALookup `json:"atas,omitempty"`
67-
// Location in the args where the debug ID is stored
68-
DebugIDLocation string `json:"debugIDLocation,omitempty"`
69-
ArgsTransform string `json:"argsTransform,omitempty"`
70-
// Overhead added to calculated compute units in the args transform
71-
ComputeUnitLimitOverhead uint32 `json:"ComputeUnitLimitOverhead,omitempty"`
72-
// Configs for buffering payloads to support larger transaction sizes for this method
73-
BufferPayloadMethod string `json:"bufferPayloadMethod,omitempty"`
74-
}
57+
// Deprecated
58+
type MethodConfig = soltypes.MethodConfig
7559

7660
func NewSolanaChainWriterService(logger logger.Logger, client client.MultiClient, txm txm.TxManager, ge fees.Estimator, config ChainWriterConfig) (*SolanaChainWriterService, error) {
7761
w := SolanaChainWriterService{
@@ -296,8 +280,12 @@ func (s *SolanaChainWriterService) SubmitTransaction(ctx context.Context, contra
296280
}
297281

298282
s.lggr.Debugw("Resolving account addresses", "contract", contractName, "method", method, "tx", transactionID, "debugID", debugID)
283+
accts := make([]Lookup, len(methodConfig.Accounts))
284+
for i, a := range methodConfig.Accounts {
285+
accts[i] = Lookup(a)
286+
}
299287
// Resolve account metas
300-
accounts, err := GetAddresses(ctx, args, methodConfig.Accounts, derivedTableMap, s.client)
288+
accounts, err := GetAddresses(ctx, args, accts, derivedTableMap, s.client)
301289
if err != nil {
302290
return errorWithDebugID(fmt.Errorf("error resolving account addresses: %w", err), debugID)
303291
}
@@ -465,7 +453,7 @@ func (s *SolanaChainWriterService) ResolveLookupTables(ctx context.Context, args
465453

466454
func (s *SolanaChainWriterService) loadTable(ctx context.Context, args any, rlt DerivedLookupTable) (map[string]map[string][]*solana.AccountMeta, error) {
467455
// Resolve all addresses specified by the identifier
468-
lookupTableAddresses, err := GetAddresses(ctx, args, []Lookup{rlt.Accounts}, nil, s.client)
456+
lookupTableAddresses, err := GetAddresses(ctx, args, []Lookup{Lookup(rlt.Accounts)}, nil, s.client)
469457
if err != nil {
470458
return nil, fmt.Errorf("error resolving addresses for lookup table: %w", err)
471459
}

pkg/solana/chainwriter/lookups.go

Lines changed: 37 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/gagliardetto/solana-go"
1010
"github.com/gagliardetto/solana-go/rpc"
1111

12+
types "github.com/smartcontractkit/chainlink-common/pkg/types/solana"
1213
"github.com/smartcontractkit/chainlink-solana/pkg/solana/client"
1314
"github.com/smartcontractkit/chainlink-solana/pkg/solana/codec"
1415
)
@@ -19,6 +20,10 @@ var (
1920
ErrGettingSeedAtLocation = fmt.Errorf("error getting address seed for location")
2021
)
2122

23+
var _ = Lookup(types.Lookup{})
24+
25+
// Lookup is not an alias like the others, because it has a widely used method with solana types that cannot be imported
26+
// in to chainlink-common. However, it can be directly converted from [types.Lookup].
2227
type Lookup struct {
2328
Optional bool
2429
AccountConstant *AccountConstant `json:"accountConstant,omitempty"`
@@ -27,83 +32,35 @@ type Lookup struct {
2732
AccountsFromLookupTable *AccountsFromLookupTable `json:"accountsFromLookupTable,omitempty"`
2833
}
2934

30-
// AccountConstant represents a fixed address, provided in Base58 format, converted into a `solana.PublicKey`.
31-
type AccountConstant struct {
32-
Name string `json:"name,omitempty"`
33-
Address string `json:"address"`
34-
IsSigner bool `json:"isSigner,omitempty"`
35-
IsWritable bool `json:"isWritable,omitempty"`
36-
}
35+
// Deprecated
36+
type AccountConstant = types.AccountConstant
3737

38-
// AccountLookup dynamically derives an account address from args using a specified location path.
39-
type AccountLookup struct {
40-
Name string `json:"name,omitempty"`
41-
Location string `json:"location"`
42-
// IsSigner and IsWritable can either be a constant bool or a location to a bitmap which decides the bools
43-
IsSigner MetaBool `json:"isSigner,omitempty"`
44-
IsWritable MetaBool `json:"isWritable,omitempty"`
45-
}
38+
// Deprecated
39+
type AccountLookup = types.AccountLookup
4640

47-
type MetaBool struct {
48-
Value bool `json:"value,omitempty"` // bool value
49-
BitmapLocation string `json:"bitmapLocation,omitempty"` // dot separated location of the bitmap
50-
}
41+
// Deprecated
42+
type MetaBool = types.MetaBool
5143

52-
type Seed struct {
53-
Static []byte `json:"static,omitempty"` // Static seed value
54-
Dynamic Lookup `json:"dynamic,omitempty"` // Dynamic lookup for seed
55-
}
44+
// Deprecated
45+
type Seed = types.Seed
5646

57-
// PDALookups generates Program Derived Addresses (PDA) by combining a derived public key with one or more seeds.
58-
type PDALookups struct {
59-
Name string `json:"name,omitempty"`
60-
// The public key of the PDA to be combined with seeds. If there are multiple PublicKeys
61-
// there will be multiple PDAs generated by combining each PublicKey with the seeds.
62-
PublicKey Lookup `json:"publicKey"`
63-
// Seeds to be derived from an additional lookup
64-
Seeds []Seed `json:"seeds"`
65-
IsSigner bool `json:"isSigner,omitempty"`
66-
IsWritable bool `json:"isWritable,omitempty"`
67-
// OPTIONAL: On-chain location and type of desired data from PDA (e.g. a sub-account of the data account)
68-
InternalField InternalField `json:"internalField,omitempty"`
69-
}
47+
// Deprecated
48+
type PDALookups = types.PDALookups
7049

71-
type InternalField struct {
72-
// must map directly to IDL type
73-
TypeName string `json:"typeName"`
74-
Location string `json:"location"`
75-
IDL string `json:"idl"`
76-
}
50+
// Deprecated
51+
type InternalField = types.InternalField
7752

78-
// LookupTables represents a list of lookup tables that are used to derive addresses for a program.
79-
type LookupTables struct {
80-
DerivedLookupTables []DerivedLookupTable `json:"derivedLookupTables,omitempty"`
81-
StaticLookupTables []solana.PublicKey `json:"staticLookupTables,omitempty"`
82-
}
53+
// Deprecated
54+
type LookupTables = types.LookupTables
8355

84-
// DerivedLookupTable represents a lookup table that is used to derive addresses for a program.
85-
type DerivedLookupTable struct {
86-
Name string `json:"name,omitempty"`
87-
Accounts Lookup `json:"accounts"`
88-
Optional bool `json:"optional"`
89-
}
56+
// Deprecated
57+
type DerivedLookupTable = types.DerivedLookupTable
9058

91-
// AccountsFromLookupTable extracts accounts from a lookup table that was previously read and stored in memory.
92-
type AccountsFromLookupTable struct {
93-
LookupTableName string `json:"lookupTableName"`
94-
IncludeIndexes []int `json:"includeIndexes"`
95-
}
59+
// Deprecated
60+
type AccountsFromLookupTable = types.AccountsFromLookupTable
9661

97-
type ATALookup struct {
98-
// Field that determines whether the ATA lookup is necessary. Basically
99-
// just need to check this field exists. Dot separated location.
100-
Location string
101-
// If the field exists, initialize a ATA account using the Wallet, Token Program, and Mint addresses below
102-
WalletAddress Lookup
103-
TokenProgram Lookup
104-
MintAddress Lookup
105-
Optional bool
106-
}
62+
// Deprecated
63+
type ATALookup = types.ATALookup
10764

10865
func (l Lookup) validate() error {
10966
count := 0
@@ -125,18 +82,18 @@ func (l Lookup) Resolve(ctx context.Context, args any, derivedTableMap map[strin
12582
return nil, err
12683
}
12784
if l.AccountConstant != nil {
128-
return l.AccountConstant.Resolve()
85+
return ResolveAccountConstant(l.AccountConstant)
12986
} else if l.AccountLookup != nil {
130-
return l.AccountLookup.Resolve(args)
87+
return ResolveAccountLookup(l.AccountLookup, args)
13188
} else if l.PDALookups != nil {
132-
return l.PDALookups.Resolve(ctx, args, derivedTableMap, client)
89+
return ResolvePDALookups(ctx, l.PDALookups, args, derivedTableMap, client)
13390
} else if l.AccountsFromLookupTable != nil {
134-
return l.AccountsFromLookupTable.Resolve(derivedTableMap)
91+
return ResolveAccountsFromLookupTable(l.AccountsFromLookupTable, derivedTableMap)
13592
}
13693
return nil, fmt.Errorf("no lookup type specified")
13794
}
13895

139-
func (ac AccountConstant) Resolve() ([]*solana.AccountMeta, error) {
96+
func ResolveAccountConstant(ac *AccountConstant) ([]*solana.AccountMeta, error) {
14097
address, err := solana.PublicKeyFromBase58(ac.Address)
14198
if err != nil {
14299
return nil, lookupErrWithName(ac.Name, fmt.Errorf("error getting account from constant: %w", err))
@@ -150,7 +107,7 @@ func (ac AccountConstant) Resolve() ([]*solana.AccountMeta, error) {
150107
}, nil
151108
}
152109

153-
func (al AccountLookup) Resolve(args any) ([]*solana.AccountMeta, error) {
110+
func ResolveAccountLookup(al *AccountLookup, args any) ([]*solana.AccountMeta, error) {
154111
derivedValues, err := GetValuesAtLocation(args, al.Location)
155112
if err != nil {
156113
return nil, lookupErrWithName(al.Name, fmt.Errorf("%w: %v", ErrLookupNotFoundAtLocation, err))
@@ -222,7 +179,7 @@ func resolveBitMap(mb MetaBool, args any, length int) ([]bool, error) {
222179
return result, nil
223180
}
224181

225-
func (alt AccountsFromLookupTable) Resolve(derivedTableMap map[string]map[string][]*solana.AccountMeta) ([]*solana.AccountMeta, error) {
182+
func ResolveAccountsFromLookupTable(alt *AccountsFromLookupTable, derivedTableMap map[string]map[string][]*solana.AccountMeta) ([]*solana.AccountMeta, error) {
226183
// Fetch the inner map for the specified lookup table name
227184
innerMap, ok := derivedTableMap[alt.LookupTableName]
228185
if !ok {
@@ -252,8 +209,8 @@ func (alt AccountsFromLookupTable) Resolve(derivedTableMap map[string]map[string
252209
return result, nil
253210
}
254211

255-
func (pda PDALookups) Resolve(ctx context.Context, args any, derivedTableMap map[string]map[string][]*solana.AccountMeta, client client.MultiClient) ([]*solana.AccountMeta, error) {
256-
publicKeys, err := GetAddresses(ctx, args, []Lookup{pda.PublicKey}, derivedTableMap, client)
212+
func ResolvePDALookups(ctx context.Context, pda *PDALookups, args any, derivedTableMap map[string]map[string][]*solana.AccountMeta, client client.MultiClient) ([]*solana.AccountMeta, error) {
213+
publicKeys, err := GetAddresses(ctx, args, []Lookup{Lookup(pda.PublicKey)}, derivedTableMap, client)
257214
if err != nil {
258215
return nil, lookupErrWithName(pda.Name, fmt.Errorf("error getting public key for PDALookups: %w", err))
259216
}
@@ -329,7 +286,7 @@ func (pda PDALookups) Resolve(ctx context.Context, args any, derivedTableMap map
329286
// to multiple addresses, multiplying the combinations accordingly.
330287
func getSeedBytesCombinations(
331288
ctx context.Context,
332-
lookup PDALookups,
289+
lookup *PDALookups,
333290
args any,
334291
derivedTableMap map[string]map[string][]*solana.AccountMeta,
335292
client client.MultiClient,
@@ -364,7 +321,7 @@ func getSeedBytesCombinations(
364321
}
365322
} else {
366323
// Get address seeds from the lookup
367-
seedAddresses, err := GetAddresses(ctx, args, []Lookup{dynamicSeed}, derivedTableMap, client)
324+
seedAddresses, err := GetAddresses(ctx, args, []Lookup{Lookup(dynamicSeed)}, derivedTableMap, client)
368325
if err != nil {
369326
return nil, fmt.Errorf("error getting address seed: %w", err)
370327
}
@@ -397,17 +354,13 @@ func getSeedBytesCombinations(
397354
return allCombinations, nil
398355
}
399356

400-
func (l Lookup) IsNil() bool {
401-
return l.AccountConstant == nil && l.AccountLookup == nil && l.PDALookups == nil && l.AccountsFromLookupTable == nil
402-
}
403-
404357
// generatePDAs generates program-derived addresses (PDAs) from public keys and seeds.
405358
// it will result in a list of PDAs whose length is the product of the number of public keys
406359
// and the number of seed combinations.
407360
func generatePDAs(
408361
publicKeys []*solana.AccountMeta,
409362
seedCombos [][][]byte,
410-
lookup PDALookups,
363+
lookup *PDALookups,
411364
) ([]*solana.AccountMeta, error) {
412365
var results []*solana.AccountMeta
413366
for _, publicKeyMeta := range publicKeys {

0 commit comments

Comments
 (0)