diff --git a/package.json b/package.json index c494a3769a..2b9579365b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,6 @@ "clsx": "^2.1.1", "graphql": "^14 || ^15 || ^16", "graphql-request": "^6.1.0", - "permissionless": "^0.2.10", "tailwind-merge": "^2.3.0", "viem": "^2.21.33", "wagmi": "^2.12.24" diff --git a/playground/nextjs-app-router/bun.lockb b/playground/nextjs-app-router/bun.lockb index a0230b737e..03e209c819 100755 Binary files a/playground/nextjs-app-router/bun.lockb and b/playground/nextjs-app-router/bun.lockb differ diff --git a/playground/nextjs-app-router/package.json b/playground/nextjs-app-router/package.json index 5d2abb21e6..59bac9eb42 100644 --- a/playground/nextjs-app-router/package.json +++ b/playground/nextjs-app-router/package.json @@ -35,7 +35,6 @@ "graphql-request": "^6.1.0", "lucide-react": "^0.416.0", "next": "^14.2.5", - "permissionless": "^0.2.10", "react": "^18", "react-dom": "^18", "tailwind-merge": "^2.4.0", diff --git a/src/transaction/components/Transaction.tsx b/src/transaction/components/Transaction.tsx index d06f44fd0a..ac47c86e9d 100644 --- a/src/transaction/components/Transaction.tsx +++ b/src/transaction/components/Transaction.tsx @@ -11,6 +11,7 @@ export function Transaction({ chainId, className, children, + contracts, isSponsored, onError, onStatus, @@ -34,6 +35,7 @@ export function Transaction({ calls={calls} capabilities={capabilities} chainId={accountChainId} + contracts={contracts} isSponsored={isSponsored} onError={onError} onStatus={onStatus} diff --git a/src/transaction/components/TransactionProvider.test.tsx b/src/transaction/components/TransactionProvider.test.tsx index dc33d157c7..a3ad83884f 100644 --- a/src/transaction/components/TransactionProvider.test.tsx +++ b/src/transaction/components/TransactionProvider.test.tsx @@ -523,7 +523,21 @@ describe('TransactionProvider', () => { , ); }).toThrowError( - 'Transaction: calls must be provided as a prop to the Transaction component.', + 'Transaction: calls or contracts must be provided as a prop to the Transaction component.', + ); + restore(); + }); + + it('should throw an error when both contracts and calls are provided', async () => { + const restore = silenceError(); + expect(() => { + render( + +
Test
+
, + ); + }).toThrowError( + 'Transaction: Only one of contracts or calls can be provided as a prop to the Transaction component.', ); restore(); }); diff --git a/src/transaction/components/TransactionProvider.tsx b/src/transaction/components/TransactionProvider.tsx index dcd54fed8e..148cc5cc48 100644 --- a/src/transaction/components/TransactionProvider.tsx +++ b/src/transaction/components/TransactionProvider.tsx @@ -50,6 +50,7 @@ export function TransactionProvider({ capabilities: transactionCapabilities, chainId, children, + contracts, isSponsored, onError, onStatus, @@ -74,7 +75,7 @@ export function TransactionProvider({ number | undefined >(); const [transactionHashList, setTransactionHashList] = useState([]); - const transactions = calls; + const transactions = calls || contracts; // Retrieve wallet capabilities const walletCapabilities = useCapabilitiesSafe({ @@ -84,9 +85,16 @@ export function TransactionProvider({ const { switchChainAsync } = useSwitchChain(); // Validate `calls` props - if (!calls) { + if (!calls && !contracts) { throw new Error( - 'Transaction: calls must be provided as a prop to the Transaction component.', + 'Transaction: calls or contracts must be provided as a prop to the Transaction component.', + ); + } + + // Validate `calls` and `contracts` props + if (calls && contracts) { + throw new Error( + 'Transaction: Only one of contracts or calls can be provided as a prop to the Transaction component.', ); } diff --git a/src/transaction/types.ts b/src/transaction/types.ts index 4c71205bb7..1196271479 100644 --- a/src/transaction/types.ts +++ b/src/transaction/types.ts @@ -149,6 +149,10 @@ export type TransactionProviderReact = { capabilities?: WalletCapabilities; // Capabilities that a wallet supports (e.g. paymasters, session keys, etc). chainId: number; // The chainId for the transaction. children: ReactNode; // The child components to be rendered within the provider component. + /** + * @deprecated Use `calls` instead. + */ + contracts?: Calls | Contracts | (Call | ContractFunctionParameters)[]; // An array of calls to be made in the transaction. isSponsored?: boolean; // Whether the transactions are sponsored (default: false) onError?: (e: TransactionError) => void; // An optional callback function that handles errors within the provider. onStatus?: (lifecycleStatus: LifecycleStatus) => void; // An optional callback function that exposes the component lifecycle state @@ -167,6 +171,10 @@ export type TransactionReact = { chainId?: number; // The chainId for the transaction. children: ReactNode; // The child components to be rendered within the transaction component. className?: string; // An optional CSS class name for styling the component. + /** + * @deprecated Use `calls` instead. + */ + contracts?: Calls | Contracts | (Call | ContractFunctionParameters)[]; // An array of calls to be made in the transaction. isSponsored?: boolean; // Whether the transactions are sponsored (default: false) onError?: (e: TransactionError) => void; // An optional callback function that handles transaction errors. onStatus?: (lifecycleStatus: LifecycleStatus) => void; // An optional callback function that exposes the component lifecycle state diff --git a/src/wallet/utils/isWalletACoinbaseSmartWallet.test.ts b/src/wallet/utils/isWalletACoinbaseSmartWallet.test.ts index cf07dae87d..56854fce7b 100644 --- a/src/wallet/utils/isWalletACoinbaseSmartWallet.test.ts +++ b/src/wallet/utils/isWalletACoinbaseSmartWallet.test.ts @@ -1,4 +1,4 @@ -import type { UserOperation } from 'permissionless'; +import type { UserOperation } from 'viem/_types/account-abstraction'; import type { PublicClient } from 'viem'; import { type Mock, describe, expect, it, vi } from 'vitest'; import {