Skip to content
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

feat: Show account balance, update UI #6

Merged
merged 8 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29,306 changes: 29,306 additions & 0 deletions assets/data/abi_datahighway_mxc_mining_testnet.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/common/components/gasInput.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import 'package:flutter/material.dart';

Widget gasInput(title,subtile){
Widget gasInput(title,gasText,subtile){
return ListTile(
leading: Text(
title,
Expand All @@ -10,6 +10,7 @@ Widget gasInput(title,subtile){
)
),
title: TextField(
controller: TextEditingController()..text = gasText,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14
Expand Down
41 changes: 23 additions & 18 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@ import 'package:web3dart/web3dart.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

// Account
var kSamplePrivateKey = DotEnv().env['SAMPLE_PRIVATE_KEY'];
var kSampleAccountAddrMainnet =
EthereumAddress.fromHex('0x022478d51bF0cF12799E443ccd19527e075B6B37');
//Latest 0x022478d51bF0cF12799E443ccd19527e075B6B37
//before 0x2733566693458ee7e35f63b309da864db2637dc1
var kMnemonicSeed = DotEnv().env['MNENOMIC'];
var kAccountAddrTestnet =
EthereumAddress.fromHex(DotEnv().env['ETHEREUM_ADDRESS']);
//Latest 0x022478d51bF0cF12799E443ccd19527e075B6B37
//before 0x2733566693458ee7e35f63b309da864db2637dc1
var kGasLimitRecommended = '200000';
var kGasPriceRecommended = '30';

// Testnet
var kRpcUrlInfuraGoerli =
'https://goerli.infura.io/v3/${DotEnv().env['INFURA_PROJECT_ID']}';
var kWsUrlInfuraGoerli =
'wss://goerli.infura.io/v3/${DotEnv().env['INFURA_PROJECT_ID']}';
var kRpcUrlInfuraTestnetRopsten =
'https://ropsten.infura.io/v3/${DotEnv().env['INFURA_API_PROJECT_ID']}';
var kWsUrlInfuraTestnetRopsten =
'wss://ropsten.infura.io/ws/v3/${DotEnv().env['INFURA_API_PROJECT_ID']}';

// Mainnet
var kRpcUrlInfuraMainnet =
'https://mainnet.infura.io/v3/${DotEnv().env['INFURA_PROJECT_ID']}';
var kWsUrlInfuraMainnet =
'wss://mainnet.infura.io/v3/${DotEnv().env['INFURA_PROJECT_ID']}';
final EthereumAddress kContractAddrMXCMainnet =
EthereumAddress.fromHex('0x5Ca381bBfb58f0092df149bD3D243b08B9a8386e');
// FIXME - deploy contract and replace address below
final EthereumAddress kContractAddrDataHighwayMiningMainnet =
EthereumAddress.fromHex('0x0');
final EthereumAddress kContractAddrDataHighwayLockdropTestnet =
EthereumAddress.fromHex(DotEnv().env['CONTRACT_ADDRESS_LOCKDROP_TESTNET']);
final EthereumAddress kContractAddrMXCTestnet =
EthereumAddress.fromHex(DotEnv().env['CONTRACT_ADDRESS_MXC_TESTNET']);

// // Mainnet
// var kRpcUrlInfuraMainnet =
// 'https://mainnet.infura.io/v3/${DotEnv().env['INFURA_API_PROJECT_ID']}';
// var kWsUrlInfuraMainnet =
// 'wss://mainnet.infura.io/v3/${DotEnv().env['INFURA_API_PROJECT_ID']}';
// final EthereumAddress kContractAddrMXCTestnet =
// EthereumAddress.fromHex('0x5Ca381bBfb58f0092df149bD3D243b08B9a8386e');
64 changes: 32 additions & 32 deletions lib/page/assets/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class _AssetsState extends State<Assets> {
EthereumApiMiningMXC ethApiMiningMXC = await EthereumApiMiningMXC();
BigInt locked = await ethApiMiningMXC
.getAccountLockedMXCAmountFromDataHighwayMXCMiningContract(
kRpcUrlInfuraMainnet,
kWsUrlInfuraMainnet,
kContractAddrMXCMainnet,
kSamplePrivateKey);
kRpcUrlInfuraTestnetRopsten,
kWsUrlInfuraTestnetRopsten,
kContractAddrMXCTestnet,
kMnemonicSeed);
return locked;
}

Expand All @@ -63,8 +63,8 @@ class _AssetsState extends State<Assets> {
EthereumApiMiningMXC ethApiMiningMXC = await EthereumApiMiningMXC();
BigInt claimsPending = await ethApiMiningMXC
.getAccountLockedClaimsPendingOfMXCAmountFromDataHighwayMXCMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
kContractAddrMXCTestnet,
kMnemonicSeed);
return claimsPending;
}

Expand All @@ -73,8 +73,8 @@ class _AssetsState extends State<Assets> {
EthereumApiMiningMXC ethApiMiningMXC = await EthereumApiMiningMXC();
BigInt claimsApproved = await ethApiMiningMXC
.getAccountLockedClaimsApprovedOfMXCAmountFromDataHighwayMXCMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
kContractAddrMXCTestnet,
kMnemonicSeed);
return claimsApproved;
}

Expand All @@ -83,8 +83,8 @@ class _AssetsState extends State<Assets> {
EthereumApiMiningMXC ethApiMiningMXC = await EthereumApiMiningMXC();
BigInt claimsRejected = await ethApiMiningMXC
.getAccountLockedClaimsRejectedOfMXCAmountFromDataHighwayMXCMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
kContractAddrMXCTestnet,
kMnemonicSeed);
return claimsRejected;
}

