Skip to content
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

refactor(send): execute prepared transaction in saga #5001

Merged
merged 7 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/fiatExchanges/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from 'src/transactions/types'
import Logger from 'src/utils/Logger'
import { Currency } from 'src/utils/currencies'
import { SerializableTransactionRequest } from 'src/viem/preparedTransactionSerialization'
import {
mockAccount,
mockCeurAddress,
Expand All @@ -37,6 +38,11 @@ const now = Date.now()
Date.now = jest.fn(() => now)

const loggerErrorSpy = jest.spyOn(Logger, 'error')
const mockPreparedTransaction: SerializableTransactionRequest = {
from: '0xfrom',
to: '0xto',
data: '0xdata',
}

describe(watchBidaliPaymentRequests, () => {
const amount = new BigNumber(20)
Expand Down Expand Up @@ -97,12 +103,7 @@ describe(watchBidaliPaymentRequests, () => {
'Some description (TEST_CHARGE_ID)',
recipient,
true,
{
fee: new BigNumber('0.01'),
gas: new BigNumber('0.01'),
gasPrice: new BigNumber('0.01'),
feeCurrency: expectedCurrency,
}
mockPreparedTransaction
)
)
.dispatch(sendPaymentSuccess({ amount, tokenId: expectedTokenId }))
Expand Down Expand Up @@ -157,12 +158,7 @@ describe(watchBidaliPaymentRequests, () => {
'Some description (TEST_CHARGE_ID)',
recipient,
true,
{
fee: new BigNumber('0.01'),
gas: new BigNumber('0.01'),
gasPrice: new BigNumber('0.01'),
feeCurrency: Currency.Dollar,
}
mockPreparedTransaction
)
)
.dispatch(sendPaymentFailure())
Expand Down
2 changes: 0 additions & 2 deletions src/send/SendConfirmation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ describe('SendConfirmation', () => {
'',
recipient,
false,
undefined,
getSerializablePreparedTransaction(mockPrepareTransactionsResultPossible.transactions[0])
)
)
Expand Down Expand Up @@ -293,7 +292,6 @@ describe('SendConfirmation', () => {
trimmedComment,
recipient,
false,
undefined,
getSerializablePreparedTransaction(mockPrepareTransactionsResultPossible.transactions[0])
),
])
Expand Down
1 change: 0 additions & 1 deletion src/send/SendConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ function SendConfirmation(props: Props) {
comment.trim(),
recipient,
fromModal,
undefined,
getSerializablePreparedTransaction(preparedTransaction)
)
)
Expand Down
8 changes: 2 additions & 6 deletions src/send/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import BigNumber from 'bignumber.js'
import { FeeInfo } from 'src/fees/saga'
import { Recipient } from 'src/recipients/recipient'
import { QrCode } from 'src/send/types'
import { Currency } from 'src/utils/currencies'
Expand Down Expand Up @@ -47,8 +46,7 @@ export interface SendPaymentAction {
comment: string
recipient: Recipient
fromModal: boolean
feeInfo?: FeeInfo
preparedTransaction?: SerializableTransactionRequest
preparedTransaction: SerializableTransactionRequest
}

export interface SendPaymentSuccessAction {
Expand Down Expand Up @@ -121,8 +119,7 @@ export const sendPayment = (
comment: string,
recipient: Recipient,
fromModal: boolean,
feeInfo?: FeeInfo,
preparedTransaction?: SerializableTransactionRequest
preparedTransaction: SerializableTransactionRequest
): SendPaymentAction => ({
type: Actions.SEND_PAYMENT,
amount,
Expand All @@ -131,7 +128,6 @@ export const sendPayment = (
comment,
recipient,
fromModal,
feeInfo,
preparedTransaction,
})

Expand Down
Loading
Loading