Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dce62de1c | ||
|
|
1c533efcd5 | ||
|
|
eca6217f77 | ||
|
|
df84f9c4ce | ||
|
|
17c0e6f282 | ||
|
|
d51c1883af | ||
|
|
9cf3a1d663 | ||
|
|
c94bcd574a | ||
|
|
41c6d04c2f | ||
|
|
3a78041de7 | ||
|
|
8b74602e3b | ||
|
|
f9081d58d4 | ||
|
|
b051d844d0 | ||
|
|
f8e0c5f84b | ||
|
|
476b6cc271 | ||
|
|
ffaff744f7 | ||
|
|
198f72c493 |
@@ -106,7 +106,7 @@ jobs:
|
||||
|
||||
- name: Install Yarn (if needed)
|
||||
if: matrix.package_manager == 'yarn'
|
||||
run: npm install -g yarn
|
||||
run: npm install -g yarn@1.22.19
|
||||
|
||||
- name: Create test project
|
||||
run: |
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { getContract } from "thirdweb";
|
||||
import { zkSyncSepolia } from "thirdweb/chains";
|
||||
import { baseSepolia } from "thirdweb/chains";
|
||||
import { THIRDWEB_CLIENT } from "../../lib/client";
|
||||
|
||||
export const chain = zkSyncSepolia;
|
||||
export const editionDropAddress = "0xd563ACBeD80e63B257B2524562BdD7Ec666eEE77";
|
||||
export const chain = baseSepolia;
|
||||
export const editionDropAddress = "0x638263e3eAa3917a53630e61B1fBa685308024fa";
|
||||
export const editionDropTokenId = 0n;
|
||||
|
||||
export const editionDropContract = getContract({
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
useReadContract,
|
||||
} from "thirdweb/react";
|
||||
import { THIRDWEB_CLIENT } from "../../lib/client";
|
||||
import { CodeExample } from "../code/code-example";
|
||||
import { editionDropContract, editionDropTokenId } from "./constants";
|
||||
|
||||
export function SponsoredTxPreview() {
|
||||
@@ -50,7 +49,7 @@ export function SponsoredTxPreview() {
|
||||
/>
|
||||
) : null}
|
||||
{smartAccount ? (
|
||||
<>
|
||||
<div className="flex flex-col justify-center p-8">
|
||||
<p className="font-semibold text-center mb-2">
|
||||
You own {ownedNfts?.[0]?.quantityOwned.toString() || "0"}{" "}
|
||||
Kittens
|
||||
@@ -73,7 +72,7 @@ export function SponsoredTxPreview() {
|
||||
>
|
||||
Mint
|
||||
</TransactionButton>
|
||||
</>
|
||||
</div>
|
||||
) : (
|
||||
<p
|
||||
style={{
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 4.1.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/wallets@2.5.36
|
||||
|
||||
## 4.1.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "4.1.93",
|
||||
"version": "4.1.94",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @thirdweb-dev/chains
|
||||
|
||||
## 0.1.119
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3311](https://github.com/thirdweb-dev/js/pull/3311) [`8b74602`](https://github.com/thirdweb-dev/js/commit/8b74602e3b7fbe011bf886b9d5ee0e2ea62f7447) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
|
||||
|
||||
## 0.1.118
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -11,12 +11,6 @@ export default {
|
||||
"name": "EIP155"
|
||||
}
|
||||
],
|
||||
"icon": {
|
||||
"url": "ipfs://QmVt5Y585JqBSrkpZmYaEnX9FW7tDwfDLmUGNyDdyV2Pd2",
|
||||
"width": 48,
|
||||
"height": 48,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://www.dioneprotocol.com/",
|
||||
"name": "Odyssey Chain (Testnet)",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "TCC Network",
|
||||
"chainId": 181155,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "Tcc Scan",
|
||||
"url": "https://scan.tccworld.org/",
|
||||
"standard": "181155",
|
||||
"icon": {
|
||||
"url": "ipfs://QmchZTtvuU7oRe3rSu1HNPELJQdnutV79NjcHxoybJ4SVo/tcc-coin.png",
|
||||
"width": 100,
|
||||
"height": 100,
|
||||
"format": "png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmchZTtvuU7oRe3rSu1HNPELJQdnutV79NjcHxoybJ4SVo/tcc-coin.png",
|
||||
"width": 100,
|
||||
"height": 100,
|
||||
"format": "png"
|
||||
},
|
||||
"name": "TCC Network",
|
||||
"nativeCurrency": {
|
||||
"name": "The ChampCoin",
|
||||
"symbol": "TCC",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 181155,
|
||||
"redFlags": [],
|
||||
"rpc": [],
|
||||
"shortName": "TCC",
|
||||
"slug": "tcc-network",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -10,12 +10,6 @@ export default {
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmdoUtvHDybu5ppYBZT8BMRp6AqByVSoQs8nFwKbaS55jd",
|
||||
"width": 367,
|
||||
"height": 367,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://milkomeda.com",
|
||||
"name": "Milkomeda C1 Mainnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -10,12 +10,6 @@ export default {
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmdoUtvHDybu5ppYBZT8BMRp6AqByVSoQs8nFwKbaS55jd",
|
||||
"width": 367,
|
||||
"height": 367,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://milkomeda.com",
|
||||
"name": "Milkomeda C1 Testnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -10,12 +10,6 @@ export default {
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmdoUtvHDybu5ppYBZT8BMRp6AqByVSoQs8nFwKbaS55jd",
|
||||
"width": 367,
|
||||
"height": 367,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://milkomeda.com",
|
||||
"name": "Milkomeda A1 Mainnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -10,12 +10,6 @@ export default {
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmdoUtvHDybu5ppYBZT8BMRp6AqByVSoQs8nFwKbaS55jd",
|
||||
"width": 367,
|
||||
"height": 367,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://milkomeda.com",
|
||||
"name": "Milkomeda A1 Testnet",
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 57923,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "QI0614I1",
|
||||
"nativeCurrency": {
|
||||
"name": "QI0614I1 Token",
|
||||
"symbol": "GZD",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 57923,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://57923.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
|
||||
],
|
||||
"shortName": "QI0614I1",
|
||||
"slug": "qi0614i1",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Open Campus Codex",
|
||||
"chainId": 656476,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "Open Campus Codex",
|
||||
"url": "https://opencampus-codex.blockscout.com",
|
||||
"standard": "none",
|
||||
"icon": {
|
||||
"url": "ipfs://QmXbz7VEYvf6NVHezuBy5HpJTCiagEThBxxdDdfVXNQ8Bt",
|
||||
"width": 30,
|
||||
"height": 30,
|
||||
"format": "png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmXbz7VEYvf6NVHezuBy5HpJTCiagEThBxxdDdfVXNQ8Bt",
|
||||
"width": 30,
|
||||
"height": 30,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://raas.gelato.network/rollups/details/public/open-campus-codex",
|
||||
"name": "Open Campus Codex",
|
||||
"nativeCurrency": {
|
||||
"name": "EDU",
|
||||
"symbol": "EDU",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 656476,
|
||||
"rpc": [
|
||||
"https://656476.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc.open-campus-codex.gelato.digital"
|
||||
],
|
||||
"shortName": "open-campus-codex",
|
||||
"slug": "open-campus-codex",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "OX",
|
||||
"chainId": 6699,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"infoURL": "https://ox.fun/chain",
|
||||
"name": "OX Chain",
|
||||
"nativeCurrency": {
|
||||
"name": "OX",
|
||||
"symbol": "OX",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 6699,
|
||||
"rpc": [
|
||||
"https://6699.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc.oxscan.io"
|
||||
],
|
||||
"shortName": "ox-chain",
|
||||
"slug": "ox-chain",
|
||||
"status": "incubating",
|
||||
"testnet": false,
|
||||
"title": "OX Chain"
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Darwinia Koi",
|
||||
"chainId": 701,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "blockscout",
|
||||
"url": "https://koi-scan.darwinia.network",
|
||||
"standard": "EIP3091"
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"infoURL": "https://darwinia.network/",
|
||||
"name": "Darwinia Koi Testnet",
|
||||
"nativeCurrency": {
|
||||
"name": "Koi Network Native Token",
|
||||
"symbol": "KRING",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 701,
|
||||
"rpc": [
|
||||
"https://701.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://koi-rpc.darwinia.network"
|
||||
],
|
||||
"shortName": "darwinia-koi",
|
||||
"slip44": 1,
|
||||
"slug": "darwinia-koi-testnet",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 85405,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": "svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "QR0614T1tS",
|
||||
"nativeCurrency": {
|
||||
"name": "QR0614T1tS Token",
|
||||
"symbol": "FTW",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 85405,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://85405.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/qr0614t1ts/testnet/rpc"
|
||||
],
|
||||
"shortName": "QR0614T1tS",
|
||||
"slug": "qr0614t1ts",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/chains",
|
||||
"version": "0.1.118",
|
||||
"version": "0.1.119",
|
||||
"main": "dist/thirdweb-dev-chains.cjs.js",
|
||||
"module": "dist/thirdweb-dev-chains.esm.js",
|
||||
"exports": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,15 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.14.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`8b74602`](https://github.com/thirdweb-dev/js/commit/8b74602e3b7fbe011bf886b9d5ee0e2ea62f7447)]:
|
||||
- @thirdweb-dev/chains@0.1.119
|
||||
- @thirdweb-dev/sdk@4.0.96
|
||||
- @thirdweb-dev/wallets@2.5.36
|
||||
- @thirdweb-dev/auth@4.1.94
|
||||
|
||||
## 0.14.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/cli",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.14.8",
|
||||
"version": "0.14.9",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"@typescript-eslint/parser": "7.9.0",
|
||||
"eslint-config-next": "14.2.1",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-config-turbo": "1.13.2",
|
||||
"eslint-config-turbo": "2.0.4",
|
||||
"eslint-plugin-react": "7.34.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 4.9.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`8b74602`](https://github.com/thirdweb-dev/js/commit/8b74602e3b7fbe011bf886b9d5ee0e2ea62f7447)]:
|
||||
- @thirdweb-dev/chains@0.1.119
|
||||
- @thirdweb-dev/sdk@4.0.96
|
||||
- @thirdweb-dev/wallets@2.5.36
|
||||
- @thirdweb-dev/auth@4.1.94
|
||||
|
||||
## 4.9.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "4.9.0",
|
||||
"version": "4.9.1",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 4.9.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`8b74602`](https://github.com/thirdweb-dev/js/commit/8b74602e3b7fbe011bf886b9d5ee0e2ea62f7447)]:
|
||||
- @thirdweb-dev/chains@0.1.119
|
||||
- @thirdweb-dev/sdk@4.0.96
|
||||
- @thirdweb-dev/react-core@4.9.1
|
||||
- @thirdweb-dev/wallets@2.5.36
|
||||
|
||||
## 4.9.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "4.9.0",
|
||||
"version": "4.9.1",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 4.0.96
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`c94bcd5`](https://github.com/thirdweb-dev/js/commit/c94bcd574aa4eaf2bd76ab8b6379302de4731ed4), [`1c533ef`](https://github.com/thirdweb-dev/js/commit/1c533efcd5fbc8a72fd03c98510fa601ee5f34b5), [`ffaff74`](https://github.com/thirdweb-dev/js/commit/ffaff744f72d2cb22896e7501677b48f76ea857a), [`8b74602`](https://github.com/thirdweb-dev/js/commit/8b74602e3b7fbe011bf886b9d5ee0e2ea62f7447), [`9cf3a1d`](https://github.com/thirdweb-dev/js/commit/9cf3a1d6636fcd56559e889ab2bfe3249d51162a)]:
|
||||
- thirdweb@5.29.3
|
||||
- @thirdweb-dev/chains@0.1.119
|
||||
|
||||
## 4.0.95
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "4.0.95",
|
||||
"version": "4.0.96",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,17 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.6.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3317](https://github.com/thirdweb-dev/js/pull/3317) [`198f72c`](https://github.com/thirdweb-dev/js/commit/198f72c4933633d44185ff7b1d7e995e90c4d618) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] fix tx builder type parsing
|
||||
|
||||
- Updated dependencies [[`8b74602`](https://github.com/thirdweb-dev/js/commit/8b74602e3b7fbe011bf886b9d5ee0e2ea62f7447)]:
|
||||
- @thirdweb-dev/chains@0.1.119
|
||||
- @thirdweb-dev/sdk@4.0.96
|
||||
- @thirdweb-dev/wallets@2.5.36
|
||||
- @thirdweb-dev/auth@4.1.94
|
||||
|
||||
## 0.6.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.6.44",
|
||||
"version": "0.6.45",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -173,7 +173,7 @@ class ThirdwebBridge implements TWBridge {
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
|
||||
(globalThis as any).X_SDK_PLATFORM = "unity";
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
|
||||
(globalThis as any).X_SDK_VERSION = "4.16.3";
|
||||
(globalThis as any).X_SDK_VERSION = "4.16.4";
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
|
||||
(globalThis as any).X_SDK_OS = browser?.os ?? "unknown";
|
||||
}
|
||||
@@ -610,7 +610,9 @@ class ThirdwebBridge implements TWBridge {
|
||||
maxFeePerGas: txInput?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: txInput?.maxPriorityFeePerGas,
|
||||
nonce: txInput?.nonce,
|
||||
type: txInput?.type?.toNumber(),
|
||||
type: txInput?.type
|
||||
? BigNumber.from(txInput.type).toNumber()
|
||||
: undefined,
|
||||
accessList: txInput?.accessList,
|
||||
// customData: txInput.data,
|
||||
// ccipReadEnabled: txInput.ccipReadEnabled,
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/wallets
|
||||
|
||||
## 2.5.36
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`8b74602`](https://github.com/thirdweb-dev/js/commit/8b74602e3b7fbe011bf886b9d5ee0e2ea62f7447)]:
|
||||
- @thirdweb-dev/chains@0.1.119
|
||||
- @thirdweb-dev/sdk@4.0.96
|
||||
|
||||
## 2.5.35
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/wallets",
|
||||
"version": "2.5.35",
|
||||
"version": "2.5.36",
|
||||
"main": "dist/thirdweb-dev-wallets.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets.esm.js",
|
||||
"browser": {
|
||||
|
||||
Binary file not shown.
+9
-6
@@ -12,7 +12,7 @@
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
"test": "turbo run test --filter=./packages/*",
|
||||
"test:legacy": "turbo run test --filter=./legacy_packages/* --filter=!sdk --filter=!auth",
|
||||
"test:legacy": "turbo run test --filter=./legacy_packages/* --filter=!@thirdweb-dev/sdk --filter=!@thirdweb-dev/auth",
|
||||
"e2e": "turbo run e2e --filter=./packages/*",
|
||||
"e2e:legacy": "turbo run e2e --filter=./legacy_packages/*",
|
||||
"build:packages": "turbo run build --filter=./packages/*",
|
||||
@@ -44,7 +44,7 @@
|
||||
"@manypkg/get-packages": "2.2.1",
|
||||
"@playwright/test": "1.31.2",
|
||||
"@types/node": "20.12.7",
|
||||
"turbo": "1.13.3",
|
||||
"turbo": "2.0.4",
|
||||
"yalc": "1.0.0-pre.53"
|
||||
},
|
||||
"_______ALL_PACKAGE_DEV_DEPENDENCIES_GO_IN_HERE_SO_CONSUMERS_DONT_END_UP_INSTALLING_THEM______": "_______ALL_PACKAGE_DEV_DEPENDENCIES_GO_IN_HERE_SO_CONSUMERS_DONT_END_UP_INSTALLING_THEM______",
|
||||
@@ -62,13 +62,13 @@
|
||||
"@viem/anvil": "0.0.9",
|
||||
"@vitest/coverage-v8": "1.5.0",
|
||||
"dotenv-mono": "1.3.14",
|
||||
"ethers5": "npm:[email protected]",
|
||||
"ethers6": "npm:[email protected]",
|
||||
"eslint-plugin-i18next": "^6.0.3",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-inclusive-language": "^2.2.1",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-tsdoc": "^0.2.17",
|
||||
"ethers5": "npm:[email protected]",
|
||||
"ethers6": "npm:[email protected]",
|
||||
"knip": "5.9.4",
|
||||
"mitata": "0.1.11",
|
||||
"react": "18.2.0",
|
||||
@@ -98,7 +98,10 @@
|
||||
"protobufjs@>=6.10.0 <7.2.4": ">=7.2.4",
|
||||
"tough-cookie@<4.1.3": ">=4.1.3",
|
||||
"@ethereumjs/util@<9.0.0": ">=9.0.0",
|
||||
"axios@<0.28.0": ">=0.28.0"
|
||||
"axios@<0.28.0": ">=0.28.0",
|
||||
"@grpc/grpc-js@<1.10.9": "1.10.9",
|
||||
"braces@<3.0.3": "3.0.3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"packageManager": "[email protected]"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# thirdweb
|
||||
|
||||
## 5.29.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3329](https://github.com/thirdweb-dev/js/pull/3329) [`c94bcd5`](https://github.com/thirdweb-dev/js/commit/c94bcd574aa4eaf2bd76ab8b6379302de4731ed4) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Dynamically import coinbase sdk to avoid cloudflare bundler issues
|
||||
|
||||
- [#3341](https://github.com/thirdweb-dev/js/pull/3341) [`1c533ef`](https://github.com/thirdweb-dev/js/commit/1c533efcd5fbc8a72fd03c98510fa601ee5f34b5) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix transaction button not respecting theme prop
|
||||
|
||||
- [#3298](https://github.com/thirdweb-dev/js/pull/3298) [`ffaff74`](https://github.com/thirdweb-dev/js/commit/ffaff744f72d2cb22896e7501677b48f76ea857a) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - refactor exports to handle native vs non-native dependencies
|
||||
|
||||
- [#3330](https://github.com/thirdweb-dev/js/pull/3330) [`9cf3a1d`](https://github.com/thirdweb-dev/js/commit/9cf3a1d6636fcd56559e889ab2bfe3249d51162a) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix coinbase wallet popup sometimes not opening on safari + improve inAppWallet web performance
|
||||
|
||||
## 5.29.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"version": "5.29.2",
|
||||
"version": "5.29.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
||||
@@ -68,7 +68,7 @@
|
||||
"./react": {
|
||||
"types": "./dist/types/exports/react.d.ts",
|
||||
"import": "./dist/esm/exports/react.js",
|
||||
"react-native": "./dist/esm/exports/react-native.js",
|
||||
"react-native": "./dist/esm/exports/react.native.js",
|
||||
"default": "./dist/cjs/exports/react.js"
|
||||
},
|
||||
"./react-native": {
|
||||
@@ -99,8 +99,15 @@
|
||||
"./wallets": {
|
||||
"types": "./dist/types/exports/wallets.d.ts",
|
||||
"import": "./dist/esm/exports/wallets.js",
|
||||
"react-native": "./dist/esm/exports/wallets.native.js",
|
||||
"default": "./dist/cjs/exports/wallets.js"
|
||||
},
|
||||
"./wallets/in-app": {
|
||||
"types": "./dist/types/exports/wallets/in-app.d.ts",
|
||||
"import": "./dist/esm/exports/wallets/in-app.js",
|
||||
"react-native": "./dist/esm/exports/wallets/in-app.native.js",
|
||||
"default": "./dist/cjs/exports/wallets/in-app.js"
|
||||
},
|
||||
"./wallets/*": {
|
||||
"types": "./dist/types/exports/wallets/*.d.ts",
|
||||
"import": "./dist/esm/exports/wallets/*.js",
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
export { ThirdwebProvider } from "../react/core/providers/thirdweb-provider.js";
|
||||
|
||||
// react/core
|
||||
export {
|
||||
useSetActiveWallet,
|
||||
useActiveWalletChain,
|
||||
useConnect,
|
||||
useDisconnect,
|
||||
useActiveAccount,
|
||||
useActiveWallet,
|
||||
useConnectedWallets,
|
||||
useSwitchActiveWalletChain,
|
||||
useActiveWalletConnectionStatus,
|
||||
useSetActiveWalletConnectionStatus,
|
||||
useIsAutoConnecting,
|
||||
} from "../react/core/hooks/wallets/wallet-hooks.js";
|
||||
export { useWalletBalance } from "../react/core/hooks/others/useWalletBalance.js";
|
||||
|
||||
// contract related
|
||||
export { useReadContract } from "../react/core/hooks/contract/useReadContract.js";
|
||||
|
||||
export { useEstimateGas } from "../react/core/hooks/contract/useEstimateGas.js";
|
||||
export { useWaitForReceipt } from "../react/core/hooks/contract/useWaitForReceipt.js";
|
||||
export { useContractEvents } from "../react/core/hooks/contract/useContractEvents.js";
|
||||
|
||||
// rpc related
|
||||
export {
|
||||
useBlockNumber,
|
||||
type UseBlockNumberOptions,
|
||||
} from "../react/core/hooks/rpc/useBlockNumber.js";
|
||||
|
||||
// utils
|
||||
export { createContractQuery } from "../react/core/utils/createQuery.js";
|
||||
export { useInvalidateContractQuery } from "../react/core/hooks/others/useInvalidateQueries.js";
|
||||
|
||||
// pay
|
||||
export {
|
||||
useBuyWithCryptoQuote,
|
||||
type BuyWithCryptoQuoteQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyWithCryptoQuote.js";
|
||||
export { useBuyWithCryptoStatus } from "../react/core/hooks/pay/useBuyWithCryptoStatus.js";
|
||||
export {
|
||||
useBuyWithCryptoHistory,
|
||||
type BuyWithCryptoHistoryQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyWithCryptoHistory.js";
|
||||
export {
|
||||
useBuyWithFiatQuote,
|
||||
type BuyWithFiatQuoteQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyWithFiatQuote.js";
|
||||
export { useBuyWithFiatStatus } from "../react/core/hooks/pay/useBuyWithFiatStatus.js";
|
||||
export {
|
||||
useBuyWithFiatHistory,
|
||||
type BuyWithFiatHistoryQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyWithFiatHistory.js";
|
||||
export {
|
||||
useBuyHistory,
|
||||
type BuyHistoryQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyHistory.js";
|
||||
export {
|
||||
usePostOnRampQuote,
|
||||
type PostOnRampQuoteQueryOptions,
|
||||
} from "../react/core/hooks/pay/usePostOnrampQuote.js";
|
||||
|
||||
import { useSendTransactionCore } from "../react/core/hooks/contract/useSendTransaction.js";
|
||||
|
||||
/**
|
||||
* A hook to send a transaction.
|
||||
* @returns A mutation object to send a transaction.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useSendTransaction } from "thirdweb/react-native";
|
||||
* const { mutate: sendTx, data: transactionResult } = useSendTransaction();
|
||||
*
|
||||
* // later
|
||||
* sendTx(tx);
|
||||
* ```
|
||||
* @transaction
|
||||
*/
|
||||
export const useSendTransaction = useSendTransactionCore;
|
||||
export { useSendBatchTransaction } from "../react/core/hooks/contract/useSendBatchTransaction.js";
|
||||
export { useSendAndConfirmTransaction } from "../react/core/hooks/contract/useSendAndConfirmTransaction.js";
|
||||
export { useEstimateGasCost } from "../react/core/hooks/contract/useEstimateGasCost.js";
|
||||
|
||||
// Components
|
||||
export {
|
||||
AutoConnect,
|
||||
type AutoConnectProps,
|
||||
} from "../react/core/hooks/connection/AutoConnect.js";
|
||||
export { useAutoConnect } from "../react/core/hooks/connection/useAutoConnect.js";
|
||||
|
||||
export { TransactionButton } from "../react/native/ui/TransactionButton/TrabsactionButton.js";
|
||||
export type { TransactionButtonProps } from "../react/core/hooks/transaction/button-core.js";
|
||||
|
||||
// wallet info
|
||||
export {
|
||||
useWalletInfo,
|
||||
useWalletImage,
|
||||
} from "../react/web/ui/hooks/useWalletInfo.js";
|
||||
@@ -0,0 +1,87 @@
|
||||
export { ThirdwebProvider } from "../react/core/providers/thirdweb-provider.js";
|
||||
|
||||
// wallet hooks
|
||||
export { useActiveWallet } from "../react/native/hooks/wallets/useActiveWallet.js";
|
||||
export { useActiveWalletChain } from "../react/native/hooks/wallets/useActiveWalletChain.js";
|
||||
export { useActiveWalletConnectionStatus } from "../react/native/hooks/wallets/useActiveWalletConnectionStatus.js";
|
||||
export { useActiveAccount } from "../react/native/hooks/wallets/useActiveAccount.js";
|
||||
export { useAutoConnect } from "../react/native/hooks/wallets/useAutoConnect.js";
|
||||
export { useCapabilities } from "../react/native/hooks/wallets/useCapabilities.js";
|
||||
export { useConnect } from "../react/native/hooks/wallets/useConnect.js";
|
||||
export { useConnectedWallets } from "../react/native/hooks/wallets/useConnectedWallets.js";
|
||||
export { useDisconnect } from "../react/native/hooks/wallets/useDisconnect.js";
|
||||
export { useIsAutoConnecting } from "../react/native/hooks/wallets/useIsAutoConnecting.js";
|
||||
export { useSetActiveWallet } from "../react/native/hooks/wallets/useSetActiveWallet.js";
|
||||
export { useSetActiveWalletConnectionStatus } from "../react/native/hooks/wallets/useSetActiveWalletConnectionStatus.js";
|
||||
export { useSendCalls } from "../react/native/hooks/wallets/useSendCalls.js";
|
||||
export { useSwitchActiveWalletChain } from "../react/native/hooks/wallets/useSwitchActiveWalletChain.js";
|
||||
export { useCallsStatus } from "../react/native/hooks/wallets/useCallsStatus.js";
|
||||
export { useWalletBalance } from "../react/core/hooks/others/useWalletBalance.js";
|
||||
|
||||
// contract
|
||||
export { useReadContract } from "../react/core/hooks/contract/useReadContract.js";
|
||||
export { useWaitForReceipt } from "../react/core/hooks/contract/useWaitForReceipt.js";
|
||||
export { useContractEvents } from "../react/core/hooks/contract/useContractEvents.js";
|
||||
|
||||
// transaction
|
||||
export {
|
||||
type SendTransactionConfig,
|
||||
type SendTransactionPayModalConfig,
|
||||
} from "../react/core/hooks/transaction/useSendTransaction.js";
|
||||
export { useSimulateTransaction } from "../react/core/hooks/transaction/useSimulateTransaction.js";
|
||||
export { useSendTransaction } from "../react/native/hooks/transaction/useSendTransaction.js";
|
||||
export { useSendBatchTransaction } from "../react/native/hooks/transaction/useSendBatchTransaction.js";
|
||||
export { useSendAndConfirmTransaction } from "../react/native/hooks/transaction/useSendAndConfirmTransaction.js";
|
||||
export { useEstimateGas } from "../react/native/hooks/transaction/useEstimateGas.js";
|
||||
export { useEstimateGasCost } from "../react/native/hooks/transaction/useEstimateGasCost.js";
|
||||
|
||||
// rpc related
|
||||
export {
|
||||
useBlockNumber,
|
||||
type UseBlockNumberOptions,
|
||||
} from "../react/core/hooks/rpc/useBlockNumber.js";
|
||||
|
||||
// utils
|
||||
export { createContractQuery } from "../react/core/utils/createQuery.js";
|
||||
export { useInvalidateContractQuery } from "../react/core/hooks/others/useInvalidateQueries.js";
|
||||
|
||||
// pay
|
||||
export {
|
||||
useBuyWithCryptoQuote,
|
||||
type BuyWithCryptoQuoteQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyWithCryptoQuote.js";
|
||||
export { useBuyWithCryptoStatus } from "../react/core/hooks/pay/useBuyWithCryptoStatus.js";
|
||||
export {
|
||||
useBuyWithCryptoHistory,
|
||||
type BuyWithCryptoHistoryQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyWithCryptoHistory.js";
|
||||
export {
|
||||
useBuyWithFiatQuote,
|
||||
type BuyWithFiatQuoteQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyWithFiatQuote.js";
|
||||
export { useBuyWithFiatStatus } from "../react/core/hooks/pay/useBuyWithFiatStatus.js";
|
||||
export {
|
||||
useBuyWithFiatHistory,
|
||||
type BuyWithFiatHistoryQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyWithFiatHistory.js";
|
||||
export {
|
||||
useBuyHistory,
|
||||
type BuyHistoryQueryOptions,
|
||||
} from "../react/core/hooks/pay/useBuyHistory.js";
|
||||
export {
|
||||
usePostOnRampQuote,
|
||||
type PostOnRampQuoteQueryOptions,
|
||||
} from "../react/core/hooks/pay/usePostOnrampQuote.js";
|
||||
|
||||
// Components
|
||||
export { AutoConnect } from "../react/native/ui/AutoConnect/AutoConnect.js";
|
||||
export type { AutoConnectProps } from "../react/core/hooks/connection/types.js";
|
||||
|
||||
export { TransactionButton } from "../react/native/ui/TransactionButton/TrabsactionButton.js";
|
||||
export type { TransactionButtonProps } from "../react/core/hooks/transaction/transaction-button-utils.js";
|
||||
|
||||
// wallet info
|
||||
export {
|
||||
useWalletInfo,
|
||||
useWalletImage,
|
||||
} from "../react/web/ui/hooks/useWalletInfo.js";
|
||||
@@ -22,7 +22,7 @@ export type { WelcomeScreen } from "../react/web/ui/ConnectWallet/screens/types.
|
||||
export type { LocaleId } from "../react/web/ui/types.js";
|
||||
|
||||
export { TransactionButton } from "../react/web/ui/TransactionButton/index.js";
|
||||
export type { TransactionButtonProps } from "../react/core/hooks/transaction/button-core.js";
|
||||
export type { TransactionButtonProps } from "../react/core/hooks/transaction/transaction-button-utils.js";
|
||||
|
||||
export { ThirdwebProvider } from "../react/core/providers/thirdweb-provider.js";
|
||||
|
||||
@@ -37,38 +37,43 @@ export { defaultTokens } from "../react/web/ui/ConnectWallet/defaultTokens.js";
|
||||
export { MediaRenderer } from "../react/web/ui/MediaRenderer/MediaRenderer.js";
|
||||
export type { MediaRendererProps } from "../react/web/ui/MediaRenderer/types.js";
|
||||
|
||||
// react/core
|
||||
export {
|
||||
useSetActiveWallet,
|
||||
useActiveWalletChain,
|
||||
useConnect,
|
||||
useDisconnect,
|
||||
useActiveAccount,
|
||||
useActiveWallet,
|
||||
useConnectedWallets,
|
||||
useSwitchActiveWalletChain,
|
||||
useActiveWalletConnectionStatus,
|
||||
useSetActiveWalletConnectionStatus,
|
||||
useIsAutoConnecting,
|
||||
} from "../react/core/hooks/wallets/wallet-hooks.js";
|
||||
// wallet hooks
|
||||
export { useActiveWallet } from "../react/web/hooks/wallets/useActiveWallet.js";
|
||||
export { useActiveWalletChain } from "../react/web/hooks/wallets/useActiveWalletChain.js";
|
||||
export { useActiveWalletConnectionStatus } from "../react/web/hooks/wallets/useActiveWalletConnectionStatus.js";
|
||||
export { useActiveAccount } from "../react/web/hooks/wallets/useActiveAccount.js";
|
||||
export { useAutoConnect } from "../react/web/hooks/wallets/useAutoConnect.js";
|
||||
export { useCapabilities } from "../react/web/hooks/wallets/useCapabilities.js";
|
||||
export { useConnect } from "../react/web/hooks/wallets/useConnect.js";
|
||||
export { useConnectedWallets } from "../react/web/hooks/wallets/useConnectedWallets.js";
|
||||
export { useDisconnect } from "../react/web/hooks/wallets/useDisconnect.js";
|
||||
export { useIsAutoConnecting } from "../react/web/hooks/wallets/useIsAutoConnecting.js";
|
||||
export { useSetActiveWallet } from "../react/web/hooks/wallets/useSetActiveWallet.js";
|
||||
export { useSetActiveWalletConnectionStatus } from "../react/web/hooks/wallets/useSetActiveWalletConnectionStatus.js";
|
||||
export { useSendCalls } from "../react/web/hooks/wallets/useSendCalls.js";
|
||||
export { useSwitchActiveWalletChain } from "../react/web/hooks/wallets/useSwitchActiveWalletChain.js";
|
||||
export { useCallsStatus } from "../react/web/hooks/wallets/useCallsStatus.js";
|
||||
export { useWalletBalance } from "../react/core/hooks/others/useWalletBalance.js";
|
||||
|
||||
export type { ConnectManagerOptions } from "../wallets/manager/index.js";
|
||||
|
||||
// contract related
|
||||
// contract
|
||||
export { useReadContract } from "../react/core/hooks/contract/useReadContract.js";
|
||||
export {
|
||||
useSendTransaction,
|
||||
type SendTransactionConfig,
|
||||
type SendTransactionPayModalConfig,
|
||||
} from "../react/web/hooks/useSendTransaction.js";
|
||||
export { useSendBatchTransaction } from "../react/core/hooks/contract/useSendBatchTransaction.js";
|
||||
export { useSendAndConfirmTransaction } from "../react/core/hooks/contract/useSendAndConfirmTransaction.js";
|
||||
export { useEstimateGas } from "../react/core/hooks/contract/useEstimateGas.js";
|
||||
export { useEstimateGasCost } from "../react/core/hooks/contract/useEstimateGasCost.js";
|
||||
export { useWaitForReceipt } from "../react/core/hooks/contract/useWaitForReceipt.js";
|
||||
export { useContractEvents } from "../react/core/hooks/contract/useContractEvents.js";
|
||||
|
||||
// transaction
|
||||
export {
|
||||
type SendTransactionConfig,
|
||||
type SendTransactionPayModalConfig,
|
||||
} from "../react/core/hooks/transaction/useSendTransaction.js";
|
||||
export { useSimulateTransaction } from "../react/core/hooks/transaction/useSimulateTransaction.js";
|
||||
export { useSendTransaction } from "../react/web/hooks/transaction/useSendTransaction.js";
|
||||
export { useSendBatchTransaction } from "../react/web/hooks/transaction/useSendBatchTransaction.js";
|
||||
export { useSendAndConfirmTransaction } from "../react/web/hooks/transaction/useSendAndConfirmTransaction.js";
|
||||
export { useEstimateGas } from "../react/web/hooks/transaction/useEstimateGas.js";
|
||||
export { useEstimateGasCost } from "../react/web/hooks/transaction/useEstimateGasCost.js";
|
||||
|
||||
// rpc related
|
||||
export {
|
||||
useBlockNumber,
|
||||
@@ -107,11 +112,8 @@ export {
|
||||
type PostOnRampQuoteQueryOptions,
|
||||
} from "../react/core/hooks/pay/usePostOnrampQuote.js";
|
||||
|
||||
export {
|
||||
AutoConnect,
|
||||
type AutoConnectProps,
|
||||
} from "../react/core/hooks/connection/AutoConnect.js";
|
||||
export { useAutoConnect } from "../react/core/hooks/connection/useAutoConnect.js";
|
||||
export { AutoConnect } from "../react/web/ui/AutoConnect/AutoConnect.js";
|
||||
export type { AutoConnectProps } from "../react/core/hooks/connection/types.js";
|
||||
|
||||
// auth
|
||||
export { type SiweAuthOptions } from "../react/core/hooks/auth/useSiweAuth.js";
|
||||
@@ -138,8 +140,3 @@ export {
|
||||
useWalletDetailsModal,
|
||||
type UseWalletDetailsModalOptions,
|
||||
} from "../react/web/ui/ConnectWallet/Details.js";
|
||||
|
||||
// eip5792 hooks
|
||||
export { useSendCalls } from "../react/core/hooks/wallets/useSendCalls.js";
|
||||
export { useCallsStatus } from "../react/core/hooks/wallets/useCallsStatus.js";
|
||||
export { useCapabilities } from "../react/core/hooks/wallets/useCapabilities.js";
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// --- KEEEP IN SYNC with exports/wallets.ts ---
|
||||
|
||||
export {
|
||||
createWallet,
|
||||
walletConnect,
|
||||
} from "../wallets/native/create-wallet.js";
|
||||
export { inAppWallet } from "../wallets/in-app/native/in-app.js";
|
||||
export { smartWallet } from "../wallets/smart/smart-wallet.js";
|
||||
|
||||
export type { Wallet, Account } from "../wallets/interfaces/wallet.js";
|
||||
export type { ConnectionStatus } from "../wallets/manager/index.js";
|
||||
|
||||
// utils
|
||||
export {
|
||||
getWalletBalance,
|
||||
type GetWalletBalanceOptions,
|
||||
} from "../wallets/utils/getWalletBalance.js";
|
||||
export {
|
||||
generateAccount,
|
||||
type GenerateAccountOptions,
|
||||
} from "../wallets/utils/generateAccount.js";
|
||||
|
||||
// private-key
|
||||
export {
|
||||
privateKeyToAccount,
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated - use {@link privateKeyToAccount} instead
|
||||
*/
|
||||
privateKeyToAccount as privateKeyAccount,
|
||||
type PrivateKeyToAccountOptions,
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated - use {@link PrivateKeyToAccountOptions} instead
|
||||
*/
|
||||
type PrivateKeyToAccountOptions as PrivateKeyAccountOptions,
|
||||
} from "../wallets/private-key.js";
|
||||
|
||||
export type {
|
||||
WalletId,
|
||||
WalletAutoConnectionOption,
|
||||
WalletCreationOptions,
|
||||
WalletConnectionOption,
|
||||
CreateWalletArgs,
|
||||
} from "../wallets/wallet-types.js";
|
||||
|
||||
export type {
|
||||
WCSupportedWalletIds,
|
||||
InjectedSupportedWalletIds,
|
||||
} from "../wallets/__generated__/wallet-ids.js";
|
||||
|
||||
export type {
|
||||
WCConnectOptions,
|
||||
WCAutoConnectOptions,
|
||||
} from "../wallets/wallet-connect/types.js";
|
||||
|
||||
export type {
|
||||
SmartWalletConnectionOptions,
|
||||
SmartWalletOptions,
|
||||
} from "../wallets/smart/types.js";
|
||||
|
||||
export type {
|
||||
InAppWalletAuth,
|
||||
/**
|
||||
* @deprecated use InAppWalletAuth instead
|
||||
*/
|
||||
InAppWalletAuth as EmbeddedWalletAuth,
|
||||
InAppWalletAutoConnectOptions,
|
||||
/**
|
||||
* @deprecated use InAppWalletAutoConnectOptions instead
|
||||
*/
|
||||
InAppWalletAutoConnectOptions as EmbeddedWalletAutoConnectOptions,
|
||||
InAppWalletConnectionOptions,
|
||||
/**
|
||||
* @deprecated use InAppWalletConnectionOptions instead
|
||||
*/
|
||||
InAppWalletConnectionOptions as EmbeddedWalletConnectionOptions,
|
||||
InAppWalletSocialAuth,
|
||||
/**
|
||||
* @deprecated use InAppWalletSocialAuth instead
|
||||
*/
|
||||
InAppWalletSocialAuth as EmbeddedWalletSocialAuth,
|
||||
} from "../wallets/in-app/core/wallet/types.js";
|
||||
|
||||
export type { CoinbaseSDKWalletConnectionOptions } from "../wallets/coinbase/coinbaseWebSDK.js";
|
||||
|
||||
export type {
|
||||
WalletEmitter,
|
||||
WalletEmitterEvents,
|
||||
} from "../wallets/wallet-emitter.js";
|
||||
|
||||
export { getAllWalletsList } from "../wallets/getAllWalletsList.js";
|
||||
export { getWalletInfo } from "../wallets/__generated__/getWalletInfo.js";
|
||||
export { type WalletInfo } from "../wallets/wallet-info.js";
|
||||
|
||||
export { createWalletAdapter } from "../adapters/wallet-adapter.js";
|
||||
|
||||
// NOT SUPPORTED
|
||||
|
||||
export const injectedProvider = () => {
|
||||
throw new Error("Not supported in native");
|
||||
};
|
||||
@@ -1,13 +1,17 @@
|
||||
// --- KEEEP IN SYNC with exports/wallets.native.ts ---
|
||||
|
||||
export {
|
||||
createWallet,
|
||||
smartWallet,
|
||||
walletConnect,
|
||||
} from "../wallets/create-wallet.js";
|
||||
export {
|
||||
inAppWallet,
|
||||
/**
|
||||
* @deprecated use inAppWallet instead
|
||||
*/
|
||||
inAppWallet as embeddedWallet,
|
||||
walletConnect,
|
||||
} from "../wallets/create-wallet.js";
|
||||
} from "../wallets/in-app/web/in-app.js";
|
||||
export { smartWallet } from "../wallets/smart/smart-wallet.js";
|
||||
|
||||
export type { Wallet, Account } from "../wallets/interfaces/wallet.js";
|
||||
export type { ConnectionStatus } from "../wallets/manager/index.js";
|
||||
@@ -38,9 +42,6 @@ export {
|
||||
type PrivateKeyToAccountOptions as PrivateKeyAccountOptions,
|
||||
} from "../wallets/private-key.js";
|
||||
|
||||
// injected
|
||||
export { injectedProvider } from "../wallets/injected/mipdStore.js";
|
||||
|
||||
export type {
|
||||
WalletId,
|
||||
WalletAutoConnectionOption,
|
||||
@@ -87,7 +88,7 @@ export type {
|
||||
InAppWalletSocialAuth as EmbeddedWalletSocialAuth,
|
||||
} from "../wallets/in-app/core/wallet/types.js";
|
||||
|
||||
export type { CoinbaseSDKWalletConnectionOptions } from "../wallets/coinbase/coinbaseSDKWallet.js";
|
||||
export type { CoinbaseSDKWalletConnectionOptions } from "../wallets/coinbase/coinbaseWebSDK.js";
|
||||
|
||||
export type {
|
||||
WalletEmitter,
|
||||
@@ -99,3 +100,8 @@ export { getWalletInfo } from "../wallets/__generated__/getWalletInfo.js";
|
||||
export { type WalletInfo } from "../wallets/wallet-info.js";
|
||||
|
||||
export { createWalletAdapter } from "../adapters/wallet-adapter.js";
|
||||
|
||||
// WEB ONLY EXPORTS
|
||||
|
||||
// injected
|
||||
export { injectedProvider } from "../wallets/injected/mipdStore.js";
|
||||
|
||||
@@ -26,6 +26,3 @@ export type {
|
||||
GetCallsStatusResponse,
|
||||
WalletCallReceipt,
|
||||
} from "../../wallets/eip5792/types.js";
|
||||
export { useSendCalls } from "../../react/core/hooks/wallets/useSendCalls.js";
|
||||
export { useCallsStatus } from "../../react/core/hooks/wallets/useCallsStatus.js";
|
||||
export { useCapabilities } from "../../react/core/hooks/wallets/useCapabilities.js";
|
||||
|
||||
@@ -4,11 +4,12 @@ export {
|
||||
* @deprecated use inAppWallet instead
|
||||
*/
|
||||
inAppWallet as embeddedWallet,
|
||||
} from "../../wallets/create-wallet.js";
|
||||
} from "../../wallets/in-app/web/in-app.js";
|
||||
|
||||
export {
|
||||
preAuthenticate,
|
||||
authenticate,
|
||||
getUserEmail,
|
||||
type GetAuthenticatedUserParams,
|
||||
} from "../../wallets/in-app/core/authentication/index.js";
|
||||
} from "../../wallets/in-app/web/lib/auth/index.js";
|
||||
|
||||
export { type GetAuthenticatedUserParams } from "../../wallets/in-app/core/authentication/type.js";
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// --- KEEEP IN SYNC with exports/wallets/in-app.ts ---
|
||||
|
||||
export { inAppWallet } from "../../wallets/in-app/native/in-app.js";
|
||||
|
||||
export {
|
||||
preAuthenticate,
|
||||
authenticate,
|
||||
getUserEmail,
|
||||
getUserPhoneNumber,
|
||||
} from "../../wallets/in-app/native/auth/index.js";
|
||||
|
||||
export { type GetAuthenticatedUserParams } from "../../wallets/in-app/core/authentication/type.js";
|
||||
|
||||
// NOT SUPPORTED (yet)
|
||||
|
||||
export const hasStoredPasskey = () => {
|
||||
throw new Error("Not supported in native");
|
||||
};
|
||||
@@ -1,12 +1,15 @@
|
||||
export { inAppWallet } from "../../wallets/create-wallet.js";
|
||||
// --- KEEEP IN SYNC with exports/wallets/in-app.native.ts ---
|
||||
|
||||
export { inAppWallet } from "../../wallets/in-app/web/in-app.js";
|
||||
|
||||
export {
|
||||
preAuthenticate,
|
||||
authenticate,
|
||||
getUserEmail,
|
||||
getUserPhoneNumber,
|
||||
type GetAuthenticatedUserParams,
|
||||
} from "../../wallets/in-app/core/authentication/index.js";
|
||||
} from "../../wallets/in-app/web/lib/auth/index.js";
|
||||
|
||||
export { type GetAuthenticatedUserParams } from "../../wallets/in-app/core/authentication/type.js";
|
||||
|
||||
export { hasStoredPasskey } from "../../wallets/in-app/web/lib/auth/passkeys.js";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export { smartWallet } from "../../wallets/create-wallet.js";
|
||||
export { smartWallet } from "../../wallets/smart/smart-wallet.js";
|
||||
|
||||
export type {
|
||||
SmartWalletConnectionOptions,
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { createConnectionManager } from "../../wallets/manager/index.js";
|
||||
import { getStorage } from "./storage.js";
|
||||
import type { AsyncStorage } from "../../utils/storage/AsyncStorage.js";
|
||||
import {
|
||||
type ConnectionManager,
|
||||
createConnectionManager,
|
||||
} from "../../wallets/manager/index.js";
|
||||
|
||||
export const connectionManager = /* @__PURE__ */ createConnectionManager(
|
||||
/* @__PURE__ */ getStorage(),
|
||||
);
|
||||
let _connectManager: ConnectionManager;
|
||||
|
||||
export function connectionManagerSingleton(storage: AsyncStorage) {
|
||||
if (_connectManager) {
|
||||
return _connectManager;
|
||||
}
|
||||
return createConnectionManager(storage);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export function CustomThemeProvider(props: {
|
||||
}
|
||||
|
||||
export function parseTheme(theme: "light" | "dark" | Theme | undefined): Theme {
|
||||
if (!theme) {
|
||||
if (!theme || !isValidTheme(theme)) {
|
||||
return darkThemeObj;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,19 @@ export function parseTheme(theme: "light" | "dark" | Theme | undefined): Theme {
|
||||
return themeObj;
|
||||
}
|
||||
|
||||
export function isValidTheme(theme: unknown): theme is Theme {
|
||||
return (
|
||||
theme === "dark" ||
|
||||
theme === "light" ||
|
||||
(typeof theme === "object" &&
|
||||
theme !== null &&
|
||||
"colors" in theme &&
|
||||
"fontSizes" in theme &&
|
||||
"radii" in theme &&
|
||||
"space" in theme)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @internal
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { LoginPayload } from "../../../../auth/core/types.js";
|
||||
import type { VerifyLoginPayloadParams } from "../../../../auth/core/verify-login-payload.js";
|
||||
import { useActiveWallet } from "../../../core/hooks/wallets/wallet-hooks.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
|
||||
/**
|
||||
* Options for Setting up SIWE (Sign in with Ethereum) Authentication
|
||||
@@ -46,8 +46,10 @@ export type SiweAuthOptions = {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function useSiweAuth(authOptions?: SiweAuthOptions) {
|
||||
const activeWallet = useActiveWallet();
|
||||
export function useSiweAuth(
|
||||
activeWallet?: Wallet,
|
||||
authOptions?: SiweAuthOptions,
|
||||
) {
|
||||
const activeAccount = activeWallet?.getAccount();
|
||||
|
||||
const requiresAuth = !!authOptions;
|
||||
|
||||
-58
@@ -1,11 +1,7 @@
|
||||
"use client";
|
||||
import { useEffect } from "react";
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
|
||||
import type { AppMetadata } from "../../../../wallets/types.js";
|
||||
import { useSetActiveWalletConnectionStatus } from "../wallets/wallet-hooks.js";
|
||||
import { useAutoConnect } from "./useAutoConnect.js";
|
||||
|
||||
export type AutoConnectProps = {
|
||||
/**
|
||||
@@ -112,57 +108,3 @@ export type AutoConnectProps = {
|
||||
*/
|
||||
onConnect?: (wallet: Wallet) => void;
|
||||
};
|
||||
|
||||
/**
|
||||
* AutoConnect last connected wallet on page reload or revisit.
|
||||
* Note: If you are using `ConnectButton` or `ConnectEmbed` components, You don't need to use this component as it is already included.
|
||||
*
|
||||
* This is useful if you are manually connecting the wallets using the [`useConnect`](https://portal.thirdweb.com/references/typescript/v5/useConnect) hook and want to auto connect the last connected wallets on page reload or revisit.
|
||||
* @param props - Object of type `AutoConnectProps`. Refer to [`AutoConnectProps`](https://portal.thirdweb.com/references/typescript/v5/AutoConnectProps)
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { AutoConnect } from "thirdweb/react";
|
||||
* import { createWallet, inAppWallet } from "thirdweb/wallets";
|
||||
*
|
||||
*
|
||||
* // list of wallets that your app uses
|
||||
* const wallets = [
|
||||
* inAppWallet(),
|
||||
* createWallet('io.metamask'),
|
||||
* createWallet("me.rainbow"),
|
||||
* ]
|
||||
*
|
||||
* function Example() {
|
||||
* return (
|
||||
* <AutoConnect
|
||||
* wallets={wallets}
|
||||
* client={client}
|
||||
* appMetadata={appMetadata}
|
||||
* />
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
* @component
|
||||
*/
|
||||
export function AutoConnect(props: AutoConnectProps) {
|
||||
useAutoConnect(props);
|
||||
return <></>;
|
||||
}
|
||||
|
||||
let noAutoConnectDone = false;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function NoAutoConnect() {
|
||||
const setConnectionStatus = useSetActiveWalletConnectionStatus();
|
||||
useEffect(() => {
|
||||
if (noAutoConnectDone) {
|
||||
return;
|
||||
}
|
||||
noAutoConnectDone = true;
|
||||
setConnectionStatus("disconnected");
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
+36
-48
@@ -1,4 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import type { TransactionReceipt } from "viem";
|
||||
import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js";
|
||||
import {
|
||||
@@ -7,12 +7,11 @@ import {
|
||||
} from "../../../../transaction/actions/wait-for-tx-receipt.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import { stringify } from "../../../../utils/json.js";
|
||||
import {
|
||||
type SendTransactionPayModalConfig,
|
||||
useSendTransaction,
|
||||
} from "../../../web/hooks/useSendTransaction.js";
|
||||
import type { Theme } from "../../design-system/index.js";
|
||||
import { useActiveAccount } from "../wallets/wallet-hooks.js";
|
||||
import type {
|
||||
SendTransactionPayModalConfig,
|
||||
useSendTransactionCore,
|
||||
} from "./useSendTransaction.js";
|
||||
|
||||
/**
|
||||
* Props for the [`TransactionButton`](https://portal.thirdweb.com/references/typescript/v5/TransactionButton) component.
|
||||
@@ -103,56 +102,45 @@ export type TransactionButtonProps = {
|
||||
theme?: "dark" | "light" | Theme;
|
||||
};
|
||||
|
||||
export function useTransactionButtonCore(props: TransactionButtonProps) {
|
||||
export const useTransactionButtonMutation = (
|
||||
props: TransactionButtonProps,
|
||||
sendTransactionFn: ReturnType<typeof useSendTransactionCore>["mutateAsync"],
|
||||
) => {
|
||||
const {
|
||||
transaction,
|
||||
onTransactionSent,
|
||||
onTransactionConfirmed,
|
||||
onError,
|
||||
onClick,
|
||||
gasless,
|
||||
payModal,
|
||||
} = props;
|
||||
const account = useActiveAccount();
|
||||
const [isPending, setIsPending] = useState(false);
|
||||
|
||||
const sendTransaction = useSendTransaction({
|
||||
gasless,
|
||||
payModal,
|
||||
});
|
||||
|
||||
const handleClick = async () => {
|
||||
if (onClick) {
|
||||
onClick();
|
||||
}
|
||||
try {
|
||||
setIsPending(true);
|
||||
const resolvedTx = await transaction();
|
||||
const result = await sendTransaction.mutateAsync(resolvedTx);
|
||||
|
||||
if (onTransactionSent) {
|
||||
onTransactionSent(result);
|
||||
return useMutation({
|
||||
mutationFn: async () => {
|
||||
if (onClick) {
|
||||
onClick();
|
||||
}
|
||||
try {
|
||||
const resolvedTx = await transaction();
|
||||
const result = await sendTransactionFn(resolvedTx);
|
||||
|
||||
if (onTransactionConfirmed) {
|
||||
const receipt = await waitForReceipt(result);
|
||||
if (receipt.status === "reverted") {
|
||||
throw new Error(`Execution reverted: ${stringify(receipt, null, 2)}`);
|
||||
if (onTransactionSent) {
|
||||
onTransactionSent(result);
|
||||
}
|
||||
onTransactionConfirmed(receipt);
|
||||
}
|
||||
} catch (error) {
|
||||
if (onError) {
|
||||
onError(error as Error);
|
||||
}
|
||||
} finally {
|
||||
setIsPending(false);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
account,
|
||||
handleClick,
|
||||
isPending,
|
||||
};
|
||||
}
|
||||
if (onTransactionConfirmed) {
|
||||
const receipt = await waitForReceipt(result);
|
||||
if (receipt.status === "reverted") {
|
||||
throw new Error(
|
||||
`Execution reverted: ${stringify(receipt, null, 2)}`,
|
||||
);
|
||||
}
|
||||
onTransactionConfirmed(receipt);
|
||||
}
|
||||
} catch (error) {
|
||||
if (onError) {
|
||||
onError(error as Error);
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import {
|
||||
type EstimateGasResult,
|
||||
estimateGas,
|
||||
} from "../../../../transaction/actions/estimate-gas.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import type { Account } from "../../../../wallets/interfaces/wallet.js";
|
||||
|
||||
export function useEstimateGasCore(
|
||||
account: Account | undefined,
|
||||
): UseMutationResult<EstimateGasResult, Error, PreparedTransaction> {
|
||||
return useMutation({
|
||||
mutationFn: (transaction) => estimateGas({ transaction, account }),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import {
|
||||
type EstimateGasCostResult,
|
||||
estimateGasCost,
|
||||
} from "../../../../transaction/actions/estimate-gas-cost.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import type { Account } from "../../../../wallets/interfaces/wallet.js";
|
||||
|
||||
export function useEstimateGasCost(
|
||||
account: Account | undefined,
|
||||
): UseMutationResult<EstimateGasCostResult, Error, PreparedTransaction> {
|
||||
return useMutation({
|
||||
mutationFn: (transaction) => estimateGasCost({ transaction, account }),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import { sendAndConfirmTransaction } from "../../../../transaction/actions/send-and-confirm-transaction.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import type { TransactionReceipt } from "../../../../transaction/types.js";
|
||||
import type { Account } from "../../../../wallets/interfaces/wallet.js";
|
||||
|
||||
export function useSendAndConfirmTransactionCore(
|
||||
account: Account | undefined,
|
||||
): UseMutationResult<TransactionReceipt, Error, PreparedTransaction> {
|
||||
return useMutation({
|
||||
mutationFn: async (transaction) => {
|
||||
if (!account) {
|
||||
throw new Error("No active account");
|
||||
}
|
||||
return await sendAndConfirmTransaction({
|
||||
transaction,
|
||||
account,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import { sendBatchTransaction } from "../../../../transaction/actions/send-batch-transaction.js";
|
||||
import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import type { Account } from "../../../../wallets/interfaces/wallet.js";
|
||||
|
||||
export function useSendBatchTransactionCore(
|
||||
account: Account | undefined,
|
||||
): UseMutationResult<WaitForReceiptOptions, Error, PreparedTransaction[]> {
|
||||
return useMutation({
|
||||
mutationFn: async (transactions) => {
|
||||
if (!account) {
|
||||
throw new Error("No active account");
|
||||
}
|
||||
return await sendBatchTransaction({
|
||||
transactions,
|
||||
account,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
+63
-12
@@ -1,20 +1,70 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import type { Chain } from "../../../../chains/types.js";
|
||||
import { estimateGasCost } from "../../../../transaction/actions/estimate-gas-cost.js";
|
||||
import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js";
|
||||
import { sendTransaction } from "../../../../transaction/actions/send-transaction.js";
|
||||
import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import {
|
||||
type GetWalletBalanceResult,
|
||||
getWalletBalance,
|
||||
} from "../../../../wallets/utils/getWalletBalance.js";
|
||||
import type { SupportedTokens } from "../../../web/ui/ConnectWallet/defaultTokens.js";
|
||||
import { fetchBuySupportedDestinations } from "../../../web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js";
|
||||
import {
|
||||
useActiveAccount,
|
||||
useActiveWallet,
|
||||
useSwitchActiveWalletChain,
|
||||
} from "../wallets/wallet-hooks.js";
|
||||
import type { LocaleId } from "../../../web/ui/types.js";
|
||||
import type { Theme } from "../../design-system/index.js";
|
||||
|
||||
/**
|
||||
* Configuration for the "Pay Modal" that opens when the user doesn't have enough funds to send a transaction.
|
||||
* Set `payModal: false` to disable the "Pay Modal" popup
|
||||
*
|
||||
* This configuration object includes the following properties to configure the "Pay Modal" UI:
|
||||
*
|
||||
* ### `locale`
|
||||
* The language to use for the "Pay Modal" UI. Defaults to `"en_US"`.
|
||||
*
|
||||
* ### `supportedTokens`
|
||||
* An object of type [`SupportedTokens`](https://portal.thirdweb.com/references/typescript/v5/SupportedTokens) to configure the tokens to show for a chain.
|
||||
*
|
||||
* ### `theme`
|
||||
* The theme to use for the "Pay Modal" UI. Defaults to `"dark"`.
|
||||
*
|
||||
* It can be set to `"light"` or `"dark"` or an object of type [`Theme`](https://portal.thirdweb.com/references/typescript/v5/Theme) for a custom theme.
|
||||
*
|
||||
* Refer to [`lightTheme`](https://portal.thirdweb.com/references/typescript/v5/lightTheme)
|
||||
* or [`darkTheme`](https://portal.thirdweb.com/references/typescript/v5/darkTheme) helper functions to use the default light or dark theme and customize it.
|
||||
*/
|
||||
export type SendTransactionPayModalConfig =
|
||||
| {
|
||||
locale?: LocaleId;
|
||||
supportedTokens?: SupportedTokens;
|
||||
theme?: Theme | "light" | "dark";
|
||||
buyWithCrypto?: false;
|
||||
buyWithFiat?:
|
||||
| false
|
||||
| {
|
||||
testMode?: boolean;
|
||||
};
|
||||
}
|
||||
| false;
|
||||
|
||||
/**
|
||||
* Configuration for the `useSendTransaction` hook.
|
||||
*/
|
||||
export type SendTransactionConfig = {
|
||||
/**
|
||||
* Refer to [`SendTransactionPayModalConfig`](https://portal.thirdweb.com/references/typescript/v5/SendTransactionPayModalConfig) for more details.
|
||||
*/
|
||||
payModal?: SendTransactionPayModalConfig;
|
||||
|
||||
/**
|
||||
* Configuration for gasless transactions.
|
||||
* Refer to [`GaslessOptions`](https://portal.thirdweb.com/references/typescript/v5/GaslessOptions) for more details.
|
||||
*/
|
||||
gasless?: GaslessOptions;
|
||||
};
|
||||
|
||||
type ShowModalData = {
|
||||
tx: PreparedTransaction;
|
||||
@@ -37,13 +87,14 @@ type ShowModalData = {
|
||||
* ```
|
||||
* @internal
|
||||
*/
|
||||
export function useSendTransactionCore(
|
||||
showPayModal?: (data: ShowModalData) => void,
|
||||
gasless?: GaslessOptions,
|
||||
): UseMutationResult<WaitForReceiptOptions, Error, PreparedTransaction> {
|
||||
let _account = useActiveAccount();
|
||||
const wallet = useActiveWallet();
|
||||
const switchChain = useSwitchActiveWalletChain();
|
||||
export function useSendTransactionCore(args: {
|
||||
showPayModal?: (data: ShowModalData) => void;
|
||||
gasless?: GaslessOptions;
|
||||
wallet: Wallet | undefined;
|
||||
switchChain: (chain: Chain) => Promise<void>;
|
||||
}): UseMutationResult<WaitForReceiptOptions, Error, PreparedTransaction> {
|
||||
const { showPayModal, gasless, wallet, switchChain } = args;
|
||||
let _account = wallet?.getAccount();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (tx) => {
|
||||
@@ -0,0 +1,19 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import type { Abi, AbiFunction } from "abitype";
|
||||
import {
|
||||
type SimulateOptions,
|
||||
simulateTransaction,
|
||||
} from "../../../../transaction/actions/simulate.js";
|
||||
|
||||
export function useSimulateTransaction<
|
||||
const abi extends Abi,
|
||||
const abiFn extends AbiFunction,
|
||||
>(): UseMutationResult<
|
||||
Awaited<ReturnType<typeof simulateTransaction>>,
|
||||
Error,
|
||||
SimulateOptions<abi, abiFn>
|
||||
> {
|
||||
return useMutation({
|
||||
mutationFn: (options) => simulateTransaction(options),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useActiveAccountCore(manager: ConnectionManager) {
|
||||
const store = manager.activeAccountStore;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useActiveWalletCore(manager: ConnectionManager) {
|
||||
const store = manager.activeWalletStore;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useActiveWalletChainCore(manager: ConnectionManager) {
|
||||
const store = manager.activeWalletChainStore;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useActiveWalletConnectionStatusCore(
|
||||
manager: ConnectionManager,
|
||||
) {
|
||||
const store = manager.activeWalletConnectionStatusStore;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
+19
-41
@@ -1,47 +1,29 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { createWallet } from "../../../../wallets/create-wallet.js";
|
||||
import { getInstalledWalletProviders } from "../../../../wallets/injected/mipdStore.js";
|
||||
import type { AsyncStorage } from "../../../../utils/storage/AsyncStorage.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import {
|
||||
type ConnectionManager,
|
||||
getLastConnectedChain,
|
||||
getStoredActiveWalletId,
|
||||
getStoredConnectedWalletIds,
|
||||
} from "../../../../wallets/manager/index.js";
|
||||
import { connectionManager } from "../../connectionManager.js";
|
||||
import { getStorage } from "../../storage.js";
|
||||
import { timeoutPromise } from "../../utils/timeoutPromise.js";
|
||||
import {
|
||||
useConnect,
|
||||
useSetActiveWalletConnectionStatus,
|
||||
} from "../wallets/wallet-hooks.js";
|
||||
import type { AutoConnectProps } from "./AutoConnect.js";
|
||||
import type { AutoConnectProps } from "../connection/types.js";
|
||||
import { useConnectCore } from "./useConnect.js";
|
||||
import { useSetActiveWalletConnectionStatusCore } from "./useSetActiveWalletConnectionStatus.js";
|
||||
|
||||
/**
|
||||
* Autoconnect the last previously connected wallet.
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useAutoConnect } from "thirdweb/react";
|
||||
*
|
||||
* const { data: autoConnected, isLoading } = useAutoConnect({
|
||||
* client,
|
||||
* accountAbstraction,
|
||||
* wallets,
|
||||
* onConnect,
|
||||
* timeout,
|
||||
* });
|
||||
* ```
|
||||
* @walletConnection
|
||||
* @param props - The props for auto connect.
|
||||
* @returns whether the auto connect was successful.
|
||||
*/
|
||||
export function useAutoConnect(props: AutoConnectProps) {
|
||||
const setConnectionStatus = useSetActiveWalletConnectionStatus();
|
||||
const { connect } = useConnect({
|
||||
export function useAutoConnectCore(
|
||||
manager: ConnectionManager,
|
||||
storage: AsyncStorage,
|
||||
props: AutoConnectProps,
|
||||
getInstalledWallets?: () => Wallet[],
|
||||
) {
|
||||
const setConnectionStatus = useSetActiveWalletConnectionStatusCore(manager);
|
||||
const { connect } = useConnectCore(manager, {
|
||||
client: props.client,
|
||||
accountAbstraction: props.accountAbstraction,
|
||||
});
|
||||
const { isAutoConnecting } = connectionManager;
|
||||
const { isAutoConnecting } = manager;
|
||||
const { wallets, onConnect } = props;
|
||||
const timeout = props.timeout ?? 15000;
|
||||
// get the supported wallets from thirdweb provider
|
||||
@@ -50,10 +32,9 @@ export function useAutoConnect(props: AutoConnectProps) {
|
||||
const autoConnect = async (): Promise<boolean> => {
|
||||
let autoConnected = false;
|
||||
isAutoConnecting.setValue(true);
|
||||
const asyncLocalStorage = getStorage();
|
||||
const [lastConnectedWalletIds, lastActiveWalletId] = await Promise.all([
|
||||
getStoredConnectedWalletIds(asyncLocalStorage),
|
||||
getStoredActiveWalletId(asyncLocalStorage),
|
||||
getStoredConnectedWalletIds(storage),
|
||||
getStoredActiveWalletId(storage),
|
||||
]);
|
||||
|
||||
// if no wallets were last connected
|
||||
@@ -61,7 +42,7 @@ export function useAutoConnect(props: AutoConnectProps) {
|
||||
return autoConnected;
|
||||
}
|
||||
|
||||
const lastConnectedChain = await getLastConnectedChain(asyncLocalStorage);
|
||||
const lastConnectedChain = await getLastConnectedChain(storage);
|
||||
|
||||
async function handleWalletConnection(wallet: Wallet) {
|
||||
return wallet.autoConnect({
|
||||
@@ -70,10 +51,7 @@ export function useAutoConnect(props: AutoConnectProps) {
|
||||
});
|
||||
}
|
||||
|
||||
const availableWallets = [
|
||||
...wallets,
|
||||
...getInstalledWalletProviders().map((p) => createWallet(p.info.rdns)),
|
||||
];
|
||||
const availableWallets = [...wallets, ...(getInstalledWallets?.() ?? [])];
|
||||
const activeWallet =
|
||||
lastActiveWalletId &&
|
||||
availableWallets.find((w) => w.id === lastActiveWalletId);
|
||||
@@ -119,7 +97,7 @@ export function useAutoConnect(props: AutoConnectProps) {
|
||||
for (const wallet of otherWallets) {
|
||||
try {
|
||||
await handleWalletConnection(wallet);
|
||||
connectionManager.addConnectedWallet(wallet);
|
||||
manager.addConnectedWallet(wallet);
|
||||
} catch (e) {
|
||||
console.error("Failed to auto connect a non-active connected wallet");
|
||||
console.error(e);
|
||||
@@ -6,29 +6,17 @@ import {
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import { getCallsStatus } from "../../../../wallets/eip5792/get-calls-status.js";
|
||||
import type { GetCallsStatusResponse } from "../../../../wallets/eip5792/types.js";
|
||||
import { useActiveWallet } from "./wallet-hooks.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
|
||||
/**
|
||||
* A hook to get a call bundle's current status according to [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792).
|
||||
*
|
||||
* @note This function is dependent on the wallet's support for EIP-5792 and could throw an error if it's not supported.
|
||||
*
|
||||
* @returns a React Query object.
|
||||
* @beta
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useCallsStatus } from "thirdweb/react";
|
||||
* const { data: status, isLoading } = useCallsStatus({ bundleId, client });
|
||||
* ```
|
||||
* @extension EIP5792
|
||||
*/
|
||||
export function useCallsStatus(options: {
|
||||
bundleId: string;
|
||||
client: ThirdwebClient;
|
||||
queryOptions?: Pick<UseQueryOptions, "enabled" | "retry">;
|
||||
}): UseQueryResult<GetCallsStatusResponse> {
|
||||
export function useCallsStatusCore(
|
||||
options: {
|
||||
bundleId: string;
|
||||
client: ThirdwebClient;
|
||||
queryOptions?: Pick<UseQueryOptions, "enabled" | "retry">;
|
||||
},
|
||||
wallet?: Wallet,
|
||||
): UseQueryResult<GetCallsStatusResponse> {
|
||||
const { client, bundleId } = options;
|
||||
const wallet = useActiveWallet();
|
||||
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
|
||||
@@ -7,28 +7,14 @@ import {
|
||||
type GetCapabilitiesResult,
|
||||
getCapabilities,
|
||||
} from "../../../../wallets/eip5792/get-capabilities.js";
|
||||
import { useActiveWallet } from "./wallet-hooks.js";
|
||||
|
||||
/**
|
||||
* A hook to get the current wallet's capabilities according to [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792).
|
||||
*
|
||||
* @note This function is dependent on the wallet's support for EIP-5792, but will not throw.
|
||||
* **The returned object contains a `message` field detailing any issues with the wallet's support for EIP-5792.**
|
||||
*
|
||||
* @returns a React Query object.
|
||||
* @beta
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useCapabilities } from "thirdweb/react";
|
||||
* const { data: capabilities, isLoading } = useCapabilities();
|
||||
* ```
|
||||
* @extension EIP5792
|
||||
*/
|
||||
export function useCapabilities(options?: {
|
||||
queryOptions?: Pick<UseQueryOptions, "enabled" | "retry">;
|
||||
}): UseQueryResult<GetCapabilitiesResult> {
|
||||
const wallet = useActiveWallet();
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
|
||||
export function useCapabilitiesCore(
|
||||
options?: {
|
||||
queryOptions?: Pick<UseQueryOptions, "enabled" | "retry">;
|
||||
},
|
||||
wallet?: Wallet,
|
||||
): UseQueryResult<GetCapabilitiesResult> {
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
"getCapabilities",
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import type {
|
||||
ConnectManagerOptions,
|
||||
ConnectionManager,
|
||||
} from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useConnectCore(
|
||||
manager: ConnectionManager,
|
||||
options?: ConnectManagerOptions,
|
||||
) {
|
||||
const { connect } = manager;
|
||||
const [isConnecting, setIsConnecting] = useState(false);
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
|
||||
const handleConnection = useCallback(
|
||||
async (walletOrFn: Wallet | (() => Promise<Wallet>)) => {
|
||||
// reset error state
|
||||
setError(null);
|
||||
if (typeof walletOrFn !== "function") {
|
||||
return connect(walletOrFn, options);
|
||||
}
|
||||
|
||||
setIsConnecting(true);
|
||||
try {
|
||||
const w = await walletOrFn();
|
||||
return connect(w, options);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError(e as Error);
|
||||
} finally {
|
||||
setIsConnecting(false);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
[connect, options],
|
||||
);
|
||||
|
||||
return { connect: handleConnection, isConnecting, error } as const;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useConnectedWalletsCore(manager: ConnectionManager) {
|
||||
const store = manager.connectedWallets;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useDisconnectCore(manager: ConnectionManager) {
|
||||
const disconnect = manager.disconnectWallet;
|
||||
return { disconnect };
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useIsAutoConnectingCore(manager: ConnectionManager) {
|
||||
const store = manager.isAutoConnecting;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
@@ -15,78 +15,19 @@ import type {
|
||||
import { waitForBundle } from "../../../../wallets/eip5792/wait-for-bundle.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import { invalidateWalletBalance } from "../../providers/invalidateWalletBalance.js";
|
||||
import { useActiveWallet } from "../wallets/wallet-hooks.js";
|
||||
|
||||
/**
|
||||
* A hook to send [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792) calls to a wallet.
|
||||
* This hook works with all Thirdweb wallets (in-app and smart) and certain injected wallets that already support EIP-5792.
|
||||
* Transactions will be bundled and sponsored when those capabilities are supported, otherwise they will be sent as individual transactions.
|
||||
*
|
||||
* When calls are sent, all contracts that are interacted with will have their corresponding reads revalidated via React Query.
|
||||
*
|
||||
* @note This hook is dependent on the wallet's support for EIP-5792 and could fail.
|
||||
* @note The mutatuon function will use your currently connected wallet by default, but you can pass it a specific wallet to use if you'd like.
|
||||
*
|
||||
* @returns A React Query mutatuon object to interact with {@link sendCalls}
|
||||
* @throws an error if the wallet does not support EIP-5792.
|
||||
* @returns The ID of the bundle of the calls.
|
||||
*
|
||||
* @beta
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useSendCalls } from "thirdweb/react";
|
||||
*
|
||||
* const sendTx1 = approve({
|
||||
contract: USDT_CONTRACT,
|
||||
amount: 100,
|
||||
spender: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
|
||||
});
|
||||
* const sendTx2 = approve({
|
||||
contract: USDT_CONTRACT,
|
||||
amount: 100,
|
||||
spender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
||||
});
|
||||
* const { mutate: sendCalls, data: bundleId } = useSendCalls({ client });
|
||||
* await sendCalls({
|
||||
* wallet,
|
||||
* client,
|
||||
* calls: [sendTx1, sendTx2],
|
||||
* });
|
||||
* ```
|
||||
* Await the bundle's full confirmation:
|
||||
* ```tsx
|
||||
* const { mutate: sendCalls, data: bundleId } = useSendCalls({ client, waitForResult: true });
|
||||
* await sendCalls({
|
||||
* wallet,
|
||||
* client,
|
||||
* calls: [sendTx1, sendTx2],
|
||||
* });
|
||||
* ```
|
||||
* Sponsor transactions with a paymaster:
|
||||
* ```ts
|
||||
* const { mutate: sendCalls, data: bundleId } = useSendCalls();
|
||||
* await sendCalls({
|
||||
* client,
|
||||
* calls: [sendTx1, sendTx2],
|
||||
* capabilities: {
|
||||
* paymasterService: {
|
||||
* url: `https://${CHAIN.id}.bundler.thirdweb.com/${client.clientId}`
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
* @note We recommend proxying any paymaster calls via an API route you setup and control.
|
||||
* ```
|
||||
* @extension EIP5792
|
||||
*/
|
||||
export function useSendCalls({
|
||||
client,
|
||||
waitForResult = true,
|
||||
}: { client: ThirdwebClient; waitForResult?: boolean }): UseMutationResult<
|
||||
export function useSendCallsCore(
|
||||
{
|
||||
client,
|
||||
waitForResult = true,
|
||||
}: { client: ThirdwebClient; waitForResult?: boolean },
|
||||
wallet?: Wallet,
|
||||
): UseMutationResult<
|
||||
GetCallsStatusResponse | WalletSendCallsId,
|
||||
Error,
|
||||
Omit<SendCallsOptions, "chain" | "wallet"> & { wallet?: Wallet } // Optional wallet override
|
||||
> {
|
||||
const connectedWallet = useActiveWallet();
|
||||
const connectedWallet = wallet;
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useSetActiveWalletCore(manager: ConnectionManager) {
|
||||
return manager.setActiveWallet;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useSetActiveWalletConnectionStatusCore(
|
||||
manager: ConnectionManager,
|
||||
) {
|
||||
return manager.activeWalletConnectionStatusStore.setValue;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { ConnectionManager } from "../../../../wallets/manager/index.js";
|
||||
|
||||
export function useSwitchActiveWalletChainCore(manager: ConnectionManager) {
|
||||
return manager.switchActiveWalletChain;
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
"use client";
|
||||
import { useCallback, useState, useSyncExternalStore } from "react";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import type { ConnectManagerOptions } from "../../../../wallets/manager/index.js";
|
||||
import { connectionManager } from "../../connectionManager.js";
|
||||
|
||||
/**
|
||||
* A hook that returns the active account
|
||||
* @returns The active `Account` or `undefined` if no active account is set.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useActiveAccount } from "thirdweb/react";
|
||||
*
|
||||
* const activeAccount = useActiveAccount();
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useActiveAccount() {
|
||||
const store = connectionManager.activeAccountStore;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook that returns the active wallet
|
||||
* @returns The active `Wallet` or `undefined` if no active wallet is set.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useActiveWallet } from "thirdweb/react";
|
||||
*
|
||||
* const wallet = useActiveWallet();
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useActiveWallet() {
|
||||
const store = connectionManager.activeWalletStore;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to blockchain with given chain id in the active wallet.
|
||||
* @returns A function to switch to blockchain with given chain id in the active wallet.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useSwitchActiveWalletChain } from "thirdweb/react";
|
||||
* import { sepolia } from "thirdweb/chains";
|
||||
*
|
||||
* const switchChain = useSwitchActiveWalletChain();
|
||||
*
|
||||
* // later in your code
|
||||
* <button onClick={() => switchChain(sepolia)}>Switch Chain</button>
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useSwitchActiveWalletChain() {
|
||||
return connectionManager.switchActiveWalletChain;
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook that returns the chain the active wallet is connected to
|
||||
* @returns The chain the active wallet is connected to or null if no active wallet.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useActiveWalletChain } from "thirdweb/react";
|
||||
*
|
||||
* const chainId = useActiveWalletChain();
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useActiveWalletChain() {
|
||||
const store = connectionManager.activeWalletChainStore;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook that returns all connected wallets
|
||||
* @returns An array of all connected wallets
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useConnectedWallets } from "thirdweb/react";
|
||||
*
|
||||
* const wallets = useConnectedWallets();
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useConnectedWallets() {
|
||||
const store = connectionManager.connectedWallets;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook that lets you set the active wallet.
|
||||
* @returns A function that lets you set the active wallet.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useSetActiveWallet } from "thirdweb/react";
|
||||
*
|
||||
* const setActiveAccount = useSetActiveWallet();
|
||||
*
|
||||
* // later in your code
|
||||
* await setActiveAccount(account);
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useSetActiveWallet() {
|
||||
return connectionManager.setActiveWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook to set a wallet as active wallet
|
||||
* @returns A function that lets you connect a wallet.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useConnect } from "thirdweb/react";
|
||||
* import { createWallet } from "thirdweb/wallets";
|
||||
*
|
||||
* function Example() {
|
||||
* const { connect, isConnecting, error } = useConnect();
|
||||
* return (
|
||||
* <button
|
||||
* onClick={() =>
|
||||
* connect(async () => {
|
||||
* // instantiate wallet
|
||||
* const wallet = createWallet("io.metamask");
|
||||
* // connect wallet
|
||||
* await wallet.connect();
|
||||
* // return the wallet
|
||||
* return wallet;
|
||||
* })
|
||||
* }
|
||||
* >
|
||||
* Connect
|
||||
* </button>
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useConnect(options?: ConnectManagerOptions) {
|
||||
const { connect } = connectionManager;
|
||||
const [isConnecting, setIsConnecting] = useState(false);
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
|
||||
const handleConnection = useCallback(
|
||||
async (walletOrFn: Wallet | (() => Promise<Wallet>)) => {
|
||||
// reset error state
|
||||
setError(null);
|
||||
if (typeof walletOrFn !== "function") {
|
||||
return connect(walletOrFn, options);
|
||||
}
|
||||
|
||||
setIsConnecting(true);
|
||||
try {
|
||||
const w = await walletOrFn();
|
||||
return connect(w, options);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError(e as Error);
|
||||
} finally {
|
||||
setIsConnecting(false);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
[connect, options],
|
||||
);
|
||||
|
||||
return { connect: handleConnection, isConnecting, error } as const;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from given account
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useDisconnect, useActiveWallet } from "thirdweb/react";
|
||||
*
|
||||
* function Example() {
|
||||
* const { disconnect } = useDisconnect();
|
||||
* const wallet = useActiveWallet();
|
||||
*
|
||||
* return (
|
||||
* <button onClick={() => disconnect(wallet)}>
|
||||
* Disconnect
|
||||
* </button>
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
* @walletConnection
|
||||
* @returns An object with a function to disconnect an account
|
||||
*/
|
||||
export function useDisconnect() {
|
||||
const disconnect = connectionManager.disconnectWallet;
|
||||
return { disconnect };
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook that returns the active account's connection status.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useActiveWalletConnectionStatus } from "thirdweb/react";
|
||||
*
|
||||
* function Example() {
|
||||
* const status = useActiveWalletConnectionStatus();
|
||||
* console.log(status);
|
||||
* return <div> ... </div>;
|
||||
* }
|
||||
* ```
|
||||
* @returns The active wallet's connection status.
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useActiveWalletConnectionStatus() {
|
||||
const store = connectionManager.activeWalletConnectionStatusStore;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook that returns the active wallet's connection status.
|
||||
* @example
|
||||
* ```jsx
|
||||
* function Example() {
|
||||
* const setActive = useSetActiveWalletConnectionStatus();
|
||||
*
|
||||
* // when you want to set an account as active
|
||||
* setActive(account)
|
||||
* }
|
||||
* ```
|
||||
* @returns The active wallet's connection status.
|
||||
* @internal
|
||||
*/
|
||||
export function useSetActiveWalletConnectionStatus() {
|
||||
return connectionManager.activeWalletConnectionStatusStore.setValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* A hook to check if the auto connect is in progress.
|
||||
* @example
|
||||
* ```jsx
|
||||
* function Example() {
|
||||
* const isAutoConnecting = useIsAutoConnecting();
|
||||
*
|
||||
* return <div> ... </div>;
|
||||
* }
|
||||
* ```
|
||||
* @returns A boolean indicating if the auto connect is in progress.
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useIsAutoConnecting() {
|
||||
const store = connectionManager.isAutoConnecting;
|
||||
return useSyncExternalStore(store.subscribe, store.getValue, store.getValue);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import { isReactNative } from "../../utils/platform.js";
|
||||
import type { AsyncStorage } from "../../wallets/storage/AsyncStorage.js";
|
||||
import { asyncLocalStorage } from "../../wallets/storage/asyncLocalStorage.js";
|
||||
|
||||
let storage: AsyncStorage;
|
||||
|
||||
/**
|
||||
* Gets the storage to be used in react.
|
||||
* @example
|
||||
* ```ts
|
||||
* const storage = getStorage();
|
||||
* ```
|
||||
* @returns The storage to use
|
||||
*/
|
||||
export function getStorage(): AsyncStorage {
|
||||
if (storage) {
|
||||
return storage;
|
||||
}
|
||||
if (isReactNative()) {
|
||||
const {
|
||||
nativeLocalStorage,
|
||||
} = require("../../wallets/storage/nativeStorage.js");
|
||||
return nativeLocalStorage;
|
||||
}
|
||||
// default to localStorage
|
||||
return asyncLocalStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the storage to be used in react.
|
||||
* @example
|
||||
* ```ts
|
||||
* setStorage(storage);
|
||||
* ```
|
||||
* @param _storage - The storage to use
|
||||
*/
|
||||
export function setStorage(_storage: AsyncStorage) {
|
||||
storage = _storage;
|
||||
}
|
||||
+5
-10
@@ -1,10 +1,8 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import {
|
||||
type EstimateGasResult,
|
||||
estimateGas,
|
||||
} from "../../../../transaction/actions/estimate-gas.js";
|
||||
import type { UseMutationResult } from "@tanstack/react-query";
|
||||
import type { EstimateGasResult } from "../../../../transaction/actions/estimate-gas.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import { useActiveAccount } from "../wallets/wallet-hooks.js";
|
||||
import { useEstimateGasCore } from "../../../core/hooks/transaction/useEstimateGas.js";
|
||||
import { useActiveAccount } from "../wallets/useActiveAccount.js";
|
||||
|
||||
/**
|
||||
* A hook to estimate the gas for a given transaction.
|
||||
@@ -24,8 +22,5 @@ export function useEstimateGas(): UseMutationResult<
|
||||
PreparedTransaction
|
||||
> {
|
||||
const account = useActiveAccount();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (transaction) => estimateGas({ transaction, account }),
|
||||
});
|
||||
return useEstimateGasCore(account);
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import {
|
||||
estimateGasCost,
|
||||
} from "../../../../transaction/actions/estimate-gas-cost.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import { useActiveAccount } from "../wallets/wallet-hooks.js";
|
||||
import { useActiveAccount } from "../wallets/useActiveAccount.js";
|
||||
|
||||
/**
|
||||
* A hook to estimate the gas cost in ether and wei for a given transaction.
|
||||
+4
-15
@@ -1,8 +1,8 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import { sendAndConfirmTransaction } from "../../../../transaction/actions/send-and-confirm-transaction.js";
|
||||
import type { UseMutationResult } from "@tanstack/react-query";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import type { TransactionReceipt } from "../../../../transaction/types.js";
|
||||
import { useActiveAccount } from "../wallets/wallet-hooks.js";
|
||||
import { useSendAndConfirmTransactionCore } from "../../../core/hooks/transaction/useSendAndConfirmTransaction.js";
|
||||
import { useActiveAccount } from "../wallets/useActiveAccount.js";
|
||||
|
||||
/**
|
||||
* A hook to send a transaction.
|
||||
@@ -23,16 +23,5 @@ export function useSendAndConfirmTransaction(): UseMutationResult<
|
||||
PreparedTransaction
|
||||
> {
|
||||
const account = useActiveAccount();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (transaction) => {
|
||||
if (!account) {
|
||||
throw new Error("No active account");
|
||||
}
|
||||
return await sendAndConfirmTransaction({
|
||||
transaction,
|
||||
account,
|
||||
});
|
||||
},
|
||||
});
|
||||
return useSendAndConfirmTransactionCore(account);
|
||||
}
|
||||
+4
-15
@@ -1,8 +1,8 @@
|
||||
import { type UseMutationResult, useMutation } from "@tanstack/react-query";
|
||||
import { sendBatchTransaction } from "../../../../transaction/actions/send-batch-transaction.js";
|
||||
import type { UseMutationResult } from "@tanstack/react-query";
|
||||
import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
|
||||
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
||||
import { useActiveAccount } from "../wallets/wallet-hooks.js";
|
||||
import { useSendBatchTransactionCore } from "../../../core/hooks/transaction/useSendBatchTransaction.js";
|
||||
import { useActiveAccount } from "../wallets/useActiveAccount.js";
|
||||
|
||||
/**
|
||||
* A hook to send a transaction.
|
||||
@@ -23,16 +23,5 @@ export function useSendBatchTransaction(): UseMutationResult<
|
||||
PreparedTransaction[]
|
||||
> {
|
||||
const account = useActiveAccount();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (transactions) => {
|
||||
if (!account) {
|
||||
throw new Error("No active account");
|
||||
}
|
||||
return await sendBatchTransaction({
|
||||
transactions,
|
||||
account,
|
||||
});
|
||||
},
|
||||
});
|
||||
return useSendBatchTransactionCore(account);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
type SendTransactionConfig,
|
||||
useSendTransactionCore,
|
||||
} from "../../../core/hooks/transaction/useSendTransaction.js";
|
||||
import { useActiveWallet } from "../wallets/useActiveWallet.js";
|
||||
import { useSwitchActiveWalletChain } from "../wallets/useSwitchActiveWalletChain.js";
|
||||
|
||||
/**
|
||||
* A hook to send a transaction.
|
||||
* @returns A mutation object to send a transaction.
|
||||
* @param config Configuration for the `useSendTransaction` hook.
|
||||
* Refer to [`SendTransactionConfig`](https://portal.thirdweb.com/references/typescript/v5/SendTransactionConfig) for more details.
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useSendTransaction } from "thirdweb/react";
|
||||
* const { mutate: sendTx, data: transactionResult } = useSendTransaction();
|
||||
*
|
||||
* // later
|
||||
* sendTx(tx);
|
||||
* ```
|
||||
*
|
||||
* @transaction
|
||||
*/
|
||||
export function useSendTransaction(config: SendTransactionConfig = {}) {
|
||||
void config; // TODO native pay modal
|
||||
const wallet = useActiveWallet();
|
||||
const switchChain = useSwitchActiveWalletChain();
|
||||
return useSendTransactionCore({
|
||||
wallet,
|
||||
switchChain,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useActiveAccountCore } from "../../../core/hooks/wallets/useActiveAccount.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook that returns the active account
|
||||
* @returns The active `Account` or `undefined` if no active account is set.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useActiveAccount } from "thirdweb/react";
|
||||
*
|
||||
* const activeAccount = useActiveAccount();
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useActiveAccount() {
|
||||
return useActiveAccountCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useActiveWalletCore } from "../../../core/hooks/wallets/useActiveWallet.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook that returns the active wallet
|
||||
* @returns The active `Wallet` or `undefined` if no active wallet is set.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useActiveWallet } from "thirdweb/react";
|
||||
*
|
||||
* const wallet = useActiveWallet();
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useActiveWallet() {
|
||||
return useActiveWalletCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useActiveWalletChainCore } from "../../../core/hooks/wallets/useActiveWalletChain.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook that returns the chain the active wallet is connected to
|
||||
* @returns The chain the active wallet is connected to or null if no active wallet.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useActiveWalletChain } from "thirdweb/react";
|
||||
*
|
||||
* const chainId = useActiveWalletChain();
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useActiveWalletChain() {
|
||||
return useActiveWalletChainCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useActiveWalletConnectionStatusCore } from "../../../core/hooks/wallets/useActiveWalletConnectionStatus.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook that returns the active account's connection status.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useActiveWalletConnectionStatus } from "thirdweb/react";
|
||||
*
|
||||
* function Example() {
|
||||
* const status = useActiveWalletConnectionStatus();
|
||||
* console.log(status);
|
||||
* return <div> ... </div>;
|
||||
* }
|
||||
* ```
|
||||
* @returns The active wallet's connection status.
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useActiveWalletConnectionStatus() {
|
||||
return useActiveWalletConnectionStatusCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { nativeLocalStorage } from "../../../../utils/storage/nativeStorage.js";
|
||||
import type { AutoConnectProps } from "../../../core/hooks/connection/types.js";
|
||||
import { useAutoConnectCore } from "../../../core/hooks/wallets/useAutoConnect.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* Autoconnect the last previously connected wallet.
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useAutoConnect } from "thirdweb/react";
|
||||
*
|
||||
* const { data: autoConnected, isLoading } = useAutoConnect({
|
||||
* client,
|
||||
* accountAbstraction,
|
||||
* wallets,
|
||||
* onConnect,
|
||||
* timeout,
|
||||
* });
|
||||
* ```
|
||||
* @walletConnection
|
||||
* @param props - The props for auto connect.
|
||||
* @returns whether the auto connect was successful.
|
||||
*/
|
||||
export function useAutoConnect(props: AutoConnectProps) {
|
||||
return useAutoConnectCore(connectionManager, nativeLocalStorage, props);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import type { GetCallsStatusResponse } from "../../../../wallets/eip5792/types.js";
|
||||
import { useCallsStatusCore } from "../../../core/hooks/wallets/useCallsStatus.js";
|
||||
import { useActiveWallet } from "./useActiveWallet.js";
|
||||
|
||||
/**
|
||||
* A hook to get a call bundle's current status according to [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792).
|
||||
*
|
||||
* @note This function is dependent on the wallet's support for EIP-5792 and could throw an error if it's not supported.
|
||||
*
|
||||
* @returns a React Query object.
|
||||
* @beta
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useCallsStatus } from "thirdweb/react";
|
||||
* const { data: status, isLoading } = useCallsStatus({ bundleId, client });
|
||||
* ```
|
||||
* @extension EIP5792
|
||||
*/
|
||||
export function useCallsStatus(options: {
|
||||
bundleId: string;
|
||||
client: ThirdwebClient;
|
||||
queryOptions?: Pick<UseQueryOptions, "enabled" | "retry">;
|
||||
}): UseQueryResult<GetCallsStatusResponse> {
|
||||
const wallet = useActiveWallet();
|
||||
|
||||
return useCallsStatusCore(options, wallet);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
||||
import type { GetCapabilitiesResult } from "../../../../wallets/eip5792/get-capabilities.js";
|
||||
import { useCapabilitiesCore } from "../../../core/hooks/wallets/useCapabilities.js";
|
||||
import { useActiveWallet } from "./useActiveWallet.js";
|
||||
|
||||
/**
|
||||
* A hook to get the current wallet's capabilities according to [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792).
|
||||
*
|
||||
* @note This function is dependent on the wallet's support for EIP-5792, but will not throw.
|
||||
* **The returned object contains a `message` field detailing any issues with the wallet's support for EIP-5792.**
|
||||
*
|
||||
* @returns a React Query object.
|
||||
* @beta
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useCapabilities } from "thirdweb/react";
|
||||
* const { data: capabilities, isLoading } = useCapabilities();
|
||||
* ```
|
||||
* @extension EIP5792
|
||||
*/
|
||||
export function useCapabilities(options?: {
|
||||
queryOptions?: Pick<UseQueryOptions, "enabled" | "retry">;
|
||||
}): UseQueryResult<GetCapabilitiesResult> {
|
||||
const wallet = useActiveWallet();
|
||||
return useCapabilitiesCore(options, wallet);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { ConnectManagerOptions } from "../../../../wallets/manager/index.js";
|
||||
import { useConnectCore } from "../../../core/hooks/wallets/useConnect.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook to set a wallet as active wallet
|
||||
* @returns A function that lets you connect a wallet.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useConnect } from "thirdweb/react";
|
||||
* import { createWallet } from "thirdweb/wallets";
|
||||
*
|
||||
* function Example() {
|
||||
* const { connect, isConnecting, error } = useConnect();
|
||||
* return (
|
||||
* <button
|
||||
* onClick={() =>
|
||||
* connect(async () => {
|
||||
* // instantiate wallet
|
||||
* const wallet = createWallet("io.metamask");
|
||||
* // connect wallet
|
||||
* await wallet.connect();
|
||||
* // return the wallet
|
||||
* return wallet;
|
||||
* })
|
||||
* }
|
||||
* >
|
||||
* Connect
|
||||
* </button>
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useConnect(options?: ConnectManagerOptions) {
|
||||
return useConnectCore(connectionManager, options);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useConnectedWalletsCore } from "../../../core/hooks/wallets/useConnectedWallets.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook that returns all connected wallets
|
||||
* @returns An array of all connected wallets
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useConnectedWallets } from "thirdweb/react";
|
||||
*
|
||||
* const wallets = useConnectedWallets();
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useConnectedWallets() {
|
||||
return useConnectedWalletsCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { useDisconnectCore } from "../../../core/hooks/wallets/useDisconnect.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* Disconnect from given account
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useDisconnect, useActiveWallet } from "thirdweb/react";
|
||||
*
|
||||
* function Example() {
|
||||
* const { disconnect } = useDisconnect();
|
||||
* const wallet = useActiveWallet();
|
||||
*
|
||||
* return (
|
||||
* <button onClick={() => disconnect(wallet)}>
|
||||
* Disconnect
|
||||
* </button>
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
* @walletConnection
|
||||
* @returns An object with a function to disconnect an account
|
||||
*/
|
||||
export function useDisconnect() {
|
||||
return useDisconnectCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { useIsAutoConnectingCore } from "../../../core/hooks/wallets/useIsAutoConnecting.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook to check if the auto connect is in progress.
|
||||
* @example
|
||||
* ```jsx
|
||||
* function Example() {
|
||||
* const isAutoConnecting = useIsAutoConnecting();
|
||||
*
|
||||
* return <div> ... </div>;
|
||||
* }
|
||||
* ```
|
||||
* @returns A boolean indicating if the auto connect is in progress.
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useIsAutoConnecting() {
|
||||
return useIsAutoConnectingCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import type { UseMutationResult } from "@tanstack/react-query";
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import {
|
||||
type SendCallsOptions,
|
||||
sendCalls,
|
||||
} from "../../../../wallets/eip5792/send-calls.js";
|
||||
import type {
|
||||
GetCallsStatusResponse,
|
||||
WalletSendCallsId,
|
||||
} from "../../../../wallets/eip5792/types.js";
|
||||
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
||||
import { useSendCallsCore } from "../../../core/hooks/wallets/useSendCalls.js";
|
||||
import { useActiveWallet } from "./useActiveWallet.js";
|
||||
|
||||
/**
|
||||
* A hook to send [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792) calls to a wallet.
|
||||
* This hook works with all Thirdweb wallets (in-app and smart) and certain injected wallets that already support EIP-5792.
|
||||
* Transactions will be bundled and sponsored when those capabilities are supported, otherwise they will be sent as individual transactions.
|
||||
*
|
||||
* When calls are sent, all contracts that are interacted with will have their corresponding reads revalidated via React Query.
|
||||
*
|
||||
* @note This hook is dependent on the wallet's support for EIP-5792 and could fail.
|
||||
* @note The mutatuon function will use your currently connected wallet by default, but you can pass it a specific wallet to use if you'd like.
|
||||
*
|
||||
* @returns A React Query mutatuon object to interact with {@link sendCalls}
|
||||
* @throws an error if the wallet does not support EIP-5792.
|
||||
* @returns The ID of the bundle of the calls.
|
||||
*
|
||||
* @beta
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { useSendCalls } from "thirdweb/react";
|
||||
*
|
||||
* const sendTx1 = approve({
|
||||
contract: USDT_CONTRACT,
|
||||
amount: 100,
|
||||
spender: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
|
||||
});
|
||||
* const sendTx2 = approve({
|
||||
contract: USDT_CONTRACT,
|
||||
amount: 100,
|
||||
spender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
||||
});
|
||||
* const { mutate: sendCalls, data: bundleId } = useSendCalls({ client });
|
||||
* await sendCalls({
|
||||
* wallet,
|
||||
* client,
|
||||
* calls: [sendTx1, sendTx2],
|
||||
* });
|
||||
* ```
|
||||
* Await the bundle's full confirmation:
|
||||
* ```tsx
|
||||
* const { mutate: sendCalls, data: bundleId } = useSendCalls({ client, waitForResult: true });
|
||||
* await sendCalls({
|
||||
* wallet,
|
||||
* client,
|
||||
* calls: [sendTx1, sendTx2],
|
||||
* });
|
||||
* ```
|
||||
* Sponsor transactions with a paymaster:
|
||||
* ```ts
|
||||
* const { mutate: sendCalls, data: bundleId } = useSendCalls();
|
||||
* await sendCalls({
|
||||
* client,
|
||||
* calls: [sendTx1, sendTx2],
|
||||
* capabilities: {
|
||||
* paymasterService: {
|
||||
* url: `https://${CHAIN.id}.bundler.thirdweb.com/${client.clientId}`
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
* @note We recommend proxying any paymaster calls via an API route you setup and control.
|
||||
* ```
|
||||
* @extension EIP5792
|
||||
*/
|
||||
export function useSendCalls({
|
||||
client,
|
||||
waitForResult = true,
|
||||
}: { client: ThirdwebClient; waitForResult?: boolean }): UseMutationResult<
|
||||
GetCallsStatusResponse | WalletSendCallsId,
|
||||
Error,
|
||||
Omit<SendCallsOptions, "chain" | "wallet"> & { wallet?: Wallet } // Optional wallet override
|
||||
> {
|
||||
const wallet = useActiveWallet();
|
||||
return useSendCallsCore({ client, waitForResult }, wallet);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { useSetActiveWalletCore } from "../../../core/hooks/wallets/useSetActiveWallet.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook that lets you set the active wallet.
|
||||
* @returns A function that lets you set the active wallet.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useSetActiveWallet } from "thirdweb/react";
|
||||
*
|
||||
* const setActiveAccount = useSetActiveWallet();
|
||||
*
|
||||
* // later in your code
|
||||
* await setActiveAccount(account);
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useSetActiveWallet() {
|
||||
return useSetActiveWalletCore(connectionManager);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { useSetActiveWalletConnectionStatusCore } from "../../../core/hooks/wallets/useSetActiveWalletConnectionStatus.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* A hook that returns the active wallet's connection status.
|
||||
* @example
|
||||
* ```jsx
|
||||
* function Example() {
|
||||
* const setActiveStatus = useSetActiveWalletConnectionStatus();
|
||||
*
|
||||
* // when you want to set the connection status of the wallet
|
||||
* setActiveStatus(status)
|
||||
* }
|
||||
* ```
|
||||
* @returns The active wallet's connection status.
|
||||
* @internal
|
||||
*/
|
||||
export function useSetActiveWalletConnectionStatus() {
|
||||
return useSetActiveWalletConnectionStatusCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useSwitchActiveWalletChainCore } from "../../../core/hooks/wallets/useSwitchActiveWalletChain.js";
|
||||
import { connectionManager } from "../../index.js";
|
||||
|
||||
/**
|
||||
* Switch to blockchain with given chain id in the active wallet.
|
||||
* @returns A function to switch to blockchain with given chain id in the active wallet.
|
||||
* @example
|
||||
* ```jsx
|
||||
* import { useSwitchActiveWalletChain } from "thirdweb/react";
|
||||
* import { sepolia } from "thirdweb/chains";
|
||||
*
|
||||
* const switchChain = useSwitchActiveWalletChain();
|
||||
*
|
||||
* // later in your code
|
||||
* <button onClick={() => switchChain(sepolia)}>Switch Chain</button>
|
||||
* ```
|
||||
* @walletConnection
|
||||
*/
|
||||
export function useSwitchActiveWalletChain() {
|
||||
return useSwitchActiveWalletChainCore(connectionManager);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { nativeLocalStorage } from "../../utils/storage/nativeStorage.js";
|
||||
import { connectionManagerSingleton } from "../core/connectionManager.js";
|
||||
|
||||
export const connectionManager = connectionManagerSingleton(nativeLocalStorage);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user