diff --git a/package.json b/package.json index 2912931..ba77368 100644 --- a/package.json +++ b/package.json @@ -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": [ @@ -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", diff --git a/src/assets/tokens/amamapt.png b/src/assets/tokens/amamapt.png new file mode 100644 index 0000000..a08f519 Binary files /dev/null and b/src/assets/tokens/amamapt.png differ diff --git a/src/assets/tokens/amstapt.png b/src/assets/tokens/amstapt.png new file mode 100644 index 0000000..3aaff41 Binary files /dev/null and b/src/assets/tokens/amstapt.png differ diff --git a/src/components/ImportTokenDialog/ImportTokenDialog.vue b/src/components/ImportTokenDialog/ImportTokenDialog.vue index 5d4a44c..72e005a 100644 --- a/src/components/ImportTokenDialog/ImportTokenDialog.vue +++ b/src/components/ImportTokenDialog/ImportTokenDialog.vue @@ -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], }; } diff --git a/src/components/SelectTokenDialog/Coins/CoinsList.vue b/src/components/SelectTokenDialog/Coins/CoinsList.vue index 1b56285..e45645e 100644 --- a/src/components/SelectTokenDialog/Coins/CoinsList.vue +++ b/src/components/SelectTokenDialog/Coins/CoinsList.vue @@ -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), }; }); diff --git a/src/components/SelectTokenDialog/TokenList.vue b/src/components/SelectTokenDialog/TokenList.vue index 7c992ab..af9e15e 100644 --- a/src/components/SelectTokenDialog/TokenList.vue +++ b/src/components/SelectTokenDialog/TokenList.vue @@ -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; diff --git a/src/constants/tokensList.ts b/src/constants/tokensList.ts index 6202c31..58892bf 100644 --- a/src/constants/tokensList.ts +++ b/src/constants/tokensList.ts @@ -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 = [ @@ -135,7 +137,16 @@ export const tokensList = [ { symbol: "thl", logo: ThlLogo + }, + { + symbol: "amamapt", + logo: AmAPTLogo + }, + { + symbol: "amstapt", + logo: stAPTLogo } + ]; export const knownTokens = [ diff --git a/src/store/useTokenStore.ts b/src/store/useTokenStore.ts index 2ead3b4..d73af5f 100644 --- a/src/store/useTokenStore.ts +++ b/src/store/useTokenStore.ts @@ -44,6 +44,10 @@ interface IStorage extends IStorageBasic { tokens: IPersistedToken[]; } +const PROVIDER_TO_SYMBOL_PREFIX: Record = { + amnis: 'am', +}; + const PERSISTING_SOURCES = ['import', 'pool']; export const useTokensStore = defineStore('tokensStore', () => { @@ -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]; }; @@ -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; @@ -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]; diff --git a/src/types/coins.ts b/src/types/coins.ts index d0e7cd5..4d30b46 100644 --- a/src/types/coins.ts +++ b/src/types/coins.ts @@ -6,6 +6,7 @@ export type TCoinSource = // partners sources | 'aptoge' | 'argo' + | 'amnis' | 'celer' | 'chainx' | 'ditto' diff --git a/src/utils/tokens.ts b/src/utils/tokens.ts index 9f8c454..df6c019 100644 --- a/src/utils/tokens.ts +++ b/src/utils/tokens.ts @@ -4,6 +4,7 @@ const PREFIXES: Record = { // layerzero: 'lz', wormhole: 'wh', celer: 'cl', + amnis: 'am', }; export function aliasForToken(token: IPersistedToken) { @@ -17,6 +18,7 @@ const TITLES: Record = { chainx: 'ChainX', celer: 'Celer', multichain: 'Multichain', + amnis: 'Amnis', }; export function titleForToken(token: IPersistedToken) { diff --git a/yarn.lock b/yarn.lock index f3041b9..0e05301 100644 --- a/yarn.lock +++ b/yarn.lock @@ -307,10 +307,10 @@ react-dom "^18.X.X || 17.X.X" vue "3.2.40" -"@pontem/coins-registry@2.1.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/coins-registry@2.1.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/liquidswap-sdk@0.6.1": version "0.6.1"