Skip to content

Commit

Permalink
TW-727: [hotfix] Deprecated TKEY (#907)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-tsx authored Jun 1, 2023
1 parent e92f778 commit 8f030ee
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "temple-wallet",
"version": "1.17.1",
"version": "1.17.2",
"private": true,
"scripts": {
"start-run": "cross-env TS_NODE_PROJECT=\"webpack/tsconfig.json\" webpack --watch --stats errors-warnings",
Expand Down
5 changes: 3 additions & 2 deletions src/lib/route3/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ export const MAX_ROUTING_FEE_CHAINS = 1;
export const SWAP_THRESHOLD_TO_GET_CASHBACK = 10;

export const ZERO = new BigNumber(0);

export const TEMPLE_TOKEN: Route3Token = {
id: 128,
id: 138,
symbol: 'TKEY',
standard: Route3TokenStandardEnum.fa2,
contract: 'KT1WihWRnmzhfebi6zqQ4tvNGiPeVxiGwTi2',
contract: 'KT1VaEsVNiBoA56eToEK6n6BcPgh1tdx9eXi',
tokenId: '0',
decimals: 18
};
9 changes: 9 additions & 0 deletions src/lib/temple/assets/known-tokens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TEMPLE_TOKEN } from 'lib/route3/constants';
import { TempleChainId } from 'lib/temple/types';

import type { AssetMetadata } from '../metadata';
import { toTokenSlug } from './utils';

export namespace KNOWN_TOKENS_SLUGS {
Expand All @@ -14,6 +15,7 @@ export namespace KNOWN_TOKENS_SLUGS {
export const YOU = toTokenSlug('KT1Xobej4mc6XgEjDoJoHtTKgbD1ELMvcQuL', 0);
export const SIRS = toTokenSlug('KT1AafHA1C1vk959wvHWBispY9Y2f3fxBUUo', 0);
export const TEMPLE = toTokenSlug(TEMPLE_TOKEN.contract!, TEMPLE_TOKEN.tokenId!);
export const DEPRECATED_TKEY = toTokenSlug('KT1WihWRnmzhfebi6zqQ4tvNGiPeVxiGwTi2', 0);
}

const PREDEFINED_TOKENS_BY_CHAIN_ID: Record<string, string[]> = {
Expand All @@ -36,3 +38,10 @@ export const TOKENS_BRAND_COLORS: Record<string, { bg: string; bgHover?: string
[KNOWN_TOKENS_SLUGS.TZBTC]: { bg: '#1373E4', bgHover: '#428FE9' },
[KNOWN_TOKENS_SLUGS.USDT]: { bg: '#009393', bgHover: '#52AF95' }
};

export const DEPRECATED_TKEY_METADATA: AssetMetadata = {
name: 'Deprecated Temple Key',
symbol: 'TKEY_OLD',
decimals: 18,
shouldPreferSymbol: false
};
11 changes: 10 additions & 1 deletion src/lib/temple/front/sync-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
toTokenSlug,
fetchDisplayedFungibleTokens,
fetchCollectibleTokens,
getPredefinedTokensSlugs
getPredefinedTokensSlugs,
KNOWN_TOKENS_SLUGS,
DEPRECATED_TKEY_METADATA
} from 'lib/temple/assets';
import { useChainId, useAccount, useTokensMetadata } from 'lib/temple/front';
import { AssetMetadata, DetailedAssetMetdata, toBaseMetadata } from 'lib/temple/metadata';
Expand Down Expand Up @@ -139,6 +141,13 @@ const makeSync = async (
}
}

// Deprecated TKEY patch
const DEPRECATED_TKEY_SLUG = KNOWN_TOKENS_SLUGS.DEPRECATED_TKEY;
if (allTokensBaseMetadataRef.current[DEPRECATED_TKEY_SLUG]?.symbol !== DEPRECATED_TKEY_METADATA.symbol) {
baseMetadatasToSet[DEPRECATED_TKEY_SLUG] = DEPRECATED_TKEY_METADATA;
detailedMetadatasToSet[DEPRECATED_TKEY_SLUG] = DEPRECATED_TKEY_METADATA;
}

setTokensBaseMetadata(baseMetadatasToSet);
setTokensDetailedMetadata(detailedMetadatasToSet);

Expand Down

0 comments on commit 8f030ee

Please sign in to comment.