Skip to content

Commit

Permalink
feat: ✨ Use fetch-api-service instead of coingecko
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Aug 9, 2024
1 parent 29d1774 commit 2629b2e
Show file tree
Hide file tree
Showing 14 changed files with 359 additions and 52 deletions.
3 changes: 3 additions & 0 deletions lib/archethic_dapp_framework_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ export 'src/domain/models/ae_token.dart';
export 'src/domain/models/ae_token_pair.dart';
export 'src/domain/models/crypto_price.dart';
export 'src/domain/models/failures.dart';
export 'src/domain/models/market_price_history.dart';
export 'src/domain/models/result.dart';
export 'src/domain/models/ucids_tokens.dart';
export 'src/domain/models/verified_tokens.dart';
export 'src/domain/repositories/coin_price_history.repository.dart';
export 'src/infrastructure/coin_price.repository.dart';
export 'src/infrastructure/coin_price_history.repository.dart';
export 'src/infrastructure/consent.respository.dart';
export 'src/infrastructure/def_tokens.repository.dart';
export 'src/infrastructure/ucids_tokens.repository.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/application/oracle/provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/src/domain/models/ae_token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AEToken with _$AEToken {
@Default('') String name,
String? address,
String? icon,
String? coingeckoCoinId,
@Default('') String symbol,
@Default(0.0) double balance,
@Default(0.0) double reserve,
Expand Down
39 changes: 3 additions & 36 deletions lib/src/domain/models/ae_token.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ mixin _$AEToken {
String get name => throw _privateConstructorUsedError;
String? get address => throw _privateConstructorUsedError;
String? get icon => throw _privateConstructorUsedError;
String? get coingeckoCoinId => throw _privateConstructorUsedError;
String get symbol => throw _privateConstructorUsedError;
double get balance => throw _privateConstructorUsedError;
double get reserve => throw _privateConstructorUsedError;
Expand All @@ -48,7 +47,6 @@ abstract class $AETokenCopyWith<$Res> {
{String name,
String? address,
String? icon,
String? coingeckoCoinId,
String symbol,
double balance,
double reserve,
Expand Down Expand Up @@ -77,7 +75,6 @@ class _$AETokenCopyWithImpl<$Res, $Val extends AEToken>
Object? name = null,
Object? address = freezed,
Object? icon = freezed,
Object? coingeckoCoinId = freezed,
Object? symbol = null,
Object? balance = null,
Object? reserve = null,
Expand All @@ -100,10 +97,6 @@ class _$AETokenCopyWithImpl<$Res, $Val extends AEToken>
? _value.icon
: icon // ignore: cast_nullable_to_non_nullable
as String?,
coingeckoCoinId: freezed == coingeckoCoinId
? _value.coingeckoCoinId
: coingeckoCoinId // ignore: cast_nullable_to_non_nullable
as String?,
symbol: null == symbol
? _value.symbol
: symbol // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -163,7 +156,6 @@ abstract class _$$AETokenImplCopyWith<$Res> implements $AETokenCopyWith<$Res> {
{String name,
String? address,
String? icon,
String? coingeckoCoinId,
String symbol,
double balance,
double reserve,
Expand Down Expand Up @@ -191,7 +183,6 @@ class __$$AETokenImplCopyWithImpl<$Res>
Object? name = null,
Object? address = freezed,
Object? icon = freezed,
Object? coingeckoCoinId = freezed,
Object? symbol = null,
Object? balance = null,
Object? reserve = null,
Expand All @@ -214,10 +205,6 @@ class __$$AETokenImplCopyWithImpl<$Res>
? _value.icon
: icon // ignore: cast_nullable_to_non_nullable
as String?,
coingeckoCoinId: freezed == coingeckoCoinId
? _value.coingeckoCoinId
: coingeckoCoinId // ignore: cast_nullable_to_non_nullable
as String?,
symbol: null == symbol
? _value.symbol
: symbol // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -261,7 +248,6 @@ class _$AETokenImpl extends _AEToken {
{this.name = '',
this.address,
this.icon,
this.coingeckoCoinId,
this.symbol = '',
this.balance = 0.0,
this.reserve = 0.0,
Expand All @@ -283,8 +269,6 @@ class _$AETokenImpl extends _AEToken {
@override
final String? icon;
@override
final String? coingeckoCoinId;
@override
@JsonKey()
final String symbol;
@override
Expand All @@ -310,7 +294,7 @@ class _$AETokenImpl extends _AEToken {

@override
String toString() {
return 'AEToken(name: $name, address: $address, icon: $icon, coingeckoCoinId: $coingeckoCoinId, symbol: $symbol, balance: $balance, reserve: $reserve, supply: $supply, isVerified: $isVerified, isLpToken: $isLpToken, lpTokenPair: $lpTokenPair, ucid: $ucid)';
return 'AEToken(name: $name, address: $address, icon: $icon, symbol: $symbol, balance: $balance, reserve: $reserve, supply: $supply, isVerified: $isVerified, isLpToken: $isLpToken, lpTokenPair: $lpTokenPair, ucid: $ucid)';
}

@override
Expand All @@ -321,8 +305,6 @@ class _$AETokenImpl extends _AEToken {
(identical(other.name, name) || other.name == name) &&
(identical(other.address, address) || other.address == address) &&
(identical(other.icon, icon) || other.icon == icon) &&
(identical(other.coingeckoCoinId, coingeckoCoinId) ||
other.coingeckoCoinId == coingeckoCoinId) &&
(identical(other.symbol, symbol) || other.symbol == symbol) &&
(identical(other.balance, balance) || other.balance == balance) &&
(identical(other.reserve, reserve) || other.reserve == reserve) &&
Expand All @@ -338,20 +320,8 @@ class _$AETokenImpl extends _AEToken {

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
name,
address,
icon,
coingeckoCoinId,
symbol,
balance,
reserve,
supply,
isVerified,
isLpToken,
lpTokenPair,
ucid);
int get hashCode => Object.hash(runtimeType, name, address, icon, symbol,
balance, reserve, supply, isVerified, isLpToken, lpTokenPair, ucid);

@JsonKey(ignore: true)
@override
Expand All @@ -372,7 +342,6 @@ abstract class _AEToken extends AEToken {
{final String name,
final String? address,
final String? icon,
final String? coingeckoCoinId,
final String symbol,
final double balance,
final double reserve,
Expand All @@ -392,8 +361,6 @@ abstract class _AEToken extends AEToken {
@override
String? get icon;
@override
String? get coingeckoCoinId;
@override
String get symbol;
@override
double get balance;
Expand Down
2 changes: 0 additions & 2 deletions lib/src/domain/models/ae_token.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions lib/src/domain/models/market_price_history.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'market_price_history.freezed.dart';
part 'market_price_history.g.dart';

enum MarketPriceHistoryInterval {
hour,
day,
week,
twoWeeks,
month,
twoMonths,
year,
}

class PriceHistoryValueConverter
implements JsonConverter<PriceHistoryValue, Map<String, dynamic>> {
const PriceHistoryValueConverter();

@override
PriceHistoryValue fromJson(Map<String, dynamic> json) {
return PriceHistoryValue.fromJson(json);
}

@override
Map<String, dynamic> toJson(PriceHistoryValue object) => object.toJson();
}

@freezed
class PriceHistoryValue with _$PriceHistoryValue {
const factory PriceHistoryValue({
required num price,
required DateTime time,
}) = _PriceHistoryValue;

factory PriceHistoryValue.fromJson(Map<String, dynamic> json) =>
_$PriceHistoryValueFromJson(json);
}
170 changes: 170 additions & 0 deletions lib/src/domain/models/market_price_history.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// 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 'market_price_history.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(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#adding-getters-and-methods-to-our-models');

PriceHistoryValue _$PriceHistoryValueFromJson(Map<String, dynamic> json) {
return _PriceHistoryValue.fromJson(json);
}

/// @nodoc
mixin _$PriceHistoryValue {
num get price => throw _privateConstructorUsedError;
DateTime get time => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$PriceHistoryValueCopyWith<PriceHistoryValue> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $PriceHistoryValueCopyWith<$Res> {
factory $PriceHistoryValueCopyWith(
PriceHistoryValue value, $Res Function(PriceHistoryValue) then) =
_$PriceHistoryValueCopyWithImpl<$Res, PriceHistoryValue>;
@useResult
$Res call({num price, DateTime time});
}

/// @nodoc
class _$PriceHistoryValueCopyWithImpl<$Res, $Val extends PriceHistoryValue>
implements $PriceHistoryValueCopyWith<$Res> {
_$PriceHistoryValueCopyWithImpl(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? price = null,
Object? time = null,
}) {
return _then(_value.copyWith(
price: null == price
? _value.price
: price // ignore: cast_nullable_to_non_nullable
as num,
time: null == time
? _value.time
: time // ignore: cast_nullable_to_non_nullable
as DateTime,
) as $Val);
}
}

/// @nodoc
abstract class _$$PriceHistoryValueImplCopyWith<$Res>
implements $PriceHistoryValueCopyWith<$Res> {
factory _$$PriceHistoryValueImplCopyWith(_$PriceHistoryValueImpl value,
$Res Function(_$PriceHistoryValueImpl) then) =
__$$PriceHistoryValueImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({num price, DateTime time});
}

/// @nodoc
class __$$PriceHistoryValueImplCopyWithImpl<$Res>
extends _$PriceHistoryValueCopyWithImpl<$Res, _$PriceHistoryValueImpl>
implements _$$PriceHistoryValueImplCopyWith<$Res> {
__$$PriceHistoryValueImplCopyWithImpl(_$PriceHistoryValueImpl _value,
$Res Function(_$PriceHistoryValueImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? price = null,
Object? time = null,
}) {
return _then(_$PriceHistoryValueImpl(
price: null == price
? _value.price
: price // ignore: cast_nullable_to_non_nullable
as num,
time: null == time
? _value.time
: time // ignore: cast_nullable_to_non_nullable
as DateTime,
));
}
}

/// @nodoc
@JsonSerializable()
class _$PriceHistoryValueImpl implements _PriceHistoryValue {
const _$PriceHistoryValueImpl({required this.price, required this.time});

factory _$PriceHistoryValueImpl.fromJson(Map<String, dynamic> json) =>
_$$PriceHistoryValueImplFromJson(json);

@override
final num price;
@override
final DateTime time;

@override
String toString() {
return 'PriceHistoryValue(price: $price, time: $time)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PriceHistoryValueImpl &&
(identical(other.price, price) || other.price == price) &&
(identical(other.time, time) || other.time == time));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, price, time);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$PriceHistoryValueImplCopyWith<_$PriceHistoryValueImpl> get copyWith =>
__$$PriceHistoryValueImplCopyWithImpl<_$PriceHistoryValueImpl>(
this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$PriceHistoryValueImplToJson(
this,
);
}
}

abstract class _PriceHistoryValue implements PriceHistoryValue {
const factory _PriceHistoryValue(
{required final num price,
required final DateTime time}) = _$PriceHistoryValueImpl;

factory _PriceHistoryValue.fromJson(Map<String, dynamic> json) =
_$PriceHistoryValueImpl.fromJson;

@override
num get price;
@override
DateTime get time;
@override
@JsonKey(ignore: true)
_$$PriceHistoryValueImplCopyWith<_$PriceHistoryValueImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Loading

0 comments on commit 2629b2e

Please sign in to comment.