Skip to content

Commit

Permalink
fixing the getPublicClient
Browse files Browse the repository at this point in the history
  • Loading branch information
szmizorsz committed Apr 5, 2024
1 parent b7c796f commit 549b830
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/utils/getPublicClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import { PublicClient, publicActions } from "viem";
import { PublicOrWalletClient } from "../lib/types";

export const getPublicClient = (client: PublicOrWalletClient): PublicClient => {
let publicClient: PublicClient;
if (client.type === "walletClient") {
publicClient = client.extend(publicActions) as PublicClient;
} else {
// publicClient
publicClient = client as PublicClient;
}
const publicClient: PublicClient = client.extend(
publicActions
) as PublicClient;

return publicClient;
};
4 changes: 1 addition & 3 deletions src/utils/signTypedDataV4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
CallWithSyncFeeConcurrentERC2771PayloadToSign,
} from "../lib/erc2771/types";

import { isWalletClient } from "./isSigner";

export const signTypedDataV4 = async (
client: PublicOrWalletClient,
payload:
Expand All @@ -16,7 +14,7 @@ export const signTypedDataV4 = async (
| SponsoredCallConcurrentERC2771PayloadToSign
| CallWithSyncFeeConcurrentERC2771PayloadToSign
): Promise<string> => {
if (!isWalletClient(client) || !client.account) {
if (!client.account) {
throw new Error(
"The provided client is not a wallet client, or account not found on the client. Please, provide an account during the client creation."
);
Expand Down

0 comments on commit 549b830

Please sign in to comment.