Skip to content

Commit

Permalink
fix(networks): namespace new network urls
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Dec 26, 2024
1 parent 557b25b commit b91d024
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const createChainHistoryProvider = (
const transactionsByAddresses = async (
args: TransactionsByAddressesArgs,
): Promise<Tx[]> => {
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)
Expand Down
2 changes: 1 addition & 1 deletion packages/vault/src/network-info/network-info-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { ProviderConfig } from "@palladxyz/providers"
export type NetworkId = string

export type NetworkInfoState = {
networkInfoV2: Record<NetworkId, ProviderConfig>
networkInfoV3: Record<NetworkId, ProviderConfig>
currentNetworkId: string
}

Expand Down
26 changes: 13 additions & 13 deletions packages/vault/src/network-info/network-info-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,49 @@ import { DEFAULT_NETWORK_INFO } from "./default"
import type { NetworkInfoStore } from "./network-info-state"

export const networkInfoSlice: StateCreator<NetworkInfoStore> = (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
}),
)
},
Expand Down
4 changes: 2 additions & 2 deletions packages/web-provider/src/vault-service/vault-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down

0 comments on commit b91d024

Please sign in to comment.