diff --git a/packages/espressocash_app/lib/features/analytics/analytics_manager.dart b/packages/espressocash_app/lib/features/analytics/analytics_manager.dart index 446970d2f0..0ff0c4ae6a 100644 --- a/packages/espressocash_app/lib/features/analytics/analytics_manager.dart +++ b/packages/espressocash_app/lib/features/analytics/analytics_manager.dart @@ -134,4 +134,6 @@ class AnalyticsManager { 'id': id, }, ); + + void ataCreated() => _analytics.track('ataCreated'); } diff --git a/packages/espressocash_app/lib/features/escrow_payments/create_incoming_escrow.dart b/packages/espressocash_app/lib/features/escrow_payments/create_incoming_escrow.dart index 463ff4e670..c9e81c192b 100644 --- a/packages/espressocash_app/lib/features/escrow_payments/create_incoming_escrow.dart +++ b/packages/espressocash_app/lib/features/escrow_payments/create_incoming_escrow.dart @@ -6,6 +6,7 @@ import 'package:solana/solana.dart'; import '../../utils/transactions.dart'; import '../accounts/models/ec_wallet.dart'; +import '../analytics/analytics_manager.dart'; import '../priority_fees/services/add_priority_fees.dart'; import '../tokens/token.dart'; import '../transactions/services/resign_tx.dart'; @@ -18,11 +19,13 @@ class CreateIncomingEscrow { this._client, this._addPriorityFees, this._ecClient, + this._analyticsManager, ); final SolanaClient _client; final AddPriorityFees _addPriorityFees; final EspressoCashClient _ecClient; + final AnalyticsManager _analyticsManager; Future call({ required Ed25519HDKeyPair escrowAccount, @@ -67,7 +70,18 @@ class CreateIncomingEscrow { mint: mint, ); - instructions.add(iCreateATA); + final newAuthorityIx = TokenInstruction.setAuthority( + mintOrAccount: ataReceiver, + authorityType: AuthorityType.closeAccount, + currentAuthority: ataReceiver, + newAuthority: platformAccount, + ); + + instructions + ..add(iCreateATA) + ..add(newAuthorityIx); + + _analyticsManager.ataCreated(); } final escrowIx = await EscrowInstruction.completeEscrow( @@ -79,25 +93,6 @@ class CreateIncomingEscrow { instructions.add(escrowIx); - final int fee; - if (shouldCreateAta) { - final transactionFees = await _ecClient.getFees(); - fee = transactionFees.escrowPaymentAtaFee; - final ataPlatform = await findAssociatedTokenAddress( - owner: platformAccount, - mint: mint, - ); - final iTransferFee = TokenInstruction.transfer( - amount: fee, - source: ataReceiver, - destination: ataPlatform, - owner: receiverAccount, - ); - instructions.add(iTransferFee); - } else { - fee = 0; - } - final message = Message( instructions: [ SystemInstruction.advanceNonceAccount( diff --git a/packages/espressocash_app/lib/features/incoming_link_payments/data/ilp_repository.dart b/packages/espressocash_app/lib/features/incoming_link_payments/data/ilp_repository.dart index 9dbdb3b114..1b3f8ba30b 100644 --- a/packages/espressocash_app/lib/features/incoming_link_payments/data/ilp_repository.dart +++ b/packages/espressocash_app/lib/features/incoming_link_payments/data/ilp_repository.dart @@ -11,8 +11,6 @@ import 'package:solana/encoder.dart'; import '../../../data/db/db.dart'; import '../../../data/db/mixins.dart'; import '../../accounts/auth_scope.dart'; -import '../../currency/models/amount.dart'; -import '../../currency/models/currency.dart'; import '../../escrow/models/escrow_private_key.dart'; import '../../transactions/models/tx_results.dart'; import '../models/incoming_link_payment.dart'; @@ -104,13 +102,8 @@ extension on ILPStatusDto { signature: row.txId!, ); case ILPStatusDto.success: - final feeAmount = row.feeAmount; - return ILPStatus.success( tx: tx ?? StubSignedTx(txId!), - fee: feeAmount != null - ? CryptoAmount(value: feeAmount, cryptoCurrency: Currency.usdc) - : null, ); case ILPStatusDto.txFailure: return ILPStatus.txFailure( @@ -129,10 +122,6 @@ extension on IncomingLinkPayment { tx: status.toTx(), txId: status.toTxId(), txFailureReason: status.toTxFailureReason(), - feeAmount: switch (status) { - ILPStatusSuccess(:final fee) => fee?.value, - _ => null, - }, ); } diff --git a/packages/espressocash_app/lib/features/incoming_link_payments/models/incoming_link_payment.dart b/packages/espressocash_app/lib/features/incoming_link_payments/models/incoming_link_payment.dart index 05925a10eb..7708d260da 100644 --- a/packages/espressocash_app/lib/features/incoming_link_payments/models/incoming_link_payment.dart +++ b/packages/espressocash_app/lib/features/incoming_link_payments/models/incoming_link_payment.dart @@ -1,7 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:solana/encoder.dart'; -import '../../currency/models/amount.dart'; import '../../escrow/models/escrow_private_key.dart'; import '../../transactions/models/tx_results.dart'; @@ -31,7 +30,6 @@ sealed class ILPStatus with _$ILPStatus { /// Final state. Tx is successfully confirmed and payment is claimed. const factory ILPStatus.success({ required SignedTx tx, - required CryptoAmount? fee, }) = ILPStatusSuccess; /// Failed to create the tx, a new tx should be created. diff --git a/packages/espressocash_app/lib/features/incoming_link_payments/screens/incoming_link_payment_screen.dart b/packages/espressocash_app/lib/features/incoming_link_payments/screens/incoming_link_payment_screen.dart index b47983651c..fd6f3aac86 100644 --- a/packages/espressocash_app/lib/features/incoming_link_payments/screens/incoming_link_payment_screen.dart +++ b/packages/espressocash_app/lib/features/incoming_link_payments/screens/incoming_link_payment_screen.dart @@ -1,14 +1,7 @@ -import 'package:dfunc/dfunc.dart'; import 'package:flutter/material.dart'; import '../../../di.dart'; -import '../../../l10n/device_locale.dart'; import '../../../l10n/l10n.dart'; -import '../../../ui/colors.dart'; -import '../../../ui/info_icon.dart'; -import '../../../ui/message_info_widget.dart'; -import '../../conversion_rates/widgets/extensions.dart'; -import '../../currency/models/amount.dart'; import '../../transactions/models/tx_results.dart'; import '../../transactions/widgets/transfer_error.dart'; import '../../transactions/widgets/transfer_progress.dart'; @@ -60,7 +53,6 @@ class _IncomingLinkPaymentScreenState extends State { success: (e) => TransferSuccess( onBack: () => Navigator.pop(context), onOkPressed: () => Navigator.pop(context), - content: e.fee?.let(_FeeNotice.new), statusContent: context.l10n.moneyReceived, ), txFailure: (it) => it.reason == TxFailureReason.escrowFailure @@ -75,47 +67,3 @@ class _IncomingLinkPaymentScreenState extends State { }, ); } - -class _FeeNotice extends StatelessWidget { - const _FeeNotice(this.amount); - - final CryptoAmount amount; - - @override - Widget build(BuildContext context) => Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - CpMessageInfoWidget( - backgroundColor: Colors.black, - padding: const EdgeInsets.all(18), - content: Row( - children: [ - const CircleAvatar( - maxRadius: 14, - backgroundColor: CpColors.yellowColor, - child: CpInfoIcon( - iconColor: CpColors.darkBackgroundColor, - ), - ), - const SizedBox(width: 16), - Expanded( - child: Text( - context.l10n - .incomingUsdcFeeNotice(amount.format(context.locale)), - style: const TextStyle( - color: Colors.white, - fontSize: 14.50, - fontWeight: FontWeight.w500, - height: 0, - ), - ), - ), - ], - ), - ), - const SizedBox(height: 32), - ], - ), - ); -} diff --git a/packages/espressocash_app/lib/features/incoming_link_payments/services/ilp_service.dart b/packages/espressocash_app/lib/features/incoming_link_payments/services/ilp_service.dart index 8ce87c66f0..6a065bc3ca 100644 --- a/packages/espressocash_app/lib/features/incoming_link_payments/services/ilp_service.dart +++ b/packages/espressocash_app/lib/features/incoming_link_payments/services/ilp_service.dart @@ -5,15 +5,12 @@ import 'package:espressocash_api/espressocash_api.dart'; import 'package:get_it/get_it.dart'; import 'package:injectable/injectable.dart'; import 'package:rxdart/rxdart.dart'; -import 'package:solana/encoder.dart'; import 'package:solana/solana.dart'; import 'package:uuid/uuid.dart'; import '../../accounts/auth_scope.dart'; import '../../accounts/models/ec_wallet.dart'; import '../../balances/services/refresh_balance.dart'; -import '../../currency/models/amount.dart'; -import '../../currency/models/currency.dart'; import '../../escrow/models/escrow_private_key.dart'; import '../../escrow_payments/create_incoming_escrow.dart'; import '../../escrow_payments/escrow_exception.dart'; @@ -147,23 +144,11 @@ class ILPService implements Disposable { await _txConfirm(txId: status.signature); - int? fee; - try { - fee = status.tx.containsAta - ? await _ecClient.getFees().then((value) => value.escrowPaymentAtaFee) - : null; - } on Object { - fee = null; - } - _refreshBalance(); return payment.copyWith( status: ILPStatus.success( tx: status.tx, - fee: fee?.let( - (fee) => CryptoAmount(value: fee, cryptoCurrency: Currency.usdc), - ), ), ); } @@ -173,10 +158,3 @@ class ILPService implements Disposable { await Future.wait(_subscriptions.values.map((it) => it.cancel())); } } - -extension on SignedTx { - bool get containsAta => decompileMessage().let( - (m) => m.instructions - .any((ix) => ix.programId == AssociatedTokenAccountProgram.id), - ); -} diff --git a/packages/espressocash_app/lib/l10n/intl_es.arb b/packages/espressocash_app/lib/l10n/intl_es.arb index 21304af8bb..7b24ba65f5 100644 --- a/packages/espressocash_app/lib/l10n/intl_es.arb +++ b/packages/espressocash_app/lib/l10n/intl_es.arb @@ -150,8 +150,6 @@ "@help": {}, "incomingSplitKeyPayments_lblByClickingTheSecondLink": "Al hacer clic en el segundo enlace del mensaje o en el botón de cancelación, aceptas nuestra ", "@incomingSplitKeyPayments_lblByClickingTheSecondLink": {}, - "incomingUsdcFeeNotice": "Se te ha cobrado una tarifa única de $0.10 por tu primera transacción entrante.", - "@incomingUsdcFeeNotice": {}, "incorrectPasscode": "código de acceso incorrecto.Volver a intentarlo", "@incorrectPasscode": {}, "insufficientFundsForFeeMessage": "No tienes suficiente {feeToken} para pagar la tarifa de la red, necesita al menos {amount}.", diff --git a/packages/espressocash_app/lib/l10n/intl_fr.arb b/packages/espressocash_app/lib/l10n/intl_fr.arb index 8268388074..0caca1875c 100644 --- a/packages/espressocash_app/lib/l10n/intl_fr.arb +++ b/packages/espressocash_app/lib/l10n/intl_fr.arb @@ -150,8 +150,6 @@ "@help": {}, "incomingSplitKeyPayments_lblByClickingTheSecondLink": "En cliquant sur le deuxième lien du message ou sur le bouton d'annulation, vous acceptez nos ", "@incomingSplitKeyPayments_lblByClickingTheSecondLink": {}, - "incomingUsdcFeeNotice": "Un frais unique de {amount} a été prélevé pour votre première transaction entrante.", - "@incomingUsdcFeeNotice": {}, "incorrectPasscode": "Code d'accès incorrect. Réessayer à nouveau", "@incorrectPasscode": {}, "insufficientFundsForFeeMessage": "Vous n'avez pas assez {feeToken} pour payer les frais de réseau, vous avez besoin d'au moins {amount}.", diff --git a/packages/espressocash_app/lib/l10n/intl_ru.arb b/packages/espressocash_app/lib/l10n/intl_ru.arb index 2c4a9d1e6c..fbdf571895 100644 --- a/packages/espressocash_app/lib/l10n/intl_ru.arb +++ b/packages/espressocash_app/lib/l10n/intl_ru.arb @@ -150,8 +150,6 @@ "@help": {}, "incomingSplitKeyPayments_lblByClickingTheSecondLink": "Нажав на вторую ссылку в сообщении или кнопку \"Отмена\", вы соглашаетесь с нашими", "@incomingSplitKeyPayments_lblByClickingTheSecondLink": {}, - "incomingUsdcFeeNotice": "С вас была снята единовременная комиссия в размере {amount} за вашу первую входящую транзакцию.", - "@incomingUsdcFeeNotice": {}, "incorrectPasscode": "Неверный пин-код. Попробуйте еще раз.", "@incorrectPasscode": {}, "insufficientFundsForFeeMessage": "У вас недостаточно {feeToken} для оплаты комиссии сети, вам нужно как минимум {amount}.", diff --git a/packages/espressocash_app/test/stub_analytics_manager.dart b/packages/espressocash_app/test/stub_analytics_manager.dart index 4ff8e4ff0b..1e649201a5 100644 --- a/packages/espressocash_app/test/stub_analytics_manager.dart +++ b/packages/espressocash_app/test/stub_analytics_manager.dart @@ -63,4 +63,7 @@ class StubAnalyticsManager implements AnalyticsManager { @override void rampOpened({required RampPartner partner, required String rampType}) {} + + @override + void ataCreated() {} }