Skip to content

Commit 36f7a8e

Browse files
authored
chore: deprecate code (#2312)
1 parent 6adfdc2 commit 36f7a8e

27 files changed

+110
-610
lines changed

packages/onchainkit/src/buy/components/BuyButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ export function BuyButton() {
7777
}, [statusName, isDropdownOpen]);
7878

7979
if (!isDisabled && !address) {
80-
return <ConnectWallet text="Buy" className="h-12 w-24 min-w-24" />;
80+
return (
81+
<ConnectWallet disconnectedLabel="Buy" className="h-12 w-24 min-w-24" />
82+
);
8183
}
8284

8385
return (

packages/onchainkit/src/core/types.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ export type IsBaseOptions = {
6363
isMainnetOnly?: boolean;
6464
};
6565

66-
/**
67-
* @deprecated Use IsBaseOptions instead
68-
*/
69-
export type isBaseOptions = IsBaseOptions;
70-
7166
/**
7267
* Note: exported as public Type
7368
*/
@@ -78,11 +73,6 @@ export type IsEthereumOptions = {
7873
isMainnetOnly?: boolean;
7974
};
8075

81-
/**
82-
* @deprecated Use IsEthereumOptions instead
83-
*/
84-
export type isEthereumOptions = IsEthereumOptions;
85-
8676
export type Mode = 'auto' | 'light' | 'dark';
8777

8878
/**

packages/onchainkit/src/earn/components/DepositButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function DepositButton({ className }: DepositButtonReact) {
6767
return (
6868
<ConnectWallet
6969
className={cn('w-full', className)}
70-
text="Connect to deposit"
70+
disconnectedLabel="Connect to deposit"
7171
/>
7272
);
7373
}

packages/onchainkit/src/earn/components/WithdrawButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function WithdrawButton({ className }: WithdrawButtonReact) {
6565
return (
6666
<ConnectWallet
6767
className={cn('w-full', className)}
68-
text="Connect to withdraw"
68+
disconnectedLabel="Connect to withdraw"
6969
/>
7070
);
7171
}

packages/onchainkit/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export type {
1414
IsEthereumOptions,
1515
OnchainKitConfig,
1616
OnchainKitContextType,
17-
isBaseOptions,
18-
isEthereumOptions,
1917
} from './core/types';
2018

2119
export type { OnchainKitProviderReact } from './types';

packages/onchainkit/src/nft/components/NFTCardDefault.test.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ describe('NFTCardDefault', () => {
2626
<NFTCardDefault contractAddress="0x123" tokenId="1" />,
2727
);
2828

29-
expect(getByTestId('nft-media')).toBeInTheDocument();
30-
expect(getByTestId('nft-title')).toBeInTheDocument();
31-
expect(getByTestId('nft-owner')).toBeInTheDocument();
32-
expect(getByTestId('nft-last-sold-price')).toBeInTheDocument();
33-
expect(getByTestId('nft-network')).toBeInTheDocument();
29+
expect(getByTestId('nft-card')).toBeInTheDocument();
3430
});
3531
});
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
'use client';
22
import type { NFTCardDefaultReact } from '@/nft/types';
33
import { NFTCard } from './NFTCard';
4-
import {
5-
NFTLastSoldPrice,
6-
NFTMedia,
7-
NFTNetwork,
8-
NFTOwner,
9-
NFTTitle,
10-
} from './view';
114

125
/**
136
* @deprecated Use the `NFTCard` component instead with no 'children' props.
@@ -28,12 +21,6 @@ export function NFTCardDefault({
2821
onStatus={onStatus}
2922
onSuccess={onSuccess}
3023
onError={onError}
31-
>
32-
<NFTMedia />
33-
<NFTTitle />
34-
<NFTOwner />
35-
<NFTLastSoldPrice />
36-
<NFTNetwork />
37-
</NFTCard>
24+
/>
3825
);
3926
}

packages/onchainkit/src/transaction/components/Transaction.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('Transaction', () => {
7777
capabilities={{}}
7878
chainId={123}
7979
className="test-class"
80-
contracts={[]}
80+
calls={[]}
8181
onError={vi.fn()}
8282
onSuccess={vi.fn()}
8383
>
@@ -93,7 +93,7 @@ describe('Transaction', () => {
9393
capabilities={{}}
9494
chainId={123}
9595
className="test-class"
96-
contracts={[]}
96+
calls={[]}
9797
onError={vi.fn()}
9898
onSuccess={vi.fn()}
9999
>
@@ -114,7 +114,7 @@ describe('Transaction', () => {
114114
capabilities={{}}
115115
chainId={123}
116116
className="test-class"
117-
contracts={[]}
117+
calls={[]}
118118
onError={onError}
119119
onStatus={onStatus}
120120
onSuccess={onSuccess}
@@ -131,7 +131,7 @@ describe('Transaction', () => {
131131
<Transaction
132132
capabilities={{}}
133133
className="test-class"
134-
contracts={[]}
134+
calls={[]}
135135
onError={vi.fn()}
136136
onSuccess={vi.fn()}
137137
>
@@ -147,7 +147,7 @@ describe('Transaction', () => {
147147
capabilities={{}}
148148
chainId={base.id}
149149
className="test-class"
150-
contracts={[]}
150+
calls={[]}
151151
onError={vi.fn()}
152152
onSuccess={vi.fn()}
153153
>
@@ -163,7 +163,7 @@ describe('Transaction', () => {
163163
capabilities={{}}
164164
chainId={base.id}
165165
className="test-class"
166-
contracts={[]}
166+
calls={[]}
167167
onError={vi.fn()}
168168
onSuccess={vi.fn()}
169169
/>,

packages/onchainkit/src/transaction/components/Transaction.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export function Transaction({
1313
chainId,
1414
className,
1515
children,
16-
contracts,
1716
disabled = false,
1817
isSponsored,
1918
onError,
@@ -43,7 +42,6 @@ export function Transaction({
4342
calls={calls}
4443
capabilities={capabilities}
4544
chainId={accountChainId}
46-
contracts={contracts}
4745
isSponsored={isSponsored}
4846
onError={onError}
4947
onStatus={onStatus}

packages/onchainkit/src/transaction/components/TransactionDefault.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ describe('TransactionDefault Component', () => {
5555

5656
const defaultProps: TransactionDefaultReact = {
5757
calls: [],
58-
contracts: [],
5958
disabled: false,
6059
onError: mockOnError,
6160
onStatus: mockOnStatus,

packages/onchainkit/src/transaction/components/TransactionDefault.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export function TransactionDefault({
99
capabilities,
1010
chainId,
1111
className,
12-
contracts,
1312
disabled,
1413
onError,
1514
onStatus,
@@ -22,7 +21,6 @@ export function TransactionDefault({
2221
chainId={chainId}
2322
className={className}
2423
disabled={disabled}
25-
contracts={contracts}
2624
onError={onError}
2725
onStatus={onStatus}
2826
onSuccess={onSuccess}

packages/onchainkit/src/transaction/components/TransactionProvider.test.tsx

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ describe('TransactionProvider', () => {
767767
</TransactionProvider>,
768768
);
769769
}).toThrowError(
770-
'Transaction: calls or contracts must be provided as a prop to the Transaction component.',
770+
'Transaction: calls must be provided as a prop to the Transaction component.',
771771
);
772772
restore();
773773
});
@@ -786,34 +786,6 @@ describe('TransactionProvider', () => {
786786
consoleError.mockRestore();
787787
});
788788

789-
it('should throw an error when both contracts and calls are provided', async () => {
790-
const restore = silenceError();
791-
expect(() => {
792-
render(
793-
<TransactionProvider
794-
chainId={base.id}
795-
contracts={[
796-
{
797-
to: '0x1234567890123456789012345678901234567890' as `0x${string}`,
798-
data: '0x' as `0x${string}`,
799-
},
800-
]}
801-
calls={[
802-
{
803-
to: '0x1234567890123456789012345678901234567890' as `0x${string}`,
804-
data: '0x' as `0x${string}`,
805-
},
806-
]}
807-
>
808-
<div>Test</div>
809-
</TransactionProvider>,
810-
);
811-
}).toThrowError(
812-
'Transaction: Only one of contracts or calls can be provided as a prop to the Transaction component.',
813-
);
814-
restore();
815-
});
816-
817789
it('should handle sponsored contract calls', async () => {
818790
const contracts = [
819791
{ to: '0alissa' as `0x${string}`, data: '0x' as `0x${string}` },

packages/onchainkit/src/transaction/components/TransactionProvider.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export function TransactionProvider({
5555
capabilities: transactionCapabilities,
5656
chainId,
5757
children,
58-
contracts,
5958
isSponsored,
6059
onError,
6160
onStatus,
@@ -79,7 +78,6 @@ export function TransactionProvider({
7978
number | undefined
8079
>();
8180
const [transactionHashList, setTransactionHashList] = useState<Address[]>([]);
82-
const transactions = calls || contracts;
8381

8482
// Retrieve wallet capabilities
8583
const walletCapabilities = useCapabilitiesSafe({
@@ -89,16 +87,9 @@ export function TransactionProvider({
8987
const { switchChainAsync } = useSwitchChain();
9088

9189
// Validate `calls` and `contracts` props
92-
if (!contracts && !calls) {
90+
if (!calls) {
9391
throw new Error(
94-
'Transaction: calls or contracts must be provided as a prop to the Transaction component.',
95-
);
96-
}
97-
98-
// Validate `calls` and `contracts` props
99-
if (calls && contracts) {
100-
throw new Error(
101-
'Transaction: Only one of contracts or calls can be provided as a prop to the Transaction component.',
92+
'Transaction: calls must be provided as a prop to the Transaction component.',
10293
);
10394
}
10495

@@ -241,7 +232,6 @@ export function TransactionProvider({
241232
}
242233
}, [receipt, resetAfter, resetSendCalls, resetSendCall]);
243234

244-
// When all transactions are successful, get the receipts
245235
const getTransactionLegacyReceipts = useCallback(async () => {
246236
const receipts = [];
247237
for (const hash of transactionHashList) {
@@ -270,17 +260,18 @@ export function TransactionProvider({
270260
});
271261
}, [chainId, config, transactionHashList]);
272262

263+
// When all transactions are successful, get the receipts
273264
useEffect(() => {
274265
if (
275-
!transactions ||
266+
!calls ||
276267
transactionHashList.length !== transactionCount ||
277268
transactionCount < 2
278269
) {
279270
return;
280271
}
281272
getTransactionLegacyReceipts();
282273
}, [
283-
transactions,
274+
calls,
284275
transactionCount,
285276
transactionHashList,
286277
getTransactionLegacyReceipts,
@@ -304,9 +295,9 @@ export function TransactionProvider({
304295
handleAnalytics(TransactionEvent.TransactionInitiated, {
305296
address: account.address,
306297
});
307-
const resolvedTransactions = await (typeof transactions === 'function'
308-
? transactions()
309-
: Promise.resolve(transactions));
298+
const resolvedTransactions = await (typeof calls === 'function'
299+
? calls()
300+
: Promise.resolve(calls));
310301
setTransactionCount(resolvedTransactions?.length);
311302
return resolvedTransactions;
312303
} catch (err) {
@@ -326,7 +317,7 @@ export function TransactionProvider({
326317
});
327318
return undefined;
328319
}
329-
}, [transactions, handleAnalytics, account.address, errorCode]);
320+
}, [calls, handleAnalytics, account.address, errorCode]);
330321

331322
const handleSubmit = useCallback(async () => {
332323
setErrorMessage('');
@@ -364,7 +355,7 @@ export function TransactionProvider({
364355
setIsToastVisible,
365356
setLifecycleStatus,
366357
setTransactionId,
367-
transactions,
358+
transactions: calls,
368359
transactionId,
369360
transactionHash: singleTransactionHash || batchedTransactionHash,
370361
transactionCount,

packages/onchainkit/src/transaction/types.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ export type TransactionProviderReact = {
165165
chainId: number;
166166
/** The child components to be rendered within the provider component */
167167
children: ReactNode;
168-
/**
169-
* @deprecated Use `calls` instead.
170-
*/
171-
contracts?: Calls | Contracts | Array<Call | ContractFunctionParameters>;
172168
/** Whether the transactions are sponsored (default: false) */
173169
isSponsored?: boolean;
174170
/** An optional callback function that handles errors within the provider */
@@ -197,10 +193,6 @@ export type TransactionReact = {
197193
children?: ReactNode;
198194
/** An optional CSS class name for styling the component */
199195
className?: string;
200-
/**
201-
* @deprecated Use `calls` instead.
202-
*/
203-
contracts?: Calls | Contracts | Array<Call | ContractFunctionParameters>;
204196
/** Whether the transactions are sponsored (default: false) */
205197
isSponsored?: boolean;
206198
/** An optional callback function that handles transaction errors */

packages/onchainkit/src/wallet/components/ConnectButton.test.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import { render, screen } from '@testing-library/react';
22
import { describe, expect, it, vi } from 'vitest';
33
import { ConnectButton } from './ConnectButton';
4-
import { ConnectWalletText } from './ConnectWalletText';
54

65
describe('ConnectButton', () => {
76
it('should render connect button', () => {
87
render(
9-
<ConnectButton
10-
connectWalletText="Connect Wallet"
11-
onClick={vi.fn()}
12-
text="text"
13-
/>,
8+
<ConnectButton connectWalletText="Connect Wallet" onClick={vi.fn()} />,
149
);
1510
const button = screen.getByTestId('ockConnectButton');
1611
expect(button).toBeInTheDocument();
@@ -20,11 +15,8 @@ describe('ConnectButton', () => {
2015
it('should render connect button with custom text', () => {
2116
render(
2217
<ConnectButton
23-
connectWalletText={
24-
<ConnectWalletText>Connect Dope Wallet</ConnectWalletText>
25-
}
18+
connectWalletText="Connect Dope Wallet"
2619
onClick={vi.fn()}
27-
text="text"
2820
/>,
2921
);
3022
const button = screen.getByTestId('ockConnectButton');
@@ -38,7 +30,6 @@ describe('ConnectButton', () => {
3830
className="custom-class"
3931
connectWalletText="Connect Dope Wallet"
4032
onClick={vi.fn()}
41-
text="text"
4233
/>,
4334
);
4435
const button = screen.getByTestId('ockConnectButton');

0 commit comments

Comments
 (0)