fix: remove account creation fee check

This commit is contained in:
poka 2024-04-21 23:02:22 +02:00
parent 56a6213e9c
commit 22e7cf17b2
3 changed files with 36 additions and 20 deletions

View File

@ -516,7 +516,6 @@ class SubstrateSdk with ChangeNotifier {
const currencyParametersNames = {
'ss58': 'system.ss58Prefix.words',
'minCertForMembership': 'wot.minCertForMembership.words',
'newAccountPrice': 'account.newAccountPrice.words',
'existentialDeposit': 'balances.existentialDeposit.words',
'certPeriod': 'cert.certPeriod.words',
'certMaxByIssuer': 'cert.maxByIssuer.words',

View File

@ -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
.sort((a, b) => a.derivation!.compareTo(b.derivation!)));
@ -74,27 +108,10 @@ void paymentPopup(BuildContext context, String toAddress, String? username) {
context: context,
builder: (BuildContext context) {
final sub = Provider.of<SubstrateSdk>(homeContext, listen: false);
final walletOptions =
Provider.of<WalletOptionsProvider>(context, listen: false);
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
if (walletViewProvider.payAmount.text != '' &&
(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;
}
canValidate = canValidatePayment();
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
return Padding(
padding: EdgeInsets.only(

View File

@ -5,7 +5,7 @@ description: Pay with G1.
# 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
version: 0.1.6+73
version: 0.1.6+74
environment:
sdk: ">=2.12.0 <3.0.0"