From 8dcccc086e8a9a06b04238a9f2ee2911e41da385 Mon Sep 17 00:00:00 2001 From: Francisco Ramos Date: Wed, 15 Mar 2023 10:22:47 +0100 Subject: [PATCH] chore(bridge-ui): remove unnecessary interface (#13322) --- packages/bridge-ui/src/App.svelte | 5 ++--- ...ustomTokenService.ts => CustomTokenService.ts} | 13 +++---------- .../{service.spec.ts => StorageService.spec.ts} | 9 ++------- .../src/storage/{service.ts => StorageService.ts} | 15 ++++----------- 4 files changed, 11 insertions(+), 31 deletions(-) rename packages/bridge-ui/src/storage/{customTokenService.ts => CustomTokenService.ts} (84%) rename packages/bridge-ui/src/storage/{service.spec.ts => StorageService.spec.ts} (97%) rename packages/bridge-ui/src/storage/{service.ts => StorageService.ts} (93%) diff --git a/packages/bridge-ui/src/App.svelte b/packages/bridge-ui/src/App.svelte index a16c1ed7d5b..8d7b71bfa8b 100644 --- a/packages/bridge-ui/src/App.svelte +++ b/packages/bridge-ui/src/App.svelte @@ -42,13 +42,13 @@ import { ethers } from 'ethers'; import type { Prover } from './domain/proof'; import { successToast } from './utils/toast'; - import { StorageService } from './storage/service'; + import { StorageService } from './storage/StorageService'; import { MessageStatus } from './domain/message'; import BridgeABI from './constants/abi/Bridge'; import { providers } from './store/providers'; import HeaderAnnouncement from './components/HeaderAnnouncement.svelte'; import type { TokenService } from './domain/token'; - import { CustomTokenService } from './storage/customTokenService'; + import { CustomTokenService } from './storage/CustomTokenService'; import { userTokens, tokenService } from './store/userToken'; import RelayerAPIService from './relayer-api/service'; import type { RelayerAPI } from './domain/relayerApi'; @@ -146,7 +146,6 @@ const apiTxs = await $relayerApi.GetAllByAddress(userAddress); - const blockInfoMap = await $relayerApi.GetBlockInfo(); relayerBlockInfoMap.set(blockInfoMap); diff --git a/packages/bridge-ui/src/storage/customTokenService.ts b/packages/bridge-ui/src/storage/CustomTokenService.ts similarity index 84% rename from packages/bridge-ui/src/storage/customTokenService.ts rename to packages/bridge-ui/src/storage/CustomTokenService.ts index ce0a69ea16f..360f7dca6f0 100644 --- a/packages/bridge-ui/src/storage/customTokenService.ts +++ b/packages/bridge-ui/src/storage/CustomTokenService.ts @@ -1,14 +1,9 @@ import type { Token, TokenService } from 'src/domain/token'; -interface storage { - getItem(key: string): string; - setItem(key: string, value: string); -} - -class CustomTokenService implements TokenService { - private readonly storage: storage; +export class CustomTokenService implements TokenService { + private readonly storage: Storage; - constructor(storage: storage) { + constructor(storage: Storage) { this.storage = storage; } @@ -57,5 +52,3 @@ class CustomTokenService implements TokenService { return updatedTokenList; } } - -export { CustomTokenService }; diff --git a/packages/bridge-ui/src/storage/service.spec.ts b/packages/bridge-ui/src/storage/StorageService.spec.ts similarity index 97% rename from packages/bridge-ui/src/storage/service.spec.ts rename to packages/bridge-ui/src/storage/StorageService.spec.ts index 31d11c3dfbc..b4e31254110 100644 --- a/packages/bridge-ui/src/storage/service.spec.ts +++ b/packages/bridge-ui/src/storage/StorageService.spec.ts @@ -1,13 +1,8 @@ import { BigNumber, BigNumberish, ethers } from 'ethers'; import { TKO } from '../domain/token'; -import { - CHAIN_ID_MAINNET, - CHAIN_ID_TAIKO, - CHAIN_MAINNET, - CHAIN_TKO, -} from '../domain/chain'; +import { CHAIN_ID_MAINNET, CHAIN_ID_TAIKO } from '../domain/chain'; import { MessageStatus } from '../domain/message'; -import { StorageService } from './service'; +import { StorageService } from './StorageService'; import type { BridgeTransaction } from '../domain/transactions'; const mockStorage = { getItem: jest.fn(), diff --git a/packages/bridge-ui/src/storage/service.ts b/packages/bridge-ui/src/storage/StorageService.ts similarity index 93% rename from packages/bridge-ui/src/storage/service.ts rename to packages/bridge-ui/src/storage/StorageService.ts index 27997be07c5..c0463f85132 100644 --- a/packages/bridge-ui/src/storage/service.ts +++ b/packages/bridge-ui/src/storage/StorageService.ts @@ -1,24 +1,19 @@ import type { BridgeTransaction, Transactioner } from '../domain/transactions'; import { BigNumber, Contract, ethers } from 'ethers'; import Bridge from '../constants/abi/Bridge'; -import { chains, CHAIN_MAINNET, CHAIN_TKO } from '../domain/chain'; +import { chains } from '../domain/chain'; import TokenVault from '../constants/abi/TokenVault'; import { chainIdToTokenVaultAddress } from '../store/bridge'; import { get } from 'svelte/store'; import ERC20 from '../constants/abi/ERC20'; import { MessageStatus } from '../domain/message'; -interface storage { - getItem(key: string): string; - setItem(key: string, value: unknown): void; -} - -class StorageService implements Transactioner { - private readonly storage: storage; +export class StorageService implements Transactioner { + private readonly storage: Storage; private readonly providerMap: Map; constructor( - storage: storage, + storage: Storage, providerMap: Map, ) { this.storage = storage; @@ -154,5 +149,3 @@ class StorageService implements Transactioner { ); } } - -export { StorageService };