Skip to content

Commit

Permalink
Merge pull request #594 from liteflow-labs/dev
Browse files Browse the repository at this point in the history
Release v3.4.6
  • Loading branch information
NicolasMahe authored May 17, 2024
2 parents 4b98ac2 + d91f9f7 commit 44664fc
Show file tree
Hide file tree
Showing 10 changed files with 942 additions and 1,297 deletions.
2 changes: 1 addition & 1 deletion components/Cart/Step/Transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const CartStepTransaction: FC<Props> = ({
try {
setApprovalLoading((x) => ({ ...x, [currencyId]: true }))
const transaction = await sendTransaction(signer, tx)
await transaction.wait()
await signer.waitForTransactionReceipt({ hash: transaction.hash })
await fetchApproval({
variables: { accountAddress: address, items: approvalItems },
})
Expand Down
2 changes: 1 addition & 1 deletion components/CartContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber } from '@ethersproject/bignumber'
import { useBatchPurchase } from '@liteflow/react'
import { BigNumber } from 'ethers'
import { FC, PropsWithChildren, useCallback, useEffect, useState } from 'react'
import useAccount from '../hooks/useAccount'
import { CartItem, CartContext as Context } from '../hooks/useCart'
Expand Down
3 changes: 1 addition & 2 deletions hooks/useAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export default function useAccount(): AccountDetail {
const login = useCallback(
async (connector: Connector) => {
const wallet = await connector.getWalletClient()
const signer = walletClientToSigner(wallet)
const currentAddress = (await signer.getAddress()).toLowerCase()
const currentAddress = wallet.account.address.toLowerCase()
if (jwt && currentAddress === jwt.address) {
setAuthenticationToken(jwt.token)
// fully login, nothing to do
Expand Down
2 changes: 1 addition & 1 deletion hooks/useFees.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber } from 'ethers'
import { BigNumber } from '@ethersproject/bignumber'
import { useEffect, useMemo, useState } from 'react'
import { useFeesLazyQuery } from '../graphql'

Expand Down
20 changes: 6 additions & 14 deletions hooks/useSigner.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import { Signer, TypedDataSigner } from '@ethersproject/abstract-signer'
import { ExternalProvider } from '@ethersproject/providers'
import { providers } from 'ethers'
import { Signer } from '@liteflow/core'
import { useMemo } from 'react'
import type { WalletClient } from 'wagmi'
import { useWalletClient } from 'wagmi'
import { publicActions } from 'viem'
import { WalletClient, useWalletClient } from 'wagmi'
import useAccount from './useAccount'

/**
* Hook returning the current signer logged in to the website. This signer can and should
* be used to sign messages or transactions
* @returns (Signer & TypedDataSigner) | undefined
*/

export function walletClientToSigner(
walletClient: WalletClient,
): providers.JsonRpcSigner {
const { account, transport } = walletClient
const provider = new providers.Web3Provider(transport as ExternalProvider)
const signer = provider.getSigner(account.address)
return signer
export function walletClientToSigner(walletClient: WalletClient): Signer {
return walletClient?.extend(publicActions)
}

export default function useSigner(): (Signer & TypedDataSigner) | undefined {
export default function useSigner(): Signer | undefined {
const { data: walletClient } = useWalletClient()
const { isLoggedIn } = useAccount()

Expand Down
Loading

0 comments on commit 44664fc

Please sign in to comment.