Skip to content

Commit

Permalink
Merge pull request #28 from pontem-network/feature-update-coin-registry
Browse files Browse the repository at this point in the history
Update coins registry to 2.1.24
  • Loading branch information
lusd authored Oct 23, 2023
2 parents 8e66823 + cb1d39a commit 26fbb60
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pontem/liquidswap-widget",
"version": "0.3.4",
"version": "0.3.5",
"homepage": "https://github.com/pontem-network/liquidswap-widget#readme",
"description": "LiquidSwap widget as custom web component",
"files": [
Expand Down Expand Up @@ -49,7 +49,7 @@
"dependencies": {
"@metamask/jazzicon": "2.0.0",
"@pontem/aptos-wallet-adapter": "0.7.2",
"@pontem/coins-registry": "2.1.19",
"@pontem/coins-registry": "2.1.24",
"@pontem/liquidswap-sdk": "0.6.1",
"@tsconfig/recommended": "1.0.2",
"@types/lodash": "4.14.182",
Expand Down
Binary file added src/assets/tokens/amamapt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/tokens/amstapt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/ImportTokenDialog/ImportTokenDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async function getToken() {
const tokenInfo = await tokensStore.getTokenInfo(props.token);
tokenPreview.value = tokenInfo && {
...tokenInfo,
logo: tokensStore.getLogoUrl(props.token),
logo: await tokensStore.getLogoUrl(props.token, tokenInfo.source),
address: firstPart.split('::')[0],
};
}
Expand Down
6 changes: 4 additions & 2 deletions src/components/SelectTokenDialog/Coins/CoinsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ watch(addressImportStr, async () => {
);
}
if (firstPart.split('::').length !== 3) return;
const tokenInfo = await tokensStore.getTokenInfo(addressImportStr.value);
if (!tokenInfo) return;
tokenPreview.value = {
...(await tokensStore.getTokenInfo(addressImportStr.value)),
logo: tokensStore.getLogoUrl(addressImportStr.value),
...tokenInfo,
logo: tokensStore.getLogoUrl(addressImportStr.value, tokenInfo.source),
};
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/SelectTokenDialog/TokenList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ watch(search, async (v, _) => {
const tokenInfo = await tokensStore.getTokenInfo(search.value);
importTokenPreview.value = tokenInfo && {
...tokenInfo,
logo: tokensStore.getLogoUrl(search.value),
logo: tokensStore.getLogoUrl(search.value, tokenInfo.source),
};
} else {
importTokenPreview.value = null;
Expand Down
11 changes: 11 additions & 0 deletions src/constants/tokensList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import DlcLogo from '../assets/tokens/dlc.svg';
import PontTokenLogo from '../assets/tokens/pont-token.svg';
import MoveLogo from '../assets/tokens/move.svg';
import ThlLogo from '../assets/tokens/thl.svg';
import AmAPTLogo from '../assets/tokens/amamapt.png';
import stAPTLogo from '../assets/tokens/amstapt.png';


export const tokensList = [
Expand Down Expand Up @@ -135,7 +137,16 @@ export const tokensList = [
{
symbol: "thl",
logo: ThlLogo
},
{
symbol: "amamapt",
logo: AmAPTLogo
},
{
symbol: "amstapt",
logo: stAPTLogo
}

];

export const knownTokens = [
Expand Down
15 changes: 11 additions & 4 deletions src/store/useTokenStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ interface IStorage extends IStorageBasic {
tokens: IPersistedToken[];
}

const PROVIDER_TO_SYMBOL_PREFIX: Record<string, string> = {
amnis: 'am',
};

const PERSISTING_SOURCES = ['import', 'pool'];

export const useTokensStore = defineStore('tokensStore', () => {
Expand Down Expand Up @@ -162,7 +166,7 @@ export const useTokensStore = defineStore('tokensStore', () => {
tokens[token.type].decimals = +resource.data.decimals;
tokens[token.type].alias = aliasForToken(token);
tokens[token.type].title = titleForToken(token);
tokens[token.type].logo = getLogoUrl.value(resource.data.symbol);
tokens[token.type].logo = getLogoUrl.value(resource.data.symbol, resource.data.source);

return tokens[token.type];
};
Expand All @@ -173,9 +177,12 @@ export const useTokensStore = defineStore('tokensStore', () => {

const getLogoUrl = computed(() => {

return (symbol: string) => {
return (symbol: string, source: string | undefined) => {

const prefix = (source && PROVIDER_TO_SYMBOL_PREFIX[source]) ?? '';

try {
const token = tokensList.find(token => token.symbol === symbol.toLowerCase());
const token = tokensList.find(token => token.symbol === `${prefix}${symbol.toLowerCase()}`);
return token?.logo as any;
} catch (_e) {
return undefined;
Expand Down Expand Up @@ -215,7 +222,7 @@ export const useTokensStore = defineStore('tokensStore', () => {
order: token.order || 1000,
alias: aliasForToken(token),
title: titleForToken(token),
logo: getLogoUrl.value(token.symbol),
logo: getLogoUrl.value(token.symbol, token.source),
};

return tokens[type];
Expand Down
1 change: 1 addition & 0 deletions src/types/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type TCoinSource =
// partners sources
| 'aptoge'
| 'argo'
| 'amnis'
| 'celer'
| 'chainx'
| 'ditto'
Expand Down
2 changes: 2 additions & 0 deletions src/utils/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const PREFIXES: Record<string, string> = {
// layerzero: 'lz',
wormhole: 'wh',
celer: 'cl',
amnis: 'am',
};

export function aliasForToken(token: IPersistedToken) {
Expand All @@ -17,6 +18,7 @@ const TITLES: Record<string, string> = {
chainx: 'ChainX',
celer: 'Celer',
multichain: 'Multichain',
amnis: 'Amnis',
};

export function titleForToken(token: IPersistedToken) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@
react-dom "^18.X.X || 17.X.X"
vue "3.2.40"

"@pontem/[email protected].19":
version "2.1.19"
resolved "https://registry.yarnpkg.com/@pontem/coins-registry/-/coins-registry-2.1.19.tgz#b615c72ae9477a6559ddb41102d25b0943f9683e"
integrity sha512-OMQXIRvZaOzka4pg2afrNocP4xyFz3iXyL/tOpysBIGZeIF+GCR9lt+zcuXAFleNJWOToE9LLksFNVDQC6atGA==
"@pontem/[email protected].24":
version "2.1.24"
resolved "https://registry.yarnpkg.com/@pontem/coins-registry/-/coins-registry-2.1.24.tgz#b63087217926521c9afa08d8d071b661dcb83a17"
integrity sha512-A/FgtPeISsF9KVcbTSGelL2NDFokCci9r1A4U9Zrefjs768qsc1CeZT/IF6CG6CiNdVRnV7S/nEdms/2137DMg==

"@pontem/[email protected]":
version "0.6.1"
Expand Down

0 comments on commit 26fbb60

Please sign in to comment.