Compare commits

...
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
0a5d2b5bdd Version Packages (#1247)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-27 17:36:21 -07:00
FirekeeperandGitHub ac3e019cd1 [unity-js-bridge] wcv2 and paper support (#1256) 2023-06-28 00:28:16 +00:00
3c5dc4804a Migration to WalletConnectV2 (#1215)
Co-authored-by: Manan Tank <[email protected]>
2023-06-28 00:04:07 +00:00
Joaquim VergesandGitHub 30ac3aef84 [SDK] Handle base64 encoded NFTs (#1254) 2023-06-27 23:31:52 +00:00
YashandGitHub ef4cb09219 [SDK] Any EVM deployments: update EIP155 error substrings (#1249) 2023-06-27 22:55:16 +00:00
ad7dae3b16 [React] Stop using useActiveChain deprecated hook (#1253)
Co-authored-by: Nacho Iacovino <[email protected]>
2023-06-27 21:50:28 +00:00
0fd8aa04a9 fix(chains): Celo Alfajores Explorer URL (#1243)
Co-authored-by: Joaquim Verges <[email protected]>
Co-authored-by: Jonas Daniels <[email protected]>
2023-06-27 19:37:23 +00:00
620e89dc25 [React] Export smart wallet hooks (#1248)
Co-authored-by: Jonas Daniels <[email protected]>
2023-06-27 19:01:45 +00:00
Nacho IacovinoandGitHub 86d33c4b3e [React] Fix marketplace v3 cache keys (#1251) 2023-06-27 18:06:30 +00:00
Adam MajmudarandGitHub d43f6171d9 Allow setting login payload duration (#1250) 2023-06-27 18:04:33 +00:00
06ca1c407d [SDK] Add tests for SmartWallet and SmartWalletFactory; add smartWallet.setAccess and smartWallet.isAdmin (#1227)
Co-authored-by: Nacho Iacovino <[email protected]>
Co-authored-by: Nacho Iacovino <[email protected]>
2023-06-27 01:57:33 +00:00
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
c578a437cc Version Packages (#1234)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-26 18:42:04 -07:00
Danny FridayandGitHub 0c5b03b8d6 Remove ipfs-2 gateway (#1246) 2023-06-27 00:31:06 +00:00
nkrishangandGitHub 9af346eead [SDK][React] SmartWalletFactory: use getAllAccounts instead of event logs of AccountCreated to get accounts of a factory (#1241) 2023-06-26 17:51:22 +00:00
iketwandGitHub d9fb134ad4 [RN] better design for custom details button (#1245) 2023-06-26 15:25:19 +00:00
Mariano FuentesandGitHub 1c7264b403 Fix install bug (#1240) 2023-06-24 00:59:52 +00:00
Joaquim VergesandGitHub a140ee99b2 add zora extension in auto docs (#1239) 2023-06-24 00:23:07 +00:00
iketwandGitHub 6e1fe6e582 [React] Add Rainbow and Trust wallets connection hooks (#1238) 2023-06-23 23:06:59 +00:00
iketwandGitHub 536b0f1240 [React] Add Rainbow Wallet (#1237) 2023-06-23 22:11:40 +00:00
b626782b0e [React/Wallets] Add Trust Wallet (#1236)
Co-authored-by: Manan Tank <[email protected]>
2023-06-23 21:23:13 +00:00
Nacho IacovinoandGitHub 1d76334dd3 [React] Fix required type for address on useSmartWalletsForAddress (#1235) 2023-06-23 18:44:00 +00:00
nkrishangandGitHub d498c79a91 [SDK] Fix smartWalletFactory.getAllWallets (#1233) 2023-06-23 18:20:03 +00:00
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
736b45ac8e Version Packages (#1211)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-23 10:33:33 -07:00
Nacho IacovinoandGitHub b5e1d3bb2b [React] Add useSmartWalletsForAddress hook (#1230) 2023-06-23 12:00:37 +00:00
Jonas DanielsandGitHub 6816219ac1 [chains] - add/update chains (#1229) 2023-06-22 23:57:03 +00:00
Nacho IacovinoandGitHub 48065bcd91 [SDK] Accept string in shared metadata (#1222) 2023-06-22 23:39:34 +00:00
Manan TankandGitHub a388d07a3d Add Magic Connect support (#1226) 2023-06-22 20:28:04 +00:00
Nacho IacovinoandGitHub 483e2b9109 [SDK] Fix namespace for platformFees (#1225) 2023-06-22 19:24:04 +00:00
Nacho IacovinoandGitHub f7f4f20737 [React + SDK] Better return type for get shared metadata (#1224) 2023-06-22 18:46:57 +00:00
Joaquim VergesandGitHub 6aa6f7e0bd [SDK] fix maxId in getAll for Open Edition contracts (#1223) 2023-06-22 03:42:24 +00:00
d4d9550713 [React + SDK] Add get shared metadata (#1218)
Co-authored-by: Jonas Daniels <[email protected]>
2023-06-22 01:56:48 +00:00
iketwandGitHub 3cb298ac4b [RN/Wallets] Fix Coinbase Wallet connection rejection error (#1220) 2023-06-22 00:29:24 +00:00
Joaquim VergesandGitHub c747670b98 [SDK] Fix nextTokenIdToMint for open edition (#1219) 2023-06-22 00:08:55 +00:00
Joaquim VergesandGitHub c08e6ba988 [SDK] Fix claim counts for Open Edition contracts (#1216) 2023-06-21 23:49:27 +00:00
Manan TankandGitHub 60fb188943 [react] Fix safeWallet tree-shaking (#1212) 2023-06-21 20:17:13 +00:00
iketwandGitHub 1ce8558df4 [Wallets] Fix switchChain in WCV2 connector (#1214) 2023-06-21 16:28:16 +00:00
iketwandGitHub 3ce5f9a0c3 [RC/Wallets] Improve error messages for wc and auth (#1213) 2023-06-21 15:45:03 +00:00
3d615a62d0 [SDK] Code abstraction; import/export updates (#1188)
Co-authored-by: Manan Tank <[email protected]>
2023-06-21 14:40:12 +00:00
207 changed files with 49108 additions and 22207 deletions
+23
View File
@@ -1,5 +1,28 @@
# @thirdweb-dev/auth
## 3.2.4
### Patch Changes
- [#1250](https://github.com/thirdweb-dev/js/pull/1250) [`d43f6171`](https://github.com/thirdweb-dev/js/commit/d43f6171d910e31b748b171b012174390aac3fff) Thanks [@adam-maj](https://github.com/adam-maj)! - Allow setting login payload validity duration
- Updated dependencies [[`ac3e019c`](https://github.com/thirdweb-dev/js/commit/ac3e019cd1776dbdb0d06b213420ad17586f678e), [`3c5dc480`](https://github.com/thirdweb-dev/js/commit/3c5dc4804abc56b933ec45e9e1da11eb182296cc)]:
- @thirdweb-dev/wallets@1.0.0
## 3.2.3
### Patch Changes
- Updated dependencies [[`536b0f12`](https://github.com/thirdweb-dev/js/commit/536b0f1240ab446aac22cf547a4e09e73ee6bf7b), [`b626782b`](https://github.com/thirdweb-dev/js/commit/b626782b0e8c6b76673472d3aee1c802dfb11b5f)]:
- @thirdweb-dev/wallets@0.3.3
## 3.2.2
### Patch Changes
- Updated dependencies [[`3cb298ac`](https://github.com/thirdweb-dev/js/commit/3cb298ac4b04d295899b5ac77c7fc5869ec2f5f2), [`3ce5f9a0`](https://github.com/thirdweb-dev/js/commit/3ce5f9a0c3fc7e99b5abf691a87048ab8475f6b1), [`a388d07a`](https://github.com/thirdweb-dev/js/commit/a388d07a3d449e56dc53fed9600931022f4a15e1), [`1ce8558d`](https://github.com/thirdweb-dev/js/commit/1ce8558df47186bcba5ee8564fdb04583bf115dd), [`60fb1889`](https://github.com/thirdweb-dev/js/commit/60fb18894372f14d9cd815fa9a239926d31bb273)]:
- @thirdweb-dev/wallets@0.3.2
## 3.2.1
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.2.1",
"version": "3.2.4",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
@@ -25,6 +25,11 @@ export default async function handler(
version: ctx.authOptions?.version,
chainId: parsedPayload.data.chainId || ctx.authOptions?.chainId,
resources: ctx.authOptions?.resources,
expirationTime: ctx.authOptions?.loginPayloadDurationInSeconds
? new Date(
Date.now() + 1000 * ctx.authOptions.loginPayloadDurationInSeconds,
)
: undefined,
});
return res.status(200).json({ payload });
+1
View File
@@ -44,6 +44,7 @@ export type ThirdwebAuthConfig<
validateTokenId?:
| ((tokenId: string) => void)
| ((tokenId: string) => Promise<void>);
loginPayloadDurationInSeconds?: number;
tokenDurationInSeconds?: number;
refreshIntervalInSeconds?: number;
};
+5
View File
@@ -25,6 +25,11 @@ export default async function handler(
version: ctx.authOptions?.version,
chainId: parsedPayload.data.chainId || ctx.authOptions?.chainId,
resources: ctx.authOptions?.resources,
expirationTime: ctx.authOptions?.loginPayloadDurationInSeconds
? new Date(
Date.now() + 1000 * ctx.authOptions.loginPayloadDurationInSeconds,
)
: undefined,
});
return res.status(200).json({ payload });
+1
View File
@@ -55,6 +55,7 @@ export type ThirdwebAuthConfig<
validateTokenId?:
| ((tokenId: string) => void)
| ((tokenId: string) => Promise<void>);
loginPayloadDurationInSeconds?: number;
tokenDurationInSeconds?: number;
refreshIntervalInSeconds?: number;
};
+20
View File
@@ -1,5 +1,25 @@
# @thirdweb-dev/chains
## 0.1.25
### Patch Changes
- [#1248](https://github.com/thirdweb-dev/js/pull/1248) [`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - update chains
- [#1243](https://github.com/thirdweb-dev/js/pull/1243) [`0fd8aa04`](https://github.com/thirdweb-dev/js/commit/0fd8aa04a9424497758d13a51a72363edcc30e19) Thanks [@therealharpaljadeja](https://github.com/therealharpaljadeja)! - update chains
## 0.1.24
### Patch Changes
- [#1241](https://github.com/thirdweb-dev/js/pull/1241) [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea) Thanks [@nkrishang](https://github.com/nkrishang)! - Use fn getAllAccounts instead of event logs AccountCreated
## 0.1.23
### Patch Changes
- [#1229](https://github.com/thirdweb-dev/js/pull/1229) [`6816219a`](https://github.com/thirdweb-dev/js/commit/6816219ac13ae571a0c90db6ab389c319bc1f052) Thanks [@jnsdls](https://github.com/jnsdls)! - add/update chains
## 0.1.22
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
import type { Chain } from "../src/types";
export default {
"name": "Optimism",
"name": "OP Mainnet",
"chain": "ETH",
"rpc": [
"https://optimism.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
+36
View File
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "BRC Chain Mainnet",
"chain": "BRC",
"rpc": [
"https://brc-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.brcchain.io"
],
"faucets": [
"https://faucet.brcchain.io"
],
"nativeCurrency": {
"name": "BRC Chain mainnet native token",
"symbol": "BRC",
"decimals": 18
},
"infoURL": "https://bridge.brcchain.io",
"shortName": "BRC",
"chainId": 12123,
"networkId": 12123,
"icon": {
"url": "ipfs://QmX8qGX7xoZqYUpHxA85uZwQX2fgbTHvmddE1NfseDyBED",
"width": 512,
"height": 512,
"format": "png"
},
"explorers": [
{
"name": "BRC Chain Explorer",
"url": "https://scan.brcchain.io",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "brc-chain"
} as const satisfies Chain;
+2 -2
View File
@@ -4,7 +4,7 @@ export default {
"chain": "ATH",
"rpc": [
"https://atheios.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://wallet.atheios.com:8797"
"https://rpc.atheios.org/"
],
"faucets": [],
"nativeCurrency": {
@@ -12,7 +12,7 @@ export default {
"symbol": "ATH",
"decimals": 18
},
"infoURL": "https://atheios.com",
"infoURL": "https://atheios.org",
"shortName": "ath",
"chainId": 1620,
"networkId": 11235813,
-51
View File
@@ -1,51 +0,0 @@
import type { Chain } from "../src/types";
export default {
"name": "Horizen Yuma Testnet",
"shortName": "Yuma",
"chain": "Yuma",
"icon": {
"url": "ipfs://QmSFMBk3rMyu45Sy9KQHjgArFj4HdywANNYrSosLMUdcti",
"width": 1213,
"height": 1213,
"format": "png"
},
"rpc": [
"https://horizen-yuma-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://yuma-testnet.horizenlabs.io/ethv1"
],
"features": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
}
],
"faucets": [
"https://yuma-testnet-faucet.horizen.io"
],
"nativeCurrency": {
"name": "Testnet Zen",
"symbol": "tZEN",
"decimals": 18
},
"infoURL": "https://horizen.io/",
"chainId": 1662,
"networkId": 1662,
"slip44": 121,
"explorers": [
{
"name": "Yuma Testnet Block Explorer",
"url": "https://yuma-explorer.horizen.io",
"icon": {
"url": "ipfs://QmSFMBk3rMyu45Sy9KQHjgArFj4HdywANNYrSosLMUdcti",
"width": 1213,
"height": 1213,
"format": "png"
},
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "horizen-yuma-testnet"
} as const satisfies Chain;
+2 -1
View File
@@ -11,7 +11,8 @@ export default {
},
"rpc": [
"https://horizen-gobi-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://gobi-testnet.horizenlabs.io/ethv1"
"https://gobi-testnet.horizenlabs.io/ethv1",
"https://rpc.ankr.com/horizen_testnet_evm"
],
"features": [
{
+37
View File
@@ -0,0 +1,37 @@
import type { Chain } from "../src/types";
export default {
"name": "Pego Network",
"chain": "PEGO",
"rpc": [
"https://pego-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://pegorpc.com",
"https://node1.pegorpc.com",
"https://node2.pegorpc.com",
"https://node3.pegorpc.com"
],
"faucets": [],
"nativeCurrency": {
"name": "Pego Native Token",
"symbol": "PG",
"decimals": 18
},
"infoURL": "https://pego.network",
"shortName": "pg",
"chainId": 20201022,
"networkId": 20201022,
"icon": {
"url": "ipfs://QmVf1afskRHuZjFSLCZH8397KrVNAoYgyAePX9VMBrPVtx",
"width": 246,
"height": 247,
"format": "png"
},
"explorers": [
{
"name": "Pego Network Explorer",
"url": "https://scan.pego.network",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "pego-network"
} as const satisfies Chain;
+40
View File
@@ -0,0 +1,40 @@
import type { Chain } from "../src/types";
export default {
"name": "Peperium Chain Testnet",
"chain": "PERIUM",
"rpc": [
"https://peperium-chain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc-testnet.peperium.io"
],
"faucets": [],
"nativeCurrency": {
"name": "Peperium Chain Testnet",
"symbol": "PERIUM",
"decimals": 18
},
"infoURL": "https://peperium.io",
"shortName": "PERIUM",
"chainId": 4001,
"networkId": 4001,
"icon": {
"url": "ipfs://Qmag2hr5DQghRzKPN3oUFBkjWzqd5CndQzZeb5LfoiMCXf",
"width": 160,
"height": 160,
"format": "png"
},
"explorers": [
{
"name": "Peperium Chain Explorer",
"url": "https://scan-testnet.peperium.io",
"icon": {
"url": "ipfs://Qmag2hr5DQghRzKPN3oUFBkjWzqd5CndQzZeb5LfoiMCXf",
"width": 160,
"height": 160,
"format": "png"
},
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "peperium-chain-testnet"
} as const satisfies Chain;
+24
View File
@@ -0,0 +1,24 @@
import type { Chain } from "../src/types";
export default {
"name": "Omega Mainnet",
"chain": "OmegaNetwork",
"shortName": "OmegaNetwork",
"chainId": 408,
"testnet": false,
"icon": {
"format": "png",
"url": "ipfs://bafkreig676zxfhwhcx5bvvvjxedx6ftr2wq4iiznrwm3c6ozrprbc4oxwm",
"height": 512,
"width": 512
},
"rpc": [
"https://omega.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet-rpc.omtch.com"
],
"nativeCurrency": {
"name": "Omega Network Coin",
"symbol": "OMN",
"decimals": 18
},
"slug": "omega"
} as const satisfies Chain;
+9 -4
View File
@@ -12,15 +12,20 @@ export default {
},
"rpc": [
"https://celo-alfajores-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://alfajores-forno.celo-testnet.org",
"wss://alfajores-forno.celo-testnet.org/ws"
"wss://alfajores-forno.celo-testnet.org/ws",
"https://alfajores-forno.celo-testnet.org"
],
"faucets": [
"https://celo.org/developers/faucet",
"https://cauldron.pretoriaresearchlab.io/alfajores-faucet"
"https://cauldron.pretoriaresearchlab.io/alfajores-faucet",
"https://celo.org/developers/faucet"
],
"infoURL": "https://docs.celo.org/",
"explorers": [
{
"name": "Celoscan",
"url": "https://alfajores.celoscan.io/",
"standard": "EIP3091"
},
{
"name": "Celoscan",
"url": "https://celoscan.io",
+35
View File
@@ -0,0 +1,35 @@
import type { Chain } from "../src/types";
export default {
"name": "opBNB",
"chain": "opBNB",
"shortName": "opBNB",
"chainId": 5611,
"testnet": true,
"nativeCurrency": {
"name": "Testnet bnb",
"symbol": "Tbnb",
"decimals": 18
},
"rpc": [
"https://opbnb.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://opbnb-testnet-rpc.bnbchain.org"
],
"explorers": [
{
"name": "opBNB Scan",
"url": "https://opbnbscan.com/",
"standard": ""
}
],
"faucets": [
"https://opbnb-testnet-bridge.bnbchain.org/"
],
"infoURL": "https://docs.bnbchain.org/",
"icon": {
"url": "ipfs://QmfFvfFsQKby3M32uqr8T55ENBnTHL8bkdeeu6rYVL2n4z/opbnblogo.svg",
"height": 512,
"width": 512,
"format": "svg"
},
"slug": "opbnb"
} as const satisfies Chain;
+2 -1
View File
@@ -5,7 +5,8 @@ export default {
"rpc": [
"https://rollux.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.rollux.com",
"wss://rpc.rollux.com/wss"
"wss://rpc.rollux.com/wss",
"https://rpc.ankr.com/rollux/${ANKR_API_KEY}"
],
"faucets": [
"https://rollux.id/faucetapp"
+1 -1
View File
@@ -4,7 +4,7 @@ export default {
"chain": "ETC",
"rpc": [
"https://ethereum-classic.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://www.ethercluster.com/etc"
"https://etc.rivet.link"
],
"faucets": [
"https://free-online-app.com/faucet-for-eth-evm-chains/?"
+1 -1
View File
@@ -4,7 +4,7 @@ export default {
"chain": "ETC",
"rpc": [
"https://ethereum-classic-testnet-mordor.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://www.ethercluster.com/mordor"
"https://rpc.mordor.etccooperative.org"
],
"faucets": [],
"nativeCurrency": {
+12 -12
View File
@@ -4,7 +4,7 @@ export default {
"chain": "ETH",
"rpc": [
"https://zora.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.zora.co/"
"https://rpc.zora.energy/"
],
"faucets": [],
"nativeCurrency": {
@@ -12,23 +12,23 @@ export default {
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://zora.co",
"shortName": "zora",
"chainId": 7777777,
"networkId": 7777777,
"explorers": [
{
"name": "Zora Network Explorer",
"url": "https://explorer.zora.co",
"standard": "EIP3091"
}
],
"icon": {
"url": "ipfs://QmZ6qaRwTPFEZUspwMUjaxC6KhmzcELdRQcQzS3P72Dzts/Vector.svg",
"height": 512,
"width": 512,
"format": "svg"
},
"infoURL": "https://zora.energy",
"shortName": "zora",
"chainId": 7777777,
"networkId": 7777777,
"explorers": [
{
"name": "Zora Network Explorer",
"url": "https://explorer.zora.energy",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "zora"
} as const satisfies Chain;
+27
View File
@@ -2,6 +2,12 @@ import type { Chain } from "../src/types";
export default {
"name": "Patex",
"chain": "ETH",
"icon": {
"url": "ipfs://QmTNTSNn3t5WpSEzQmUYbkxYkBKaH6QahyVdVrRKyPHChr",
"width": 800,
"height": 800,
"format": "png"
},
"rpc": [
"https://patex.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.patex.io/"
@@ -12,10 +18,31 @@ export default {
"symbol": "ETH",
"decimals": 18
},
"features": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
}
],
"infoURL": "https://patex.io/",
"shortName": "peth",
"chainId": 789,
"networkId": 789,
"explorers": [
{
"name": "patexscan",
"url": "https://patexscan.io",
"icon": {
"url": "ipfs://QmTNTSNn3t5WpSEzQmUYbkxYkBKaH6QahyVdVrRKyPHChr",
"width": 800,
"height": 800,
"format": "png"
},
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "patex"
} as const satisfies Chain;
+15 -19
View File
@@ -1,39 +1,35 @@
import type { Chain } from "../src/types";
export default {
"name": "Shardeum Liberty 2.X",
"name": "Shardeum Sphinx DApp 1.X",
"shortName": "Sphinx",
"chain": "Shardeum",
"chainId": 8081,
"icon": {
"url": "ipfs://Qma1bfuubpepKn7DLDy4NPSKDeT3S4VPCNhu6UmdGrb6YD",
"width": 609,
"height": 533,
"height": 1200,
"width": 1200,
"url": "ipfs://QmQWzHUy4kmk1eGksDREGQL3GWrssdAPBxHt4aKGAFHSfJ",
"format": "png"
},
"rpc": [
"https://shardeum-liberty-2-x.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://liberty20.shardeum.org/"
],
"faucets": [
"https://faucet.liberty20.shardeum.org"
"https://shardeum-sphinx-dapp-1-x.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://dapps.shardeum.org/sphinx"
],
"nativeCurrency": {
"name": "Shardeum SHM",
"name": "Shardeum",
"symbol": "SHM",
"decimals": 18
},
"infoURL": "https://docs.shardeum.org/",
"shortName": "Liberty20",
"chainId": 8081,
"networkId": 8081,
"explorers": [
{
"name": "Shardeum Scan",
"url": "https://explorer-liberty20.shardeum.org",
"url": "https://explorer-dapps.shardeum.org",
"standard": "EIP3091"
}
],
"redFlags": [
"reusedChainId"
"faucets": [
"https://faucet-dapps.shardeum.org/"
],
"testnet": false,
"slug": "shardeum-liberty-2-x"
"infoURL": "https://docs.shardeum.org/",
"testnet": true,
"slug": "shardeum-sphinx-dapp-1-x"
} as const satisfies Chain;
+23
View File
@@ -0,0 +1,23 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "Omega Mainnet",
chain: "OmegaNetwork",
shortName: "OmegaNetwork",
chainId: 408,
testnet: false,
icon: {
format: "png",
url: "ipfs://bafkreig676zxfhwhcx5bvvvjxedx6ftr2wq4iiznrwm3c6ozrprbc4oxwm",
height: 512,
width: 512,
},
rpc: ["https://mainnet-rpc.omtch.com"],
nativeCurrency: {
name: "Omega Network Coin",
symbol: "OMN",
decimals: 18,
},
};
+32
View File
@@ -0,0 +1,32 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "opBNB",
chain: "opBNB",
shortName: "opBNB",
chainId: 5611,
testnet: true,
nativeCurrency: {
name: "Testnet bnb",
symbol: "Tbnb",
decimals: 18,
},
rpc: ["https://opbnb-testnet-rpc.bnbchain.org"],
explorers: [
{
name: "opBNB Scan",
url: "https://opbnbscan.com/",
standard: "",
},
],
faucets: ["https://opbnb-testnet-bridge.bnbchain.org/"],
infoURL: "https://docs.bnbchain.org/",
icon: {
url: "ipfs://QmfFvfFsQKby3M32uqr8T55ENBnTHL8bkdeeu6rYVL2n4z/opbnblogo.svg",
height: 512,
width: 512,
format: "svg",
},
};
+32
View File
@@ -0,0 +1,32 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "Shardeum Sphinx DApp 1.X",
shortName: "Sphinx",
chain: "Shardeum",
chainId: 8081,
icon: {
height: 1200,
width: 1200,
url: "ipfs://QmQWzHUy4kmk1eGksDREGQL3GWrssdAPBxHt4aKGAFHSfJ",
format: "png",
},
rpc: ["https://dapps.shardeum.org/sphinx"],
nativeCurrency: {
name: "Shardeum",
symbol: "SHM",
decimals: 18,
},
explorers: [
{
name: "Shardeum Scan",
url: "https://explorer-dapps.shardeum.org",
standard: "EIP3091",
},
],
faucets: ["https://faucet-dapps.shardeum.org/"],
infoURL: "https://docs.shardeum.org/",
testnet: true,
};
+13
View File
@@ -0,0 +1,13 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Partial<Chain>} */
export default {
explorers: [
{
name: "Celoscan",
url: "https://alfajores.celoscan.io/",
standard: "EIP3091",
},
],
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/chains",
"version": "0.1.22",
"version": "0.1.25",
"main": "dist/thirdweb-dev-chains.cjs.js",
"module": "dist/thirdweb-dev-chains.esm.js",
"browser": {
@@ -146,6 +146,10 @@ function findSlug(chain) {
if (slug === "base-goerli-testnet") {
slug = "base-goerli";
}
// optimisim rename handling
if (slug === "op") {
slug = "optimism";
}
// end special cases
takenSlugs[slug] = true;
File diff suppressed because one or more lines are too long
+27
View File
@@ -1,5 +1,32 @@
# thirdweb
## 0.10.27
### Patch Changes
- Updated dependencies [[`ef4cb092`](https://github.com/thirdweb-dev/js/commit/ef4cb092192c58c9b292b29590b888f45f9fd23d), [`30ac3aef`](https://github.com/thirdweb-dev/js/commit/30ac3aef840bde51a61acf786c709cffd3c47354), [`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087), [`0fd8aa04`](https://github.com/thirdweb-dev/js/commit/0fd8aa04a9424497758d13a51a72363edcc30e19)]:
- @thirdweb-dev/sdk@3.10.26
- @thirdweb-dev/chains@0.1.25
## 0.10.26
### Patch Changes
- [#1240](https://github.com/thirdweb-dev/js/pull/1240) [`1c7264b4`](https://github.com/thirdweb-dev/js/commit/1c7264b40330d068ece67df537a0f5db0f6aedca) Thanks [@Marfuen](https://github.com/Marfuen)! - Small bug fix for updating packages using --nightly
- Updated dependencies [[`d498c79a`](https://github.com/thirdweb-dev/js/commit/d498c79a911d478077dfb8a2490eb1bf91523186), [`0c5b03b8`](https://github.com/thirdweb-dev/js/commit/0c5b03b8d6cc6a4e69bb2a4647d3626e69f1283c), [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea)]:
- @thirdweb-dev/sdk@3.10.25
- @thirdweb-dev/storage@1.1.5
- @thirdweb-dev/chains@0.1.24
## 0.10.25
### Patch Changes
- Updated dependencies [[`6816219a`](https://github.com/thirdweb-dev/js/commit/6816219ac13ae571a0c90db6ab389c319bc1f052), [`48065bcd`](https://github.com/thirdweb-dev/js/commit/48065bcd91c13e1f44d54343b5c6c2646b9e86e4), [`6aa6f7e0`](https://github.com/thirdweb-dev/js/commit/6aa6f7e0bd2313e2e1ad96dd41aad91e6694d380), [`f7f4f207`](https://github.com/thirdweb-dev/js/commit/f7f4f20737ac5d78424ca9c91220f00b85adde6b), [`d4d95507`](https://github.com/thirdweb-dev/js/commit/d4d95507130b2b5408bfaa73ef3b708ca00c773e), [`483e2b91`](https://github.com/thirdweb-dev/js/commit/483e2b910934d75276a68bae64d04c47cd7d57e3), [`c08e6ba9`](https://github.com/thirdweb-dev/js/commit/c08e6ba988ad97aa27d5868cec8abe3498d07a0a), [`3d615a62`](https://github.com/thirdweb-dev/js/commit/3d615a62d0a6801f6fb0e63f9b95c2f98446add1)]:
- @thirdweb-dev/chains@0.1.23
- @thirdweb-dev/sdk@3.10.24
## 0.10.24
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.10.24",
"version": "0.10.27",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+5 -5
View File
@@ -1,8 +1,8 @@
import * as toml from "@iarna/toml";
import { PackageManagerType } from "../core/types/ProjectType";
import { existsSync, readFileSync } from "fs";
import { runCommand } from "../create/helpers/run-command";
import path from "path";
import { PackageManagerType } from "../core/types/ProjectType";
import { runCommand } from "../create/helpers/run-command";
import { IProcessAppTypeArgs, IProcessContractAppTypeArgs } from "./types";
export function convertDependenciesToStringFormat(dependenciesObject: object) {
@@ -174,7 +174,7 @@ export const installOrUpdate = async (packageManager: PackageManagerType, depend
case "npm":
runner = "npm";
installCommand = ["install"];
updateCommand = ["update"]
updateCommand = ["install", "--legacy-peer-deps"]
break;
case "yarn":
runner = "yarn";
@@ -223,7 +223,7 @@ export const installOrUpdate = async (packageManager: PackageManagerType, depend
}
if (typeOfAction === "install") {
if (!dependenciesToAdd.length) {return;}
if (!dependenciesToAdd.length) { return; }
const commands = [...installCommand, ...dependenciesToAdd];
await runCommand(runner, commands, printLogs);
@@ -233,7 +233,7 @@ export const installOrUpdate = async (packageManager: PackageManagerType, depend
}
}
if (typeOfAction === "update") {
if (!dependenciesToUpdate.length) {return;}
if (!dependenciesToUpdate.length) { return; }
const commands = [...updateCommand, ...dependenciesToUpdate];
await runCommand(runner, commands, printLogs);
}
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/contracts-js
## 1.3.7
### Patch Changes
- [#1241](https://github.com/thirdweb-dev/js/pull/1241) [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea) Thanks [@nkrishang](https://github.com/nkrishang)! - Use fn getAllAccounts instead of event logs AccountCreated
## 1.3.6
### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/contracts-js",
"version": "1.3.6",
"version": "1.3.7",
"main": "dist/thirdweb-dev-contracts-js.cjs.js",
"module": "dist/thirdweb-dev-contracts-js.esm.js",
"browser": {
@@ -10,7 +10,7 @@
"license": "Apache-2.0",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
"dependencies": {
"@thirdweb-dev/contracts": "3.5.7"
"@thirdweb-dev/contracts": "3.5.9"
},
"devDependencies": {
"@babel/preset-env": "^7.18.10",
+1 -1
View File
@@ -17,7 +17,7 @@ module.exports = {
// import rules
"import/first": "error",
"import/newline-after-import": "error",
"import/no-cycle": "warn",
"import/no-cycle": "error",
"import/no-useless-path-segments": "error",
//eslint
+46
View File
@@ -1,5 +1,51 @@
# @thirdweb-dev/react-core
## 3.14.4
### Patch Changes
- [#1227](https://github.com/thirdweb-dev/js/pull/1227) [`06ca1c40`](https://github.com/thirdweb-dev/js/commit/06ca1c407dfee9d3d1fdaed1b6223ad0f9b8857b) Thanks [@nkrishang](https://github.com/nkrishang)! - Add react hooks for smart wallet
- [#1248](https://github.com/thirdweb-dev/js/pull/1248) [`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Export account hooks
- [#1253](https://github.com/thirdweb-dev/js/pull/1253) [`ad7dae3b`](https://github.com/thirdweb-dev/js/commit/ad7dae3b163e61c7a6eb57f654885a7fdaa4cbb6) Thanks [@rattrayd11](https://github.com/rattrayd11)! - Stop using useActiveChain deprecated hook
- Updated dependencies [[`ef4cb092`](https://github.com/thirdweb-dev/js/commit/ef4cb092192c58c9b292b29590b888f45f9fd23d), [`ac3e019c`](https://github.com/thirdweb-dev/js/commit/ac3e019cd1776dbdb0d06b213420ad17586f678e), [`30ac3aef`](https://github.com/thirdweb-dev/js/commit/30ac3aef840bde51a61acf786c709cffd3c47354), [`3c5dc480`](https://github.com/thirdweb-dev/js/commit/3c5dc4804abc56b933ec45e9e1da11eb182296cc), [`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087), [`0fd8aa04`](https://github.com/thirdweb-dev/js/commit/0fd8aa04a9424497758d13a51a72363edcc30e19)]:
- @thirdweb-dev/sdk@3.10.26
- @thirdweb-dev/wallets@1.0.0
- @thirdweb-dev/chains@0.1.25
## 3.14.3
### Patch Changes
- [#1235](https://github.com/thirdweb-dev/js/pull/1235) [`1d76334d`](https://github.com/thirdweb-dev/js/commit/1d76334dd3884703629835422f241d2825128f6f) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Fix required type for address on useSmartWalletsForAddress
- [#1241](https://github.com/thirdweb-dev/js/pull/1241) [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea) Thanks [@nkrishang](https://github.com/nkrishang)! - Use fn getAllAccounts instead of event logs AccountCreated
- Updated dependencies [[`536b0f12`](https://github.com/thirdweb-dev/js/commit/536b0f1240ab446aac22cf547a4e09e73ee6bf7b), [`b626782b`](https://github.com/thirdweb-dev/js/commit/b626782b0e8c6b76673472d3aee1c802dfb11b5f), [`d498c79a`](https://github.com/thirdweb-dev/js/commit/d498c79a911d478077dfb8a2490eb1bf91523186), [`0c5b03b8`](https://github.com/thirdweb-dev/js/commit/0c5b03b8d6cc6a4e69bb2a4647d3626e69f1283c), [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea)]:
- @thirdweb-dev/wallets@0.3.3
- @thirdweb-dev/sdk@3.10.25
- @thirdweb-dev/storage@1.1.5
- @thirdweb-dev/chains@0.1.24
## 3.14.2
### Patch Changes
- [#1230](https://github.com/thirdweb-dev/js/pull/1230) [`b5e1d3bb`](https://github.com/thirdweb-dev/js/commit/b5e1d3bb2b82785d6d3e5c899d27691bdb638625) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Add useSmartWalletsForAddress hook
- [#1224](https://github.com/thirdweb-dev/js/pull/1224) [`f7f4f207`](https://github.com/thirdweb-dev/js/commit/f7f4f20737ac5d78424ca9c91220f00b85adde6b) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Better return type for get shared metadata
- [#1213](https://github.com/thirdweb-dev/js/pull/1213) [`3ce5f9a0`](https://github.com/thirdweb-dev/js/commit/3ce5f9a0c3fc7e99b5abf691a87048ab8475f6b1) Thanks [@iketw](https://github.com/iketw)! - [ReactCore/Wallets] Improve error messages for wc and auth
- [#1218](https://github.com/thirdweb-dev/js/pull/1218) [`d4d95507`](https://github.com/thirdweb-dev/js/commit/d4d95507130b2b5408bfaa73ef3b708ca00c773e) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Add get for shared metadata
- Updated dependencies [[`6816219a`](https://github.com/thirdweb-dev/js/commit/6816219ac13ae571a0c90db6ab389c319bc1f052), [`48065bcd`](https://github.com/thirdweb-dev/js/commit/48065bcd91c13e1f44d54343b5c6c2646b9e86e4), [`3cb298ac`](https://github.com/thirdweb-dev/js/commit/3cb298ac4b04d295899b5ac77c7fc5869ec2f5f2), [`6aa6f7e0`](https://github.com/thirdweb-dev/js/commit/6aa6f7e0bd2313e2e1ad96dd41aad91e6694d380), [`f7f4f207`](https://github.com/thirdweb-dev/js/commit/f7f4f20737ac5d78424ca9c91220f00b85adde6b), [`3ce5f9a0`](https://github.com/thirdweb-dev/js/commit/3ce5f9a0c3fc7e99b5abf691a87048ab8475f6b1), [`d4d95507`](https://github.com/thirdweb-dev/js/commit/d4d95507130b2b5408bfaa73ef3b708ca00c773e), [`a388d07a`](https://github.com/thirdweb-dev/js/commit/a388d07a3d449e56dc53fed9600931022f4a15e1), [`1ce8558d`](https://github.com/thirdweb-dev/js/commit/1ce8558df47186bcba5ee8564fdb04583bf115dd), [`483e2b91`](https://github.com/thirdweb-dev/js/commit/483e2b910934d75276a68bae64d04c47cd7d57e3), [`c08e6ba9`](https://github.com/thirdweb-dev/js/commit/c08e6ba988ad97aa27d5868cec8abe3498d07a0a), [`60fb1889`](https://github.com/thirdweb-dev/js/commit/60fb18894372f14d9cd815fa9a239926d31bb273), [`3d615a62`](https://github.com/thirdweb-dev/js/commit/3d615a62d0a6801f6fb0e63f9b95c2f98446add1)]:
- @thirdweb-dev/chains@0.1.23
- @thirdweb-dev/sdk@3.10.24
- @thirdweb-dev/wallets@0.3.2
## 3.14.1
### Patch Changes
+1 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "3.14.1",
"version": "3.14.4",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -113,10 +113,6 @@
"ethers": ">=5.5.1",
"react": ">=18.0.0"
},
"resolutions": {
"ansi-regex": "^6.0.1",
"typescript": "^4.6.2"
},
"peerDependenciesMeta": {
"@solana/web3.js": {
"optional": true
@@ -1,6 +1,6 @@
import { Chain, defaultChains } from "@thirdweb-dev/chains";
import { useCallback, useState } from "react";
import { useActiveChain, useChainId } from "../../evm/hooks/wallet";
import { useChain, useChainId } from "../../evm/hooks/wallet";
import { useSupportedChains } from "../../evm/hooks/useSupportedChains";
import { useSwitchChain, useWallet } from "./wallet-hooks";
import { assertWindowEthereum, walletIds } from "@thirdweb-dev/wallets";
@@ -29,7 +29,7 @@ type NetworkMetadata = {
/**
*
* @deprecated - use `useActiveChain`, `useSwitchChain`, `useChainId` instead
* @deprecated - use `useChain`, `useSwitchChain`, `useChainId` instead
*
* Hook for getting metadata about the network the current wallet is connected to and switching networks
*
@@ -55,7 +55,7 @@ type NetworkMetadata = {
* @public
*/
export function useNetwork(): [NetworkMetadata, SwitchNetwork | undefined] {
const chain = useActiveChain();
const chain = useChain();
const chainId = useChainId();
const switchChain = useSwitchChain();
const supportedChains = useSupportedChains();
@@ -52,7 +52,7 @@ function ChangeActiveWalletOnAccountSwitch() {
try {
await switchAccount(data.address);
} catch (err) {
console.warn(
console.debug(
`[Auth] Failed to switch account to ${data.address} with error:\n`,
err,
);
@@ -63,7 +63,7 @@ function ChangeActiveWalletOnAccountSwitch() {
try {
await logout();
} catch (err) {
console.warn(`[Auth] Failed to logout with error:\n`, err);
console.debug(`[Auth] Failed to logout with error:\n`, err);
}
};
@@ -504,7 +504,7 @@ export function useEnglishAuctionWinningBid(
) {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.marketplace.auction.getWinningBid(
cacheKeys.contract.marketplace.englishAuctions.getWinningBid(
contractAddress,
auctionId,
),
@@ -596,7 +596,7 @@ export function useBidBuffer(
) {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.marketplace.getBidBufferBps(contractAddress),
cacheKeys.contract.marketplace.auction.getBidBufferBps(contractAddress, listingId),
() => {
requiredParamInvariant(contract, "No Contract instance provided");
@@ -647,7 +647,7 @@ export function useMinimumNextBid(
) {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.marketplace.auction.getWinner(
cacheKeys.contract.marketplace.auction.getMinimumNextBid(
contractAddress,
listingId,
),
+39 -4
View File
@@ -24,6 +24,7 @@ import {
useMutation,
UseMutationResult,
useQueryClient,
UseQueryResult,
} from "@tanstack/react-query";
import { Erc1155, QueryAllParams, NFT } from "@thirdweb-dev/sdk";
import { BigNumber, BigNumberish, providers } from "ethers";
@@ -319,6 +320,44 @@ export function useNFTBalance(
);
}
/**
* Get the shared metadata of an Open Edition NFT contract
*
* @example
* ```javascript
* const { data: sharedMetadata, isLoading, error } = useSharedMetadata(contract);
* ```
*
* @param contract - an instance of a {@link NFTContract}
* @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>,
): UseQueryResult<BasicNFTInput | undefined> {
const contractAddress = contract?.getAddress();
const { erc721 } = getErcs(contract);
return useQueryWithNetwork(
cacheKeys.contract.nft.sharedMetadata.get(contractAddress),
() => {
requiredParamInvariant(contract, "No Contract instance provided");
if (erc721) {
invariant(
erc721.sharedMetadata.get,
"Contract instance does not support sharedMetadata.get",
);
return erc721.sharedMetadata.get();
}
invariant(false, "Unknown NFT type");
},
{
enabled: !!contract,
},
);
}
/** **********************/
/** WRITE HOOKS **/
/** **********************/
@@ -605,10 +644,6 @@ export function useAirdropNFT(contract: Erc1155) {
);
}
/** **********************/
/** WRITE HOOKS **/
/** **********************/
/**
* Burn an NFT
*
@@ -14,14 +14,10 @@ import {
useQueryClient,
UseQueryResult,
} from "@tanstack/react-query";
import type {
AccountEvent, SmartContract,
} from "@thirdweb-dev/sdk";
import type { AccountEvent, SmartContract } from "@thirdweb-dev/sdk";
import type { BytesLike } from "ethers";
import invariant from "tiny-invariant";
/** **********************/
/** READ HOOKS **/
/** **********************/
@@ -41,7 +37,7 @@ import invariant from "tiny-invariant";
* @beta
*/
export function useSmartWallets(
contract: RequiredParam<SmartContract>
contract: RequiredParam<SmartContract>,
): UseQueryResult<AccountEvent[]> {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
@@ -49,10 +45,46 @@ export function useSmartWallets(
() => {
requiredParamInvariant(contract, "No Contract instance provided");
invariant(
contract.smartWalletFactory.getAllWallets,
"Contract instance does not support contract.smartWalletFactory.getAllWallets",
contract.smartWalletFactory.getAllAccounts,
"Contract instance does not support contract.smartWalletFactory.getAllAccounts",
);
return contract.smartWalletFactory.getAllWallets();
return contract.smartWalletFactory.getAllAccounts();
},
{ enabled: !!contract },
);
}
/**
* Get all wallets associated with the provided address
*
* @example
* ```javascript
* const { data: smartWalletsForAddress, isLoading, error } = useSmartWalletsForAddress(contract, "{{wallet_address}}");
* ```
*
* @param contract - an instance of a smart wallet factory contract
* @returns a response object that includes an array of all smart wallets associated with the adress
* @twfeature SmartWalletFactory
* @see {@link https://portal.thirdweb.com/react/react.usesmartwalletsforaddress?utm_source=sdk | Documentation}
* @beta
*/
export function useSmartWalletsForAddress(
contract: RequiredParam<SmartContract>,
address: RequiredParam<WalletAddress>,
): UseQueryResult<string[]> {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.smartWalletFactory.getAllForAddress(
contractAddress,
address,
),
() => {
requiredParamInvariant(contract, "No Contract instance provided");
invariant(
contract.smartWalletFactory.getAssociatedWallets,
"Contract instance does not support contract.smartWalletFactory.getAssociatedWallets",
);
return contract.smartWalletFactory.getAssociatedWallets(address || "");
},
{ enabled: !!contract },
);
@@ -79,7 +111,10 @@ export function useIsSmartWalletDeployed(
): UseQueryResult<boolean> {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.smartWalletFactory.isSmartWalletDeployed(contractAddress, admin),
cacheKeys.contract.smartWalletFactory.isSmartWalletDeployed(
contractAddress,
admin,
),
() => {
requiredParamInvariant(contract, "No Contract instance provided");
invariant(
@@ -130,9 +165,7 @@ export function useIsSmartWalletDeployed(
* @see {@link https://portal.thirdweb.com/react/react.usecreatesmartwallet?utm_source=sdk | Documentation}
* @beta
*/
export function useCreateSmartWallet(
contract: RequiredParam<SmartContract>,
) {
export function useCreateSmartWallet(contract: RequiredParam<SmartContract>) {
const activeChainId = useSDKChainId();
const contractAddress = contract?.getAddress();
const queryClient = useQueryClient();
@@ -141,10 +174,7 @@ export function useCreateSmartWallet(
async (admin: string, extraData?: BytesLike) => {
requiredParamInvariant(contract, "contract is undefined");
return contract.smartWalletFactory.createWallet(
admin,
extraData,
);
return contract.smartWalletFactory.createWallet(admin, extraData);
},
{
onSettled: () =>
@@ -0,0 +1,125 @@
import type { providers } from "ethers";
import {
RequiredParam,
requiredParamInvariant,
} from "../../../core/query-utils/required-param";
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
import {
cacheKeys,
invalidateContractAndBalances,
} from "../../utils/cache-keys";
import { useQueryWithNetwork } from "../query-utils/useQueryWithNetwork";
import {
useMutation,
UseMutationResult,
useQueryClient,
UseQueryResult,
} from "@tanstack/react-query";
import type {
SignerWithRestrictions,
SignerWithRestrictionsBatchInput,
SmartContract,
} from "@thirdweb-dev/sdk";
import invariant from "tiny-invariant";
/** **********************/
/** READ HOOKS **/
/** **********************/
/**
* Get all wallets
*
* @example
* ```javascript
* const { data: smartWallets, isLoading, error } = useSmartWalletSigners(contract);
* ```
*
* @param contract - an instance of a smart wallet
* @returns a response object that includes an array of all signers of the provided smart wallet
* @twfeature SmartWallet
* @see {@link https://portal.thirdweb.com/react/react.usesmartwalletsigners?utm_source=sdk | Documentation}
* @beta
*/
export function useSmartWalletSigners(
contract: RequiredParam<SmartContract>,
): UseQueryResult<SignerWithRestrictions[]> {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.smartWallet.signers(contractAddress),
() => {
requiredParamInvariant(contract, "No Contract instance provided");
invariant(
contract.smartWallet.getSignersWithRestrictions,
"Contract instance does not support contract.smartWallet.getSignersWithRestrictions",
);
return contract.smartWallet.getSignersWithRestrictions();
},
{ enabled: !!contract },
);
}
/** **********************/
/** WRITE HOOKS **/
/** **********************/
/**
* Set the wallet's entire snapshot of permissions
*
* @example
* ```jsx
* const Component = () => {
* const { contract } = useContract("{{contract_address}}");
* const {
* mutate: setSmartWalletSigners,
* isLoading,
* error,
* } = useSetSmartWalletSigners(contract);
*
* if (error) {
* console.error("failed to set smart wallet signers", error);
* }
*
* return (
* <button
* disabled={isLoading}
* onClick={() => setSmartWalletSigners("0x...")}
* >
* Set Smart Wallet Signers
* </button>
* );
* };
* ```
*
* @param contract - an instance of a smart wallet contract
* @returns a mutation object that can be used to set the smart wallet signers
* @twfeature SmartWallet
* @see {@link https://portal.thirdweb.com/react/react.usesetsmartwalletsigners?utm_source=sdk | Documentation}
* @beta
*/
export function useSetSmartWalletSigners(
contract: RequiredParam<SmartContract>,
): UseMutationResult<
{ receipt: providers.TransactionReceipt },
unknown,
SignerWithRestrictionsBatchInput,
unknown
> {
const activeChainId = useSDKChainId();
const contractAddress = contract?.getAddress();
const queryClient = useQueryClient();
return useMutation(
async (permissionsSnapshot: SignerWithRestrictionsBatchInput) => {
requiredParamInvariant(contract, "contract is undefined");
return contract.smartWallet.setAccess(permissionsSnapshot);
},
{
onSettled: () =>
invalidateContractAndBalances(
queryClient,
contractAddress,
activeChainId,
),
},
);
}
+8
View File
@@ -167,6 +167,7 @@ export {
useTransferNFT,
useAirdropNFT,
useBurnNFT,
useSharedMetadata,
useSetSharedMetadata,
} from "./hooks/async/nft";
@@ -198,8 +199,15 @@ export {
useIsSmartWalletDeployed,
useSmartWallets,
useCreateSmartWallet,
useSmartWalletsForAddress,
} from "./hooks/async/smart-wallet-factory";
// smart wallet
export {
useSmartWalletSigners,
useSetSmartWalletSigners,
} from "./hooks/async/smart-wallet";
// thirdweb hooks (work as long as at least `<ThirdwebSdkProvider>` is used)
// auth hooks
+48 -13
View File
@@ -123,6 +123,13 @@ export const cacheKeys = {
createContractCacheKey(contractAddress, ["smartWalletFactory"]),
isSmartWalletDeployed: (contractAdress: RequiredParam<ContractAddress>, admin: RequiredParam<string>) =>
createContractCacheKey(contractAdress, ["isSmartWalletDeployed", admin]),
getAllForAddress: (contractAdress: RequiredParam<ContractAddress>, address: RequiredParam<string>) =>
createContractCacheKey(contractAdress, ["getAllForAddress", address]),
},
smartWallet: {
signers: (contractAddress: RequiredParam<ContractAddress>) =>
createContractCacheKey(contractAddress, ["smartWallet", "signers"]),
},
app: {
@@ -190,6 +197,14 @@ export const cacheKeys = {
]),
},
},
sharedMetadata: {
get: (
contractAddress: RequiredParam<ContractAddress>,
) =>
createContractCacheKey(
contractAddress
),
},
drop: {
getAllUnclaimed: (
contractAddress: RequiredParam<ContractAddress>,
@@ -263,10 +278,16 @@ export const cacheKeys = {
contractAddress,
params ? ["getActiveListings", params] : ["getActiveListings"],
),
getBidBufferBps: (contractAddress: RequiredParam<ContractAddress>) =>
createContractCacheKey(contractAddress, ["getBidBufferBps"]),
auction: {
getBidBufferBps: (
contractAddress: RequiredParam<ContractAddress>,
listingId: RequiredParam<BigNumberish>,
) =>
createContractCacheKey(contractAddress, [
"auction",
"getBidBufferBps",
{ listingId },
]),
getWinningBid: (
contractAddress: RequiredParam<ContractAddress>,
listingId: RequiredParam<BigNumberish>,
@@ -276,6 +297,15 @@ export const cacheKeys = {
"getWinningBid",
{ listingId },
]),
getMinimumNextBid: (
contractAddress: RequiredParam<ContractAddress>,
listingId: RequiredParam<BigNumberish>,
) =>
createContractCacheKey(contractAddress, [
"auction",
"getMinimumNextBid",
{ listingId },
]),
getWinner: (
contractAddress: RequiredParam<ContractAddress>,
listingId: RequiredParam<BigNumberish>,
@@ -295,8 +325,8 @@ export const cacheKeys = {
createContractCacheKey(
contractAddress,
params
? ["getAllDirectListings", params]
: ["getAllDirectListings"],
? ["directListings", "getAll", params]
: ["directListings", "getAll"],
),
getAllValid: (
contractAddress: RequiredParam<ContractAddress>,
@@ -305,20 +335,22 @@ export const cacheKeys = {
createContractCacheKey(
contractAddress,
params
? ["getAllValidDirectListings", params]
: ["getAllValidDirectListings"],
? ["directListings", "getAllValid", params]
: ["directListings", "getAllValid"],
),
getListing: (
contractAddress: RequiredParam<ContractAddress>,
listingId: RequiredParam<BigNumberish>,
) =>
createContractCacheKey(contractAddress, [
"directListings",
"getListing",
{ listingId },
]),
getTotalCount: (contractAddress: RequiredParam<ContractAddress>) =>
createContractCacheKey(contractAddress, [
"getTotalDirectListingsCount",
"directListings",
"getTotalCount",
]),
},
@@ -330,8 +362,8 @@ export const cacheKeys = {
createContractCacheKey(
contractAddress,
params
? ["getAllEnglishAuctions", params]
: ["getAllEnglishAuctions"],
? ["englishAuctions", "getAll", params]
: ["englishAuctions", "getAll"],
),
getAllValid: (
contractAddress: RequiredParam<ContractAddress>,
@@ -340,14 +372,15 @@ export const cacheKeys = {
createContractCacheKey(
contractAddress,
params
? ["getAllEValidEnglishAuctions", params]
: ["getAllEValidEnglishAuctions"],
? ["englishAuctions", "getAllValid", params]
: ["englishAuctions", "getAllValid"],
),
getAuction: (
contractAddress: RequiredParam<ContractAddress>,
auctionId: RequiredParam<BigNumberish>,
) =>
createContractCacheKey(contractAddress, [
"englishAuctions",
"getAuction",
{ auctionId },
]),
@@ -356,12 +389,14 @@ export const cacheKeys = {
auctionId: RequiredParam<BigNumberish>,
) =>
createContractCacheKey(contractAddress, [
"englishAuctions",
"getWinningBid",
{ auctionId },
]),
getTotalCount: (contractAddress: RequiredParam<ContractAddress>) =>
createContractCacheKey(contractAddress, [
"getTotalEnglishAuctionsCount",
"englishAuctions",
"getTotalCount",
]),
},
},
@@ -1,5 +1,11 @@
# @thirdweb-dev/react-native-compat
## 0.2.23
## 0.2.22
## 0.2.21
## 0.2.20
## 0.2.19
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.2.20",
"version": "0.2.23",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+71
View File
@@ -1,5 +1,76 @@
# @thirdweb-dev/react-native
## 0.2.23
### Patch Changes
- [#1215](https://github.com/thirdweb-dev/js/pull/1215) [`3c5dc480`](https://github.com/thirdweb-dev/js/commit/3c5dc4804abc56b933ec45e9e1da11eb182296cc) Thanks [@iketw](https://github.com/iketw)! - Migrate wallets to WCV2 and remove WCV1 support.
Please, check our changelogs for more info: https://blog.thirdweb.com/changelog/
- Updated dependencies [[`ef4cb092`](https://github.com/thirdweb-dev/js/commit/ef4cb092192c58c9b292b29590b888f45f9fd23d), [`06ca1c40`](https://github.com/thirdweb-dev/js/commit/06ca1c407dfee9d3d1fdaed1b6223ad0f9b8857b), [`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087), [`ac3e019c`](https://github.com/thirdweb-dev/js/commit/ac3e019cd1776dbdb0d06b213420ad17586f678e), [`30ac3aef`](https://github.com/thirdweb-dev/js/commit/30ac3aef840bde51a61acf786c709cffd3c47354), [`3c5dc480`](https://github.com/thirdweb-dev/js/commit/3c5dc4804abc56b933ec45e9e1da11eb182296cc), [`ad7dae3b`](https://github.com/thirdweb-dev/js/commit/ad7dae3b163e61c7a6eb57f654885a7fdaa4cbb6), [`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087), [`0fd8aa04`](https://github.com/thirdweb-dev/js/commit/0fd8aa04a9424497758d13a51a72363edcc30e19)]:
- @thirdweb-dev/sdk@3.10.26
- @thirdweb-dev/react-core@3.14.4
- @thirdweb-dev/wallets@1.0.0
- @thirdweb-dev/chains@0.1.25
## 0.2.22
### Patch Changes
- [#1245](https://github.com/thirdweb-dev/js/pull/1245) [`d9fb134a`](https://github.com/thirdweb-dev/js/commit/d9fb134ad40ae067416625eb43cf3708f87db7b5) Thanks [@iketw](https://github.com/iketw)! - [RN]
- Added the option to import a new wallet in guest mode
- Added a "Request Testnet Funds" option when on testnets
- [#1245](https://github.com/thirdweb-dev/js/pull/1245) [`d9fb134a`](https://github.com/thirdweb-dev/js/commit/d9fb134ad40ae067416625eb43cf3708f87db7b5) Thanks [@iketw](https://github.com/iketw)! - [ReactNative] Export more components for easy development
- IconTextButton
Component that renders an icon and a text inside a button with border:
```javascript
<IconTextButton
mt="xs"
text="Switch Accounts"
icon={<SwitchIcon height={10} width={10} />}
onPress={() => {}}
/>
```
- NetworkButton: Used to render a Network
```javascript
<NetworkButton
chainIconUrl={chain?.icon?.url || ""}
chainName={chain?.name || "Unknown Network"}
onPress={onChangeNetworkPress}
/>
```
- Exported all icons from the assets folder for external use
- Updated dependencies [[`536b0f12`](https://github.com/thirdweb-dev/js/commit/536b0f1240ab446aac22cf547a4e09e73ee6bf7b), [`1d76334d`](https://github.com/thirdweb-dev/js/commit/1d76334dd3884703629835422f241d2825128f6f), [`b626782b`](https://github.com/thirdweb-dev/js/commit/b626782b0e8c6b76673472d3aee1c802dfb11b5f), [`d498c79a`](https://github.com/thirdweb-dev/js/commit/d498c79a911d478077dfb8a2490eb1bf91523186), [`0c5b03b8`](https://github.com/thirdweb-dev/js/commit/0c5b03b8d6cc6a4e69bb2a4647d3626e69f1283c), [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.21
### Patch Changes
- [#1220](https://github.com/thirdweb-dev/js/pull/1220) [`3cb298ac`](https://github.com/thirdweb-dev/js/commit/3cb298ac4b04d295899b5ac77c7fc5869ec2f5f2) Thanks [@iketw](https://github.com/iketw)! - [RN/Wallets] Fix Coinbase wallet connection rejection error
Unhandled Rejections: We were rethrowing an error in an async function (connect) without any catch block to handle it. We were getting an Unhandled Promise Rejection, which lead to a crash in React Native when rejecting a connection from the Coinbase Wallet.
- Updated dependencies [[`6816219a`](https://github.com/thirdweb-dev/js/commit/6816219ac13ae571a0c90db6ab389c319bc1f052), [`48065bcd`](https://github.com/thirdweb-dev/js/commit/48065bcd91c13e1f44d54343b5c6c2646b9e86e4), [`3cb298ac`](https://github.com/thirdweb-dev/js/commit/3cb298ac4b04d295899b5ac77c7fc5869ec2f5f2), [`b5e1d3bb`](https://github.com/thirdweb-dev/js/commit/b5e1d3bb2b82785d6d3e5c899d27691bdb638625), [`6aa6f7e0`](https://github.com/thirdweb-dev/js/commit/6aa6f7e0bd2313e2e1ad96dd41aad91e6694d380), [`f7f4f207`](https://github.com/thirdweb-dev/js/commit/f7f4f20737ac5d78424ca9c91220f00b85adde6b), [`3ce5f9a0`](https://github.com/thirdweb-dev/js/commit/3ce5f9a0c3fc7e99b5abf691a87048ab8475f6b1), [`d4d95507`](https://github.com/thirdweb-dev/js/commit/d4d95507130b2b5408bfaa73ef3b708ca00c773e), [`a388d07a`](https://github.com/thirdweb-dev/js/commit/a388d07a3d449e56dc53fed9600931022f4a15e1), [`1ce8558d`](https://github.com/thirdweb-dev/js/commit/1ce8558df47186bcba5ee8564fdb04583bf115dd), [`483e2b91`](https://github.com/thirdweb-dev/js/commit/483e2b910934d75276a68bae64d04c47cd7d57e3), [`c08e6ba9`](https://github.com/thirdweb-dev/js/commit/c08e6ba988ad97aa27d5868cec8abe3498d07a0a), [`60fb1889`](https://github.com/thirdweb-dev/js/commit/60fb18894372f14d9cd815fa9a239926d31bb273), [`3d615a62`](https://github.com/thirdweb-dev/js/commit/3d615a62d0a6801f6fb0e63f9b95c2f98446add1)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.20
### Patch Changes
+2 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.2.20",
"version": "0.2.23",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -24,7 +24,7 @@
"android"
],
"dependencies": {
"@coinbase/wallet-mobile-sdk": "^1.0.4",
"@coinbase/wallet-mobile-sdk": "1.0.6",
"@magic-sdk/provider": "17.2.0",
"@magic-sdk/react-native-bare": "^18.3.0",
"@shopify/restyle": "^2.4.1",
@@ -44,10 +44,6 @@
"react-native-svg": "^13.8.0",
"tiny-invariant": "^1.2.0"
},
"resolutions": {
"react-native-mmkv": "2.5.1",
"@magic-sdk/provider": "17.2.0"
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@babel/preset-env": "^7.1.6",
@@ -1,7 +1,10 @@
import { ThemeProvider } from "../styles/ThemeProvider";
import { WalletDetailsButton } from "./ConnectWalletDetails/WalletDetailsButton";
import {
ConnectWalletDetailsProps,
WalletDetailsButton,
} from "./ConnectWalletDetails/WalletDetailsButton";
import { useAddress } from "@thirdweb-dev/react-core";
import React, { useEffect, useRef } from "react";
import { useEffect, useRef } from "react";
import { Animated } from "react-native";
import { ConnectWalletButton } from "./ConnectWalletFlow/ConnectWalletButton";
import { ConnectWalletButtonProps } from "./ConnectWalletFlow/ConnectWalletButton";
@@ -10,7 +13,7 @@ export type ConnectWalletProps = {
/**
* render a custom button to display the connected wallet details instead of the default button
*/
detailsButton?: React.ReactElement;
detailsButton?: ConnectWalletDetailsProps["detailsButton"];
} & ConnectWalletButtonProps;
export const ConnectWallet = ({
@@ -1,4 +1,4 @@
import { StyleSheet, View } from "react-native";
import { Linking, StyleSheet, View } from "react-native";
import Box from "../base/Box";
import { Toast } from "../base/Toast";
import { ExportLocalWalletModal } from "./ExportLocalWalletModal";
@@ -22,6 +22,8 @@ import { useModalState } from "../../providers/ui-context-provider";
import { CLOSE_MODAL_STATE, WalletDetailsModal } from "../../utils/modalTypes";
import { useAppTheme } from "../../styles/hooks";
import { LocalWalletImportModal } from "../ConnectWalletFlow/LocalWalletImportModal";
import { IconTextButton } from "../base/IconTextButton";
import MoneyIcon from "../../assets/money";
export const ConnectWalletDetailsModal = () => {
const theme = useAppTheme();
@@ -192,6 +194,18 @@ export const ConnectWalletDetailsModal = () => {
chainName={chain?.name || "Unknown Network"}
onPress={onChangeNetworkPress}
/>
{chain?.testnet && chain?.faucets?.length ? (
<IconTextButton
mt="xs"
text="Request Testnet Funds"
icon={<MoneyIcon height={10} width={10} />}
onPress={() => {
if (chain?.faucets?.[0]) {
Linking.openURL(chain.faucets[0]);
}
}}
/>
) : null}
{getAdditionalActions()}
{addressCopied === true ? (
<Toast text={"Address copied to clipboard"} />
@@ -3,8 +3,7 @@ import BaseButton from "../base/BaseButton";
import { ChainIcon } from "../base/ChainIcon";
import Text from "../base/Text";
import { WalletIcon } from "../base/WalletIcon";
import { useWallet, useBalance } from "@thirdweb-dev/react-core";
import { useActiveChain } from "@thirdweb-dev/react-core/evm";
import { useWallet, useBalance, useChain } from "@thirdweb-dev/react-core";
import { StyleSheet } from "react-native";
import { LocalWallet } from "@thirdweb-dev/wallets";
import { useModalState } from "../../providers/ui-context-provider";
@@ -12,7 +11,7 @@ import Box from "../base/Box";
export type ConnectWalletDetailsProps = {
address: string;
detailsButton?: React.ReactElement;
detailsButton?: React.FC<{ onPress: () => void }>;
};
export const WalletDetailsButton = ({
@@ -20,7 +19,7 @@ export const WalletDetailsButton = ({
detailsButton,
}: ConnectWalletDetailsProps) => {
const activeWallet = useWallet();
const chain = useActiveChain();
const chain = useChain();
const balanceQuery = useBalance();
const { setModalState } = useModalState();
@@ -38,15 +37,15 @@ export const WalletDetailsButton = ({
return (
<>
<BaseButton
backgroundColor="background"
borderColor="border"
style={styles.walletDetails}
onPress={onPress}
>
{detailsButton ? (
detailsButton
) : (
{detailsButton ? (
detailsButton({ onPress })
) : (
<BaseButton
backgroundColor="background"
borderColor="border"
style={styles.walletDetails}
onPress={onPress}
>
<Box flex={1} flexDirection="row" justifyContent="space-between">
<ChainIcon size={32} chainIconUrl={chain?.icon?.url} />
<Box justifyContent="center" alignItems="flex-start">
@@ -70,8 +69,8 @@ export const WalletDetailsButton = ({
iconUri={activeWallet?.getMeta().iconURL || ""}
/>
</Box>
)}
</BaseButton>
</BaseButton>
)}
</>
);
};
@@ -39,13 +39,13 @@ export const ConnectWalletFlow = () => {
const connectActiveWallet = useCallback(
async (wallet: WalletConfig, data?: any) => {
setIsConnecting(true);
connect(wallet, { ...data })
.catch((error) => {
console.error("Error connecting to the wallet", error);
})
.finally(() => {
onClose(true);
});
try {
await connect(wallet, { ...data });
} catch (error) {
console.error("Error connecting to the wallet", error);
} finally {
onClose(true);
}
},
[connect, onClose],
);
-1
View File
@@ -17,7 +17,6 @@ export { localWallet } from "./wallets/wallets/local-wallet";
export { LocalWallet } from "./wallets/wallets/LocalWallet";
export { magicWallet } from "./wallets/wallets/magic-wallet";
export { MagicWallet } from "./wallets/wallets/MagicWallet";
export * from "./wallets/wallets/WalletConnectV1";
export * from "./wallets/wallets/WalletConnectV2";
export type { WCMeta } from "./wallets/types/wc";
@@ -72,10 +72,10 @@ export class CoinbaseWalletConnector extends WagmiConnector<
this.emit("message", { type: "connecting" });
const account = (await provider.request({
const accounts: string[] = await provider.request({
method: "eth_requestAccounts",
params: [],
})) as Address;
});
// Switch to chain if provided
let id = await this.getChainId();
let unsupported = this.isChainUnsupported(id);
@@ -93,7 +93,7 @@ export class CoinbaseWalletConnector extends WagmiConnector<
}
return {
account,
account: accounts[0],
chain: { id, unsupported },
provider: new providers.Web3Provider(
provider as unknown as providers.ExternalProvider,
@@ -1,52 +0,0 @@
import {
WalletOptions,
WalletConnectV1Options,
WalletConnectV1 as WalletConnectV1Wallets,
} from "@thirdweb-dev/wallets";
import { formatWalletConnectDisplayUri } from "../../utils/uri";
import { Linking } from "react-native";
import { ExtraCoreWalletOptions } from "@thirdweb-dev/react-core";
import { WCMeta } from "../types/wc";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";
export type WC1Options = Omit<
WalletOptions<WalletConnectV1Options>,
"qrcode" | "walletId"
> &
ExtraCoreWalletOptions & {
walletId: NonNullable<WalletOptions["walletId"]>;
};
export abstract class WalletConnectV1 extends WalletConnectV1Wallets {
constructor(options: WC1Options) {
super({
...options,
walletId: options.walletId,
walletStorage:
options.walletStorage || createAsyncLocalStorage(options.walletId),
qrcode: false,
});
this.on("open_wallet", this._onWCOpenWallet);
this.on("disconnect", () => {
this.removeListener("open_wallet", this._onWCOpenWallet);
});
}
abstract getMeta(): WCMeta;
_onWCOpenWallet(uri?: string) {
const links = this.getMeta().links;
if (uri) {
const fullUrl = formatWalletConnectDisplayUri(uri, links);
Linking.openURL(fullUrl);
} else {
const fullUrl = formatWalletConnectDisplayUri("", links);
Linking.openURL(fullUrl);
}
}
}
@@ -1,9 +1,9 @@
import { walletIds } from "@thirdweb-dev/wallets";
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { WalletConnectV1 } from "./WalletConnectV1";
import { WalletConnectV2 } from "./WalletConnectV2";
import { WCMeta } from "../types/wc";
export class MetaMaskWallet extends WalletConnectV1 {
export class MetaMaskWallet extends WalletConnectV2 {
static id = walletIds.metamask;
static meta = {
name: "MetaMask",
@@ -20,11 +20,17 @@ export class MetaMaskWallet extends WalletConnectV1 {
}
}
export const metamaskWallet = () => {
type MetaMaskWalletConfig = { projectId?: string };
export const metamaskWallet = (config?: MetaMaskWalletConfig) => {
return {
id: MetaMaskWallet.id,
meta: MetaMaskWallet.meta,
create: (options: WalletOptions) =>
new MetaMaskWallet({ ...options, walletId: walletIds.metamask }),
new MetaMaskWallet({
...options,
walletId: walletIds.metamask,
projectId: config?.projectId,
}),
} satisfies WalletConfig;
};
@@ -2,9 +2,9 @@ import {
WalletOptions as WalletOptionsRC,
WalletConfig,
} from "@thirdweb-dev/react-core";
import { WalletConnectV1 } from "./WalletConnectV1";
import { WalletConnectV2 } from "./WalletConnectV2";
export class RainbowWallet extends WalletConnectV1 {
export class RainbowWallet extends WalletConnectV2 {
static id = "rainbow" as const;
static meta = {
name: "Rainbow",
@@ -21,11 +21,17 @@ export class RainbowWallet extends WalletConnectV1 {
}
}
export const rainbowWallet = () => {
type RainbowWalletConfig = { projectId?: string };
export const rainbowWallet = (config?: RainbowWalletConfig) => {
return {
id: RainbowWallet.id,
meta: RainbowWallet.meta,
create: (options: WalletOptionsRC) =>
new RainbowWallet({ ...options, walletId: RainbowWallet.id }),
new RainbowWallet({
...options,
walletId: RainbowWallet.id,
projectId: config?.projectId,
}),
} satisfies WalletConfig;
};
@@ -1,5 +1,5 @@
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { WC2Options, WalletConnectV2 } from "./WalletConnectV2";
import { WalletConnectV2 } from "./WalletConnectV2";
import { WCMeta } from "../types/wc";
export class TrustWallet extends WalletConnectV2 {
@@ -14,10 +14,6 @@ export class TrustWallet extends WalletConnectV2 {
},
};
constructor(options: WC2Options) {
super(options);
}
getMeta(): WCMeta {
return TrustWallet.meta;
}
+77
View File
@@ -1,5 +1,82 @@
# @thirdweb-dev/react
## 3.14.4
### Patch Changes
- [#1215](https://github.com/thirdweb-dev/js/pull/1215) [`3c5dc480`](https://github.com/thirdweb-dev/js/commit/3c5dc4804abc56b933ec45e9e1da11eb182296cc) Thanks [@iketw](https://github.com/iketw)! - Migrate wallets to WCV2 and remove WCV1 support.
Please, check our changelogs for more info: https://blog.thirdweb.com/changelog/
- Updated dependencies [[`ef4cb092`](https://github.com/thirdweb-dev/js/commit/ef4cb092192c58c9b292b29590b888f45f9fd23d), [`06ca1c40`](https://github.com/thirdweb-dev/js/commit/06ca1c407dfee9d3d1fdaed1b6223ad0f9b8857b), [`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087), [`ac3e019c`](https://github.com/thirdweb-dev/js/commit/ac3e019cd1776dbdb0d06b213420ad17586f678e), [`30ac3aef`](https://github.com/thirdweb-dev/js/commit/30ac3aef840bde51a61acf786c709cffd3c47354), [`3c5dc480`](https://github.com/thirdweb-dev/js/commit/3c5dc4804abc56b933ec45e9e1da11eb182296cc), [`ad7dae3b`](https://github.com/thirdweb-dev/js/commit/ad7dae3b163e61c7a6eb57f654885a7fdaa4cbb6), [`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087), [`0fd8aa04`](https://github.com/thirdweb-dev/js/commit/0fd8aa04a9424497758d13a51a72363edcc30e19)]:
- @thirdweb-dev/sdk@3.10.26
- @thirdweb-dev/react-core@3.14.4
- @thirdweb-dev/wallets@1.0.0
- @thirdweb-dev/chains@0.1.25
## 3.14.3
### Patch Changes
- [#1238](https://github.com/thirdweb-dev/js/pull/1238) [`6e1fe6e5`](https://github.com/thirdweb-dev/js/commit/6e1fe6e582d4178884fc1793b330a9e477df5b4d) Thanks [@iketw](https://github.com/iketw)! - '[React] Adds Rainbow and Trust wallets hooks'
```javascript
import { useRainbowWallet, useTrustWallet } from "@thirdweb-dev/react";
const connectWithRainbow = useRainbowWallet();
const connectWithTrust = useTrustWallet();
```
- [#1237](https://github.com/thirdweb-dev/js/pull/1237) [`536b0f12`](https://github.com/thirdweb-dev/js/commit/536b0f1240ab446aac22cf547a4e09e73ee6bf7b) Thanks [@iketw](https://github.com/iketw)! - [React] Add Rainbow Wallet (implementing the WalletConnect wallet)
```javascript
import { ThirdwebProvider, rainbowWallet } from "@thirdweb-dev/react";
const activeChain = "ethereum";
<ThirdwebProvider
activeChain={activeChain}
supportedWallets={[rainbowWallet()]}
>
<App />
</ThirdwebProvider>;
```
- [#1236](https://github.com/thirdweb-dev/js/pull/1236) [`b626782b`](https://github.com/thirdweb-dev/js/commit/b626782b0e8c6b76673472d3aee1c802dfb11b5f) Thanks [@iketw](https://github.com/iketw)! - [Wallets/React] Add Trust Wallet
```javascript
import { ThirdwebProvider, trustWallet } from "@thirdweb-dev/react";
const activeChain = "mumbai";
<ThirdwebProvider
activeChain={activeChain}
autoSwitch={true}
supportedWallets={[trustWallet()]}
>
<App />
</ThirdwebProvider>;
```
- Updated dependencies [[`536b0f12`](https://github.com/thirdweb-dev/js/commit/536b0f1240ab446aac22cf547a4e09e73ee6bf7b), [`1d76334d`](https://github.com/thirdweb-dev/js/commit/1d76334dd3884703629835422f241d2825128f6f), [`b626782b`](https://github.com/thirdweb-dev/js/commit/b626782b0e8c6b76673472d3aee1c802dfb11b5f), [`d498c79a`](https://github.com/thirdweb-dev/js/commit/d498c79a911d478077dfb8a2490eb1bf91523186), [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 3.14.2
### Patch Changes
- [#1226](https://github.com/thirdweb-dev/js/pull/1226) [`a388d07a`](https://github.com/thirdweb-dev/js/commit/a388d07a3d449e56dc53fed9600931022f4a15e1) Thanks [@MananTank](https://github.com/MananTank)! - Add Magic Connect support
- Updated dependencies [[`6816219a`](https://github.com/thirdweb-dev/js/commit/6816219ac13ae571a0c90db6ab389c319bc1f052), [`48065bcd`](https://github.com/thirdweb-dev/js/commit/48065bcd91c13e1f44d54343b5c6c2646b9e86e4), [`3cb298ac`](https://github.com/thirdweb-dev/js/commit/3cb298ac4b04d295899b5ac77c7fc5869ec2f5f2), [`b5e1d3bb`](https://github.com/thirdweb-dev/js/commit/b5e1d3bb2b82785d6d3e5c899d27691bdb638625), [`6aa6f7e0`](https://github.com/thirdweb-dev/js/commit/6aa6f7e0bd2313e2e1ad96dd41aad91e6694d380), [`f7f4f207`](https://github.com/thirdweb-dev/js/commit/f7f4f20737ac5d78424ca9c91220f00b85adde6b), [`3ce5f9a0`](https://github.com/thirdweb-dev/js/commit/3ce5f9a0c3fc7e99b5abf691a87048ab8475f6b1), [`d4d95507`](https://github.com/thirdweb-dev/js/commit/d4d95507130b2b5408bfaa73ef3b708ca00c773e), [`a388d07a`](https://github.com/thirdweb-dev/js/commit/a388d07a3d449e56dc53fed9600931022f4a15e1), [`1ce8558d`](https://github.com/thirdweb-dev/js/commit/1ce8558df47186bcba5ee8564fdb04583bf115dd), [`483e2b91`](https://github.com/thirdweb-dev/js/commit/483e2b910934d75276a68bae64d04c47cd7d57e3), [`c08e6ba9`](https://github.com/thirdweb-dev/js/commit/c08e6ba988ad97aa27d5868cec8abe3498d07a0a), [`60fb1889`](https://github.com/thirdweb-dev/js/commit/60fb18894372f14d9cd815fa9a239926d31bb273), [`3d615a62`](https://github.com/thirdweb-dev/js/commit/3d615a62d0a6801f6fb0e63f9b95c2f98446add1)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 3.14.1
### Patch Changes
+1 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.14.1",
"version": "3.14.4",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -153,10 +153,6 @@
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
},
"resolutions": {
"ansi-regex": "^6.0.1",
"typescript": "^4.6.2"
},
"peerDependenciesMeta": {
"@solana/wallet-adapter-base": {
"optional": true
@@ -0,0 +1,15 @@
import { useConnect } from "@thirdweb-dev/react-core";
import { useCallback } from "react";
export function useRainbowWallet() {
const connect = useConnect();
return useCallback(
async (connectOptions?: { chainId?: number }) => {
const { rainbowWallet } = await import(
"../../../wallet/wallets/rainbow/RainbowWallet"
);
return connect(rainbowWallet(), connectOptions);
},
[connect],
);
}
@@ -0,0 +1,15 @@
import { useConnect } from "@thirdweb-dev/react-core";
import { useCallback } from "react";
export function useTrustWallet() {
const connect = useConnect();
return useCallback(
async (connectOptions?: { chainId?: number }) => {
const { trustWallet } = await import(
"../../../wallet/wallets/trustWallet/TrustWallet"
);
return connect(trustWallet(), connectOptions);
},
[connect],
);
}
+2
View File
@@ -20,6 +20,8 @@ export { ThirdwebProvider } from "./providers/thirdweb-provider";
export { useInstalledWallets } from "../wallet/hooks/useInstalledWallets";
// wallet connection hooks
export { useRainbowWallet } from "./hooks/wallets/useRainbowWallet";
export { useTrustWallet } from "./hooks/wallets/useTrustWallet";
export { useMetamask } from "./hooks/wallets/useMetamask";
export { useCoinbaseWallet } from "./hooks/wallets/useCoinbaseWallet";
export { useFrameWallet } from "./hooks/wallets/useFrame";
@@ -18,15 +18,15 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
"createWalletStorage" | "supportedWallets"
> {
/**
* Wallets that will be supported by the dApp
* @defaultValue [metamaskWallet(), coinbaseWallet(), walletConnectV1()]
* Wallets supported by the dApp
* @defaultValue `[ metamaskWallet(), coinbaseWallet(), walletConnect() ]`
*
* @example
* ```jsx
* import { metamaskWallet, coinbaseWallet, walletConnectV1 } from "@thirdweb-dev/react";
* import { metamaskWallet, coinbaseWallet, walletConnect } from "@thirdweb-dev/react";
*
* <ThirdwebProvider
* supportedWallets={[metamaskWallet(), coinbaseWallet(), walletConnectV1()]}
* supportedWallets={[metamaskWallet(), coinbaseWallet(), walletConnect()]}
* />
* ```
*/
+2
View File
@@ -4,7 +4,9 @@ export { coinbaseWallet } from "./wallet/wallets/coinbase/coinbaseWallet";
export { frameWallet } from "./wallet/wallets/frame/frameWallet";
export { metamaskWallet } from "./wallet/wallets/metamask/metamaskWallet";
export { paperWallet } from "./wallet/wallets/paperWallet";
export { rainbowWallet } from "./wallet/wallets/rainbow/RainbowWallet";
export { safeWallet } from "./wallet/wallets/safe/safeWallet";
export { trustWallet } from "./wallet/wallets/trustWallet/TrustWallet";
export { walletConnect } from "./wallet/wallets/walletConnect";
export { walletConnectV1 } from "./wallet/wallets/walletConnectV1";
export { smartWallet } from "./wallet/wallets/smartWallet/smartWallet";
@@ -385,6 +385,17 @@ const NetworkList = /* @__PURE__ */ memo(function NetworkList(props: {
const [switchingChainId, setSwitchingChainId] = useState(-1);
const [errorSwitchingChainId, setErrorSwitchingChainId] = useState(-1);
const close = props.close;
useEffect(() => {
// if switching and switched successfully - close modal
if (switchingChainId !== -1 && activeChainId === switchingChainId) {
if (close) {
close();
}
}
}, [switchingChainId, close, activeChainId]);
const handleSwitch = async (chain: Chain) => {
setErrorSwitchingChainId(-1);
setSwitchingChainId(chain.chainId);
@@ -3,6 +3,7 @@ import { assertWindowEthereum } from "@thirdweb-dev/wallets";
export function useInstalledWallets() {
let isMetamaskInstalled = false;
let isCoinbaseWalletInstalled = false;
let isTrustWalletInstalled: boolean | undefined = false;
if (assertWindowEthereum(globalThis.window)) {
isMetamaskInstalled = globalThis.window.ethereum?.isMetaMask;
@@ -10,11 +11,13 @@ export function useInstalledWallets() {
globalThis.window.ethereum?.isCoinbaseWallet ||
globalThis.window.ethereum?.providers?.some((p) => p.isCoinbaseWallet) ||
false;
isTrustWalletInstalled = globalThis.window.ethereum?.isTrust;
}
const installedWallets = {
metamask: !!isMetamaskInstalled,
coinbaseWallet: !!isCoinbaseWalletInstalled,
trustWallet: !!isTrustWalletInstalled,
};
return installedWallets;
@@ -1,10 +1,10 @@
import { WalletConfig } from "@thirdweb-dev/react-core";
import { coinbaseWallet } from "./coinbase/coinbaseWallet";
import { metamaskWallet } from "./metamask/metamaskWallet";
import { walletConnectV1 } from "./walletConnectV1";
import { walletConnect } from "./walletConnect";
export const defaultWallets: WalletConfig<any>[] = /* @__PURE__ */ (() => [
metamaskWallet(),
coinbaseWallet(),
walletConnectV1(),
walletConnect(),
])();
@@ -14,21 +14,24 @@ import { InputSelectionUI } from "../InputSelectionUI";
export function magicLink(
config: MagicLinkAdditionalOptions,
): ConfiguredMagicLinkWallet {
const selectUI = (props: SelectUIProps<MagicLink>) => (
<MagicSelectionUI
{...props}
emailLogin={config.emailLogin !== false}
smsLogin={config.smsLogin !== false}
/>
);
return {
id: MagicLink.id,
meta: MagicLink.meta,
create: (options: WalletOptions) =>
new MagicLink({ ...options, ...config }),
connectUI: MagicConnectionUI,
selectUI(props) {
return (
<MagicSelectionUI
{...props}
emailLogin={config.emailLogin !== false}
smsLogin={config.smsLogin !== false}
/>
);
connectUI(props) {
return <MagicConnectionUI {...props} type={config.type || "auth"} />;
},
// select UI only for auth
selectUI: config.type === "connect" ? undefined : selectUI,
isInstalled() {
return false;
},
@@ -101,13 +104,9 @@ const MagicSelectionUI: React.FC<
);
};
const MagicConnectionUI: React.FC<ConnectUIProps<MagicLink>> = ({
close,
walletConfig,
open,
selectionData,
supportedWallets,
}) => {
const MagicConnectionUI: React.FC<
ConnectUIProps<MagicLink> & { type: "auth" | "connect" }
> = ({ close, walletConfig, open, selectionData, supportedWallets, type }) => {
const connectPrompted = useRef(false);
const singleWallet = supportedWallets.length === 1;
const connect = useConnect();
@@ -117,14 +116,20 @@ const MagicConnectionUI: React.FC<ConnectUIProps<MagicLink>> = ({
return;
}
connectPrompted.current = true;
const isEmail = (selectionData as string).includes("@");
const isEmail = selectionData
? (selectionData as string).includes("@")
: false;
(async () => {
close();
try {
await connect(
walletConfig,
isEmail ? { email: selectionData } : { phoneNumber: selectionData },
type === "connect"
? {}
: isEmail
? { email: selectionData }
: { phoneNumber: selectionData },
);
} catch (e) {
if (!singleWallet) {
@@ -133,7 +138,7 @@ const MagicConnectionUI: React.FC<ConnectUIProps<MagicLink>> = ({
console.error(e);
}
})();
}, [connect, selectionData, walletConfig, close, open, singleWallet]);
}, [connect, selectionData, walletConfig, close, open, singleWallet, type]);
return (
<Flex
@@ -2,12 +2,28 @@ import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { MetaMaskWallet, assertWindowEthereum } from "@thirdweb-dev/wallets";
import { MetamaskConnectUI } from "./MetamaskConnectUI";
export const metamaskWallet = (): WalletConfig<MetaMaskWallet> => {
type MetamaskWalletOptions = {
/**
* When connecting MetaMask using the QR Code - Wallet Connect connector is used which requires a project id.
* This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com.
*
* https://docs.walletconnect.com/2.0/web3modal/options#projectid-required
*/
projectId?: string;
};
export const metamaskWallet = (
options?: MetamaskWalletOptions,
): WalletConfig<MetaMaskWallet> => {
return {
id: MetaMaskWallet.id,
meta: MetaMaskWallet.meta,
create: (options: WalletOptions) => {
return new MetaMaskWallet({ ...options, qrcode: false });
create: (walletOptions: WalletOptions) => {
return new MetaMaskWallet({
...walletOptions,
projectId: options?.projectId,
qrcode: false,
});
},
connectUI: MetamaskConnectUI,
isInstalled() {
@@ -0,0 +1,74 @@
import { ConnectUIProps, useConnect } from "@thirdweb-dev/react-core";
import { WalletConnect } from "@thirdweb-dev/wallets";
import { useEffect, useRef, useState } from "react";
import { isMobile } from "../../../evm/utils/isMobile";
import { ConnectingScreen } from "../../ConnectWallet/screens/ConnectingScreen";
import { GetStartedScreen } from "../../ConnectWallet/screens/GetStartedScreen";
import { RainbowScan } from "./RainbowScan";
export const RainbowConnectUI = (props: ConnectUIProps<WalletConnect>) => {
const [screen, setScreen] = useState<
"connecting" | "scanning" | "get-started"
>("connecting");
const { walletConfig, close } = props;
const connect = useConnect();
const { goBack } = props;
const connectPrompted = useRef(false);
useEffect(() => {
if (connectPrompted.current) {
return;
}
// if loading
(async () => {
// on mobile, open rainbow app link
if (isMobile()) {
window.open("https://rnbwapp.com");
} else {
// on desktop, show the rainbow scan qr code
setScreen("scanning");
}
})();
}, [walletConfig, close, connect, goBack]);
if (screen === "connecting") {
return (
<ConnectingScreen
onBack={props.goBack}
walletName={walletConfig.meta.name}
walletIconURL={walletConfig.meta.iconURL}
supportLink="https://rainbow.me/"
/>
);
}
if (screen === "get-started") {
return (
<GetStartedScreen
walletIconURL={walletConfig.meta.iconURL}
walletName={walletConfig.meta.name}
chromeExtensionLink={walletConfig.meta.urls?.chrome}
googlePlayStoreLink={walletConfig.meta.urls?.android}
appleStoreLink={walletConfig.meta.urls?.ios}
onBack={props.goBack}
/>
);
}
if (screen === "scanning") {
return (
<RainbowScan
onBack={props.goBack}
onConnected={close}
onGetStarted={() => {
setScreen("get-started");
}}
walletConfig={walletConfig}
/>
);
}
return null;
};
@@ -0,0 +1,59 @@
import { ScanScreen } from "../../ConnectWallet/screens/ScanScreen";
import {
useCreateWalletInstance,
useWalletContext,
} from "@thirdweb-dev/react-core";
import { useEffect, useRef, useState } from "react";
import type { WalletConnect } from "@thirdweb-dev/wallets";
import type { WalletConfig } from "@thirdweb-dev/react-core";
export const RainbowScan: React.FC<{
onBack: () => void;
onGetStarted: () => void;
onConnected: () => void;
walletConfig: WalletConfig<WalletConnect>;
}> = ({ onBack, onConnected, onGetStarted, walletConfig }) => {
const createInstance = useCreateWalletInstance();
const [qrCodeUri, setQrCodeUri] = useState<string | undefined>();
const { setConnectedWallet, chainToConnect, setConnectionStatus } =
useWalletContext();
const scanStarted = useRef(false);
useEffect(() => {
if (scanStarted.current) {
return;
}
scanStarted.current = true;
const rainbow = createInstance(walletConfig);
setConnectionStatus("connecting");
rainbow.connectWithQrCode({
chainId: chainToConnect?.chainId,
onQrCodeUri(uri) {
setQrCodeUri(uri);
},
onConnected() {
setConnectedWallet(rainbow);
onConnected();
},
});
}, [
createInstance,
setConnectedWallet,
chainToConnect,
onConnected,
walletConfig,
setConnectionStatus,
]);
return (
<ScanScreen
onBack={onBack}
onGetStarted={onGetStarted}
qrCodeUri={qrCodeUri}
walletName={walletConfig.meta.name}
walletIconURL={walletConfig.meta.iconURL}
/>
);
};
@@ -0,0 +1,38 @@
import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { WalletConnect } from "@thirdweb-dev/wallets";
import { RainbowConnectUI } from "./RainbowConnectUI";
type RainbowWalletOptions = {
/**
* When connecting Rainbow using the QR Code - Wallet Connect connector is used which requires a project id.
* This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com.
*
* https://docs.walletconnect.com/2.0/web3modal/options#projectid-required
*/
projectId?: string;
};
export const rainbowWallet = (
options?: RainbowWalletOptions,
): WalletConfig<WalletConnect> => {
return {
id: "rainbow",
meta: {
name: "Rainbow Wallet",
iconURL:
"ipfs://QmSZn47p4DVVBfzvg9BAX2EqwnPxkT1YAE7rUnrtd9CybQ/rainbow-logo.png",
},
create: (walletOptions: WalletOptions) => {
return new WalletConnect({
...walletOptions,
walletId: "rainbow",
projectId: options?.projectId,
qrcode: false,
});
},
connectUI: RainbowConnectUI,
isInstalled() {
return false;
},
};
};
@@ -0,0 +1,92 @@
import { ConnectUIProps, useConnect } from "@thirdweb-dev/react-core";
import { TrustWallet } from "@thirdweb-dev/wallets";
import { useEffect, useRef, useState } from "react";
import { isMobile } from "../../../evm/utils/isMobile";
import { ConnectingScreen } from "../../ConnectWallet/screens/ConnectingScreen";
import { GetStartedScreen } from "../../ConnectWallet/screens/GetStartedScreen";
import { TrustScan } from "./TrustScan";
export const TrustConnectUI = (props: ConnectUIProps<TrustWallet>) => {
const [screen, setScreen] = useState<
"connecting" | "scanning" | "get-started"
>("connecting");
const { walletConfig, close } = props;
const connect = useConnect();
const { goBack } = props;
const connectPrompted = useRef(false);
useEffect(() => {
if (connectPrompted.current) {
return;
}
const isInstalled = walletConfig.isInstalled
? walletConfig.isInstalled()
: false;
// if loading
(async () => {
if (isInstalled) {
try {
connectPrompted.current = true;
setScreen("connecting");
await connect(walletConfig);
close();
} catch (e) {
goBack();
}
}
// if trust is not injected
else {
// on mobile, open trust app link
if (isMobile()) {
window.open("https://link.trustwallet.com");
} else {
// on desktop, show the trust scan qr code
setScreen("scanning");
}
}
})();
}, [walletConfig, close, connect, goBack]);
if (screen === "connecting") {
return (
<ConnectingScreen
onBack={props.goBack}
walletName={walletConfig.meta.name}
walletIconURL={walletConfig.meta.iconURL}
supportLink="https://community.trustwallet.com/c/helpcenter/8"
/>
);
}
if (screen === "get-started") {
return (
<GetStartedScreen
walletIconURL={walletConfig.meta.iconURL}
walletName={walletConfig.meta.name}
chromeExtensionLink={walletConfig.meta.urls?.chrome}
googlePlayStoreLink={walletConfig.meta.urls?.android}
appleStoreLink={walletConfig.meta.urls?.ios}
onBack={props.goBack}
/>
);
}
if (screen === "scanning") {
return (
<TrustScan
onBack={props.goBack}
onConnected={close}
onGetStarted={() => {
setScreen("get-started");
}}
walletConfig={walletConfig}
/>
);
}
return null;
};
@@ -0,0 +1,59 @@
import { ScanScreen } from "../../ConnectWallet/screens/ScanScreen";
import {
useCreateWalletInstance,
useWalletContext,
} from "@thirdweb-dev/react-core";
import { useEffect, useRef, useState } from "react";
import type { TrustWallet } from "@thirdweb-dev/wallets";
import type { WalletConfig } from "@thirdweb-dev/react-core";
export const TrustScan: React.FC<{
onBack: () => void;
onGetStarted: () => void;
onConnected: () => void;
walletConfig: WalletConfig<TrustWallet>;
}> = ({ onBack, onConnected, onGetStarted, walletConfig }) => {
const createInstance = useCreateWalletInstance();
const [qrCodeUri, setQrCodeUri] = useState<string | undefined>();
const { setConnectedWallet, chainToConnect, setConnectionStatus } =
useWalletContext();
const scanStarted = useRef(false);
useEffect(() => {
if (scanStarted.current) {
return;
}
scanStarted.current = true;
const trust = createInstance(walletConfig);
setConnectionStatus("connecting");
trust.connectWithQrCode({
chainId: chainToConnect?.chainId,
onQrCodeUri(uri) {
setQrCodeUri(uri);
},
onConnected() {
setConnectedWallet(trust);
onConnected();
},
});
}, [
createInstance,
setConnectedWallet,
chainToConnect,
onConnected,
walletConfig,
setConnectionStatus,
]);
return (
<ScanScreen
onBack={onBack}
onGetStarted={onGetStarted}
qrCodeUri={qrCodeUri}
walletName={walletConfig.meta.name}
walletIconURL={walletConfig.meta.iconURL}
/>
);
};
@@ -0,0 +1,36 @@
import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { TrustWallet, assertWindowEthereum } from "@thirdweb-dev/wallets";
import { TrustConnectUI } from "./TrustConnectUI";
type TrustWalletOptions = {
/**
* When connecting Trust using the QR Code - Wallet Connect connector is used which requires a project id.
* This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com.
*
* https://docs.walletconnect.com/2.0/web3modal/options#projectid-required
*/
projectId?: string;
};
export const trustWallet = (
options?: TrustWalletOptions,
): WalletConfig<TrustWallet> => {
return {
id: TrustWallet.id,
meta: TrustWallet.meta,
create: (walletOptions: WalletOptions) => {
return new TrustWallet({
...walletOptions,
projectId: options?.projectId,
qrcode: false,
});
},
connectUI: TrustConnectUI,
isInstalled() {
if (assertWindowEthereum(globalThis.window)) {
return !!globalThis.window.ethereum.isTrust;
}
return false;
},
};
};
@@ -1,12 +1,9 @@
import { WalletConnectV1 } from "@thirdweb-dev/wallets";
import { WalletConfig, WalletOptions } from "@thirdweb-dev/react-core";
import { walletConnect } from "./walletConnect";
export const walletConnectV1 = (): WalletConfig<WalletConnectV1> => {
return {
id: WalletConnectV1.id,
meta: WalletConnectV1.meta,
create(options: WalletOptions) {
return new WalletConnectV1({ ...options, qrcode: true });
},
};
};
/**
* @deprecated Use `walletConnect` instead
*
* The WalletConnect v1.0 protocol has been shut down and no longer works.
* To avoid breaking change, `walletConnectV1` is still available but is an alias of `walletConnect`.
*/
export const walletConnectV1 = walletConnect;
@@ -2,12 +2,28 @@ import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { ZerionWallet, assertWindowEthereum } from "@thirdweb-dev/wallets";
import { ZerionConnectUI } from "./ZerionConnectUI";
export const zerionWallet = (): WalletConfig<ZerionWallet> => {
type ZerionkWalletOptions = {
/**
* When connecting MetaMask using the QR Code - Wallet Connect connector is used which requires a project id.
* This project id is Your project’s unique identifier for wallet connect that can be obtained at cloud.walletconnect.com.
*
* https://docs.walletconnect.com/2.0/web3modal/options#projectid-required
*/
projectId?: string;
};
export const zerionWallet = (
options?: ZerionkWalletOptions,
): WalletConfig<ZerionWallet> => {
return {
id: ZerionWallet.id,
meta: ZerionWallet.meta,
create: (options: WalletOptions) => {
return new ZerionWallet(options);
create: (walletOptions: WalletOptions) => {
return new ZerionWallet({
...walletOptions,
projectId: options?.projectId,
qrcode: false,
});
},
connectUI: ZerionConnectUI,
isInstalled() {
+14
View File
@@ -4,6 +4,19 @@ module.exports = {
plugins: ["better-tree-shaking"],
rules: {
"better-tree-shaking/no-top-level-side-effects": "error",
"no-restricted-imports": [
"error",
{
paths: [
{
name: "ethers",
importNames: ["ethers"],
message:
"Do not import entire ethers object, Use named imports instead.",
},
],
},
],
},
// allow all imports from within tests
overrides: [
@@ -11,6 +24,7 @@ module.exports = {
files: "./test/**/*",
rules: {
"@typescript-eslint/no-restricted-imports": "off",
"better-tree-shaking/no-top-level-side-effects": "off",
},
},
],
+45
View File
@@ -1,5 +1,50 @@
# @thirdweb-dev/sdk
## 3.10.26
### Patch Changes
- [#1249](https://github.com/thirdweb-dev/js/pull/1249) [`ef4cb092`](https://github.com/thirdweb-dev/js/commit/ef4cb092192c58c9b292b29590b888f45f9fd23d) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Update EIP155 error substrings for any evm deployments
- [#1254](https://github.com/thirdweb-dev/js/pull/1254) [`30ac3aef`](https://github.com/thirdweb-dev/js/commit/30ac3aef840bde51a61acf786c709cffd3c47354) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fetch base64 NFTs
- Updated dependencies [[`620e89dc`](https://github.com/thirdweb-dev/js/commit/620e89dc25c91557e2164a602c7aedd733525087), [`0fd8aa04`](https://github.com/thirdweb-dev/js/commit/0fd8aa04a9424497758d13a51a72363edcc30e19)]:
- @thirdweb-dev/chains@0.1.25
## 3.10.25
### Patch Changes
- [#1233](https://github.com/thirdweb-dev/js/pull/1233) [`d498c79a`](https://github.com/thirdweb-dev/js/commit/d498c79a911d478077dfb8a2490eb1bf91523186) Thanks [@nkrishang](https://github.com/nkrishang)! - Fix smartWalletFactory.getAllEvents
- [#1241](https://github.com/thirdweb-dev/js/pull/1241) [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea) Thanks [@nkrishang](https://github.com/nkrishang)! - Use fn getAllAccounts instead of event logs AccountCreated
- Updated dependencies [[`0c5b03b8`](https://github.com/thirdweb-dev/js/commit/0c5b03b8d6cc6a4e69bb2a4647d3626e69f1283c), [`9af346ee`](https://github.com/thirdweb-dev/js/commit/9af346eeada1037be27c8d3c9e1777f7be11a8ea)]:
- @thirdweb-dev/storage@1.1.5
- @thirdweb-dev/contracts-js@1.3.7
- @thirdweb-dev/chains@0.1.24
## 3.10.24
### Patch Changes
- [#1222](https://github.com/thirdweb-dev/js/pull/1222) [`48065bcd`](https://github.com/thirdweb-dev/js/commit/48065bcd91c13e1f44d54343b5c6c2646b9e86e4) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Accept string for image/animation_url on shared metadata
- [#1223](https://github.com/thirdweb-dev/js/pull/1223) [`6aa6f7e0`](https://github.com/thirdweb-dev/js/commit/6aa6f7e0bd2313e2e1ad96dd41aad91e6694d380) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - fix maxId in getAll for Open Edition contracts
- [#1224](https://github.com/thirdweb-dev/js/pull/1224) [`f7f4f207`](https://github.com/thirdweb-dev/js/commit/f7f4f20737ac5d78424ca9c91220f00b85adde6b) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Better return type for get shared metadata
- [#1218](https://github.com/thirdweb-dev/js/pull/1218) [`d4d95507`](https://github.com/thirdweb-dev/js/commit/d4d95507130b2b5408bfaa73ef3b708ca00c773e) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Add get for shared metadata
- [#1225](https://github.com/thirdweb-dev/js/pull/1225) [`483e2b91`](https://github.com/thirdweb-dev/js/commit/483e2b910934d75276a68bae64d04c47cd7d57e3) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Fix namespace for platform fees
- [#1216](https://github.com/thirdweb-dev/js/pull/1216) [`c08e6ba9`](https://github.com/thirdweb-dev/js/commit/c08e6ba988ad97aa27d5868cec8abe3498d07a0a) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix claim counts for Open Edition contracts
- [#1188](https://github.com/thirdweb-dev/js/pull/1188) [`3d615a62`](https://github.com/thirdweb-dev/js/commit/3d615a62d0a6801f6fb0e63f9b95c2f98446add1) Thanks [@kienngo98](https://github.com/kienngo98)! - Abstract duplicated code; treeshake ethers.js imports
- Updated dependencies [[`6816219a`](https://github.com/thirdweb-dev/js/commit/6816219ac13ae571a0c90db6ab389c319bc1f052)]:
- @thirdweb-dev/chains@0.1.23
## 3.10.23
### Patch Changes
+1 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "3.10.23",
"version": "3.10.26",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
@@ -197,12 +197,6 @@
"yaml": "^2.1.1",
"zod": "^3.20.2"
},
"resolutions": {
"bn.js": "^5.2.1",
"nanoid": "^3.1.31",
"typescript": "^4.6.2",
"@microsoft/tsdoc": "^0.14.1"
},
"bugs": {
"url": "https://github.com/thirdweb-dev/js/issues"
},
@@ -10,6 +10,8 @@ export const ERROR_SUBSTRINGS = [
"recovered sender mismatch",
"transaction hash mismatch",
"chainid no support",
"chainid (0)",
"chainid(0)",
];
export const ERROR_SUBSTRINGS_COMPOSITE = [
@@ -1,4 +1,4 @@
import { BytesLike, ethers } from "ethers";
import { type BytesLike, utils } from "ethers";
import { getSaltHash } from "./getSaltHash";
/**
@@ -15,27 +15,27 @@ export function computeDeploymentAddress(
create2FactoryAddress: string,
salt?: string,
): string {
const saltHash = salt ? ethers.utils.id(salt) : getSaltHash(bytecode);
const saltHash = salt ? utils.id(salt) : getSaltHash(bytecode);
// 1. create init bytecode hash with contract's bytecode and encoded args
const initBytecode = ethers.utils.solidityPack(
const initBytecode = utils.solidityPack(
["bytes", "bytes"],
[bytecode, encodedArgs],
);
// 2. abi-encode pack the deployer address, salt, and bytecode hash
const deployInfoPacked = ethers.utils.solidityPack(
const deployInfoPacked = utils.solidityPack(
["bytes1", "address", "bytes32", "bytes32"],
[
"0xff",
create2FactoryAddress,
saltHash,
ethers.utils.solidityKeccak256(["bytes"], [initBytecode]),
utils.solidityKeccak256(["bytes"], [initBytecode]),
],
);
// 3. hash the packed deploy info
const hashedDeployInfo = ethers.utils.solidityKeccak256(
const hashedDeployInfo = utils.solidityKeccak256(
["bytes"],
[deployInfoPacked],
);
@@ -12,7 +12,7 @@ import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
import { isContractDeployed } from "./isContractDeployed";
import { getInitBytecodeWithSalt } from "./getInitBytecodeWithSalt";
import { computeDeploymentAddress } from "./computeDeploymentAddress";
import { BytesLike, ethers } from "ethers";
import { type BytesLike, utils, constants } from "ethers";
import { getNativeTokenByChainId } from "../../constants/currency";
import { PreDeployMetadataFetched } from "../../schema/contracts/custom";
import { ConstructorParamMap } from "../../types/any-evm/deploy-data";
@@ -113,7 +113,7 @@ export async function encodeConstructorParamsForImplementation(
);
let constructorParamTypes = constructorParams.map((p) => {
if (p.type === "tuple[]") {
return ethers.utils.ParamType.from(p);
return utils.ParamType.from(p);
} else {
return p.type;
}
@@ -137,7 +137,7 @@ export async function encodeConstructorParamsForImplementation(
let nativeTokenWrapperAddress =
getNativeTokenByChainId(chainId).wrapped.address;
if (nativeTokenWrapperAddress === ethers.constants.AddressZero) {
if (nativeTokenWrapperAddress === constants.AddressZero) {
const deploymentInfo = await computeDeploymentInfo(
"infra",
provider,
@@ -194,7 +194,7 @@ export async function encodeConstructorParamsForImplementation(
}),
);
const encodedArgs = ethers.utils.defaultAbiCoder.encode(
const encodedArgs = utils.defaultAbiCoder.encode(
constructorParamTypes,
constructorParamValues,
);
@@ -1,4 +1,4 @@
import { BigNumber, ethers } from "ethers";
import { BigNumber, utils } from "ethers";
import invariant from "tiny-invariant";
export function convertParamValues(
@@ -21,14 +21,14 @@ export function convertParamValues(
}
if (p === "bytes32") {
invariant(
ethers.utils.isHexString(constructorParamValues[index]),
utils.isHexString(constructorParamValues[index]),
`Could not parse bytes32 value. Expected valid hex string but got "${constructorParamValues[index]}".`,
);
return ethers.utils.hexZeroPad(constructorParamValues[index], 32);
return utils.hexZeroPad(constructorParamValues[index], 32);
}
if (p.startsWith("bytes")) {
invariant(
ethers.utils.isHexString(constructorParamValues[index]),
utils.isHexString(constructorParamValues[index]),
`Could not parse bytes value. Expected valid hex string but got "${constructorParamValues[index]}".`,
);
return constructorParamValues[index];
@@ -1,4 +1,4 @@
import { BigNumber, ethers, Signer } from "ethers";
import { BigNumber, type PopulatedTransaction, type Signer } from "ethers";
import invariant from "tiny-invariant";
import { PrecomputedDeploymentTransaction } from "../../types/any-evm/deploy-data";
import type { DeployOptions } from "../../types/deploy";
@@ -33,7 +33,7 @@ export async function deployContractDeterministic(
`deploying contract via create2 factory at: ${transaction.predictedAddress}`,
);
let tx: ethers.PopulatedTransaction = {
let tx: PopulatedTransaction = {
to: transaction.to,
data: transaction.data,
};
@@ -1,4 +1,9 @@
import { BigNumber, BytesLike, ethers, Signer } from "ethers";
import {
BigNumber,
type BytesLike,
type PopulatedTransaction,
type Signer,
} from "ethers";
import invariant from "tiny-invariant";
import type { DeployOptions } from "../../types/deploy";
import { isContractDeployed } from "./isContractDeployed";
@@ -10,7 +15,7 @@ import { getInitBytecodeWithSalt } from "./getInitBytecodeWithSalt";
*
* @public
*
* @param signer
* @param type signer
* @param bytecode
* @param encodedArgs
* @param create2FactoryAddress
@@ -36,7 +41,7 @@ export async function deployContractDeterministicRaw(
);
const initBytecodeWithSalt = getInitBytecodeWithSalt(bytecode, encodedArgs);
let tx: ethers.PopulatedTransaction = {
let tx: PopulatedTransaction = {
to: create2FactoryAddress,
data: initBytecodeWithSalt,
};
@@ -1,9 +1,9 @@
import {
BigNumber,
PopulatedTransaction,
Signer,
ethers,
providers,
type PopulatedTransaction,
type Signer,
utils,
type providers,
} from "ethers";
import invariant from "tiny-invariant";
import { isContractDeployed } from "./isContractDeployed";
@@ -56,7 +56,7 @@ export async function directDeployDeterministic(
constructorParamTypes,
constructorArgs,
);
const encodedArgs = ethers.utils.defaultAbiCoder.encode(
const encodedArgs = utils.defaultAbiCoder.encode(
constructorParamTypes,
paramValues,
);
@@ -159,7 +159,7 @@ export async function predictAddressDeterministic(
constructorParamTypes,
constructorArgs,
);
const encodedArgs = ethers.utils.defaultAbiCoder.encode(
const encodedArgs = utils.defaultAbiCoder.encode(
constructorParamTypes,
paramValues,
);
@@ -1,4 +1,4 @@
import { ethers, Signer } from "ethers";
import { ContractFactory, type Signer } from "ethers";
import { PrecomputedDeploymentTransaction } from "../../types/any-evm/deploy-data";
import type { DeployOptions } from "../../types/deploy";
import { DEPLOYER_ABI, DEPLOYER_BYTECODE } from "./constants";
@@ -18,10 +18,7 @@ export async function deployWithThrowawayDeployer(
const deployTxns = await Promise.all(
transactionBatches.map((txBatch) => {
// Using the deployer contract, send the deploy transactions to common factory with a signer
const deployer = new ethers.ContractFactory(
DEPLOYER_ABI,
DEPLOYER_BYTECODE,
)
const deployer = new ContractFactory(DEPLOYER_ABI, DEPLOYER_BYTECODE)
.connect(signer)
.deploy(txBatch);
@@ -1,8 +1,8 @@
import { ethers } from "ethers";
import { utils } from "ethers";
export function estimateGasForDeploy(initCode: string) {
let gasLimit =
ethers.utils
utils
.arrayify(initCode)
.map((x) => (x === 0 ? 4 : 16))
.reduce((sum, x) => sum + x) +
@@ -1,4 +1,4 @@
import { ethers } from "ethers";
import { utils } from "ethers";
import { KeylessDeploymentInfo } from "../../types/any-evm/deploy-data";
import { SIGNATURE, CREATE2_FACTORY_BYTECODE } from "./constants";
import { getKeylessTxn } from "./getKeylessTxn";
@@ -13,7 +13,7 @@ export function getCreate2FactoryDeploymentInfo(
chainId: number,
gasPrice?: number,
): KeylessDeploymentInfo {
const signature = ethers.utils.joinSignature(SIGNATURE);
const signature = utils.joinSignature(SIGNATURE);
const deploymentTransaction = getKeylessTxn(
{
gasPrice: gasPrice ? gasPrice : 100 * 10 ** 9,
@@ -24,7 +24,7 @@ export function getCreate2FactoryDeploymentInfo(
},
signature,
);
const create2FactoryAddress = ethers.utils.getContractAddress({
const create2FactoryAddress = utils.getContractAddress({
from: deploymentTransaction.signer,
nonce: 0,
});
@@ -1,4 +1,4 @@
import { BytesLike, ethers } from "ethers";
import { type BytesLike, utils } from "ethers";
import { getSaltHash } from "./getSaltHash";
/**
@@ -15,9 +15,9 @@ export function getInitBytecodeWithSalt(
encodedArgs: BytesLike,
salt?: string,
): string {
const saltHash = salt ? ethers.utils.id(salt) : getSaltHash(bytecode);
const saltHash = salt ? utils.id(salt) : getSaltHash(bytecode);
const initBytecodeWithSalt = ethers.utils.solidityPack(
const initBytecodeWithSalt = utils.solidityPack(
["bytes32", "bytes", "bytes"],
[saltHash, bytecode, encodedArgs],
);
@@ -1,4 +1,4 @@
import { ethers } from "ethers";
import { utils, type UnsignedTransaction } from "ethers";
import { KeylessTransaction } from "../../types/any-evm/deploy-data";
/**
@@ -9,20 +9,20 @@ import { KeylessTransaction } from "../../types/any-evm/deploy-data";
* @param signature: Signature bytes
*/
export function getKeylessTxn(
transaction: ethers.UnsignedTransaction,
transaction: UnsignedTransaction,
signature: string,
): KeylessTransaction {
// 1. Create serialized txn string
const digest = ethers.utils.arrayify(
ethers.utils.keccak256(ethers.utils.serializeTransaction(transaction)),
const digest = utils.arrayify(
utils.keccak256(utils.serializeTransaction(transaction)),
);
// 2. Determine signer address from custom signature + txn
const signer = ethers.utils.recoverAddress(digest, signature);
const signer = utils.recoverAddress(digest, signature);
// 3. Create the signed serialized txn string.
// To be sent directly to the chain using a provider.
const signedSerializedTx = ethers.utils.serializeTransaction(
const signedSerializedTx = utils.serializeTransaction(
transaction,
signature,
);
@@ -1,4 +1,4 @@
import { ethers } from "ethers";
import { utils } from "ethers";
/**
* Generate salt for deployment with Create2
@@ -8,9 +8,9 @@ import { ethers } from "ethers";
* @param bytecode: Creation bytecode of the contract to deploy
*/
export function getSaltHash(bytecode: string): string {
const bytecodeHash = ethers.utils.id(bytecode);
const bytecodeHash = utils.id(bytecode);
const salt = `tw.${bytecodeHash}`;
const saltHash = ethers.utils.id(salt);
const saltHash = utils.id(salt);
return saltHash;
}
@@ -1,5 +1,5 @@
import { Quantity } from "../../../core/schema/shared";
import { ethers } from "ethers";
import { utils, constants } from "ethers";
/**
* @internal
@@ -11,8 +11,8 @@ export function convertQuantityToBigNumber(
tokenDecimals: number,
) {
if (quantity === "unlimited") {
return ethers.constants.MaxUint256;
return constants.MaxUint256;
} else {
return ethers.utils.parseUnits(quantity, tokenDecimals);
return utils.parseUnits(quantity, tokenDecimals);
}
}
@@ -1,4 +1,4 @@
import { BigNumberish, ethers } from "ethers";
import { type BigNumberish, constants, utils } from "ethers";
/**
* @internal
@@ -9,9 +9,9 @@ export function convertToReadableQuantity(
bn: BigNumberish,
tokenDecimals: number,
) {
if (bn.toString() === ethers.constants.MaxUint256.toString()) {
if (bn.toString() === constants.MaxUint256.toString()) {
return "unlimited";
} else {
return ethers.utils.formatUnits(bn, tokenDecimals);
return utils.formatUnits(bn, tokenDecimals);
}
}
@@ -7,13 +7,13 @@ import {
SnapshotFormatVersion,
} from "../sharded-merkle-tree";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { ethers } from "ethers";
import type { providers } from "ethers";
export async function fetchSnapshotEntryForAddress(
address: string,
merkleRoot: string,
merkleMetadata: Record<string, string> | undefined,
provider: ethers.providers.Provider,
provider: providers.Provider,
storage: ThirdwebStorage,
snapshotFormatVersion: SnapshotFormatVersion,
): Promise<SnapshotEntryWithProof | null> {
@@ -5,7 +5,7 @@ import type {
} from "../../types/claim-conditions/claim-conditions";
import { SnapshotFormatVersion } from "../sharded-merkle-tree";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { BigNumber, BigNumberish, constants, ethers, utils } from "ethers";
import { BigNumber, type BigNumberish, constants, utils } from "ethers";
import { approveErc20Allowance } from "../currency/approveErc20Allowance";
import { isNativeToken } from "../currency/isNativeToken";
import { normalizePriceValue } from "../currency/normalizePriceValue";
@@ -54,22 +54,19 @@ export async function prepareClaim(
// override only if not default values (unlimited for quantity, zero addr for currency)
maxClaimable =
snapshotEntry.maxClaimable === "unlimited"
? ethers.constants.MaxUint256
: ethers.utils.parseUnits(
snapshotEntry.maxClaimable,
tokenDecimals,
);
? constants.MaxUint256
: utils.parseUnits(snapshotEntry.maxClaimable, tokenDecimals);
priceInProof =
snapshotEntry.price === undefined ||
snapshotEntry.price === "unlimited"
? ethers.constants.MaxUint256
? constants.MaxUint256
: await normalizePriceValue(
contractWrapper.getProvider(),
snapshotEntry.price,
snapshotEntry.currencyAddress || ethers.constants.AddressZero,
snapshotEntry.currencyAddress || constants.AddressZero,
);
currencyAddressInProof =
snapshotEntry.currencyAddress || ethers.constants.AddressZero;
snapshotEntry.currencyAddress || constants.AddressZero;
} else {
// if no snapshot entry, and it's a v1 format (exclusive allowlist) then address can't claim
if (snapshotFormatVersion === SnapshotFormatVersion.V1) {
@@ -95,19 +92,19 @@ export async function prepareClaim(
// if proof price is unlimited, then we use the price from the claim condition
// this mimics the contract behavior
const pricePerToken =
priceInProof.toString() !== ethers.constants.MaxUint256.toString()
priceInProof.toString() !== constants.MaxUint256.toString()
? priceInProof
: activeClaimCondition.price;
// same for currency address
const currencyAddress =
currencyAddressInProof !== ethers.constants.AddressZero
currencyAddressInProof !== constants.AddressZero
? currencyAddressInProof
: activeClaimCondition.currencyAddress;
if (pricePerToken.gt(0)) {
if (isNativeToken(currencyAddress)) {
overrides["value"] = BigNumber.from(pricePerToken)
.mul(quantity)
.div(ethers.utils.parseUnits("1", tokenDecimals));
.div(utils.parseUnits("1", tokenDecimals));
} else if (checkERC20Allowance) {
await approveErc20Allowance(
contractWrapper,

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