Skip to content

Commit

Permalink
Merge pull request #1031 from lens-protocol/cesare/T-23349-sdk-ethers…
Browse files Browse the repository at this point in the history
…-support-for-op-handling

fix: OperationHandler type
  • Loading branch information
cesarenaldi authored Dec 17, 2024
2 parents 3c724cb + ffe498d commit 4ee4d68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
7 changes: 4 additions & 3 deletions packages/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type DelegableOperationHandler<T extends string, E extends string> = (
result: DelegableOperationResult<T, E>,
) => ResultAsync<TxHash, SigningError | ValidationError<E>>;

export type OperationHandler<T extends string, E extends string> =
| RestrictedOperationHandler<E>
| DelegableOperationHandler<T, E>;
export type OperationHandler<
T extends string = string,
E extends string = string,
> = T extends string ? DelegableOperationHandler<T, E> : RestrictedOperationHandler<E>;
18 changes: 3 additions & 15 deletions packages/client/src/viem/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ import type { Account, Hash, Transport, WalletClient } from 'viem';
import { sendTransaction as sendEip1559Transaction } from 'viem/actions';
import { sendEip712Transaction } from 'viem/zksync';
import { SigningError, ValidationError } from '../errors';
import {
type DelegableOperationHandler,
type OperationHandler,
type OperationResult,
type RestrictedOperationHandler,
isTransactionRequest,
} from '../types';
import { type OperationHandler, type OperationResult, isTransactionRequest } from '../types';

async function sendTransaction(
walletClient: WalletClient<Transport, chains.LensNetworkChain, Account>,
Expand Down Expand Up @@ -69,15 +63,9 @@ function signWith(
);
}

export function handleWith<T extends string, E extends string>(
walletClient: WalletClient<Transport, chains.LensNetworkChain, Account>,
): DelegableOperationHandler<T, E>;
export function handleWith<E extends string>(
walletClient: WalletClient<Transport, chains.LensNetworkChain, Account>,
): RestrictedOperationHandler<E>;
export function handleWith<T extends string, E extends string>(
export function handleWith(
walletClient: WalletClient<Transport, chains.LensNetworkChain, Account>,
): OperationHandler<T, E> {
): OperationHandler {
return <T extends string, E extends string>(
result: OperationResult<T, E>,
): ResultAsync<TxHash, SigningError | ValidationError<E>> => {
Expand Down

0 comments on commit 4ee4d68

Please sign in to comment.