diff --git a/centrifuge-app/src/components/InvestRedeem/InvestRedeemLiquidityPoolsProvider.tsx b/centrifuge-app/src/components/InvestRedeem/InvestRedeemLiquidityPoolsProvider.tsx index 411c5c070d..746e8a3e1d 100644 --- a/centrifuge-app/src/components/InvestRedeem/InvestRedeemLiquidityPoolsProvider.tsx +++ b/centrifuge-app/src/components/InvestRedeem/InvestRedeemLiquidityPoolsProvider.tsx @@ -40,12 +40,13 @@ export function InvestRedeemLiquidityPoolsProvider({ poolId, trancheId, children isLoading: isInvestmentLoading, } = useLiquidityPoolInvestment(poolId, trancheId, lpIndex) const provider = useEvmProvider() + const { evm } = useWallet() + const chainId = evm.chainId || 1 const isAllowedToInvest = lpInvest?.isAllowedToInvest const tranche = pool.tranches.find((t) => t.id === trancheId) const { data: metadata, isLoading: isMetadataLoading } = usePoolMetadata(pool) const trancheMeta = metadata?.tranches?.[trancheId] - const chainId = Number(provider?._network.chainId) if (!tranche) throw new Error(`Token not found. Pool id: ${poolId}, token id: ${trancheId}`) diff --git a/centrifuge-app/src/components/OnboardingAuthProvider.tsx b/centrifuge-app/src/components/OnboardingAuthProvider.tsx index 4c15f1bb01..91b7769afe 100644 --- a/centrifuge-app/src/components/OnboardingAuthProvider.tsx +++ b/centrifuge-app/src/components/OnboardingAuthProvider.tsx @@ -59,12 +59,13 @@ export function OnboardingAuthProvider({ children }: { children: React.ReactNode const { mutate: login, isLoading: isLoggingIn } = useMutation(async () => { try { + const signer = await provider?.getSigner() if (selectedAccount?.address && selectedWallet?.signer) { await loginWithSubstrate(selectedAccount?.address, selectedWallet.signer as Signer, cent, proxy) - } else if (isEvmOnSubstrate && selectedAddress && provider?.getSigner()) { - await loginWithEvm(selectedAddress, provider.getSigner(), evmChainId, isEvmOnSubstrate) - } else if (selectedAddress && provider?.getSigner()) { - await loginWithEvm(selectedAddress, provider.getSigner(), evm.chainId) + } else if (isEvmOnSubstrate && selectedAddress && signer) { + await loginWithEvm(selectedAddress, signer, evmChainId, isEvmOnSubstrate) + } else if (selectedAddress && signer) { + await loginWithEvm(selectedAddress, signer, evm.chainId) } throw new Error('network not supported') } catch { diff --git a/centrifuge-js/src/utils/signERC2612Permit.ts b/centrifuge-js/src/utils/signERC2612Permit.ts index 0a3d70badf..4d9258d45d 100644 --- a/centrifuge-js/src/utils/signERC2612Permit.ts +++ b/centrifuge-js/src/utils/signERC2612Permit.ts @@ -1,4 +1,4 @@ -import { ethers } from 'ethers' +import { Contract, Signature } from 'ethers' export async function signERC2612Permit( provider: any, @@ -9,7 +9,7 @@ export async function signERC2612Permit( deadline: number ) { const tokenAddress = typeof token === 'string' ? token : token.verifyingContract - const tokenContract = new ethers.Contract( + const tokenContract = new Contract( tokenAddress, ['function name() view returns (string)', 'function nonces(address) view returns (uint256)'], provider @@ -51,9 +51,8 @@ export async function signERC2612Permit( deadline, } - const signer = await provider.getSigner(owner) - const signature = await signer.signTypedData(domain, types, values) - const { v, r, s } = ethers.Signature.from(signature) + const signature = await provider.signTypedData(domain, types, values) + const { v, r, s } = Signature.from(signature) return { owner,