toOperationBody method

  1. @override
XdrOperationBody toOperationBody ()
override

Generates OperationBody XDR object.

Implementation

@override
XdrOperationBody toOperationBody() {
  XdrSetOptionsOp op = new XdrSetOptionsOp();
  if (inflationDestination != null) {
    XdrAccountID inflationDestination = new XdrAccountID();
    inflationDestination.accountID =
        KeyPair.fromAccountId(this.inflationDestination).xdrPublicKey;
    op.inflationDest = inflationDestination;
  }
  if (clearFlags != null) {
    XdrUint32 clearFlags = new XdrUint32();
    clearFlags.uint32 = this.clearFlags;
    op.clearFlags = clearFlags;
  }
  if (setFlags != null) {
    XdrUint32 setFlags = new XdrUint32();
    setFlags.uint32 = this.setFlags;
    op.setFlags = setFlags;
  }
  if (masterKeyWeight != null) {
    XdrUint32 uint32 = new XdrUint32();
    uint32.uint32 = masterKeyWeight;
    op.masterWeight = uint32;
  }
  if (lowThreshold != null) {
    XdrUint32 uint32 = new XdrUint32();
    uint32.uint32 = lowThreshold;
    op.lowThreshold = uint32;
  }
  if (mediumThreshold != null) {
    XdrUint32 uint32 = new XdrUint32();
    uint32.uint32 = mediumThreshold;
    op.medThreshold = uint32;
  }
  if (highThreshold != null) {
    XdrUint32 uint32 = new XdrUint32();
    uint32.uint32 = highThreshold;
    op.highThreshold = uint32;
  }
  if (homeDomain != null) {
    XdrString32 homeDomain = new XdrString32();
    homeDomain.string32 = this.homeDomain;
    op.homeDomain = homeDomain;
  }
  if (signer != null) {
    XdrSigner signer = new XdrSigner();
    XdrUint32 weight = new XdrUint32();
    weight.uint32 = signerWeight & 0xFF;
    signer.key = this.signer;
    signer.weight = weight;
    op.signer = signer;
  }

  XdrOperationBody body = new XdrOperationBody();
  body.discriminant = XdrOperationType.SET_OPTIONS;
  body.setOptionsOp = op;
  return body;
}