From b91d0241bbe16a5f0e8c8f2ba6ed736e0e728f52 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Thu, 26 Dec 2024 09:28:45 +0100 Subject: [PATCH] fix(networks): namespace new network urls --- .../chain-history/chain-history-provider.ts | 1 - .../src/network-info/network-info-state.ts | 2 +- .../src/network-info/network-info-store.ts | 26 +++++++++---------- .../src/vault-service/vault-service.ts | 4 +-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/providers/src/blockberry-provider/chain-history/chain-history-provider.ts b/packages/providers/src/blockberry-provider/chain-history/chain-history-provider.ts index f4be3aa3..7a6b5de4 100644 --- a/packages/providers/src/blockberry-provider/chain-history/chain-history-provider.ts +++ b/packages/providers/src/blockberry-provider/chain-history/chain-history-provider.ts @@ -35,7 +35,6 @@ export const createChainHistoryProvider = ( const transactionsByAddresses = async ( args: TransactionsByAddressesArgs, ): Promise => { - console.log(">>>>ARGS", args, url) const limit = 50 const endpoint = `${url}/v1/accounts/${args.addresses[0]}/txs?page=0&sortBy=AGE&orderBy=DESC&size=${limit}&direction=ALL` const response = await fetch(endpoint) diff --git a/packages/vault/src/network-info/network-info-state.ts b/packages/vault/src/network-info/network-info-state.ts index 7271190d..46ae8293 100644 --- a/packages/vault/src/network-info/network-info-state.ts +++ b/packages/vault/src/network-info/network-info-state.ts @@ -8,7 +8,7 @@ import type { ProviderConfig } from "@palladxyz/providers" export type NetworkId = string export type NetworkInfoState = { - networkInfoV2: Record + networkInfoV3: Record currentNetworkId: string } diff --git a/packages/vault/src/network-info/network-info-store.ts b/packages/vault/src/network-info/network-info-store.ts index 60dc8c51..cb1e71e7 100644 --- a/packages/vault/src/network-info/network-info-store.ts +++ b/packages/vault/src/network-info/network-info-store.ts @@ -5,49 +5,49 @@ import { DEFAULT_NETWORK_INFO } from "./default" import type { NetworkInfoStore } from "./network-info-state" export const networkInfoSlice: StateCreator = (set, get) => ({ - networkInfoV2: DEFAULT_NETWORK_INFO, + networkInfoV3: DEFAULT_NETWORK_INFO, currentNetworkId: process.env.VITE_APP_DEFAULT_NETWORK_ID ?? "mina:mainnet", setCurrentNetworkId: (networkId) => { return set({ currentNetworkId: networkId }) }, getCurrentNetworkInfo: () => { - const { networkInfoV2, currentNetworkId } = get() - return Object.values(networkInfoV2).find( + const { networkInfoV3, currentNetworkId } = get() + return Object.values(networkInfoV3).find( (network) => network.networkId === currentNetworkId, ) }, setNetworkInfo: (networkId, providerConfig) => { - const { networkInfoV2 } = get() + const { networkInfoV3 } = get() set((current) => produce(current, (draft) => { - draft.networkInfoV2[networkId] = { - ...networkInfoV2[networkId], + draft.networkInfoV3[networkId] = { + ...networkInfoV3[networkId], ...providerConfig, } }), ) }, getNetworkInfo: (networkId) => { - const { networkInfoV2 } = get() - return networkInfoV2[networkId] || undefined + const { networkInfoV3 } = get() + return networkInfoV3[networkId] || undefined }, removeNetworkInfo: (networkId) => { set((current) => produce(current, (draft) => { - delete draft.networkInfoV2[networkId] + delete draft.networkInfoV3[networkId] }), ) }, allNetworkInfo: () => { - const { networkInfoV2 } = get() - return Object.keys(networkInfoV2).map( - (networkId) => networkInfoV2[networkId], + const { networkInfoV3 } = get() + return Object.keys(networkInfoV3).map( + (networkId) => networkInfoV3[networkId], ) }, clearNetworkInfo: () => { set((current) => produce(current, (draft) => { - draft.networkInfoV2 = DEFAULT_NETWORK_INFO + draft.networkInfoV3 = DEFAULT_NETWORK_INFO }), ) }, diff --git a/packages/web-provider/src/vault-service/vault-service.ts b/packages/web-provider/src/vault-service/vault-service.ts index 70b93da7..13ea006c 100644 --- a/packages/web-provider/src/vault-service/vault-service.ts +++ b/packages/web-provider/src/vault-service/vault-service.ts @@ -163,8 +163,8 @@ export const createVaultService = (): IVaultService => { } }, requestNetwork: async () => { - const { currentNetworkId, networkInfoV2 } = useVault.getState() - const currentNetwork = networkInfoV2[currentNetworkId] + const { currentNetworkId, networkInfoV3 } = useVault.getState() + const currentNetwork = networkInfoV3[currentNetworkId] if (!currentNetwork) { throw new Error( `Network Configuration is not defined for the networkId: ${currentNetworkId}`,