fix: remove account creation fee check
This commit is contained in:
parent
56a6213e9c
commit
22e7cf17b2
|
@ -516,7 +516,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
const currencyParametersNames = {
|
const currencyParametersNames = {
|
||||||
'ss58': 'system.ss58Prefix.words',
|
'ss58': 'system.ss58Prefix.words',
|
||||||
'minCertForMembership': 'wot.minCertForMembership.words',
|
'minCertForMembership': 'wot.minCertForMembership.words',
|
||||||
'newAccountPrice': 'account.newAccountPrice.words',
|
|
||||||
'existentialDeposit': 'balances.existentialDeposit.words',
|
'existentialDeposit': 'balances.existentialDeposit.words',
|
||||||
'certPeriod': 'cert.certPeriod.words',
|
'certPeriod': 'cert.certPeriod.words',
|
||||||
'certMaxByIssuer': 'cert.maxByIssuer.words',
|
'certMaxByIssuer': 'cert.maxByIssuer.words',
|
||||||
|
|
|
@ -60,6 +60,40 @@ void paymentPopup(BuildContext context, String toAddress, String? username) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool canValidatePayment() {
|
||||||
|
final payAmount = walletViewProvider.payAmount.text;
|
||||||
|
if (payAmount.isEmpty) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final walletOptions =
|
||||||
|
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||||
|
final defaultWalletBalance =
|
||||||
|
walletOptions.balanceCache[defaultWallet.address] ?? 0;
|
||||||
|
|
||||||
|
const existentialDeposit = 2;
|
||||||
|
final double payAmountValue = double.parse(payAmount);
|
||||||
|
final double toAddressBalance = walletOptions.balanceCache[toAddress] ?? 0;
|
||||||
|
|
||||||
|
// Prevent sending more than the balance with existential deposit
|
||||||
|
if (payAmountValue / balanceRatio >
|
||||||
|
defaultWalletBalance - existentialDeposit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent sending to self
|
||||||
|
if (toAddress == defaultWallet.address) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent sending to an empty wallet with less than 2 (existential deposit)
|
||||||
|
if (toAddressBalance == 0 &&
|
||||||
|
payAmountValue < existentialDeposit / balanceRatio) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
myWalletProvider.readAllWallets().then((value) => myWalletProvider.listWallets
|
myWalletProvider.readAllWallets().then((value) => myWalletProvider.listWallets
|
||||||
.sort((a, b) => a.derivation!.compareTo(b.derivation!)));
|
.sort((a, b) => a.derivation!.compareTo(b.derivation!)));
|
||||||
|
|
||||||
|
@ -74,27 +108,10 @@ void paymentPopup(BuildContext context, String toAddress, String? username) {
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
final sub = Provider.of<SubstrateSdk>(homeContext, listen: false);
|
final sub = Provider.of<SubstrateSdk>(homeContext, listen: false);
|
||||||
final walletOptions =
|
|
||||||
Provider.of<WalletOptionsProvider>(context, listen: false);
|
|
||||||
|
|
||||||
return StatefulBuilder(
|
return StatefulBuilder(
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
if (walletViewProvider.payAmount.text != '' &&
|
canValidate = canValidatePayment();
|
||||||
(double.parse(walletViewProvider.payAmount.text) +
|
|
||||||
2 / balanceRatio) <=
|
|
||||||
(walletOptions.balanceCache[defaultWallet.address] ?? 0) &&
|
|
||||||
toAddress != defaultWallet.address) {
|
|
||||||
if ((walletOptions.balanceCache[toAddress] == 0 ||
|
|
||||||
walletOptions.balanceCache[toAddress] == null) &&
|
|
||||||
double.parse(walletViewProvider.payAmount.text) <
|
|
||||||
5 / balanceRatio) {
|
|
||||||
canValidate = false;
|
|
||||||
} else {
|
|
||||||
canValidate = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
canValidate = false;
|
|
||||||
}
|
|
||||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
|
|
|
@ -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.1.6+73
|
version: 0.1.6+74
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
|
Loading…
Reference in New Issue