Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica committed Jul 29, 2024
1 parent 168407a commit 8f8322d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions x/tx/signing/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (c *Context) Validate() error {
errs = append(errs, fmt.Errorf("a custom signer function as been defined for message %s which already has a signer field defined with (cosmos.msg.v1.signer)", md.FullName()))
continue
}
_, err := c.getGetSignersFn(md)
_, err := c.getGetSignersFn(md, true)
if err != nil {
errs = append(errs, err)
}
Expand Down Expand Up @@ -333,22 +333,31 @@ func (c *Context) getAddressCodec(field protoreflect.FieldDescriptor) address.Co
return addrCdc
}

func (c *Context) getGetSignersFn(messageDescriptor protoreflect.MessageDescriptor) (GetSignersFunc, error) {
func (c *Context) getGetSignersFn(messageDescriptor protoreflect.MessageDescriptor, add bool) (GetSignersFunc, error) {
f, ok := c.customGetSignerFuncs[messageDescriptor.FullName()]
if ok {
return f, nil
}
f, ok = c.getSignersFuncs[messageDescriptor.FullName()]
if !ok {
return nil, fmt.Errorf("no GetSignersFunc found for message %s; have you called Validate()?", messageDescriptor.FullName())
if !add {
return nil, fmt.Errorf("no GetSignersFunc found for message %s; have you called Validate()?", messageDescriptor.FullName())
}

var err error
f, err = c.makeGetSignersFunc(messageDescriptor)
if err != nil {
return nil, err
}
c.getSignersFuncs[messageDescriptor.FullName()] = f
}

return f, nil
}

// GetSigners returns the signers for a given message.
func (c *Context) GetSigners(msg proto.Message) ([][]byte, error) {
f, err := c.getGetSignersFn(msg.ProtoReflect().Descriptor())
f, err := c.getGetSignersFn(msg.ProtoReflect().Descriptor(), false)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 8f8322d

Please sign in to comment.