Merge branch 'calculTxFees' into 'master'
Calcul tx fees See merge request clients/gecko!32
This commit is contained in:
commit
ebc69445ed
|
@ -367,6 +367,19 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<double> txFees(
|
||||||
|
String fromAddress, String destAddress, double amount) async {
|
||||||
|
if (amount == 0) return 0;
|
||||||
|
final sender = await _setSender(fromAddress);
|
||||||
|
final txInfo = TxInfoData('balances', 'transferKeepAlive', sender);
|
||||||
|
final amountUnit = (amount * 100).toInt();
|
||||||
|
|
||||||
|
final estimateFees =
|
||||||
|
await sdk.api.tx.estimateFees(txInfo, [destAddress, amountUnit]);
|
||||||
|
|
||||||
|
return estimateFees.partialFee / 100;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
////// 3: SUBSTRATE CONNECTION //////
|
////// 3: SUBSTRATE CONNECTION //////
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
@ -714,7 +727,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
txOptions = [destAddress, false];
|
txOptions = [destAddress, false];
|
||||||
tx2 = 'api.tx.balances.transferAll("$destAddress", false)';
|
tx2 = 'api.tx.balances.transferAll("$destAddress", false)';
|
||||||
} else {
|
} else {
|
||||||
int amountUnit;
|
late int amountUnit;
|
||||||
if (isUdUnit) {
|
if (isUdUnit) {
|
||||||
palette = 'universalDividend';
|
palette = 'universalDividend';
|
||||||
call = 'transferUd';
|
call = 'transferUd';
|
||||||
|
|
|
@ -82,16 +82,18 @@ class MigrateIdentityScreen extends StatelessWidget {
|
||||||
if (status.data == null) {
|
if (status.data == null) {
|
||||||
return Column(children: [
|
return Column(children: [
|
||||||
const SizedBox(height: 80),
|
const SizedBox(height: 80),
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: const [
|
Row(
|
||||||
SizedBox(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
height: 35,
|
children: const [
|
||||||
width: 35,
|
SizedBox(
|
||||||
child: CircularProgressIndicator(
|
height: 35,
|
||||||
color: orangeC,
|
width: 35,
|
||||||
strokeWidth: 4,
|
child: CircularProgressIndicator(
|
||||||
),
|
color: orangeC,
|
||||||
),
|
strokeWidth: 4,
|
||||||
]),
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,10 @@ class WalletsHome extends StatelessWidget {
|
||||||
} else if (screenWidth >= 650) {
|
} else if (screenWidth >= 650) {
|
||||||
nTule = 3;
|
nTule = 3;
|
||||||
}
|
}
|
||||||
|
// Offset followDragAnchorStrategy(
|
||||||
|
// Draggable<Object> d, BuildContext context, Offset point) {
|
||||||
|
// return Offset(d.feedbackOffset.dx - 30, d.feedbackOffset.dy - 0);
|
||||||
|
// }
|
||||||
|
|
||||||
return CustomScrollView(slivers: <Widget>[
|
return CustomScrollView(slivers: <Widget>[
|
||||||
const SliverToBoxAdapter(child: SizedBox(height: 20)),
|
const SliverToBoxAdapter(child: SizedBox(height: 20)),
|
||||||
|
@ -235,10 +239,11 @@ class WalletsHome extends StatelessWidget {
|
||||||
LongPressDraggable<String>(
|
LongPressDraggable<String>(
|
||||||
delay: const Duration(milliseconds: 200),
|
delay: const Duration(milliseconds: 200),
|
||||||
data: repository.address!,
|
data: repository.address!,
|
||||||
// dragAnchorStrategy:
|
dragAnchorStrategy:
|
||||||
// (Draggable<Object> _, BuildContext __, Offset ___) =>
|
(Draggable<Object> _, BuildContext __, Offset ___) =>
|
||||||
// const Offset(40, 40),
|
const Offset(0, 0),
|
||||||
dragAnchorStrategy: pointerDragAnchorStrategy,
|
// feedbackOffset: const Offset(-500, -500),
|
||||||
|
// dragAnchorStrategy: childDragAnchorStrategy,
|
||||||
onDragStarted: () =>
|
onDragStarted: () =>
|
||||||
myWalletProvider.dragAddress = repository.address!,
|
myWalletProvider.dragAddress = repository.address!,
|
||||||
onDragEnd: (_) {
|
onDragEnd: (_) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ class QrCodeFullscreen extends StatelessWidget {
|
||||||
backgroundColor: color ?? Colors.black,
|
backgroundColor: color ?? Colors.black,
|
||||||
toolbarHeight: 60 * ratio,
|
toolbarHeight: 60 * ratio,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon:const Icon(Icons.arrow_back, color: orangeC),
|
icon: const Icon(Icons.arrow_back, color: orangeC),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -452,6 +452,8 @@ void paymentPopup(BuildContext context, String toAddress) {
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
final sub = Provider.of<SubstrateSdk>(homeContext, listen: false);
|
||||||
|
double fees = 0;
|
||||||
return StatefulBuilder(
|
return StatefulBuilder(
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
if (walletViewProvider.payAmount.text != '' &&
|
if (walletViewProvider.payAmount.text != '' &&
|
||||||
|
@ -588,12 +590,26 @@ void paymentPopup(BuildContext context, String toAddress) {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Text(
|
Row(
|
||||||
'amount'.tr(),
|
children: [
|
||||||
style: TextStyle(
|
Text(
|
||||||
fontSize: 19,
|
'amount'.tr(),
|
||||||
fontWeight: FontWeight.w500,
|
style: TextStyle(
|
||||||
color: Colors.grey[600]),
|
fontSize: 19,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Text(
|
||||||
|
'frais: $fees $currencyName',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: orangeC,
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
TextField(
|
TextField(
|
||||||
|
@ -606,7 +622,17 @@ void paymentPopup(BuildContext context, String toAddress) {
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
onChanged: (_) => setState(() {}),
|
onChanged: (_) async {
|
||||||
|
fees = await sub.txFees(
|
||||||
|
defaultWallet.address!,
|
||||||
|
toAddress,
|
||||||
|
double.parse(
|
||||||
|
walletViewProvider.payAmount.text == ''
|
||||||
|
? '0'
|
||||||
|
: walletViewProvider.payAmount.text));
|
||||||
|
log.d(fees);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
inputFormatters: <TextInputFormatter>[
|
inputFormatters: <TextInputFormatter>[
|
||||||
FilteringTextInputFormatter.deny(',',
|
FilteringTextInputFormatter.deny(',',
|
||||||
replacementString: '.'),
|
replacementString: '.'),
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: Pay with G1.
|
||||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.11+31
|
version: 0.0.11+32
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
|
|
Loading…
Reference in New Issue