Skip to content

Commit

Permalink
fix: update service wallet logic to use selected home chain dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Dec 18, 2024
1 parent 7c2ba1c commit 44263de
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions frontend/hooks/useService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { useMemo } from 'react';

import {
MiddlewareBuildingStatuses,
MiddlewareChain,
MiddlewareDeploymentStatus,
MiddlewareRunningStatuses,
MiddlewareTransitioningStatuses,
} from '@/client';
import { EvmChainId } from '@/enums/Chain';
import {
AgentEoa,
AgentSafe,
Expand Down Expand Up @@ -54,12 +52,12 @@ export const useService = (serviceConfigId?: string) => {
return service?.chain_configs?.[service?.home_chain]?.chain_data.token;
}, [service?.chain_configs, service?.home_chain]);

// TODO: quick hack to fix for refactor (only predict), will make it dynamic later
const serviceWallets: AgentWallets = useMemo(() => {
if (!service) return [];
if (!service.chain_configs?.[MiddlewareChain.GNOSIS]) return [];
if (!selectedService?.home_chain) return [];
if (!service.chain_configs?.[selectedService?.home_chain]) return [];

const chainConfig = service.chain_configs[MiddlewareChain.GNOSIS];
const chainConfig = service.chain_configs[selectedService?.home_chain];
if (!chainConfig) return [];

return [
Expand All @@ -77,12 +75,12 @@ export const useService = (serviceConfigId?: string) => {
address: chainConfig.chain_data.multisig,
owner: WalletOwnerType.Agent,
type: WalletType.Safe,
evmChainId: EvmChainId.Gnosis,
evmChainId: asEvmChainId(selectedService?.home_chain),
} as AgentSafe,
]
: []),
];
}, [service]);
}, [service, selectedService]);

const addresses: ServiceChainIdAddressRecord = useMemo(() => {
if (!service) return {};
Expand Down

0 comments on commit 44263de

Please sign in to comment.