Skip to content

Commit

Permalink
Merge branch 'main' into sign-attestation-before-nav-update
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn authored Oct 18, 2024
2 parents 99ea16f + 727d4c3 commit f675b60
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
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

0 comments on commit f675b60

Please sign in to comment.