diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f5a492..02d7adf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.15.0 + +- fix some dtos. +- activate wallet events. +- add BasicAuth to wallet client. + ## 0.14.0 Daemon API upgrade : diff --git a/lib/src/data_transfer_objects/dtos.dart b/lib/src/data_transfer_objects/dtos.dart index beb203b..a85eaca 100644 --- a/lib/src/data_transfer_objects/dtos.dart +++ b/lib/src/data_transfer_objects/dtos.dart @@ -48,18 +48,22 @@ export 'submit_block/submit_block_params.dart'; export 'submit_transaction/submit_transaction_params.dart'; export 'transaction/burn.dart'; export 'transaction/call_contract.dart'; -export 'transaction/transaction.dart'; +export 'transaction/transaction_response.dart'; export 'transaction/transaction_type.dart'; export 'transaction/transfer.dart'; export 'transaction_executed_event/transaction_executed_event.dart'; export 'versioned_balance/versioned_balance.dart'; -export 'wallet/balance_changed_event/balance_changed.dart'; +export 'wallet/balance_changed_event/balance_changed_event.dart'; export 'wallet/build_transaction/build_transaction_params.dart'; export 'wallet/build_transaction/fee_builder.dart'; export 'wallet/get_address/get_address_params.dart'; export 'wallet/list_transactions/list_transactions_params.dart'; -export 'wallet/list_transactions/transaction_entry.dart'; export 'wallet/new_asset_event/asset_with_data.dart'; export 'wallet/rescan/rescan_params.dart'; export 'wallet/split_address/split_address_params.dart'; export 'wallet/split_address/split_address_result.dart'; +export 'wallet/transaction_entry/coinbase.dart'; +export 'wallet/transaction_entry/incoming.dart'; +export 'wallet/transaction_entry/outgoing.dart'; +export 'wallet/transaction_entry/tranfer_entry.dart'; +export 'wallet/transaction_entry/transaction_entry.dart'; diff --git a/lib/src/data_transfer_objects/get_nonce_at_topoheight/get_nonce_at_topoheight_result.freezed.dart b/lib/src/data_transfer_objects/get_nonce_at_topoheight/get_nonce_at_topoheight_result.freezed.dart index a433540..87399d6 100644 --- a/lib/src/data_transfer_objects/get_nonce_at_topoheight/get_nonce_at_topoheight_result.freezed.dart +++ b/lib/src/data_transfer_objects/get_nonce_at_topoheight/get_nonce_at_topoheight_result.freezed.dart @@ -23,12 +23,10 @@ GetNonceAtTopoHeightResult _$GetNonceAtTopoHeightResultFromJson( mixin _$GetNonceAtTopoHeightResult { @JsonKey(name: 'nonce') int get nonce => throw _privateConstructorUsedError; - @JsonKey(name: 'previous_topoheight') int? get previousTopoheight => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $GetNonceAtTopoHeightResultCopyWith get copyWith => throw _privateConstructorUsedError; @@ -40,7 +38,6 @@ abstract class $GetNonceAtTopoHeightResultCopyWith<$Res> { $Res Function(GetNonceAtTopoHeightResult) then) = _$GetNonceAtTopoHeightResultCopyWithImpl<$Res, GetNonceAtTopoHeightResult>; - @useResult $Res call( {@JsonKey(name: 'nonce') int nonce, @@ -55,7 +52,6 @@ class _$GetNonceAtTopoHeightResultCopyWithImpl<$Res, // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -85,7 +81,6 @@ abstract class _$$GetNonceAtTopoHeightResultImplCopyWith<$Res> _$GetNonceAtTopoHeightResultImpl value, $Res Function(_$GetNonceAtTopoHeightResultImpl) then) = __$$GetNonceAtTopoHeightResultImplCopyWithImpl<$Res>; - @override @useResult $Res call( @@ -187,11 +182,9 @@ abstract class _GetNonceAtTopoHeightResult @override @JsonKey(name: 'nonce') int get nonce; - @override @JsonKey(name: 'previous_topoheight') int? get previousTopoheight; - @override @JsonKey(ignore: true) _$$GetNonceAtTopoHeightResultImplCopyWith<_$GetNonceAtTopoHeightResultImpl> diff --git a/lib/src/data_transfer_objects/has_balance/has_balance_params.freezed.dart b/lib/src/data_transfer_objects/has_balance/has_balance_params.freezed.dart index ce01734..ca594c0 100644 --- a/lib/src/data_transfer_objects/has_balance/has_balance_params.freezed.dart +++ b/lib/src/data_transfer_objects/has_balance/has_balance_params.freezed.dart @@ -22,15 +22,12 @@ HasBalanceParams _$HasBalanceParamsFromJson(Map json) { mixin _$HasBalanceParams { @JsonKey(name: 'address') String get address => throw _privateConstructorUsedError; - @JsonKey(name: 'asset') String get asset => throw _privateConstructorUsedError; - @JsonKey(name: 'topoheight') int? get topoheight => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $HasBalanceParamsCopyWith get copyWith => throw _privateConstructorUsedError; @@ -41,7 +38,6 @@ abstract class $HasBalanceParamsCopyWith<$Res> { factory $HasBalanceParamsCopyWith( HasBalanceParams value, $Res Function(HasBalanceParams) then) = _$HasBalanceParamsCopyWithImpl<$Res, HasBalanceParams>; - @useResult $Res call( {@JsonKey(name: 'address') String address, @@ -56,7 +52,6 @@ class _$HasBalanceParamsCopyWithImpl<$Res, $Val extends HasBalanceParams> // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -90,7 +85,6 @@ abstract class _$$HasBalanceParamsImplCopyWith<$Res> factory _$$HasBalanceParamsImplCopyWith(_$HasBalanceParamsImpl value, $Res Function(_$HasBalanceParamsImpl) then) = __$$HasBalanceParamsImplCopyWithImpl<$Res>; - @override @useResult $Res call( @@ -200,15 +194,12 @@ abstract class _HasBalanceParams implements HasBalanceParams { @override @JsonKey(name: 'address') String get address; - @override @JsonKey(name: 'asset') String get asset; - @override @JsonKey(name: 'topoheight') int? get topoheight; - @override @JsonKey(ignore: true) _$$HasBalanceParamsImplCopyWith<_$HasBalanceParamsImpl> get copyWith => diff --git a/lib/src/data_transfer_objects/has_balance/has_balance_result.freezed.dart b/lib/src/data_transfer_objects/has_balance/has_balance_result.freezed.dart index 019d38e..7370969 100644 --- a/lib/src/data_transfer_objects/has_balance/has_balance_result.freezed.dart +++ b/lib/src/data_transfer_objects/has_balance/has_balance_result.freezed.dart @@ -24,7 +24,6 @@ mixin _$HasBalanceResult { bool get exist => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $HasBalanceResultCopyWith get copyWith => throw _privateConstructorUsedError; @@ -35,7 +34,6 @@ abstract class $HasBalanceResultCopyWith<$Res> { factory $HasBalanceResultCopyWith( HasBalanceResult value, $Res Function(HasBalanceResult) then) = _$HasBalanceResultCopyWithImpl<$Res, HasBalanceResult>; - @useResult $Res call({@JsonKey(name: 'exist') bool exist}); } @@ -47,7 +45,6 @@ class _$HasBalanceResultCopyWithImpl<$Res, $Val extends HasBalanceResult> // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -71,7 +68,6 @@ abstract class _$$HasBalanceResultImplCopyWith<$Res> factory _$$HasBalanceResultImplCopyWith(_$HasBalanceResultImpl value, $Res Function(_$HasBalanceResultImpl) then) = __$$HasBalanceResultImplCopyWithImpl<$Res>; - @override @useResult $Res call({@JsonKey(name: 'exist') bool exist}); @@ -154,7 +150,6 @@ abstract class _HasBalanceResult implements HasBalanceResult { @override @JsonKey(name: 'exist') bool get exist; - @override @JsonKey(ignore: true) _$$HasBalanceResultImplCopyWith<_$HasBalanceResultImpl> get copyWith => diff --git a/lib/src/data_transfer_objects/transaction/transaction.dart b/lib/src/data_transfer_objects/transaction/transaction_response.dart similarity index 72% rename from lib/src/data_transfer_objects/transaction/transaction.dart rename to lib/src/data_transfer_objects/transaction/transaction_response.dart index 72a3834..c0120bd 100644 --- a/lib/src/data_transfer_objects/transaction/transaction.dart +++ b/lib/src/data_transfer_objects/transaction/transaction_response.dart @@ -3,14 +3,14 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:xelis_dart_sdk/src/data_transfer_objects/dtos.dart'; -part 'transaction.freezed.dart'; +part 'transaction_response.freezed.dart'; -part 'transaction.g.dart'; +part 'transaction_response.g.dart'; @freezed -class Transaction with _$Transaction { +class TransactionResponse with _$TransactionResponse { @JsonSerializable(includeIfNull: false) - const factory Transaction({ + const factory TransactionResponse({ @JsonKey(name: 'blocks') List? blocks, @JsonKey(name: 'executed_in_block') String? executedInBlock, @JsonKey(name: 'hash') required String hash, @@ -21,8 +21,8 @@ class Transaction with _$Transaction { @JsonKey(name: 'nonce') required int nonce, @JsonKey(name: 'owner') required String owner, @JsonKey(name: 'signature') required String signature, - }) = _Transaction; + }) = _TransactionResponse; - factory Transaction.fromJson(Map json) => - _$TransactionFromJson(json); + factory TransactionResponse.fromJson(Map json) => + _$TransactionResponseFromJson(json); } diff --git a/lib/src/data_transfer_objects/transaction/transaction.freezed.dart b/lib/src/data_transfer_objects/transaction/transaction_response.freezed.dart similarity index 82% rename from lib/src/data_transfer_objects/transaction/transaction.freezed.dart rename to lib/src/data_transfer_objects/transaction/transaction_response.freezed.dart index df82ca8..f1281b9 100644 --- a/lib/src/data_transfer_objects/transaction/transaction.freezed.dart +++ b/lib/src/data_transfer_objects/transaction/transaction_response.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'transaction.dart'; +part of 'transaction_response.dart'; // ************************************************************************** // FreezedGenerator @@ -14,20 +14,24 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); -Transaction _$TransactionFromJson(Map json) { - return _Transaction.fromJson(json); +TransactionResponse _$TransactionResponseFromJson(Map json) { + return _TransactionResponse.fromJson(json); } /// @nodoc -mixin _$Transaction { +mixin _$TransactionResponse { @JsonKey(name: 'blocks') List? get blocks => throw _privateConstructorUsedError; + @JsonKey(name: 'executed_in_block') String? get executedInBlock => throw _privateConstructorUsedError; + @JsonKey(name: 'hash') String get hash => throw _privateConstructorUsedError; + @JsonKey(name: 'data') TransactionType get data => throw _privateConstructorUsedError; + @JsonKey(name: 'fee') int get fee => throw _privateConstructorUsedError; @JsonKey(name: 'version') @@ -42,16 +46,18 @@ mixin _$Transaction { String get signature => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) - $TransactionCopyWith get copyWith => + $TransactionResponseCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $TransactionCopyWith<$Res> { - factory $TransactionCopyWith( - Transaction value, $Res Function(Transaction) then) = - _$TransactionCopyWithImpl<$Res, Transaction>; +abstract class $TransactionResponseCopyWith<$Res> { + factory $TransactionResponseCopyWith( + TransactionResponse value, $Res Function(TransactionResponse) then) = + _$TransactionResponseCopyWithImpl<$Res, TransactionResponse>; + @useResult $Res call( {@JsonKey(name: 'blocks') List? blocks, @@ -69,12 +75,13 @@ abstract class $TransactionCopyWith<$Res> { } /// @nodoc -class _$TransactionCopyWithImpl<$Res, $Val extends Transaction> - implements $TransactionCopyWith<$Res> { - _$TransactionCopyWithImpl(this._value, this._then); +class _$TransactionResponseCopyWithImpl<$Res, $Val extends TransactionResponse> + implements $TransactionResponseCopyWith<$Res> { + _$TransactionResponseCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; + // ignore: unused_field final $Res Function($Val) _then; @@ -146,11 +153,12 @@ class _$TransactionCopyWithImpl<$Res, $Val extends Transaction> } /// @nodoc -abstract class _$$TransactionImplCopyWith<$Res> - implements $TransactionCopyWith<$Res> { - factory _$$TransactionImplCopyWith( - _$TransactionImpl value, $Res Function(_$TransactionImpl) then) = - __$$TransactionImplCopyWithImpl<$Res>; +abstract class _$$TransactionResponseImplCopyWith<$Res> + implements $TransactionResponseCopyWith<$Res> { + factory _$$TransactionResponseImplCopyWith(_$TransactionResponseImpl value, + $Res Function(_$TransactionResponseImpl) then) = + __$$TransactionResponseImplCopyWithImpl<$Res>; + @override @useResult $Res call( @@ -170,11 +178,11 @@ abstract class _$$TransactionImplCopyWith<$Res> } /// @nodoc -class __$$TransactionImplCopyWithImpl<$Res> - extends _$TransactionCopyWithImpl<$Res, _$TransactionImpl> - implements _$$TransactionImplCopyWith<$Res> { - __$$TransactionImplCopyWithImpl( - _$TransactionImpl _value, $Res Function(_$TransactionImpl) _then) +class __$$TransactionResponseImplCopyWithImpl<$Res> + extends _$TransactionResponseCopyWithImpl<$Res, _$TransactionResponseImpl> + implements _$$TransactionResponseImplCopyWith<$Res> { + __$$TransactionResponseImplCopyWithImpl(_$TransactionResponseImpl _value, + $Res Function(_$TransactionResponseImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -191,7 +199,7 @@ class __$$TransactionImplCopyWithImpl<$Res> Object? owner = null, Object? signature = null, }) { - return _then(_$TransactionImpl( + return _then(_$TransactionResponseImpl( blocks: freezed == blocks ? _value._blocks : blocks // ignore: cast_nullable_to_non_nullable @@ -239,8 +247,8 @@ class __$$TransactionImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable(includeIfNull: false) -class _$TransactionImpl implements _Transaction { - const _$TransactionImpl( +class _$TransactionResponseImpl implements _TransactionResponse { + const _$TransactionResponseImpl( {@JsonKey(name: 'blocks') final List? blocks, @JsonKey(name: 'executed_in_block') this.executedInBlock, @JsonKey(name: 'hash') required this.hash, @@ -253,10 +261,11 @@ class _$TransactionImpl implements _Transaction { @JsonKey(name: 'signature') required this.signature}) : _blocks = blocks; - factory _$TransactionImpl.fromJson(Map json) => - _$$TransactionImplFromJson(json); + factory _$TransactionResponseImpl.fromJson(Map json) => + _$$TransactionResponseImplFromJson(json); final List? _blocks; + @override @JsonKey(name: 'blocks') List? get blocks { @@ -297,14 +306,14 @@ class _$TransactionImpl implements _Transaction { @override String toString() { - return 'Transaction(blocks: $blocks, executedInBlock: $executedInBlock, hash: $hash, data: $data, fee: $fee, version: $version, inMempool: $inMempool, nonce: $nonce, owner: $owner, signature: $signature)'; + return 'TransactionResponse(blocks: $blocks, executedInBlock: $executedInBlock, hash: $hash, data: $data, fee: $fee, version: $version, inMempool: $inMempool, nonce: $nonce, owner: $owner, signature: $signature)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$TransactionImpl && + other is _$TransactionResponseImpl && const DeepCollectionEquality().equals(other._blocks, _blocks) && (identical(other.executedInBlock, executedInBlock) || other.executedInBlock == executedInBlock) && @@ -338,19 +347,20 @@ class _$TransactionImpl implements _Transaction { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$TransactionImplCopyWith<_$TransactionImpl> get copyWith => - __$$TransactionImplCopyWithImpl<_$TransactionImpl>(this, _$identity); + _$$TransactionResponseImplCopyWith<_$TransactionResponseImpl> get copyWith => + __$$TransactionResponseImplCopyWithImpl<_$TransactionResponseImpl>( + this, _$identity); @override Map toJson() { - return _$$TransactionImplToJson( + return _$$TransactionResponseImplToJson( this, ); } } -abstract class _Transaction implements Transaction { - const factory _Transaction( +abstract class _TransactionResponse implements TransactionResponse { + const factory _TransactionResponse( {@JsonKey(name: 'blocks') final List? blocks, @JsonKey(name: 'executed_in_block') final String? executedInBlock, @JsonKey(name: 'hash') required final String hash, @@ -361,17 +371,19 @@ abstract class _Transaction implements Transaction { @JsonKey(name: 'nonce') required final int nonce, @JsonKey(name: 'owner') required final String owner, @JsonKey(name: 'signature') required final String signature}) = - _$TransactionImpl; + _$TransactionResponseImpl; - factory _Transaction.fromJson(Map json) = - _$TransactionImpl.fromJson; + factory _TransactionResponse.fromJson(Map json) = + _$TransactionResponseImpl.fromJson; @override @JsonKey(name: 'blocks') List? get blocks; + @override @JsonKey(name: 'executed_in_block') String? get executedInBlock; + @override @JsonKey(name: 'hash') String get hash; @@ -393,11 +405,13 @@ abstract class _Transaction implements Transaction { @override @JsonKey(name: 'owner') String get owner; + @override @JsonKey(name: 'signature') String get signature; + @override @JsonKey(ignore: true) - _$$TransactionImplCopyWith<_$TransactionImpl> get copyWith => + _$$TransactionResponseImplCopyWith<_$TransactionResponseImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/src/data_transfer_objects/transaction/transaction.g.dart b/lib/src/data_transfer_objects/transaction/transaction_response.g.dart similarity index 83% rename from lib/src/data_transfer_objects/transaction/transaction.g.dart rename to lib/src/data_transfer_objects/transaction/transaction_response.g.dart index dd225cf..816d528 100644 --- a/lib/src/data_transfer_objects/transaction/transaction.g.dart +++ b/lib/src/data_transfer_objects/transaction/transaction_response.g.dart @@ -2,14 +2,15 @@ // ignore_for_file: package_api_docs, non_constant_identifier_names -part of 'transaction.dart'; +part of 'transaction_response.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$TransactionImpl _$$TransactionImplFromJson(Map json) => - _$TransactionImpl( +_$TransactionResponseImpl _$$TransactionResponseImplFromJson( + Map json) => + _$TransactionResponseImpl( blocks: (json['blocks'] as List?)?.map((e) => e as String).toList(), executedInBlock: json['executed_in_block'] as String?, @@ -23,7 +24,8 @@ _$TransactionImpl _$$TransactionImplFromJson(Map json) => signature: json['signature'] as String, ); -Map _$$TransactionImplToJson(_$TransactionImpl instance) { +Map _$$TransactionResponseImplToJson( + _$TransactionResponseImpl instance) { final val = {}; void writeNotNull(String key, dynamic value) { diff --git a/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.dart b/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.dart deleted file mode 100644 index 1c8e64e..0000000 --- a/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.dart +++ /dev/null @@ -1,18 +0,0 @@ -// ignore_for_file: public_member_api_docs, invalid_annotation_target - -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'balance_changed.freezed.dart'; - -part 'balance_changed.g.dart'; - -@freezed -class BalanceChanged with _$BalanceChanged { - const factory BalanceChanged({ - @JsonKey(name: 'asset') required String assetHash, - @JsonKey(name: 'balance') required int balance, - }) = _BalanceChanged; - - factory BalanceChanged.fromJson(Map json) => - _$BalanceChangedFromJson(json); -} diff --git a/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.dart b/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.dart new file mode 100644 index 0000000..65b0064 --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.dart @@ -0,0 +1,18 @@ +// ignore_for_file: public_member_api_docs, invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'balance_changed_event.freezed.dart'; + +part 'balance_changed_event.g.dart'; + +@freezed +class BalanceChangedEvent with _$BalanceChangedEvent { + const factory BalanceChangedEvent({ + @JsonKey(name: 'asset') required String assetHash, + @JsonKey(name: 'balance') required int balance, + }) = _BalanceChangedEvent; + + factory BalanceChangedEvent.fromJson(Map json) => + _$BalanceChangedEventFromJson(json); +} diff --git a/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.freezed.dart b/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.freezed.dart similarity index 63% rename from lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.freezed.dart rename to lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.freezed.dart index d5dbd9c..90146cd 100644 --- a/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.freezed.dart +++ b/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'balance_changed.dart'; +part of 'balance_changed_event.dart'; // ************************************************************************** // FreezedGenerator @@ -14,28 +14,31 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); -BalanceChanged _$BalanceChangedFromJson(Map json) { - return _BalanceChanged.fromJson(json); +BalanceChangedEvent _$BalanceChangedEventFromJson(Map json) { + return _BalanceChangedEvent.fromJson(json); } /// @nodoc -mixin _$BalanceChanged { +mixin _$BalanceChangedEvent { @JsonKey(name: 'asset') String get assetHash => throw _privateConstructorUsedError; + @JsonKey(name: 'balance') int get balance => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) - $BalanceChangedCopyWith get copyWith => + $BalanceChangedEventCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $BalanceChangedCopyWith<$Res> { - factory $BalanceChangedCopyWith( - BalanceChanged value, $Res Function(BalanceChanged) then) = - _$BalanceChangedCopyWithImpl<$Res, BalanceChanged>; +abstract class $BalanceChangedEventCopyWith<$Res> { + factory $BalanceChangedEventCopyWith( + BalanceChangedEvent value, $Res Function(BalanceChangedEvent) then) = + _$BalanceChangedEventCopyWithImpl<$Res, BalanceChangedEvent>; + @useResult $Res call( {@JsonKey(name: 'asset') String assetHash, @@ -43,12 +46,13 @@ abstract class $BalanceChangedCopyWith<$Res> { } /// @nodoc -class _$BalanceChangedCopyWithImpl<$Res, $Val extends BalanceChanged> - implements $BalanceChangedCopyWith<$Res> { - _$BalanceChangedCopyWithImpl(this._value, this._then); +class _$BalanceChangedEventCopyWithImpl<$Res, $Val extends BalanceChangedEvent> + implements $BalanceChangedEventCopyWith<$Res> { + _$BalanceChangedEventCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; + // ignore: unused_field final $Res Function($Val) _then; @@ -72,11 +76,12 @@ class _$BalanceChangedCopyWithImpl<$Res, $Val extends BalanceChanged> } /// @nodoc -abstract class _$$BalanceChangedImplCopyWith<$Res> - implements $BalanceChangedCopyWith<$Res> { - factory _$$BalanceChangedImplCopyWith(_$BalanceChangedImpl value, - $Res Function(_$BalanceChangedImpl) then) = - __$$BalanceChangedImplCopyWithImpl<$Res>; +abstract class _$$BalanceChangedEventImplCopyWith<$Res> + implements $BalanceChangedEventCopyWith<$Res> { + factory _$$BalanceChangedEventImplCopyWith(_$BalanceChangedEventImpl value, + $Res Function(_$BalanceChangedEventImpl) then) = + __$$BalanceChangedEventImplCopyWithImpl<$Res>; + @override @useResult $Res call( @@ -85,11 +90,11 @@ abstract class _$$BalanceChangedImplCopyWith<$Res> } /// @nodoc -class __$$BalanceChangedImplCopyWithImpl<$Res> - extends _$BalanceChangedCopyWithImpl<$Res, _$BalanceChangedImpl> - implements _$$BalanceChangedImplCopyWith<$Res> { - __$$BalanceChangedImplCopyWithImpl( - _$BalanceChangedImpl _value, $Res Function(_$BalanceChangedImpl) _then) +class __$$BalanceChangedEventImplCopyWithImpl<$Res> + extends _$BalanceChangedEventCopyWithImpl<$Res, _$BalanceChangedEventImpl> + implements _$$BalanceChangedEventImplCopyWith<$Res> { + __$$BalanceChangedEventImplCopyWithImpl(_$BalanceChangedEventImpl _value, + $Res Function(_$BalanceChangedEventImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -98,7 +103,7 @@ class __$$BalanceChangedImplCopyWithImpl<$Res> Object? assetHash = null, Object? balance = null, }) { - return _then(_$BalanceChangedImpl( + return _then(_$BalanceChangedEventImpl( assetHash: null == assetHash ? _value.assetHash : assetHash // ignore: cast_nullable_to_non_nullable @@ -113,13 +118,13 @@ class __$$BalanceChangedImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$BalanceChangedImpl implements _BalanceChanged { - const _$BalanceChangedImpl( +class _$BalanceChangedEventImpl implements _BalanceChangedEvent { + const _$BalanceChangedEventImpl( {@JsonKey(name: 'asset') required this.assetHash, @JsonKey(name: 'balance') required this.balance}); - factory _$BalanceChangedImpl.fromJson(Map json) => - _$$BalanceChangedImplFromJson(json); + factory _$BalanceChangedEventImpl.fromJson(Map json) => + _$$BalanceChangedEventImplFromJson(json); @override @JsonKey(name: 'asset') @@ -130,14 +135,14 @@ class _$BalanceChangedImpl implements _BalanceChanged { @override String toString() { - return 'BalanceChanged(assetHash: $assetHash, balance: $balance)'; + return 'BalanceChangedEvent(assetHash: $assetHash, balance: $balance)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$BalanceChangedImpl && + other is _$BalanceChangedEventImpl && (identical(other.assetHash, assetHash) || other.assetHash == assetHash) && (identical(other.balance, balance) || other.balance == balance)); @@ -150,35 +155,37 @@ class _$BalanceChangedImpl implements _BalanceChanged { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$BalanceChangedImplCopyWith<_$BalanceChangedImpl> get copyWith => - __$$BalanceChangedImplCopyWithImpl<_$BalanceChangedImpl>( + _$$BalanceChangedEventImplCopyWith<_$BalanceChangedEventImpl> get copyWith => + __$$BalanceChangedEventImplCopyWithImpl<_$BalanceChangedEventImpl>( this, _$identity); @override Map toJson() { - return _$$BalanceChangedImplToJson( + return _$$BalanceChangedEventImplToJson( this, ); } } -abstract class _BalanceChanged implements BalanceChanged { - const factory _BalanceChanged( +abstract class _BalanceChangedEvent implements BalanceChangedEvent { + const factory _BalanceChangedEvent( {@JsonKey(name: 'asset') required final String assetHash, @JsonKey(name: 'balance') required final int balance}) = - _$BalanceChangedImpl; + _$BalanceChangedEventImpl; - factory _BalanceChanged.fromJson(Map json) = - _$BalanceChangedImpl.fromJson; + factory _BalanceChangedEvent.fromJson(Map json) = + _$BalanceChangedEventImpl.fromJson; @override @JsonKey(name: 'asset') String get assetHash; + @override @JsonKey(name: 'balance') int get balance; + @override @JsonKey(ignore: true) - _$$BalanceChangedImplCopyWith<_$BalanceChangedImpl> get copyWith => + _$$BalanceChangedEventImplCopyWith<_$BalanceChangedEventImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.g.dart b/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.g.dart similarity index 64% rename from lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.g.dart rename to lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.g.dart index a1ba054..91c26b5 100644 --- a/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed.g.dart +++ b/lib/src/data_transfer_objects/wallet/balance_changed_event/balance_changed_event.g.dart @@ -2,20 +2,21 @@ // ignore_for_file: package_api_docs, non_constant_identifier_names -part of 'balance_changed.dart'; +part of 'balance_changed_event.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$BalanceChangedImpl _$$BalanceChangedImplFromJson(Map json) => - _$BalanceChangedImpl( +_$BalanceChangedEventImpl _$$BalanceChangedEventImplFromJson( + Map json) => + _$BalanceChangedEventImpl( assetHash: json['asset'] as String, balance: json['balance'] as int, ); -Map _$$BalanceChangedImplToJson( - _$BalanceChangedImpl instance) => +Map _$$BalanceChangedEventImplToJson( + _$BalanceChangedEventImpl instance) => { 'asset': instance.assetHash, 'balance': instance.balance, diff --git a/lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.g.dart b/lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.g.dart deleted file mode 100644 index 11df4da..0000000 --- a/lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.g.dart +++ /dev/null @@ -1,42 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -// ignore_for_file: package_api_docs, non_constant_identifier_names - -part of 'transaction_entry.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$TransactionEntryImpl _$$TransactionEntryImplFromJson( - Map json) => - _$TransactionEntryImpl( - hash: json['hash'] as String, - topoHeight: json['topoheight'] as int, - transfers: (json['transfers'] as List?) - ?.map((e) => Transfer.fromJson(e as Map)) - .toList(), - burn: json['burn'] == null - ? null - : Burn.fromJson(json['burn'] as Map), - callContract: json['call_contract'] == null - ? null - : CallContract.fromJson( - json['call_contract'] as Map), - deployContract: json['deploy_contract'] as String?, - fee: json['fee'] as int?, - nonce: json['nonce'] as int?, - ); - -Map _$$TransactionEntryImplToJson( - _$TransactionEntryImpl instance) => - { - 'hash': instance.hash, - 'topoheight': instance.topoHeight, - 'transfers': instance.transfers, - 'burn': instance.burn, - 'call_contract': instance.callContract, - 'deploy_contract': instance.deployContract, - 'fee': instance.fee, - 'nonce': instance.nonce, - }; diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.dart new file mode 100644 index 0000000..25ca8be --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.dart @@ -0,0 +1,17 @@ +// ignore_for_file: public_member_api_docs, invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'coinbase.freezed.dart'; + +part 'coinbase.g.dart'; + +@freezed +class Coinbase with _$Coinbase { + const factory Coinbase({ + @JsonKey(name: 'reward') required int reward, + }) = _Coinbase; + + factory Coinbase.fromJson(Map json) => + _$CoinbaseFromJson(json); +} diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.freezed.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.freezed.dart new file mode 100644 index 0000000..a78264c --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.freezed.dart @@ -0,0 +1,159 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'coinbase.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +Coinbase _$CoinbaseFromJson(Map json) { + return _Coinbase.fromJson(json); +} + +/// @nodoc +mixin _$Coinbase { + @JsonKey(name: 'reward') + int get reward => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $CoinbaseCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CoinbaseCopyWith<$Res> { + factory $CoinbaseCopyWith(Coinbase value, $Res Function(Coinbase) then) = + _$CoinbaseCopyWithImpl<$Res, Coinbase>; + + @useResult + $Res call({@JsonKey(name: 'reward') int reward}); +} + +/// @nodoc +class _$CoinbaseCopyWithImpl<$Res, $Val extends Coinbase> + implements $CoinbaseCopyWith<$Res> { + _$CoinbaseCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? reward = null, + }) { + return _then(_value.copyWith( + reward: null == reward + ? _value.reward + : reward // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$CoinbaseImplCopyWith<$Res> + implements $CoinbaseCopyWith<$Res> { + factory _$$CoinbaseImplCopyWith( + _$CoinbaseImpl value, $Res Function(_$CoinbaseImpl) then) = + __$$CoinbaseImplCopyWithImpl<$Res>; + + @override + @useResult + $Res call({@JsonKey(name: 'reward') int reward}); +} + +/// @nodoc +class __$$CoinbaseImplCopyWithImpl<$Res> + extends _$CoinbaseCopyWithImpl<$Res, _$CoinbaseImpl> + implements _$$CoinbaseImplCopyWith<$Res> { + __$$CoinbaseImplCopyWithImpl( + _$CoinbaseImpl _value, $Res Function(_$CoinbaseImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? reward = null, + }) { + return _then(_$CoinbaseImpl( + reward: null == reward + ? _value.reward + : reward // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$CoinbaseImpl implements _Coinbase { + const _$CoinbaseImpl({@JsonKey(name: 'reward') required this.reward}); + + factory _$CoinbaseImpl.fromJson(Map json) => + _$$CoinbaseImplFromJson(json); + + @override + @JsonKey(name: 'reward') + final int reward; + + @override + String toString() { + return 'Coinbase(reward: $reward)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CoinbaseImpl && + (identical(other.reward, reward) || other.reward == reward)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, reward); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$CoinbaseImplCopyWith<_$CoinbaseImpl> get copyWith => + __$$CoinbaseImplCopyWithImpl<_$CoinbaseImpl>(this, _$identity); + + @override + Map toJson() { + return _$$CoinbaseImplToJson( + this, + ); + } +} + +abstract class _Coinbase implements Coinbase { + const factory _Coinbase( + {@JsonKey(name: 'reward') required final int reward}) = _$CoinbaseImpl; + + factory _Coinbase.fromJson(Map json) = + _$CoinbaseImpl.fromJson; + + @override + @JsonKey(name: 'reward') + int get reward; + + @override + @JsonKey(ignore: true) + _$$CoinbaseImplCopyWith<_$CoinbaseImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.g.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.g.dart new file mode 100644 index 0000000..f868bba --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/coinbase.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: package_api_docs, non_constant_identifier_names + +part of 'coinbase.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$CoinbaseImpl _$$CoinbaseImplFromJson(Map json) => + _$CoinbaseImpl( + reward: json['reward'] as int, + ); + +Map _$$CoinbaseImplToJson(_$CoinbaseImpl instance) => + { + 'reward': instance.reward, + }; diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.dart new file mode 100644 index 0000000..ae96ce6 --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.dart @@ -0,0 +1,19 @@ +// ignore_for_file: public_member_api_docs, invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:xelis_dart_sdk/xelis_dart_sdk.dart'; + +part 'incoming.freezed.dart'; + +part 'incoming.g.dart'; + +@freezed +class Incoming with _$Incoming { + const factory Incoming({ + @JsonKey(name: 'from') required String from, + @JsonKey(name: 'transfers') required List transfers, + }) = _Incoming; + + factory Incoming.fromJson(Map json) => + _$IncomingFromJson(json); +} diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.freezed.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.freezed.dart new file mode 100644 index 0000000..112ad52 --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.freezed.dart @@ -0,0 +1,197 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'incoming.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +Incoming _$IncomingFromJson(Map json) { + return _Incoming.fromJson(json); +} + +/// @nodoc +mixin _$Incoming { + @JsonKey(name: 'from') + String get from => throw _privateConstructorUsedError; + + @JsonKey(name: 'transfers') + List get transfers => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $IncomingCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $IncomingCopyWith<$Res> { + factory $IncomingCopyWith(Incoming value, $Res Function(Incoming) then) = + _$IncomingCopyWithImpl<$Res, Incoming>; + + @useResult + $Res call( + {@JsonKey(name: 'from') String from, + @JsonKey(name: 'transfers') List transfers}); +} + +/// @nodoc +class _$IncomingCopyWithImpl<$Res, $Val extends Incoming> + implements $IncomingCopyWith<$Res> { + _$IncomingCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? from = null, + Object? transfers = null, + }) { + return _then(_value.copyWith( + from: null == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as String, + transfers: null == transfers + ? _value.transfers + : transfers // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$IncomingImplCopyWith<$Res> + implements $IncomingCopyWith<$Res> { + factory _$$IncomingImplCopyWith( + _$IncomingImpl value, $Res Function(_$IncomingImpl) then) = + __$$IncomingImplCopyWithImpl<$Res>; + + @override + @useResult + $Res call( + {@JsonKey(name: 'from') String from, + @JsonKey(name: 'transfers') List transfers}); +} + +/// @nodoc +class __$$IncomingImplCopyWithImpl<$Res> + extends _$IncomingCopyWithImpl<$Res, _$IncomingImpl> + implements _$$IncomingImplCopyWith<$Res> { + __$$IncomingImplCopyWithImpl( + _$IncomingImpl _value, $Res Function(_$IncomingImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? from = null, + Object? transfers = null, + }) { + return _then(_$IncomingImpl( + from: null == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as String, + transfers: null == transfers + ? _value._transfers + : transfers // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$IncomingImpl implements _Incoming { + const _$IncomingImpl( + {@JsonKey(name: 'from') required this.from, + @JsonKey(name: 'transfers') required final List transfers}) + : _transfers = transfers; + + factory _$IncomingImpl.fromJson(Map json) => + _$$IncomingImplFromJson(json); + + @override + @JsonKey(name: 'from') + final String from; + final List _transfers; + + @override + @JsonKey(name: 'transfers') + List get transfers { + if (_transfers is EqualUnmodifiableListView) return _transfers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_transfers); + } + + @override + String toString() { + return 'Incoming(from: $from, transfers: $transfers)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$IncomingImpl && + (identical(other.from, from) || other.from == from) && + const DeepCollectionEquality() + .equals(other._transfers, _transfers)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, from, const DeepCollectionEquality().hash(_transfers)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$IncomingImplCopyWith<_$IncomingImpl> get copyWith => + __$$IncomingImplCopyWithImpl<_$IncomingImpl>(this, _$identity); + + @override + Map toJson() { + return _$$IncomingImplToJson( + this, + ); + } +} + +abstract class _Incoming implements Incoming { + const factory _Incoming( + {@JsonKey(name: 'from') required final String from, + @JsonKey(name: 'transfers') + required final List transfers}) = _$IncomingImpl; + + factory _Incoming.fromJson(Map json) = + _$IncomingImpl.fromJson; + + @override + @JsonKey(name: 'from') + String get from; + + @override + @JsonKey(name: 'transfers') + List get transfers; + + @override + @JsonKey(ignore: true) + _$$IncomingImplCopyWith<_$IncomingImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.g.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.g.dart new file mode 100644 index 0000000..db0b59a --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/incoming.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: package_api_docs, non_constant_identifier_names + +part of 'incoming.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$IncomingImpl _$$IncomingImplFromJson(Map json) => + _$IncomingImpl( + from: json['from'] as String, + transfers: (json['transfers'] as List) + .map((e) => TransferEntry.fromJson(e as Map)) + .toList(), + ); + +Map _$$IncomingImplToJson(_$IncomingImpl instance) => + { + 'from': instance.from, + 'transfers': instance.transfers, + }; diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.dart new file mode 100644 index 0000000..0dbdef5 --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.dart @@ -0,0 +1,18 @@ +// ignore_for_file: public_member_api_docs, invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:xelis_dart_sdk/xelis_dart_sdk.dart'; + +part 'outgoing.freezed.dart'; + +part 'outgoing.g.dart'; + +@freezed +class Outgoing with _$Outgoing { + const factory Outgoing({ + @JsonKey(name: 'transfers') required List transfers, + }) = _Outgoing; + + factory Outgoing.fromJson(Map json) => + _$OutgoingFromJson(json); +} diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.freezed.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.freezed.dart new file mode 100644 index 0000000..5a1436f --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.freezed.dart @@ -0,0 +1,171 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'outgoing.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +Outgoing _$OutgoingFromJson(Map json) { + return _Outgoing.fromJson(json); +} + +/// @nodoc +mixin _$Outgoing { + @JsonKey(name: 'transfers') + List get transfers => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $OutgoingCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $OutgoingCopyWith<$Res> { + factory $OutgoingCopyWith(Outgoing value, $Res Function(Outgoing) then) = + _$OutgoingCopyWithImpl<$Res, Outgoing>; + + @useResult + $Res call({@JsonKey(name: 'transfers') List transfers}); +} + +/// @nodoc +class _$OutgoingCopyWithImpl<$Res, $Val extends Outgoing> + implements $OutgoingCopyWith<$Res> { + _$OutgoingCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? transfers = null, + }) { + return _then(_value.copyWith( + transfers: null == transfers + ? _value.transfers + : transfers // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$OutgoingImplCopyWith<$Res> + implements $OutgoingCopyWith<$Res> { + factory _$$OutgoingImplCopyWith( + _$OutgoingImpl value, $Res Function(_$OutgoingImpl) then) = + __$$OutgoingImplCopyWithImpl<$Res>; + + @override + @useResult + $Res call({@JsonKey(name: 'transfers') List transfers}); +} + +/// @nodoc +class __$$OutgoingImplCopyWithImpl<$Res> + extends _$OutgoingCopyWithImpl<$Res, _$OutgoingImpl> + implements _$$OutgoingImplCopyWith<$Res> { + __$$OutgoingImplCopyWithImpl( + _$OutgoingImpl _value, $Res Function(_$OutgoingImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? transfers = null, + }) { + return _then(_$OutgoingImpl( + transfers: null == transfers + ? _value._transfers + : transfers // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$OutgoingImpl implements _Outgoing { + const _$OutgoingImpl( + {@JsonKey(name: 'transfers') + required final List transfers}) + : _transfers = transfers; + + factory _$OutgoingImpl.fromJson(Map json) => + _$$OutgoingImplFromJson(json); + + final List _transfers; + + @override + @JsonKey(name: 'transfers') + List get transfers { + if (_transfers is EqualUnmodifiableListView) return _transfers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_transfers); + } + + @override + String toString() { + return 'Outgoing(transfers: $transfers)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$OutgoingImpl && + const DeepCollectionEquality() + .equals(other._transfers, _transfers)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_transfers)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$OutgoingImplCopyWith<_$OutgoingImpl> get copyWith => + __$$OutgoingImplCopyWithImpl<_$OutgoingImpl>(this, _$identity); + + @override + Map toJson() { + return _$$OutgoingImplToJson( + this, + ); + } +} + +abstract class _Outgoing implements Outgoing { + const factory _Outgoing( + {@JsonKey(name: 'transfers') + required final List transfers}) = _$OutgoingImpl; + + factory _Outgoing.fromJson(Map json) = + _$OutgoingImpl.fromJson; + + @override + @JsonKey(name: 'transfers') + List get transfers; + + @override + @JsonKey(ignore: true) + _$$OutgoingImplCopyWith<_$OutgoingImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.g.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.g.dart new file mode 100644 index 0000000..9133ea1 --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/outgoing.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: package_api_docs, non_constant_identifier_names + +part of 'outgoing.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$OutgoingImpl _$$OutgoingImplFromJson(Map json) => + _$OutgoingImpl( + transfers: (json['transfers'] as List) + .map((e) => TransferEntry.fromJson(e as Map)) + .toList(), + ); + +Map _$$OutgoingImplToJson(_$OutgoingImpl instance) => + { + 'transfers': instance.transfers, + }; diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.dart new file mode 100644 index 0000000..a96e1e2 --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.dart @@ -0,0 +1,20 @@ +// ignore_for_file: public_member_api_docs, invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'tranfer_entry.freezed.dart'; + +part 'tranfer_entry.g.dart'; + +@freezed +class TransferEntry with _$TransferEntry { + const factory TransferEntry({ + @JsonKey(name: 'amount') required int amount, + @JsonKey(name: 'asset') required String asset, + @JsonKey(name: 'extra_data') required dynamic extraData, + @JsonKey(name: 'key') required String key, + }) = _TransferEntry; + + factory TransferEntry.fromJson(Map json) => + _$TransferEntryFromJson(json); +} diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.freezed.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.freezed.dart new file mode 100644 index 0000000..1cc881e --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.freezed.dart @@ -0,0 +1,239 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'tranfer_entry.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +TransferEntry _$TransferEntryFromJson(Map json) { + return _TransferEntry.fromJson(json); +} + +/// @nodoc +mixin _$TransferEntry { + @JsonKey(name: 'amount') + int get amount => throw _privateConstructorUsedError; + + @JsonKey(name: 'asset') + String get asset => throw _privateConstructorUsedError; + + @JsonKey(name: 'extra_data') + dynamic get extraData => throw _privateConstructorUsedError; + + @JsonKey(name: 'key') + String get key => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $TransferEntryCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TransferEntryCopyWith<$Res> { + factory $TransferEntryCopyWith( + TransferEntry value, $Res Function(TransferEntry) then) = + _$TransferEntryCopyWithImpl<$Res, TransferEntry>; + + @useResult + $Res call( + {@JsonKey(name: 'amount') int amount, + @JsonKey(name: 'asset') String asset, + @JsonKey(name: 'extra_data') dynamic extraData, + @JsonKey(name: 'key') String key}); +} + +/// @nodoc +class _$TransferEntryCopyWithImpl<$Res, $Val extends TransferEntry> + implements $TransferEntryCopyWith<$Res> { + _$TransferEntryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? amount = null, + Object? asset = null, + Object? extraData = freezed, + Object? key = null, + }) { + return _then(_value.copyWith( + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + asset: null == asset + ? _value.asset + : asset // ignore: cast_nullable_to_non_nullable + as String, + extraData: freezed == extraData + ? _value.extraData + : extraData // ignore: cast_nullable_to_non_nullable + as dynamic, + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$TransferEntryImplCopyWith<$Res> + implements $TransferEntryCopyWith<$Res> { + factory _$$TransferEntryImplCopyWith( + _$TransferEntryImpl value, $Res Function(_$TransferEntryImpl) then) = + __$$TransferEntryImplCopyWithImpl<$Res>; + + @override + @useResult + $Res call( + {@JsonKey(name: 'amount') int amount, + @JsonKey(name: 'asset') String asset, + @JsonKey(name: 'extra_data') dynamic extraData, + @JsonKey(name: 'key') String key}); +} + +/// @nodoc +class __$$TransferEntryImplCopyWithImpl<$Res> + extends _$TransferEntryCopyWithImpl<$Res, _$TransferEntryImpl> + implements _$$TransferEntryImplCopyWith<$Res> { + __$$TransferEntryImplCopyWithImpl( + _$TransferEntryImpl _value, $Res Function(_$TransferEntryImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? amount = null, + Object? asset = null, + Object? extraData = freezed, + Object? key = null, + }) { + return _then(_$TransferEntryImpl( + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + asset: null == asset + ? _value.asset + : asset // ignore: cast_nullable_to_non_nullable + as String, + extraData: freezed == extraData + ? _value.extraData + : extraData // ignore: cast_nullable_to_non_nullable + as dynamic, + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$TransferEntryImpl implements _TransferEntry { + const _$TransferEntryImpl( + {@JsonKey(name: 'amount') required this.amount, + @JsonKey(name: 'asset') required this.asset, + @JsonKey(name: 'extra_data') required this.extraData, + @JsonKey(name: 'key') required this.key}); + + factory _$TransferEntryImpl.fromJson(Map json) => + _$$TransferEntryImplFromJson(json); + + @override + @JsonKey(name: 'amount') + final int amount; + @override + @JsonKey(name: 'asset') + final String asset; + @override + @JsonKey(name: 'extra_data') + final dynamic extraData; + @override + @JsonKey(name: 'key') + final String key; + + @override + String toString() { + return 'TransferEntry(amount: $amount, asset: $asset, extraData: $extraData, key: $key)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$TransferEntryImpl && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.asset, asset) || other.asset == asset) && + const DeepCollectionEquality().equals(other.extraData, extraData) && + (identical(other.key, key) || other.key == key)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, amount, asset, + const DeepCollectionEquality().hash(extraData), key); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$TransferEntryImplCopyWith<_$TransferEntryImpl> get copyWith => + __$$TransferEntryImplCopyWithImpl<_$TransferEntryImpl>(this, _$identity); + + @override + Map toJson() { + return _$$TransferEntryImplToJson( + this, + ); + } +} + +abstract class _TransferEntry implements TransferEntry { + const factory _TransferEntry( + {@JsonKey(name: 'amount') required final int amount, + @JsonKey(name: 'asset') required final String asset, + @JsonKey(name: 'extra_data') required final dynamic extraData, + @JsonKey(name: 'key') required final String key}) = _$TransferEntryImpl; + + factory _TransferEntry.fromJson(Map json) = + _$TransferEntryImpl.fromJson; + + @override + @JsonKey(name: 'amount') + int get amount; + + @override + @JsonKey(name: 'asset') + String get asset; + + @override + @JsonKey(name: 'extra_data') + dynamic get extraData; + + @override + @JsonKey(name: 'key') + String get key; + + @override + @JsonKey(ignore: true) + _$$TransferEntryImplCopyWith<_$TransferEntryImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.g.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.g.dart new file mode 100644 index 0000000..46a3ea4 --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/tranfer_entry.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: package_api_docs, non_constant_identifier_names + +part of 'tranfer_entry.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$TransferEntryImpl _$$TransferEntryImplFromJson(Map json) => + _$TransferEntryImpl( + amount: json['amount'] as int, + asset: json['asset'] as String, + extraData: json['extra_data'], + key: json['key'] as String, + ); + +Map _$$TransferEntryImplToJson(_$TransferEntryImpl instance) => + { + 'amount': instance.amount, + 'asset': instance.asset, + 'extra_data': instance.extraData, + 'key': instance.key, + }; diff --git a/lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.dart similarity index 76% rename from lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.dart rename to lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.dart index 3de3161..8723160 100644 --- a/lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.dart +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.dart @@ -9,13 +9,14 @@ part 'transaction_entry.g.dart'; @freezed class TransactionEntry with _$TransactionEntry { + @JsonSerializable(includeIfNull: false) const factory TransactionEntry({ @JsonKey(name: 'hash') required String hash, @JsonKey(name: 'topoheight') required int topoHeight, - @JsonKey(name: 'transfers') List? transfers, + @JsonKey(name: 'coinbase') Coinbase? coinbase, @JsonKey(name: 'burn') Burn? burn, - @JsonKey(name: 'call_contract') CallContract? callContract, - @JsonKey(name: 'deploy_contract') String? deployContract, + @JsonKey(name: 'outgoing') Outgoing? outgoingTransfers, + @JsonKey(name: 'incoming') Incoming? incomingTransfers, @JsonKey(name: 'fee') int? fee, @JsonKey(name: 'nonce') int? nonce, }) = _TransactionEntry; diff --git a/lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.freezed.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.freezed.dart similarity index 65% rename from lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.freezed.dart rename to lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.freezed.dart index 405a173..31bd276 100644 --- a/lib/src/data_transfer_objects/wallet/list_transactions/transaction_entry.freezed.dart +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.freezed.dart @@ -22,22 +22,30 @@ TransactionEntry _$TransactionEntryFromJson(Map json) { mixin _$TransactionEntry { @JsonKey(name: 'hash') String get hash => throw _privateConstructorUsedError; + @JsonKey(name: 'topoheight') int get topoHeight => throw _privateConstructorUsedError; - @JsonKey(name: 'transfers') - List? get transfers => throw _privateConstructorUsedError; + + @JsonKey(name: 'coinbase') + Coinbase? get coinbase => throw _privateConstructorUsedError; + @JsonKey(name: 'burn') Burn? get burn => throw _privateConstructorUsedError; - @JsonKey(name: 'call_contract') - CallContract? get callContract => throw _privateConstructorUsedError; - @JsonKey(name: 'deploy_contract') - String? get deployContract => throw _privateConstructorUsedError; + + @JsonKey(name: 'outgoing') + Outgoing? get outgoingTransfers => throw _privateConstructorUsedError; + + @JsonKey(name: 'incoming') + Incoming? get incomingTransfers => throw _privateConstructorUsedError; + @JsonKey(name: 'fee') int? get fee => throw _privateConstructorUsedError; + @JsonKey(name: 'nonce') int? get nonce => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) $TransactionEntryCopyWith get copyWith => throw _privateConstructorUsedError; @@ -52,15 +60,20 @@ abstract class $TransactionEntryCopyWith<$Res> { $Res call( {@JsonKey(name: 'hash') String hash, @JsonKey(name: 'topoheight') int topoHeight, - @JsonKey(name: 'transfers') List? transfers, + @JsonKey(name: 'coinbase') Coinbase? coinbase, @JsonKey(name: 'burn') Burn? burn, - @JsonKey(name: 'call_contract') CallContract? callContract, - @JsonKey(name: 'deploy_contract') String? deployContract, + @JsonKey(name: 'outgoing') Outgoing? outgoingTransfers, + @JsonKey(name: 'incoming') Incoming? incomingTransfers, @JsonKey(name: 'fee') int? fee, @JsonKey(name: 'nonce') int? nonce}); + $CoinbaseCopyWith<$Res>? get coinbase; + $BurnCopyWith<$Res>? get burn; - $CallContractCopyWith<$Res>? get callContract; + + $OutgoingCopyWith<$Res>? get outgoingTransfers; + + $IncomingCopyWith<$Res>? get incomingTransfers; } /// @nodoc @@ -78,10 +91,10 @@ class _$TransactionEntryCopyWithImpl<$Res, $Val extends TransactionEntry> $Res call({ Object? hash = null, Object? topoHeight = null, - Object? transfers = freezed, + Object? coinbase = freezed, Object? burn = freezed, - Object? callContract = freezed, - Object? deployContract = freezed, + Object? outgoingTransfers = freezed, + Object? incomingTransfers = freezed, Object? fee = freezed, Object? nonce = freezed, }) { @@ -94,22 +107,22 @@ class _$TransactionEntryCopyWithImpl<$Res, $Val extends TransactionEntry> ? _value.topoHeight : topoHeight // ignore: cast_nullable_to_non_nullable as int, - transfers: freezed == transfers - ? _value.transfers - : transfers // ignore: cast_nullable_to_non_nullable - as List?, + coinbase: freezed == coinbase + ? _value.coinbase + : coinbase // ignore: cast_nullable_to_non_nullable + as Coinbase?, burn: freezed == burn ? _value.burn : burn // ignore: cast_nullable_to_non_nullable as Burn?, - callContract: freezed == callContract - ? _value.callContract - : callContract // ignore: cast_nullable_to_non_nullable - as CallContract?, - deployContract: freezed == deployContract - ? _value.deployContract - : deployContract // ignore: cast_nullable_to_non_nullable - as String?, + outgoingTransfers: freezed == outgoingTransfers + ? _value.outgoingTransfers + : outgoingTransfers // ignore: cast_nullable_to_non_nullable + as Outgoing?, + incomingTransfers: freezed == incomingTransfers + ? _value.incomingTransfers + : incomingTransfers // ignore: cast_nullable_to_non_nullable + as Incoming?, fee: freezed == fee ? _value.fee : fee // ignore: cast_nullable_to_non_nullable @@ -121,6 +134,18 @@ class _$TransactionEntryCopyWithImpl<$Res, $Val extends TransactionEntry> ) as $Val); } + @override + @pragma('vm:prefer-inline') + $CoinbaseCopyWith<$Res>? get coinbase { + if (_value.coinbase == null) { + return null; + } + + return $CoinbaseCopyWith<$Res>(_value.coinbase!, (value) { + return _then(_value.copyWith(coinbase: value) as $Val); + }); + } + @override @pragma('vm:prefer-inline') $BurnCopyWith<$Res>? get burn { @@ -135,13 +160,25 @@ class _$TransactionEntryCopyWithImpl<$Res, $Val extends TransactionEntry> @override @pragma('vm:prefer-inline') - $CallContractCopyWith<$Res>? get callContract { - if (_value.callContract == null) { + $OutgoingCopyWith<$Res>? get outgoingTransfers { + if (_value.outgoingTransfers == null) { + return null; + } + + return $OutgoingCopyWith<$Res>(_value.outgoingTransfers!, (value) { + return _then(_value.copyWith(outgoingTransfers: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $IncomingCopyWith<$Res>? get incomingTransfers { + if (_value.incomingTransfers == null) { return null; } - return $CallContractCopyWith<$Res>(_value.callContract!, (value) { - return _then(_value.copyWith(callContract: value) as $Val); + return $IncomingCopyWith<$Res>(_value.incomingTransfers!, (value) { + return _then(_value.copyWith(incomingTransfers: value) as $Val); }); } } @@ -157,17 +194,24 @@ abstract class _$$TransactionEntryImplCopyWith<$Res> $Res call( {@JsonKey(name: 'hash') String hash, @JsonKey(name: 'topoheight') int topoHeight, - @JsonKey(name: 'transfers') List? transfers, + @JsonKey(name: 'coinbase') Coinbase? coinbase, @JsonKey(name: 'burn') Burn? burn, - @JsonKey(name: 'call_contract') CallContract? callContract, - @JsonKey(name: 'deploy_contract') String? deployContract, + @JsonKey(name: 'outgoing') Outgoing? outgoingTransfers, + @JsonKey(name: 'incoming') Incoming? incomingTransfers, @JsonKey(name: 'fee') int? fee, @JsonKey(name: 'nonce') int? nonce}); + @override + $CoinbaseCopyWith<$Res>? get coinbase; + @override $BurnCopyWith<$Res>? get burn; + + @override + $OutgoingCopyWith<$Res>? get outgoingTransfers; + @override - $CallContractCopyWith<$Res>? get callContract; + $IncomingCopyWith<$Res>? get incomingTransfers; } /// @nodoc @@ -183,10 +227,10 @@ class __$$TransactionEntryImplCopyWithImpl<$Res> $Res call({ Object? hash = null, Object? topoHeight = null, - Object? transfers = freezed, + Object? coinbase = freezed, Object? burn = freezed, - Object? callContract = freezed, - Object? deployContract = freezed, + Object? outgoingTransfers = freezed, + Object? incomingTransfers = freezed, Object? fee = freezed, Object? nonce = freezed, }) { @@ -199,22 +243,22 @@ class __$$TransactionEntryImplCopyWithImpl<$Res> ? _value.topoHeight : topoHeight // ignore: cast_nullable_to_non_nullable as int, - transfers: freezed == transfers - ? _value._transfers - : transfers // ignore: cast_nullable_to_non_nullable - as List?, + coinbase: freezed == coinbase + ? _value.coinbase + : coinbase // ignore: cast_nullable_to_non_nullable + as Coinbase?, burn: freezed == burn ? _value.burn : burn // ignore: cast_nullable_to_non_nullable as Burn?, - callContract: freezed == callContract - ? _value.callContract - : callContract // ignore: cast_nullable_to_non_nullable - as CallContract?, - deployContract: freezed == deployContract - ? _value.deployContract - : deployContract // ignore: cast_nullable_to_non_nullable - as String?, + outgoingTransfers: freezed == outgoingTransfers + ? _value.outgoingTransfers + : outgoingTransfers // ignore: cast_nullable_to_non_nullable + as Outgoing?, + incomingTransfers: freezed == incomingTransfers + ? _value.incomingTransfers + : incomingTransfers // ignore: cast_nullable_to_non_nullable + as Incoming?, fee: freezed == fee ? _value.fee : fee // ignore: cast_nullable_to_non_nullable @@ -228,18 +272,18 @@ class __$$TransactionEntryImplCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$TransactionEntryImpl implements _TransactionEntry { const _$TransactionEntryImpl( {@JsonKey(name: 'hash') required this.hash, @JsonKey(name: 'topoheight') required this.topoHeight, - @JsonKey(name: 'transfers') final List? transfers, + @JsonKey(name: 'coinbase') this.coinbase, @JsonKey(name: 'burn') this.burn, - @JsonKey(name: 'call_contract') this.callContract, - @JsonKey(name: 'deploy_contract') this.deployContract, + @JsonKey(name: 'outgoing') this.outgoingTransfers, + @JsonKey(name: 'incoming') this.incomingTransfers, @JsonKey(name: 'fee') this.fee, - @JsonKey(name: 'nonce') this.nonce}) - : _transfers = transfers; + @JsonKey(name: 'nonce') this.nonce}); factory _$TransactionEntryImpl.fromJson(Map json) => _$$TransactionEntryImplFromJson(json); @@ -250,26 +294,18 @@ class _$TransactionEntryImpl implements _TransactionEntry { @override @JsonKey(name: 'topoheight') final int topoHeight; - final List? _transfers; - @override - @JsonKey(name: 'transfers') - List? get transfers { - final value = _transfers; - if (value == null) return null; - if (_transfers is EqualUnmodifiableListView) return _transfers; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); - } - + @override + @JsonKey(name: 'coinbase') + final Coinbase? coinbase; @override @JsonKey(name: 'burn') final Burn? burn; @override - @JsonKey(name: 'call_contract') - final CallContract? callContract; + @JsonKey(name: 'outgoing') + final Outgoing? outgoingTransfers; @override - @JsonKey(name: 'deploy_contract') - final String? deployContract; + @JsonKey(name: 'incoming') + final Incoming? incomingTransfers; @override @JsonKey(name: 'fee') final int? fee; @@ -279,7 +315,7 @@ class _$TransactionEntryImpl implements _TransactionEntry { @override String toString() { - return 'TransactionEntry(hash: $hash, topoHeight: $topoHeight, transfers: $transfers, burn: $burn, callContract: $callContract, deployContract: $deployContract, fee: $fee, nonce: $nonce)'; + return 'TransactionEntry(hash: $hash, topoHeight: $topoHeight, coinbase: $coinbase, burn: $burn, outgoingTransfers: $outgoingTransfers, incomingTransfers: $incomingTransfers, fee: $fee, nonce: $nonce)'; } @override @@ -290,29 +326,21 @@ class _$TransactionEntryImpl implements _TransactionEntry { (identical(other.hash, hash) || other.hash == hash) && (identical(other.topoHeight, topoHeight) || other.topoHeight == topoHeight) && - const DeepCollectionEquality() - .equals(other._transfers, _transfers) && + (identical(other.coinbase, coinbase) || + other.coinbase == coinbase) && (identical(other.burn, burn) || other.burn == burn) && - (identical(other.callContract, callContract) || - other.callContract == callContract) && - (identical(other.deployContract, deployContract) || - other.deployContract == deployContract) && + (identical(other.outgoingTransfers, outgoingTransfers) || + other.outgoingTransfers == outgoingTransfers) && + (identical(other.incomingTransfers, incomingTransfers) || + other.incomingTransfers == incomingTransfers) && (identical(other.fee, fee) || other.fee == fee) && (identical(other.nonce, nonce) || other.nonce == nonce)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, - hash, - topoHeight, - const DeepCollectionEquality().hash(_transfers), - burn, - callContract, - deployContract, - fee, - nonce); + int get hashCode => Object.hash(runtimeType, hash, topoHeight, coinbase, burn, + outgoingTransfers, incomingTransfers, fee, nonce); @JsonKey(ignore: true) @override @@ -333,10 +361,10 @@ abstract class _TransactionEntry implements TransactionEntry { const factory _TransactionEntry( {@JsonKey(name: 'hash') required final String hash, @JsonKey(name: 'topoheight') required final int topoHeight, - @JsonKey(name: 'transfers') final List? transfers, + @JsonKey(name: 'coinbase') final Coinbase? coinbase, @JsonKey(name: 'burn') final Burn? burn, - @JsonKey(name: 'call_contract') final CallContract? callContract, - @JsonKey(name: 'deploy_contract') final String? deployContract, + @JsonKey(name: 'outgoing') final Outgoing? outgoingTransfers, + @JsonKey(name: 'incoming') final Incoming? incomingTransfers, @JsonKey(name: 'fee') final int? fee, @JsonKey(name: 'nonce') final int? nonce}) = _$TransactionEntryImpl; @@ -346,21 +374,27 @@ abstract class _TransactionEntry implements TransactionEntry { @override @JsonKey(name: 'hash') String get hash; + @override @JsonKey(name: 'topoheight') int get topoHeight; + @override - @JsonKey(name: 'transfers') - List? get transfers; + @JsonKey(name: 'coinbase') + Coinbase? get coinbase; + @override @JsonKey(name: 'burn') Burn? get burn; + @override - @JsonKey(name: 'call_contract') - CallContract? get callContract; + @JsonKey(name: 'outgoing') + Outgoing? get outgoingTransfers; + @override - @JsonKey(name: 'deploy_contract') - String? get deployContract; + @JsonKey(name: 'incoming') + Incoming? get incomingTransfers; + @override @JsonKey(name: 'fee') int? get fee; diff --git a/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.g.dart b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.g.dart new file mode 100644 index 0000000..e4573fa --- /dev/null +++ b/lib/src/data_transfer_objects/wallet/transaction_entry/transaction_entry.g.dart @@ -0,0 +1,52 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: package_api_docs, non_constant_identifier_names + +part of 'transaction_entry.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$TransactionEntryImpl _$$TransactionEntryImplFromJson( + Map json) => + _$TransactionEntryImpl( + hash: json['hash'] as String, + topoHeight: json['topoheight'] as int, + coinbase: json['coinbase'] == null + ? null + : Coinbase.fromJson(json['coinbase'] as Map), + burn: json['burn'] == null + ? null + : Burn.fromJson(json['burn'] as Map), + outgoingTransfers: json['outgoing'] == null + ? null + : Outgoing.fromJson(json['outgoing'] as Map), + incomingTransfers: json['incoming'] == null + ? null + : Incoming.fromJson(json['incoming'] as Map), + fee: json['fee'] as int?, + nonce: json['nonce'] as int?, + ); + +Map _$$TransactionEntryImplToJson( + _$TransactionEntryImpl instance) { + final val = { + 'hash': instance.hash, + 'topoheight': instance.topoHeight, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('coinbase', instance.coinbase); + writeNotNull('burn', instance.burn); + writeNotNull('outgoing', instance.outgoingTransfers); + writeNotNull('incoming', instance.incomingTransfers); + writeNotNull('fee', instance.fee); + writeNotNull('nonce', instance.nonce); + return val; +} diff --git a/lib/src/repositories/daemon/daemon_client.dart b/lib/src/repositories/daemon/daemon_client.dart index 2b305c1..0992b87 100644 --- a/lib/src/repositories/daemon/daemon_client.dart +++ b/lib/src/repositories/daemon/daemon_client.dart @@ -18,7 +18,7 @@ class DaemonClient extends RpcClientRepository { DaemonEvent.stableHeightChanged: [], DaemonEvent.transactionAddedInMempool: - [], + [], DaemonEvent.transactionExecuted: [], // TODO: define rawTransactionSCResult type @@ -37,6 +37,14 @@ class DaemonClient extends RpcClientRepository { }; } + @override + WebSocket _initWebSocket() { + return WebSocket( + _uri, + timeout: Duration(milliseconds: _channelTimeout), + ); + } + @override void _handleEvent(String eventJsonKey, Map result) { final event = DaemonEvent.fromStr(eventJsonKey); @@ -54,7 +62,7 @@ class DaemonClient extends RpcClientRepository { _logInfo('Stable height changed: $stableHeightChanged'); _triggerCallbacks(event, stableHeightChanged); case DaemonEvent.transactionAddedInMempool: - final transaction = Transaction.fromJson(result); + final transaction = TransactionResponse.fromJson(result); _logInfo('Transaction added in mempool: $transaction'); _triggerCallbacks(event, transaction); case DaemonEvent.transactionExecuted: diff --git a/lib/src/repositories/daemon/daemon_events_extension.dart b/lib/src/repositories/daemon/daemon_events_extension.dart index dfae435..53634b2 100644 --- a/lib/src/repositories/daemon/daemon_events_extension.dart +++ b/lib/src/repositories/daemon/daemon_events_extension.dart @@ -47,7 +47,7 @@ extension DaemonEventsExtension on DaemonClient { /// /// Note: It is called when a transaction is added to the mempool. void onTransactionAddedInMempool( - void Function(Transaction transaction) callback, + void Function(TransactionResponse transactionResponse) callback, ) => onEvent(DaemonEvent.transactionAddedInMempool, callback); diff --git a/lib/src/repositories/daemon/daemon_rpc_methods_extension.dart b/lib/src/repositories/daemon/daemon_rpc_methods_extension.dart index f6626fc..36a4eff 100644 --- a/lib/src/repositories/daemon/daemon_rpc_methods_extension.dart +++ b/lib/src/repositories/daemon/daemon_rpc_methods_extension.dart @@ -215,27 +215,29 @@ extension DaemonRpcMethodsExtension on DaemonClient { /// /// NOTE: result returned in data field can changes based on /// the TransactionType (transfer, burn, Smart Contract call, Deploy Code...). - Future getTransaction( + Future getTransaction( GetTransactionParams getTransactionParams, ) async { final result = await sendRequest( DaemonMethod.getTransaction, getTransactionParams.toJson(), ); - return Transaction.fromJson(result as Map); + return TransactionResponse.fromJson(result as Map); } /// Fetch all transactions presents in the mempool. - Future getMempool() async { + Future> getMempool() async { final result = await sendRequest( DaemonMethod.getMempool, ); - return Transaction.fromJson(result as Map); + return (result as List) + .map((e) => TransactionResponse.fromJson(e as Map)) + .toList(); } /// Fetch transactions by theirs hashes from daemon and keep /// the same order in response. - Future> getTransactions( + Future> getTransactions( GetTransactionsParams getTransactionsParams, ) async { final result = await sendRequest( @@ -243,7 +245,7 @@ extension DaemonRpcMethodsExtension on DaemonClient { getTransactionsParams.toJson(), ); return (result as List) - .map((e) => Transaction.fromJson(e as Map)) + .map((e) => TransactionResponse.fromJson(e as Map)) .toList(); } diff --git a/lib/src/repositories/rpc_client_repository.dart b/lib/src/repositories/rpc_client_repository.dart index b4d25b2..775aca0 100644 --- a/lib/src/repositories/rpc_client_repository.dart +++ b/lib/src/repositories/rpc_client_repository.dart @@ -76,14 +76,16 @@ sealed class RpcClientRepository { } } - /// Initialize the websocket to communicate with daemon and start listening. + /// Initialize the websocket for specific target. + /// + /// Note: must be implemented. + WebSocket _initWebSocket(); + + /// Initialize the websocket to communicate with RPC server and start listening. /// /// Note: It has to be called first. void connect() { - socket = WebSocket( - _uri, - timeout: Duration(milliseconds: _channelTimeout), - ); + socket = _initWebSocket(); socket?.connection.listen( (state) { @@ -253,25 +255,25 @@ sealed class RpcClientRepository { } /// Manages the event response. + /// + /// Note: must be implemented. void _handleEvent(String eventJsonKey, Map result); // Calls all callbacks for a given connection state. void _onConnOpen() { - _logInfo('successfully connected to xelis daemon'); // ignore: avoid_dynamic_calls _stateChangeCallbacks['open']!.map((callback) => callback()); } // Calls all callbacks for a given connection state. void _onConnClose() { - _logInfo('connection to xelis daemon closed'); // ignore: avoid_dynamic_calls _stateChangeCallbacks['close']!.map((callback) => callback()); } // Calls all callbacks for a given connection state. void _onConnError(dynamic error) { - _logInfo('error connecting to xelis daemon: $error'); + _logInfo('error connecting to Xelis: $error'); // ignore: avoid_dynamic_calls _stateChangeCallbacks['error']!.map((callback) => callback()); } diff --git a/lib/src/repositories/wallet/wallet_client.dart b/lib/src/repositories/wallet/wallet_client.dart index e8d61fc..52b09e2 100644 --- a/lib/src/repositories/wallet/wallet_client.dart +++ b/lib/src/repositories/wallet/wallet_client.dart @@ -1,54 +1,87 @@ part of '../rpc_client_repository.dart'; -/// JSON-RPC Client to interact with Xelis daemon. +/// JSON-RPC Client to interact with Xelis wallet. class WalletClient extends RpcClientRepository { /// [WalletClient] constructor /// /// Note: Secure WebSocket is enabled by default. WalletClient({ required super.endPoint, + required String username, + required String password, super.secureWebSocket, super.timeout, super.logger, }) { eventsCallbacks = { - WalletEvent.newChainInfo: [], + WalletEvent.newTopoHeight: [], WalletEvent.newAsset: [], WalletEvent.newTransaction: [], WalletEvent.balanceChanged: - [], + [], + WalletEvent.rescan: [], + WalletEvent.online: [], + WalletEvent.offline: [], }; + + _basicAuth = stringToBase64('$username:$password'); + } + + late final String _basicAuth; + + @override + WebSocket _initWebSocket() { + return WebSocket( + _uri, + timeout: Duration(milliseconds: _channelTimeout), + headers: {'Authorization': 'Basic $_basicAuth'}, + ); } @override void _handleEvent(String eventJsonKey, Map result) { final event = WalletEvent.fromStr(eventJsonKey); switch (event) { - case WalletEvent.newChainInfo: - final newChainInfo = GetInfoResult.fromJson(result); - _logInfo('New chain info: $newChainInfo'); - _triggerCallbacks(event, newChainInfo); + case WalletEvent.newTopoHeight: + final topoheight = result['topoheight']; + _logInfo('New topoheight event: $topoheight'); + _triggerCallbacks(event, topoheight); case WalletEvent.newAsset: final assetWithData = AssetWithData.fromJson(result); - _logInfo('New asset: $assetWithData'); + _logInfo('New asset event: $assetWithData'); _triggerCallbacks(event, assetWithData); case WalletEvent.newTransaction: final transactionEntry = TransactionEntry.fromJson(result); _logInfo('New transaction entry: $transactionEntry'); _triggerCallbacks(event, transactionEntry); case WalletEvent.balanceChanged: - final balanceChanged = BalanceChanged.fromJson(result); + final balanceChanged = BalanceChangedEvent.fromJson(result); _logInfo('Balance changed: $balanceChanged'); _triggerCallbacks(event, balanceChanged); + case WalletEvent.rescan: + final topoheight = result['start_topoheight']; + _logInfo('Rescan event: $topoheight'); + _triggerCallbacks(event, topoheight); + case WalletEvent.online: + _logInfo('Online event'); + _triggerCallbacks(event, null); + case WalletEvent.offline: + _logInfo('Offline event'); + _triggerCallbacks(event, null); } } /// Triggers callbacks for a specific event. void _triggerCallbacks(XelisJsonKey event, dynamic parameter) { for (final callback in eventsCallbacks[event]!) { - // ignore: avoid_dynamic_calls - callback(parameter); + if (parameter != null) { + // ignore: avoid_dynamic_calls + callback(parameter); + } else { + // ignore: avoid_dynamic_calls + callback(); + } } } } diff --git a/lib/src/repositories/wallet/wallet_constants.dart b/lib/src/repositories/wallet/wallet_constants.dart index 4d13a44..85fa35b 100644 --- a/lib/src/repositories/wallet/wallet_constants.dart +++ b/lib/src/repositories/wallet/wallet_constants.dart @@ -88,19 +88,29 @@ enum WalletMethod implements XelisJsonKey { enum WalletEvent implements XelisJsonKey { /// When a a get_info request is made /// and we receive a different topoheight than previous one - newChainInfo('NewChainInfo'), + newTopoHeight('new_chain_info'), /// When a new asset is added to wallet /// Contains a Hash as value - newAsset('NewAsset'), + newAsset('new_asset'), /// When a new transaction is added to wallet /// Contains TransactionEntry struct as value - newTransaction('NewTransaction'), + newTransaction('new_transaction'), /// When a balance is changed /// Contains a BalanceChanged as value - balanceChanged('BalanceChanged'); + balanceChanged('balance_changed'), + + /// When a rescan happened on the wallet. + /// Contains a topoheight as value to indicate until which topoheight transactions got deleted. + rescan('rescan'), + + /// When network state changed to Online. + online('online'), + + /// When network state changed to Offline. + offline('offline'); /// Creates a new [WalletEvent] instance. const WalletEvent(this.jsonKey); @@ -108,14 +118,20 @@ enum WalletEvent implements XelisJsonKey { /// Factory to convert a [String] to a [WalletEvent]. factory WalletEvent.fromStr(String value) { switch (value) { - case 'NewChainInfo': - return WalletEvent.newChainInfo; - case 'NewAsset': + case 'new_chain_info': + return WalletEvent.newTopoHeight; + case 'new_asset': return WalletEvent.newAsset; - case 'NewTransaction': + case 'new_transaction': return WalletEvent.newTransaction; - case 'BalanceChanged': + case 'balance_changed': return WalletEvent.balanceChanged; + case 'rescan': + return WalletEvent.rescan; + case 'online': + return WalletEvent.online; + case 'offline': + return WalletEvent.offline; default: throw Exception('Unknown event: $value'); } diff --git a/lib/src/repositories/wallet/wallet_events_extension.dart b/lib/src/repositories/wallet/wallet_events_extension.dart new file mode 100644 index 0000000..0ceb540 --- /dev/null +++ b/lib/src/repositories/wallet/wallet_events_extension.dart @@ -0,0 +1,93 @@ +import 'dart:async'; + +import 'package:xelis_dart_sdk/src/data_transfer_objects/dtos.dart'; +import 'package:xelis_dart_sdk/src/repositories/rpc_client_repository.dart'; +import 'package:xelis_dart_sdk/src/repositories/wallet/wallet_constants.dart'; + +/// Extension of [WalletClient] that provides methods to +/// subscribe/unsubscribe to wallet events. +extension WalletEventsExtension on WalletClient { + /// Registers a callback for NewTopoHeight event. + void onNewTopoHeight(void Function(int topoheight) callback) => + onEvent(WalletEvent.newTopoHeight, callback); + + /// Unsubscribes from NewTopoHeight event. + void unsubscribeFromNewTopoHeight() { + unawaited(unsubscribeFrom(WalletEvent.newTopoHeight)); + } + + /// Registers a callback for NewAsset event. + void onNewAsset(void Function(AssetWithData assetWithData) callback) => + onEvent(WalletEvent.newAsset, callback); + + /// Unsubscribes from NewAsset event. + void unsubscribeFromNewAsset() { + unawaited(unsubscribeFrom(WalletEvent.newAsset)); + } + + /// Registers a callback for NewTransaction event. + void onNewTransaction( + void Function(TransactionEntry transactionEntry) callback, + ) => + onEvent(WalletEvent.newTransaction, callback); + + /// Unsubscribes from NewTransaction event. + void unsubscribeFromNewTransaction() { + unawaited(unsubscribeFrom(WalletEvent.newTransaction)); + } + + /// Registers a callback for BalanceChanged event. + void onBalanceChanged( + void Function(BalanceChangedEvent balanceChangedEvent) callback, + ) => + onEvent(WalletEvent.balanceChanged, callback); + + /// Unsubscribes from BalanceChanged event. + void unsubscribeFromBalanceChanged() { + unawaited(unsubscribeFrom(WalletEvent.balanceChanged)); + } + + /// Registers a callback for Rescan event. + void onRescan( + void Function(int topoheight) callback, + ) => + onEvent(WalletEvent.rescan, callback); + + /// Unsubscribes from Rescan event. + void unsubscribeFromRescan() { + unawaited(unsubscribeFrom(WalletEvent.rescan)); + } + + /// Registers a callback for Online event. + void onOnline( + void Function() callback, + ) => + onEvent(WalletEvent.online, callback); + + /// Unsubscribes from Online event. + void unsubscribeFromOnline() { + unawaited(unsubscribeFrom(WalletEvent.online)); + } + + /// Registers a callback for Offline event. + void onOffline( + void Function() callback, + ) => + onEvent(WalletEvent.offline, callback); + + /// Unsubscribes from Offline event. + void unsubscribeFromOffline() { + unawaited(unsubscribeFrom(WalletEvent.offline)); + } + + /// Unsubscribes from all events. + void unsubscribeFromAll() { + unsubscribeFromNewTopoHeight(); + unsubscribeFromNewAsset(); + unsubscribeFromNewTransaction(); + unsubscribeFromBalanceChanged(); + unsubscribeFromRescan(); + unsubscribeFromOnline(); + unsubscribeFromOffline(); + } +} diff --git a/lib/src/repositories/wallet/wallet_rpc_methods_extension.dart b/lib/src/repositories/wallet/wallet_rpc_methods_extension.dart index 9adc024..c185eb7 100644 --- a/lib/src/repositories/wallet/wallet_rpc_methods_extension.dart +++ b/lib/src/repositories/wallet/wallet_rpc_methods_extension.dart @@ -86,14 +86,14 @@ extension WalletRpcMethodsExtension on WalletClient { } /// Gets transaction by hash from wallet. - Future getTransaction( + Future getTransaction( GetTransactionParams getTransactionParams, ) async { final result = await sendRequest( WalletMethod.getTransaction, getTransactionParams.toJson(), ); - return Transaction.fromJson(result as Map); + return TransactionEntry.fromJson(result as Map); } /// Builds a transaction to be send by the wallet. @@ -101,24 +101,25 @@ extension WalletRpcMethodsExtension on WalletClient { /// /// NOTE: Amount set are in atomic units, for XELIS it would 100000 to /// represents 1 XELIS because of 5 decimals precision. - Future buildTransaction( + Future buildTransaction( BuildTransactionParams buildTransactionParams, ) async { final result = await sendRequest( WalletMethod.buildTransaction, buildTransactionParams.toJson(), ); - return Transaction.fromJson(result as Map); + return TransactionResponse.fromJson(result as Map); } /// Search for transactions based on various parameters. /// By default it accepts every TXs. - Future> listTransactions( - ListTransactionsParams listTransactionsParams, - ) async { + Future> listTransactions([ + ListTransactionsParams? listTransactionsParams, + ]) async { final result = await sendRequest( WalletMethod.listTransactions, - listTransactionsParams.toJson(), + listTransactionsParams?.toJson() ?? + const ListTransactionsParams().toJson(), ); return (result as List) diff --git a/lib/src/utils/data_converter.dart b/lib/src/utils/data_converter.dart index c9f0961..39381fd 100644 --- a/lib/src/utils/data_converter.dart +++ b/lib/src/utils/data_converter.dart @@ -33,6 +33,12 @@ String stringToHex(String input) { return hex.encode(bytes); } +/// Converts a character string into a base64 string. +String stringToBase64(String input) { + final bytes = utf8.encode(input); + return base64.encode(bytes); +} + /* final _jsonLiterals = RegExp( r'"(?:[^"\\]|\\.)*"|((?