Compare commits

..
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
a4339818a0 Version Packages (#1998)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-01 06:55:35 -08:00
Manan TankandGitHub b3394277c7 [react] JSDoc improvements (#1987) 2023-12-01 13:13:30 +00:00
Manan TankandGitHub fdf19b0a26 [react] Do not swallow error in useEmbeddedWallet() connect (#2031) 2023-12-01 12:42:39 +00:00
FirekeeperandGitHub 9798a31a9a [Unity] Pass down authOptions with smart wallet connections (#2026) 2023-11-30 00:59:22 +00:00
Kien NgoandGitHub f93bd325e1 [Storage] Catch error when converting invalid IPFS URIs (#2021) 2023-11-29 21:35:50 +00:00
iketwandGitHub 97ba1fbd42 [RN] Adds version header to ews calls (#2025) 2023-11-29 20:43:35 +00:00
Kien NgoandGitHub 28fc3736aa [storage] Add Base Sepolia to defaultChains (#2024) 2023-11-29 20:02:58 +00:00
Kien NgoandGitHub 06805217c2 [chains] Add Eth Sepolia to defaultChains (#2023) 2023-11-29 15:24:54 +00:00
Jonas DanielsandGitHub b833250053 chore(chains): add & update chains (#2019) 2023-11-28 22:07:14 +00:00
iketwandGitHub 9455912932 [ReactCore] Share WalletConnecthandler in react core (#2016) 2023-11-28 16:00:48 +00:00
Manan TankandGitHub 4c488aa31f [react-core] Fix auto-connecting a personal wallet for smart/safe wallet (#2015) 2023-11-28 12:17:28 +00:00
Joaquim VergesandGitHub b0ecfd2d8d [SDK] propagate isPartialABI (#2012) 2023-11-27 20:30:32 +00:00
2b4f1c8e55 [wallet, react] Add Crypto.com Defi wallet (#1928)
Co-authored-by: Manan Tank <[email protected]>
2023-11-27 15:16:30 +00:00
e79b293562 [react-core] Add hook: useBalanceForAddress (#2007)
Co-authored-by: Manan Tank <[email protected]>
2023-11-27 14:43:32 +00:00
Joaquim VergesandGitHub 2861dff1f0 [SDK] dont fetch metadata from CDN for local nodes (#2011) 2023-11-27 06:02:33 +00:00
Kien NgoandGitHub 61b6a00214 Fix typo in comment (#2010) 2023-11-27 05:35:30 +00:00
Joaquim VergesandGitHub b02fb91a54 [SDK] Add missing roles from new contracts (#2009) 2023-11-26 04:51:52 +00:00
Joaquim VergesandGitHub 8bf3be88be [SDK] Enable deployments for older AccountFactory contracts (#2005) 2023-11-24 23:02:15 +00:00
Joaquim VergesandGitHub fb5095bff5 [SDK] Handle other possible undefined cases for unknown chains (#2004) 2023-11-23 21:24:05 +00:00
Joaquim VergesandGitHub d28097f508 [SDK] Fix undefined error for unknow chains (#2003) 2023-11-23 17:31:11 +00:00
iketwandGitHub a27b10c5c3 [React] Do not set disconnected if connecting (#2001) 2023-11-23 16:12:39 +00:00
8c2d4e5ea7 [wallet, react] Add Rabby wallet (browser extension) (#1926)
Co-authored-by: Manan Tank <[email protected]>
2023-11-22 18:33:15 +00:00
Manan TankandGitHub 507496627b [react] Fix SmartWallet + MagicLink social login connection, Fix WalletIcon in CW (#1997) 2023-11-22 18:14:30 +00:00
146 changed files with 2628 additions and 457 deletions
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/auth
## 4.1.13
### Patch Changes
- Updated dependencies [[`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c)]:
- @thirdweb-dev/wallets@2.1.10
## 4.1.12
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "4.1.12",
"version": "4.1.13",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/chains
## 0.1.60
### Patch Changes
- [#2019](https://github.com/thirdweb-dev/js/pull/2019) [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a) Thanks [@jnsdls](https://github.com/jnsdls)! - add & update chains
- [#2024](https://github.com/thirdweb-dev/js/pull/2024) [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Base Sepolia to defaultChains
- [#2023](https://github.com/thirdweb-dev/js/pull/2023) [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Eth Sepolia to defaultChains
## 0.1.59
### Patch Changes
+37
View File
@@ -0,0 +1,37 @@
import type { Chain } from "../src/types";
export default {
"chain": "parallel-stormy-spica",
"chainId": 1350216234,
"explorers": [
{
"name": "Blockscout",
"url": "https://parallel-stormy-spica.explorer.mainnet.skalenodes.com",
"standard": "EIP3091"
}
],
"faucets": [
"https://sfuel.skale.network/"
],
"icon": {
"url": "ipfs://bafkreiagrt5dhgltg2kmw7hf24kslstr5h42e745luuxwp2wbg24gm6zza",
"width": 500,
"height": 500,
"format": "png"
},
"name": "SKALE Titan Hub",
"nativeCurrency": {
"name": "sFUEL",
"symbol": "sFUEL",
"decimals": 18
},
"networkId": 1350216234,
"rpc": [
"https://skale-titan-hub.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://1350216234.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet.skalenodes.com/v1/parallel-stormy-spica",
"wss://mainnet.skalenodes.com/v1/ws/parallel-stormy-spica"
],
"shortName": "titan-mainnet",
"slug": "skale-titan-hub",
"testnet": false
} as const satisfies Chain;
+14 -12
View File
@@ -4,20 +4,22 @@ export default {
"chainId": 1482601649,
"explorers": [
{
"name": "nebula",
"name": "Blockscout",
"url": "https://green-giddy-denebola.explorer.mainnet.skalenodes.com",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmfQkfmQuoUUUKwF1yCcrPEzFcWLaqNyiSv5YMcSj6zs74",
"width": 500,
"height": 500,
"format": "png"
}
"standard": "EIP3091"
}
],
"faucets": [],
"faucets": [
"https://sfuel.skale.network/"
],
"icon": {
"url": "ipfs://bafybeic5eexvd34wfy4kuebcyu73qpkv3x57s54ebzjyhyjsmeuni5jwcm",
"width": 500,
"height": 500,
"format": "png"
},
"infoURL": "https://nebulachain.io/",
"name": "Nebula Mainnet",
"name": "SKALE Nebula Hub",
"nativeCurrency": {
"name": "sFUEL",
"symbol": "sFUEL",
@@ -25,12 +27,12 @@ export default {
},
"networkId": 1482601649,
"rpc": [
"https://nebula.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://skale-nebula-hub.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://1482601649.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet.skalenodes.com/v1/green-giddy-denebola",
"wss://mainnet-proxy.skalenodes.com/v1/ws/green-giddy-denebola"
],
"shortName": "nebula-mainnet",
"slug": "nebula",
"slug": "skale-nebula-hub",
"testnet": false
} as const satisfies Chain;
+37
View File
@@ -0,0 +1,37 @@
import type { Chain } from "../src/types";
export default {
"chain": "staging-aware-chief-gianfar",
"chainId": 1517929550,
"explorers": [
{
"name": "Blockscout",
"url": "https://staging-aware-chief-gianfar.explorer.staging-v3.skalenodes.com",
"standard": "EIP3091"
}
],
"faucets": [
"https://sfuel.dirtroad.dev/staging"
],
"icon": {
"url": "ipfs://bafkreiagrt5dhgltg2kmw7hf24kslstr5h42e745luuxwp2wbg24gm6zza",
"width": 500,
"height": 500,
"format": "png"
},
"name": "SKALE Titan Hub Testnet",
"nativeCurrency": {
"name": "sFUEL",
"symbol": "sFUEL",
"decimals": 18
},
"networkId": 1517929550,
"rpc": [
"https://skale-titan-hub-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://1517929550.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://staging-v3.skalenodes.com/v1/staging-aware-chief-gianfar",
"wss://staging-v3.skalenodes.com/v1/ws/staging-aware-chief-gianfar"
],
"shortName": "titan-testnet",
"slug": "skale-titan-hub-testnet",
"testnet": true
} as const satisfies Chain;
+31
View File
@@ -0,0 +1,31 @@
import type { Chain } from "../src/types";
export default {
"chain": "Avalanche",
"chainId": 15535,
"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": "QI M 11271",
"nativeCurrency": {
"name": "QI M 11271 Token",
"symbol": "JZW",
"decimals": 18
},
"networkId": 15535,
"redFlags": [],
"rpc": [
"https://qi-m-11271.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://15535.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avacloud-dev.io/a47e1c06-fa75-4536-a900-1574d198e197"
],
"shortName": "QI M 11271",
"slug": "qi-m-11271",
"testnet": true
} as const satisfies Chain;
+11 -12
View File
@@ -6,20 +6,20 @@ export default {
{
"name": "Blockscout",
"url": "https://honorable-steel-rasalhague.explorer.mainnet.skalenodes.com",
"standard": "EIP3091",
"icon": {
"url": "ipfs://bafybeigyayzxvt7vosat4rtrbmhhnldgx57w2pfbutuniax7h6kswzi42m",
"width": 1637,
"height": 1636,
"format": "png"
}
"standard": "EIP3091"
}
],
"faucets": [
"https://sfuel.dirtroad.dev"
],
"icon": {
"url": "ipfs://bafybeigyayzxvt7vosat4rtrbmhhnldgx57w2pfbutuniax7h6kswzi42m",
"width": 1637,
"height": 1636,
"format": "png"
},
"infoURL": "https://calypsohub.network/",
"name": "Calypso NFT Hub (SKALE)",
"name": "SKALE Calypso Hub",
"nativeCurrency": {
"name": "sFUEL",
"symbol": "sFUEL",
@@ -27,12 +27,11 @@ export default {
},
"networkId": 1564830818,
"rpc": [
"https://calypso-nft-hub-skale.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://skale-calypso-hub.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://1564830818.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet.skalenodes.com/v1/honorable-steel-rasalhague"
],
"shortName": "calypso-mainnet",
"slug": "calypso-nft-hub-skale",
"testnet": false,
"title": "Calypso NFT Hub Mainnet"
"slug": "skale-calypso-hub",
"testnet": false
} as const satisfies Chain;
+16 -23
View File
@@ -1,35 +1,28 @@
import type { Chain } from "../src/types";
export default {
"chain": "Yuma",
"chain": "LQC",
"chainId": 1662,
"explorers": [],
"faucets": [],
"features": [
"explorers": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
"name": "Liquichain Mainnet",
"url": "https://mainnet.liquichain.io",
"standard": "EIP3091"
}
],
"icon": {
"url": "ipfs://QmSFMBk3rMyu45Sy9KQHjgArFj4HdywANNYrSosLMUdcti",
"width": 1213,
"height": 1213,
"format": "png"
},
"infoURL": "https://horizen.io/",
"name": "Horizen Yuma Testnet Deprecated",
"faucets": [],
"infoURL": "https://liquichain.io/",
"name": "Liquichain",
"nativeCurrency": {
"name": "Testnet Zen",
"symbol": "tZEN",
"name": "Licoin",
"symbol": "LCN",
"decimals": 18
},
"networkId": 1662,
"redFlags": [
"reusedChainId"
],
"rpc": [],
"shortName": "Yuma",
"slip44": 121,
"slug": "horizen-yuma-testnet-deprecated",
"status": "deprecated",
"testnet": true
"shortName": "Liquichain",
"slug": "liquichain",
"testnet": false
} as const satisfies Chain;
+2 -1
View File
@@ -67,5 +67,6 @@ export default {
"shortName": "holesky",
"slug": "holesky",
"status": "incubating",
"testnet": true
"testnet": true,
"title": "Ethereum Testnet Holesky"
} as const satisfies Chain;
+41
View File
@@ -0,0 +1,41 @@
import type { Chain } from "../src/types";
export default {
"chain": "ETH",
"chainId": 17001,
"explorers": [
{
"name": "Redstone Holesky Explorer",
"url": "https://explorer.holesky.redstone.xyz",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmdwQDr6vmBtXmK2TmknkEuZNoaDqTasFdZdu3DRw8b2wt",
"width": 1000,
"height": 1628,
"format": "png"
}
}
],
"faucets": [],
"icon": {
"url": "ipfs://bafkreieyaqgkgntvxuo5tnhgseladga5q6gutc37dab7kqqfdguhq7vkxq",
"width": 5836,
"height": 5836,
"format": "png"
},
"infoURL": "https://redstone.xyz/docs/network-info",
"name": "Redstone Holesky Testnet",
"nativeCurrency": {
"name": "Redstone Testnet Ether",
"symbol": "ETH",
"decimals": 18
},
"networkId": 17001,
"rpc": [
"https://redstone-holesky-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://17001.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.holesky.redstone.xyz"
],
"shortName": "redstone",
"slug": "redstone-holesky-testnet",
"testnet": true
} as const satisfies Chain;
+2 -1
View File
@@ -29,7 +29,8 @@ export default {
"rpc": [
"https://z-mainnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://2016.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet-rpc.mainnetz.io"
"https://mainnet-rpc.mainnetz.io",
"https://eu-rpc.mainnetz.io"
],
"shortName": "NetZm",
"slug": "z-mainnet",
+3 -3
View File
@@ -20,7 +20,7 @@ export default {
"format": "png"
},
"infoURL": "https://europahub.network/",
"name": "Europa SKALE Chain",
"name": "SKALE Europa Hub",
"nativeCurrency": {
"name": "sFUEL",
"symbol": "sFUEL",
@@ -37,12 +37,12 @@ export default {
]
},
"rpc": [
"https://europa-skale-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://skale-europa-hub.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://2046399126.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet.skalenodes.com/v1/elated-tan-skat",
"wss://mainnet.skalenodes.com/v1/elated-tan-skat"
],
"shortName": "europa",
"slug": "europa-skale-chain",
"slug": "skale-europa-hub",
"testnet": false
} as const satisfies Chain;
+13
View File
@@ -13,9 +13,21 @@ export default {
"height": 540,
"format": "png"
}
},
{
"name": "etherscan",
"url": "https://kromascan.com/",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM",
"width": 551,
"height": 540,
"format": "png"
}
}
],
"faucets": [],
"features": [],
"icon": {
"url": "ipfs://QmVpV2WET6ZrqnvvPfE9hCwoE2y5ygbPuniuugpaRoxrho",
"width": 320,
@@ -39,6 +51,7 @@ export default {
}
]
},
"redFlags": [],
"rpc": [
"https://kroma.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://255.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
+2 -2
View File
@@ -6,8 +6,8 @@ export default {
"faucets": [],
"name": "DPU Chain",
"nativeCurrency": {
"name": "DGS",
"symbol": "DGS",
"name": "DGC",
"symbol": "DGC",
"decimals": 18
},
"networkId": 2611555,
+43
View File
@@ -0,0 +1,43 @@
import type { Chain } from "../src/types";
export default {
"chain": "K-LAOS",
"chainId": 2718,
"explorers": [
{
"name": "blockscout",
"url": "https://blockscout.klaos.laosfoundation.io",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmW26eoxJeyUfikZ4DUT1Gfk78sBkvydEo8QzHa1BXjUUL",
"width": 580,
"height": 580,
"format": "png"
}
}
],
"faucets": [],
"icon": {
"url": "ipfs://QmW26eoxJeyUfikZ4DUT1Gfk78sBkvydEo8QzHa1BXjUUL",
"width": 580,
"height": 580,
"format": "png"
},
"infoURL": "https://www.laosfoundation.io/",
"name": "K-LAOS",
"nativeCurrency": {
"name": "KLAOS",
"symbol": "KLAOS",
"decimals": 18
},
"networkId": 2718,
"rpc": [
"https://k-laos.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://2718.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.klaos.laosfoundation.io",
"wss://rpc.klaos.laosfoundation.io"
],
"shortName": "k-laos",
"slug": "k-laos",
"testnet": false,
"title": "K-LAOS: LAOS on Kusama"
} as const satisfies Chain;
+2 -2
View File
@@ -5,8 +5,8 @@ export default {
"explorers": [
{
"name": "HashScan",
"url": "https://hashscan.io/mainnet/dashboard",
"standard": "none"
"url": "https://hashscan.io/mainnet",
"standard": "EIP3091"
},
{
"name": "Arkhia Explorer",
+2 -2
View File
@@ -5,8 +5,8 @@ export default {
"explorers": [
{
"name": "HashScan",
"url": "https://hashscan.io/testnet/dashboard",
"standard": "none"
"url": "https://hashscan.io/testnet",
"standard": "EIP3091"
},
{
"name": "Arkhia Explorer",
+2 -2
View File
@@ -5,8 +5,8 @@ export default {
"explorers": [
{
"name": "HashScan",
"url": "https://hashscan.io/previewnet/dashboard",
"standard": "none"
"url": "https://hashscan.io/previewnet",
"standard": "EIP3091"
}
],
"faucets": [
+10 -10
View File
@@ -6,20 +6,20 @@ export default {
{
"name": "Blockscout",
"url": "https://staging-utter-unripe-menkar.explorer.staging-v3.skalenodes.com",
"standard": "EIP3091",
"icon": {
"url": "ipfs://bafybeigyayzxvt7vosat4rtrbmhhnldgx57w2pfbutuniax7h6kswzi42m",
"width": 1637,
"height": 1636,
"format": "png"
}
"standard": "EIP3091"
}
],
"faucets": [
"https://sfuel.dirtroad.dev/staging"
],
"icon": {
"url": "ipfs://bafybeigyayzxvt7vosat4rtrbmhhnldgx57w2pfbutuniax7h6kswzi42m",
"width": 1637,
"height": 1636,
"format": "png"
},
"infoURL": "https://calypsohub.network/",
"name": "Calypso NFT Hub (SKALE Testnet)",
"name": "SKALE Calypso Hub Testnet",
"nativeCurrency": {
"name": "sFUEL",
"symbol": "sFUEL",
@@ -27,12 +27,12 @@ export default {
},
"networkId": 344106930,
"rpc": [
"https://calypso-nft-hub-skale-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://skale-calypso-hub-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://344106930.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://staging-v3.skalenodes.com/v1/staging-utter-unripe-menkar"
],
"shortName": "calypso-testnet",
"slug": "calypso-nft-hub-skale-testnet",
"slug": "skale-calypso-hub-testnet",
"testnet": true,
"title": "Calypso NFT Hub Testnet"
} as const satisfies Chain;
+7 -1
View File
@@ -4,6 +4,12 @@ export default {
"chainId": 363636,
"explorers": [],
"faucets": [],
"icon": {
"url": "ipfs://QmRiAUu3xV5uiX6Nk1iXD5w6qjki5ugGFETRVavzJ2h5QF",
"width": 370,
"height": 320,
"format": "png"
},
"name": "Digit Soul Smart Chain 2",
"nativeCurrency": {
"name": "Digit Coin",
@@ -14,7 +20,7 @@ export default {
"rpc": [
"https://digit-soul-smart-chain-2.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://363636.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"http://dgs-rpc.digitsoul.co.th"
"https://dgs-rpc.digitsoul.co.th"
],
"shortName": "DS2",
"slug": "digit-soul-smart-chain-2",
+1 -3
View File
@@ -38,14 +38,12 @@ export default {
"rpc": [
"https://arbitrum-goerli.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://421613.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://arbitrum-goerli.infura.io/v3/${INFURA_API_KEY}",
"https://arb-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY}",
"https://goerli-rollup.arbitrum.io/rpc",
"https://arbitrum-goerli.publicnode.com",
"wss://arbitrum-goerli.publicnode.com"
],
"shortName": "arb-goerli",
"slug": "arbitrum-goerli",
"testnet": false,
"testnet": true,
"title": "Arbitrum Goerli Rollup Testnet"
} as const satisfies Chain;
+35
View File
@@ -0,0 +1,35 @@
import type { Chain } from "../src/types";
export default {
"chain": "Geso Verse",
"chainId": 428,
"explorers": [
{
"name": "Geso Verse Explorer",
"url": "https://explorer.verse.gesoten.com",
"standard": "EIP3091"
}
],
"faucets": [],
"icon": {
"url": "ipfs://Qmb7oJY9zd9sTzxNNQNTVZQz2hkd1aA94mWm4cvXfJ9QxV",
"width": 1280,
"height": 1280,
"format": "png"
},
"infoURL": "https://gesoten.com/",
"name": "Geso Verse",
"nativeCurrency": {
"name": "OAS",
"symbol": "OAS",
"decimals": 18
},
"networkId": 428,
"rpc": [
"https://geso-verse.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://428.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.verse.gesoten.com/"
],
"shortName": "GSV",
"slug": "geso-verse",
"testnet": false
} as const satisfies Chain;
+38
View File
@@ -0,0 +1,38 @@
import type { Chain } from "../src/types";
export default {
"chain": "staging-legal-crazy-castor",
"chainId": 476158412,
"explorers": [
{
"name": "Blockscout",
"url": "https://staging-legal-crazy-castor.explorer.staging-v3.skalenodes.com",
"standard": "EIP3091"
}
],
"faucets": [
"https://sfuel.dirtroad.dev/staging"
],
"icon": {
"url": "ipfs://bafkreiezcwowhm6xjrkt44cmiu6ml36rhrxx3amcg3cfkcntv2vgcvgbre",
"width": 600,
"height": 600,
"format": "png"
},
"infoURL": "https://europahub.network/",
"name": "SKALE Europa Hub Testnet",
"nativeCurrency": {
"name": "sFUEL",
"symbol": "sFUEL",
"decimals": 18
},
"networkId": 476158412,
"rpc": [
"https://skale-europa-hub-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://476158412.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://staging-v3.skalenodes.com/v1/staging-legal-crazy-castor"
],
"shortName": "europa-testnet",
"slug": "skale-europa-hub-testnet",
"testnet": true,
"title": "Europa Hub Testnet"
} as const satisfies Chain;
+16 -14
View File
@@ -4,20 +4,22 @@ export default {
"chainId": 503129905,
"explorers": [
{
"name": "nebula",
"name": "Blockscout",
"url": "https://staging-faint-slimy-achird.explorer.staging-v3.skalenodes.com",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmfQkfmQuoUUUKwF1yCcrPEzFcWLaqNyiSv5YMcSj6zs74",
"width": 500,
"height": 500,
"format": "png"
}
"standard": "EIP3091"
}
],
"faucets": [],
"faucets": [
"https://sfuel.dirtroad.dev/staging"
],
"icon": {
"url": "ipfs://bafybeic5eexvd34wfy4kuebcyu73qpkv3x57s54ebzjyhyjsmeuni5jwcm",
"width": 500,
"height": 500,
"format": "png"
},
"infoURL": "https://nebulachain.io/",
"name": "Nebula Staging",
"name": "SKALE Nebula Hub Testnet",
"nativeCurrency": {
"name": "sFUEL",
"symbol": "sFUEL",
@@ -25,12 +27,12 @@ export default {
},
"networkId": 503129905,
"rpc": [
"https://nebula-staging.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://skale-nebula-hub-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://503129905.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://staging-v3.skalenodes.com/v1/staging-faint-slimy-achird",
"wss://staging-v3.skalenodes.com/v1/ws/staging-faint-slimy-achird"
],
"shortName": "nebula-staging",
"slug": "nebula-staging",
"testnet": false
"shortName": "nebula-testnet",
"slug": "skale-nebula-hub-testnet",
"testnet": true
} as const satisfies Chain;
-1
View File
@@ -24,7 +24,6 @@ export default {
"https://rollux.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://570.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.rollux.com",
"https://rollux.public-rpc.com",
"wss://rpc.rollux.com/wss"
],
"shortName": "sys-rollux",
+2 -1
View File
@@ -47,6 +47,7 @@ export default {
}
]
},
"redFlags": [],
"rpc": [
"https://sepolia-pgn-public-goods-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://58008.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
@@ -54,5 +55,5 @@ export default {
],
"shortName": "sepPGN",
"slug": "sepolia-pgn-public-goods-network",
"testnet": false
"testnet": true
} as const satisfies Chain;
+7 -1
View File
@@ -4,6 +4,12 @@ export default {
"chainId": 6363,
"explorers": [],
"faucets": [],
"icon": {
"url": "ipfs://QmRiAUu3xV5uiX6Nk1iXD5w6qjki5ugGFETRVavzJ2h5QF",
"width": 370,
"height": 320,
"format": "png"
},
"name": "Digit Soul Smart Chain",
"nativeCurrency": {
"name": "Digit Coin",
@@ -14,7 +20,7 @@ export default {
"rpc": [
"https://digit-soul-smart-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://6363.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"http://dsc-rpc.digitsoul.co.th"
"https://dsc-rpc.digitsoul.co.th"
],
"shortName": "DGS",
"slug": "digit-soul-smart-chain",
+38
View File
@@ -0,0 +1,38 @@
import type { Chain } from "../src/types";
export default {
"chain": "MaalChain Testnet",
"chainId": 7860,
"explorers": [
{
"name": "maalscan testnet",
"url": "https://testnet.maalscan.io",
"standard": "EIP3091"
}
],
"faucets": [
"https://faucet-testnet.maalscan.io/"
],
"icon": {
"url": "ipfs://bafkreiexfqfe2x4impvwhra3xxa5eb25gv25zi3kkaoatdnld7wbxdzf2a",
"width": 512,
"height": 512,
"format": "png"
},
"infoURL": "https://www.maalchain.com/",
"name": "MaalChain Testnet",
"nativeCurrency": {
"name": "MAAL",
"symbol": "MAAL",
"decimals": 18
},
"networkId": 7860,
"rpc": [
"https://maalchain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://7860.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://node1.maalscan.io/",
"https://rpc-bntest.maalscan.io/"
],
"shortName": "maal-test",
"slug": "maalchain-testnet",
"testnet": true
} as const satisfies Chain;
+14 -1
View File
@@ -13,16 +13,28 @@ export default {
"height": 512,
"format": "png"
}
},
{
"name": "DOScan",
"url": "https://explorer.doschain.com/",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmV2Nowzo81F6pi2qFcHePA4MwmmdMKBMUzBJUrxcymxx4",
"width": 512,
"height": 512,
"format": "png"
}
}
],
"faucets": [],
"features": [],
"icon": {
"url": "ipfs://QmV2Nowzo81F6pi2qFcHePA4MwmmdMKBMUzBJUrxcymxx4",
"width": 512,
"height": 512,
"format": "png"
},
"infoURL": "https://doschain.io",
"infoURL": "https://doschain.com/",
"name": "DOS Chain",
"nativeCurrency": {
"name": "DOS",
@@ -30,6 +42,7 @@ export default {
"decimals": 18
},
"networkId": 7979,
"redFlags": [],
"rpc": [
"https://dos-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://7979.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
+41
View File
@@ -0,0 +1,41 @@
import type { Chain } from "../src/types";
export default {
"chain": "TQF",
"chainId": 8192,
"explorers": [
{
"name": "blockscout",
"url": "https://toruscan.com",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM",
"width": 551,
"height": 540,
"format": "png"
}
}
],
"faucets": [],
"icon": {
"url": "ipfs://bafkreidchntjaxmq52cuqqoalpajk5ssk4p77k7n4jgywqmkpldo5qgobm",
"width": 1200,
"height": 1200,
"format": "png"
},
"infoURL": "https://docs.toruschain.com",
"name": "Torus Mainnet",
"nativeCurrency": {
"name": "TQF",
"symbol": "TQF",
"decimals": 18
},
"networkId": 8192,
"rpc": [
"https://torus.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://8192.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.toruschain.com"
],
"shortName": "tqf",
"slug": "torus",
"testnet": false
} as const satisfies Chain;
+13 -1
View File
@@ -6,10 +6,22 @@ export default {
{
"name": "Dodao Explorer",
"url": "https://tanssi-evmexplorer.netlify.app/?rpcUrl=https://fraa-dancebox-3041-rpc.a.dancebox.tanssi.network",
"standard": "none"
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmdWsi6mhs6Agb3LF4uycUwx2fgNmwkuAGb7JmsLPkwd3j",
"width": 636,
"height": 629,
"format": "png"
}
}
],
"faucets": [],
"icon": {
"url": "ipfs://QmdWsi6mhs6Agb3LF4uycUwx2fgNmwkuAGb7JmsLPkwd3j",
"width": 636,
"height": 629,
"format": "png"
},
"infoURL": "https://dodao.dev/",
"name": "Dodao",
"nativeCurrency": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/chains",
"version": "0.1.59",
"version": "0.1.60",
"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
+11
View File
@@ -1,5 +1,16 @@
# thirdweb
## 0.13.21
### Patch Changes
- Updated dependencies [[`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c)]:
- @thirdweb-dev/wallets@2.1.10
- @thirdweb-dev/sdk@4.0.18
- @thirdweb-dev/chains@0.1.60
- @thirdweb-dev/storage@2.0.6
- @thirdweb-dev/auth@4.1.13
## 0.13.20
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.13.20",
"version": "0.13.21",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+35
View File
@@ -1,5 +1,40 @@
# @thirdweb-dev/react-core
## 4.1.11
### Patch Changes
- [#2007](https://github.com/thirdweb-dev/js/pull/2007) [`e79b2935`](https://github.com/thirdweb-dev/js/commit/e79b293562bbcf4af6fbcb4829b2acb4cb3e2cb4) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Get the native token balance of a wallet address on the `activeChain` network set in the `ThirdwebProvider`
```ts
const balanceQuery = useBalanceForAddress(walletAddress);
console.log(balanceQuery.data);
```
- [#1926](https://github.com/thirdweb-dev/js/pull/1926) [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Rabby browser extension
- [#2001](https://github.com/thirdweb-dev/js/pull/2001) [`a27b10c5`](https://github.com/thirdweb-dev/js/commit/a27b10c5c3400500ef0138069acc550b3a07ffc6) Thanks [@iketw](https://github.com/iketw)! - Don't disconnect wallet if connecting
- [#2016](https://github.com/thirdweb-dev/js/pull/2016) [`94559129`](https://github.com/thirdweb-dev/js/commit/9455912932c71f3ef9b67461bf5604f1ea1f71e8) Thanks [@iketw](https://github.com/iketw)! - Share WalletConnectHandler between React and RN to support wallets as receivers
- [#1997](https://github.com/thirdweb-dev/js/pull/1997) [`50749662`](https://github.com/thirdweb-dev/js/commit/507496627bcd77b49bb027b24996a31c57e04819) Thanks [@MananTank](https://github.com/MananTank)! - - Fixes issue #1708
- Fixes smart wallet icon shown even after clicking on "Switch to Personal wallet" in ConnectWallet dropdown
- [#1987](https://github.com/thirdweb-dev/js/pull/1987) [`b3394277`](https://github.com/thirdweb-dev/js/commit/b3394277c77e4af130151111e056e27a28ac893a) Thanks [@MananTank](https://github.com/MananTank)! - Improved JSDoc comments and type exports
- [#1928](https://github.com/thirdweb-dev/js/pull/1928) [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Crypto.com Defi wallet
- [#2015](https://github.com/thirdweb-dev/js/pull/2015) [`4c488aa3`](https://github.com/thirdweb-dev/js/commit/4c488aa31f6fadc13759ff60f30230b929feb314) Thanks [@MananTank](https://github.com/MananTank)! - Fix auto-connecting a personal wallet for smart/safe wallet
- Updated dependencies [[`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c)]:
- @thirdweb-dev/wallets@2.1.10
- @thirdweb-dev/sdk@4.0.18
- @thirdweb-dev/chains@0.1.60
- @thirdweb-dev/storage@2.0.6
- @thirdweb-dev/auth@4.1.13
## 4.1.10
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "4.1.10",
"version": "4.1.11",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -29,10 +29,12 @@ type NetworkMetadata = {
/**
*
* @deprecated - use `useChain`, `useSwitchChain`, `useChainId` instead
*
* Hook for getting metadata about the network the current wallet is connected to and switching networks
*
* It's important to note that some wallet apps do not support programmatic network switching and switchNetwork will be undefined.
* For those situations, you can typically switch networks in the wallet app this hook will still work.
*
* @example
* ```javascript
* import { useNetwork } from "@thirdweb-dev/react";
@@ -47,12 +49,9 @@ type NetworkMetadata = {
* </button>
* );
* };
```
* ```
*
* It's important to note that some wallet apps do not support programmatic network switching and switchNetwork will be undefined.
* For those situations, you can typically switch networks in the wallet app this hook will still work.
*
* @public
* @deprecated - use `useChain`, `useSwitchChain`, `useChainId` instead
*/
export function useNetwork(): [NetworkMetadata, SwitchNetwork | undefined] {
const chain = useChain();
@@ -5,6 +5,7 @@ import type {
Coin98Wallet,
CoinbaseWallet,
CoreWallet,
CryptoDefiWallet,
EmbeddedWallet,
FrameWallet,
LocalWallet,
@@ -13,6 +14,7 @@ import type {
OKXWallet,
PaperWallet,
PhantomWallet,
RabbyWallet,
RainbowWallet,
SafeWallet,
SmartWallet,
@@ -45,6 +47,8 @@ type WalletIdToWalletTypeMap = {
phantom: PhantomWallet;
walletConnectV1: WalletConnect;
okx: OKXWallet;
cryptoDefiWallet: CryptoDefiWallet;
rabby: RabbyWallet;
};
/**
@@ -1,5 +1,8 @@
import { createContext } from "react";
/**
* @internal
*/
export const ThirdwebThemeContext = /* @__PURE__ */ createContext<
"light" | "dark" | undefined
>(undefined);
@@ -11,6 +11,9 @@ import {
ConnectParams,
CreateAsyncStorage,
SignerWallet,
WalletConnectHandler,
WalletConnectReceiverConfig,
WalletConnectV2Handler,
walletIds,
} from "@thirdweb-dev/wallets";
import { Signer } from "ethers";
@@ -24,6 +27,7 @@ import {
useRef,
useState,
} from "react";
import { isWalletConnectReceiverEnabled } from "../utils/receiver";
const LAST_CONNECTED_WALLET_STORAGE_KEY = "lastConnectedWallet";
@@ -92,6 +96,7 @@ type ThirdwebWalletContextData = {
getWalletConfig: (walletInstance: WalletInstance) => WalletConfig | undefined;
activeChainSetExplicitly: boolean;
clientId?: string;
walletConnectHandler: WalletConnectHandler | undefined;
};
const ThirdwebWalletContext = /* @__PURE__ */ createContext<
@@ -131,6 +136,9 @@ export function ThirdwebWalletProvider(
WalletConfig | undefined
>();
const [walletConnectHandler, setWalletConnectHandler] =
useState<WalletConnectHandler>();
if (!lastConnectedWalletStorage) {
lastConnectedWalletStorage =
props.createWalletStorage("coordinatorStorage");
@@ -172,6 +180,34 @@ export function ThirdwebWalletProvider(
}
}, [activeWallet, props.chains]);
useEffect(() => {
if (!activeWallet) {
return;
}
const initWCHandler = async () => {
const wcReceiverOptions =
activeWallet?.getOptions() as WalletConnectReceiverConfig;
const handler = new WalletConnectV2Handler(
{
walletConnectReceiver: {
...(wcReceiverOptions?.walletConnectReceiver === true
? {}
: wcReceiverOptions?.walletConnectReceiver),
},
},
activeWallet,
);
await handler.init();
setWalletConnectHandler(handler);
};
if (isWalletConnectReceiverEnabled(activeWallet)) {
initWCHandler();
}
}, [activeWallet]);
const setConnectedWallet = useCallback(
async (
wallet: WalletInstance,
@@ -275,12 +311,6 @@ export function ThirdwebWalletProvider(
if (autoConnectTriggered.current) {
return;
}
// if explicitly set to false, don't auto connect
// by default, auto connect
if (props.shouldAutoConnect === false) {
setConnectionStatus("disconnected");
return;
}
if (activeWallet) {
// there's already an active wallet, don't auto connect
@@ -292,6 +322,13 @@ export function ThirdwebWalletProvider(
return;
}
// if explicitly set to false, don't auto connect
// by default, auto connect
if (props.shouldAutoConnect === false) {
setConnectionStatus("disconnected");
return;
}
autoConnectTriggered.current = true;
async function autoconnect() {
@@ -302,7 +339,7 @@ export function ThirdwebWalletProvider(
return;
}
const walletObj = props.supportedWallets.find(
let walletObj = props.supportedWallets.find(
(W) => W.id === walletInfo.walletId,
);
@@ -312,17 +349,39 @@ export function ThirdwebWalletProvider(
return;
}
const personalWalletInfo = walletInfo.connectParams?.personalWallet;
let _personalWalletInfo = walletInfo.connectParams?.personalWallet;
// when connecting to magicLink with social login, it redirects to other page
// before redirecting, we save the walletInfo to local storage so that we can auto connect after redirect back to current page
// when using smartWallet + magicLink combination - the walletInfo will only contain info about magicLink and not smartWallet because it was never connected
// so if smartWallet + magicLink combination is used, we need to connect magicLink first and then connect smartWallet
if (
walletInfo.walletId === walletIds.magicLink &&
walletInfo.connectParams &&
"oauthProvider" in walletInfo.connectParams
) {
// if the wallet requires a personal wallet (like smartWallet), but the saved data does not have it
if (walletObj.personalWallets && !_personalWalletInfo) {
// fix the connectParams by adding the personal wallet info
_personalWalletInfo = {
walletId: walletInfo.walletId,
connectParams: walletInfo.connectParams,
};
}
}
const personalWalletInfo = _personalWalletInfo;
if (personalWalletInfo) {
const personalWallets = walletObj.personalWallets || [];
const personalWalleObj = personalWallets.find(
const personalWalletObj = personalWallets.find(
(W) => W.id === personalWalletInfo.walletId,
);
if (personalWalleObj) {
if (personalWalletObj) {
// create a personal wallet instance and auto connect it
const personalWalletInstance = createWalletInstance(personalWalleObj);
const personalWalletInstance =
createWalletInstance(personalWalletObj);
try {
await timeoutPromise(
@@ -351,6 +410,19 @@ export function ThirdwebWalletProvider(
setConnectionStatus("disconnected");
return;
}
} else {
// if walletObj requires a personal wallet, but the saved data does not have it
// connect to personal wallet only ( this happens when user switches to personal wallet and reloads the page )
if (walletObj.personalWallets) {
// connect the personal wallet instead
walletObj = walletObj.personalWallets.find(
(w) => w.id === walletInfo.walletId,
);
if (!walletObj) {
setConnectionStatus("disconnected");
return;
}
}
}
// create a wallet instance and auto connect it
@@ -525,6 +597,7 @@ export function ThirdwebWalletProvider(
},
activeChainSetExplicitly: props.activeChainSetExplicitly,
clientId: props.clientId,
walletConnectHandler: walletConnectHandler,
}}
>
{props.children}
@@ -532,6 +605,9 @@ export function ThirdwebWalletProvider(
);
}
/**
* @internal
*/
export function useWalletContext() {
const ctx = useContext(ThirdwebWalletContext);
if (!ctx) {
@@ -542,6 +618,16 @@ export function useWalletContext() {
return ctx;
}
export function useWalletConnectHandler() {
const ctx = useWalletContext();
if (!ctx) {
throw new Error(
`useWalletConnectHandler() can only be used inside <ThirdwebProvider />`,
);
}
return ctx.walletConnectHandler;
}
async function getLastConnectedWalletInfo() {
const str = await lastConnectedWalletStorage.getItem(
LAST_CONNECTED_WALLET_STORAGE_KEY,
@@ -3,7 +3,7 @@ import invariant from "tiny-invariant";
/**
* Makes a parameter required to be passed, but still allows it to be null or undefined.
*
* @beta
* @internal
*/
export type RequiredParam<T> = T | null | undefined;
@@ -0,0 +1,10 @@
import { WalletInstance } from "../types/wallet";
export const isWalletConnectReceiverEnabled = (wallet?: WalletInstance) => {
const options = wallet?.getOptions();
return (
options &&
"walletConnectReceiver" in options &&
options.walletConnectReceiver
);
};
@@ -10,6 +10,9 @@ import { WalletData } from "@thirdweb-dev/wallets";
import { useLogout } from "../hooks/auth";
import { useSwitchAccount } from "../hooks/auth/useSwitchAccount";
/**
* @internal
*/
export const ThirdwebAuthProvider: React.FC<
PropsWithChildren<{ value?: ThirdwebAuthConfig }>
> = ({ value, children }) => {
@@ -9,7 +9,6 @@ export interface ISecureStorage {
/**
* The configuration to use the react SDK with an [auth](https://portal.thirdweb.com/auth) server.
*
* @beta
*/
export interface ThirdwebAuthConfig {
/**
@@ -11,6 +11,9 @@ export const ThirdwebConfigContext = /* @__PURE__ */ createContext<
ThirdwebConfigContext | undefined
>(undefined);
/**
* @internal
*/
export const ThirdwebConfigProvider: React.FC<
PropsWithChildren<{
value: ThirdwebConfigContext;
@@ -21,6 +24,9 @@ export const ThirdwebConfigProvider: React.FC<
</ThirdwebConfigContext.Provider>
);
/**
* @internal
*/
export function useThirdwebConfigContext() {
const context = useContext(ThirdwebConfigContext);
invariant(
@@ -34,7 +34,6 @@ import invariant from "tiny-invariant";
* @returns a response object that includes an array of all accounts with their associated admin
* @twfeature AccountFactory
* @see {@link https://portal.thirdweb.com/react/react.useaccounts?utm_source=sdk | Documentation}
* @beta
*/
export function useAccounts(
contract: RequiredParam<SmartContract>,
@@ -66,7 +65,6 @@ export function useAccounts(
* @returns a response object that includes an array of all accounts associated with the address
* @twfeature AccountFactory
* @see {@link https://portal.thirdweb.com/react/react.useaccountsforaddress?utm_source=sdk | Documentation}
* @beta
*/
export function useAccountsForAddress(
contract: RequiredParam<SmartContract>,
@@ -102,7 +100,6 @@ export function useAccountsForAddress(
* @returns a boolean indicating if a account has been deployed for the given admin
* @twfeature AccountFactory
* @see {@link https://portal.thirdweb.com/react/react.useisaccountdeployed?utm_source=sdk | Documentation}
* @beta
*/
export function useIsAccountDeployed(
contract: RequiredParam<SmartContract>,
@@ -160,7 +157,6 @@ export function useIsAccountDeployed(
* @returns a mutation object that can be used to create a account
* @twfeature AccountFactory
* @see {@link https://portal.thirdweb.com/react/react.usecreateaccount?utm_source=sdk | Documentation}
* @beta
*/
export function useCreateAccount(contract: RequiredParam<SmartContract>) {
const activeChainId = useSDKChainId();
@@ -35,7 +35,6 @@ import { useWallet } from "../../../core/hooks/wallet-hooks";
* @returns a response object that includes an array of all signers of the provided account
* @twfeature Account
* @see {@link https://portal.thirdweb.com/react/react.useaccountsigners?utm_source=sdk | Documentation}
* @beta
*/
export function useAccountSigners(
contract: RequiredParam<SmartContract>,
@@ -67,7 +66,6 @@ export function useAccountSigners(
* @returns a response object that includes an array of all admins of the provided account
* @twfeature Account
* @see {@link https://portal.thirdweb.com/react/react.useaccountadmins?utm_source=sdk | Documentation}
* @beta
*/
export function useAccountAdmins(
contract: RequiredParam<SmartContract>,
@@ -99,7 +97,6 @@ export function useAccountAdmins(
* @returns a response object that includes an array of all admins of the provided account
* @twfeature Account
* @see {@link https://portal.thirdweb.com/react/react.useaccountadmins?utm_source=sdk | Documentation}
* @beta
*/
export function useAccountAdminsAndSigners(
contract: RequiredParam<SmartContract>,
@@ -28,7 +28,6 @@ import invariant from "tiny-invariant";
* @param contract - the {@link SmartContract} instance of the contract to get the appURI of
* @returns a response object that includes the appURI of the contract
* @twfeature AppURI
* @beta
*/
export function useAppURI<TContract extends ValidContractInstance>(
contract: RequiredParam<TContract>,
@@ -75,7 +74,6 @@ export function useAppURI<TContract extends ValidContractInstance>(
* @param contract - an instance of a {@link SmartContract}
* @returns a mutation object that can be used to update the appURI of a contract
* @twfeature AppUR
* @beta
*/
export function useSetAppURI(
contract: RequiredParam<ValidContractInstance>,
@@ -30,7 +30,6 @@ import invariant from "tiny-invariant";
/**
* The options to be passed as the second parameter to the {@link useClaimIneligibilityReasons} hook.
*
* @beta
*/
export type ClaimIneligibilityParams = {
// the wallet address to check claim eligibility for
@@ -42,7 +41,6 @@ export type ClaimIneligibilityParams = {
/**
* The params for the {@link useSetClaimConditions} hook mutation.
*
* @beta
*/
export type SetClaimConditionsParams = {
phases: ClaimConditionInput[];
@@ -66,7 +64,6 @@ export type SetClaimConditionsParams = {
* @returns a response object with the currently active claim condition
* @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1
* @see {@link https://portal.thirdweb.com/react/react.useactiveclaimcondition?utm_source=sdk | Documentation}
* @beta
*/
export function useActiveClaimCondition(
contract: RequiredParam<DropContract>,
@@ -122,7 +119,6 @@ export function useActiveClaimCondition(
* @returns a response object with the snapshot for the provided address
* @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1
* @see {@link https://portal.thirdweb.com/react/react.useclaimerproofs?utm_source=sdk | Documentation}
* @beta
*/
export function useClaimerProofs(
contract: RequiredParam<DropContract>,
@@ -186,7 +182,6 @@ export function useClaimerProofs(
* @returns a response object with the list of claim conditions
* @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1
* @see {@link https://portal.thirdweb.com/react/react.useclaimconditions?utm_source=sdk | Documentation}
* @beta
*/
export function useClaimConditions(
contract: RequiredParam<DropContract>,
@@ -241,7 +236,6 @@ export function useClaimConditions(
* @returns a response object with the reasons for the claim ineligibility
* @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1
* @see {@link https://portal.thirdweb.com/react/react.useclaimineligibilityreasons?utm_source=sdk | Documentation}
* @beta
*/
export function useClaimIneligibilityReasons(
contract: RequiredParam<DropContract>,
@@ -311,7 +305,6 @@ export function useClaimIneligibilityReasons(
* @returns the active claim condition for the wallet address or null if there is no active claim condition
* @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1
* @see {@link https://portal.thirdweb.com/react/react.useactiveclaimconditionforwallet?utm_source=sdk | Documentation}
* @beta
*/
export function useActiveClaimConditionForWallet(
contract: RequiredParam<DropContract>,
@@ -467,7 +460,6 @@ export function useActiveClaimConditionForWallet(
* @returns a mutation object that can be used to set claim conditions
* @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1
* @see {@link https://portal.thirdweb.com/react/react.usesetclaimconditions?utm_source=sdk | Documentation}
* @beta
*/
export function useSetClaimConditions(
contract: RequiredParam<DropContract>,
@@ -546,7 +538,6 @@ export function useSetClaimConditions(
* @param contract - an instance of a {@link DropContract}
* @returns a mutation object that can be used to reset claim conditions
* @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1 | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1
* @beta
*/
export function useResetClaimConditions(
contract: RequiredParam<DropContract>,
@@ -37,7 +37,6 @@ import invariant from "tiny-invariant";
* @returns the wallet address of the primary sales recipient
* @twfeature PrimarySale
* @see {@link https://portal.thirdweb.com/react/react.useprimarysalerecipient?utm_source=sdk | Documentation}
* @beta
*/
export function usePrimarySaleRecipient(
contract: RequiredParam<ValidContractInstance>,
@@ -89,7 +88,6 @@ export function usePrimarySaleRecipient(
* @returns a mutation object that can be used to update the primary sales recipient
* @twfeature PrimarySale
* @see {@link https://portal.thirdweb.com/react/react.useupdateprimarysalerecipient?utm_source=sdk | Documentation}
* @beta
*/
export function useUpdatePrimarySaleRecipient(
contract: RequiredParam<ValidContractInstance>,
@@ -140,7 +138,6 @@ export function useUpdatePrimarySaleRecipient(
* @returns an object containing recipient address and the royalty basis points
* @twfeature Royalty
* @see {@link https://portal.thirdweb.com/react/react.useroyaltysettings?utm_source=sdk | Documentation}
* @beta
*/
export function useRoyaltySettings(
contract: RequiredParam<ValidContractInstance>,
@@ -192,7 +189,6 @@ export function useRoyaltySettings(
* @returns a mutation object that can be used to update the royalty settings
* @twfeature Royalty
* @see {@link https://portal.thirdweb.com/react/react.useupdateroyaltysettings?utm_source=sdk | Documentation}
* @beta
*/
export function useUpdateRoyaltySettings(
contract: RequiredParam<ValidContractInstance>,
@@ -239,7 +235,6 @@ export function useUpdateRoyaltySettings(
* @returns an object containing the platform fee basis points and the fee recipient address
* @twfeature PlatformFee
* @see {@link https://portal.thirdweb.com/react/react.useplatformfees?utm_source=sdk | Documentation}
* @beta
*/
export function usePlatformFees(
contract: RequiredParam<ValidContractInstance>,
@@ -290,7 +285,6 @@ export function usePlatformFees(
* @returns a mutation object that can be used to update the platform fees settings
* @twfeature PlatformFee
* @see {@link https://portal.thirdweb.com/react/react.useupdateplatformfees?utm_source=sdk | Documentation}
* @beta
*/
export function useUpdatePlatformFees(
contract: RequiredParam<ValidContractInstance>,
@@ -336,7 +330,6 @@ export function useUpdatePlatformFees(
* @param contract - an instance of a {@link SmartContract}
* @returns a {@link CustomContractMetadata} object containing the metadata
* @see {@link https://portal.thirdweb.com/react/react.usemetadata?utm_source=sdk | Documentation}
* @beta
*/
export function useMetadata(
contract: RequiredParam<ValidContractInstance>,
@@ -390,7 +383,6 @@ export function useMetadata(
* @param contract - an instance of a {@link SmartContract}
* @returns a mutation object that can be used to update the metadata
* @see {@link https://portal.thirdweb.com/react/react.useupdatemetadata?utm_source=sdk | Documentation}
* @beta
*/
export function useUpdateMetadata(
contract: RequiredParam<ValidContractInstance>,
@@ -307,7 +307,6 @@ export function useContract(
* @param contract - the {@link ValidContractInstance} instance of the contract to get the metadata for
* @returns a response object that includes the contract metadata of the deployed contract
* @twfeature ContractMetadata
* @beta
*/
export function useContractMetadata<TContract extends ValidContractInstance>(
contract: RequiredParam<TContract>,
@@ -359,7 +358,6 @@ export function useContractMetadata<TContract extends ValidContractInstance>(
* @param contract - the {@link ValidContractInstance} instance of the contract to get the metadata for
* @returns a response object that includes the contract metadata of the deployed contract
* @twfeature ContractMetadata
* @beta
*/
export function useContractMetadataUpdate(
contract: RequiredParam<ValidContractInstance>,
@@ -417,7 +415,6 @@ export function useContractMetadataUpdate(
* @param options - options includes the filters ({@link QueryAllEvents}) for the query as well as if you want to subscribe to real-time updates (default: true)
* @returns a response object that includes the contract events
* @see {@link https://portal.thirdweb.com/react/react.usecontractevents?utm_source=sdk | Documentation}
* @beta
*/
export function useContractEvents(
contract: RequiredParam<ValidContractInstance>,
@@ -515,7 +512,6 @@ export function useContractEvents(
* @param args - The arguments to pass to the function (if any), with optional call arguments as the last parameter
* @returns a response object that includes the data returned by the function call
* @see {@link https://portal.thirdweb.com/react/react.usecontractread?utm_source=sdk | Documentation}
* @beta
*/
export function useContractRead<
TContractAddress extends GeneratedContractAddress | ContractAddress,
@@ -592,7 +588,6 @@ export function useContractRead<
* @param functionName - the name of the function to call
* @returns a response object that includes the write function to call
* @see {@link https://portal.thirdweb.com/react/react.usecontractwrite?utm_source=sdk | Documentation}
* @beta
*/
export function useContractWrite<
TContractAddress extends GeneratedContractAddress | ContractAddress,
@@ -52,7 +52,6 @@ import invariant from "tiny-invariant";
* @returns a response object that includes an array of NFTs that are unclaimed
* @twfeature ERC721LazyMintable
* @see {@link https://portal.thirdweb.com/react/react.useunclaimednfts?utm_source=sdk | Documentation}
* @beta
*/
export function useUnclaimedNFTs(
contract: RequiredParam<NFTDrop>,
@@ -89,7 +88,6 @@ export function useUnclaimedNFTs(
* @returns a response object that includes an array of NFTs that are claimed
* @twfeature ERC721LazyMintable
* @see {@link https://portal.thirdweb.com/react/react.useclaimednfts?utm_source=sdk | Documentation}
* @beta
*/
export function useClaimedNFTs(
contract: RequiredParam<NFTDrop>,
@@ -226,7 +224,6 @@ export function useBatchesToReveal<TContract extends RevealableContract>(
* @returns a mutation object that can be used to claim a NFT to the wallet specificed in the params
* @twfeature ERC721Claimable | ERC1155Claimable | ERC721ClaimPhasesV2 | ERC721ClaimPhasesV1 | ERC721ClaimConditionsV2 | ERC721ClaimConditionsV1 | ERC1155ClaimPhasesV2 | ERC1155ClaimPhasesV1 | ERC1155ClaimConditionsV2 | ERC1155ClaimConditionsV1
* @see {@link https://portal.thirdweb.com/react/react.useclaimnft?utm_source=sdk | Documentation}
* @beta
*/
export function useClaimNFT<TContract extends DropContract>(
contract: RequiredParam<TContract>,
@@ -316,7 +313,6 @@ export function useClaimNFT<TContract extends DropContract>(
* @returns a mutation object that can be used to lazy mint a batch of NFTs
* @twfeature ERC721LazyMintable | ERC1155LazyMintable
* @see {@link https://portal.thirdweb.com/react/react.uselazymint?utm_source=sdk | Documentation}
* @beta
*/
export function useLazyMint<TContract extends DropContract>(
contract: RequiredParam<TContract>,
@@ -389,7 +385,6 @@ export function useLazyMint<TContract extends DropContract>(
* @returns a mutation object that can be used to lazy mint a batch of NFTs
* @twfeature ERC721Revealable | ERC1155Revealable
* @see {@link https://portal.thirdweb.com/react/react.usedelayedreveallazymint?utm_source=sdk | Documentation}
* @beta
*/
export function useDelayedRevealLazyMint<TContract extends RevealableContract>(
contract: RequiredParam<TContract>,
@@ -470,7 +465,6 @@ export function useDelayedRevealLazyMint<TContract extends RevealableContract>(
* @returns a mutation object that can be used to reveal a batch of delayed reveal NFTs
* @twfeature ERC721Revealable | ERC1155Revealable
* @see {@link https://portal.thirdweb.com/react/react.usereveallazymint?utm_source=sdk | Documentation}
* @beta
*/
export function useRevealLazyMint<TContract extends RevealableContract>(
contract: RequiredParam<TContract>,
@@ -56,7 +56,6 @@ import invariant from "tiny-invariant";
* @param listingId - the listing id to check
* @returns a response object that includes the desired listing
* @see {@link https://portal.thirdweb.com/react/react.uselisting?utm_source=sdk | Documentation}
* @beta
*/
export function useListing(
contract: RequiredParam<Marketplace>,
@@ -163,7 +162,6 @@ export function useEnglishAuction(
* @param filter - filter to pass to the query for the sake of pagination & filtering
* @returns a response object that includes an array of listings
* @see {@link https://portal.thirdweb.com/react/react.uselistings?utm_source=sdk | Documentation}
* @beta
*/
export function useListings(
contract: RequiredParam<Marketplace>,
@@ -334,7 +332,6 @@ export function useValidEnglishAuctions(
* @param contract - an instance of a marketplace contract
* @returns a response object that includes the listing count
* @see {@link https://portal.thirdweb.com/react/react.uselistingscount?utm_source=sdk | Documentation}
* @beta
*/
export function useListingsCount(contract: RequiredParam<Marketplace>) {
const contractAddress = contract?.getAddress();
@@ -422,7 +419,6 @@ export function useEnglishAuctionsCount(
* @param filter - filter to pass to the query for the sake of pagination & filtering
* @returns a response object that includes an array of listings
* @see {@link https://portal.thirdweb.com/react/react.useactivelistings?utm_source=sdk | Documentation}
* @beta
*/
export function useActiveListings(
contract: RequiredParam<Marketplace>,
@@ -456,7 +452,6 @@ export function useActiveListings(
* @param listingId - the listing id to check
* @returns a response object that includes the {@link Offer} that is winning the auction
* @see {@link https://portal.thirdweb.com/react/react.usewinningbid?utm_source=sdk | Documentation}
* @beta
*/
export function useWinningBid(
contract: RequiredParam<Marketplace>,
@@ -585,7 +580,6 @@ export function useAuctionWinner(
*
* @param contract - an instance of a marketplace contract
* @param listingId - the listing id to check (only necessary for marketplace v3)
* @returns a response object that includes an array of listings
* @twfeature EnglishAuctions
* @see {@link https://portal.thirdweb.com/react/react.usebidbuffer?utm_source=sdk | Documentation}
@@ -694,7 +688,6 @@ export function useMinimumNextBid(
* @param contract - an instance of a Marketplace contract
* @param listingId - the id of the listing to fetch offers for
* @see {@link https://portal.thirdweb.com/react/react.useoffers?utm_source=sdk | Documentation}
* @beta
*/
export function useOffers(
contract: RequiredParam<Marketplace>,
@@ -902,7 +895,6 @@ export function useCreateAuctionListing<
* @param contract - an instance of a Marketplace contract
* @returns a mutation object that can be used to cancel a listing
* @see {@link https://portal.thirdweb.com/react/react.usecancellisting?utm_source=sdk | Documentation}
* @beta
*/
export function useCancelListing(
contract: RequiredParam<Marketplace>,
@@ -1107,7 +1099,6 @@ export function useCancelEnglishAuction(
* @param contract - an instance of a Marketplace contract
* @returns a mutation object that can be used to make a bid on an auction listing
* @see {@link https://portal.thirdweb.com/react/react.usemakebid?utm_source=sdk | Documentation}
* @beta
*/
export function useMakeBid(contract: RequiredParam<Marketplace>) {
const activeChainId = useSDKChainId();
@@ -1166,7 +1157,6 @@ export function useMakeBid(contract: RequiredParam<Marketplace>) {
* @param contract - an instance of a Marketplace contract
* @returns a mutation object that can be used to make a bid on an auction listing
* @see {@link https://portal.thirdweb.com/react/react.usemakeoffer?utm_source=sdk | Documentation}
* @beta
*/
export function useMakeOffer(contract: RequiredParam<Marketplace>) {
const activeChainId = useSDKChainId();
@@ -1286,7 +1276,6 @@ export function useAcceptDirectListingOffer(
* @param contract - an instance of a Marketplace contract
* @returns a mutation object that can be used to accept an offer on a direct listing
* @see {@link https://portal.thirdweb.com/react/react.useexecuteauctionsale?utm_source=sdk | Documentation}
* @beta
*/
export function useExecuteAuctionSale(contract: RequiredParam<Marketplace>) {
const activeChainId = useSDKChainId();
@@ -1344,7 +1333,6 @@ export function useExecuteAuctionSale(contract: RequiredParam<Marketplace>) {
* @param contract - an instance of a Marketplace contract
* @returns a mutation object that can be used to buy out an auction listing
* @see {@link https://portal.thirdweb.com/react/react.usebuynow?utm_source=sdk | Documentation}
* @beta
*/
export function useBuyNow(contract: RequiredParam<Marketplace>) {
const activeChainId = useSDKChainId();
@@ -1415,7 +1403,6 @@ export function useBuyNow(contract: RequiredParam<Marketplace>) {
* @param contract - an instance of a MarketplaceV3 contract
* @returns a mutation object that can be used to buy out a direct listing
* @see {@link https://portal.thirdweb.com/react/react.useBuyDirectListing?utm_source=sdk | Documentation}
* @beta
*/
export function useBuyDirectListing(contract: RequiredParam<MarketplaceV3>) {
const activeChainId = useSDKChainId();
@@ -46,7 +46,6 @@ import invariant from "tiny-invariant";
* @param contract - an instance of a {@link NFTContract}
* @param tokenId - the tokenId to look up
* @returns a response object that includes the metadata for the given tokenId
* @beta
* @twfeature ERC721 | ERC1155
* @see {@link https://portal.thirdweb.com/react/react.usenft?utm_source=sdk | Documentation}
*/
@@ -90,7 +89,6 @@ export function useNFT<TContract extends NFTContract>(
* @param queryParams - query params to pass to the query for pagination
* @returns a response object that includes an array of NFTs
* @twfeature ERC721Supply | ERC721Enumerable | ERC1155Enumerable
* @beta
* @see {@link https://portal.thirdweb.com/react/react.usenfts?utm_source=sdk | Documentation}
*/
export function useNFTs<TContract extends NFTContract>(
@@ -132,7 +130,6 @@ export function useNFTs<TContract extends NFTContract>(
*
* @param contract - an instance of a {@link NFTContract}
* @returns a response object that includes the total count of NFTs
* @beta
* @twfeature ERC721Supply | ERC1155Enumerable
* @see {@link https://portal.thirdweb.com/react/react.usetotalcount?utm_source=sdk | Documentation}
*/
@@ -181,7 +178,6 @@ export function useTotalCount<TContract extends NFTContract>(
* @param contract - an instance of a {@link NFTContract}
* @param tokenId - required for ERC1155, the tokenId to look up
* @returns a response object that includes the total minted supply
* @beta
* @twfeature ERC721Supply | ERC1155Enumerable
* @see {@link https://portal.thirdweb.com/react/react.usetotalcirculatingsupply?utm_source=sdk | Documentation}
*/
@@ -235,7 +231,6 @@ export function useTotalCirculatingSupply(
* @param ownerWalletAddress - the wallet address to get owned tokens for
* @param queryParams - query params to pass to the query for pagination
* @returns a response object that includes the list of owned tokens
* @beta
* @twfeature ERC721Enumerable | ERC1155Enumerable | ERC721Supply
* @see {@link https://portal.thirdweb.com/react/react.useownednfts?utm_source=sdk | Documentation}
*/
@@ -283,7 +278,6 @@ export function useOwnedNFTs<TContract extends NFTContract>(
* @returns a response object that includes the total balance of the owner
* @twfeature ERC721 | ERC1155
* @see {@link https://portal.thirdweb.com/react/react.usenftbalance?utm_source=sdk | Documentation}
* @beta
*/
export function useNFTBalance(
contract: RequiredParam<NFTContract>,
@@ -337,7 +331,6 @@ export function useNFTBalance(
* @returns a response object that includes the shared metadata of the contract
* @twfeature ERC721SharedMetadata
* @see {@link https://portal.thirdweb.com/react/react.usesharedmetadata?utm_source=sdk | Documentation}
* @beta
*/
export function useSharedMetadata(
contract: RequiredParam<NFTContract>,
@@ -397,7 +390,6 @@ export function useSharedMetadata(
*
* @param contract - an instance of a {@link NFTContract}
* @returns a mutation object that can be used to mint a new NFT token to the connected wallet
* @beta
* @twfeature ERC721Mintable | ERC1155Mintable
* @see {@link https://portal.thirdweb.com/react/react.usemintnft?utm_source=sdk | Documentation}
*/
@@ -470,7 +462,6 @@ export function useMintNFT<TContract extends NFTContract>(
*
* @param contract - an instance of a {@link Erc1155}
* @returns a mutation object that can be used to mint a more supply of a token id to the provided wallet
* @beta
* @twfeature ERC1155Mintable
* @see {@link https://portal.thirdweb.com/react/react.usemintnftsupply?utm_source=sdk | Documentation}
*/
@@ -537,7 +528,6 @@ export function useMintNFTSupply(contract: Erc1155) {
*
* @param contract - an instance of a {@link NFTContract}
* @returns a mutation object that can be used to transfer NFTs
* @beta
* @twfeature ERC721 | ERC1155
* @see {@link https://portal.thirdweb.com/react/react.usetransfernft?utm_source=sdk | Documentation}
*/
@@ -624,7 +614,6 @@ export function useTransferNFT<TContract extends NFTContract>(
* @returns a mutation object that can be used to transfer batch NFTs
* @twfeature ERC1155
* @see {@link https://portal.thirdweb.com/react/react.useairdropnft?utm_source=sdk | Documentation}
* @beta
*/
export function useAirdropNFT(contract: Erc1155) {
const activeChainId = useSDKChainId();
@@ -681,7 +670,6 @@ export function useAirdropNFT(contract: Erc1155) {
* @returns a mutation object that can be used to burn an NFT token from the connected wallet
* @twfeature ERC721Burnable | ERC1155Burnable
* @see {@link https://portal.thirdweb.com/react/react.useburnnft?utm_source=sdk | Documentation}
* @beta
*/
export function useBurnNFT<TContract extends NFTContract>(
contract: RequiredParam<TContract>,
@@ -57,7 +57,6 @@ type GetAllReturnType<TContract extends ContractWithRoles> = Promise<
* @returns a list of addresses for all supported roles on the contract.
* @twfeature PermissionsEnumerable
* @see {@link https://portal.thirdweb.com/react/react.useallrolemembers?utm_source=sdk | Documentation}
* @beta
*/
export function useAllRoleMembers<TContract extends ContractWithRoles>(
contract: RequiredParam<TContract>,
@@ -90,7 +89,6 @@ export function useAllRoleMembers<TContract extends ContractWithRoles>(
* @returns a list of addresses that are members of the role
* @twfeature Permissions
* @see {@link https://portal.thirdweb.com/react/react.userolemembers?utm_source=sdk | Documentation}
* @beta
*/
export function useRoleMembers<TContract extends ContractWithRoles>(
contract: RequiredParam<TContract>,
@@ -124,7 +122,6 @@ export function useRoleMembers<TContract extends ContractWithRoles>(
* @returns true if the address is a member of the role, or false if not
* @twfeature PermissionsEnumerable
* @see {@link https://portal.thirdweb.com/react/react.useisaddressrole?utm_source=sdk | Documentation}
* @beta
*/
export function useIsAddressRole<TContract extends ContractWithRoles>(
contract: RequiredParam<TContract>,
@@ -187,7 +184,6 @@ export function useIsAddressRole<TContract extends ContractWithRoles>(
* @param contract - an instance of a {@link SmartContract}
* @returns a mutation object that can be used to overwrite all roles on the contract
* @twfeature Permissions
* @beta
*/
export function useSetAllRoleMembers<TContract extends ContractWithRoles>(
contract: RequiredParam<TContract>,
@@ -247,7 +243,6 @@ export function useSetAllRoleMembers<TContract extends ContractWithRoles>(
* @returns a mutation object that can be used to grant a member of a role on the contract
* @twfeature Permissions | PermissionsEnumerable
* @see {@link https://portal.thirdweb.com/react/react.usegrantrole?utm_source=sdk | Documentation}
* @beta
*/
export function useGrantRole<TContract extends ContractWithRoles>(
contract: RequiredParam<TContract>,
@@ -308,7 +303,6 @@ export function useGrantRole<TContract extends ContractWithRoles>(
* @returns a mutation object that can be used to revoke a role from a member on the contract
* @twfeature Permissions | PermissionsEnumerable
* @see {@link https://portal.thirdweb.com/react/react.userevokerole?utm_source=sdk | Documentation}
* @beta
*/
export function useRevokeRole<TContract extends ContractWithRoles>(
contract: RequiredParam<TContract>,
@@ -40,7 +40,6 @@ import invariant from "tiny-invariant";
* @returns a response object that includes the total minted supply
* @twfeature ERC20
* @see {@link https://portal.thirdweb.com/react/react.usetokensupply?utm_source=sdk | Documentation}
* @beta
*/
export function useTokenSupply(contract: RequiredParam<TokenContract>) {
const contractAddress = contract?.getAddress();
@@ -72,7 +71,6 @@ export function useTokenSupply(contract: RequiredParam<TokenContract>) {
* @returns a response object that includes the balance of the address
* @twfeature ERC20
* @see {@link https://portal.thirdweb.com/react/react.usetokenbalance?utm_source=sdk | Documentation}
* @beta
*/
export function useTokenBalance(
contract: RequiredParam<TokenContract>,
@@ -109,7 +107,6 @@ export function useTokenBalance(
* @returns a response object that includes the decimals of the ERC20 token
* @twfeature ERC20
* @see {@link https://portal.thirdweb.com/react/react.usetokendecimals?utm_source=sdk | Documentation}
* @beta
*/
export function useTokenDecimals(contract: RequiredParam<TokenContract>) {
const contractAddress = contract?.getAddress();
@@ -166,7 +163,6 @@ export function useTokenDecimals(contract: RequiredParam<TokenContract>) {
* @returns a mutation object that can be used to mint new tokens to the connected wallet
* @twfeature ERC20Mintable
* @see {@link https://portal.thirdweb.com/react/react.useminttoken?utm_source=sdk | Documentation}
* @beta
*/
export function useMintToken(
contract: RequiredParam<TokenContract>,
@@ -239,7 +235,6 @@ export function useMintToken(
* @returns a mutation object that can be used to tokens to the wallet specified in the params
* @twfeature ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1
* @see {@link https://portal.thirdweb.com/react/react.useclaimtoken?utm_source=sdk | Documentation}
* @beta
*/
export function useClaimToken(contract: RequiredParam<TokenContract>) {
const activeChainId = useSDKChainId();
@@ -301,7 +296,6 @@ export function useClaimToken(contract: RequiredParam<TokenContract>) {
* @returns a mutation object that can be used to transfer tokens
* @twfeature ERC20
* @see {@link https://portal.thirdweb.com/react/react.usetransfertoken?utm_source=sdk | Documentation}
* @beta
*/
export function useTransferToken(contract: RequiredParam<TokenContract>) {
const activeChainId = useSDKChainId();
@@ -361,7 +355,6 @@ export function useTransferToken(contract: RequiredParam<TokenContract>) {
* @returns a mutation object that can be used to transfer batch tokens
* @twfeature ERC20
* @see {@link https://portal.thirdweb.com/react/react.usetransferbatchtoken?utm_source=sdk | Documentation}
* @beta
*/
export function useTransferBatchToken(contract: RequiredParam<TokenContract>) {
const activeChainId = useSDKChainId();
@@ -428,7 +421,6 @@ export function useTransferBatchToken(contract: RequiredParam<TokenContract>) {
* @returns a mutation object that can be used to burn tokens from the connected wallet
* @twfeature ERC20Burnable
* @see {@link https://portal.thirdweb.com/react/react.useburntoken?utm_source=sdk | Documentation}
* @beta
*/
export function useBurnToken(contract: RequiredParam<TokenContract>) {
const activeChainId = useSDKChainId();
@@ -14,7 +14,6 @@ import { AUTH_TOKEN_STORAGE_KEY } from "../../../core/constants/auth";
*
* @see {@link https://portal.thirdweb.com/react/react.uselogin?utm_source=sdk | Documentation}
*
* @beta
*/
export function useLogin() {
const queryClient = useQueryClient();
@@ -12,7 +12,6 @@ import invariant from "tiny-invariant";
*
* @see {@link https://portal.thirdweb.com/react/react.uselogout?utm_source=sdk | Documentation}
*
* @beta
*/
export function useLogout() {
const queryClient = useQueryClient();
@@ -10,7 +10,6 @@ import invariant from "tiny-invariant";
*
* @see {@link https://portal.thirdweb.com/react/react.useswitchaccount?utm_source=sdk | Documentation}
*
* @beta
*/
export function useSwitchAccount() {
const queryClient = useQueryClient();
@@ -19,7 +19,6 @@ export interface UserWithData<
*
* @see {@link https://portal.thirdweb.com/react/react.useuser?utm_source=sdk | Documentation}
*
* @beta
*/
export function useUser<
TData extends Json = Json,
@@ -5,6 +5,9 @@ import { useAddress } from "./wallet";
import { useSupportedChains } from "./useSupportedChains";
import { useWalletContext } from "../../core/providers/thirdweb-wallet-provider";
/**
* @internal
*/
export function useENS() {
const address = useAddress();
const supportedChains = useSupportedChains();
@@ -8,7 +8,7 @@ import { useChainId } from "./wallet";
* import { useNetworkMismatch } from "@thirdweb-dev/react"
* ```
*
* @returns `true` if the chainId of the connected wallet is different from the chainId of the network passed into <ThirdwebProvider />
* @returns `true` if the chainId of the connected wallet is different from the chainId of the network passed into `<ThirdwebProvider />`
*
* @see {@link https://portal.thirdweb.com/react/react.usenetworkmismatch?utm_source=sdk | Documentation}
*
+23 -1
View File
@@ -9,13 +9,14 @@ import { useSupportedChains } from "./useSupportedChains";
import { useQuery } from "@tanstack/react-query";
import { Chain, defaultChains } from "@thirdweb-dev/chains";
import { useContext, useMemo } from "react";
import { useSDK } from "./useSDK";
import { useWalletContext } from "../../core/providers/thirdweb-wallet-provider";
/**
* A hook to get the native or (optional) ERC20 token balance of the connected wallet.
*
* @param tokenAddress - the address of the token contract, if empty will use the chain's native token
* @returns the balance of the connected wallet (native or ERC20)
* @beta
*/
export function useBalance(tokenAddress?: ContractAddress) {
const walletAddress = useAddress();
@@ -40,6 +41,27 @@ export function useBalance(tokenAddress?: ContractAddress) {
);
}
/**
* Get the native token balance of a wallet address on the `activeChain` network set in the `ThirdwebProvider`
*
* @param walletAddress - the address of the wallet that you want to get the native balance
* @returns the balance of the given wallet address
*/
export function useBalanceForAddress(walletAddress: string) {
invariant(walletAddress, "wallet address is not provided");
const { activeChain } = useWalletContext();
const chainId = activeChain.chainId;
const sdk = useSDK();
const cacheKey = useMemo(() => {
return cacheKeys.wallet.balance(chainId, walletAddress);
}, [chainId, walletAddress]);
return useQuery(cacheKey, async () => {
invariant(sdk, "SDK is not initialized");
return await sdk.getBalance(walletAddress);
});
}
/**
* @internal
*/
+2
View File
@@ -23,6 +23,7 @@ export {
export { useNetwork } from "../core/hooks/useNetwork";
export { useWalletContext } from "../core/providers/thirdweb-wallet-provider";
export { usePersonalWalletAddress } from "./hooks/usePersonalWalletAddress";
export { useWalletConnectHandler } from "../core/providers/thirdweb-wallet-provider";
// connected wallet hooks
export {
@@ -32,6 +33,7 @@ export {
useChainId,
useActiveChain,
useChain,
useBalanceForAddress,
} from "./hooks/wallet";
// Utilities and Others
@@ -152,23 +152,47 @@ const WrappedThirdwebSDKProvider = <TChains extends Chain[]>({
};
/**
* A basic wrapper around the Thirdweb SDK.
* The `ThirdwebSDKProvider` is used when you want to provide your own wallet connection logic and just use the thirdweb SDK to interact with smart contracts and the blockchain.
* This means you can use everything in the SDK except for wallet connection-related components and hooks. if you need those please use the `ThirdwebProvider` instead.
*
* You can use this in order to be able to pass a provider & signer directly to the SDK.
* `ThirdwebSDKProvider` allows you to set a provider & signer to the Thirdweb SDK.
*
* @remarks Utilizing this provider will mean hooks for wallet management are not available, if you need those please use the {@link ThirdwebProvider} instead.
* @example
* Wrap your app in the ThirdwebSDKProvider to access the SDK’s functionality from anywhere in your app.
*
* ```tsx
* import { ThirdwebSDKProvider } from "@thirdweb-dev/react";
* import { ethers } from "ethers";
*
* // Example shows how to get the signer from the injected provider ( wallet extension )
* function Example() {
* return (
* <ThirdwebSDKProvider
* activeChain="ethereum"
* clientId="YOUR_CLIENT_ID"
* signer={new ethers.providers.Web3Provider(window.ethereum).getSigner()}
* >
* <App />
* </ThirdwebSDKProvider>
* )
* }
* ```
*
* @public
*/
export const ThirdwebSDKProvider = <TChains extends Chain[]>({
signer,
children,
queryClient,
supportedChains: _supportedChains,
activeChain,
clientId,
...restProps
}: React.PropsWithChildren<ThirdwebSDKProviderProps<TChains>>) => {
export const ThirdwebSDKProvider = <TChains extends Chain[]>(
props: React.PropsWithChildren<ThirdwebSDKProviderProps<TChains>>,
) => {
const {
signer,
children,
queryClient,
supportedChains: _supportedChains,
activeChain,
clientId,
...restProps
} = props;
if (!clientId) {
checkClientIdOrSecretKey(
"No API key. Please provide a clientId. It is required to access thirdweb's services. You can create a key at https://thirdweb.com/create-api-key",
+85 -10
View File
@@ -8,29 +8,97 @@ import type { Signer } from "ethers";
export interface ThirdwebSDKProviderProps<TChains extends Chain[]>
extends QueryClientProviderProps {
/**
* Chains to support. If not provided, will default to the chains supported by the SDK.
* An array of chains supported by your app.
* There are 1000+ chains available in the `@thirdweb-dev/chains` package. You can import the chain you want and pass it to the `supportedChains` prop in an array.
*
* If not provided, it will default to the default supported chains supported by the thirdweb SDK.
*
* @example
* ```tsx
* import { Ethereum, Polygon } from "@thirdweb-dev/chains";
*
* function Example() {
* return (
* <ThirdwebSDKProvider supportedChains={[ Ethereum, Polygon ]} activeChain={Ethereum}>
* <App />
* </ThirdwebSDKProvider>
* )
* }
* ```
*/
supportedChains?: TChains;
// a possible signer - optional, defaults to undefined
/**
* A signer is an abstraction of an Ethereum Account, which can be used to sign messages and initiate transactions.
*
* Since the ThirdwebSDKProvider is used when you want to provide your own wallet connection logic, you will need to provide a signer prop to inform the SDK of the wallet you want to use to sign transactions.
*
* Libraries such as ethers.js, web3.js, wagmi, etc. all provide ways to get a signer.
*
* To use this signer with the SDK, pass it to the `signer` prop. If the signer is connected, the SDK will use this wallet to sign transactions for all write operations on the blockchain.
*/
signer?: Signer;
/**
* The {@link SDKOptions | Thirdweb SDK Options} to pass to the thirdweb SDK
* comes with sensible defaults
* The thirdweb SDK Options to pass to the thirdweb SDK which includes Gas settings, gasless transactions, RPC configuration, and more.
*
* This Overrides any of the default values for the SDK. If not provided, it uses sensible defaults.
*/
sdkOptions?: Omit<SDKOptions, "chains">;
/**
* The storage interface to use with the sdk.
* Override the default [Storage](https://portal.thirdweb.com/storage) interface used by the SDK.
*
* It allows you to create an instance of `ThirdwebStorage` with your own customized config, and pass it to the SDK.
*
* *This requires the `@thirdweb-dev/storage` package to be installed.*
*
* @example
* ```tsx
* import { ThirdwebSDKProvider } from "@thirdweb-dev/react";
* import {
* ThirdwebStorage,
* StorageDownloader,
* IpfsUploader,
* } from "@thirdweb-dev/storage";
*
* // Configure a custom ThirdwebStorage instance
* const gatewayUrls = {
* "ipfs://": [
* "https://gateway.ipfscdn.io/ipfs/",
* "https://cloudflare-ipfs.com/ipfs/",
* "https://ipfs.io/ipfs/",
* ],
* };
* const downloader = new StorageDownloader();
* const uploader = new IpfsUploader();
* const storage = new ThirdwebStorage({ uploader, downloader, gatewayUrls });
*
* // Provide the custom storage instance to the SDK
* function MyApp() {
* return (
* <ThirdwebSDKProvider
* storageInterface={storage}
* >
* <YourApp />
* </ThirdwebSDKProvider>
* );
* }
* ```
*/
storageInterface?: IThirdwebStorage;
/**
* The configuration used for thirdweb auth usage. Enables users to login
* to backends with their wallet.
* The configuration object for setting up [Auth](https://portal.thirdweb.com/auth); allowing users to sign in with their wallet.
*/
authConfig?: ThirdwebAuthConfig;
/**
* The network to use for the SDK.
* The activeChain prop determines which chain you want your app to be operating on.
*
* There are 1000+ chains available in the `@thirdweb-dev/chains` package. Import the chain you want and pass it to the `activeChain` prop.
*
* You can override the imported object or pass a custom chain object with required properties.
*/
activeChain?:
| TChains[number]["chainId"]
@@ -43,9 +111,16 @@ export interface ThirdwebSDKProviderProps<TChains extends Chain[]>
| (string & {})
| Chain;
// client Id for thirdweb services
/**
* The clientId prop is required to use the thirdweb infrastructure services with the SDK.
*
* You can get a client ID by creating an API key on [thirdweb dashboard](https://thirdweb.com/dashboard/settings/api-keys)
*/
clientId?: string;
// pass in a secret key when doing server side rendering
/**
* secretKey for thirdweb services
* This is only required if server side rendering is being used.
*/
secretKey?: string;
}
-19
View File
@@ -54,20 +54,17 @@ export type Chain = {
/**
* A wallet address.
* @beta
*/
export type WalletAddress = AddressOrEns;
/**
* A contract address.
* @beta
*/
export type ContractAddress = AddressOrEns;
/**
* The parameters to pass to the mint and transfer functions.
*
* @beta
*/
export type TokenParams = {
to: WalletAddress;
@@ -77,7 +74,6 @@ export type TokenParams = {
/**
* The parameters to pass to the burn function.
*
* @beta
*/
export type TokenBurnParams = {
amount: Amount;
@@ -91,7 +87,6 @@ export type TokenBurnParams = {
* ```javascript
* const { contract } = useContract("{{contract_address}}");
* ```
* @beta
*/
export type NFTContract =
| NFTCollection
@@ -106,19 +101,16 @@ export type NFTContract =
* ```javascript
* const { contract } = useContract("{{contract_address}}");
* ```
* @beta
*/
export type TokenContract = TokenDrop | Token | SmartContract | null;
/**
* Possible NFT contract types.
* @beta
*/
export type Erc721OrErc1155 = Erc721 | Erc1155;
/**
* The params to pass to `useTransferNFT`.
* @beta
*/
export type TransferNFTParams = {
to: WalletAddress;
@@ -128,7 +120,6 @@ export type TransferNFTParams = {
/**
* The params to pass to `useTransferBatchNFT`.
* @beta
*/
export type AirdropNFTParams = {
tokenId: BigNumberish;
@@ -137,7 +128,6 @@ export type AirdropNFTParams = {
/**
* The params to pass to `useMintNFTSupply`.
* @beta
*/
export type MintNFTSupplyParams = {
tokenId: BigNumberish;
@@ -148,7 +138,6 @@ export type MintNFTSupplyParams = {
/**
* The params for the {@link useMintNFT} hook mutation.
*
* @beta
*/
export type MintNFTParams = {
metadata: NFTMetadataOrUri;
@@ -159,7 +148,6 @@ export type MintNFTParams = {
/**
* The return type of the {@link useMintNFT} hook.
*
* @beta
*/
export type MintNFTReturnType<TContract> = TContract extends Erc721
? Awaited<ReturnType<Erc721Mintable["to"]>>
@@ -170,7 +158,6 @@ export type MintNFTReturnType<TContract> = TContract extends Erc721
/**
* The params for the {@link useBurnNFT} hook mutation.
*
* @beta
*/
export type BurnNFTParams = { tokenId: BigNumberish; amount?: Amount };
@@ -178,7 +165,6 @@ export type BurnNFTParams = { tokenId: BigNumberish; amount?: Amount };
/**
* The possible DROP contract types.
* @beta
*/
export type DropContract =
| NFTDrop
@@ -190,14 +176,12 @@ export type DropContract =
/**
* The possible revealable contract types.
* @beta
*/
export type RevealableContract = NFTDrop | SignatureDrop | SmartContract | null;
/**
* The params for the {@link useDelayedRevealLazyMint} hook mutation.
*
* @beta
*/
export type DelayedRevealLazyMintInput = {
placeholder: NFTMetadataInput;
@@ -208,7 +192,6 @@ export type DelayedRevealLazyMintInput = {
/**
* The params for the {@link useRevealLazyMint} hook mutation.
*
* @beta
*/
export type RevealLazyMintInput = {
batchId: BigNumberish;
@@ -218,7 +201,6 @@ export type RevealLazyMintInput = {
/**
* The params for the {@link useClaimNFT} hook mutation.
*
* @beta
*/
export type ClaimNFTParams = {
to?: WalletAddress;
@@ -233,7 +215,6 @@ export type ClaimNFTParams = {
/**
* The return type of the {@link useClaimNFT} hook.
*
* @beta
*/
export type ClaimNFTReturnType =
| Awaited<ReturnType<Erc721["claimTo"]>>
@@ -1,5 +1,7 @@
# @thirdweb-dev/react-native-compat
## 0.4.11
## 0.4.10
## 0.4.9
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.4.10",
"version": "0.4.11",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+15
View File
@@ -1,5 +1,20 @@
# @thirdweb-dev/react-native
## 0.4.11
### Patch Changes
- [#2025](https://github.com/thirdweb-dev/js/pull/2025) [`97ba1fbd`](https://github.com/thirdweb-dev/js/commit/97ba1fbd42d40d4a2ed5c3680115a147a1fa12f0) Thanks [@iketw](https://github.com/iketw)! - Adds version header to ews calls
- [#2016](https://github.com/thirdweb-dev/js/pull/2016) [`94559129`](https://github.com/thirdweb-dev/js/commit/9455912932c71f3ef9b67461bf5604f1ea1f71e8) Thanks [@iketw](https://github.com/iketw)! - Share WalletConnectHandler between React and RN to support wallets as receivers
- Updated dependencies [[`e79b2935`](https://github.com/thirdweb-dev/js/commit/e79b293562bbcf4af6fbcb4829b2acb4cb3e2cb4), [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`a27b10c5`](https://github.com/thirdweb-dev/js/commit/a27b10c5c3400500ef0138069acc550b3a07ffc6), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`94559129`](https://github.com/thirdweb-dev/js/commit/9455912932c71f3ef9b67461bf5604f1ea1f71e8), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`f93bd325`](https://github.com/thirdweb-dev/js/commit/f93bd325e119381ddc3380a5ea43fe63fbcf42c0), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`50749662`](https://github.com/thirdweb-dev/js/commit/507496627bcd77b49bb027b24996a31c57e04819), [`b3394277`](https://github.com/thirdweb-dev/js/commit/b3394277c77e4af130151111e056e27a28ac893a), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c), [`4c488aa3`](https://github.com/thirdweb-dev/js/commit/4c488aa31f6fadc13759ff60f30230b929feb314)]:
- @thirdweb-dev/react-core@4.1.11
- @thirdweb-dev/wallets@2.1.10
- @thirdweb-dev/sdk@4.0.18
- @thirdweb-dev/chains@0.1.60
- @thirdweb-dev/storage@2.0.6
## 0.4.10
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.4.10",
"version": "0.4.11",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -5,10 +5,10 @@ import {
TW_UPLOAD_SERVER_URL,
} from "@thirdweb-dev/storage";
import { IpfsUploaderOptions, UploadDataValue } from "./types";
import * as Application from "expo-application";
import { Platform } from "react-native";
import { appBundleId, packageVersion } from "../../evm/utils/version";
import { BUNDLE_ID_HEADER } from "../../evm/constants/headers";
const APP_BUNDLE_ID = Application.applicationId;
const METADATA_NAME = "Storage React Native SDK";
export class IpfsUploader implements IStorageUploader<IpfsUploadBatchOptions> {
@@ -39,9 +39,7 @@ export class IpfsUploader implements IStorageUploader<IpfsUploadBatchOptions> {
keyvalues: { ...options?.metadata },
};
// this is on purpose because we can't import package.json as a module as it is outside rootDir
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version, name: packageName } = require("../../../package.json");
const { version, name: packageName } = packageVersion;
const platform = `react-native-${Platform.OS}`;
if ("uri" in data[0] && "type" in data[0] && "name" in data[0]) {
@@ -143,7 +141,7 @@ export class IpfsUploader implements IStorageUploader<IpfsUploadBatchOptions> {
});
xhr.open("POST", `${TW_UPLOAD_SERVER_URL}/ipfs/upload`);
xhr.setRequestHeader("x-bundle-id", APP_BUNDLE_ID || ""); // only empty on web
xhr.setRequestHeader(BUNDLE_ID_HEADER, appBundleId || ""); // only empty on web
if (this.clientId) {
xhr.setRequestHeader("x-client-id", this.clientId);
}
@@ -168,7 +166,7 @@ export class IpfsUploader implements IStorageUploader<IpfsUploadBatchOptions> {
{
method: "POST",
headers: {
"x-bundle-id": APP_BUNDLE_ID || "", // only empty on web
[BUNDLE_ID_HEADER]: appBundleId || "", // only empty on web
...(this.clientId ? { "x-client-id": this.clientId } : {}),
"Content-Type": "application/json",
"x-sdk-version": version,
@@ -1,4 +1,4 @@
import { useWallet } from "@thirdweb-dev/react-core";
import { useWallet, useWalletConnectHandler } from "@thirdweb-dev/react-core";
import { useCallback, useEffect, useRef, useState } from "react";
import Box from "../base/Box";
import BaseButton from "../base/BaseButton";
@@ -13,7 +13,6 @@ import WalletConnectIcon from "../../assets/wallet-connect";
import QrCodeIcon from "../../assets/qr-code";
import { QRCodeScan } from "./QRCodeScan";
import { useLocale } from "../../providers/ui-context-provider";
import { useWalletConnectHandler } from "../../providers/context-provider";
const ConnectAppField = ({
onConnectAppTriggered,
@@ -1,4 +1,4 @@
import { useWallet } from "@thirdweb-dev/react-core";
import { useWallet, useWalletConnectHandler } from "@thirdweb-dev/react-core";
import Box from "../base/Box";
import BaseButton from "../base/BaseButton";
import Text from "../base/Text";
@@ -7,7 +7,6 @@ import {
WalletConnectSessionProposalModal,
} from "../../utils/modalTypes";
import { useLocale, useModalState } from "../../providers/ui-context-provider";
import { useWalletConnectHandler } from "../../providers/context-provider";
export const SessionProposalModal = () => {
const l = useLocale();
@@ -1,4 +1,9 @@
import { shortenAddress, useChain, useWallet } from "@thirdweb-dev/react-core";
import {
shortenAddress,
useChain,
useWallet,
useWalletConnectHandler,
} from "@thirdweb-dev/react-core";
import Box from "../base/Box";
import BaseButton from "../base/BaseButton";
import Text from "../base/Text";
@@ -10,7 +15,6 @@ import {
} from "../../utils/modalTypes";
import { ActivityIndicator, Dimensions } from "react-native";
import { useCallback, useState } from "react";
import { useWalletConnectHandler } from "../../providers/context-provider";
const getTitle = (method: string) => {
switch (method) {
@@ -2,8 +2,8 @@ import { useStorage } from "@thirdweb-dev/react-core";
import { useState } from "react";
import { Image } from "react-native";
import { SvgUri, SvgXml } from "react-native-svg";
import { isAppBundleIdPresentInGlobal } from "../../utils/global";
import Box from "./Box";
import { appBundleId } from "../../utils/version";
const ImageSvgUri = ({
imageUrl = "",
@@ -24,10 +24,7 @@ const ImageSvgUri = ({
}
const resolvedImageUrl = storage
? storage.resolveScheme(imageUrl) +
(isAppBundleIdPresentInGlobal()
? `?bundleId=${(globalThis as any).APP_BUNDLE_ID as string}`
: "")
? storage.resolveScheme(imageUrl) + `?bundleId=${appBundleId}`
: imageUrl.replace("ipfs://", "https://ipfs.io/ipfs/");
if (!resolvedImageUrl || resolvedImageUrl === "") {
@@ -0,0 +1 @@
export const BUNDLE_ID_HEADER = "x-bundle-id";
@@ -1,10 +1,4 @@
import {
SmartWallet,
WalletConnectHandler,
WalletConnectReceiverConfig,
WalletConnectV2Handler,
walletIds,
} from "@thirdweb-dev/wallets";
import { SmartWallet, walletIds } from "@thirdweb-dev/wallets";
import {
createContext,
useCallback,
@@ -14,15 +8,13 @@ import {
} from "react";
import { useWalletConnectListener } from "../wallets/hooks/useWalletConnectListener";
import { MagicLink } from "../wallets/wallets/MagicLink";
import { useWallet, useWalletContext } from "@thirdweb-dev/react-core";
import { isWalletConnectReceiverEnabled } from "../wallets/utils";
import { useWalletContext } from "@thirdweb-dev/react-core";
type DappContextType = {
smartWallet?: SmartWallet;
setSmartWallet?: (value?: SmartWallet) => void;
magicLink?: MagicLink;
setMagicLink?: (value?: MagicLink) => void;
walletConnectHandler?: WalletConnectHandler;
};
const DappContext = createContext<DappContextType>({});
@@ -30,10 +22,7 @@ const DappContext = createContext<DappContextType>({});
export const DappContextProvider = (props: React.PropsWithChildren) => {
const [smartWallet, setSmartWallet] = useState<SmartWallet | undefined>();
const [magicLink, setMagicLink] = useState<MagicLink | undefined>();
const [walletConnectHandler, setWalletConnectHandler] =
useState<WalletConnectHandler>();
const createdWalletInstance = useWalletContext().createdWalletInstance;
const activeWallet = useWallet();
useEffect(() => {
if (!createdWalletInstance) {
@@ -45,35 +34,7 @@ export const DappContextProvider = (props: React.PropsWithChildren) => {
}
}, [createdWalletInstance, setMagicLink]);
useEffect(() => {
if (!activeWallet) {
return;
}
const initWCHandler = async () => {
const wcReceiverOptions =
activeWallet?.getOptions() as WalletConnectReceiverConfig;
const handler = new WalletConnectV2Handler(
{
walletConnectReceiver: {
...(wcReceiverOptions?.walletConnectReceiver === true
? {}
: wcReceiverOptions?.walletConnectReceiver),
},
},
activeWallet,
);
await handler.init();
setWalletConnectHandler(handler);
};
if (isWalletConnectReceiverEnabled(activeWallet)) {
initWCHandler();
}
}, [activeWallet]);
useWalletConnectListener(walletConnectHandler);
useWalletConnectListener();
const magicSDK = useCallback(() => {
if (magicLink) {
@@ -91,7 +52,6 @@ export const DappContextProvider = (props: React.PropsWithChildren) => {
setSmartWallet,
magicLink: magicLink,
setMagicLink: setMagicLink,
walletConnectHandler: walletConnectHandler,
}}
>
{props.children}
@@ -118,9 +78,3 @@ export const useMagicLink = () => {
setMagicLink: context.setMagicLink,
} as const;
};
export const useWalletConnectHandler = () => {
const context = useContext(DappContext);
return context.walletConnectHandler;
};
@@ -0,0 +1,12 @@
import * as Application from "expo-application";
export const packageVersion: {
version: string;
name: string;
// this is on purpose because we can't import package.json as a module as it is outside rootDir
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require("../../../package.json");
export const reactNativePackageVersion = `react-native:${packageVersion.version}`;
export const appBundleId = Application.applicationId || "";
@@ -26,12 +26,18 @@ import { isDeviceSharePresentForUser } from "./helpers/storage/local";
import { Auth } from "aws-amplify";
import {
DOMAIN_URL_2023,
EWS_VERSION_HEADER,
ROUTE_AUTH_JWT_CALLBACK,
ROUTE_HEADLESS_OAUTH_LOGIN,
} from "./helpers/constants";
import { AuthOptions, OauthOption, VerifiedTokenResponse } from "../types";
import { InAppBrowser } from "react-native-inappbrowser-reborn";
import { createErrorMessage } from "./helpers/errors";
import {
appBundleId,
reactNativePackageVersion,
} from "../../../../utils/version";
import { BUNDLE_ID_HEADER } from "../../../../constants/headers";
export async function sendVerificationEmail(options: {
email: string;
@@ -179,7 +185,12 @@ export async function socialLogin(oauthOptions: OauthOption, clientId: string) {
DOMAIN_URL_2023,
)}&platform=${encodeURIComponent("mobile")}`;
const resp = await fetch(headlessLoginLinkWithParams);
const resp = await fetch(headlessLoginLinkWithParams, {
headers: {
[EWS_VERSION_HEADER]: reactNativePackageVersion,
[BUNDLE_ID_HEADER]: appBundleId,
},
});
if (!resp.ok) {
const error = await resp.json();
@@ -256,7 +267,11 @@ export async function customJwt(authOptions: AuthOptions, clientId: string) {
const resp = await fetch(ROUTE_AUTH_JWT_CALLBACK, {
method: "POST",
headers: { "Content-Type": "application/json" },
headers: {
"Content-Type": "application/json",
[EWS_VERSION_HEADER]: reactNativePackageVersion,
[BUNDLE_ID_HEADER]: appBundleId,
},
body: JSON.stringify({
jwt: jwt,
developerClientId: clientId,
@@ -7,9 +7,9 @@ import {
ROUTE_USER_MANAGED_OTP,
ROUTE_VALIDATE_USER_MANAGED_OTP,
ROUTE_IS_VALID_USER_MANAGED_OTP,
EWS_VERSION_HEADER,
} from "../constants";
import { getAuthTokenClient } from "../storage/local";
import * as Application from "expo-application";
import {
RecoveryShareManagement,
UserWalletStatus,
@@ -19,18 +19,25 @@ import {
VerifiedTokenResponse,
} from "../../../types";
import { createErrorMessage } from "../errors";
import {
appBundleId,
reactNativePackageVersion,
} from "../../../../../../utils/version";
import { BUNDLE_ID_HEADER } from "../../../../../../constants/headers";
const EMBEDDED_WALLET_TOKEN_HEADER = "embedded-wallet-token";
const PAPER_CLIENT_ID_HEADER = "x-thirdweb-client-id";
const BUNDLE_ID_HEADER = "x-bundle-id";
const APP_BUNDLE_ID = Application.applicationId || "";
const HEADERS = {
"Content-Type": "application/json",
[BUNDLE_ID_HEADER]: appBundleId,
[EWS_VERSION_HEADER]: reactNativePackageVersion,
};
export const verifyClientId = async (clientId: string) => {
const resp = await fetch(ROUTE_VERIFY_THIRDWEB_CLIENT_ID, {
method: "POST",
headers: {
"Content-Type": "application/json",
[BUNDLE_ID_HEADER]: APP_BUNDLE_ID,
...HEADERS,
},
body: JSON.stringify({ clientId, parentDomain: "" }),
});
@@ -58,15 +65,17 @@ export const authFetchEmbeddedWalletUser = async (
Authorization: `Bearer ${EMBEDDED_WALLET_TOKEN_HEADER}:${
authTokenClient || ""
}`,
[BUNDLE_ID_HEADER]: APP_BUNDLE_ID,
[BUNDLE_ID_HEADER]: appBundleId,
[PAPER_CLIENT_ID_HEADER]: clientId,
[EWS_VERSION_HEADER]: reactNativePackageVersion,
}
: {
Authorization: `Bearer ${EMBEDDED_WALLET_TOKEN_HEADER}:${
authTokenClient || ""
}`,
[BUNDLE_ID_HEADER]: APP_BUNDLE_ID,
[BUNDLE_ID_HEADER]: appBundleId,
[PAPER_CLIENT_ID_HEADER]: clientId,
[EWS_VERSION_HEADER]: reactNativePackageVersion,
};
return fetch(url, params);
};
@@ -118,8 +127,7 @@ export async function generateAuthTokenFromCognitoEmailOtp(
const resp = await fetch(ROUTE_VERIFY_COGNITO_OTP, {
method: "POST",
headers: {
"Content-Type": "application/json",
[BUNDLE_ID_HEADER]: APP_BUNDLE_ID,
...HEADERS,
},
body: JSON.stringify({
access_token: session.getAccessToken().getJwtToken(),
@@ -143,8 +151,7 @@ export async function sendUserManagedEmailOtp(email: string, clientId: string) {
const resp = await fetch(ROUTE_USER_MANAGED_OTP, {
method: "POST",
headers: {
"Content-Type": "application/json",
[BUNDLE_ID_HEADER]: APP_BUNDLE_ID,
...HEADERS,
},
body: JSON.stringify({
email,
@@ -169,8 +176,7 @@ export async function validateUserManagedEmailOtp(options: {
const resp = await fetch(ROUTE_VALIDATE_USER_MANAGED_OTP, {
method: "POST",
headers: {
"Content-Type": "application/json",
[BUNDLE_ID_HEADER]: APP_BUNDLE_ID,
...HEADERS,
},
body: JSON.stringify({
email: options.email,
@@ -195,8 +201,7 @@ export async function isValidUserManagedEmailOtp(options: {
const resp = await fetch(ROUTE_IS_VALID_USER_MANAGED_OTP, {
method: "POST",
headers: {
"Content-Type": "application/json",
[BUNDLE_ID_HEADER]: APP_BUNDLE_ID,
...HEADERS,
},
body: JSON.stringify({
email: options.email,
@@ -12,6 +12,8 @@ export const RECOVERY_SHARE_INDEX = RECOVERY_SHARE_ID - 1;
export const AWS_REGION = "us-west-2";
export const EWS_VERSION_HEADER = "x-embedded-wallet-version";
export const COGNITO_USER_POOL_ID = "us-west-2_UFwLcZIpq";
export const COGNITO_APP_CLIENT_ID = "2e02ha2ce6du13ldk8pai4h3d0";
export const COGNITO_IDENTITY_POOL_ID =
@@ -1,21 +1,16 @@
import { useWallet } from "@thirdweb-dev/react-core";
import { useWallet, useWalletConnectHandler } from "@thirdweb-dev/react-core";
import { useCallback, useEffect } from "react";
import { useModalState } from "../../providers/ui-context-provider";
import {
WCProposal,
WCRequest,
WalletConnectHandler,
} from "@thirdweb-dev/wallets";
import { WCProposal, WCRequest } from "@thirdweb-dev/wallets";
/**
* Registers listeners for wallet connect if the active wallet
* is also a WalletConnectReceiver
*/
export function useWalletConnectListener(
walletConnectHandler?: WalletConnectHandler,
) {
export function useWalletConnectListener() {
const activeWallet = useWallet();
const { setModalState } = useModalState();
const walletConnectHandler = useWalletConnectHandler();
const onSessionProposal = useCallback(
(proposal: WCProposal) => {
+2 -2
View File
@@ -1,8 +1,8 @@
import * as Application from "expo-application";
import { isGlobalThisPresent } from "./evm/utils/global";
import { appBundleId } from "./evm/utils/version";
export * from "./evm";
if (isGlobalThisPresent()) {
(globalThis as any).APP_BUNDLE_ID = Application.applicationId;
(globalThis as any).APP_BUNDLE_ID = appBundleId;
}
+22
View File
@@ -1,5 +1,27 @@
# @thirdweb-dev/react
## 4.1.11
### Patch Changes
- [#1926](https://github.com/thirdweb-dev/js/pull/1926) [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Rabby browser extension
- [#2031](https://github.com/thirdweb-dev/js/pull/2031) [`fdf19b0a`](https://github.com/thirdweb-dev/js/commit/fdf19b0a26be0404ddf5424f26d96719de849627) Thanks [@MananTank](https://github.com/MananTank)! - Do not swallow errors in useEmbeddedWallet().connect
- [#1997](https://github.com/thirdweb-dev/js/pull/1997) [`50749662`](https://github.com/thirdweb-dev/js/commit/507496627bcd77b49bb027b24996a31c57e04819) Thanks [@MananTank](https://github.com/MananTank)! - - Fixes issue #1708
- Fixes smart wallet icon shown even after clicking on "Switch to Personal wallet" in ConnectWallet dropdown
- [#1987](https://github.com/thirdweb-dev/js/pull/1987) [`b3394277`](https://github.com/thirdweb-dev/js/commit/b3394277c77e4af130151111e056e27a28ac893a) Thanks [@MananTank](https://github.com/MananTank)! - Improved JSDoc comments and type exports
- [#1928](https://github.com/thirdweb-dev/js/pull/1928) [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Crypto.com Defi wallet
- Updated dependencies [[`e79b2935`](https://github.com/thirdweb-dev/js/commit/e79b293562bbcf4af6fbcb4829b2acb4cb3e2cb4), [`8c2d4e5e`](https://github.com/thirdweb-dev/js/commit/8c2d4e5ea7c38b3efa4d8d94c9822a92d271e59b), [`b0ecfd2d`](https://github.com/thirdweb-dev/js/commit/b0ecfd2d8d5cda33dc8f5ea2d20119cb901a0bcb), [`a27b10c5`](https://github.com/thirdweb-dev/js/commit/a27b10c5c3400500ef0138069acc550b3a07ffc6), [`d28097f5`](https://github.com/thirdweb-dev/js/commit/d28097f508739cdbd6625e09c2ed0fe25a922c0f), [`94559129`](https://github.com/thirdweb-dev/js/commit/9455912932c71f3ef9b67461bf5604f1ea1f71e8), [`b8332500`](https://github.com/thirdweb-dev/js/commit/b833250053320c8608109053f5cffe2dc96ce70a), [`8bf3be88`](https://github.com/thirdweb-dev/js/commit/8bf3be88be051178a7142618c4371d2f2ef26271), [`b02fb91a`](https://github.com/thirdweb-dev/js/commit/b02fb91a548a3f66f7677ced24be9397e0f9a7ba), [`2861dff1`](https://github.com/thirdweb-dev/js/commit/2861dff1f013b5150314fdaccaeadddbcf0d21c9), [`61b6a002`](https://github.com/thirdweb-dev/js/commit/61b6a00214716454222e67fe5fdb47edba391070), [`28fc3736`](https://github.com/thirdweb-dev/js/commit/28fc3736aa30c89690084aa2c62556c183796352), [`50749662`](https://github.com/thirdweb-dev/js/commit/507496627bcd77b49bb027b24996a31c57e04819), [`b3394277`](https://github.com/thirdweb-dev/js/commit/b3394277c77e4af130151111e056e27a28ac893a), [`06805217`](https://github.com/thirdweb-dev/js/commit/06805217c26de203a57c21246acba22def8a78fa), [`2b4f1c8e`](https://github.com/thirdweb-dev/js/commit/2b4f1c8e55de091100fb5279887bcb19ea31d38c), [`4c488aa3`](https://github.com/thirdweb-dev/js/commit/4c488aa31f6fadc13759ff60f30230b929feb314)]:
- @thirdweb-dev/react-core@4.1.11
- @thirdweb-dev/wallets@2.1.10
- @thirdweb-dev/sdk@4.0.18
- @thirdweb-dev/chains@0.1.60
## 4.1.10
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "4.1.10",
"version": "4.1.11",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -3,7 +3,7 @@ import invariant from "tiny-invariant";
/**
* Makes a parameter required to be passed, but still allows it to be null or undefined.
*
* @beta
* @internal
*/
export type RequiredParam<T> = T | null | undefined;
@@ -357,13 +357,14 @@ const LinkPlayer = /* @__PURE__ */ (() =>
/**
* This component can be used to render any media type, including image, audio, video, and html files.
* Its convenient for rendering NFT media files, as these can be a variety of different types.
* The component falls back to a external link if the media type is not supported.
* The default size is 300px by 300px, but this can be changed using the `width` and `height` props.
*
* Props: {@link MediaRendererProps}
* The component falls back to a external link if the media type is not supported.
*
* The default size is 300px by 300px, but this can be changed using the `width` and `height` props.
*
* @example
* We can take a video file hosted on IPFS and render it using this component as follows
*
* ```jsx
* const Component = () => {
* return <MediaRenderer
@@ -2,10 +2,7 @@ import { Popover } from "../../../components/Popover";
import { Spinner } from "../../../components/Spinner";
import { Button } from "../../../components/buttons";
import { Theme } from "../../../design-system";
import {
ConnectWallet,
ConnectWalletProps,
} from "../../../wallet/ConnectWallet/ConnectWallet";
import { ConnectWallet } from "../../../wallet/ConnectWallet/ConnectWallet";
import { useIsHeadlessWallet } from "../../../wallet/hooks/useIsHeadlessWallet";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import {
@@ -25,43 +22,180 @@ import {
useCustomTheme,
} from "../../../design-system/CustomThemeProvider";
import { useTWLocale } from "../../providers/locale-provider";
import { WelcomeScreen } from "../../../wallet/ConnectWallet/screens/types";
type ActionFn = (contract: SmartContract) => any;
const TW_WEB3BUTTON = "tw-web3button";
interface Web3ButtonProps<TActionFn extends ActionFn> {
export interface Web3ButtonProps<TActionFn extends ActionFn> {
/**
* the class to apply to the button for adding custom styles
*
* @example
* ```tsx
* <Web3Button className="my-custom-class" contractAddress={contractAddress} action={someAction} >
* Claim NFT
* </Web3Button>
* ```
*/
className?: string;
/**
* the address of the contract
*
* If you have not imported your contract to [thirdweb dashboard](https://thirdweb.com/dashboard), you must additionally specify the contractAbi prop.
*/
contractAddress: `0x${string}` | `${string}.eth` | string;
/**
* The [Application Binary Interface](https://docs.soliditylang.org/en/v0.8.17/abi-spec.html) (ABI) of the contract.
*
* This is only required if you have not imported your contract to the [thirdweb dashboard](https://thirdweb.com/dashboard).
*/
contractAbi?: ContractInterface;
// called with the result
/**
* Callback function to be run when the contract method call is successful.
* @param result - value returned from given `action` function when it is called
*/
onSuccess?: (result: Awaited<ReturnType<TActionFn>>) => void;
// called with any error that might happen
/**
* Callback function to be run when the contract method call fails.
* @param error - error thrown when running given `action` function
*/
onError?: (error: Error) => void;
// called before the `action` function is called
/**
* Callback function to be run after the user has confirmed the transaction.
* It is called just before the `action` function is called
*/
onSubmit?: () => void;
// disabled state
/**
* Whether the button should be disabled or not
*
* The button is disabled and shows a spinner when the transaction is executing.
*/
isDisabled?: boolean;
// the fn to execute
/**
* The logic to execute when the button is clicked.
*
* The contract instance is available as the first argument of the function for you to interact with.
*
* If the action you are performing is async, make sure to return a Promise from the action function so that the SDK knows when the action is complete
*
* @example
* ```tsx
* <Web3Button
* contractAddress="0x..."
* action={(contract) => contract.erc721.claim(1)}
* >
* Claim NFT
* </Web3Button>
* ```
*/
action: TActionFn;
/**
* button element's `type` attribute
*/
type?: "button" | "submit" | "reset";
/**
* The theme to use for the button
*/
theme?: "dark" | "light" | Theme;
/**
* The style to apply to the button element
*/
style?: React.CSSProperties;
connectWallet?: Omit<
ConnectWalletProps,
| "detailsBtn"
| "hideTestnetFaucet"
| "switchToActiveChain"
| "theme"
| "hideSwitchToPersonalWallet"
>;
/**
* Web3Button renders a `ConnectWallet` if no wallet is connected. You can pass props for that component by passing a `connectWallet` prop to Web3Button
*
* @example
* ```tsx
* <Web3Button
* contractAddress="0x..."
* action={(contract) => contract.erc721.claim(1)}
* >
* Claim NFT
* </Web3Button>
* ```
*/
connectWallet?: {
/**
* The class to apply to the ConnectWallet component for adding custom styles
*/
className?: string;
/**
* text to render in ConnectWallet button
* @defaultValue "Connect Wallet"
*/
btnTitle?: string;
/**
* title of the `ConnectWallet` Modal
* @defaultValue "Connect"
*/
modalTitle?: string;
/**
* Replace the thirdweb icon next to modalTitle and set your own iconUrl
*
* Set to empty string to hide the icon
*/
modalTitleIconUrl?: string;
auth?: {
loginOptional?: boolean;
onLogin?: (token: string) => void;
onLogout?: () => void;
};
/**
* apply custom styles to ConnectWallet button element
*/
style?: React.CSSProperties;
/**
* Set the size of the modal - `compact` or `wide` on desktop
*
* Modal size is always `compact` on mobile
*
* @defaultValue "wide"
*/
modalSize?: "compact" | "wide";
/**
* If provided, ConnectWallet Modal will show a Terms of Service message at the bottom with below link
*/
termsOfServiceUrl?: string;
/**
* If provided, ConnectWallet Modal will show a Privacy Policy message at the bottom with below link
*/
privacyPolicyUrl?: string;
/**
* Customize the welcome screen of the ConnectWallet Modal
*
* Either provide a component to replace the default screen entirely or an object with title, subtitle and imgSrc to change the content of the default screen
*/
welcomeScreen?: WelcomeScreen;
};
}
/**
* A component that allows the user to call an on-chain function on a contract.
* Button that executes a function on a smart contract from the connected wallet when clicked.
*
* The button has to be wrapped in a `ThirdwebProvider` in order to function.
* It ensures the following criteria before attempting to call the contract function:
*
* 1. There is a connected wallet (if there is not, it renders a `ConnectWallet` component instead.
*
* 2. The connected wallet is on the correct network as specified in the `ThirdwebProvider`'s `activeChain` prop. if it is not, it renders a "switch network" button instead.
*
* If the action you are performing is async, make sure to return a `Promise` from the action function so that the SDK knows when the action is complete. This can be done by either using async/await or by returning a `Promise`.
*
* @example
* ```javascript
@@ -70,14 +204,17 @@ interface Web3ButtonProps<TActionFn extends ActionFn> {
* const App = () => {
* return (
* <div>
* <Web3Button contractAddress="0x..." action={(contract) => contract.erc721.transfer("0x...", 1)} />
* <Web3Button
* contractAddress="0x..."
* action={(contract) => contract.erc721.transfer("0x...", 1)}
* >
* Claim NFT
* </Web3Button>
* </div>
* )
* )
* }
* ```
*
*
* @beta
*/
export const Web3Button = <TAction extends ActionFn>(
props: PropsWithChildren<Web3ButtonProps<TAction>>,
+25 -2
View File
@@ -1,21 +1,38 @@
import type { ReactNode } from "react";
export interface SharedMediaProps {
/**
* The className to apply on the rendered element to add custom styling.
*/
className?: string;
/**
* The style to apply on the rendered element to add custom styling.
*/
style?: React.CSSProperties;
/**
* The CSS width property to apply on the rendered element.
*/
width?: HTMLIFrameElement["width"];
/**
* The CSS height property to apply on the rendered element.
*/
height?: HTMLIFrameElement["height"];
/**
* Require user interaction to play the media. (default false)
* Require user interaction to play the media.
* @defaultValue false
*/
requireInteraction?: boolean;
/**
* Show the media controls (where applicable) (default false)
* Show the media controls (where applicable)
* @defaultValue false
*/
controls?: HTMLVideoElement["controls"];
children?: ReactNode;
/**
* Provide the [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the media if it is known
*/
mimeType?: string;
}
@@ -41,6 +58,12 @@ export interface MediaRendererProps extends SharedMediaProps {
* The IPFS gateway URL to use
*/
gatewayUrl?: string;
/**
* The CSS width property to apply on the rendered element.
*/
width?: string;
/**
* The CSS height property to apply on the rendered element.
*/
height?: string;
}
@@ -51,6 +51,7 @@ export function useEmbeddedWallet() {
} catch (e) {
console.error("Error connecting to embedded wallet", e);
setStatus("disconnected");
throw e;
}
return wallet;
},
@@ -13,6 +13,9 @@ import { useCallback, useEffect } from "react";
type PaperConfig = Omit<PaperWalletAdditionalOptions, "chain">;
/**
* @deprecated We have deprecated `PaperWallet` in favor of our `EmbeddedWallet` which adds support for more sign in methods. use the `useEmbeddedWallet` hook instead
*/
export function usePaperWallet() {
const connect = useConnect();
return useCallback(
@@ -29,6 +32,9 @@ export function usePaperWallet() {
);
}
/**
* @deprecated We have deprecated `PaperWallet` in favor of our `EmbeddedWallet` which adds support for more sign in methods. use the `useEmbeddedWallet` hook instead
*/
export function usePaperWalletUserEmail(): UseQueryResult<
string | undefined,
string
@@ -2,6 +2,9 @@ import { useConnect } from "@thirdweb-dev/react-core";
import { WC2_QRModalOptions } from "@thirdweb-dev/wallets";
import { useCallback } from "react";
/**
* @deprecated use the `useWalletConnect` hook instead
*/
export function useWalletConnectV1() {
const connect = useConnect();
return useCallback(
+19 -4
View File
@@ -10,16 +10,24 @@ export {
ConnectWallet,
type ConnectWalletProps,
} from "../wallet/ConnectWallet/ConnectWallet";
export type { WelcomeScreen } from "../wallet/ConnectWallet/screens/types";
export { ConnectModalInline } from "../wallet/ConnectWallet/Modal/ConnectModalInline";
export { NetworkSelector } from "../wallet/ConnectWallet/NetworkSelector";
export type { NetworkSelectorProps } from "../wallet/ConnectWallet/NetworkSelector";
export {
NetworkSelector,
type NetworkSelectorProps,
type NetworkSelectorChain,
} from "../wallet/ConnectWallet/NetworkSelector";
// UI components
export * from "./components/MediaRenderer";
export * from "./components/NftMedia";
export * from "./components/Web3Button";
export { ThirdwebProvider } from "./providers/thirdweb-provider";
export { Web3Button, type Web3ButtonProps } from "./components/Web3Button";
export {
ThirdwebProvider,
type DefaultChains,
type ThirdwebProviderProps,
} from "./providers/thirdweb-provider";
export type { MediaRendererProps } from "./components/types";
@@ -49,6 +57,11 @@ export {
useWalletConnectV1,
} from "./hooks/wallets/useWalletConnect";
export {
defaultTokens,
type SupportedTokens,
} from "../wallet/ConnectWallet/defaultTokens";
// react-core
export * from "@thirdweb-dev/react-core";
// wallets
@@ -73,5 +86,7 @@ export {
InjectedWallet,
setWalletAnalyticsEnabled,
CoreWallet,
CryptoDefiWallet,
RabbyWallet,
Coin98Wallet,
} from "@thirdweb-dev/wallets";
+2
View File
@@ -168,6 +168,8 @@ export function enDefault() {
trustWallet: extensionAndQRScanScreens("Trust"),
zerionWallet: extensionAndQRScanScreens("Zerion"),
coreWallet: extensionAndQRScanScreens("Core"),
cryptoDefiWallet: extensionAndQRScanScreens("Crypto Defi"),
rabbyWallet: extensionAndQRScanScreens("Rabby"),
coin98Wallet: extensionAndQRScanScreens("Coin98"),
paperWallet: {
signIn: "Sign in",
+2
View File
@@ -173,6 +173,8 @@ export function esDefault(): ThirdwebLocale {
rainbowWallet: extensionAndQRScanScreens("Rainbow"),
trustWallet: extensionAndQRScanScreens("Trust"),
zerionWallet: extensionAndQRScanScreens("Zerion"),
cryptoDefiWallet: extensionAndQRScanScreens("Crypto Defi"),
rabbyWallet: extensionAndQRScanScreens("Rabby"),
paperWallet: {
signIn: "Iniciar sesión",
signInWithGoogle: "Iniciar sesión con Google",
+2
View File
@@ -173,6 +173,8 @@ export function jaDefault(): ThirdwebLocale {
rainbowWallet: extensionAndQRScanScreens("Rainbow"),
trustWallet: extensionAndQRScanScreens("Trust"),
zerionWallet: extensionAndQRScanScreens("Zerion"),
cryptoDefiWallet: extensionAndQRScanScreens("Crypto Defi"),
rabbyWallet: extensionAndQRScanScreens("Rabby"),
paperWallet: {
signIn: "サインイン",
signInWithGoogle: "Googleでサインイン",
@@ -16,7 +16,7 @@ import { ThirdwebLocale, en } from "../locales/en";
import { ThirdwebLocaleContext } from "./locale-provider";
import { walletIds } from "@thirdweb-dev/wallets";
interface ThirdwebProviderProps<TChains extends Chain[]>
export interface ThirdwebProviderProps<TChains extends Chain[]>
extends Omit<
ThirdwebProviderCoreProps<TChains>,
"createWalletStorage" | "supportedWallets" | "theme"
@@ -47,6 +47,8 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
locale?: ThirdwebLocale;
}
export type DefaultChains = typeof defaultChains;
/**
*
* The `<ThirdwebProvider />` component lets you control what networks you want users to connect to,
@@ -68,15 +70,17 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
* ```
*
*/
export const ThirdwebProvider = <
TChains extends Chain[] = typeof defaultChains,
>({
supportedWallets,
children,
signer,
theme: _theme,
...restProps
}: PropsWithChildren<ThirdwebProviderProps<TChains>>) => {
export const ThirdwebProvider = <TChains extends Chain[] = DefaultChains>(
props: PropsWithChildren<ThirdwebProviderProps<TChains>>,
) => {
const {
supportedWallets,
children,
signer,
theme: _theme,
...restProps
} = props;
const wallets: WalletConfig[] = supportedWallets || defaultWallets;
const theme = _theme || "dark";

Some files were not shown because too many files have changed in this diff Show More