Skip to content

Commit

Permalink
v2.0.5-3
Browse files Browse the repository at this point in the history
  • Loading branch information
RomeroYang committed May 14, 2021
1 parent 537bcda commit 39f26eb
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 75 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@
- Add Edgeware network support.
- Update ChainX plugin.
- Update Laminar plugin to TC3.
- Fix known Bugs.

# 2.0.5-beta
- Update Acala swap & loan UI.
- Remove Kusama council module.
- Update Edgeware Update.
- Update ChainX plugin.
- Fix known Bugs.
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -493,7 +493,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -526,7 +526,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = WQ5H736A22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
2 changes: 2 additions & 0 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ class _WalletAppState extends State<WalletApp> {
// todo: remove this after crowd loan
final karStarted = await WalletApi.getKarCrowdLoanStarted();
if (karStarted != null && karStarted['result']) {
storage.write(kar_crowd_loan_api_key,
'${karStarted['endpoint']}|${karStarted['subscribe']}');
Navigator.of(context).pushNamed(AdPage.route);
return;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/common/consts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const prefixList = [

/// app versions
enum BuildTargets { apk, playStore, dev }
const String app_beta_version = 'v2.0.5-beta.1';
const int app_beta_version_code = 2051;
const String app_beta_version = 'v2.0.5-beta.3';
const int app_beta_version_code = 2053;

const show_guide_status_key = 'show_guide_status';
const show_banner_status_key = 'show_banner_status';
const kar_crowd_loan_api_key = 'kar_crowd_loan_api';
6 changes: 1 addition & 5 deletions lib/pages/public/AdBanner.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:app/common/consts.dart';
import 'package:app/main.dart';
import 'package:app/pages/public/karCrowdLoanPage.dart';
import 'package:app/service/walletApi.dart';
import 'package:app/utils/i18n/index.dart';
Expand Down Expand Up @@ -61,10 +60,7 @@ class _AdBannerState extends State<AdBanner> {
super.initState();

WidgetsBinding.instance.addPostFrameCallback((_) {
// todo: only available in dev now
if (widget.service.buildTarget == BuildTargets.dev) {
_getCrowdLoanStarted();
}
_getCrowdLoanStarted();
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/pages/public/adPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AdPage extends StatefulWidget {
}

class _AdPageState extends State<AdPage> {
int _timerCount = 6;
int _timerCount = 10;

void _updateTimer() {
if (_timerCount > 0) {
Expand Down
33 changes: 19 additions & 14 deletions lib/pages/public/karCrowdLoanFormPage.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:app/common/consts.dart';
import 'package:app/pages/public/karCrowdLoanPage.dart';
import 'package:app/service/index.dart';
import 'package:app/service/walletApi.dart';
Expand Down Expand Up @@ -63,10 +64,9 @@ class _KarCrowdLoanFormPageState extends State<KarCrowdLoanFormPage> {

final amt = double.parse(v);

// todo: update decimals while online
final decimals = 12;
// final decimals = widget.service.plugin.networkState.tokenDecimals[0];
final valid = amt < Fmt.bigIntToDouble(balanceInt, decimals);
final decimals =
(widget.service.plugin.networkState.tokenDecimals ?? [12])[0];
final valid = amt < Fmt.bigIntToDouble(balanceInt, decimals) && amt >= 1;
setState(() {
_amountValid = valid;
_amount = amt;
Expand All @@ -92,7 +92,8 @@ class _KarCrowdLoanFormPageState extends State<KarCrowdLoanFormPage> {
});
return;
}
final res = await WalletApi.verifyKarReferralCode(v);
final karApis = widget.service.store.storage.read(kar_crowd_loan_api_key);
final res = await WalletApi.verifyKarReferralCode(v, karApis.split('|')[0]);
print(res);
final valid2 = res != null && res['result'];
setState(() {
Expand All @@ -109,16 +110,22 @@ class _KarCrowdLoanFormPageState extends State<KarCrowdLoanFormPage> {
setState(() {
_submitting = true;
});
final karApi = widget.service.store.storage.read(kar_crowd_loan_api_key);
final karApis = karApi.split('|');
final KarCrowdLoanPageParams params =
ModalRoute.of(context).settings.arguments;
// todo: update decimals while online
final decimals = 12;
// final decimals = widget.service.plugin.networkState.tokenDecimals[0];
final decimals =
(widget.service.plugin.networkState.tokenDecimals ?? [12])[0];
final amountInt = Fmt.tokenInt(_amount.toString(), decimals);
final signed = widget.service.store.storage
.read('$kar_statement_store_key${account.pubKey}');
final signingRes = await widget.service.account.postKarCrowdLoan(
account.address, amountInt, params.email, _referral, signed);
account.address,
amountInt,
params.email,
_referral,
signed,
karApis[0]);
if (signingRes != null && (signingRes['result'] ?? false)) {
final dic = I18n.of(context).getDic(i18n_full_dic_app, 'public');
final res = (await Navigator.of(context).pushNamed(TxConfirmPage.route,
Expand All @@ -135,8 +142,7 @@ class _KarCrowdLoanFormPageState extends State<KarCrowdLoanFormPage> {
))) as Map;
if (res != null) {
if (params.email.isNotEmpty && _emailAccept) {
// todo: update subscribe id in production
WalletApi.postKarSubscribe(params.email);
WalletApi.postKarSubscribe(params.email, karApis[1]);
}
await showCupertinoDialog(
context: context,
Expand Down Expand Up @@ -200,9 +206,8 @@ class _KarCrowdLoanFormPageState extends State<KarCrowdLoanFormPage> {
Widget build(_) {
return Observer(builder: (BuildContext context) {
final dic = I18n.of(context).getDic(i18n_full_dic_app, 'public');
// todo: update decimals while online
final decimals = 12;
// final decimals = widget.service.plugin.networkState.tokenDecimals[0];
final decimals =
(widget.service.plugin.networkState.tokenDecimals ?? [12])[0];

final cardColor = Theme.of(context).cardColor;
final karColor = Colors.red;
Expand Down
11 changes: 7 additions & 4 deletions lib/pages/public/karCrowdLoanPage.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:app/common/consts.dart';
import 'package:app/pages/public/karCrowdLoanFormPage.dart';
import 'package:app/pages/public/adPage.dart';
import 'package:app/service/index.dart';
Expand Down Expand Up @@ -80,7 +81,9 @@ class _KarCrowdLoanPageState extends State<KarCrowdLoanPage> {
}

Future<void> _getCrowdLoanHistory() async {
final res = await WalletApi.getKarCrowdLoanHistory(_account.address);
final karApis = widget.service.store.storage.read(kar_crowd_loan_api_key);
final res = await WalletApi.getKarCrowdLoanHistory(
_account.address, karApis.split('|')[0]);
print(res);
if (res != null && mounted) {
setState(() {
Expand All @@ -102,8 +105,8 @@ class _KarCrowdLoanPageState extends State<KarCrowdLoanPage> {
}

Future<void> _getKarStatement() async {
final res = await WalletApi.getKarCrowdLoanStatement();
print(res);
final karApis = widget.service.store.storage.read(kar_crowd_loan_api_key);
final res = await WalletApi.getKarCrowdLoanStatement(karApis.split('|')[0]);
if (res != null && mounted) {
setState(() {
_statement = res;
Expand Down Expand Up @@ -656,7 +659,7 @@ class CrowdLoanPageLayout extends StatelessWidget {
),
Container(
height: 56,
margin: EdgeInsets.only(top: 24, left: 8),
margin: EdgeInsets.only(top: 32, left: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand Down
4 changes: 2 additions & 2 deletions lib/service/apiAccount.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ class ApiAccount {
}

Future<Map> postKarCrowdLoan(String address, BigInt amount, String email,
String referral, String signature) async {
String referral, String signature, String endpoint) async {
final submitted = await WalletApi.postKarCrowdLoan(
address, amount, email, referral, signature);
address, amount, email, referral, signature, endpoint);
print(submitted);
if (submitted != null && (submitted['result'] ?? false)) {
apiRoot.store.account.setBannerVisible(false);
Expand Down
24 changes: 11 additions & 13 deletions lib/service/walletApi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import 'package:http/http.dart';

class WalletApi {
static const String _endpoint = 'https://api.polkawallet.io';
// todo: change the _karEndpoint while online
// static const String _karEndpoint = 'https://api.aca-staging.network/';
static const String _karEndpoint = 'https://crowdloan-api.laminar.codes';

static const String _jsCodeStorageKey = 'js_service_';
static const String _jsCodeStorageVersionKey = 'js_service_version_';
Expand Down Expand Up @@ -131,9 +128,9 @@ class WalletApi {
}
}

static Future<Map> getKarCrowdLoanStatement() async {
static Future<Map> getKarCrowdLoanStatement(String endpoint) async {
try {
final res = await get('$_karEndpoint/statement');
final res = await get('https://$endpoint/statement');
if (res == null) {
return null;
} else {
Expand All @@ -145,9 +142,10 @@ class WalletApi {
}
}

static Future<List> getKarCrowdLoanHistory(String address) async {
static Future<List> getKarCrowdLoanHistory(
String address, String endpoint) async {
try {
final res = await get('$_karEndpoint/contributions/$address');
final res = await get('https://$endpoint/contributions/$address');
if (res == null) {
return null;
} else {
Expand All @@ -160,9 +158,9 @@ class WalletApi {
}
}

static Future<Map> verifyKarReferralCode(String code) async {
static Future<Map> verifyKarReferralCode(String code, String endpoint) async {
try {
final res = await get('$_karEndpoint/referral/$code');
final res = await get('https://$endpoint/referral/$code');
if (res == null) {
return null;
} else {
Expand All @@ -175,7 +173,7 @@ class WalletApi {
}

static Future<Map> postKarCrowdLoan(String address, BigInt amount,
String email, String referral, String signature) async {
String email, String referral, String signature, String endpoint) async {
final headers = {"Content-type": "application/json", "Accept": "*/*"};
final body = {
"address": address,
Expand All @@ -189,7 +187,7 @@ class WalletApi {
body.addAll({"referral": referral});
}
try {
final res = await post('$_karEndpoint/verify',
final res = await post('https://$endpoint/verify',
headers: headers, body: jsonEncode(body));
if (res == null) {
return null;
Expand All @@ -202,7 +200,7 @@ class WalletApi {
}
}

static Future<Map> postKarSubscribe(String email) async {
static Future<Map> postKarSubscribe(String email, String subscribeId) async {
final headers = {"Content-type": "application/json", "Accept": "*/*"};
final body = {
"fields": [
Expand All @@ -211,7 +209,7 @@ class WalletApi {
};
try {
final res = await post(
'https://api.hsforms.com/submissions/v3/integration/submit/7522932/fc605148-482f-4302-a8d2-cece3251f7fc',
'https://api.hsforms.com/submissions/v3/integration/submit/7522932/$subscribeId',
headers: headers,
body: jsonEncode(body));
if (res == null) {
Expand Down
61 changes: 47 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -747,31 +747,64 @@ packages:
polkawallet_plugin_acala:
dependency: "direct main"
description:
path: "../../coding/polkawallet/polkawallet_plugin_acala"
relative: true
source: path
path: "."
ref: "28aff6c52cbc4fbdf22120f191b073ffd1faf3a9"
resolved-ref: "28aff6c52cbc4fbdf22120f191b073ffd1faf3a9"
url: "https://github.com/AcalaNetwork/polkawallet_plugin_acala.git"
source: git
version: "0.1.6"
polkawallet_plugin_kusama:
polkawallet_plugin_chainx:
dependency: "direct main"
description:
path: "."
ref: "0692cbb02da9cfd59eae2856e6e2819c072d4cd3"
resolved-ref: "0692cbb02da9cfd59eae2856e6e2819c072d4cd3"
url: "https://github.com/true-eye/polkawallet_plugin_chainx.git"
source: git
version: "0.0.1"
polkawallet_plugin_edgeware:
dependency: "direct main"
description:
path: "../../coding/polkawallet/polkawallet_plugin_kusama"
relative: true
source: path
path: "."
ref: "4e0d7dffee5222c493f70a310ce5f9b5b24f4d90"
resolved-ref: "4e0d7dffee5222c493f70a310ce5f9b5b24f4d90"
url: "https://github.com/remzrn/polkawallet_plugin_edgeware.git"
source: git
version: "0.1.6"
polkawallet_plugin_kusama:
dependency: "direct main"
description:
path: "."
ref: "8add53266eb2bc65aa94b378f0daeb456e39eee7"
resolved-ref: "8add53266eb2bc65aa94b378f0daeb456e39eee7"
url: "https://github.com/polkawallet-io/polkawallet_plugin_kusama.git"
source: git
version: "0.1.7"
polkawallet_plugin_laminar:
dependency: "direct main"
description:
path: "."
ref: "73b623a259fa6c31c0999625ebbfa7cdb84a6dcd"
resolved-ref: "73b623a259fa6c31c0999625ebbfa7cdb84a6dcd"
url: "https://github.com/polkawallet-io/polkawallet_plugin_laminar.git"
source: git
version: "0.1.5"
polkawallet_sdk:
dependency: "direct overridden"
description:
path: "../../coding/polkawallet/sdk"
relative: true
source: path
name: polkawallet_sdk
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.7"
polkawallet_ui:
dependency: "direct overridden"
description:
path: "../../coding/polkawallet/ui"
relative: true
source: path
version: "0.1.5"
path: "."
ref: b68da4b7d56dec37ddc34844b204fd095a00f7df
resolved-ref: b68da4b7d56dec37ddc34844b204fd095a00f7df
url: "https://github.com/polkawallet-io/ui.git"
source: git
version: "0.1.7"
pool:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit 39f26eb

Please sign in to comment.