Skip to content

Commit

Permalink
Merge pull request #1518 from p2p-org/feature/pwn-9438
Browse files Browse the repository at this point in the history
[PWN-9438] feat: Send as SendViaLink
  • Loading branch information
bigearsenal authored Jul 31, 2023
2 parents 0175ca8 + 383cd3b commit 8ca4a15
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Copyright 2022 P2P Validator Authors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.

import FeeRelayerSwift
import Foundation
import KeyAppKitCore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public class SendFeeCalculatorImpl: SendFeeCalculator {
accountBalances: isAssociatedTokenUnregister ? context.minimumTokenAccountBalance : 0
)

// TODO: - Remove later: Send as SendViaLink when link creation available
if !context.usageStatus.reachedLimitLinkCreation {
return .zero
}

// when free transaction is not available and user is paying with sol, let him do this the normal way (don't use
// fee relayer)
if isFreeTransactionNotAvailableAndUserIsPayingWithSOL(context, payingTokenMint: payingTokenMint) {
Expand Down
2 changes: 2 additions & 0 deletions p2p_wallet/Scenes/Main/Send/Input/SendInputViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ private extension SendInputViewModel {
isFakeSendTransaction: isFakeSendTransaction,
isFakeSendTransactionError: isFakeSendTransactionError,
isFakeSendTransactionNetworkError: isFakeSendTransactionNetworkError,
isLinkCreationAvailable: stateMachine.currentState.feeRelayerContext?.usageStatus
.reachedLimitLinkCreation == false,
recipient: recipient,
sendViaLinkSeed: sendViaLinkSeed,
amount: amountInToken,
Expand Down
3 changes: 2 additions & 1 deletion p2p_wallet/Scenes/Main/Send/Models/SendTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct SendTransaction: RawTransactionType {
let isFakeSendTransaction: Bool
let isFakeSendTransactionError: Bool
let isFakeSendTransactionNetworkError: Bool
let isLinkCreationAvailable: Bool
let recipient: Recipient
let sendViaLinkSeed: String?
let amount: Double
Expand Down Expand Up @@ -84,7 +85,7 @@ struct SendTransaction: RawTransactionType {
receiver: address,
amount: amount,
feeWallet: payingFeeWallet,
ignoreTopUp: isSendingViaLink,
ignoreTopUp: isSendingViaLink || isLinkCreationAvailable,
memo: isSendingViaLink ? .secretConfig("SEND_VIA_LINK_MEMO_PREFIX")! + "-send" : nil,
operationType: isSendingViaLink ? .sendViaLink : .transfer
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct SendTransactionStatusView_Previews: PreviewProvider {
isFakeSendTransaction: false,
isFakeSendTransactionError: false,
isFakeSendTransactionNetworkError: false,
isLinkCreationAvailable: true,
recipient: .init(address: "", category: .solanaAddress, attributes: .funds),
sendViaLinkSeed: nil,
amount: 0.01,
Expand Down

0 comments on commit 8ca4a15

Please sign in to comment.