toOperationBody method

  1. @override
XdrOperationBody toOperationBody()
override

Generates OperationBody XDR object.

Implementation

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

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