Expand Down Expand Up @@ -113,10 +113,10 @@ class _AssetsState extends State<Assets> {
EthereumApiMiningMXC ethApiMiningMXC = await EthereumApiMiningMXC();
BigInt signalled = await ethApiMiningMXC
.getAccountSignalledMXCAmountFromDataHighwayMXCMiningContract(
kRpcUrlInfuraMainnet,
kWsUrlInfuraMainnet,
kContractAddrMXCMainnet,
kSamplePrivateKey);
kRpcUrlInfuraTestnetRopsten,
kWsUrlInfuraTestnetRopsten,
kContractAddrMXCTestnet,
kMnemonicSeed);
return signalled;
}

Expand All @@ -125,8 +125,8 @@ class _AssetsState extends State<Assets> {
EthereumApiMiningMXC ethApiMiningMXC = await EthereumApiMiningMXC();
BigInt claimsPending = await ethApiMiningMXC
.getAccountSignalledClaimsPendingOfMXCAmountFromDataHighwayMXCMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
kContractAddrMXCTestnet,
kMnemonicSeed);
return claimsPending;
}

Expand All @@ -135,8 +135,8 @@ class _AssetsState extends State<Assets> {
EthereumApiMiningMXC ethApiMiningMXC = await EthereumApiMiningMXC();
BigInt claimsApproved = await ethApiMiningMXC
.getAccountSignalledClaimsApprovedOfMXCAmountFromDataHighwayMXCMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
kContractAddrMXCTestnet,
kMnemonicSeed);
return claimsApproved;
}

Expand All @@ -145,8 +145,8 @@ class _AssetsState extends State<Assets> {
EthereumApiMiningMXC ethApiMiningMXC = await EthereumApiMiningMXC();
BigInt claimsRejected = await ethApiMiningMXC
.getAccountSignalledClaimsRejectedOfMXCAmountFromDataHighwayMXCMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
kContractAddrMXCTestnet,
kMnemonicSeed);
return claimsRejected;
}

