Skip to content

Commit

Permalink
Merge pull request #26 from AcalaNetwork/develop
Browse files Browse the repository at this point in the history
Release 0.4.9
  • Loading branch information
RomeroYang authored Aug 8, 2022
2 parents 415c730 + 7f8b4d5 commit 9c8bf1a
Show file tree
Hide file tree
Showing 148 changed files with 10,921 additions and 5,754 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.4.9] - 20220808
- bump polkawallet_sdk v0.4.9.
- js api update.
- ui update.

## [0.4.8] - 20220621
- bump polkawallet_sdk v0.4.8.
- ui update.
Expand Down
Binary file added assets/images/QueuedRedeemRequesting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cdp_multiply.riv
Binary file not shown.
Binary file added assets/images/cdp_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/history.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/homa_myStats_item_bg.png
Binary file not shown.
Binary file removed assets/images/homa_myStats_item_select_bg.png
Binary file not shown.
Binary file modified assets/images/icon_earn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/icon_homa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/icon_instrument_black.png
Binary file not shown.
Binary file removed assets/images/icon_instrument_blue.png
Binary file not shown.
Binary file removed assets/images/icon_instrument_orange.png
Binary file not shown.
Binary file removed assets/images/icon_instrument_yellow.png
Binary file not shown.
Binary file modified assets/images/icon_loan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/icon_multiply.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/icon_swap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/lp_detail_reward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/mint_kusd_head.png
Binary file not shown.
Binary file added assets/images/qr_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/rewards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/screening.png
Binary file not shown.
Binary file added assets/images/send_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/staked.png
Binary file not shown.
17 changes: 0 additions & 17 deletions assets/images/staked.svg

This file was deleted.

Binary file added assets/images/staked_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/swapRoute/karura.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/swapRoute/nuts-taiga-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/swap_repeat.png
Binary file added assets/images/swap_set.png
Binary file modified assets/images/swap_switch.png
Binary file added assets/images/swap_to.png
Binary file added assets/images/taiga_addliquidity.png
Binary file removed assets/images/tokens/ARIS.png
Diff not rendered.
Binary file modified assets/images/tokens/KAR.png
Binary file modified assets/images/tokens/KUSD.png
Binary file modified assets/images/unstaked.png
Binary file added assets/images/xcm_to.png
5 changes: 4 additions & 1 deletion lib/api/acalaApi.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:polkawallet_plugin_karura/api/acalaService.dart';
import 'package:polkawallet_plugin_karura/api/assets/acalaApiAssets.dart';
import 'package:polkawallet_plugin_karura/api/earn/acalaApiEarn.dart';
import 'package:polkawallet_plugin_karura/api/history/acalaApiHistory.dart';
import 'package:polkawallet_plugin_karura/api/homa/acalaApiHoma.dart';
import 'package:polkawallet_plugin_karura/api/loan/acalaApiLoan.dart';
import 'package:polkawallet_plugin_karura/api/swap/acalaApiSwap.dart';
Expand All @@ -11,11 +12,13 @@ class AcalaApi {
loan = AcalaApiLoan(service.loan),
swap = AcalaApiSwap(service.swap),
homa = AcalaApiHoma(service.homa),
earn = AcalaApiEarn(service.earn);
earn = AcalaApiEarn(service.earn),
history = AcalaApiHistory(service.history);

final AcalaApiAssets assets;
final AcalaApiLoan loan;
final AcalaApiSwap swap;
final AcalaApiHoma homa;
final AcalaApiEarn earn;
final AcalaApiHistory history;
}
5 changes: 4 additions & 1 deletion lib/api/acalaService.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:polkawallet_plugin_karura/api/assets/acalaServiceAssets.dart';
import 'package:polkawallet_plugin_karura/api/earn/acalaServiceEarn.dart';
import 'package:polkawallet_plugin_karura/api/history/acalaServiceHistory.dart';
import 'package:polkawallet_plugin_karura/api/homa/acalaServiceHoma.dart';
import 'package:polkawallet_plugin_karura/api/loan/acalaServiceLoan.dart';
import 'package:polkawallet_plugin_karura/api/swap/acalaServiceSwap.dart';
Expand All @@ -11,11 +12,13 @@ class AcalaService {
loan = AcalaServiceLoan(plugin),
swap = AcalaServiceSwap(plugin),
homa = AcalaServiceHoma(plugin),
earn = AcalaServiceEarn(plugin);
earn = AcalaServiceEarn(plugin),
history = AcalaServiceHistory(plugin);

final AcalaServiceAssets assets;
final AcalaServiceLoan loan;
final AcalaServiceSwap swap;
final AcalaServiceHoma homa;
final AcalaServiceEarn earn;
final AcalaServiceHistory history;
}
12 changes: 11 additions & 1 deletion lib/api/assets/acalaApiAssets.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:polkawallet_plugin_karura/api/assets/acalaServiceAssets.dart';
import 'package:polkawallet_plugin_karura/api/types/nftData.dart';
import 'package:polkawallet_plugin_karura/pages/assets/tokenDetailPage.dart';
import 'package:polkawallet_plugin_karura/utils/assets.dart';
import 'package:polkawallet_plugin_karura/utils/format.dart';
import 'package:polkawallet_sdk/plugin/store/balances.dart';

