diff --git a/background/services/block/db.ts b/background/services/block/db.ts index 058979b4..88f2077c 100644 --- a/background/services/block/db.ts +++ b/background/services/block/db.ts @@ -2,7 +2,6 @@ import Dexie, { DexieOptions } from "dexie" import { AnyEVMBlock } from "../../networks" import { NetworkInterface } from "../../constants/networks/networkTypes" -import { ChainDatabase } from "../chain/db" export class BlockDatabase extends Dexie { private blocks!: Dexie.Table diff --git a/background/services/block/index.ts b/background/services/block/index.ts index 7abe8eae..a2aaa185 100644 --- a/background/services/block/index.ts +++ b/background/services/block/index.ts @@ -1,4 +1,4 @@ -import { getZoneForAddress, JsonRpcProvider, Shard, Zone } from "quais" +import { JsonRpcProvider, Shard, toZone } from "quais" import { NetworkInterface } from "../../constants/networks/networkTypes" import logger from "../../lib/logger" import { AnyEVMBlock, BlockPrices, toHexChainID } from "../../networks" @@ -144,9 +144,9 @@ export default class BlockService extends BaseService { async getBlockPrices( network: NetworkInterface, provider: JsonRpcProvider, - shard: Shard, - zone: Zone + shard: Shard ): Promise { + const zone = toZone(shard) const [currentBlock, feeData] = await Promise.all([ provider.getBlock(shard, "latest"), provider.getFeeData(zone), @@ -232,16 +232,15 @@ export default class BlockService extends BaseService { const { address } = await this.preferenceService.getSelectedAccount() const shard = getExtendedZoneForAddress(address, false) as Shard - const zone = getZoneForAddress(address) - if (!zone) { - logger.warn(`Can't get zone for ${address}`) + + if (!shard) { + logger.warn(`Can't get shard for ${address}`) return } const blockPrices = await this.getBlockPrices( subscription.network, subscription.provider, - shard, - zone + shard ) await this.emitter.emit("blockPrices", { blockPrices, diff --git a/background/services/chain/index.ts b/background/services/chain/index.ts index 2854df40..6c2144ae 100644 --- a/background/services/chain/index.ts +++ b/background/services/chain/index.ts @@ -790,7 +790,7 @@ export default class ChainService extends BaseService { }: AddressOnNetwork): Promise { const addressWasInactive = this.addressIsInactive(address) const networkWasInactive = this.networkIsInactive(network.chainID) - this.markNetworkActivity(network.chainID) + this.lastUserActivityOnNetwork[network.chainID] = Date.now() this.lastUserActivityOnAddress[address] = Date.now() if (addressWasInactive || networkWasInactive) { // Reactivating a potentially deactivated address @@ -799,15 +799,6 @@ export default class ChainService extends BaseService { } } - async markNetworkActivity(chainID: string): Promise { - const networkWasInactive = this.networkIsInactive(chainID) - this.lastUserActivityOnNetwork[chainID] = Date.now() - if (networkWasInactive) { - // TODO - // await this.blockService.pollBlockPricesForNetwork(chainID) - } - } - addressIsInactive(address: string): boolean { return ( Date.now() - NETWORK_POLLING_TIMEOUT > diff --git a/background/services/chain/tests/index.unit.test.ts b/background/services/chain/tests/index.unit.test.ts index 996563ca..99c0b0f9 100644 --- a/background/services/chain/tests/index.unit.test.ts +++ b/background/services/chain/tests/index.unit.test.ts @@ -86,8 +86,6 @@ describe("Chain Service", () => { jest.advanceTimersByTime(100) - chainService.markNetworkActivity(QuaiGoldenAgeTestnet.chainID) - expect(lastUserActivity).toBeLessThan( (chainService as unknown as ChainServiceExternalized) .lastUserActivityOnNetwork[QuaiGoldenAgeTestnet.chainID] @@ -123,18 +121,6 @@ describe("Chain Service", () => { await chainService.stopService() }) - it("should call markNetworkActivity with the correct network", async () => { - const stub = sandbox - .stub(chainService, "markNetworkActivity") - .callsFake(async () => {}) - - chainService.markAccountActivity( - createAddressOnNetwork({ network: QuaiGoldenAgeTestnet }) - ) - - expect(stub.calledWith(QuaiGoldenAgeTestnet.chainID)).toEqual(true) - }) - it("should call loadRecentAssetTransfers if the NETWORK_POLLING_TIMEOUT has been exceeded", async () => { const account = createAddressOnNetwork({ network: QuaiGoldenAgeTestnet })