(signature []byte, mayUseBytes bool)
| 541 | } |
| 542 | |
| 543 | func (buf *Buffer) WriteSequenceSignature(signature []byte, mayUseBytes bool) (EncodeType, error) { |
| 544 | // First byte determines the signature type |
| 545 | if mayUseBytes && (len(signature) == 0 || !buf.Refs.useContractStorage) { |
| 546 | // Guestmodule signatures are empty |
| 547 | return buf.WriteBytesOptimized(signature, false) |
| 548 | } |
| 549 | |
| 550 | typeByte := signature[0] |
| 551 | |
| 552 | switch typeByte { |
| 553 | case 0x00: // Legacy |
| 554 | return buf.WriteSequenceSignatureBody(false, signature) |
| 555 | case 0x01: // Dynamic |
| 556 | return buf.WriteSequenceSignatureBody(false, signature[1:]) |
| 557 | case 0x02: // No chain ID |
| 558 | return buf.WriteSequenceSignatureBody(true, signature[1:]) |
| 559 | case 0x03: // Chained |
| 560 | return buf.WriteSequenceChainedSignature(signature[1:]) |
| 561 | |
| 562 | default: |
| 563 | return Stateless, fmt.Errorf("invalid signature type %d", typeByte) |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | func (buf *Buffer) WriteSequenceSignatureBody(noChain bool, body []byte) (EncodeType, error) { |
| 568 | // The first 2 bytes are the threshold |
no test coverage detected