Expand Down Expand Up @@ -32,6 +33,12 @@ class AcalaApiAssets {
return res;
}

Future<Map<String, num>> getTokenPrices(List<String> tokens) async {
tokens.add('KAR');
final res = await service.getTokenPrices(tokens);
return Map<String, num>.from(res);
}

void unsubscribeTokenBalances(String? address) {
service.unsubscribeTokenBalances(address);
}
Expand Down Expand Up @@ -85,7 +92,10 @@ class AcalaApiAssets {
amount: e['balance']['free'].toString(),
locked: e['balance']['frozen'].toString(),
reserved: e['balance']['reserved'].toString(),
price: service.plugin.store!.assets.marketPrices[e['symbol']],
price: AssetsUtils.getMarketPrice(service.plugin, e['symbol']),
getPrice: () {
return AssetsUtils.getMarketPrice(service.plugin, e['symbol']);
},
detailPageRoute: TokenDetailPage.route,
);
}).toList());
Expand Down
6 changes: 6 additions & 0 deletions lib/api/assets/acalaServiceAssets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class AcalaServiceAssets {
return res;
}

Future<Map> getTokenPrices(List<String> tokens) async {
final Map? res = await plugin.sdk.webView!
.evalJavascript('acala.getTokenPrices(${jsonEncode(tokens)})');
return res ?? {};
}

