Skip to content

Commit

Permalink
allow addresses to be filtered by labels in external api (#16600)
Browse files Browse the repository at this point in the history
  • Loading branch information
eutopian authored Feb 27, 2025
1 parent 6c0229e commit 12d5b27
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion deployment/keystone/changeset/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import (
type GetContractSetsRequest struct {
Chains map[uint64]deployment.Chain
AddressBook deployment.AddressBook

// Labels indicates the label set that a contract must include to be considered as a member
// of the returned contract set. By default, an empty label set implies that only contracts without
// labels will be considered. Otherwise, all labels must be on the contract (e.g., "label1" AND "label2").
Labels []string
}

type GetContractSetsResponse struct {
Expand Down Expand Up @@ -135,7 +140,10 @@ func GetContractSets(lggr logger.Logger, req *GetContractSetsRequest) (*GetContr
if err != nil {
return nil, fmt.Errorf("failed to get addresses for chain %d: %w", id, err)
}
cs, err := loadContractSet(lggr, chain, addrs)

filtered := deployment.LabeledAddresses(addrs).And(req.Labels...)

cs, err := loadContractSet(lggr, chain, filtered)
if err != nil {
return nil, fmt.Errorf("failed to load contract set for chain %d: %w", id, err)
}
Expand Down

0 comments on commit 12d5b27

Please sign in to comment.