Expand Down Expand Up @@ -176,10 +176,10 @@ class _AssetsState extends State<Assets> {
await EthereumApiMiningIOTAPegged();
BigInt signalled = await ethApiMiningIOTAPegged
.getAccountSignalledIOTAPeggedAmountFromDataHighwayIOTAPeggedMiningContract(
kRpcUrlInfuraMainnet,
kWsUrlInfuraMainnet,
kContractAddrMXCMainnet,
kSamplePrivateKey);
kRpcUrlInfuraTestnetRopsten,
kWsUrlInfuraTestnetRopsten,
kContractAddrMXCTestnet,
kMnemonicSeed);
return signalled;
}

Expand All @@ -190,8 +190,8 @@ class _AssetsState extends State<Assets> {
await EthereumApiMiningIOTAPegged();
BigInt claimsSignalledPending = await ethApiMiningIOTAPegged
.getAccountSignalledClaimsPendingOfIOTAPeggedAmountFromDataHighwayIOTAPeggedMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
kContractAddrMXCTestnet,
kMnemonicSeed);
return claimsSignalledPending;
}

Expand All @@ -200,11 +200,11 @@ class _AssetsState extends State<Assets> {
'Getting amount of approved reward claims for signalling IOTA (pegged)');
EthereumApiMiningIOTAPegged ethApiMiningIOTAPegged =
await EthereumApiMiningIOTAPegged();
BigInt claimsSignalledApproved = await ethApiMiningIOTAPegged
BigInt getClaimsSignalledApproved = await ethApiMiningIOTAPegged
.getAccountSignalledClaimsApprovedOfIOTAPeggedAmountFromDataHighwayIOTAPeggedMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
return claimsSignalledApproved;
kContractAddrMXCTestnet,
kMnemonicSeed);
return getClaimsSignalledApproved;
}

Future<BigInt> _fetchIOTAPeggedSignalledClaimsRejected() async {
Expand All @@ -214,8 +214,8 @@ class _AssetsState extends State<Assets> {
await EthereumApiMiningIOTAPegged();
BigInt claimsSignalledRejected = await ethApiMiningIOTAPegged
.getAccountSignalledClaimsRejectedOfIOTAPeggedAmountFromDataHighwayIOTAPeggedMiningContract(
kContractAddrMXCMainnet,
kSamplePrivateKey);
kContractAddrMXCTestnet,
kMnemonicSeed);
return claimsSignalledRejected;
}

Expand Down
23 changes: 22 additions & 1 deletion lib/page/assets/lock/lockDetailPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import 'package:polka_wallet/page/assets/lock/lockResultPage.dart';
import 'package:polka_wallet/store/app.dart';
import 'package:polka_wallet/utils/i18n/index.dart';

import '../../../constants.dart';

