Skip to content

Commit

Permalink
ci(release): publish latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
hello-happy-puppy committed Nov 26, 2024
1 parent 463d627 commit a6ca7d5
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 74 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mobile/1.39
extension/1.9.0
3 changes: 3 additions & 0 deletions apps/extension/src/app/datadog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export async function initializeDatadog(appName: string): Promise<void> {
// otherwise DataDog will ignore error events
event.view.url = event.view.url.replace(/^chrome-extension:\/\/[a-z]{32}\//i, '')
if (event.error && event.type === 'error') {
if (event.error.source === 'console') {
return false
}
Object.defineProperty(event.error, 'stack', {
value: event.error.stack?.replace(/chrome-extension:\/\/[a-z]{32}/gi, ''),
writable: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BigNumber } from 'ethers'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { useDappLastChainId } from 'src/app/features/dapp/hooks'
import { DappRequestContent } from 'src/app/features/dappRequests/DappRequestContent'
import { useDappRequestQueueContext } from 'src/app/features/dappRequests/DappRequestQueueContext'
import { isNonZeroBigNumber } from 'src/app/features/dappRequests/requestContent/EthSend/Swap/utils'
import { SendTransactionRequest } from 'src/app/features/dappRequests/types/DappRequestTypes'
import { useCopyToClipboard } from 'src/app/hooks/useOnCopyToClipboard'
import { Anchor, Flex, Text, TouchableArea } from 'ui/src'
Expand Down Expand Up @@ -55,6 +55,7 @@ export function FallbackEthSendRequestContent({
)
const { parsedTransactionData } = useNoYoloParser(dappRequest.transaction, chainId)
const transactionCurrencies = useTransactionCurrencies({ chainId, to: toAddress, parsedTransactionData })
const showSpendingEthDetails = isNonZeroBigNumber(sending) && chainId

return (
<DappRequestContent
Expand All @@ -74,9 +75,7 @@ export function FallbackEthSendRequestContent({
p="$spacing16"
width="100%"
>
{sending && !BigNumber.from(sending).eq(0) && chainId && (
<SpendingEthDetails chainId={chainId} value={sending} />
)}
{showSpendingEthDetails && <SpendingEthDetails chainId={chainId} value={sending} />}
{transactionCurrencies?.map((currencyInfo, i) => (
<SpendingDetails
key={currencyInfo.currencyId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,6 @@ function extractTokenAddresses(commands: UniversalRouterCommand[]): {
return { inputAddress, outputAddress }
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isZeroBigNumber(bigNumberObj: any): boolean {
// The true type of bigNumberObj is { type: string; hex: string } but param.value is any type
try {
if (!bigNumberObj) {
return true
}
const bigNumber = BigNumber.from(bigNumberObj.hex)
return bigNumber.isZero()
} catch (error) {
return true // Treat as zero if there's any error
}
}

function getTokenAmounts(commands: UniversalRouterCommand[]): {
inputValue: string
outputValue: string
Expand Down Expand Up @@ -205,7 +191,9 @@ function getTokenAmounts(commands: UniversalRouterCommand[]): {
const inputValue = firstAmountInParam?.value
const fallbackOutputValue = sweepAmountOutParam?.value || unwrapWethAmountOutParam?.value
const outputValue =
fallbackOutputValue && isZeroBigNumber(lastAmountOutParam?.value) ? fallbackOutputValue : lastAmountOutParam?.value
fallbackOutputValue && isZeroBigNumberParam(lastAmountOutParam?.value)
? fallbackOutputValue
: lastAmountOutParam?.value

return {
inputValue: inputValue || '0', // Safe due to assert
Expand Down Expand Up @@ -384,3 +372,34 @@ export function getTokenDetailsFromV4SwapCommands(command: UniversalRouterComman

return { inputAddress, outputAddress, inputValue, outputValue }
}

export function isNonZeroBigNumber(value: string | undefined): boolean {
if (!value) {
return false
}

try {
const valueBN = BigNumber.from(value)
return !valueBN.isZero()
} catch {
return false
}
}

interface BigNumberParam {
type: string
hex: string
}

const isBigNumberParam = (obj: unknown): obj is BigNumberParam =>
typeof obj === 'object' && !!obj && 'hex' in obj && typeof (obj as BigNumberParam).hex === 'string'

// We have to type this as unknown because BigNumberSchema is any (as defined in apps/extension/src/app/features/dappRequests/types/EthersTypes.ts)
function isZeroBigNumberParam(bigNumberObj: unknown): boolean {
// We treat an undefined or badly formatted param as zero
if (!bigNumberObj || !isBigNumberParam(bigNumberObj)) {
return true
}

return !isNonZeroBigNumber(bigNumberObj.hex)
}
17 changes: 1 addition & 16 deletions apps/mobile/src/components/explore/SortButton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SortButton } from 'src/components/explore/SortButton'
import { act, render } from 'src/test/test-utils'
import { render } from 'src/test/test-utils'
import { CustomRankingType, ExploreOrderBy, RankingType } from 'wallet/src/features/wallet/types'

jest.mock('react-native-context-menu-view', () => {
Expand All @@ -9,21 +9,9 @@ jest.mock('react-native-context-menu-view', () => {
})

describe('SortButton', () => {
beforeEach(() => {
jest.useFakeTimers()
})

afterEach(() => {
jest.useRealTimers()
})

it('renders without error', () => {
const tree = render(<SortButton orderBy={RankingType.Volume} />)

act(async () => {
jest.runAllTimers()
})

expect(tree).toMatchSnapshot()
})

Expand All @@ -46,9 +34,6 @@ describe('SortButton', () => {
describe.each(cases)('when ordering by $test', ({ orderBy, label }) => {
it(`renders ${label} as the selected option`, () => {
const { queryByText } = render(<SortButton orderBy={orderBy} />)
act(async () => {
jest.runAllTimers()
})
const selectedOption = queryByText(label)

expect(selectedOption).toBeTruthy()
Expand Down
13 changes: 2 additions & 11 deletions apps/mobile/src/utils/useOpenBackupReminderModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,22 @@ import { selectBackupReminderLastSeenTs } from 'wallet/src/features/behaviorHist
import { Account } from 'wallet/src/features/wallet/accounts/types'

const BACKUP_REMINDER_DELAY_MS = 20 * ONE_SECOND_MS
const BACKUP_REMINDER_MIN_TIMEOUT_MS = 2 * ONE_SECOND_MS

export function useOpenBackupReminderModal(activeAccount: Account): void {
const dispatch = useDispatch()
const txns = useSelectAddressTransactions(activeAccount.address)
const { isOpen: isBackupReminderModalOpen } = useSelector(selectModalState(ModalName.BackupReminder))
const { isOpen: isBackupReminderWarningModalOpen } = useSelector(selectModalState(ModalName.BackupReminderWarning))
const backupReminderLastSeenTs = useSelector(selectBackupReminderLastSeenTs)

const isSignerAccount = activeAccount.type === AccountType.SignerMnemonic
const shouldOpenBackupReminderModal =
!isBackupReminderModalOpen &&
!isBackupReminderWarningModalOpen &&
isSignerAccount &&
!!txns &&
!activeAccount.backups
!isBackupReminderModalOpen && isSignerAccount && !!txns && !activeAccount.backups

useEffect(() => {
if (shouldOpenBackupReminderModal && backupReminderLastSeenTs === undefined) {
// Get the min addedTime from the transactions (i.e. the user's first transaction)
const minAddedTime = Math.min(...txns.map((txn) => txn.addedTime))
const remainingTimeMs = Math.max(
minAddedTime + BACKUP_REMINDER_DELAY_MS - Date.now(),
BACKUP_REMINDER_MIN_TIMEOUT_MS,
)
const remainingTimeMs = Math.max(minAddedTime + BACKUP_REMINDER_DELAY_MS - Date.now(), 0)
const timeoutId = setTimeout(() => {
dispatch(openModal({ name: ModalName.BackupReminder }))
}, remainingTimeMs)
Expand Down
24 changes: 9 additions & 15 deletions packages/uniswap/src/components/dropdowns/ActionSheetDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import { BaseCard } from 'uniswap/src/components/BaseCard/BaseCard'
import { Scrollbar } from 'uniswap/src/components/misc/Scrollbar'
import { MenuItemProp } from 'uniswap/src/components/modals/ActionSheetModal'
import { useAppInsets } from 'uniswap/src/hooks/useAppInsets'
import { isAndroid, isInterface, isTouchable } from 'utilities/src/platform'
import { useTimeout } from 'utilities/src/time/timing'
import { isAndroid, isInterface, isMobileApp, isTouchable } from 'utilities/src/platform'

const DEFAULT_MIN_WIDTH = 225

Expand Down Expand Up @@ -177,22 +176,17 @@ const ActionSheetBackdropWithContent = memo(function ActionSheetBackdropWithCont
toggleMeasurements: DropdownState['toggleMeasurements']
contentProps: ActionSheetDropdownProps
closeOnSelect: boolean
}): JSX.Element | null {
}): JSX.Element {
/*
There is a race condition when we switch from a view with one Portal to another view with a Portal.
It seems that if we mount a second Portal while the first is still mounted, the second would not work properly.
setTimeout with 0ms is a workaround to avoid this issue for now
Remove when https://linear.app/uniswap/issue/WALL-4817 is resolved
We need to add key to Portal on mobile, becuase of a bug in tamagui.
Remove when https://linear.app/uniswap/issue/WALL-4817/tamaguis-portal-stops-reacting-to-re-renders is done
*/
const [shouldRender, setShouldRender] = useState(false)
useTimeout(() => setShouldRender(true), 0)

if (!shouldRender) {
return null
}

const key = useMemo(
() => (isMobileApp ? Math.random() : undefined), // eslint-disable-next-line react-hooks/exhaustive-deps
[closeDropdown, styles, isOpen, toggleMeasurements, contentProps, closeOnSelect],
)
return (
<Portal zIndex={styles?.dropdownZIndex || zIndices.popover}>
<Portal key={key} zIndex={styles?.dropdownZIndex || zIndices.popover}>
<AnimatePresence custom={{ isOpen }}>
{isOpen && toggleMeasurements && (
<>
Expand Down
13 changes: 1 addition & 12 deletions packages/uniswap/src/components/network/NetworkFilter.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NetworkFilter } from 'uniswap/src/components/network/NetworkFilter'
import { act, render } from 'uniswap/src/test/test-utils'
import { render } from 'uniswap/src/test/test-utils'

import ReactDOM from 'react-dom'
import { SUPPORTED_CHAIN_IDS } from 'uniswap/src/features/chains/types'
Expand All @@ -9,19 +9,8 @@ ReactDOM.createPortal = jest.fn((element) => {
})

describe(NetworkFilter, () => {
beforeEach(() => {
jest.useFakeTimers()
})

afterEach(() => {
jest.useRealTimers()
})

it('renders a NetworkFilter', () => {
const tree = render(<NetworkFilter chainIds={SUPPORTED_CHAIN_IDS} selectedChain={null} onPressChain={() => null} />)
act(async () => {
jest.runAllTimers()
})
expect(tree).toMatchSnapshot()
})
})

0 comments on commit a6ca7d5

Please sign in to comment.