From 52ee02050ab765776836c0e46e33b6f2fb57bc30 Mon Sep 17 00:00:00 2001 From: Roman Petriv Date: Mon, 20 Nov 2023 16:52:25 +0200 Subject: [PATCH] feat: use new tokens api (#91) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # What ❔ - use new tokens API - remove token library - remove token price API usage - refactoring --- package-lock.json | 9 --- packages/api/src/token/token.controller.ts | 2 +- packages/api/src/token/token.service.ts | 2 +- packages/app/firebase.json | 2 +- packages/app/mock/transactions/Execute.json | 12 ++-- packages/app/package.json | 1 - packages/app/src/components/FeeData.vue | 8 +-- .../app/src/components/TokenAmountPrice.vue | 36 ++++------- .../app/src/components/TokenIconLabel.vue | 19 +++--- .../src/components/balances/BalanceValue.vue | 23 +++----- .../app/src/components/balances/Table.vue | 10 +++- .../common/table/fields/TokenPrice.vue | 4 +- .../src/components/token/TokenListTable.vue | 4 +- .../transactions/EthAmountPrice.vue | 11 ++-- .../app/src/components/transactions/Table.vue | 26 +++++--- .../TokenAmountPriceTableCell.vue | 59 +++++++------------ .../infoTable/TransferTableCell.vue | 2 +- .../app/src/components/transfers/Table.vue | 3 +- packages/app/src/composables/common/Api.d.ts | 3 + packages/app/src/composables/useToken.ts | 28 +-------- .../app/src/composables/useTokenLibrary.ts | 23 +++----- packages/app/src/composables/useTokenPrice.ts | 58 ------------------ .../app/src/composables/useTransaction.ts | 10 +++- packages/app/src/composables/useTransfers.ts | 3 + packages/app/src/utils/constants.ts | 9 +-- packages/app/tests/components/FeeData.spec.ts | 12 ++-- .../tests/components/TokenAmountPrice.spec.ts | 16 ++--- .../tests/components/TokenIconLabel.spec.ts | 15 ++--- .../components/balances/BalanceValue.spec.ts | 15 ++--- .../tests/components/balances/Table.spec.ts | 23 ++++---- .../components/token/TokenListTable.spec.ts | 13 ++-- .../transactions/GeneralInfo.spec.ts | 24 ++++++-- .../components/transactions/Table.spec.ts | 21 ++----- .../TokenAmountPriceTableCell.spec.ts | 24 ++------ .../transactions/TransferTableCell.spec.ts | 3 +- .../tests/components/transfers/Table.spec.ts | 18 ++---- .../app/tests/composables/useToken.spec.ts | 15 ++--- .../tests/composables/useTokenLibrary.spec.ts | 44 +++++++------- .../tests/composables/useTokenPrice.spec.ts | 54 ----------------- .../tests/composables/useTransaction.spec.ts | 39 +++++++----- .../tests/composables/useTransfers.spec.ts | 6 ++ .../app/tests/e2e/features/copying.feature | 4 -- packages/app/tests/mocks.ts | 14 +++++ packages/app/tests/utils/formatters.spec.ts | 10 ++-- packages/app/tests/views/HomeView.spec.ts | 14 ++++- packages/worker/.env.example | 2 +- packages/worker/src/config.spec.ts | 2 +- packages/worker/src/config.ts | 2 +- ...portalsFiTokenOffChainDataProvider.spec.ts | 2 +- 49 files changed, 296 insertions(+), 463 deletions(-) delete mode 100644 packages/app/src/composables/useTokenPrice.ts delete mode 100644 packages/app/tests/composables/useTokenPrice.spec.ts diff --git a/package-lock.json b/package-lock.json index 4740048ce2..7e845b2567 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5952,14 +5952,6 @@ "integrity": "sha512-JW7nHREPqEtjBWz3EfxLarkmJBD8vi7Kx/1AQ6eBZnz12eHc1VkOyrc6mpR5ogTf0dOUNXFAfZut+cDe2dn4kQ==", "dev": true }, - "node_modules/@matterlabs/token-library": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/@matterlabs/token-library/-/token-library-2.9.0.tgz", - "integrity": "sha512-Xkp0n0NdmG5UqHMRtY6BJSWbfTgv8OjhkWYuaevhwjb8+0uv3GpJC++2webB0jdebDVQBFUiwcC+Er7E49sryQ==", - "dependencies": { - "ohmyfetch": "^0.4.21" - } - }, "node_modules/@mdx-js/loader": { "version": "1.6.22", "resolved": "https://registry.npmjs.org/@mdx-js/loader/-/loader-1.6.22.tgz", @@ -54492,7 +54484,6 @@ "license": "MIT", "dependencies": { "@matterlabs/composables": "1.1.7", - "@matterlabs/token-library": "2.9.0", "@vueuse/components": "8.9.2", "@vueuse/core": "8.9.2", "date-fns": "2.28.0", diff --git a/packages/api/src/token/token.controller.ts b/packages/api/src/token/token.controller.ts index 4b45ebb218..44ea613065 100644 --- a/packages/api/src/token/token.controller.ts +++ b/packages/api/src/token/token.controller.ts @@ -35,7 +35,7 @@ export class TokenController { name: "minLiquidity", type: "integer", description: "Min liquidity filter", - example: 1000000, + example: 100000, required: false, }) public async getTokens( diff --git a/packages/api/src/token/token.service.ts b/packages/api/src/token/token.service.ts index ef77a5f9ae..c4dd045655 100644 --- a/packages/api/src/token/token.service.ts +++ b/packages/api/src/token/token.service.ts @@ -43,7 +43,7 @@ export class TokenService { paginationOptions: IPaginationOptions ): Promise> { const queryBuilder = this.tokenRepository.createQueryBuilder("token"); - if (minLiquidity > 0) { + if (minLiquidity >= 0) { queryBuilder.where({ liquidity: MoreThanOrEqual(minLiquidity), }); diff --git a/packages/app/firebase.json b/packages/app/firebase.json index 598ece64f5..f2525ac862 100644 --- a/packages/app/firebase.json +++ b/packages/app/firebase.json @@ -36,7 +36,7 @@ }, { "key": "Content-Security-Policy-Report-Only", - "value": "default-src 'self'; child-src 'self' blob:; script-src 'self' 'unsafe-eval' blob:; connect-src https://*.ingest.sentry.io https://firestore.googleapis.com/ https://*.zkscan.io https://*.zksync.io https://*.zksync.dev https://storage.googleapis.com; style-src 'self' fonts.googleapis.com; font-src 'self' fonts.gstatic.com; img-src 'self' 'https://assets.coingecko.com' blob: data: https://firebasestorage.googleapis.com/v0/b/token-library.appspot.com/o/;" + "value": "default-src 'self'; child-src 'self' blob:; script-src 'self' 'unsafe-eval' blob:; connect-src https://*.ingest.sentry.io https://firestore.googleapis.com/ https://*.zkscan.io https://*.zksync.io https://*.zksync.dev https://storage.googleapis.com; style-src 'self' fonts.googleapis.com; font-src 'self' fonts.gstatic.com; img-src 'self' https://assets.coingecko.com blob: data: https://firebasestorage.googleapis.com/v0/b/token-library.appspot.com/o/;" } ] } diff --git a/packages/app/mock/transactions/Execute.json b/packages/app/mock/transactions/Execute.json index 5dd4e8d3e8..ade6fbb50d 100644 --- a/packages/app/mock/transactions/Execute.json +++ b/packages/app/mock/transactions/Execute.json @@ -34,7 +34,7 @@ "symbol": "LINK", "name": "ChainLink Token (goerli)", "decimals": 18, - "usdPrice": "1" + "usdPrice": 1 }, "from": "0xcfa3DD0CBa60484d1C8D0cDd22C5432013368875", "to": "0xde03a0B5963f75f1C8485B355fF6D30f3093BDE7", @@ -48,7 +48,7 @@ "symbol": "LINK", "name": "ChainLink Token (goerli)", "decimals": 18, - "usdPrice": "1" + "usdPrice": 1 }, "from": "0xcfa3DD0CBa60484d1C8D0cDd22C5432013368875", "to": "0x6c557bc88804254760Be210c01fd9B6B5dE96e53", @@ -63,7 +63,7 @@ "symbol": "LINK", "name": "ChainLink Token (goerli)", "decimals": 18, - "usdPrice": "1" + "usdPrice": 1 }, "from": "0xcfa3DD0CBa60484d1C8D0cDd22C5432013368875", "to": "0x6c557bc88804254760Be210c01fd9B6B5dE96e53", @@ -78,7 +78,7 @@ "symbol": "ETH", "name": "Ether", "decimals": 18, - "usdPrice": "1" + "usdPrice": 1 }, "from": "0xcfa3DD0CBa60484d1C8D0cDd22C5432013368875", "to": "0xde03a0B5963f75f1C8485B355fF6D30f3093BDE7", @@ -95,7 +95,7 @@ "symbol": "LINK", "name": "ChainLink Token (goerli)", "decimals": 18, - "usdPrice": "1" + "usdPrice": 1 }, "from": "0xcfa3DD0CBa60484d1C8D0cDd22C5432013368875", "to": "0x6c557bc88804254760Be210c01fd9B6B5dE96e53", @@ -114,7 +114,7 @@ "symbol": "LINK", "name": "ChainLink Token (goerli)", "decimals": 18, - "usdPrice": "1" + "usdPrice": 1 }, "from": "0xcfa3DD0CBa60484d1C8D0cDd22C5432013368875", "to": "0x6c557bc88804254760Be210c01fd9B6B5dE96e53", diff --git a/packages/app/package.json b/packages/app/package.json index 7dcfb315ae..9e7060b904 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -26,7 +26,6 @@ }, "dependencies": { "@matterlabs/composables": "1.1.7", - "@matterlabs/token-library": "2.9.0", "@vueuse/components": "8.9.2", "@vueuse/core": "8.9.2", "date-fns": "2.28.0", diff --git a/packages/app/src/components/FeeData.vue b/packages/app/src/components/FeeData.vue index 4663877049..fadf95e40d 100644 --- a/packages/app/src/components/FeeData.vue +++ b/packages/app/src/components/FeeData.vue @@ -62,7 +62,7 @@ import useToken from "@/composables/useToken"; import type { Token } from "@/composables/useToken"; import type { FeeData } from "@/composables/useTransaction"; -import { ETH_TOKEN } from "@/utils/constants"; +import { ETH_TOKEN_L2_ADDRESS } from "@/utils/constants"; const props = defineProps({ showDetails: { @@ -81,7 +81,7 @@ const collapsed = ref(false); const buttonTitle = computed(() => collapsed.value ? t("transactions.table.feeDetails.closeDetails") : t("transactions.table.feeDetails.moreDetails") ); -getTokenInfo(ETH_TOKEN.l2Address); +getTokenInfo(ETH_TOKEN_L2_ADDRESS); const initialFee = computed(() => { if (props.feeData) { @@ -89,8 +89,8 @@ const initialFee = computed(() => { } return null; }); -const token = computed(() => { - return tokenInfo.value ?? { ...ETH_TOKEN, usdPrice: null }; +const token = computed(() => { + return tokenInfo.value; });