Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { useNetwork } from '@perawallet/wallet-core-blockchain'
import { useDeviceID } from '@perawallet/wallet-core-device'
import { useDeleteMultisigInvitationMutation } from '@perawallet/wallet-core-messages'
import { useAllAccounts } from '@perawallet/wallet-core-accounts'
import { useAppNavigation } from '@hooks/useAppNavigation'
import { useLanguage } from '@hooks/useLanguage'
import { useToast } from '@hooks/useToast'
import type { MultisigInvitationParam } from '../../routes/types'
Expand All @@ -40,7 +39,6 @@ export const useMultisigInvitationDetailContent = ({
onIgnored,
onAccepted,
}: UseMultisigInvitationDetailContentParams): UseMultisigInvitationDetailContentResult => {
const { push } = useAppNavigation()
const { t } = useLanguage()
const { errorToast } = useToast()
const { network } = useNetwork()
Expand Down Expand Up @@ -96,20 +94,12 @@ export const useMultisigInvitationDetailContent = ({
t,
])

const handleAccept = useCallback(() => {
onAccepted()
push('Messages', {
screen: 'MultisigInvitationName',
params: { invitation: renderedInvitation },
})
}, [push, renderedInvitation, onAccepted])

return {
renderedInvitation,
totalParticipants,
isIgnoring,
isUserIncluded,
handleIgnore,
handleAccept,
handleAccept: onAccepted,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,81 @@ describe('useInboxScreen', () => {
expect(mockRequestBottomSheet).toHaveBeenCalledTimes(1)
const arg = mockRequestBottomSheet.mock.calls[0][0]
expect(arg.options).toEqual({
size: 'lg',
size: 'auto',
enablePanDownToClose: true,
})
})

it('navigates to MultisigInvitationName when the invitation sheet resolves "accept"', async () => {
mockRequestBottomSheet.mockResolvedValueOnce('accept')
const createdAt = new Date('2025-01-15T00:00:00.000Z')
const importItem = {
type: 'multisig_import' as const,
data: {
customId: 'msig-1',
createdAt,
address: 'MSIG_ADDR1',
version: 1,
threshold: 2,
participantAddresses: ['ADDR1', 'ADDR2'],
},
createdAt,
}

const { result } = renderHook(() => useInboxScreen())

await act(async () => {
result.current.handleInboxItemPress(
importItem as unknown as Parameters<
typeof result.current.handleInboxItemPress
>[0],
)
})

expect(mockPush).toHaveBeenCalledWith('Messages', {
screen: 'MultisigInvitationName',
params: {
invitation: {
customId: 'msig-1',
createdAt: createdAt.toISOString(),
address: 'MSIG_ADDR1',
version: 1,
threshold: 2,
participantAddresses: ['ADDR1', 'ADDR2'],
},
},
})
})

it('does not navigate when the invitation sheet resolves "decline"', async () => {
mockRequestBottomSheet.mockResolvedValueOnce('decline')
const createdAt = new Date('2025-01-15T00:00:00.000Z')
const importItem = {
type: 'multisig_import' as const,
data: {
customId: 'msig-1',
createdAt,
address: 'MSIG_ADDR1',
version: 1,
threshold: 2,
participantAddresses: ['ADDR1', 'ADDR2'],
},
createdAt,
}

const { result } = renderHook(() => useInboxScreen())

await act(async () => {
result.current.handleInboxItemPress(
importItem as unknown as Parameters<
typeof result.current.handleInboxItemPress
>[0],
)
})

expect(mockPush).not.toHaveBeenCalled()
})

it('handleInboxItemPress delegates multisig_sign to the multisig sign-tap handler', () => {
const signItem = {
type: 'multisig_sign' as const,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,26 @@ export const useInboxScreen = (): UseInboxScreenResult => {

const openInvitationDetail = useCallback(
async (invitation: MultisigInvitationParam) => {
await requestBottomSheet<MultisigInvitationDetailContentResult>({
contents: (
<MultisigInvitationDetailContent invitation={invitation} />
),
options: { size: 'lg', enablePanDownToClose: true },
})
const result =
await requestBottomSheet<MultisigInvitationDetailContentResult>(
{
contents: (
<MultisigInvitationDetailContent
invitation={invitation}
/>
),
options: { size: 'auto', enablePanDownToClose: true },
},
)

if (result === 'accept') {
push('Messages', {
screen: 'MultisigInvitationName',
params: { invitation },
})
}
},
[requestBottomSheet],
[requestBottomSheet, push],
)

const handleInboxItemPress = useCallback(
Expand Down
Loading