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
2 changes: 1 addition & 1 deletion packages/hdwallet-keepkey/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shapeshiftoss/hdwallet-keepkey",
"version": "1.62.41",
"version": "1.62.42",
"repository": "https://github.com/shapeshift/web",
"license": "MIT",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/hdwallet-keepkey/src/thorchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export async function thorchainSignTx(
}

const coinAsset = m.value.coins[0].asset
if (coinAsset !== 'THOR.RUNE' && coinAsset !== 'THOR.TCY') {
if (!['THOR.RUNE', 'THOR.TCY', 'THOR.RUJI'].includes(coinAsset)) {
throw new Error('THORChain: Unsupported coin asset: ' + coinAsset)
}

Expand Down
1 change: 1 addition & 0 deletions src/assets/translations/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,7 @@
"broadcastingTransaction": "Broadcasting Transaction",
"youHaveSent": "You have successfully sent %{amount} %{symbol}",
"sendFailed": "Send failed",
"assetNotSupportedByWallet": "Sending %{asset} is not supported by %{wallet}.",
"toAddress": "To Address",
"toAddressOrEns": "To Address or ENS",
"scanQrCode": "Scan QR Code",
Expand Down
30 changes: 29 additions & 1 deletion src/components/Modals/Send/views/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
Alert,
AlertIcon,
Button,
Flex,
FormControl,
Expand Down Expand Up @@ -29,9 +31,12 @@ import { DialogTitle } from '@/components/Modal/components/DialogTitle'
import { SelectAssetRoutes } from '@/components/SelectAssets/SelectAssetCommon'
import { SlideTransition } from '@/components/SlideTransition'
import { Text } from '@/components/Text'
import type { TextPropTypes } from '@/components/Text/Text'
import { useFeatureFlag } from '@/hooks/useFeatureFlag/useFeatureFlag'
import { useModal } from '@/hooks/useModal/useModal'
import { useWallet } from '@/hooks/useWallet/useWallet'
import { parseAddressInputWithChainId } from '@/lib/address/address'
import { walletSupportsSendingAsset } from '@/lib/utils'
import {
selectInternalAccountIdByAddress,
selectIsAddressInAddressBook,
Expand Down Expand Up @@ -85,6 +90,23 @@ export const Address = () => {

const asset = useAppSelector(state => selectAssetById(state, assetId))

const {
state: { wallet, walletInfo },
} = useWallet()

const isSendSupported = useMemo(
() => !wallet || !assetId || walletSupportsSendingAsset(assetId, wallet),
[assetId, wallet],
)

const notSupportedTranslation: TextPropTypes['translation'] = useMemo(
() => [
'modals.send.assetNotSupportedByWallet',
{ asset: asset?.symbol ?? '', wallet: walletInfo?.name ?? '' },
],
[asset?.symbol, walletInfo?.name],
)

const isInAddressBookFilter = useMemo(
() => ({ accountAddress: address, chainId: asset?.chainId }),
[address, asset?.chainId],
Expand Down Expand Up @@ -247,9 +269,15 @@ export const Address = () => {

<DialogFooter pt={2}>
<Stack flex={1}>
{!isSendSupported && (
<Alert status='warning' borderRadius='lg' mb={3}>
<AlertIcon />
<Text translation={notSupportedTranslation} fontSize='sm' />
</Alert>
)}
<Button
width='full'
isDisabled={!address || !input || addressError}
isDisabled={!isSendSupported || !address || !input || addressError}
isLoading={isValidating}
colorScheme={addressError && !isValidating ? 'red' : 'blue'}
size='lg'
Expand Down
8 changes: 7 additions & 1 deletion src/lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AssetId, ChainId, ChainNamespace } from '@shapeshiftoss/caip'
import { fromChainId } from '@shapeshiftoss/caip'
import { fromChainId, rujiAssetId, tcyAssetId } from '@shapeshiftoss/caip'
import type { ChainAdapter } from '@shapeshiftoss/chain-adapters'
import type { HDWallet } from '@shapeshiftoss/hdwallet-core'
import type { GridPlusHDWallet } from '@shapeshiftoss/hdwallet-gridplus'
Expand Down Expand Up @@ -118,6 +118,12 @@ export const isNonEmptyString = (value: string | undefined): value is string =>
type Falsy = false | null | undefined | '' | 0
export const isTruthy = <T>(value: T | Falsy): value is T => Boolean(value)

export const walletSupportsSendingAsset = (assetId: AssetId, wallet: HDWallet): boolean => {
if (isKeepKeyHDWallet(wallet) && [tcyAssetId, rujiAssetId].includes(assetId)) return false

return true
}

export const walletCanEditMemo = (wallet: HDWallet): boolean => {
switch (true) {
case isKeepKeyHDWallet(wallet):
Expand Down
Loading