From 7f468de4285766b9e3a0a3dcb61239faadef4ea6 Mon Sep 17 00:00:00 2001 From: Ez3kiel Date: Sun, 14 Apr 2024 13:12:12 +0200 Subject: [PATCH] fix: outgoing transaction entry --- CHANGELOG.md | 10 +++ .../transaction_entry/transaction_entry.dart | 10 --- .../transaction_entry.freezed.dart | 66 +++------------- .../transaction_entry_type.dart | 2 + .../transaction_entry_type.freezed.dart | 77 ++++++++++++++++--- .../transaction_entry_type.g.dart | 4 + pubspec.yaml | 6 +- 7 files changed, 97 insertions(+), 78 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7953de4..1c55384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 0.17.0 + +Daemon API upgrade : + +- GetMempoolCache RPC method. + +Wallet API: + +- Fix outgoing transaction entry. + ## 0.16.2 - fix transfer entry. diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.dart index 3edce07..0cb7687 100644 --- a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.dart +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.dart @@ -13,8 +13,6 @@ class TransactionEntry with _$TransactionEntry { required String hash, required int topoHeight, required TransactionEntryType txEntryType, - int? fee, - int? nonce, }) = _TransactionEntry; /// @nodoc @@ -29,8 +27,6 @@ class TransactionEntry with _$TransactionEntry { hash: hash, topoHeight: topoHeight, txEntryType: CoinbaseEntry.fromJson(coinbase), - fee: json['fee'] as int?, - nonce: json['nonce'] as int?, ); } else if (json case { @@ -42,8 +38,6 @@ class TransactionEntry with _$TransactionEntry { hash: hash, topoHeight: topoHeight, txEntryType: BurnEntry.fromJson(burn), - fee: json['fee'] as int?, - nonce: json['nonce'] as int?, ); } else if (json case { @@ -55,8 +49,6 @@ class TransactionEntry with _$TransactionEntry { hash: hash, topoHeight: topoHeight, txEntryType: IncomingEntry.fromJson(incoming), - fee: json['fee'] as int?, - nonce: json['nonce'] as int?, ); } else if (json case { @@ -68,8 +60,6 @@ class TransactionEntry with _$TransactionEntry { hash: hash, topoHeight: topoHeight, txEntryType: OutgoingEntry.fromJson(outgoing), - fee: json['fee'] as int?, - nonce: json['nonce'] as int?, ); } else { throw Exception('Unknown type for this transaction entry: $json'); diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.freezed.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.freezed.dart index ba5befe..7c623ee 100644 --- a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.freezed.dart +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.freezed.dart @@ -19,8 +19,6 @@ mixin _$TransactionEntry { String get hash => throw _privateConstructorUsedError; int get topoHeight => throw _privateConstructorUsedError; TransactionEntryType get txEntryType => throw _privateConstructorUsedError; - int? get fee => throw _privateConstructorUsedError; - int? get nonce => throw _privateConstructorUsedError; @JsonKey(ignore: true) $TransactionEntryCopyWith get copyWith => @@ -33,12 +31,7 @@ abstract class $TransactionEntryCopyWith<$Res> { TransactionEntry value, $Res Function(TransactionEntry) then) = _$TransactionEntryCopyWithImpl<$Res, TransactionEntry>; @useResult - $Res call( - {String hash, - int topoHeight, - TransactionEntryType txEntryType, - int? fee, - int? nonce}); + $Res call({String hash, int topoHeight, TransactionEntryType txEntryType}); $TransactionEntryTypeCopyWith<$Res> get txEntryType; } @@ -59,8 +52,6 @@ class _$TransactionEntryCopyWithImpl<$Res, $Val extends TransactionEntry> Object? hash = null, Object? topoHeight = null, Object? txEntryType = null, - Object? fee = freezed, - Object? nonce = freezed, }) { return _then(_value.copyWith( hash: null == hash @@ -75,14 +66,6 @@ class _$TransactionEntryCopyWithImpl<$Res, $Val extends TransactionEntry> ? _value.txEntryType : txEntryType // ignore: cast_nullable_to_non_nullable as TransactionEntryType, - fee: freezed == fee - ? _value.fee - : fee // ignore: cast_nullable_to_non_nullable - as int?, - nonce: freezed == nonce - ? _value.nonce - : nonce // ignore: cast_nullable_to_non_nullable - as int?, ) as $Val); } @@ -103,12 +86,7 @@ abstract class _$$TransactionEntryImplCopyWith<$Res> __$$TransactionEntryImplCopyWithImpl<$Res>; @override @useResult - $Res call( - {String hash, - int topoHeight, - TransactionEntryType txEntryType, - int? fee, - int? nonce}); + $Res call({String hash, int topoHeight, TransactionEntryType txEntryType}); @override $TransactionEntryTypeCopyWith<$Res> get txEntryType; @@ -128,8 +106,6 @@ class __$$TransactionEntryImplCopyWithImpl<$Res> Object? hash = null, Object? topoHeight = null, Object? txEntryType = null, - Object? fee = freezed, - Object? nonce = freezed, }) { return _then(_$TransactionEntryImpl( hash: null == hash @@ -144,14 +120,6 @@ class __$$TransactionEntryImplCopyWithImpl<$Res> ? _value.txEntryType : txEntryType // ignore: cast_nullable_to_non_nullable as TransactionEntryType, - fee: freezed == fee - ? _value.fee - : fee // ignore: cast_nullable_to_non_nullable - as int?, - nonce: freezed == nonce - ? _value.nonce - : nonce // ignore: cast_nullable_to_non_nullable - as int?, )); } } @@ -162,9 +130,7 @@ class _$TransactionEntryImpl implements _TransactionEntry { const _$TransactionEntryImpl( {required this.hash, required this.topoHeight, - required this.txEntryType, - this.fee, - this.nonce}); + required this.txEntryType}); @override final String hash; @@ -172,14 +138,10 @@ class _$TransactionEntryImpl implements _TransactionEntry { final int topoHeight; @override final TransactionEntryType txEntryType; - @override - final int? fee; - @override - final int? nonce; @override String toString() { - return 'TransactionEntry(hash: $hash, topoHeight: $topoHeight, txEntryType: $txEntryType, fee: $fee, nonce: $nonce)'; + return 'TransactionEntry(hash: $hash, topoHeight: $topoHeight, txEntryType: $txEntryType)'; } @override @@ -191,14 +153,11 @@ class _$TransactionEntryImpl implements _TransactionEntry { (identical(other.topoHeight, topoHeight) || other.topoHeight == topoHeight) && (identical(other.txEntryType, txEntryType) || - other.txEntryType == txEntryType) && - (identical(other.fee, fee) || other.fee == fee) && - (identical(other.nonce, nonce) || other.nonce == nonce)); + other.txEntryType == txEntryType)); } @override - int get hashCode => - Object.hash(runtimeType, hash, topoHeight, txEntryType, fee, nonce); + int get hashCode => Object.hash(runtimeType, hash, topoHeight, txEntryType); @JsonKey(ignore: true) @override @@ -210,11 +169,10 @@ class _$TransactionEntryImpl implements _TransactionEntry { abstract class _TransactionEntry implements TransactionEntry { const factory _TransactionEntry( - {required final String hash, - required final int topoHeight, - required final TransactionEntryType txEntryType, - final int? fee, - final int? nonce}) = _$TransactionEntryImpl; + {required final String hash, + required final int topoHeight, + required final TransactionEntryType txEntryType}) = + _$TransactionEntryImpl; @override String get hash; @@ -223,10 +181,6 @@ abstract class _TransactionEntry implements TransactionEntry { @override TransactionEntryType get txEntryType; @override - int? get fee; - @override - int? get nonce; - @override @JsonKey(ignore: true) _$$TransactionEntryImplCopyWith<_$TransactionEntryImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.dart index 3f382ae..4d2acd5 100644 --- a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.dart +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.dart @@ -29,6 +29,8 @@ sealed class TransactionEntryType with _$TransactionEntryType { /// @nodoc const factory TransactionEntryType.outgoing({ + @JsonKey(name: 'fee') required int fee, + @JsonKey(name: 'nonce') required int nonce, @JsonKey(name: 'transfers') required List transfers, }) = OutgoingEntry; diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.freezed.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.freezed.dart index a1697f8..ab17bd3 100644 --- a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.freezed.dart +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.freezed.dart @@ -46,6 +46,8 @@ mixin _$TransactionEntryType { @JsonKey(name: 'transfers') List transfers) incoming, required TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers) outgoing, }) => @@ -60,6 +62,8 @@ mixin _$TransactionEntryType { @JsonKey(name: 'transfers') List transfers)? incoming, TResult? Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, }) => @@ -74,6 +78,8 @@ mixin _$TransactionEntryType { @JsonKey(name: 'transfers') List transfers)? incoming, TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, required TResult orElse(), @@ -208,6 +214,8 @@ class _$CoinbaseEntryImpl implements CoinbaseEntry { @JsonKey(name: 'transfers') List transfers) incoming, required TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers) outgoing, }) { @@ -225,6 +233,8 @@ class _$CoinbaseEntryImpl implements CoinbaseEntry { @JsonKey(name: 'transfers') List transfers)? incoming, TResult? Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, }) { @@ -242,6 +252,8 @@ class _$CoinbaseEntryImpl implements CoinbaseEntry { @JsonKey(name: 'transfers') List transfers)? incoming, TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, required TResult orElse(), @@ -407,6 +419,8 @@ class _$BurnEntryImpl implements BurnEntry { @JsonKey(name: 'transfers') List transfers) incoming, required TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers) outgoing, }) { @@ -424,6 +438,8 @@ class _$BurnEntryImpl implements BurnEntry { @JsonKey(name: 'transfers') List transfers)? incoming, TResult? Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, }) { @@ -441,6 +457,8 @@ class _$BurnEntryImpl implements BurnEntry { @JsonKey(name: 'transfers') List transfers)? incoming, TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, required TResult orElse(), @@ -617,6 +635,8 @@ class _$IncomingEntryImpl implements IncomingEntry { @JsonKey(name: 'transfers') List transfers) incoming, required TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers) outgoing, }) { @@ -634,6 +654,8 @@ class _$IncomingEntryImpl implements IncomingEntry { @JsonKey(name: 'transfers') List transfers)? incoming, TResult? Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, }) { @@ -651,6 +673,8 @@ class _$IncomingEntryImpl implements IncomingEntry { @JsonKey(name: 'transfers') List transfers)? incoming, TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, required TResult orElse(), @@ -730,7 +754,10 @@ abstract class _$$OutgoingEntryImplCopyWith<$Res> { _$OutgoingEntryImpl value, $Res Function(_$OutgoingEntryImpl) then) = __$$OutgoingEntryImplCopyWithImpl<$Res>; @useResult - $Res call({@JsonKey(name: 'transfers') List transfers}); + $Res call( + {@JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, + @JsonKey(name: 'transfers') List transfers}); } /// @nodoc @@ -744,9 +771,19 @@ class __$$OutgoingEntryImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ + Object? fee = null, + Object? nonce = null, Object? transfers = null, }) { return _then(_$OutgoingEntryImpl( + fee: null == fee + ? _value.fee + : fee // ignore: cast_nullable_to_non_nullable + as int, + nonce: null == nonce + ? _value.nonce + : nonce // ignore: cast_nullable_to_non_nullable + as int, transfers: null == transfers ? _value._transfers : transfers // ignore: cast_nullable_to_non_nullable @@ -759,7 +796,9 @@ class __$$OutgoingEntryImplCopyWithImpl<$Res> @JsonSerializable() class _$OutgoingEntryImpl implements OutgoingEntry { const _$OutgoingEntryImpl( - {@JsonKey(name: 'transfers') + {@JsonKey(name: 'fee') required this.fee, + @JsonKey(name: 'nonce') required this.nonce, + @JsonKey(name: 'transfers') required final List transfers, final String? $type}) : _transfers = transfers, @@ -768,6 +807,12 @@ class _$OutgoingEntryImpl implements OutgoingEntry { factory _$OutgoingEntryImpl.fromJson(Map json) => _$$OutgoingEntryImplFromJson(json); + @override + @JsonKey(name: 'fee') + final int fee; + @override + @JsonKey(name: 'nonce') + final int nonce; final List _transfers; @override @JsonKey(name: 'transfers') @@ -782,7 +827,7 @@ class _$OutgoingEntryImpl implements OutgoingEntry { @override String toString() { - return 'TransactionEntryType.outgoing(transfers: $transfers)'; + return 'TransactionEntryType.outgoing(fee: $fee, nonce: $nonce, transfers: $transfers)'; } @override @@ -790,14 +835,16 @@ class _$OutgoingEntryImpl implements OutgoingEntry { return identical(this, other) || (other.runtimeType == runtimeType && other is _$OutgoingEntryImpl && + (identical(other.fee, fee) || other.fee == fee) && + (identical(other.nonce, nonce) || other.nonce == nonce) && const DeepCollectionEquality() .equals(other._transfers, _transfers)); } @JsonKey(ignore: true) @override - int get hashCode => - Object.hash(runtimeType, const DeepCollectionEquality().hash(_transfers)); + int get hashCode => Object.hash( + runtimeType, fee, nonce, const DeepCollectionEquality().hash(_transfers)); @JsonKey(ignore: true) @override @@ -816,10 +863,12 @@ class _$OutgoingEntryImpl implements OutgoingEntry { @JsonKey(name: 'transfers') List transfers) incoming, required TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers) outgoing, }) { - return outgoing(transfers); + return outgoing(fee, nonce, transfers); } @override @@ -833,10 +882,12 @@ class _$OutgoingEntryImpl implements OutgoingEntry { @JsonKey(name: 'transfers') List transfers)? incoming, TResult? Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, }) { - return outgoing?.call(transfers); + return outgoing?.call(fee, nonce, transfers); } @override @@ -850,12 +901,14 @@ class _$OutgoingEntryImpl implements OutgoingEntry { @JsonKey(name: 'transfers') List transfers)? incoming, TResult Function( + @JsonKey(name: 'fee') int fee, + @JsonKey(name: 'nonce') int nonce, @JsonKey(name: 'transfers') List transfers)? outgoing, required TResult orElse(), }) { if (outgoing != null) { - return outgoing(transfers); + return outgoing(fee, nonce, transfers); } return orElse(); } @@ -907,12 +960,18 @@ class _$OutgoingEntryImpl implements OutgoingEntry { abstract class OutgoingEntry implements TransactionEntryType { const factory OutgoingEntry( - {@JsonKey(name: 'transfers') + {@JsonKey(name: 'fee') required final int fee, + @JsonKey(name: 'nonce') required final int nonce, + @JsonKey(name: 'transfers') required final List transfers}) = _$OutgoingEntryImpl; factory OutgoingEntry.fromJson(Map json) = _$OutgoingEntryImpl.fromJson; + @JsonKey(name: 'fee') + int get fee; + @JsonKey(name: 'nonce') + int get nonce; @JsonKey(name: 'transfers') List get transfers; @JsonKey(ignore: true) diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.g.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.g.dart index 65be5c4..958c875 100644 --- a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.g.dart +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry_type.g.dart @@ -52,6 +52,8 @@ Map _$$IncomingEntryImplToJson(_$IncomingEntryImpl instance) => _$OutgoingEntryImpl _$$OutgoingEntryImplFromJson(Map json) => _$OutgoingEntryImpl( + fee: json['fee'] as int, + nonce: json['nonce'] as int, transfers: (json['transfers'] as List) .map((e) => TransferOutEntry.fromJson(e as Map)) .toList(), @@ -60,6 +62,8 @@ _$OutgoingEntryImpl _$$OutgoingEntryImplFromJson(Map json) => Map _$$OutgoingEntryImplToJson(_$OutgoingEntryImpl instance) => { + 'fee': instance.fee, + 'nonce': instance.nonce, 'transfers': instance.transfers, 'runtimeType': instance.$type, }; diff --git a/pubspec.yaml b/pubspec.yaml index 333cfa8..4df87e2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: xelis_dart_sdk description: Software Development Kit in Dart to build Apps for the Xelis Blockchain. -version: 0.16.2 +version: 0.17.0 repository: https://github.com/xelis-project/xelis-dart-jdk environment: @@ -18,7 +18,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.9 - freezed: ^2.4.7 + freezed: ^2.5.1 json_serializable: ^6.7.1 lints: ^3.0.0 - test: ^1.25.2 + test: ^1.25.3