Skip to content

Commit

Permalink
feat: change matic to pol symbol in the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Sep 26, 2024
1 parent c26f202 commit c523383
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions packages/address-validator/src/currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,8 @@ var CURRENCIES = [
validator: ETHValidator,
},
{
name: 'Matic Network',
symbol: 'matic',
name: 'Polygon PoS',
symbol: 'pol',
validator: ETHValidator,
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain-link/src/ui/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ export default [
blockchain: {
name: 'Polygon PoS',
worker: 'js/blockbook-worker.js',
server: ['https://matic1.trezor.io', 'https://matic2.trezor.io'],
server: ['https://pol1.trezor.io', 'https://pol2.trezor.io'],
debug: true,
},
data: {
Expand Down
6 changes: 3 additions & 3 deletions packages/connect-common/files/coins-eth.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
{
"blockchain_link": {
"type": "blockbook",
"url": ["https://matic1.trezor.io", "https://matic2.trezor.io"]
"url": ["https://pol1.trezor.io", "https://pol2.trezor.io"]
},
"chain": "matic",
"chain": "pol",
"chain_id": 137,
"coingecko_id": "polygon-pos",
"is_testnet": false,
"name": "Polygon",
"shortcut": "MATIC",
"shortcut": "POL",
"slip44": 966,
"support": {
"T1B1": "1.9.4",
Expand Down
16 changes: 13 additions & 3 deletions packages/connect/src/backend/Blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getWorker = (type: string) => {
}
};

const getNormalizedShortcut = (shortcut: string) => {
const getNormalizedTrezorShortcut = (shortcut: string) => {
// There is no `rippled` setting that defines which network it uses neither mainnet or testnet
// see: https://xrpl.org/parallel-networks.html
if (shortcut === 'tXRP') {
Expand All @@ -43,6 +43,15 @@ const getNormalizedShortcut = (shortcut: string) => {
return shortcut;
};

const getNormalizedBackendShortcut = (shortcut: string) => {
// Can be safely removed when both Polygon PoS Blockbooks return POL as shortcut
if (shortcut.toLowerCase() === 'matic') {
return 'pol';
}

return shortcut;
};

export type BlockchainOptions = {
coinInfo: CoinInfo;
postMessage: (message: CoreEventMessage) => void;
Expand Down Expand Up @@ -128,9 +137,10 @@ export class Blockchain {

this.serverInfo = info;

const shortcut = getNormalizedShortcut(this.coinInfo.shortcut);
const trezorShortcut = getNormalizedTrezorShortcut(this.coinInfo.shortcut);
const backendShortcut = getNormalizedBackendShortcut(this.serverInfo.shortcut);

if (info.shortcut.toLowerCase() !== shortcut.toLowerCase()) {
if (trezorShortcut.toLowerCase() !== backendShortcut.toLowerCase()) {
throw ERRORS.TypedError('Backend_Invalid');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('utils/deviceFeaturesUtils', () => {
crw: 'update-required',
eos: 'no-support',
maid: 'no-capability',
matic: 'update-required',
pol: 'update-required',
omni: 'no-capability',
ppc: 'update-required',
sol: 'no-support',
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('utils/deviceFeaturesUtils', () => {
eip1559: 'update-required',
'eip712-domain-only': 'update-required',
maid: 'no-capability',
matic: 'update-required',
pol: 'update-required',
omni: 'no-capability',
taproot: 'update-required',
tsep: 'update-required',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const COINS: Record<NetworkSymbol, string> = {
etc: require('../../images/coins/etc.svg'),
eth: require('../../images/coins/eth.svg'),
ltc: require('../../images/coins/ltc.svg'),
matic: require('../../images/coins/matic.svg'),
pol: require('../../images/coins/pol.svg'),
nmc: require('../../images/coins/nmc.svg'),
regtest: require('../../images/coins/btc_test.svg'),
sol: require('../../images/coins/sol.svg'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Icon,
Column,
Row,
Paragraph,
SkeletonRectangle,
TOOLTIP_DELAY_LONG,
TruncateWithTooltip,
Expand Down Expand Up @@ -111,18 +110,14 @@ export const AccountItem = forwardRef(

const { shouldAnimate } = useLoadingSkeleton();

const { accountType, index, networkType, symbol } = account;
const { accountType, index, symbol } = account;

const accountRouteParams = {
symbol,
accountIndex: index,
accountType,
};

const isTokensCountShown =
(['cardano', 'solana'].includes(networkType) || account.symbol === 'matic') &&
!!tokens?.length;

const getRoute = () => {
switch (type) {
case 'coin':
Expand All @@ -140,9 +135,6 @@ export const AccountItem = forwardRef(
return (
<Column>
<CoinLogo size={ICON_SIZE} symbol={symbol} />
{isTokensCountShown && type === 'coin' && (
<Paragraph typographyStyle="label">{tokens?.length}</Paragraph>
)}
</Column>
);
case 'staking':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const FIXTURE_ACCOUNTS: Partial<Account>[] = [
{
deviceState: '1stTestnet@device_id:0',
formattedBalance: '0.101213',
symbol: 'matic',
symbol: 'pol',
visible: true,
tokens: [
{
Expand All @@ -143,7 +143,7 @@ export const FIXTURE_ACCOUNTS: Partial<Account>[] = [
{
deviceState: '1stTestnetAddress@device_id:0',
formattedBalance: '250',
symbol: 'matic',
symbol: 'pol',
visible: true,
tokens: [
// unsupported token
Expand All @@ -162,7 +162,7 @@ export const FIXTURE_ACCOUNTS: Partial<Account>[] = [
{
deviceState: '1stTestnetAddress@device_id:0',
formattedBalance: '250',
symbol: 'matic',
symbol: 'pol',
visible: false,
tokens: [
// unsupported token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('coinmarket utils', () => {
'bitcoin',
'litecoin',
'ethereum',
'matic-network',
'polygon-ecosystem-token',
'ethereum--0x1234123412341234123412341234123412341236',
]) as Set<CryptoId>,
});
Expand Down Expand Up @@ -237,8 +237,8 @@ describe('coinmarket utils', () => {
balance: '250',
cryptoName: 'Polygon PoS',
descriptor: 'descriptor6',
label: 'MATIC',
value: 'matic-network',
label: 'POL',
value: 'polygon-ecosystem-token',
decimals: 18,
},
],
Expand Down
4 changes: 1 addition & 3 deletions packages/suite/src/views/wallet/send/Outputs/Outputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export const Outputs = ({ disableAnim }: OutputsProps) => {
}
}, [outputs]);

const isMatic = account.networkType === 'ethereum' && account.symbol === 'matic'; // TODO: POLYGON DEBUG

return (
<Container $height={height || 0}>
<div ref={ref}>
Expand All @@ -83,7 +81,7 @@ export const Outputs = ({ disableAnim }: OutputsProps) => {
>
<Card
label={
isMatic && (
account.networkType === 'ethereum' && (
<StyledEvmExplanation>
<CoinLogo symbol={account.symbol} size={16} />
<Translation
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/coinsColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const coinsColors: CoinsColors = {
etc: '#60c67e',
eth: '#454a75',
ltc: '#a6a8a9',
matic: '#7b3fe4',
pol: '#7b3fe4',
nmc: '#186c9d',
regtest: '#e75f5f',
sol: '#9945ff',
Expand Down
2 changes: 1 addition & 1 deletion suite-common/icons-deprecated/src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export const cryptoIcons = {
eth: require('../assets/cryptoIcons/eth.svg'),
gnt: require('../assets/cryptoIcons/gnt.svg'),
ltc: require('../assets/cryptoIcons/ltc.svg'),
matic: require('../assets/cryptoIcons/matic.svg'),
pol: require('../assets/cryptoIcons/pol.svg'),
name: require('../assets/cryptoIcons/name.svg'),
nmc: require('../assets/cryptoIcons/nmc.svg'),
regtest: require('../assets/cryptoIcons/regtest.svg'),
Expand Down
14 changes: 7 additions & 7 deletions suite-common/wallet-config/src/networksConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,19 +380,19 @@ export const networks = {
coingeckoId: 'solana',
coingeckoNativeId: 'solana',
},
matic: {
symbol: 'matic',
pol: {
symbol: 'pol',
name: 'Polygon PoS',
networkType: 'ethereum',
chainId: 137,
bip43Path: "m/44'/60'/0'/0/i",
decimals: 18,
testnet: false,
explorer: {
tx: 'https://matic2.trezor.io/tx/',
account: 'https://matic2.trezor.io/address/',
nft: 'https://matic2.trezor.io/nft/',
address: 'https://matic2.trezor.io/address/',
tx: 'https://pol1.trezor.io/tx/',
account: 'https://pol1.trezor.io/address/',
nft: 'https://pol1.trezor.io/nft/',
address: 'https://pol1.trezor.io/address/',
},
features: ['rbf', 'sign-verify', 'tokens', 'coin-definitions', 'nft-definitions'],
customBackends: ['blockbook'],
Expand All @@ -405,7 +405,7 @@ export const networks = {
},
},
coingeckoId: 'polygon-pos',
coingeckoNativeId: 'matic-network',
coingeckoNativeId: 'polygon-ecosystem-token',
},
bnb: {
symbol: 'bnb',
Expand Down
2 changes: 1 addition & 1 deletion suite-common/wallet-config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type NetworkSymbol =
| 'zec'
| 'ada'
| 'sol'
| 'matic'
| 'pol'
| 'bnb'
| 'test'
| 'regtest'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const DEFAULT_ACCOUNT_SYNC_INTERVAL = 60 * 1000;

// using fast and cheap blockchains, it looks suspicious when tx is not almost instantly confirmed
const CUSTOM_ACCOUNT_SYNC_INTERVALS: Partial<Record<NetworkSymbol, number>> = {
matic: 20 * 1000,
pol: 20 * 1000,
bnb: 20 * 1000,
};

Expand Down
Loading

0 comments on commit c523383

Please sign in to comment.