toOperationBody method

  1. @override
XdrOperationBody toOperationBody ()
override

Generates OperationBody XDR object.

Implementation

@override
XdrOperationBody toOperationBody() {
  XdrClaimClaimableBalanceOp op = XdrClaimClaimableBalanceOp();

  XdrClaimableBalanceID bId = XdrClaimableBalanceID();
  bId.discriminant = XdrClaimableBalanceIDType.CLAIMABLE_BALANCE_ID_TYPE_V0;
  Uint8List bytes = Util.hexToBytes(balanceId.toUpperCase());
  if (bytes.length < 32) {
    bytes = Util.paddedByteArray(bytes, 32);
  } else if (bytes.length > 32) {
    bytes = bytes.sublist(bytes.length - 32, bytes.length);
  }

  XdrHash hash = XdrHash();
  hash.hash = bytes;
  bId.v0 = hash;
  op.balanceID = bId;

  XdrOperationBody body = XdrOperationBody();
  body.discriminant = XdrOperationType.CLAIM_CLAIMABLE_BALANCE;
  body.claimClaimableBalanceOp = op;
  return body;
}