Aptos: add shared capability payload conversion helpers#1923
Aptos: add shared capability payload conversion helpers#1923
Conversation
|
| if payload == nil { | ||
| return nil, fmt.Errorf("viewRequest.Payload is required") | ||
| } | ||
| if payload.Module == nil { |
There was a problem hiding this comment.
should module name be validated as well?
| if payload.Function == "" { | ||
| return nil, fmt.Errorf("viewRequest.Payload.Function is required") | ||
| } | ||
| if len(payload.Module.Address) > typeaptos.AccountAddressLength { |
There was a problem hiding this comment.
shouldn't the validation check exact size?
| } | ||
| elementType, err := ConvertCapabilityTypeTagFromProto(vector.ElementType) | ||
| if err != nil { | ||
| return nil, err |
There was a problem hiding this comment.
maybe wrap this error to add additional context
| if len(structTag.Address) > typeaptos.AccountAddressLength { | ||
| return nil, fmt.Errorf("struct address too long: %d", len(structTag.Address)) | ||
| } | ||
|
|
||
| var structAddress typeaptos.AccountAddress | ||
| copy(structAddress[typeaptos.AccountAddressLength-len(structTag.Address):], structTag.Address) |
There was a problem hiding this comment.
this looks a bit confusing and is duplicated, lets just extract this logic similar to evm
func ConvertAddressFromProto(protoAddress []byte) (evmtypes.Address, error) {
if err := ValidateAddressBytes(protoAddress); err != nil {
return evmtypes.Address{}, err
}
return evmtypes.Address(protoAddress), nil
}
Summary
pkg/chains/aptoschainlink-commonWhy