Skip to content

Commit 04802cd

Browse files
fix: use strings to represent addresses in proposal analyzer (#17397)
This will allow us to use the proposal analyzer types to decode Solana transactions.
1 parent b6cf9d5 commit 04802cd

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

deployment/common/proposalutils/analyze.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ func (a BytesArgument) Describe(_ *ArgumentContext) string {
164164
}
165165

166166
type AddressArgument struct {
167-
Value common.Address
167+
Value string
168168
}
169169

170170
func (a AddressArgument) Describe(ctx *ArgumentContext) string {
171-
description := a.Value.Hex() + " (address of <type unknown> from <chain unknown>)"
171+
description := a.Value + " (address of <type unknown> from <chain unknown>)"
172172
addresses, err := ContextGet[deployment.AddressesByChain](ctx, "AddressesByChain")
173173
if err != nil {
174174
return description
@@ -178,9 +178,9 @@ func (a AddressArgument) Describe(ctx *ArgumentContext) string {
178178
if err != nil || chainName == "" {
179179
chainName = strconv.FormatUint(chainSel, 10)
180180
}
181-
typeAndVersion, ok := addresses[a.Value.Hex()]
181+
typeAndVersion, ok := addresses[a.Value]
182182
if ok {
183-
return fmt.Sprintf("%s (address of %s from %s)", a.Value.Hex(), typeAndVersion.String(), chainName)
183+
return fmt.Sprintf("%s (address of %s from %s)", a.Value, typeAndVersion.String(), chainName)
184184
}
185185
}
186186
return description
@@ -195,7 +195,7 @@ type DecodedCall struct {
195195

196196
func (d *DecodedCall) Describe(context *ArgumentContext) string {
197197
description := strings.Builder{}
198-
description.WriteString(fmt.Sprintf("Address: %s\n", AddressArgument{Value: common.HexToAddress(d.Address)}.Describe(context)))
198+
description.WriteString(fmt.Sprintf("Address: %s\n", AddressArgument{Value: d.Address}.Describe(context)))
199199
description.WriteString(fmt.Sprintf("Method: %s\n", d.Method))
200200
describedInputs := d.describeArguments(d.Inputs, context)
201201
if len(describedInputs) > 0 {
@@ -211,8 +211,11 @@ func (d *DecodedCall) Describe(context *ArgumentContext) string {
211211
func (d *DecodedCall) describeArguments(arguments []NamedArgument, context *ArgumentContext) string {
212212
description := strings.Builder{}
213213
for _, argument := range arguments {
214-
description.WriteString(argument.Describe(context))
215-
description.WriteRune('\n')
214+
describedContent := argument.Describe(context)
215+
description.WriteString(describedContent)
216+
if describedContent[len(describedContent)-1] != '\n' {
217+
description.WriteRune('\n')
218+
}
216219
}
217220
return description.String()
218221
}
@@ -341,11 +344,11 @@ func BytesAndAddressAnalyzer(_ string, argAbi *abi.Type, argVal interface{}, _ [
341344
if argAbi.T == abi.FixedBytesTy || argAbi.T == abi.BytesTy || argAbi.T == abi.AddressTy {
342345
argArrTyp := reflect.ValueOf(argVal)
343346
argArr := make([]byte, argArrTyp.Len())
344-
for i := 0; i < argArrTyp.Len(); i++ {
347+
for i := range argArrTyp.Len() {
345348
argArr[i] = byte(argArrTyp.Index(i).Uint())
346349
}
347350
if argAbi.T == abi.AddressTy {
348-
return AddressArgument{Value: common.BytesToAddress(argArr)}
351+
return AddressArgument{Value: common.BytesToAddress(argArr).Hex()}
349352
}
350353
return BytesArgument{Value: argArr}
351354
}

0 commit comments

Comments
 (0)