diff --git a/apps/wallet-mobile/package.json b/apps/wallet-mobile/package.json index 647a024809..5df9f87d87 100644 --- a/apps/wallet-mobile/package.json +++ b/apps/wallet-mobile/package.json @@ -128,7 +128,7 @@ "@yoroi/links": "1.5.1", "@yoroi/resolver": "2.0.4", "@yoroi/staking": "1.5.1", - "@yoroi/swap": "1.5.1", + "@yoroi/swap": "1.5.2", "@yoroi/theme": "^1.0.0", "@yoroi/transfer": "1.0.0", "add": "2.0.6", diff --git a/packages/swap/package.json b/packages/swap/package.json index 60ce45a69f..4fbed1f09a 100644 --- a/packages/swap/package.json +++ b/packages/swap/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/swap", - "version": "1.5.1", + "version": "1.5.2", "description": "The Swap package of Yoroi SDK", "keywords": [ "yoroi", @@ -140,6 +140,7 @@ "immer": "^10.0.2" }, "devDependencies": { + "@emurgo/yoroi-lib": "0.15.0", "@commitlint/config-conventional": "^17.0.2", "@react-native-async-storage/async-storage": "^1.19.3", "@react-native-community/eslint-config": "^3.0.2", @@ -171,6 +172,7 @@ "typescript": "^5.3.3" }, "peerDependencies": { + "@emurgo/yoroi-lib": "0.15.0", "@react-native-async-storage/async-storage": ">= 1.19.3 <= 1.20.0", "react": ">= 16.8.0 <= 19.0.0", "react-query": "^3.39.3" diff --git a/packages/swap/src/adapters/openswap-api/api.mocks.ts b/packages/swap/src/adapters/openswap-api/api.mocks.ts index f501c1eb98..0ef53c097f 100644 --- a/packages/swap/src/adapters/openswap-api/api.mocks.ts +++ b/packages/swap/src/adapters/openswap-api/api.mocks.ts @@ -325,6 +325,21 @@ const getTokens: Balance.TokenInfo[] = [ ticker: 'ELADR', metadatas: {}, }, + { + id: '2d420236ffaada336c21e3f4520b799f6e246d8618f2fc89a4907da6.FFFFFF', + group: '2d420236ffaada336c21e3f4520b799f6e246d8618f2fc89a4907da6', + fingerprint: 'asset1ud7y8pzglxmf68jtww3xhpes9j87akx4mtyx28', + name: 'FFFFFF', + decimals: 6, + description: 'Proof Of Contribution.', + image: + 'https://tokens.muesliswap.com/static/img/tokens/2d420236ffaada336c21e3f4520b799f6e246d8618f2fc89a4907da6.4564756c6164646572546f6b656e.png', + kind: 'ft', + symbol: undefined, + icon: undefined, + ticker: 'ELADR', + metadatas: {}, + }, ] export const apiMocks = { diff --git a/packages/swap/src/adapters/openswap-api/openswap.mocks.ts b/packages/swap/src/adapters/openswap-api/openswap.mocks.ts index b5e034ffeb..23e7fc396c 100644 --- a/packages/swap/src/adapters/openswap-api/openswap.mocks.ts +++ b/packages/swap/src/adapters/openswap-api/openswap.mocks.ts @@ -80,6 +80,24 @@ const getTokens: ListTokensResponse = [ }, categories: [], }, + { + supply: { + total: '45000000003000000', + circulating: null, + }, + status: 'verified', + website: 'https://eduladder.com', + symbol: 'ELADR', + decimalPlaces: 6, + image: + 'https://tokens.muesliswap.com/static/img/tokens/2d420236ffaada336c21e3f4520b799f6e246d8618f2fc89a4907da6.4564756c6164646572546f6b656e.png', + description: 'Proof Of Contribution.', + address: { + policyId: '2d420236ffaada336c21e3f4520b799f6e246d8618f2fc89a4907da6', + name: 'FFFFFF', + }, + categories: [], + }, ] const getTokenPairs: TokenPairsResponse = [ diff --git a/packages/swap/src/helpers/transformers.ts b/packages/swap/src/helpers/transformers.ts index 09a13a1fdc..54d41d54ce 100644 --- a/packages/swap/src/helpers/transformers.ts +++ b/packages/swap/src/helpers/transformers.ts @@ -1,6 +1,7 @@ import AssetFingerprint from '@emurgo/cip14-js' import {Swap, Balance} from '@yoroi/types' import {isString} from '@yoroi/common' +import {AssetNameUtils} from '@emurgo/yoroi-lib/dist/internals/utils/assets' import {Quantities} from '../utils/quantities' import {supportedProviders} from '../translators/constants' @@ -123,7 +124,7 @@ export const transformersMaker = ( policyId: openswapToken.address.policyId, assetNameHex: openswapToken.address.name, }), - name: asUtf8(openswapToken.address.name), + name: asTokenName(openswapToken.address.name), decimals: openswapToken.decimalPlaces, description: openswapToken.description, image: openswapToken.image, @@ -266,7 +267,10 @@ export const asTokenFingerprint = ({ return assetFingerprint.fingerprint() } -export const asUtf8 = (hex: string) => Buffer.from(hex, 'hex').toString('utf-8') +export const asTokenName = (hex: string) => { + const {asciiName, hexName} = AssetNameUtils.resolveProperties(hex) + return asciiName ?? hexName +} function isSupportedProvider( provider: string,