-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix transactions #259
Fix transactions #259
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ class TokenSymbolScope { | |
final String symbol; | ||
final String scope; | ||
final String tokenContract; | ||
|
||
TokenSymbolScope({required this.symbol, required this.scope, required this.tokenContract}); | ||
} | ||
|
||
|
@@ -31,12 +32,12 @@ class TokenService { | |
}) async { | ||
LogHelper.d('getTokenBalance: $tokenContract'); | ||
try { | ||
final requestBody = ''' | ||
{ | ||
"account": "${user.accountName}", | ||
"code": "$tokenContract", | ||
"symbol": "$symbol", | ||
}'''; | ||
final requestBody = { | ||
'account': user.accountName, | ||
'code': tokenContract, | ||
'symbol': symbol, | ||
}; | ||
|
||
final Response<List> res = await user.network.manager.post<List>( | ||
Endpoints.getCurrencyBalance, | ||
data: requestBody, | ||
|
@@ -64,15 +65,15 @@ class TokenService { | |
required String tokenContract, | ||
}) async { | ||
try { | ||
final requestBody = ''' | ||
{ | ||
"code": "$tokenContract", | ||
"table": "stat", | ||
"lower_bound": "", | ||
"upper_bound": "", | ||
"limit": 1000, | ||
"reverse": false, | ||
}'''; | ||
final requestBody = { | ||
'code': tokenContract, | ||
'table': 'stat', | ||
'lower_bound': '', | ||
'upper_bound': '', | ||
'limit': 1000, | ||
'reverse': false, | ||
}; | ||
|
||
final res = await networkingManager.post(Endpoints.getTableScopes, data: requestBody); | ||
final List<Map<String, dynamic>> list = List<Map<String, dynamic>>.from(res.data['rows']); | ||
final tokenSymbolScopes = List<TokenSymbolScope>.from(list.map((e) { | ||
|
@@ -96,12 +97,12 @@ class TokenService { | |
required String symbol, | ||
}) async { | ||
try { | ||
final requestBody = ''' | ||
{ | ||
"json": true, | ||
"code": "$tokenContract", | ||
"symbol": "$symbol" | ||
}'''; | ||
final requestBody = { | ||
'json': true, | ||
'code': tokenContract, | ||
'symbol': symbol | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you test these? I guess the library makes proper json strings out of these... ?! the API rejects it if there's not " around all keys and values ... but that is the normal JSON spec so I'd expect it to work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes i did. |
||
final res = await networkingManager.post(Endpoints.getCurrencyStats, data: requestBody); | ||
final json = res.data; | ||
// flutter: res: {HYPHA: {supply: 47738747.41 HYPHA, max_supply: -1.00 HYPHA, issuer: dao.hypha}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,13 @@ class UserAccountService { | |
required String publicKey, | ||
required String network, | ||
}) async { | ||
final requestBody = ''' | ||
{ | ||
"code": "$code", | ||
"accountName": "$accountName", | ||
"publicKey": "$publicKey", | ||
"network": "$network" | ||
}'''; | ||
final requestBody = { | ||
'code': code, | ||
'accountName': accountName, | ||
'publicKey': publicKey, | ||
'network': network | ||
}; | ||
|
||
final url = remoteConfigService.accountCreatorEndpoint + Endpoints.createAccount; | ||
try { | ||
// ignore: unused_local_variable | ||
|
@@ -46,7 +46,9 @@ class UserAccountService { | |
} | ||
|
||
Future<bool> isUserAccountAvailable(String accountName, Network network) async { | ||
final requestBody = '{ "account_name": "$accountName" }'; | ||
final requestBody = { | ||
'account_name': accountName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, fake map removed |
||
}; | ||
try { | ||
// ignore: unused_local_variable | ||
final res = await network.manager.post(Endpoints.getAccount, data: requestBody); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
import 'package:equatable/equatable.dart'; | ||
|
||
const _daoAccount = 'dao.hypha'; | ||
const _systemTokenAccount = 'eosio.token'; | ||
const _hyphaTokenAccount = 'hypha.hypha'; | ||
const _hyphaWrapTokenAccount = 'whypha.hypha'; | ||
const _eosioLoginAccount = 'eosio.login'; | ||
|
||
sealed class TransactionModel extends Equatable { | ||
|
@@ -26,7 +23,7 @@ sealed class TransactionModel extends Equatable { | |
}); | ||
|
||
@override | ||
List<Object?> get props => [actionName, data, account, timestamp, blockNumber]; | ||
List<Object?> get props => [actionName, data, account, timestamp, blockNumber, actor, transactionId]; | ||
|
||
factory TransactionModel.parseFromParams({ | ||
required timestamp, | ||
|
@@ -38,9 +35,7 @@ sealed class TransactionModel extends Equatable { | |
required Map<String, dynamic> data, | ||
}) { | ||
return switch (actionName) { | ||
'transfer' | ||
when account == _hyphaTokenAccount || account == _hyphaWrapTokenAccount || account == _systemTokenAccount => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when account == _hyphaTokenAccount || account == _hyphaWrapTokenAccount || account == _systemTokenAccount Is this needed?? Basically this is never true when it call it for my account. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah because we recognize our own wrap token accounts This is only identifying a transaction as a transfer system token = TLOS or EOS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok so a transfer is any actions that includes 'transfer' as the action name Later on we decide which one to show or not. But the model is not the one dictating this, the UI is. The models just models data. |
||
TransactionTransfer( | ||
'transfer' => TransactionTransfer( | ||
account: account, | ||
actionName: actionName, | ||
blockNumber: blockNumber, | ||
|
@@ -187,10 +182,10 @@ class TransactionTransfer extends TransactionModel { | |
String get to => data['to']; | ||
|
||
/// 3175.00 | ||
num get amount => data['amount']; | ||
String get amount => (data['quantity'] as String).split(' ').first; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @n13 pls review these |
||
|
||
/// HUSD | ||
String get symbol => data['symbol']; | ||
String get symbol => (data['quantity'] as String).split(' ').last; | ||
|
||
const TransactionTransfer({ | ||
required super.data, | ||
|
@@ -208,10 +203,11 @@ class TransactionRedeem extends TransactionModel { | |
|
||
String get requestor => data['requestor']; | ||
|
||
/// 3175.00 HUSD Beware of this... | ||
String get amount => (data['amount'] as String).split(' ').first; | ||
/// 3175.00 | ||
String get amount => (data['quantity'] as String).split(' ').first; | ||
|
||
String get symbol => (data['amount'] as String).split(' ')[1]; | ||
/// HUSD | ||
String get symbol => (data['quantity'] as String).split(' ').last; | ||
|
||
const TransactionRedeem({ | ||
required super.data, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,11 @@ class TransactionHistoryRepository { | |
|
||
TransactionHistoryRepository({required this.service}); | ||
|
||
Future<Result<List<TransactionModel>, HyphaError>> getTransactions(UserProfileData user, bool transferOnly, | ||
{useV1History = false}) async { | ||
Future<Result<List<TransactionModel>, HyphaError>> getTransactions( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatting |
||
UserProfileData user, | ||
bool transferOnly, { | ||
useV1History = false, | ||
}) async { | ||
try { | ||
final Response response = useV1History | ||
? await service.getAllTransactionsV1History(user) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i removed these fake maps and created using maps.
Seems to work.