Skip to content

Commit

Permalink
fix: Revert constants, add fallback for pending tx notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Aug 29, 2023
1 parent 88c6a13 commit af34a83
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/components/tx-flow/flows/ExecuteBatch/ReviewBatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const ReviewBatch = ({ params }: { params: ExecuteBatchFlowProps }) => {
? { maxFeePerGas: maxFeePerGas?.toString(), maxPriorityFeePerGas: maxPriorityFeePerGas?.toString() }
: { gasPrice: maxFeePerGas?.toString() }

const humanDescription = 'Batch transaction'
const FALLBACK_HUMAN_DESCRIPTION = 'Batch transaction'

await dispatchBatchExecution(
txsWithDetails,
Expand All @@ -90,23 +90,23 @@ export const ReviewBatch = ({ params }: { params: ExecuteBatchFlowProps }) => {
onboard,
safe.chainId,
safe.address.value,
humanDescription,
overrides,
FALLBACK_HUMAN_DESCRIPTION,
)
}

const onRelay = async () => {
if (!multiSendTxData || !multiSendContract || !txsWithDetails) return

const humanDescription = 'Batch transaction'
const FALLBACK_HUMAN_DESCRIPTION = 'Batch transaction'

await dispatchBatchExecutionRelay(
txsWithDetails,
multiSendContract,
multiSendTxData,
safe.chainId,
safe.address.value,
humanDescription,
FALLBACK_HUMAN_DESCRIPTION,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@ const ReviewSpendingLimitTx = ({
setSubmitError(undefined)

const txOptions = getTxOptions(advancedParams, currentChain)
const humanDescription = 'Module transaction'
const FALLBACK_HUMAN_DESCRIPTION = 'Module transaction'

try {
await dispatchSpendingLimitTxExecution(txParams, txOptions, onboard, safe.chainId, safeAddress, humanDescription)
await dispatchSpendingLimitTxExecution(
txParams,
txOptions,
onboard,
safe.chainId,
safeAddress,
FALLBACK_HUMAN_DESCRIPTION,
)
onSubmit()
setTxFlow(undefined)
} catch (_err) {
Expand Down
5 changes: 3 additions & 2 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import chains from './chains'
export const IS_PRODUCTION = !!process.env.NEXT_PUBLIC_IS_PRODUCTION
export const IS_DEV = process.env.NODE_ENV === 'development'

export const GATEWAY_URL_PRODUCTION = process.env.NEXT_PUBLIC_GATEWAY_URL_PRODUCTION || 'http://localhost:3030'
export const GATEWAY_URL_STAGING = process.env.NEXT_PUBLIC_GATEWAY_URL_STAGING || 'http://localhost:3030'
export const GATEWAY_URL_PRODUCTION =
process.env.NEXT_PUBLIC_GATEWAY_URL_PRODUCTION || 'https://safe-client.safe.global'
export const GATEWAY_URL_STAGING = process.env.NEXT_PUBLIC_GATEWAY_URL_STAGING || 'https://safe-client.staging.5afe.dev'

// Magic numbers
export const POLLING_INTERVAL = 15_000
Expand Down
2 changes: 1 addition & 1 deletion src/services/tx/tx-sender/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ export const dispatchBatchExecution = async (
onboard: OnboardAPI,
chainId: SafeInfo['chainId'],
safeAddress: string,
humanDescription?: string,
overrides?: PayableOverrides,
humanDescription?: string,
) => {
const groupKey = multiSendTxData

Expand Down
9 changes: 7 additions & 2 deletions src/store/txHistorySlice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { listenerMiddlewareInstance } from '@/store'
import type { TransactionListPage } from '@safe-global/safe-gateway-typescript-sdk'
import { isTransactionListItem } from '@/utils/transaction-guards'
import { isMultisigExecutionInfo, isTransactionListItem } from '@/utils/transaction-guards'
import { txDispatch, TxEvent } from '@/services/tx/txEvents'
import { selectPendingTxs } from './pendingTxsSlice'
import { makeLoadableSlice } from './common'
Expand Down Expand Up @@ -28,10 +28,15 @@ export const txHistoryListener = (listenerMiddleware: typeof listenerMiddlewareI
const txId = result.transaction.id

if (pendingTxs[txId]) {
const HUMAN_DESCRIPTION_FALLBACK =
'Transaction' +
(isMultisigExecutionInfo(result.transaction.executionInfo) && `#${result.transaction.executionInfo.nonce}`)
const humanDescription = result.transaction.txInfo?.humanDescription || HUMAN_DESCRIPTION_FALLBACK

txDispatch(TxEvent.SUCCESS, {
txId,
groupKey: pendingTxs[txId].groupKey,
humanDescription: result.transaction.txInfo?.humanDescription,
humanDescription,
})
}
}
Expand Down

0 comments on commit af34a83

Please sign in to comment.