Compare commits

..
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
182a4e7e8f Version Packages (#1528)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-25 09:03:36 -07:00
iketwandGitHub 8b82f3c59c [CLI] Adds support for PWA Vite template (#1538) 2023-08-25 15:38:21 +00:00
YashandGitHub f59b729f8b [SDK] Fix auto-factory deployment: correct bytecode format (#1537) 2023-08-25 14:19:39 +00:00
iketwandGitHub 387dddbd87 [RN] Adds switchToActiveChain to the ConnectWallet button (#1536) 2023-08-25 13:10:17 +00:00
YashandGitHub 911e14fcac [Chains] Add Chiliz Spicy testnet (#1530) 2023-08-24 18:35:05 +00:00
cd6b07b591 feat(sdk): centralize contract reads (#1520)
Co-authored-by: Joaquim Verges <[email protected]>
2023-08-24 04:29:26 +00:00
YashandGitHub 154c55add5 Contracts version 3.9.3-0 (#1527) 2023-08-24 03:33:49 +00:00
65 changed files with 893 additions and 164 deletions
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/auth
## 3.2.37
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@1.1.20
## 3.2.36
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.2.36",
"version": "3.2.37",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/chains
## 0.1.48
### Patch Changes
- [#1530](https://github.com/thirdweb-dev/js/pull/1530) [`911e14fc`](https://github.com/thirdweb-dev/js/commit/911e14fcac743b07fa1a66440c72d662c08e971c) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Add Chiliz Spicy testnet
## 0.1.47
### Patch Changes
+5 -5
View File
@@ -1,10 +1,10 @@
import type { Chain } from "../src/types";
export default {
"name": "Omni Testnet 1",
"name": "Omni Testnet",
"chain": "Omni",
"rpc": [
"https://omni-testnet-1.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet-1.omni.network"
"https://omni-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet.omni.network"
],
"features": [
{
@@ -24,10 +24,10 @@ export default {
"explorers": [
{
"name": "Omni Explorer",
"url": "https://testnet-1.explorer.omni.network",
"url": "https://testnet.explorer.omni.network",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "omni-testnet-1"
"slug": "omni-testnet"
} as const satisfies Chain;
+2 -2
View File
@@ -11,8 +11,8 @@ export default {
},
"rpc": [
"https://horizen-gobi-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://gobi-testnet.horizenlabs.io/ethv1",
"https://rpc.ankr.com/horizen_testnet_evm"
"https://gobi-rpc.horizenlabs.io/ethv1",
"https://rpc.ankr.com/horizen_gobi_testnet"
],
"features": [
{
+34
View File
@@ -0,0 +1,34 @@
import type { Chain } from "../src/types";
export default {
"name": "DeBank Testnet",
"chain": "DeBank",
"rpc": [
"https://debank-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"http://rpc.testnet.debank.com"
],
"faucets": [],
"icon": {
"url": "ipfs://QmW9pBps8WHRRWmyXhjLZrjZJUe8F48hUu7z98bu2RVsjN",
"width": 400,
"height": 400,
"format": "png"
},
"nativeCurrency": {
"name": "DeBank USD",
"symbol": "USD",
"decimals": 18
},
"infoURL": "https://debank.com",
"shortName": "dbk",
"chainId": 2021398,
"networkId": 2021398,
"explorers": [
{
"name": "DeBank Chain Explorer",
"url": "https://explorer.testnet.debank.com",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "debank-testnet"
} as const satisfies Chain;
+31
View File
@@ -0,0 +1,31 @@
import type { Chain } from "../src/types";
export default {
"name": "opBNB Mainnet",
"chain": "opBNB",
"rpc": [
"https://opbnb.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://opbnb-mainnet-rpc.bnbchain.org"
],
"faucets": [
"https://free-online-app.com/faucet-for-eth-evm-chains"
],
"nativeCurrency": {
"name": "BNB Chain Native Token",
"symbol": "BNB",
"decimals": 18
},
"infoURL": "https://opbnb.bnbchain.org/en",
"shortName": "obnb",
"chainId": 204,
"networkId": 204,
"slip44": 714,
"explorers": [
{
"name": "opbnbscan",
"url": "http://mainnet.opbnbscan.com",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "opbnb"
} as const satisfies Chain;
+2 -2
View File
@@ -3,7 +3,7 @@ export default {
"name": "Xpla Mainnet",
"chain": "XPLA",
"rpc": [
"https://xpla.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://xpla-xpla.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://dimension-evm-rpc.xpla.dev"
],
"nativeCurrency": {
@@ -31,5 +31,5 @@ export default {
"redFlags": [
"reusedChainId"
],
"slug": "xpla"
"slug": "xpla-xpla"
} as const satisfies Chain;
+36
View File
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "Xpla Mainnet",
"chain": "XPLA",
"rpc": [
"https://xpla.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://dimension-rpc.xpla.dev"
],
"faucets": [
"https://faucet.xpla.io/"
],
"nativeCurrency": {
"name": "XPLA",
"symbol": "XPLA",
"decimals": 18
},
"infoURL": "https://xpla.io/",
"shortName": "xpla",
"chainId": 3701,
"networkId": 3701,
"icon": {
"url": "ipfs://Qmf4GoxfpeA5VGqu7KP5eyv1WKaCpNDbvMxq1MjQBwFWxq",
"width": 512,
"height": 512,
"format": "png"
},
"explorers": [
{
"name": "XPLA Explorer",
"url": "https://explorer.xpla.io",
"standard": "none"
}
],
"testnet": false,
"slug": "xpla"
} as const satisfies Chain;
+42
View File
@@ -0,0 +1,42 @@
import type { Chain } from "../src/types";
export default {
"name": "KalyChain Mainnet",
"chain": "KLC",
"icon": {
"url": "ipfs://QmUaXcPewLuQtY5a7xPTzJyVdjkH487VfV7gSR8UXrbxQ3",
"width": 512,
"height": 512,
"format": "png"
},
"rpc": [
"https://kalychain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.kalychain.io/rpc"
],
"features": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
}
],
"faucets": [],
"nativeCurrency": {
"name": "KalyCoin",
"symbol": "KLC",
"decimals": 18
},
"infoURL": "https://kalychain.io",
"shortName": "kalymainnet",
"chainId": 3888,
"networkId": 3888,
"explorers": [
{
"name": "KalyScan",
"url": "https://kalyscan.io",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "kalychain"
} as const satisfies Chain;
+42
View File
@@ -0,0 +1,42 @@
import type { Chain } from "../src/types";
export default {
"name": "KalyChain Testnet",
"chain": "KLC",
"icon": {
"url": "ipfs://QmUaXcPewLuQtY5a7xPTzJyVdjkH487VfV7gSR8UXrbxQ3",
"width": 512,
"height": 512,
"format": "png"
},
"rpc": [
"https://kalychain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnetrpc.kalychain.io/rpc"
],
"features": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
}
],
"faucets": [],
"nativeCurrency": {
"name": "KalyCoin",
"symbol": "KLC",
"decimals": 18
},
"infoURL": "https://kalychain.io",
"shortName": "kalytestnet",
"chainId": 3889,
"networkId": 3889,
"explorers": [
{
"name": "KalyScan",
"url": "https://testnet.kalyscan.io",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "kalychain-testnet"
} as const satisfies Chain;
+39
View File
@@ -0,0 +1,39 @@
import type { Chain } from "../src/types";
export default {
"name": "Beam",
"chain": "BEAM",
"rpc": [
"https://beam.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avax.network/beam/mainnet/rpc"
],
"features": [
{
"name": "EIP1559"
}
],
"faucets": [],
"nativeCurrency": {
"name": "Merit Circle",
"symbol": "MC",
"decimals": 18
},
"infoURL": "https://www.onbeam.com",
"shortName": "beam",
"icon": {
"url": "ipfs://QmQJ21NWyGGDraicVEzS1Uqq1yXahM9NCuNZgnfYvtspdt",
"width": 512,
"height": 512,
"format": "png"
},
"chainId": 4337,
"networkId": 4337,
"explorers": [
{
"name": "Beam Explorer",
"url": "https://subnets.avax.network/beam",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "beam"
} as const satisfies Chain;
+23
View File
@@ -0,0 +1,23 @@
import type { Chain } from "../src/types";
export default {
"name": "Tanssi EVM ContainerChain",
"chain": "EVMCC",
"rpc": [
"https://tanssi-evm-containerchain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://fraa-dancebox-3001-rpc.a.dancebox.tanssi.network",
"wss://fraa-dancebox-3001-rpc.a.dancebox.tanssi.network"
],
"faucets": [],
"nativeCurrency": {
"name": "Unit",
"symbol": "Unit",
"decimals": 18
},
"infoURL": "https://tanssi.network",
"shortName": "TanssiCC",
"chainId": 5678,
"networkId": 5678,
"explorers": [],
"testnet": false,
"slug": "tanssi-evm-containerchain"
} as const satisfies Chain;
+36
View File
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "VELO Labs Mainnet",
"chain": "NOVA chain",
"rpc": [
"https://velo-labs.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://nova.velo.org"
],
"faucets": [
"https://nova-faucet.velo.org"
],
"nativeCurrency": {
"name": "Nova",
"symbol": "NOVA",
"decimals": 18
},
"infoURL": "https://velo.org",
"shortName": "VELO",
"chainId": 56789,
"networkId": 56789,
"icon": {
"url": "ipfs://QmYqvnW2jwPEKUv8BdaV4sbL8Audcwosat6SPn4GqYtKxc",
"width": 225,
"height": 225,
"format": "png"
},
"explorers": [
{
"name": "novascan",
"url": "https://novascan.velo.org",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "velo-labs"
} as const satisfies Chain;
+8 -10
View File
@@ -1,19 +1,17 @@
import type { Chain } from "../src/types";
export default {
"name": "BeOne Chain Testnet",
"chain": "BOC",
"name": "Testnet BeOne Chain",
"chain": "tBOC",
"rpc": [
"https://beone-chain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://pre-boc1.beonechain.com",
"https://pre-boc2.beonechain.com",
"https://pre-boc3.beonechain.com"
"https://testnet-beone-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://pre-boc1.beonechain.com"
],
"faucets": [
"https://testnet.beonescan.com/faucet"
],
"nativeCurrency": {
"name": "BeOne Chain Testnet",
"symbol": "BOC",
"name": "Testnet BeOne Chain",
"symbol": "tBOC",
"decimals": 18
},
"infoURL": "https://testnet.beonescan.com",
@@ -28,7 +26,7 @@ export default {
},
"explorers": [
{
"name": "BeOne Chain Testnet",
"name": "Testnet BeOne Chain",
"url": "https://testnet.beonescan.com",
"icon": {
"url": "ipfs://QmbVLQnaMDu86bPyKgCvTGhFBeYwjr15hQnrCcsp1EkAGL",
@@ -40,5 +38,5 @@ export default {
}
],
"testnet": true,
"slug": "beone-chain-testnet"
"slug": "testnet-beone-chain"
} as const satisfies Chain;
+40
View File
@@ -0,0 +1,40 @@
import type { Chain } from "../src/types";
export default {
"name": "Aerie Network",
"chain": "Aerie",
"rpc": [
"https://aerie-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet.aerielab.io"
],
"faucets": [],
"nativeCurrency": {
"name": "Aerie",
"symbol": "AER",
"decimals": 18
},
"infoURL": "https://aerielab.io/",
"shortName": "Aerie",
"chainId": 84886,
"networkId": 84886,
"icon": {
"url": "ipfs://bafkreig54jss26xllpjbclmfgwvot72m4ku7qxignhlqei6mijvwi2m4pu",
"width": 1062,
"height": 1069,
"format": "png"
},
"explorers": [
{
"name": "Aerie Explorer",
"url": "https://explorer.aerielab.io",
"icon": {
"url": "ipfs://bafkreig54jss26xllpjbclmfgwvot72m4ku7qxignhlqei6mijvwi2m4pu",
"width": 1062,
"height": 1069,
"format": "png"
},
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "aerie-network"
} as const satisfies Chain;
+36
View File
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "Spicy Chain",
"chain": "Spicy",
"rpc": [
"https://spicy-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://spicy-rpc.chiliz.com/"
],
"faucets": [
"https://spicy-faucet.chiliz.com/"
],
"nativeCurrency": {
"name": "Chiliz",
"symbol": "CHZ",
"decimals": 18
},
"infoURL": "https://chiliz.com/",
"shortName": "Spicy",
"chainId": 88882,
"networkId": 88882,
"explorers": [
{
"name": "Spicy Explorer",
"url": "http://spicy-explorer.chiliz.com/",
"standard": "none"
}
],
"icon": {
"url": "ipfs://QmTGYofJ8VLkeNY4J69AvXi8e126kmbHmf34wLFoJ1FKAK",
"width": 400,
"height": 400,
"format": "png"
},
"testnet": true,
"slug": "spicy-chain"
} as const satisfies Chain;
+2 -1
View File
@@ -10,7 +10,8 @@ export default {
},
"rpc": [
"https://mind-smart-chain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet-msc.mindchain.info/"
"https://testnet-msc.mindchain.info/",
"wss://testnet-msc.mindchain.info/ws"
],
"faucets": [
"https://faucet.mindchain.info/"
+33
View File
@@ -0,0 +1,33 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "Spicy Chain",
chain: "Spicy",
rpc: ["https://spicy-rpc.chiliz.com/"],
faucets: ["https://spicy-faucet.chiliz.com/"],
nativeCurrency: {
name: "Chiliz",
symbol: "CHZ",
decimals: 18,
},
infoURL: "https://chiliz.com/",
shortName: "Spicy",
chainId: 88882,
networkId: 88882,
explorers: [
{
name: "Spicy Explorer",
url: "http://spicy-explorer.chiliz.com/",
standard: "none",
},
],
icon: {
url: "ipfs://QmTGYofJ8VLkeNY4J69AvXi8e126kmbHmf34wLFoJ1FKAK",
width: 400,
height: 400,
format: "png",
},
testnet: true,
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/chains",
"version": "0.1.47",
"version": "0.1.48",
"main": "dist/thirdweb-dev-chains.cjs.js",
"module": "dist/thirdweb-dev-chains.esm.js",
"browser": {
File diff suppressed because one or more lines are too long
+16
View File
@@ -1,5 +1,21 @@
# thirdweb
## 0.11.20
### Patch Changes
- [#1538](https://github.com/thirdweb-dev/js/pull/1538) [`8b82f3c5`](https://github.com/thirdweb-dev/js/commit/8b82f3c59cad6bd1167c13cb0b8a1cdc36475ab8) Thanks [@iketw](https://github.com/iketw)! - Adds support for creating PWA Vite apps
You can now run:
```bash
npx thirdweb@nightly create --template pwa-vite-typescript-starter
```
- Updated dependencies [[`f59b729f`](https://github.com/thirdweb-dev/js/commit/f59b729f8b09aa86655b8e8a70fba644fc52009b), [`911e14fc`](https://github.com/thirdweb-dev/js/commit/911e14fcac743b07fa1a66440c72d662c08e971c), [`cd6b07b5`](https://github.com/thirdweb-dev/js/commit/cd6b07b591606d2671794cebebf8edcb59076c32)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.11.19
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.11.19",
"version": "0.11.20",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+6
View File
@@ -69,6 +69,9 @@ export async function twCreate(
if (options.reactNative) {
framework = "react-native";
}
if (options.pwaVite) {
framework = "pwa-vite";
}
if (options.solana) {
chain = "solana";
@@ -239,6 +242,7 @@ export async function twCreate(
{ title: "Next.js", value: "next" },
{ title: "Create React App", value: "cra" },
{ title: "Vite", value: "vite" },
{ title: "PWA Vite", value: "pwa-vite" },
{ title: "React Native", value: "react-native" },
{ title: "Node.js", value: "node" },
{ title: "Express", value: "express" },
@@ -265,6 +269,8 @@ export async function twCreate(
if (typeof res.project === "string") {
language = res.project.trim();
}
} else if (framework === "pwa-vite" || framework === "pwa-next") {
language = "typescript";
} else {
const res = await prompts({
type: "select",
@@ -220,7 +220,7 @@ export async function createApp({
}
let startOrDev: string | undefined;
if (framework && (framework === "next" || framework === "vite")) {
if (framework && (framework.includes("next") || framework.includes("vite"))) {
startOrDev = "dev";
} else if (template) {
startOrDev = await getStartOrDev(template);
+1 -1
View File
@@ -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.8.5"
"@thirdweb-dev/contracts": "3.9.3-0"
},
"devDependencies": {
"@babel/preset-env": "^7.22.9",
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/react-core
## 3.14.37
### Patch Changes
- Updated dependencies [[`f59b729f`](https://github.com/thirdweb-dev/js/commit/f59b729f8b09aa86655b8e8a70fba644fc52009b), [`911e14fc`](https://github.com/thirdweb-dev/js/commit/911e14fcac743b07fa1a66440c72d662c08e971c), [`cd6b07b5`](https://github.com/thirdweb-dev/js/commit/cd6b07b591606d2671794cebebf8edcb59076c32)]:
- @thirdweb-dev/sdk@3.10.56
- @thirdweb-dev/chains@0.1.48
- @thirdweb-dev/wallets@1.1.20
- @thirdweb-dev/auth@3.2.37
## 3.14.36
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "3.14.36",
"version": "3.14.37",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -1,5 +1,7 @@
# @thirdweb-dev/react-native-compat
## 0.2.56
## 0.2.55
## 0.2.54
+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.55",
"version": "0.2.56",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+24
View File
@@ -1,5 +1,29 @@
# @thirdweb-dev/react-native
## 0.2.56
### Patch Changes
- [#1536](https://github.com/thirdweb-dev/js/pull/1536) [`387dddbd`](https://github.com/thirdweb-dev/js/commit/387dddbd87ff6c1a53ffaf663564a44b89a3a2a5) Thanks [@iketw](https://github.com/iketw)! - Adds switchToActiveChain prop to the ConnectWallet button.
When set to true it will show a "Switch Network" button if the wallet
is connected to a different chain than the `activeChain` provided in `ThirdwebProvider`
**Note:** IF you support multiple networks in your app this prop should
be set to `false` to allow users to switch between networks.
Usage:
```javascript
<ConnectWallet switchToActiveChain={true} />
```
- Updated dependencies [[`f59b729f`](https://github.com/thirdweb-dev/js/commit/f59b729f8b09aa86655b8e8a70fba644fc52009b), [`911e14fc`](https://github.com/thirdweb-dev/js/commit/911e14fcac743b07fa1a66440c72d662c08e971c), [`cd6b07b5`](https://github.com/thirdweb-dev/js/commit/cd6b07b591606d2671794cebebf8edcb59076c32)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.55
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.2.55",
"version": "0.2.56",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -3,11 +3,18 @@ import {
ConnectWalletDetailsProps,
WalletDetailsButton,
} from "./ConnectWalletDetails/WalletDetailsButton";
import { useAddress } from "@thirdweb-dev/react-core";
import { useEffect, useRef } from "react";
import { Animated } from "react-native";
import {
useAddress,
useNetworkMismatch,
useSwitchChain,
useWalletContext,
} from "@thirdweb-dev/react-core";
import { useEffect, useRef, useState } from "react";
import { ActivityIndicator, Animated, StyleSheet } from "react-native";
import { ConnectWalletButton } from "./ConnectWalletFlow/ConnectWalletButton";
import { ConnectWalletButtonProps } from "./ConnectWalletFlow/ConnectWalletButton";
import BaseButton from "./base/BaseButton";
import Text from "./base/Text";
export type ConnectWalletProps = {
/**
@@ -26,6 +33,17 @@ export type ConnectWalletProps = {
* @default false
*/
hideTestnetFaucet?: boolean;
/**
* Whether to show "Switch Network" button if the wallet is connected,
* but it is not connected to the `activeChain` provided in `ThirdwebProvider`
*
* Please, note that if you support multiple networks in your app this prop should
* be set to `false` to allow users to switch between networks.
*
* @default false
*/
switchToActiveChain?: boolean;
} & ConnectWalletButtonProps;
export const ConnectWallet = ({
@@ -35,9 +53,15 @@ export const ConnectWallet = ({
modalTitle,
extraRows,
hideTestnetFaucet,
switchToActiveChain,
}: ConnectWalletProps) => {
const fadeAnim = useRef(new Animated.Value(0)).current;
const address = useAddress();
const isNetworkMismatch = useNetworkMismatch();
const { activeChainSetExplicitly } = useWalletContext();
const { activeChain } = useWalletContext();
const switchChain = useSwitchChain();
const [switching, setSwitching] = useState(false);
useEffect(() => {
Animated.timing(fadeAnim, {
@@ -51,12 +75,38 @@ export const ConnectWallet = ({
<ThemeProvider theme={theme}>
<Animated.View style={{ opacity: fadeAnim }}>
{address ? (
<WalletDetailsButton
address={address}
detailsButton={detailsButton}
extraRows={extraRows}
hideTestnetFaucet={hideTestnetFaucet}
/>
switchToActiveChain &&
isNetworkMismatch &&
activeChainSetExplicitly ? (
<BaseButton
backgroundColor="buttonBackgroundColor"
onPress={async () => {
setSwitching(true);
try {
await switchChain(activeChain.chainId);
} catch {
// ignore
}
setSwitching(false);
}}
style={styles.connectWalletButton}
>
{switching ? (
<ActivityIndicator size="small" color="buttonTextColor" />
) : (
<Text variant="bodyLarge" color="buttonTextColor">
Switch Network
</Text>
)}
</BaseButton>
) : (
<WalletDetailsButton
address={address}
detailsButton={detailsButton}
extraRows={extraRows}
hideTestnetFaucet={hideTestnetFaucet}
/>
)
) : (
<ConnectWalletButton
modalTitle={modalTitle}
@@ -68,3 +118,17 @@ export const ConnectWallet = ({
</ThemeProvider>
);
};
const styles = StyleSheet.create({
connectWalletButton: {
display: "flex",
flexDirection: "row",
alignContent: "center",
alignItems: "center",
justifyContent: "center",
borderRadius: 8,
paddingHorizontal: 10,
paddingVertical: 10,
minWidth: 150,
},
});
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/react
## 3.14.37
### Patch Changes
- Updated dependencies [[`f59b729f`](https://github.com/thirdweb-dev/js/commit/f59b729f8b09aa86655b8e8a70fba644fc52009b), [`911e14fc`](https://github.com/thirdweb-dev/js/commit/911e14fcac743b07fa1a66440c72d662c08e971c), [`cd6b07b5`](https://github.com/thirdweb-dev/js/commit/cd6b07b591606d2671794cebebf8edcb59076c32)]:
- @thirdweb-dev/sdk@3.10.56
- @thirdweb-dev/chains@0.1.48
- @thirdweb-dev/react-core@3.14.37
- @thirdweb-dev/wallets@1.1.20
## 3.14.36
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.14.36",
"version": "3.14.37",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -59,7 +59,11 @@ type ConnectWalletProps = {
hideTestnetFaucet?: boolean;
/**
* Whether to show "Switch Network" button if wallet connected, but it is not connected to the `activeChain` provided in `ThirdwebProvider`
* Whether to show "Switch Network" button if the wallet is connected,
* but it is not connected to the `activeChain` provided in `ThirdwebProvider`
*
* Please, note that if you support multiple networks in your app this prop should
* be set to `false` to allow users to switch between networks.
*
* @default false
*/
+11
View File
@@ -1,5 +1,16 @@
# @thirdweb-dev/sdk
## 3.10.56
### Patch Changes
- [#1537](https://github.com/thirdweb-dev/js/pull/1537) [`f59b729f`](https://github.com/thirdweb-dev/js/commit/f59b729f8b09aa86655b8e8a70fba644fc52009b) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Fix auto-factory deployment: correct bytecode format
- [#1520](https://github.com/thirdweb-dev/js/pull/1520) [`cd6b07b5`](https://github.com/thirdweb-dev/js/commit/cd6b07b591606d2671794cebebf8edcb59076c32) Thanks [@ElasticBottle](https://github.com/ElasticBottle)! - internal(sdk): update read calls to be centralized in contract-wrapper.ts
- Updated dependencies [[`911e14fc`](https://github.com/thirdweb-dev/js/commit/911e14fcac743b07fa1a66440c72d662c08e971c)]:
- @thirdweb-dev/chains@0.1.48
## 3.10.55
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "3.10.55",
"version": "3.10.56",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
@@ -15,12 +15,15 @@ export function computeDeploymentAddress(
create2FactoryAddress: string,
salt?: string,
): string {
const saltHash = salt ? utils.id(salt) : getSaltHash(bytecode);
const bytecodePrefixed = bytecode.startsWith("0x")
? bytecode
: `0x${bytecode}`;
const saltHash = salt ? utils.id(salt) : getSaltHash(bytecodePrefixed);
// 1. create init bytecode hash with contract's bytecode and encoded args
const initBytecode = utils.solidityPack(
["bytes", "bytes"],
[bytecode, encodedArgs],
[bytecodePrefixed, encodedArgs],
);
// 2. abi-encode pack the deployer address, salt, and bytecode hash
@@ -15,11 +15,14 @@ export function getInitBytecodeWithSalt(
encodedArgs: BytesLike,
salt?: string,
): string {
const saltHash = salt ? utils.id(salt) : getSaltHash(bytecode);
const bytecodePrefixed = bytecode.startsWith("0x")
? bytecode
: `0x${bytecode}`;
const saltHash = salt ? utils.id(salt) : getSaltHash(bytecodePrefixed);
const initBytecodeWithSalt = utils.solidityPack(
["bytes32", "bytes", "bytes"],
[saltHash, bytecode, encodedArgs],
[saltHash, bytecodePrefixed, encodedArgs],
);
return initBytecodeWithSalt;
@@ -8,7 +8,10 @@ import { utils } from "ethers";
* @param bytecode: Creation bytecode of the contract to deploy
*/
export function getSaltHash(bytecode: string): string {
const bytecodeHash = utils.id(bytecode);
const bytecodePrefixed = bytecode.startsWith("0x")
? bytecode
: `0x${bytecode}`;
const bytecodeHash = utils.id(bytecodePrefixed);
const salt = `tw.${bytecodeHash}`;
const saltHash = utils.id(salt);
@@ -1,7 +1,7 @@
import { ContractWrapper } from "../../core/classes/contract-wrapper";
import type { IERC20 } from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
import { BigNumber, type BigNumberish, utils } from "ethers";
import { BigNumber, utils, type BigNumberish } from "ethers";
import { ContractWrapper } from "../../core/classes/contract-wrapper";
export async function approveErc20Allowance(
contractToApprove: ContractWrapper<any>,
@@ -20,8 +20,8 @@ export async function approveErc20Allowance(
contractToApprove.storage,
);
const owner = await contractToApprove.getSignerAddress();
const spender = contractToApprove.readContract.address;
const allowance = await erc20.readContract.allowance(owner, spender);
const spender = contractToApprove.address;
const allowance = await erc20.read("allowance", [owner, spender]);
const totalPrice = BigNumber.from(price)
.mul(BigNumber.from(quantity))
.div(utils.parseUnits("1", tokenDecimals));
@@ -1,7 +1,7 @@
import { ContractWrapper } from "../../core/classes/contract-wrapper";
import type { IERC20 } from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
import { BigNumber } from "ethers";
import { ContractWrapper } from "../../core/classes/contract-wrapper";
export async function hasERC20Allowance(
contractToApprove: ContractWrapper<any>,
@@ -17,7 +17,7 @@ export async function hasERC20Allowance(
contractToApprove.storage,
);
const owner = await contractToApprove.getSignerAddress();
const spender = contractToApprove.readContract.address;
const allowance = await erc20.readContract.allowance(owner, spender);
const spender = contractToApprove.address;
const allowance = await erc20.read("allowance", [owner, spender]);
return allowance.gte(value);
}
@@ -1,13 +1,13 @@
import { BigNumber, utils } from "ethers";
import { AmountSchema } from "../../../core/schema/shared";
import { ContractWrapper } from "../../core/classes/contract-wrapper";
import { Amount } from "../../types/currency";
import { BaseERC20 } from "../../types/eips";
import { BigNumber, utils } from "ethers";
export async function normalizeAmount(
contractWrapper: ContractWrapper<BaseERC20>,
amount: Amount,
): Promise<BigNumber> {
const decimals = await contractWrapper.readContract.decimals();
const decimals = await contractWrapper.read("decimals", []);
return utils.parseUnits(AmountSchema.parse(amount), decimals);
}
@@ -48,7 +48,7 @@ export class EditionDrop extends StandardErc1155<PrebuiltEditionDrop> {
private static contractRoles = NFT_BASE_CONTRACT_ROLES;
public abi: Abi;
public sales: ContractPrimarySale<PrebuiltEditionDrop>;
public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<PrebuiltEditionDrop>;
public encoder: ContractEncoder<PrebuiltEditionDrop>;
public estimator: GasCostEstimator<PrebuiltEditionDrop>;
@@ -56,7 +56,7 @@ export class Edition extends StandardErc1155<TokenERC1155> {
TokenERC1155,
(typeof Edition.contractRoles)[number]
>;
public sales: ContractPrimarySale<TokenERC1155>;
public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<TokenERC1155>;
public encoder: ContractEncoder<TokenERC1155>;
public estimator: GasCostEstimator<TokenERC1155>;
@@ -58,7 +58,7 @@ export class NFTCollection extends StandardErc721<TokenERC721> {
public encoder: ContractEncoder<TokenERC721>;
public estimator: GasCostEstimator<TokenERC721>;
public events: ContractEvents<TokenERC721>;
public sales: ContractPrimarySale<TokenERC721>;
public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<TokenERC721>;
/**
* Configure royalties
@@ -60,7 +60,7 @@ export class NFTDrop extends StandardErc721<PrebuiltNFTDrop> {
typeof DropErc721ContractSchema
>;
public app: ContractAppURI<PrebuiltNFTDrop>;
public sales: ContractPrimarySale<PrebuiltNFTDrop>;
public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<PrebuiltNFTDrop>;
public events: ContractEvents<PrebuiltNFTDrop>;
public roles: ContractRoles<
@@ -65,7 +65,7 @@ export class SignatureDrop extends StandardErc721<SignatureDropContract> {
typeof DropErc721ContractSchema
>;
public app: ContractAppURI<SignatureDropContract>;
public sales: ContractPrimarySale<SignatureDropContract>;
public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<SignatureDropContract>;
public events: ContractEvents<SignatureDropContract>;
public roles: ContractRoles<
@@ -1,3 +1,11 @@
import type {
IERC20,
Split as SplitContract,
} from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { BigNumber, CallOverrides, Contract } from "ethers";
import { fetchCurrencyValue } from "../../common/currency/fetchCurrencyValue";
import { resolveAddress } from "../../common/ens/resolveAddress";
import { buildTransactionFunction } from "../../common/transactions";
import { ContractAppURI } from "../../core/classes/contract-appuri";
@@ -11,21 +19,13 @@ import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions";
import { UpdateableNetwork } from "../../core/interfaces/contract";
import { NetworkInput } from "../../core/types";
import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema";
import { Address } from "../../schema/shared/Address";
import { Abi, AbiInput, AbiSchema } from "../../schema/contracts/custom";
import { SplitsContractSchema } from "../../schema/contracts/splits";
import { SDKOptions } from "../../schema/sdk-options";
import { Address } from "../../schema/shared/Address";
import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema";
import { SplitRecipient } from "../../types/SplitRecipient";
import { CurrencyValue } from "../../types/currency";
import type {
IERC20,
Split as SplitContract,
} from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { BigNumber, CallOverrides, Contract } from "ethers";
import { fetchCurrencyValue } from "../../common/currency/fetchCurrencyValue";
import { ADMIN_ROLE } from "../contractRoles";
/**
@@ -54,7 +54,7 @@ export class TokenDrop extends StandardErc20<PrebuiltTokenDrop> {
>;
public encoder: ContractEncoder<PrebuiltTokenDrop>;
public estimator: GasCostEstimator<PrebuiltTokenDrop>;
public sales: ContractPrimarySale<PrebuiltTokenDrop>;
public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<PrebuiltTokenDrop>;
public events: ContractEvents<PrebuiltTokenDrop>;
/**
@@ -58,7 +58,7 @@ export class Token extends StandardErc20<TokenERC20> {
public history: TokenERC20History;
public events: ContractEvents<TokenERC20>;
public platformFees: ContractPlatformFee<TokenERC20>;
public sales: ContractPrimarySale<TokenERC20>;
public sales: ContractPrimarySale;
/**
* Signature Minting
* @remarks Generate tokens that can be minted only with your own signature, attaching your own set of mint conditions.
@@ -112,7 +112,7 @@ export class Vote implements UpdateableNetwork {
}
getAddress(): Address {
return this.contractWrapper.readContract.address;
return this.contractWrapper.address;
}
/** ******************************
@@ -151,7 +151,7 @@ export class Vote implements UpdateableNetwork {
*/
public async getAll(): Promise<Proposal[]> {
return Promise.all(
(await this.contractWrapper.readContract.getAllProposals()).map(
(await this.contractWrapper.read("getAllProposals", [])).map(
async (data) => ({
proposalId: data.proposalId,
proposer: data.proposer,
@@ -136,7 +136,7 @@ export class SmartContract<
/**
* Handle primary sales
*/
get sales(): ContractPrimarySale<IPrimarySale> {
get sales(): ContractPrimarySale {
return assertEnabled(this.detectPrimarySales(), FEATURE_PRIMARY_SALE);
}
@@ -317,7 +317,7 @@ export class SmartContract<
get airdrop1155(): Airdrop1155<AirdropERC1155> {
return assertEnabled(this.detectAirdrop1155(), FEATURE_AIRDROP_ERC1155);
}
/**
* Account Factory
*
@@ -594,7 +594,10 @@ export class SmartContract<
private detectAirdrop721() {
if (
detectContractFeature<AirdropERC721>(this.contractWrapper, "AirdropERC721")
detectContractFeature<AirdropERC721>(
this.contractWrapper,
"AirdropERC721",
)
) {
return new Airdrop721(this.contractWrapper);
}
@@ -603,7 +606,10 @@ export class SmartContract<
private detectAirdrop1155() {
if (
detectContractFeature<AirdropERC1155>(this.contractWrapper, "AirdropERC1155")
detectContractFeature<AirdropERC1155>(
this.contractWrapper,
"AirdropERC1155",
)
) {
return new Airdrop1155(this.contractWrapper);
}
@@ -1,30 +1,30 @@
import { BigNumber, utils } from "ethers";
import { FEATURE_ACCOUNT_PERMISSIONS } from "../../constants/thirdweb-features";
import { DetectableFeature } from "../interfaces/DetectableFeature";
import { ContractWrapper } from "./contract-wrapper";
import { FEATURE_ACCOUNT_PERMISSIONS } from "../../constants/thirdweb-features";
import { utils, BigNumber } from "ethers";
import { Transaction } from "./transactions";
import type {
IAccountCore,
IAccountPermissions,
} from "@thirdweb-dev/contracts-js";
import invariant from "tiny-invariant";
import { resolveAddress } from "../../common";
import { resolveOrGenerateId } from "../../common/signature-minting";
import { buildTransactionFunction } from "../../common/transactions";
import { AddressOrEns } from "../../schema";
import {
PermissionSnapshotInput,
PermissionSnapshotOutput,
PermissionSnapshotSchema,
SignedSignerPermissionsPayload,
SignerPermissionsOutput,
SignerWithPermissions,
SignerPermissionRequest,
SignerPermissions,
SignerPermissionsInput,
SignerPermissionRequest,
SignerPermissionsOutput,
SignerPermissionsSchema,
PermissionSnapshotInput,
PermissionSnapshotSchema,
PermissionSnapshotOutput,
SignerWithPermissions,
} from "../../types";
import invariant from "tiny-invariant";
import { buildTransactionFunction } from "../../common/transactions";
import { resolveOrGenerateId } from "../../common/signature-minting";
import { AddressOrEns } from "../../schema";
import { resolveAddress } from "../../common";
export class AccountPermissions implements DetectableFeature {
featureName = FEATURE_ACCOUNT_PERMISSIONS.name;
@@ -91,11 +91,11 @@ export class AccountPermissions implements DetectableFeature {
permissions,
);
const { success } =
await this.contractWrapper.readContract.verifySignerPermissionRequest(
payload,
signature,
);
const [success] = await this.contractWrapper.read(
"verifySignerPermissionRequest",
[payload, signature],
);
if (!success) {
throw new Error(`Invalid signature.`);
}
@@ -1,3 +1,4 @@
import type { Ownable } from "@thirdweb-dev/contracts-js";
import { resolveAddress } from "../../common/ens/resolveAddress";
import { buildTransactionFunction } from "../../common/transactions";
import { FEATURE_OWNER } from "../../constants/thirdweb-features";
@@ -5,7 +6,6 @@ import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema";
import { DetectableFeature } from "../interfaces/DetectableFeature";
import { ContractWrapper } from "./contract-wrapper";
import { Transaction } from "./transactions";
import type { Ownable } from "@thirdweb-dev/contracts-js";
/**
* Encodes and decodes Contract functions
@@ -1,10 +1,10 @@
import type { IPrimarySale } from "@thirdweb-dev/contracts-js";
import { buildTransactionFunction } from "../../common/transactions";
import { FEATURE_PRIMARY_SALE } from "../../constants/thirdweb-features";
import { Address } from "../../schema/shared/Address";
import { DetectableFeature } from "../interfaces/DetectableFeature";
import { ContractWrapper } from "./contract-wrapper";
import { Transaction } from "./transactions";
import type { IPrimarySale } from "@thirdweb-dev/contracts-js";
/**
* Handle primary sales recipients
@@ -17,13 +17,11 @@ import type { IPrimarySale } from "@thirdweb-dev/contracts-js";
* ```
* @public
*/
export class ContractPrimarySale<TContract extends IPrimarySale>
implements DetectableFeature
{
export class ContractPrimarySale implements DetectableFeature {
featureName = FEATURE_PRIMARY_SALE.name;
private contractWrapper;
constructor(contractWrapper: ContractWrapper<TContract>) {
constructor(contractWrapper: ContractWrapper<IPrimarySale>) {
this.contractWrapper = contractWrapper;
}
@@ -38,7 +36,8 @@ export class ContractPrimarySale<TContract extends IPrimarySale>
* @twfeature PrimarySale
*/
public async getRecipient(): Promise<Address> {
return await this.contractWrapper.readContract.primarySaleRecipient();
const result = await this.contractWrapper.read("primarySaleRecipient", []);
return result;
}
/**
@@ -54,7 +53,7 @@ export class ContractPrimarySale<TContract extends IPrimarySale>
setRecipient = /* @__PURE__ */ buildTransactionFunction(
async (recipient: string): Promise<Transaction> => {
return Transaction.fromContractWrapper({
contractWrapper: this.contractWrapper as ContractWrapper<IPrimarySale>,
contractWrapper: this.contractWrapper,
method: "setPrimarySaleRecipient",
args: [recipient],
});
@@ -1,8 +1,25 @@
import ForwarderABI from "@thirdweb-dev/contracts-js/dist/abis/Forwarder.json";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import fetch from "cross-fetch";
import {
BaseContract,
BigNumber,
Contract,
ContractTransaction,
constants,
utils,
type BytesLike,
type CallOverrides,
type ContractFunction,
type ContractInterface,
type Signer,
type providers,
} from "ethers";
import invariant from "tiny-invariant";
import { computeEOAForwarderAddress } from "../../common/any-evm-utils/computeEOAForwarderAddress";
import { computeForwarderAddress } from "../../common/any-evm-utils/computeForwarderAddress";
import { parseRevertReason, TransactionError } from "../../common/error";
import { TransactionError, parseRevertReason } from "../../common/error";
import { extractFunctionsFromAbi } from "../../common/feature-detection/extractFunctionsFromAbi";
import { fetchContractMetadataFromAddress } from "../../common/metadata-resolver";
import { fetchSourceFilesFromMetadata } from "../../common/fetchSourceFilesFromMetadata";
import {
BiconomyForwarderAbi,
@@ -11,15 +28,18 @@ import {
getAndIncrementNonce,
} from "../../common/forwarder";
import { getPolygonGasPriorityFee } from "../../common/gas-price";
import { fetchContractMetadataFromAddress } from "../../common/metadata-resolver";
import { signEIP2612Permit } from "../../common/permit";
import { signTypedDataInternal } from "../../common/sign";
import { isBrowser } from "../../common/utils";
import { CONTRACT_ADDRESSES } from "../../constants/addresses/CONTRACT_ADDRESSES";
import { getContractAddressByChainId } from "../../constants/addresses/getContractAddressByChainId";
import { ChainId } from "../../constants/chains/ChainId";
import { EventType } from "../../constants/events";
import { Address } from "../../schema/shared/Address";
import { CallOverrideSchema } from "../../schema/shared/CallOverrideSchema";
import { AbiSchema, ContractSource } from "../../schema/contracts/custom";
import { SDKOptions } from "../../schema/sdk-options";
import { Address } from "../../schema/shared/Address";
import { CallOverrideSchema } from "../../schema/shared/CallOverrideSchema";
import {
ForwardRequestMessage,
GaslessTransaction,
@@ -27,26 +47,6 @@ import {
PermitRequestMessage,
} from "../types";
import { RPCConnectionHandler } from "./rpc-connection-handler";
import ForwarderABI from "@thirdweb-dev/contracts-js/dist/abis/Forwarder.json";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import fetch from "cross-fetch";
import {
BaseContract,
BigNumber,
type BytesLike,
type CallOverrides,
Contract,
type ContractInterface,
type ContractTransaction,
utils,
type ContractFunction,
type providers,
type Signer,
constants,
} from "ethers";
import invariant from "tiny-invariant";
import { CONTRACT_ADDRESSES } from "../../constants/addresses/CONTRACT_ADDRESSES";
import { getContractAddressByChainId } from "../../constants/addresses/getContractAddressByChainId";
/**
* @internal
@@ -63,6 +63,7 @@ export class ContractWrapper<
public writeContract;
public readContract;
public abi;
public address;
constructor(
network: NetworkInput,
@@ -73,6 +74,7 @@ export class ContractWrapper<
) {
super(network, options);
this.abi = contractAbi;
this.address = contractAddress;
// set up the contract
this.writeContract = new Contract(
contractAddress,
@@ -271,6 +273,74 @@ export class ContractWrapper<
this.customOverrides = hook;
}
/**
*
* @param functionName The function name on the contract to call
* @param args The arguments to be passed to the functionName
* @returns The return value of the function call
*/
public async read<
OverrideContract extends BaseContract = TContract,
FnName extends
keyof OverrideContract["functions"] = keyof OverrideContract["functions"],
Param extends Parameters<
OverrideContract["functions"][FnName]
> = Parameters<OverrideContract["functions"][FnName]>,
>(
functionName: FnName,
args: Param,
): Promise<
Awaited<ReturnType<OverrideContract["functions"][FnName]>> extends {
length: 1;
}
? Awaited<ReturnType<OverrideContract["functions"][FnName]>>[0]
: Awaited<ReturnType<OverrideContract["functions"][FnName]>>
> {
const functions = extractFunctionsFromAbi(AbiSchema.parse(this.abi)).filter(
(f) => f.name === functionName,
);
if (!functions.length) {
throw new Error(
`Function "${functionName.toString()}" not found in contract. Check your dashboard for the list of functions available`,
);
}
const fn = functions.find(
(f) => f.name === functionName && f.inputs.length === args.length,
);
// TODO extract this and re-use for deploy function to check constructor args
if (!fn) {
throw new Error(
`Function "${functionName.toString()}" requires ${
functions[0].inputs.length
} arguments, but ${
args.length
} were provided.\nExpected function signature: ${
functions[0].signature
}`,
);
}
const ethersFnName = `${functionName.toString()}(${fn.inputs
.map((i) => i.type)
.join()})`;
// check if the function exists on the contract, otherwise use the name passed in
const fnName =
ethersFnName in this.readContract.functions ? ethersFnName : functionName;
if (fn.stateMutability === "view" || fn.stateMutability === "pure") {
// read function
const result = await (this.readContract as any)[fnName.toString()](
...args,
);
return result;
}
throw new Error("Cannot call a write function with read()");
}
/**
* @internal
*/
@@ -367,9 +437,7 @@ export class ContractWrapper<
} else {
// one time verification that this is a valid contract (to avoid sending funds to wrong addresses)
if (!this.isValidContract) {
const code = await this.getProvider().getCode(
this.readContract.address,
);
const code = await this.getProvider().getCode(this.address);
this.isValidContract = code !== "0x";
if (!this.isValidContract) {
throw new Error(
@@ -476,7 +544,7 @@ export class ContractWrapper<
// Get metadata for transaction to populate into error
const network = await provider.getNetwork();
const from = await (callOverrides.from || this.getSignerAddress());
const to = this.readContract.address;
const to = this.address;
const data = this.readContract.interface.encodeFunctionData(
fn as string,
args,
@@ -516,7 +584,7 @@ export class ContractWrapper<
let contractName: string | undefined = undefined;
try {
const metadata = await fetchContractMetadataFromAddress(
this.readContract.address,
this.address,
this.getProvider(),
this.storage,
this.options,
@@ -888,7 +956,7 @@ export class ContractWrapper<
const { r, s, v } = utils.splitSignature(sig);
message = {
to: this.readContract.address,
to: this.address,
owner: permit.owner,
spender: permit.spender,
value: BigNumber.from(permit.value).toString(),
@@ -12,8 +12,8 @@ import { DetectableFeature } from "../interfaces/DetectableFeature";
import { UpdateableNetwork } from "../interfaces/contract";
import { ContractWrapper } from "./contract-wrapper";
import { Erc20 } from "./erc-20";
import type { ERC20, PackVRFDirect } from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/ERC20.json";
import type { ERC20Base, PackVRFDirect } from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
import IPackAbi from "@thirdweb-dev/contracts-js/dist/abis/IPackVRFDirect.json";
import {
ITokenBundle,
@@ -340,7 +340,7 @@ export class PackVRF implements UpdateableNetwork, DetectableFeature {
`No LINK token address found for chainId ${this.chainId}`,
);
}
const contract = new ContractWrapper<ERC20>(
const contract = new ContractWrapper<ERC20Base>(
this.contractWrapper.getSignerOrProvider(),
linkAddress,
ERC20Abi,
@@ -1,8 +1,8 @@
import { SignatureDrop } from "@thirdweb-dev/contracts-js/dist/declarations/src/SignatureDrop";
import { ChainId } from "../constants/chains/ChainId";
import { ContractWrapper } from "../core/classes/contract-wrapper";
import { SignedPayload721WithQuantitySignature } from "../schema/contracts/common/signature";
import { PrebuiltEditionDrop, PrebuiltNFTDrop } from "../types/eips";
import { SignatureDrop } from "@thirdweb-dev/contracts-js/dist/declarations/src/SignatureDrop";
// import fetch from "cross-fetch";
import invariant from "tiny-invariant";
@@ -213,7 +213,7 @@ export class PaperCheckout<
private async getCheckoutId(): Promise<string> {
return fetchRegisteredCheckoutId(
this.contractWrapper.readContract.address,
this.contractWrapper.address,
await this.contractWrapper.getChainID(),
);
}
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/unity-js-bridge
## 0.2.74
### Patch Changes
- Updated dependencies [[`f59b729f`](https://github.com/thirdweb-dev/js/commit/f59b729f8b09aa86655b8e8a70fba644fc52009b), [`911e14fc`](https://github.com/thirdweb-dev/js/commit/911e14fcac743b07fa1a66440c72d662c08e971c), [`cd6b07b5`](https://github.com/thirdweb-dev/js/commit/cd6b07b591606d2671794cebebf8edcb59076c32)]:
- @thirdweb-dev/sdk@3.10.56
- @thirdweb-dev/chains@0.1.48
- @thirdweb-dev/wallets@1.1.20
- @thirdweb-dev/auth@3.2.37
## 0.2.73
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.73",
"version": "0.2.74",
"main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0",
+8
View File
@@ -1,5 +1,13 @@
# @thirdweb-dev/wallets
## 1.1.20
### Patch Changes
- Updated dependencies [[`f59b729f`](https://github.com/thirdweb-dev/js/commit/f59b729f8b09aa86655b8e8a70fba644fc52009b), [`911e14fc`](https://github.com/thirdweb-dev/js/commit/911e14fcac743b07fa1a66440c72d662c08e971c), [`cd6b07b5`](https://github.com/thirdweb-dev/js/commit/cd6b07b591606d2671794cebebf8edcb59076c32)]:
- @thirdweb-dev/sdk@3.10.56
- @thirdweb-dev/chains@0.1.48
## 1.1.19
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "1.1.19",
"version": "1.1.20",
"main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js",
"types": "dist/thirdweb-dev-wallets.cjs.d.ts",
+79 -17
View File
@@ -1,5 +1,9 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
overrides:
cross-fetch@>=3.0.0 <3.1.5: '>=3.1.5'
got@<11.8.5: '>=11.8.5'
@@ -156,7 +160,7 @@ importers:
version: link:../eslint-config-thirdweb
eslint-plugin-import:
specifier: ^2.26.0
version: 2.27.5(@typescript-eslint/parser@5.60.1)([email protected])([email protected])
version: 2.27.5(@typescript-eslint/parser@6.2.0)([email protected])
eslint-plugin-inclusive-language:
specifier: ^2.2.0
version: 2.2.0
@@ -378,8 +382,8 @@ importers:
packages/contracts-js:
dependencies:
'@thirdweb-dev/contracts':
specifier: 3.8.5
version: 3.8.5([email protected])
specifier: 3.9.3-0
version: 3.9.3-0([email protected])
devDependencies:
'@babel/preset-env':
specifier: ^7.22.9
@@ -606,7 +610,7 @@ importers:
version: 0.0.3([email protected])
eslint-plugin-import:
specifier: ^2.26.0
version: 2.27.5(@typescript-eslint/parser@5.60.1)([email protected])([email protected])
version: 2.27.5(@typescript-eslint/parser@6.2.0)([email protected])
eslint-plugin-inclusive-language:
specifier: ^2.2.0
version: 2.2.0
@@ -730,7 +734,7 @@ importers:
version: 0.0.3([email protected])
eslint-plugin-import:
specifier: ^2.26.0
version: 2.27.5(@typescript-eslint/parser@5.60.1)([email protected])([email protected])
version: 2.27.5(@typescript-eslint/parser@6.2.0)([email protected])
eslint-plugin-inclusive-language:
specifier: ^2.2.0
version: 2.2.0
@@ -873,7 +877,7 @@ importers:
version: link:../eslint-config-thirdweb
eslint-plugin-import:
specifier: ^2.26.0
version: 2.27.5(@typescript-eslint/parser@5.60.1)([email protected])([email protected])
version: 2.27.5(@typescript-eslint/parser@6.2.0)([email protected])
eslint-plugin-inclusive-language:
specifier: ^2.2.0
version: 2.2.0
@@ -1103,7 +1107,7 @@ importers:
version: 0.0.3([email protected])
eslint-plugin-import:
specifier: ^2.26.0
version: 2.27.5(@typescript-eslint/parser@5.60.1)([email protected])([email protected])
version: 2.27.5(@typescript-eslint/parser@6.2.0)([email protected])
eslint-plugin-inclusive-language:
specifier: ^2.2.0
version: 2.2.0
@@ -10342,8 +10346,8 @@ packages:
use-sync-external-store: 1.2.0([email protected])
dev: false
/@thirdweb-dev/contracts@3.8.5([email protected]):
resolution: {integrity: sha512-JUAeJJlNLw+Lb/8StER8k74VEi5kXDaQx6Ko3cyJnKTWHpZ28xvGIPphkgOFaLw6cG/q4xB423crcZnQZw9YLQ==}
/@thirdweb-dev/contracts@3.9.3-0([email protected]):
resolution: {integrity: sha512-4KyYvkBjufUz5o1XKGKP0nBega6oDarZScaFufUjAyt7/yFP6hSSY+dYSihRWIfqWTbENoDlUAnZfnaczZlDYw==}
dependencies:
'@chainlink/contracts': 0.6.1([email protected])
'@openzeppelin/contracts': 4.9.3
@@ -16000,7 +16004,7 @@ packages:
eslint: 8.45.0
eslint-import-resolver-node: 0.3.7
eslint-import-resolver-typescript: 3.5.3([email protected])([email protected])
eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.60.1)([email protected])([email protected])
eslint-plugin-import: 2.27.5(@typescript-eslint/parser@6.2.0)([email protected])
eslint-plugin-jsx-a11y: 6.7.1([email protected])
eslint-plugin-react: 7.33.0([email protected])
eslint-plugin-react-hooks: 5.0.0-canary-7118f5dd7-20230705([email protected])
@@ -16036,7 +16040,7 @@ packages:
confusing-browser-globals: 1.0.11
eslint: 8.45.0
eslint-plugin-flowtype: 8.0.3(@babel/[email protected])(@babel/[email protected])([email protected])
eslint-plugin-import: 2.27.5(@typescript-eslint/[email protected])(eslint[email protected])(eslint@8.45.0)
eslint-plugin-import: 2.27.5(@typescript-eslint/[email protected])([email protected])
eslint-plugin-jest: 25.7.0(@typescript-eslint/[email protected])([email protected])([email protected])([email protected])
eslint-plugin-jsx-a11y: 6.7.1([email protected])
eslint-plugin-react: 7.33.0([email protected])
@@ -16080,7 +16084,7 @@ packages:
debug: 4.3.4([email protected])
enhanced-resolve: 5.12.0
eslint: 8.45.0
eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.60.1)([email protected])([email protected])
eslint-plugin-import: 2.27.5(@typescript-eslint/parser@6.2.0)([email protected])
get-tsconfig: 4.4.0
globby: 13.1.3
is-core-module: 2.11.0
@@ -16117,6 +16121,35 @@ packages:
eslint-import-resolver-typescript: 3.5.3([email protected])([email protected])
transitivePeerDependencies:
- supports-color
dev: false
/[email protected](@typescript-eslint/[email protected])([email protected])([email protected]):
resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==}
engines: {node: '>=4'}
peerDependencies:
'@typescript-eslint/parser': '*'
eslint: '*'
eslint-import-resolver-node: '*'
eslint-import-resolver-typescript: '*'
eslint-import-resolver-webpack: '*'
peerDependenciesMeta:
'@typescript-eslint/parser':
optional: true
eslint:
optional: true
eslint-import-resolver-node:
optional: true
eslint-import-resolver-typescript:
optional: true
eslint-import-resolver-webpack:
optional: true
dependencies:
'@typescript-eslint/parser': 6.2.0([email protected])([email protected])
debug: 3.2.7
eslint: 8.45.0
eslint-import-resolver-node: 0.3.7
transitivePeerDependencies:
- supports-color
/[email protected]([email protected]):
resolution: {integrity: sha512-U5OjauLSVcXvlh2La3ptPwIs6JwLPJKP20OQdTDBe2oh0cHvBeEwhQ8mjFrEoCMdQdmMdrSBkSRLG3gLxFjK3A==}
@@ -16165,7 +16198,7 @@ packages:
string-natural-compare: 3.0.1
dev: true
/[email protected](@typescript-eslint/[email protected])(eslint[email protected])(eslint@8.45.0):
/[email protected](@typescript-eslint/[email protected])([email protected]):
resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==}
engines: {node: '>=4'}
peerDependencies:
@@ -16196,6 +16229,39 @@ packages:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
- supports-color
dev: false
/[email protected](@typescript-eslint/[email protected])([email protected]):
resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==}
engines: {node: '>=4'}
peerDependencies:
'@typescript-eslint/parser': '*'
eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8
peerDependenciesMeta:
'@typescript-eslint/parser':
optional: true
dependencies:
'@typescript-eslint/parser': 6.2.0([email protected])([email protected])
array-includes: 3.1.6
array.prototype.flat: 1.3.1
array.prototype.flatmap: 1.3.1
debug: 3.2.7
doctrine: 2.1.0
eslint: 8.45.0
eslint-import-resolver-node: 0.3.7
eslint-module-utils: 2.7.4(@typescript-eslint/[email protected])([email protected])([email protected])
has: 1.0.3
is-core-module: 2.11.0
is-glob: 4.0.3
minimatch: 3.1.2
object.values: 1.1.6
resolve: 1.22.1
semver: 7.5.3
tsconfig-paths: 3.14.2
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
- supports-color
/[email protected]:
resolution: {integrity: sha512-RzPeSjuw1NYiTSQyFzYl2uTDgiPQWDUmFCiGAMCITmXN627DsWZ9rR4KNzrb8vnk/gLL5qdYr8oxh44xsrcO5Q==}
@@ -28981,7 +29047,3 @@ packages:
version: 5.4.7
engines: {node: '>=0.11'}
dev: true
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false