Skip to content

Commit ad2d175

Browse files
Version Packages (#8452)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 52aba0f commit ad2d175

10 files changed

Lines changed: 136 additions & 120 deletions

File tree

.changeset/vast-nails-wash.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/wet-maps-play.md

Lines changed: 0 additions & 111 deletions
This file was deleted.

apps/wagmi-demo/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# wagmi-inapp
22

3+
## 0.0.36
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`52aba0f`](https://github.com/thirdweb-dev/js/commit/52aba0ffb814904414cdc8e76407afd71272d88e), [`9809d5c`](https://github.com/thirdweb-dev/js/commit/9809d5cf66baa520a9413986eb5bd2900de6f337)]:
8+
- thirdweb@5.113.0
9+
- @thirdweb-dev/wagmi-adapter@0.2.191
10+
311
## 0.0.35
412

513
### Patch Changes

apps/wagmi-demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "wagmi-inapp",
33
"private": true,
4-
"version": "0.0.35",
4+
"version": "0.0.36",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

packages/nebula/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @thirdweb-dev/nebula
22

3+
## 0.2.94
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`52aba0f`](https://github.com/thirdweb-dev/js/commit/52aba0ffb814904414cdc8e76407afd71272d88e), [`9809d5c`](https://github.com/thirdweb-dev/js/commit/9809d5cf66baa520a9413986eb5bd2900de6f337)]:
8+
- thirdweb@5.113.0
9+
310
## 0.2.93
411

512
### Patch Changes

packages/nebula/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@
5757
"type": "module",
5858
"types": "./dist/types/exports/thirdweb.d.ts",
5959
"typings": "./dist/types/exports/thirdweb.d.ts",
60-
"version": "0.2.93"
60+
"version": "0.2.94"
6161
}

packages/thirdweb/CHANGELOG.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,120 @@
11
# thirdweb
22

3+
## 5.113.0
4+
5+
### Minor Changes
6+
7+
- [#8444](https://github.com/thirdweb-dev/js/pull/8444) [`9809d5c`](https://github.com/thirdweb-dev/js/commit/9809d5cf66baa520a9413986eb5bd2900de6f337) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - # New `useFetchWithPayment()` React Hook
8+
9+
Added a new React hook that wraps the native fetch API to automatically handle 402 Payment Required responses using the x402 payment protocol.
10+
11+
## Features
12+
- **Automatic Payment Handling**: Automatically detects 402 responses, creates payment headers, and retries requests
13+
- **Built-in UI**: Shows an error modal with retry and fund wallet options when payment fails
14+
- **Sign In Flow**: Prompts users to connect their wallet if not connected, then automatically retries the payment
15+
- **Insufficient Funds Flow**: Integrates BuyWidget to help users top up their wallet directly in the modal
16+
- **Customizable**: Supports theming, custom payment selectors, BuyWidget customization, and ConnectModal customization
17+
- **Opt-out Modal**: Can disable the modal to handle errors manually
18+
19+
## Basic Usage
20+
21+
The hook automatically parses JSON responses by default.
22+
23+
```tsx
24+
import { useFetchWithPayment } from "thirdweb/react";
25+
import { createThirdwebClient } from "thirdweb";
26+
27+
const client = createThirdwebClient({ clientId: "your-client-id" });
28+
29+
function MyComponent() {
30+
const { fetchWithPayment, isPending } = useFetchWithPayment(client);
31+
32+
const handleApiCall = async () => {
33+
// Response is automatically parsed as JSON by default
34+
const data = await fetchWithPayment(
35+
"https://api.example.com/paid-endpoint",
36+
);
37+
console.log(data);
38+
};
39+
40+
return (
41+
<button onClick={handleApiCall} disabled={isPending}>
42+
{isPending ? "Loading..." : "Make Paid API Call"}
43+
</button>
44+
);
45+
}
46+
```
47+
48+
## Customize Response Parsing
49+
50+
By default, responses are parsed as JSON. You can customize this with the `parseAs` option:
51+
52+
```tsx
53+
// Parse as text instead of JSON
54+
const { fetchWithPayment } = useFetchWithPayment(client, {
55+
parseAs: "text",
56+
});
57+
58+
// Or get the raw Response object
59+
const { fetchWithPayment } = useFetchWithPayment(client, {
60+
parseAs: "raw",
61+
});
62+
```
63+
64+
## Customize Theme & Payment Options
65+
66+
```tsx
67+
const { fetchWithPayment } = useFetchWithPayment(client, {
68+
maxValue: 5000000n, // 5 USDC in base units
69+
theme: "light",
70+
paymentRequirementsSelector: (requirements) => {
71+
// Custom logic to select preferred payment method
72+
return requirements[0];
73+
},
74+
});
75+
```
76+
77+
## Customize Fund Wallet Widget
78+
79+
```tsx
80+
const { fetchWithPayment } = useFetchWithPayment(client, {
81+
fundWalletOptions: {
82+
title: "Add Funds",
83+
description: "You need more tokens to complete this payment",
84+
buttonLabel: "Get Tokens",
85+
},
86+
});
87+
```
88+
89+
## Customize Connect Modal
90+
91+
```tsx
92+
const { fetchWithPayment } = useFetchWithPayment(client, {
93+
connectOptions: {
94+
wallets: [inAppWallet(), createWallet("io.metamask")],
95+
title: "Sign in to continue",
96+
showThirdwebBranding: false,
97+
},
98+
});
99+
```
100+
101+
## Disable Modal (Handle Errors Manually)
102+
103+
```tsx
104+
const { fetchWithPayment, error } = useFetchWithPayment(client, {
105+
showErrorModal: false,
106+
});
107+
108+
// Handle the error manually
109+
if (error) {
110+
console.error("Payment failed:", error);
111+
}
112+
```
113+
114+
### Patch Changes
115+
116+
- [#8453](https://github.com/thirdweb-dev/js/pull/8453) [`52aba0f`](https://github.com/thirdweb-dev/js/commit/52aba0ffb814904414cdc8e76407afd71272d88e) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Dont attempt chain switching for cb wallet if already connected to the right chain
117+
3118
## 5.112.4
4119

5120
### Patch Changes

packages/thirdweb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,5 +430,5 @@
430430
}
431431
},
432432
"typings": "./dist/types/exports/thirdweb.d.ts",
433-
"version": "5.112.4"
433+
"version": "5.113.0"
434434
}

packages/wagmi-adapter/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# @thirdweb-dev/wagmi-adapter
22

3+
## 0.2.191
4+
35
## 0.2.190
46

57
## 0.2.189

packages/wagmi-adapter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@
5656
"type": "module",
5757
"types": "./dist/types/exports/thirdweb.d.ts",
5858
"typings": "./dist/types/exports/thirdweb.d.ts",
59-
"version": "0.2.190"
59+
"version": "0.2.191"
6060
}

0 commit comments

Comments
 (0)