Skip to content

Commit

Permalink
NamedAddr AppendTags() and IsZeroAddress() (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x19 authored Apr 23, 2024
1 parent bf390a1 commit ccbb203
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions storage/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (v *Variable) IsAddressType() bool {
}

// IsDynamicArray checks if the variable is a dynamic array.
// Currently returns false and needs implementation for dynamic array checking.
// Currently, returns false and needs implementation for dynamic array checking.
func (v *Variable) IsDynamicArray() bool {
variableType := v.StateVariable.GetType()
return strings.Contains(variableType, "[]")
Expand All @@ -52,7 +52,7 @@ func (v *Variable) IsStructType() bool {
return strings.HasPrefix(variableType, "struct")
}

// IsStructType checks if the variable is of a contract type.
// IsContractType checks if the variable is of a contract type.
// Returns true if the variable type starts with "contract".
func (v *Variable) IsContractType() bool {
variableType := v.StateVariable.GetType()
Expand Down
15 changes: 15 additions & 0 deletions utils/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ type NamedAddr struct {
Addr common.Address `json:"addr"`
Type AddressType `json:"type"`
}

// AppendTags appends unique tags to the named address
func (n NamedAddr) AppendTags(tags ...string) NamedAddr {
for _, tag := range tags {
if !StringInSlice(tag, n.Tags) {
n.Tags = append(n.Tags, tag)
}
}
return n
}

// IsZeroAddress checks whenever named address is zero address
func (n NamedAddr) IsZeroAddress() bool {
return n.Addr == ZeroAddress
}

0 comments on commit ccbb203

Please sign in to comment.