Skip to content

Commit 0128352

Browse files
add bitcoin logo
1 parent 8cfd626 commit 0128352

File tree

3 files changed

+63
-12
lines changed

3 files changed

+63
-12
lines changed

src/pages/MinerDashboard/Header/AccountHeader.tsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import { getChecksumByTicker } from 'src/utils/validators/checksum';
1313
import { MinerSettingsModal } from '../Settings/MinerSettings.modal';
1414
import { Button } from 'src/components/Button';
1515
import useMinerDetailsQuery from '@/hooks/api/useMinerDetailsQuery';
16+
import {
17+
extractAddressFromBTCAddress,
18+
isBTCAddress,
19+
} from '@/utils/validators/btcWalletAddress';
1620

1721
const rotate = keyframes`
1822
from {
@@ -97,6 +101,15 @@ const Memo = styled.div`
97101
padding: 10px;
98102
`;
99103

104+
const CoinLogo = styled(Img)`
105+
z-index: 1;
106+
`;
107+
108+
const BitcoinLogo = styled(Img)`
109+
margin-left: -20px;
110+
z-index: 0;
111+
`;
112+
100113
export const AccountHeader: React.FC<{
101114
coin?: ApiPoolCoin;
102115
address: string;
@@ -129,23 +142,34 @@ export const AccountHeader: React.FC<{
129142
if (coin) {
130143
addressText = getChecksumByTicker(coin.ticker)(address);
131144

132-
if (addressText && (coin.ticker as string) === 'iron') {
133-
const parsedRes = parseIronAddressWithMemo(addressText);
134-
addressText = parsedRes.address;
135-
ironMemo = parsedRes.memo;
145+
if (addressText) {
146+
if ((coin.ticker as string) === 'iron') {
147+
const parsedRes = parseIronAddressWithMemo(addressText);
148+
addressText = parsedRes.address;
149+
ironMemo = parsedRes.memo;
150+
}
136151
}
137152
}
138153

139154
return (
140155
<Wrap paddingShort>
141156
<AddressContainer>
142157
{coin ? (
143-
<Img src={getCoinIconUrl(coin.ticker)} alt={`${coin.name} logo`} />
158+
<React.Fragment>
159+
<CoinLogo
160+
src={getCoinIconUrl(coin.ticker)}
161+
alt={`${coin.name} logo`}
162+
/>
163+
{isBTCAddress(addressText) && (
164+
<BitcoinLogo src={getCoinIconUrl('btc')} alt={`btc logo`} />
165+
)}
166+
</React.Fragment>
144167
) : (
145168
<CoinIconSkeleton />
146169
)}
170+
147171
<Address href={getCoinLink('wallet', address, coinName)}>
148-
{addressText}
172+
{extractAddressFromBTCAddress(addressText || '')}
149173
</Address>
150174
{ironMemo && <Memo>{ironMemo}</Memo>}
151175
<CopyButton text={addressText || ''} />
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const isBTCAddress = (address: string | null) => {
2+
if (address == null) {
3+
return false
4+
}
5+
6+
return address.toLowerCase().startsWith("btc:")
7+
}
8+
9+
export const extractAddressFromBTCAddress = (address: string) => {
10+
if (!isBTCAddress(address)) {
11+
return address
12+
}
13+
return address.slice(4)
14+
}

tsconfig.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"compilerOptions": {
33
"target": "es5",
4-
"lib": ["dom", "dom.iterable", "esnext"],
4+
"lib": [
5+
"dom",
6+
"dom.iterable",
7+
"esnext"
8+
],
59
"allowJs": true,
610
"skipLibCheck": true,
711
"esModuleInterop": true,
@@ -20,10 +24,19 @@
2024
"inlineSources": true,
2125
"sourceRoot": "/",
2226
"noImplicitAny": false,
23-
"paths": {
24-
"@/*": ["src/*"]
25-
}
27+
"paths": {
28+
"@/*": [
29+
"src/*"
30+
]
31+
},
32+
"incremental": true
2633
},
27-
"exclude": ["node_modules"],
28-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
34+
"exclude": [
35+
"node_modules"
36+
],
37+
"include": [
38+
"next-env.d.ts",
39+
"**/*.ts",
40+
"**/*.tsx"
41+
]
2942
}

0 commit comments

Comments
 (0)