toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  Map<String, dynamic> json = {
    "Account": this.account,
    "TransactionType": this.transactionType,
    "Flags": this.flags,
    "Sequence": this.sequence,
    "Fee": this.fee,
    "LastLedgerSequence": this.lastLedgerSequence,
    "SigningPubKey": this.signingPubKey
  };
  switch (this.transactionType) {
    case XrpTransactionType.payment:
      json = {...json, "Destination": this.destination};
      if (amount is String) {
        return {...json, "Amount": this.amount};
      } else if (amount is XrpTokenAmount) {
        return {...json, "Amount": this.amount.toJson()};
      } else {
        throw Exception('unsupported amount format');
      }
    case XrpTransactionType.trustSet:
      return {...json, "LimitAmount": this.limitAmount!.toJson()};
    default:
      throw Exception('unsupported transaction type');
  }
}