class LockDetailPage extends StatefulWidget {
LockDetailPage(this.store);

Expand All @@ -36,6 +38,7 @@ class _DetailPageState extends State<LockDetailPage> {
TextEditingController _durationCtl = TextEditingController(text: '');
TextEditingController _amountCtl = TextEditingController(text: '');
TextEditingController _publicKeyCtl = TextEditingController(text: '');
TextEditingController _genesisValidator = TextEditingController(text: 'false');
bool _qrcodeValue = false;
bool _doubleCheckValue = false;

Expand Down Expand Up @@ -105,6 +108,21 @@ class _DetailPageState extends State<LockDetailPage> {
formulaInput(
controller: _publicKeyCtl,
lable: dic['public.key'],
onChanged: (value){
setState(() {});
}
)
],
),
Row(
children: <Widget>[
formulaInput(
controller: _genesisValidator,
lable: dic['genesis.validator'],
onChanged: (value){
setState(() {});
},
value: 'false'
)
],
),
Expand All @@ -121,7 +139,10 @@ class _DetailPageState extends State<LockDetailPage> {
padding: const EdgeInsets.all(5),
color: Colors.grey[200],
child: Text(
'${_durationCtl.text.isEmpty ? '??' : _durationCtl.text},Lock,${_amountCtl.text.isEmpty ? '??' : _amountCtl.text}',
'${_durationCtl.text.isEmpty ? '??' : _durationCtl.text},Lock,${_amountCtl.text.isEmpty ? '??' : _amountCtl.text},${_publicKeyCtl.text.isEmpty ? '??' : _publicKeyCtl.text},${kContractAddrMXCTestnet},${_genesisValidator.text.isEmpty ? '??' : _genesisValidator.text}',
style: TextStyle(
fontSize: 12
),
textAlign: TextAlign.center,
),
),
Expand Down
8 changes: 5 additions & 3 deletions lib/page/assets/lock/lockResultPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:polka_wallet/common/components/linkTap.dart';
import 'package:polka_wallet/store/app.dart';
import 'package:polka_wallet/utils/i18n/index.dart';

import '../../../constants.dart';

class LockResultPage extends StatefulWidget {
LockResultPage(this.store);

Expand Down Expand Up @@ -60,14 +62,14 @@ class _ResultPageState extends State<LockResultPage> {
padding: const EdgeInsets.all(5),
color: Colors.grey[200],
child: Text(
'Wallet Address',
'${kContractAddrDataHighwayLockdropTestnet}',
textAlign: TextAlign.center,
),
),
trailing: Icon(Icons.content_copy),
),
gasInput(dic['gas.limit'],dic['units']),
gasInput(dic['gas.price'],dic['gwei']),
gasInput(dic['gas.limit'],kGasLimitRecommended,dic['units']),
gasInput(dic['gas.price'],kGasPriceRecommended,dic['gwei']),
linkTap(
dic['click.instructions'],
onTap: (){}
Expand Down
10 changes: 9 additions & 1 deletion lib/page/assets/signal/signalDetailPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import 'package:polka_wallet/page/assets/signal/signalResultPage.dart';
import 'package:polka_wallet/store/app.dart';
import 'package:polka_wallet/utils/i18n/index.dart';

import '../../../constants.dart';

class SignalDetailPage extends StatefulWidget {
SignalDetailPage(this.store);

Expand Down Expand Up @@ -105,6 +107,9 @@ class _DetailPageState extends State<SignalDetailPage> {
formulaInput(
controller: _publicKeyCtl,
lable: dic['public.key'],
onChanged: (value){
setState(() {});
}
)
],
),
Expand All @@ -121,7 +126,10 @@ class _DetailPageState extends State<SignalDetailPage> {
padding: const EdgeInsets.all(5),
color: Colors.grey[200],
child: Text(
'${_durationCtl.text.isEmpty ? '??' : _durationCtl.text},Signal,${_amountCtl.text.isEmpty ? '??' : _amountCtl.text}',
'${_durationCtl.text.isEmpty ? '??' : _durationCtl.text},Signal,${_amountCtl.text.isEmpty ? '??' : _amountCtl.text},${_publicKeyCtl.text.isEmpty ? '??' : _publicKeyCtl.text},${kContractAddrMXCTestnet}',
style: TextStyle(
fontSize: 12
),
textAlign: TextAlign.center,
),
),
Expand Down
8 changes: 5 additions & 3 deletions lib/page/assets/signal/signalResultPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:polka_wallet/common/components/linkTap.dart';
import 'package:polka_wallet/store/app.dart';
import 'package:polka_wallet/utils/i18n/index.dart';

import '../../../constants.dart';

class SignalResultPage extends StatefulWidget {
SignalResultPage(this.store);

Expand Down Expand Up @@ -60,14 +62,14 @@ class _ResultPageState extends State<SignalResultPage> {
padding: const EdgeInsets.all(5),
color: Colors.grey[200],
child: Text(
'Wallet Address',
'${kContractAddrDataHighwayLockdropTestnet}',
textAlign: TextAlign.center,
),
),
trailing: Icon(Icons.content_copy),
),
gasInput(dic['gas.limit'],dic['units']),
gasInput(dic['gas.price'],dic['gwei']),
gasInput(dic['gas.limit'],kGasLimitRecommended,dic['units']),
gasInput(dic['gas.price'],kGasPriceRecommended,dic['gwei']),
linkTap(
dic['click.instructions'],
onTap: (){}
Expand Down
Loading