(tx *sequence.Transaction)
| 410 | } |
| 411 | |
| 412 | func (buf *Buffer) WriteSequenceTransaction(tx *sequence.Transaction) (EncodeType, error) { |
| 413 | // The first byte is the flag of the transaction, the specification follows: |
| 414 | // - 1000 0000 - 1 if it uses delegate call |
| 415 | // - 0100 0000 - 1 if it uses revert on error |
| 416 | // - 0010 0000 - 1 if it has a defined gas limit |
| 417 | // - 0001 0000 - 1 if it has a defined value |
| 418 | // - 0000 1000 - Unused |
| 419 | // - 0000 0100 - Unused |
| 420 | // - 0000 0010 - Unused |
| 421 | // - 0000 0001 - 1 if it has a defined data |
| 422 | |
| 423 | flag := byte(0x00) |
| 424 | |
| 425 | if tx.DelegateCall { |
| 426 | flag |= 0x80 |
| 427 | } |
| 428 | |
| 429 | if tx.RevertOnError { |
| 430 | flag |= 0x40 |
| 431 | } |
| 432 | |
| 433 | hasGasLimit := tx.GasLimit != nil && tx.GasLimit.Cmp(big.NewInt(0)) != 0 |
| 434 | if hasGasLimit { |
| 435 | flag |= 0x20 |
| 436 | } |
| 437 | |
| 438 | hasValue := tx.Value != nil && tx.Value.Cmp(big.NewInt(0)) != 0 |
| 439 | if hasValue { |
| 440 | flag |= 0x10 |
| 441 | } |
| 442 | |
| 443 | hasData := len(tx.Data) > 0 || len(tx.Transactions) > 0 |
| 444 | if hasData { |
| 445 | flag |= 0x01 |
| 446 | } |
| 447 | |
| 448 | buf.commitByte(flag) |
| 449 | buf.end([]byte{}, Stateless) |
| 450 | |
| 451 | encodeType := Stateless |
| 452 | |
| 453 | // Now we start writing the values that we do have |
| 454 | if hasGasLimit { |
| 455 | t, err := buf.WriteWord(tx.GasLimit.Bytes(), false) |
| 456 | if err != nil { |
| 457 | return Stateless, err |
| 458 | } |
| 459 | |
| 460 | encodeType = maxPriority(encodeType, t) |
| 461 | } |
| 462 | |
| 463 | // Encode the address as a word |
| 464 | t, err := buf.WriteWord(tx.To.Bytes(), buf.Refs.useContractStorage) |
| 465 | if err != nil { |
| 466 | return Stateless, err |
| 467 | } |
| 468 | |
| 469 | encodeType = maxPriority(encodeType, t) |
no test coverage detected