void unsubscribeTokenBalances(String? address) async {
final tokens = await plugin.api!.assets.getAllTokenSymbols(withCache: true);
tokens.forEach((e) {
Expand Down
31 changes: 31 additions & 0 deletions lib/api/earn/acalaApiEarn.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
import 'package:polkawallet_plugin_karura/api/earn/acalaServiceEarn.dart';
import 'package:polkawallet_plugin_karura/api/earn/types/incentivesData.dart';
import 'package:polkawallet_plugin_karura/api/types/dexPoolInfoData.dart';
import 'package:polkawallet_plugin_karura/pages/types/taigaPoolInfoData.dart';

class AcalaApiEarn {
AcalaApiEarn(this.service);

final AcalaServiceEarn service;

Future<Map?> getTaigaMintAmount(
String poolId, List<String> input, double slippage) async {
final Map? res = await service.getTaigaMintAmount(poolId, input, slippage);
//{"minAmount":"99215063014","params":[0,["98963000000","0"],"99215063014"]}
return res;
}

Future<Map?> getTaigaRedeemAmount(
String poolId, String input, double slippage) async {
final Map? res =
await service.getTaigaRedeemAmount(poolId, input, slippage);
// {"minAmount":["23693477297","384434880258"],"params":[0,"69679144669",["23693477297","45491610738"]]}
return res;
}

Future<List<DexPoolData>?> getTaigaTokenPairs() async {
final List? res = await service.getTaigaTokenPairs();
return res?.map((e) => DexPoolData.fromJson(e)).toList();
}

Future<Map<String, TaigaPoolInfoData>> getTaigaPoolInfo(
String address) async {
final Map? res = await service.getTaigaPoolInfo(address);
Map<String, TaigaPoolInfoData> data = {};
res?.forEach(
(key, value) => data.addAll({key: TaigaPoolInfoData.fromJson(value)}));
return data;
}

Future<IncentivesData> queryIncentives() async {
final res =
await (service.queryIncentives() as Future<Map<dynamic, dynamic>>);
Expand Down
32 changes: 32 additions & 0 deletions lib/api/earn/acalaServiceEarn.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';

import 'package:polkawallet_plugin_karura/polkawallet_plugin_karura.dart';

Expand All @@ -7,6 +8,37 @@ class AcalaServiceEarn {

final PluginKarura plugin;

Future<Map?> getTaigaMintAmount(
String poolId, List<String> input, double slippage) async {
final Map? res = await plugin.sdk.webView!.evalJavascript(
'acala.getTaigaMintAmount("$poolId",${jsonEncode(input)},$slippage)');
return res;
}

Future<Map?> getTaigaRedeemAmount(
String poolId, String input, double slippage) async {
final Map? res = await plugin.sdk.webView!.evalJavascript(
'acala.getTaigaRedeemAmount("$poolId","$input",$slippage)');
return res;
}

Future<List?> getTaigaTokenPairs() async {
final List? res =
await plugin.sdk.webView!.evalJavascript('acala.getTaigaTokenPairs()');
return res;
}

Future<Map?> getTaigaPoolInfo(String address) async {
try {
final Map? res = await plugin.sdk.webView!
.evalJavascript('acala.getTaigaPoolInfo(api, "$address")');
return res;
} catch (error) {
print(error);
return {};
}
}

Future<Map?> queryIncentives() async {
final Map? res =
await plugin.sdk.webView!.evalJavascript('acala.queryIncentives(api)');
Expand Down
14 changes: 14 additions & 0 deletions lib/api/history/acalaApiHistory.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:polkawallet_plugin_karura/api/history/acalaServiceHistory.dart';
import 'package:polkawallet_plugin_karura/api/history/types/historyData.dart';

class AcalaApiHistory {
AcalaApiHistory(this.service);

final AcalaServiceHistory service;

Future<List<HistoryData>> queryHistory(String type, String? address,
{Map<String, dynamic> params = const {}}) async {
final List? res = await service.queryHistory(type, address, params);
return res?.map((e) => HistoryData.fromJson(e)).toList() ?? [];
}
}
17 changes: 17 additions & 0 deletions lib/api/history/acalaServiceHistory.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'dart:async';
import 'dart:convert';

import 'package:polkawallet_plugin_karura/polkawallet_plugin_karura.dart';

class AcalaServiceHistory {
AcalaServiceHistory(this.plugin);

final PluginKarura plugin;

Future<List?> queryHistory(
String type, String? address, Map<String, dynamic> params) async {
final List? list = await plugin.sdk.webView!.evalJavascript(
'acala.getHistory(api,"$type","$address",${jsonEncode(params)})');
return list;
}
}
19 changes: 19 additions & 0 deletions lib/api/history/types/historyData.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class HistoryData extends _HistoryData {
static HistoryData fromJson(Map json) {
final res = new HistoryData();
res.message = json['message'] as String?;
res.hash = json['hash'] as String?;
res.resolveLinks = json['resolveLinks'] as String?;
res.data = Map.from(json['data']);
res.event = json['event'] as String?;
return res;
}
}

abstract class _HistoryData {
String? message;
Map<String, dynamic>? data;
String? hash;
String? resolveLinks;
String? event;
}
29 changes: 28 additions & 1 deletion lib/api/swap/acalaApiSwap.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
import 'package:polkawallet_plugin_karura/api/swap/acalaServiceSwap.dart';
import 'package:polkawallet_plugin_karura/api/types/dexPoolInfoData.dart';
import 'package:polkawallet_plugin_karura/api/types/swapOutputData.dart';
import 'package:polkawallet_plugin_karura/pages/assets/tokenDetailPage.dart';
import 'package:polkawallet_plugin_karura/utils/assets.dart';
import 'package:polkawallet_plugin_karura/utils/format.dart';
import 'package:polkawallet_sdk/plugin/store/balances.dart';

class AcalaApiSwap {
AcalaApiSwap(this.service);

final AcalaServiceSwap service;

Future<List<TokenBalanceData>?> getSwapTokens() async {
final data = await service.getSwapTokens();
final tokensConfig =
service.plugin.store!.setting.remoteConfig['tokens'] ?? {};
return data
?.map((e) => TokenBalanceData(
id: e['id'] ?? e['symbol'],
symbol: e['symbol'],
type: e['type'],
tokenNameId: e['tokenNameId'],
currencyId: e['currencyId'],
minBalance: e['minBalance'],
name: PluginFmt.tokenView(e['symbol']),
fullName: tokensConfig['tokenName'] != null
? tokensConfig['tokenName'][e['symbol']]
: null,
decimals: e['decimals'],
price: AssetsUtils.getMarketPrice(service.plugin, e['symbol']),
detailPageRoute: TokenDetailPage.route,
))
.toList();
}

Future<SwapOutputData> queryTokenSwapAmount(
String? supplyAmount,
String? targetAmount,
List<Map> swapPair,
List<String?> swapPair,
String slippage,
) async {
final output = await (service.queryTokenSwapAmount(
Expand Down
9 changes: 7 additions & 2 deletions lib/api/swap/acalaServiceSwap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ class AcalaServiceSwap {

final PluginKarura plugin;

Future<List?> getSwapTokens() async {
return await plugin.sdk.webView!
.evalJavascript('acala.getSwapTokens(apiRx)');
}

Future<Map?> queryTokenSwapAmount(
String? supplyAmount,
String? targetAmount,
List<Map> swapPair,
List<String?> swapPair,
String slippage,
) async {
final code =
'acala.calcTokenSwapAmount(api, $supplyAmount, $targetAmount, ${jsonEncode(swapPair)}, $slippage)';
'acala.calcTokenSwapAmount(apiRx, $supplyAmount, $targetAmount, ${jsonEncode(swapPair)}, $slippage)';
final output = await plugin.sdk.webView!.evalJavascript(code);
return output;
}
Expand Down
1 change: 1 addition & 0 deletions lib/api/types/dexPoolInfoData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abstract class _DexPoolData {
ProvisioningData? provisioning;
double? rewards;
double? rewardsLoyalty;
List? balances;
}

@JsonSerializable()
Expand Down
4 changes: 3 additions & 1 deletion lib/api/types/dexPoolInfoData.g.dart

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

2 changes: 1 addition & 1 deletion lib/api/types/homaNewEnvData.g.dart

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

Loading

0 comments on commit 9c8bf1a

Please sign in to comment.