Skip to content

Commit

Permalink
fix: chainId in vault factory
Browse files Browse the repository at this point in the history
  • Loading branch information
ev-d committed Dec 20, 2024
1 parent da76599 commit 784d2ee
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
11 changes: 6 additions & 5 deletions contracts/vault-factory.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { getContract, createPublicClient, http, Chain } from "viem";
import { VaultFactoryAbi } from "abi";
import { getDeployedAddress, envs } from "@configs";
import { getDeployedAddress, envs, getRpcUrl } from "@configs";

export const getVaultFactoryContract = (chainId?: Chain) => {
const rpcUrl = envs?.[`RPC_URL_${chainId || process.env.CHAIN_ID}`];
export const getVaultFactoryContract = (chain: Chain) => {
const rpcUrls = getRpcUrl() ?? envs?.[`RPC_URL_${chain}`];
const url = rpcUrls.split(',')[0];

return getContract({
address: getDeployedAddress("stakingVaultFactory"),
abi: VaultFactoryAbi,
client: createPublicClient({
chain: chainId,
transport: http(rpcUrl),
chain: chain,
transport: http(url),
}),
});
};
2 changes: 1 addition & 1 deletion programs/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// export * from "./vault-hub";
export * from "./vault-hub";
export * from "./vault";
export * from "./vault-factory";
8 changes: 5 additions & 3 deletions programs/vault-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ vaultFactory
operatorFee: string,
{ chainId, manager, operator }: ChainOption & { manager: Address, operator: Address }
) => {
const contract = getVaultFactoryContract(chainId);
const chain = chainId ?? getChainId()
const contract = getVaultFactoryContract(chain);
const managementFee = BigInt(ownerFee);
const performanceFee = BigInt(operatorFee);
const chain = chainId ?? getChainId()

console.log('vaultFactory::chain', chain)

const tx = await contract.write.createVault(
[
Expand All @@ -39,7 +41,7 @@ vaultFactory
],
{
account: getAccount(chain),
chain,
chain: chain,
}
);

Expand Down
5 changes: 3 additions & 2 deletions providers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {envs, getConfig, getChainId, getRpcUrl} from "@configs";

export const getWalletClient = (chainId?: Chain) => {
const chain = getChainId() ?? chainId;
const rpcUrl = getRpcUrl() ?? envs?.[`RPC_URL_${chain}`];
const rpcUrls = getRpcUrl() ?? envs?.[`RPC_URL_${chain}`];
const url = rpcUrls.split(',')[0];

const client = createWalletClient({
chain,
transport: http(rpcUrl),
transport: http(url),
});

return client;
Expand Down
1 change: 0 additions & 1 deletion utils/data-validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { JSONConfig } from "@types";
export const validateConfig = (config: JSONConfig) => {
const errors = {} as Record<keyof JSONConfig, string>;

console.log('validateConfig::config', config)
if (!isValidUrl(config.rpcLink)) {
errors.rpcLink = 'Invalid rpcLink: must be a valid URL.';
}
Expand Down

0 comments on commit 784d2ee

Please sign in to comment.