Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fetching chain id #2506

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)

Expand Down
9 changes: 5 additions & 4 deletions centrifuge-app/src/components/OnboardingAuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions centrifuge-js/src/utils/signERC2612Permit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers } from 'ethers'
import { Contract, Signature } from 'ethers'

export async function signERC2612Permit(
provider: any,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading