-
Notifications
You must be signed in to change notification settings - Fork 43
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
IOS-8312 solana rent notification #4302
IOS-8312 solana rent notification #4302
Conversation
} | ||
.eraseToAnyPublisher() | ||
let amountValue = Amount(with: wallet.blockchain, value: mainAccountRentExemption) | ||
return CurrentValueSubject(amountValue).eraseToAnyPublisher() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Интересная запись, а почему не Just()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поправил
@@ -300,6 +292,29 @@ extension SolanaWalletManager: RentProvider { | |||
} | |||
} | |||
|
|||
extension SolanaWalletManager: TransactionValidator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше бы конечно сделать как и в остальных, просто для консистенстности, так как ни один WalletManager сейчас не реализует TransactionValidator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поправил
// MARK: - RentExtemptionRestrictable e.g. SolanaWalletManager | ||
|
||
extension TransactionValidator where Self: RentExtemptionRestrictable { | ||
func validate(amount: Amount, fee: Fee, destination: DestinationType) async throws { | ||
Log.debug("TransactionValidator \(self) doesn't checking destination. If you want it, make our own implementation") | ||
try validate(amount: amount, fee: fee) | ||
} | ||
|
||
func validate(amount: Amount, fee: Fee) throws { | ||
try validateAmounts(amount: amount, fee: fee.amount) | ||
try validateRentExtemption(amount: amount, fee: fee.amount) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
На токене я сам проверю |
*/ | ||
.flatMap { service, info in | ||
service.minimalBalanceForRentExemption(dataLength: info.space ?? 0) | ||
.tryMap { rentExemption in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а зачем tryMap
, а не просто map
?
|
||
let remainingBalance = balance.value - (amount.value + fee.value) | ||
|
||
if remainingBalance > 0, remainingBalance < minimalAmountForRentExemption.value { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а тут точно нужна проверка что больше 0?
Кстати, если сейчас выводить все, тогда остаточный баланс будет 0 и проверка не сработает. Не звучит как норм.
Вообще выглядит будто надо оставить только 2 проверку или же сделать в начале проверку на то что остаток 0 или больше 0, а потом уже проверку на минималку.
А то это же можно вызвать и не через TransactionValidator
и тогда отрицательное значение и 0 будет валидным остатоком
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в ноль выводить можно, не указал в описании
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавил доп проверку
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вообще вроде как это должно в validateAmounts проверяться, но хз, лишним не будет наверно
601f686
129ee96
Добавил нотификацию о недопустимости вывода суммы после которой остаток будет меньше чем minimalBalanceForRentExemption для соланы. Выводить в 0 также допустимо
