toXdr method

XdrPreconditions toXdr()

Implementation

XdrPreconditions toXdr() {
  XdrPreconditionType type = XdrPreconditionType.NONE;
  if (hasV2()) {
    type = XdrPreconditionType.V2;
  } else if (_timeBounds != null) {
    type = XdrPreconditionType.TIME;
  }
  XdrPreconditions result = XdrPreconditions(type);
  if (hasV2()) {
    int sav = 0;
    if (_minSeqAge != null) {
      sav = _minSeqAge!;
    }
    XdrUint64 sa = XdrUint64(sav);

    int slv = 0;
    if (_minSeqLedgerGap != null) {
      slv = _minSeqLedgerGap!;
    }
    XdrUint32 sl = XdrUint32(slv);

    List<XdrSignerKey> es = [];
    if (_extraSigners != null) {
      es = _extraSigners!;
    }

    XdrPreconditionsV2 v2 = XdrPreconditionsV2(sa, sl, es);

    if (_minSeqNumber != null) {
      XdrUint64 sn = XdrUint64(_minSeqNumber!);
      v2.sequenceNumber = sn;
    }

    if (_timeBounds != null) {
      v2.timeBounds = _timeBounds!.toXdr();
    }

    if (_ledgerBounds != null) {
      v2.ledgerBounds = _ledgerBounds!.toXdr();
    }

    result.v2 = v2;
  } else if (_timeBounds != null) {
    result.timeBounds = _timeBounds!.toXdr();
  }
  return result;
}