toOperationBody method

  1. @override
XdrOperationBody toOperationBody()
override

Generates OperationBody XDR object.

Implementation

@override
XdrOperationBody toOperationBody() {
  XdrOperationBody body =
      XdrOperationBody(XdrOperationType.REVOKE_SPONSORSHIP);

  if (_ledgerKey != null) {
    XdrRevokeSponsorshipOp op = XdrRevokeSponsorshipOp(
        XdrRevokeSponsorshipType.REVOKE_SPONSORSHIP_LEDGER_ENTRY);
    op.ledgerKey = this._ledgerKey;
    body.revokeSponsorshipOp = op;
  } else {
    XdrRevokeSponsorshipOp op = XdrRevokeSponsorshipOp(
        XdrRevokeSponsorshipType.REVOKE_SPONSORSHIP_SIGNER);

    XdrAccountID xAccountId = XdrAccountID(
        KeyPair.fromAccountId(this._signerAccountId!).xdrPublicKey);
    op.signer = XdrRevokeSponsorshipSigner(xAccountId, _signerKey!);
    body.revokeSponsorshipOp = op;
  }

  return body;
}