Compare commits

..
Author SHA1 Message Date
github-actions[bot]andgithub-actions[bot] 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
iketw 8b82f3c59c [CLI] Adds support for PWA Vite template (#1538) 2023-08-25 15:38:21 +00:00
Yash f59b729f8b [SDK] Fix auto-factory deployment: correct bytecode format (#1537) 2023-08-25 14:19:39 +00:00
iketw 387dddbd87 [RN] Adds switchToActiveChain to the ConnectWallet button (#1536) 2023-08-25 13:10:17 +00:00
Yash 911e14fcac [Chains] Add Chiliz Spicy testnet (#1530) 2023-08-24 18:35:05 +00:00
Winston YeoandJoaquim Verges cd6b07b591 feat(sdk): centralize contract reads (#1520)
Co-authored-by: Joaquim Verges <[email protected]>
2023-08-24 04:29:26 +00:00
Yash 154c55add5 Contracts version 3.9.3-0 (#1527) 2023-08-24 03:33:49 +00:00
github-actions[bot]andgithub-actions[bot] f202f597ca Version Packages (#1517)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-23 20:25:07 -07:00
Yash 91f0245be7 [SDK] Fix getChainProvider (#1526) 2023-08-24 00:00:03 +00:00
Joaquim Verges ae74b8ef62 [SDK] separate ERC1155Supply extension from ERC1155 (#1523) 2023-08-23 22:23:17 +00:00
Yash 5a373a7509 [SDK] Correct polygon rpc for fetching published contract (#1525) 2023-08-23 19:22:16 +00:00
Manan Tank 088547f763 [react] various ConnectWallet improvements (#1522) 2023-08-23 17:48:04 +00:00
YashandNacho Iacovino 586e91dbe6 [SDK] Publish dynamic contract (#1488)
Co-authored-by: Nacho Iacovino <[email protected]>
2023-08-23 14:27:40 +00:00
Joaquim Verges f65578d637 [SDK] Optimize contract resolution + Fallback to bytecode extension detection for un-imported contracts (#1498) 2023-08-23 00:03:52 +00:00
YashandAtharva Deosthale 447d984653 [SDK] Airdrops (#1288)
Co-authored-by: Atharva Deosthale <[email protected]>
2023-08-22 13:26:31 +00:00
nkrishang 34a3bb8ae3 [SDK][REACT] Update contracts release (#1518) 2023-08-22 04:31:36 +00:00
Joaquim Verges bc003c2fef [SDK] Return early for claim checks when possible (#1516) 2023-08-22 00:01:06 +00:00
github-actions[bot]andgithub-actions[bot] c88fa57591 Version Packages (#1509)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-21 12:17:36 -07:00
Jonas Daniels c12f0874b4 feat(chains): add new chains (#1513) 2023-08-21 18:20:53 +00:00
Jonas Daniels 184c325ab2 fix(chains): Update icon URL for chains 37 and 47 (#1508) 2023-08-19 02:19:31 +00:00
farhanW3andJonas Daniels 046c9ad604 moved res.json() to avoid getting JSON error in console (#1501)
Co-authored-by: Jonas Daniels <[email protected]>
2023-08-19 02:09:58 +00:00
github-actions[bot]andgithub-actions[bot] 2a7bbf8665 Version Packages (#1507)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-18 18:18:39 -07:00
Jonas Daniels f97ddf4c7f [chains] - add xpla chains & update chains (#1506) 2023-08-19 01:01:08 +00:00
162 changed files with 4113 additions and 798 deletions
+28
View File
@@ -1,5 +1,33 @@
# @thirdweb-dev/auth # @thirdweb-dev/auth
## 3.2.37
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@1.1.20
## 3.2.36
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@1.1.19
## 3.2.35
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@1.1.18
## 3.2.34
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@1.1.17
## 3.2.33 ## 3.2.33
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/auth", "name": "@thirdweb-dev/auth",
"version": "3.2.33", "version": "3.2.37",
"main": "dist/thirdweb-dev-auth.cjs.js", "main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js", "module": "dist/thirdweb-dev-auth.esm.js",
"browser": { "browser": {
+26
View File
@@ -1,5 +1,31 @@
# @thirdweb-dev/chains # @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
- [#1518](https://github.com/thirdweb-dev/js/pull/1518) [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8) Thanks [@nkrishang](https://github.com/nkrishang)! - Update contracts package
## 0.1.46
### Patch Changes
- [#1508](https://github.com/thirdweb-dev/js/pull/1508) [`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f) Thanks [@jnsdls](https://github.com/jnsdls)! - update xpla chain icons
- [#1513](https://github.com/thirdweb-dev/js/pull/1513) [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34) Thanks [@jnsdls](https://github.com/jnsdls)! - add additonal chains
## 0.1.45
### Patch Changes
- [#1506](https://github.com/thirdweb-dev/js/pull/1506) [`f97ddf4c`](https://github.com/thirdweb-dev/js/commit/f97ddf4c7f14854f3b204ad9741b52ddb8dac736) Thanks [@jnsdls](https://github.com/jnsdls)! - add xpla chains & update chains
## 0.1.44 ## 0.1.44
### Patch Changes ### Patch Changes
+1
View File
@@ -18,6 +18,7 @@ export default {
"https://gnosis.api.onfinality.io/public", "https://gnosis.api.onfinality.io/public",
"https://gnosis.blockpi.network/v1/rpc/public", "https://gnosis.blockpi.network/v1/rpc/public",
"https://web3endpoints.com/gnosischain-mainnet", "https://web3endpoints.com/gnosischain-mainnet",
"https://gnosis.oat.farm",
"wss://rpc.gnosischain.com/wss" "wss://rpc.gnosischain.com/wss"
], ],
"faucets": [ "faucets": [
+2 -2
View File
@@ -10,8 +10,8 @@ export default {
"https://t.me/HumanodeTestnet5FaucetBot" "https://t.me/HumanodeTestnet5FaucetBot"
], ],
"nativeCurrency": { "nativeCurrency": {
"name": "HMND", "name": "eHMND",
"symbol": "HMND", "symbol": "eHMND",
"decimals": 18 "decimals": 18
}, },
"infoURL": "https://humanode.io", "infoURL": "https://humanode.io",
+5 -5
View File
@@ -1,10 +1,10 @@
import type { Chain } from "../src/types"; import type { Chain } from "../src/types";
export default { export default {
"name": "Omni Testnet 1", "name": "Omni Testnet",
"chain": "Omni", "chain": "Omni",
"rpc": [ "rpc": [
"https://omni-testnet-1.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://omni-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet-1.omni.network" "https://testnet.omni.network"
], ],
"features": [ "features": [
{ {
@@ -24,10 +24,10 @@ export default {
"explorers": [ "explorers": [
{ {
"name": "Omni Explorer", "name": "Omni Explorer",
"url": "https://testnet-1.explorer.omni.network", "url": "https://testnet.explorer.omni.network",
"standard": "EIP3091" "standard": "EIP3091"
} }
], ],
"testnet": true, "testnet": true,
"slug": "omni-testnet-1" "slug": "omni-testnet"
} as const satisfies Chain; } as const satisfies Chain;
+2 -2
View File
@@ -11,8 +11,8 @@ export default {
}, },
"rpc": [ "rpc": [
"https://horizen-gobi-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://horizen-gobi-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://gobi-testnet.horizenlabs.io/ethv1", "https://gobi-rpc.horizenlabs.io/ethv1",
"https://rpc.ankr.com/horizen_testnet_evm" "https://rpc.ankr.com/horizen_gobi_testnet"
], ],
"features": [ "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;
+5 -4
View File
@@ -1,10 +1,11 @@
import type { Chain } from "../src/types"; import type { Chain } from "../src/types";
export default { export default {
"name": "Kava EVM Testnet", "name": "Kava Testnet",
"chain": "KAVA", "chain": "KAVA",
"rpc": [ "rpc": [
"https://kava-evm-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://kava-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://evm.testnet.kava.io", "https://evm.testnet.kava.io",
"https://kava-evm-testnet.rpc.thirdweb.com",
"wss://wevm.testnet.kava.io" "wss://wevm.testnet.kava.io"
], ],
"faucets": [ "faucets": [
@@ -28,7 +29,7 @@ export default {
"explorers": [ "explorers": [
{ {
"name": "Kava Testnet Explorer", "name": "Kava Testnet Explorer",
"url": "https://explorer.testnet.kava.io", "url": "http://testnet.kavascan.com",
"standard": "EIP3091", "standard": "EIP3091",
"icon": { "icon": {
"url": "ipfs://QmdpRTk6oL1HRW9xC6cAc4Rnf9gs6zgdAcr4Z3HcLztusm", "url": "ipfs://QmdpRTk6oL1HRW9xC6cAc4Rnf9gs6zgdAcr4Z3HcLztusm",
@@ -39,5 +40,5 @@ export default {
} }
], ],
"testnet": true, "testnet": true,
"slug": "kava-evm-testnet" "slug": "kava-testnet"
} as const satisfies Chain; } as const satisfies Chain;
+6 -4
View File
@@ -1,11 +1,13 @@
import type { Chain } from "../src/types"; import type { Chain } from "../src/types";
export default { export default {
"name": "Kava EVM", "name": "Kava",
"chain": "KAVA", "chain": "KAVA",
"rpc": [ "rpc": [
"https://kava-evm.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://kava.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://evm.kava.io", "https://evm.kava.io",
"https://evm2.kava.io", "https://evm2.kava.io",
"https://kava-rpc.gateway.pokt.network",
"https://kava-evm.rpc.thirdweb.com",
"wss://wevm.kava.io", "wss://wevm.kava.io",
"wss://wevm2.kava.io", "wss://wevm2.kava.io",
"https://kava-evm.publicnode.com" "https://kava-evm.publicnode.com"
@@ -29,7 +31,7 @@ export default {
"explorers": [ "explorers": [
{ {
"name": "Kava EVM Explorer", "name": "Kava EVM Explorer",
"url": "https://explorer.kava.io", "url": "https://kavascan.com",
"standard": "EIP3091", "standard": "EIP3091",
"icon": { "icon": {
"url": "ipfs://QmdpRTk6oL1HRW9xC6cAc4Rnf9gs6zgdAcr4Z3HcLztusm", "url": "ipfs://QmdpRTk6oL1HRW9xC6cAc4Rnf9gs6zgdAcr4Z3HcLztusm",
@@ -40,5 +42,5 @@ export default {
} }
], ],
"testnet": false, "testnet": false,
"slug": "kava-evm" "slug": "kava"
} as const satisfies Chain; } as const satisfies Chain;
+5 -1
View File
@@ -4,7 +4,11 @@ export default {
"chain": "SOMA", "chain": "SOMA",
"rpc": [ "rpc": [
"https://soma-network-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://soma-network-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://data-testnet-v1.somanetwork.io/" "https://data-testnet-v1.somanetwork.io/",
"https://testnet-au-server-2.somanetwork.io",
"https://testnet-au-server-1.somanetwork.io",
"https://testnet-sg-server-1.somanetwork.io",
"https://testnet-sg-server-2.somanetwork.io"
], ],
"faucets": [ "faucets": [
"https://faucet.somanetwork.io" "https://faucet.somanetwork.io"
+4 -1
View File
@@ -4,7 +4,10 @@ export default {
"chain": "SOMA", "chain": "SOMA",
"rpc": [ "rpc": [
"https://soma-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://soma-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://data-mainnet-v1.somanetwork.io/" "https://data-mainnet-v1.somanetwork.io/",
"https://id-mainnet.somanetwork.io",
"https://hk-mainnet.somanetwork.io",
"https://sg-mainnet.somanetwork.io"
], ],
"faucets": [ "faucets": [
"https://airdrop.somanetwork.io" "https://airdrop.somanetwork.io"
+34
View File
@@ -0,0 +1,34 @@
import type { Chain } from "../src/types";
export default {
"name": "Ancient8 Testnet",
"chain": "Ancient8",
"icon": {
"url": "ipfs://QmSX8sHToRzyFupT8BvPQjVsegRWFYz2mdnLkVnqBFKohY",
"width": 901,
"height": 901,
"format": "png"
},
"rpc": [
"https://ancient8-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc-testnet.ancient8.gg"
],
"faucets": [],
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://ancient8.gg/",
"shortName": "a8",
"chainId": 2863311531,
"networkId": 2863311531,
"explorers": [
{
"name": "a8scan-testnet",
"url": "https://testnet.a8scan.io",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "ancient8-testnet"
} as const satisfies Chain;
+6
View File
@@ -5,6 +5,12 @@ export default {
"shortName": "POPTestnet", "shortName": "POPTestnet",
"chainId": 331769, "chainId": 331769,
"testnet": true, "testnet": true,
"icon": {
"format": "png",
"url": "ipfs://QmP8rYvcc7aJB3c2YZxjxaySvHapHnoK8MnxuSuDT4PtF2",
"height": 400,
"width": 400
},
"rpc": [ "rpc": [
"https://proofofpepe-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://proofofpepe-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet01.proofofpepe.tech" "https://testnet01.proofofpepe.tech"
+33
View File
@@ -0,0 +1,33 @@
import type { Chain } from "../src/types";
export default {
"name": "POP Mainnet",
"chain": "POP",
"shortName": "POP",
"chainId": 331771,
"testnet": false,
"icon": {
"format": "png",
"url": "ipfs://QmP8rYvcc7aJB3c2YZxjxaySvHapHnoK8MnxuSuDT4PtF2",
"height": 400,
"width": 400
},
"rpc": [
"https://pop.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc00.proofofpepe.tech",
"https://rpc01.proofofpepe.tech",
"https://rpc02.proofofpepe.tech"
],
"nativeCurrency": {
"name": "Pepe",
"symbol": "PEPE",
"decimals": 18
},
"explorers": [
{
"name": "Pepescan",
"url": "https://pepescan.app",
"standard": "none"
}
],
"slug": "pop"
} as const satisfies Chain;
+23 -15
View File
@@ -1,27 +1,35 @@
import type { Chain } from "../src/types"; import type { Chain } from "../src/types";
export default { export default {
"name": "SeedCoin-Network", "name": "Xpla Mainnet",
"chain": "SeedCoin-Network", "chain": "XPLA",
"rpc": [ "rpc": [
"https://seedcoin-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://xpla-xpla.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://node.seedcoin.network" "https://dimension-evm-rpc.xpla.dev"
], ],
"faucets": [],
"nativeCurrency": { "nativeCurrency": {
"name": "SeedCoin", "name": "XPLA",
"symbol": "SEED", "symbol": "XPLA",
"decimals": 18 "decimals": 18
}, },
"infoURL": "https://www.seedcoin.network/", "infoURL": "https://xpla.io/",
"shortName": "SEED", "shortName": "xpla",
"chainId": 37,
"icon": { "icon": {
"url": "ipfs://QmSchLvCCZjBzcv5n22v1oFDAc2yHJ42NERyjZeL9hBgrh", "url": "ipfs://QmbvEAKZfgJckEziU3mpCwz6jqMeWRcLgd8TNsWA7g8sD9/xpla.png",
"width": 64, "width": 512,
"height": 64, "height": 512,
"format": "png" "format": "png"
}, },
"chainId": 37, "explorers": [
"networkId": 37, {
"name": "XPLA Explorer",
"url": "https://explorer.xpla.io",
"standard": "none"
}
],
"testnet": false, "testnet": false,
"slug": "seedcoin-network" "redFlags": [
"reusedChainId"
],
"slug": "xpla-xpla"
} as const satisfies Chain; } 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;
+24 -22
View File
@@ -1,36 +1,38 @@
import type { Chain } from "../src/types"; import type { Chain } from "../src/types";
export default { export default {
"name": "Acria IntelliChain", "name": "Xpla Testnet",
"chain": "AIC", "chain": "XPLA",
"rpc": [ "rpc": [
"https://acria-intellichain.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://xpla-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://aic.acria.ai" "https://cube-evm-rpc.xpla.dev"
], ],
"faucets": [],
"nativeCurrency": { "nativeCurrency": {
"name": "ACRIA", "name": "XPLA",
"symbol": "ACRIA", "symbol": "XPLA",
"decimals": 18 "decimals": 18
}, },
"features": [ "faucets": [
{ "https://faucet.xpla.io/"
"name": "EIP155"
},
{
"name": "EIP1559"
}
], ],
"infoURL": "https://acria.ai", "infoURL": "https://xpla.io/",
"shortName": "aic", "shortName": "xpla-test",
"chainId": 47, "chainId": 47,
"networkId": 47, "icon": {
"url": "ipfs://QmbvEAKZfgJckEziU3mpCwz6jqMeWRcLgd8TNsWA7g8sD9/xpla.png",
"width": 512,
"height": 512,
"format": "png"
},
"explorers": [ "explorers": [
{ {
"name": "Acria IntelliChain-Explorer", "name": "XPLA Explorer",
"url": "https://explorer.acria.ai", "url": "https://explorer.xpla.io/testnet",
"standard": "EIP3091" "standard": "none"
} }
], ],
"testnet": false, "testnet": true,
"slug": "acria-intellichain" "redFlags": [
"reusedChainId"
],
"slug": "xpla-testnet"
} as const satisfies Chain; } as const satisfies Chain;
+2 -2
View File
@@ -8,8 +8,8 @@ export default {
], ],
"faucets": [], "faucets": [],
"nativeCurrency": { "nativeCurrency": {
"name": "HMND", "name": "eHMND",
"symbol": "HMND", "symbol": "eHMND",
"decimals": 18 "decimals": 18
}, },
"infoURL": "https://humanode.io", "infoURL": "https://humanode.io",
+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;
+5 -1
View File
@@ -4,7 +4,11 @@ export default {
"chain": "DSC", "chain": "DSC",
"rpc": [ "rpc": [
"https://decimal-smart-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://decimal-smart-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://node.decimalchain.com/web3/" "https://node.decimalchain.com/web3/",
"https://node1-mainnet.decimalchain.com/web3/",
"https://node2-mainnet.decimalchain.com/web3/",
"https://node3-mainnet.decimalchain.com/web3/",
"https://node4-mainnet.decimalchain.com/web3/"
], ],
"faucets": [], "faucets": [],
"nativeCurrency": { "nativeCurrency": {
+8 -10
View File
@@ -1,19 +1,17 @@
import type { Chain } from "../src/types"; import type { Chain } from "../src/types";
export default { export default {
"name": "BeOne Chain Testnet", "name": "Testnet BeOne Chain",
"chain": "BOC", "chain": "tBOC",
"rpc": [ "rpc": [
"https://beone-chain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://testnet-beone-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://pre-boc1.beonechain.com", "https://pre-boc1.beonechain.com"
"https://pre-boc2.beonechain.com",
"https://pre-boc3.beonechain.com"
], ],
"faucets": [ "faucets": [
"https://testnet.beonescan.com/faucet" "https://testnet.beonescan.com/faucet"
], ],
"nativeCurrency": { "nativeCurrency": {
"name": "BeOne Chain Testnet", "name": "Testnet BeOne Chain",
"symbol": "BOC", "symbol": "tBOC",
"decimals": 18 "decimals": 18
}, },
"infoURL": "https://testnet.beonescan.com", "infoURL": "https://testnet.beonescan.com",
@@ -28,7 +26,7 @@ export default {
}, },
"explorers": [ "explorers": [
{ {
"name": "BeOne Chain Testnet", "name": "Testnet BeOne Chain",
"url": "https://testnet.beonescan.com", "url": "https://testnet.beonescan.com",
"icon": { "icon": {
"url": "ipfs://QmbVLQnaMDu86bPyKgCvTGhFBeYwjr15hQnrCcsp1EkAGL", "url": "ipfs://QmbVLQnaMDu86bPyKgCvTGhFBeYwjr15hQnrCcsp1EkAGL",
@@ -40,5 +38,5 @@ export default {
} }
], ],
"testnet": true, "testnet": true,
"slug": "beone-chain-testnet" "slug": "testnet-beone-chain"
} as const satisfies Chain; } as const satisfies Chain;
+2 -1
View File
@@ -4,7 +4,8 @@ export default {
"chain": "ETH", "chain": "ETH",
"rpc": [ "rpc": [
"https://base.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "https://base.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://mainnet.base.org/" "https://mainnet.base.org/",
"https://developer-access-mainnet.base.org/"
], ],
"faucets": [], "faucets": [],
"nativeCurrency": { "nativeCurrency": {
+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;
+21
View File
@@ -0,0 +1,21 @@
import type { Chain } from "../src/types";
export default {
"name": "Worlds Appchain",
"chain": "WRLDS",
"shortName": "WRLDS",
"chainId": 91003,
"testnet": true,
"rpc": [
"https://worlds-appchain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://api.evm.worlds.dev.eclipsenetwork.xyz/"
],
"nativeCurrency": {
"name": "WRLDS",
"symbol": "WRLDS",
"decimals": 18
},
"faucets": [
"https://faucet.evm.worlds.dev.eclipsenetwork.xyz/request_neon"
],
"slug": "worlds-appchain"
} as const satisfies Chain;
+2 -1
View File
@@ -10,7 +10,8 @@ export default {
}, },
"rpc": [ "rpc": [
"https://mind-smart-chain-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}", "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": [ "faucets": [
"https://faucet.mindchain.info/" "https://faucet.mindchain.info/"
@@ -8,6 +8,12 @@ export default {
shortName: "POPTestnet", shortName: "POPTestnet",
chainId: 331769, chainId: 331769,
testnet: true, testnet: true,
icon: {
format: "png",
url: "ipfs://QmP8rYvcc7aJB3c2YZxjxaySvHapHnoK8MnxuSuDT4PtF2",
height: 400,
width: 400,
},
rpc: ["https://testnet01.proofofpepe.tech"], rpc: ["https://testnet01.proofofpepe.tech"],
nativeCurrency: { nativeCurrency: {
name: "POP", name: "POP",
@@ -0,0 +1,30 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "POP Mainnet",
chain: "POP",
shortName: "POP",
chainId: 331771,
testnet: false,
icon: {
format: "png",
url: "ipfs://QmP8rYvcc7aJB3c2YZxjxaySvHapHnoK8MnxuSuDT4PtF2",
height: 400,
width: 400,
},
rpc: [
"https://rpc00.proofofpepe.tech",
"https://rpc01.proofofpepe.tech",
"https://rpc02.proofofpepe.tech",
],
nativeCurrency: {
name: "Pepe",
symbol: "PEPE",
decimals: 18,
},
explorers: [
{ name: "Pepescan", url: "https://pepescan.app", standard: "none" },
],
};
+32
View File
@@ -0,0 +1,32 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "Xpla Mainnet",
chain: "XPLA",
rpc: ["https://dimension-evm-rpc.xpla.dev"],
nativeCurrency: {
name: "XPLA",
symbol: "XPLA",
decimals: 18,
},
infoURL: "https://xpla.io/",
shortName: "xpla",
chainId: 37,
icon: {
url: "ipfs://QmbvEAKZfgJckEziU3mpCwz6jqMeWRcLgd8TNsWA7g8sD9/xpla.png",
width: 512,
height: 512,
format: "png",
},
explorers: [
{
name: "XPLA Explorer",
url: "https://explorer.xpla.io",
standard: "none",
},
],
testnet: false,
redFlags: ["reusedChainId"],
};
+33
View File
@@ -0,0 +1,33 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "Xpla Testnet",
chain: "XPLA",
rpc: ["https://cube-evm-rpc.xpla.dev"],
nativeCurrency: {
name: "XPLA",
symbol: "XPLA",
decimals: 18,
},
faucets: ["https://faucet.xpla.io/"],
infoURL: "https://xpla.io/",
shortName: "xpla-test",
chainId: 47,
icon: {
url: "ipfs://QmbvEAKZfgJckEziU3mpCwz6jqMeWRcLgd8TNsWA7g8sD9/xpla.png",
width: 512,
height: 512,
format: "png",
},
explorers: [
{
name: "XPLA Explorer",
url: "https://explorer.xpla.io/testnet",
standard: "none",
},
],
testnet: true,
redFlags: ["reusedChainId"],
};
+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,
};
+18
View File
@@ -0,0 +1,18 @@
// @ts-check
/** @typedef { import("../../src/types").Chain } Chain */
/** @type {Omit<Chain, "slug">} */
export default {
name: "Worlds Appchain",
chain: "WRLDS",
shortName: "WRLDS",
chainId: 91003,
testnet: true,
rpc: ["https://api.evm.worlds.dev.eclipsenetwork.xyz/"],
nativeCurrency: {
name: "WRLDS",
symbol: "WRLDS",
decimals: 18,
},
faucets: ["https://faucet.evm.worlds.dev.eclipsenetwork.xyz/request_neon"],
};
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/chains", "name": "@thirdweb-dev/chains",
"version": "0.1.44", "version": "0.1.48",
"main": "dist/thirdweb-dev-chains.cjs.js", "main": "dist/thirdweb-dev-chains.cjs.js",
"module": "dist/thirdweb-dev-chains.esm.js", "module": "dist/thirdweb-dev-chains.esm.js",
"browser": { "browser": {
@@ -344,6 +344,7 @@ ${exports.join("\n")}
export * from "./types"; export * from "./types";
export * from "./utils"; export * from "./utils";
export const defaultChains = [c1, c5, c8453, c84531, c137, c80001, c42161, c421613, c10, c420, c56, c97, c250, c4002, c43114, c43113, c1337]; export const defaultChains = [c1, c5, c8453, c84531, c137, c80001, c42161, c421613, c10, c420, c56, c97, c250, c4002, c43114, c43113, c1337];
// @ts-expect-error - TODO: fix this later
export const allChains: Chain[] = [${exportNames.join(", ")}]; export const allChains: Chain[] = [${exportNames.join(", ")}];
type ChainsById = { type ChainsById = {
File diff suppressed because one or more lines are too long
+42
View File
@@ -1,5 +1,47 @@
# thirdweb # 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
- Updated dependencies [[`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074), [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21), [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0), [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927), [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.11.18
### Patch Changes
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`046c9ad6`](https://github.com/thirdweb-dev/js/commit/046c9ad604587ff79bf028c4fe7b1f9c94f4ea54), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.11.17
### Patch Changes
- Updated dependencies [[`f97ddf4c`](https://github.com/thirdweb-dev/js/commit/f97ddf4c7f14854f3b204ad9741b52ddb8dac736)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.11.16 ## 0.11.16
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "thirdweb", "name": "thirdweb",
"main": "dist/cli/index.js", "main": "dist/cli/index.js",
"version": "0.11.16", "version": "0.11.20",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
+6
View File
@@ -69,6 +69,9 @@ export async function twCreate(
if (options.reactNative) { if (options.reactNative) {
framework = "react-native"; framework = "react-native";
} }
if (options.pwaVite) {
framework = "pwa-vite";
}
if (options.solana) { if (options.solana) {
chain = "solana"; chain = "solana";
@@ -239,6 +242,7 @@ export async function twCreate(
{ title: "Next.js", value: "next" }, { title: "Next.js", value: "next" },
{ title: "Create React App", value: "cra" }, { title: "Create React App", value: "cra" },
{ title: "Vite", value: "vite" }, { title: "Vite", value: "vite" },
{ title: "PWA Vite", value: "pwa-vite" },
{ title: "React Native", value: "react-native" }, { title: "React Native", value: "react-native" },
{ title: "Node.js", value: "node" }, { title: "Node.js", value: "node" },
{ title: "Express", value: "express" }, { title: "Express", value: "express" },
@@ -265,6 +269,8 @@ export async function twCreate(
if (typeof res.project === "string") { if (typeof res.project === "string") {
language = res.project.trim(); language = res.project.trim();
} }
} else if (framework === "pwa-vite" || framework === "pwa-next") {
language = "typescript";
} else { } else {
const res = await prompts({ const res = await prompts({
type: "select", type: "select",
@@ -220,7 +220,7 @@ export async function createApp({
} }
let startOrDev: string | undefined; let startOrDev: string | undefined;
if (framework && (framework === "next" || framework === "vite")) { if (framework && (framework.includes("next") || framework.includes("vite"))) {
startOrDev = "dev"; startOrDev = "dev";
} else if (template) { } else if (template) {
startOrDev = await getStartOrDev(template); startOrDev = await getStartOrDev(template);
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/contracts-js # @thirdweb-dev/contracts-js
## 1.3.12
### Patch Changes
- [#1518](https://github.com/thirdweb-dev/js/pull/1518) [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8) Thanks [@nkrishang](https://github.com/nkrishang)! - Update contracts package
## 1.3.11 ## 1.3.11
### Patch Changes ### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/contracts-js", "name": "@thirdweb-dev/contracts-js",
"version": "1.3.11", "version": "1.3.12",
"main": "dist/thirdweb-dev-contracts-js.cjs.js", "main": "dist/thirdweb-dev-contracts-js.cjs.js",
"module": "dist/thirdweb-dev-contracts-js.esm.js", "module": "dist/thirdweb-dev-contracts-js.esm.js",
"browser": { "browser": {
@@ -10,7 +10,7 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
"dependencies": { "dependencies": {
"@thirdweb-dev/contracts": "3.8.3" "@thirdweb-dev/contracts": "3.9.3-0"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-env": "^7.22.9", "@babel/preset-env": "^7.22.9",
+45
View File
@@ -1,5 +1,50 @@
# @thirdweb-dev/react-core # @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
- [#1522](https://github.com/thirdweb-dev/js/pull/1522) [`088547f7`](https://github.com/thirdweb-dev/js/commit/088547f763294f1641c01ffe1aabac585f255dc0) Thanks [@MananTank](https://github.com/MananTank)! - - New prop `switchToActiveChain` added to `ConnectWallet`` component to show "Switch Network" button if wallet is not connected to the `activeChain`passed to the`ThirdwebProvider`
- Add max-height on `ConnectWallet` modal
- Local Wallet UI adjustments
- Updated dependencies [[`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074), [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21), [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0), [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927), [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5)]:
- @thirdweb-dev/sdk@3.10.55
- @thirdweb-dev/chains@0.1.47
- @thirdweb-dev/storage@1.2.8
- @thirdweb-dev/wallets@1.1.19
- @thirdweb-dev/auth@3.2.36
## 3.14.35
### Patch Changes
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`046c9ad6`](https://github.com/thirdweb-dev/js/commit/046c9ad604587ff79bf028c4fe7b1f9c94f4ea54), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
- @thirdweb-dev/chains@0.1.46
- @thirdweb-dev/storage@1.2.7
- @thirdweb-dev/sdk@3.10.54
- @thirdweb-dev/wallets@1.1.18
- @thirdweb-dev/auth@3.2.35
## 3.14.34
### Patch Changes
- Updated dependencies [[`f97ddf4c`](https://github.com/thirdweb-dev/js/commit/f97ddf4c7f14854f3b204ad9741b52ddb8dac736)]:
- @thirdweb-dev/chains@0.1.45
- @thirdweb-dev/sdk@3.10.53
- @thirdweb-dev/wallets@1.1.17
- @thirdweb-dev/auth@3.2.34
## 3.14.33 ## 3.14.33
### Patch Changes ### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react-core", "name": "@thirdweb-dev/react-core",
"version": "3.14.33", "version": "3.14.37",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -98,7 +98,7 @@
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"dependencies": { "dependencies": {
"@tanstack/react-query": "^4.32.0", "@tanstack/react-query": "^4.33.0",
"@thirdweb-dev/chains": "workspace:*", "@thirdweb-dev/chains": "workspace:*",
"@thirdweb-dev/generated-abis": "workspace:^", "@thirdweb-dev/generated-abis": "workspace:^",
"@thirdweb-dev/sdk": "workspace:*", "@thirdweb-dev/sdk": "workspace:*",
@@ -152,6 +152,7 @@ export const ThirdwebProviderCore = <TChains extends Chain[]>({
autoSwitch={props.autoSwitch} autoSwitch={props.autoSwitch}
autoConnectTimeout={props.autoConnectTimeout} autoConnectTimeout={props.autoConnectTimeout}
clientId={props.clientId} clientId={props.clientId}
activeChainSetExplicitly={!!props.activeChain}
> >
<ThirdwebSDKProviderWrapper <ThirdwebSDKProviderWrapper
queryClient={props.queryClient} queryClient={props.queryClient}
@@ -89,6 +89,7 @@ type ThirdwebWalletContextData = {
* Get wallet config object from wallet instance * Get wallet config object from wallet instance
*/ */
getWalletConfig: (walletInstance: WalletInstance) => WalletConfig | undefined; getWalletConfig: (walletInstance: WalletInstance) => WalletConfig | undefined;
activeChainSetExplicitly: boolean;
}; };
const ThirdwebWalletContext = /* @__PURE__ */ createContext< const ThirdwebWalletContext = /* @__PURE__ */ createContext<
@@ -106,6 +107,7 @@ export function ThirdwebWalletProvider(
autoSwitch?: boolean; autoSwitch?: boolean;
autoConnectTimeout?: number; autoConnectTimeout?: number;
clientId?: string; clientId?: string;
activeChainSetExplicitly: boolean;
}>, }>,
) { ) {
const [signer, setSigner] = useState<Signer | undefined>(undefined); const [signer, setSigner] = useState<Signer | undefined>(undefined);
@@ -480,6 +482,7 @@ export function ThirdwebWalletProvider(
getWalletConfig: (walletInstance: WalletInstance) => { getWalletConfig: (walletInstance: WalletInstance) => {
return walletInstanceToConfig.get(walletInstance); return walletInstanceToConfig.get(walletInstance);
}, },
activeChainSetExplicitly: props.activeChainSetExplicitly,
}} }}
> >
{props.children} {props.children}
@@ -21,7 +21,6 @@ import {
} from "@tanstack/react-query"; } from "@tanstack/react-query";
import { getCachedAbiForContract, TransactionResult } from "@thirdweb-dev/sdk"; import { getCachedAbiForContract, TransactionResult } from "@thirdweb-dev/sdk";
import type { import type {
Abi,
CommonContractSchemaInput, CommonContractSchemaInput,
ContractEvent, ContractEvent,
ContractForPrebuiltContractType, ContractForPrebuiltContractType,
@@ -33,6 +32,7 @@ import type {
ThirdwebSDK, ThirdwebSDK,
ValidContractInstance, ValidContractInstance,
BaseContractForAddress, BaseContractForAddress,
PublishedMetadata,
} from "@thirdweb-dev/sdk"; } from "@thirdweb-dev/sdk";
import type { CallOverrides, ContractInterface, providers } from "ethers"; import type { CallOverrides, ContractInterface, providers } from "ethers";
import { useEffect, useMemo } from "react"; import { useEffect, useMemo } from "react";
@@ -88,19 +88,11 @@ export const contractType = {
// end contract type // end contract type
type FetchCompilerMetadataReturnType = {
name: string;
metadata: Record<string, any>;
abi: Abi;
info: Record<string, any>;
licenses: string[];
};
// contract compiler metadata // contract compiler metadata
function fetchCompilerMetadata( function fetchCompilerMetadata(
contractAddress: RequiredParam<ContractAddress>, contractAddress: RequiredParam<ContractAddress>,
sdk: RequiredParam<ThirdwebSDK>, sdk: RequiredParam<ThirdwebSDK>,
): Promise<FetchCompilerMetadataReturnType> | null { ): Promise<PublishedMetadata> | null {
if (!contractAddress || !sdk) { if (!contractAddress || !sdk) {
return null; return null;
} }
@@ -114,7 +106,7 @@ function fetchCompilerMetadata(
export function useCompilerMetadata( export function useCompilerMetadata(
contractAddress: RequiredParam<ContractAddress>, contractAddress: RequiredParam<ContractAddress>,
): UseQueryResult<FetchCompilerMetadataReturnType | null> { ): UseQueryResult<PublishedMetadata | null> {
const sdk = useSDK(); const sdk = useSDK();
return useQueryWithNetwork( return useQueryWithNetwork(
+3
View File
@@ -251,6 +251,9 @@ export { ThirdwebSDKProvider } from "./providers/thirdweb-sdk-provider";
export { useSDK, useSDKChainId } from "./hooks/useSDK"; export { useSDK, useSDKChainId } from "./hooks/useSDK";
export type { ThirdwebSDKProviderProps } from "./providers/types"; export type { ThirdwebSDKProviderProps } from "./providers/types";
// utils
export { invalidateContractAndBalances } from "./utils/cache-keys";
// types // types
export type { export type {
Chain, Chain,
@@ -1,5 +1,13 @@
# @thirdweb-dev/react-native-compat # @thirdweb-dev/react-native-compat
## 0.2.56
## 0.2.55
## 0.2.54
## 0.2.53
## 0.2.52 ## 0.2.52
## 0.2.51 ## 0.2.51
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@thirdweb-dev/react-native-compat", "name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects", "description": "Shims for Thirdweb in React Native Projects",
"version": "0.2.52", "version": "0.2.56",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0", "license": "Apache-2.0",
+56
View File
@@ -1,5 +1,61 @@
# @thirdweb-dev/react-native # @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
- Updated dependencies [[`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074), [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21), [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0), [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927), [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`088547f7`](https://github.com/thirdweb-dev/js/commit/088547f763294f1641c01ffe1aabac585f255dc0)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.54
### Patch Changes
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`046c9ad6`](https://github.com/thirdweb-dev/js/commit/046c9ad604587ff79bf028c4fe7b1f9c94f4ea54), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.53
### Patch Changes
- Updated dependencies [[`f97ddf4c`](https://github.com/thirdweb-dev/js/commit/f97ddf4c7f14854f3b204ad9741b52ddb8dac736)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.2.52 ## 0.2.52
### Patch Changes ### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react-native", "name": "@thirdweb-dev/react-native",
"version": "0.2.52", "version": "0.2.56",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -28,7 +28,7 @@
"@magic-sdk/provider": "17.2.0", "@magic-sdk/provider": "17.2.0",
"@magic-sdk/react-native-bare": "^18.5.0", "@magic-sdk/react-native-bare": "^18.5.0",
"@shopify/restyle": "^2.4.2", "@shopify/restyle": "^2.4.2",
"@tanstack/react-query": "^4.32.0", "@tanstack/react-query": "^4.33.0",
"@thirdweb-dev/chains": "workspace:*", "@thirdweb-dev/chains": "workspace:*",
"@thirdweb-dev/react-core": "workspace:*", "@thirdweb-dev/react-core": "workspace:*",
"@thirdweb-dev/sdk": "workspace:*", "@thirdweb-dev/sdk": "workspace:*",
@@ -3,11 +3,18 @@ import {
ConnectWalletDetailsProps, ConnectWalletDetailsProps,
WalletDetailsButton, WalletDetailsButton,
} from "./ConnectWalletDetails/WalletDetailsButton"; } from "./ConnectWalletDetails/WalletDetailsButton";
import { useAddress } from "@thirdweb-dev/react-core"; import {
import { useEffect, useRef } from "react"; useAddress,
import { Animated } from "react-native"; 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 { ConnectWalletButton } from "./ConnectWalletFlow/ConnectWalletButton";
import { ConnectWalletButtonProps } from "./ConnectWalletFlow/ConnectWalletButton"; import { ConnectWalletButtonProps } from "./ConnectWalletFlow/ConnectWalletButton";
import BaseButton from "./base/BaseButton";
import Text from "./base/Text";
export type ConnectWalletProps = { export type ConnectWalletProps = {
/** /**
@@ -26,6 +33,17 @@ export type ConnectWalletProps = {
* @default false * @default false
*/ */
hideTestnetFaucet?: boolean; 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; } & ConnectWalletButtonProps;
export const ConnectWallet = ({ export const ConnectWallet = ({
@@ -35,9 +53,15 @@ export const ConnectWallet = ({
modalTitle, modalTitle,
extraRows, extraRows,
hideTestnetFaucet, hideTestnetFaucet,
switchToActiveChain,
}: ConnectWalletProps) => { }: ConnectWalletProps) => {
const fadeAnim = useRef(new Animated.Value(0)).current; const fadeAnim = useRef(new Animated.Value(0)).current;
const address = useAddress(); const address = useAddress();
const isNetworkMismatch = useNetworkMismatch();
const { activeChainSetExplicitly } = useWalletContext();
const { activeChain } = useWalletContext();
const switchChain = useSwitchChain();
const [switching, setSwitching] = useState(false);
useEffect(() => { useEffect(() => {
Animated.timing(fadeAnim, { Animated.timing(fadeAnim, {
@@ -51,12 +75,38 @@ export const ConnectWallet = ({
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<Animated.View style={{ opacity: fadeAnim }}> <Animated.View style={{ opacity: fadeAnim }}>
{address ? ( {address ? (
<WalletDetailsButton switchToActiveChain &&
address={address} isNetworkMismatch &&
detailsButton={detailsButton} activeChainSetExplicitly ? (
extraRows={extraRows} <BaseButton
hideTestnetFaucet={hideTestnetFaucet} 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 <ConnectWalletButton
modalTitle={modalTitle} modalTitle={modalTitle}
@@ -68,3 +118,17 @@ export const ConnectWallet = ({
</ThemeProvider> </ThemeProvider>
); );
}; };
const styles = StyleSheet.create({
connectWalletButton: {
display: "flex",
flexDirection: "row",
alignContent: "center",
alignItems: "center",
justifyContent: "center",
borderRadius: 8,
paddingHorizontal: 10,
paddingVertical: 10,
minWidth: 150,
},
});
+43
View File
@@ -1,5 +1,48 @@
# @thirdweb-dev/react # @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
- [#1522](https://github.com/thirdweb-dev/js/pull/1522) [`088547f7`](https://github.com/thirdweb-dev/js/commit/088547f763294f1641c01ffe1aabac585f255dc0) Thanks [@MananTank](https://github.com/MananTank)! - - New prop `switchToActiveChain` added to `ConnectWallet`` component to show "Switch Network" button if wallet is not connected to the `activeChain`passed to the`ThirdwebProvider`
- Add max-height on `ConnectWallet` modal
- Local Wallet UI adjustments
- Updated dependencies [[`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074), [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9), [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21), [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0), [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927), [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5), [`088547f7`](https://github.com/thirdweb-dev/js/commit/088547f763294f1641c01ffe1aabac585f255dc0)]:
- @thirdweb-dev/sdk@3.10.55
- @thirdweb-dev/chains@0.1.47
- @thirdweb-dev/react-core@3.14.36
- @thirdweb-dev/wallets@1.1.19
## 3.14.35
### Patch Changes
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
- @thirdweb-dev/chains@0.1.46
- @thirdweb-dev/react-core@3.14.35
- @thirdweb-dev/sdk@3.10.54
- @thirdweb-dev/wallets@1.1.18
## 3.14.34
### Patch Changes
- Updated dependencies [[`f97ddf4c`](https://github.com/thirdweb-dev/js/commit/f97ddf4c7f14854f3b204ad9741b52ddb8dac736)]:
- @thirdweb-dev/chains@0.1.45
- @thirdweb-dev/react-core@3.14.34
- @thirdweb-dev/sdk@3.10.53
- @thirdweb-dev/wallets@1.1.17
## 3.14.33 ## 3.14.33
### Patch Changes ### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react", "name": "@thirdweb-dev/react",
"version": "3.14.33", "version": "3.14.37",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -131,7 +131,7 @@
"@radix-ui/react-tabs": "^1.0.4", "@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.6", "@radix-ui/react-tooltip": "^1.0.6",
"@react-icons/all-files": "^4.1.0", "@react-icons/all-files": "^4.1.0",
"@tanstack/react-query": "^4.32.0", "@tanstack/react-query": "^4.33.0",
"@thirdweb-dev/chains": "workspace:*", "@thirdweb-dev/chains": "workspace:*",
"@thirdweb-dev/react-core": "workspace:*", "@thirdweb-dev/react-core": "workspace:*",
"@thirdweb-dev/wallets": "workspace:*", "@thirdweb-dev/wallets": "workspace:*",
@@ -18,6 +18,7 @@ export const FormFieldWithIconButton: React.FC<{
error?: string; error?: string;
noSave?: boolean; noSave?: boolean;
dataTest?: string; dataTest?: string;
placeholder?: string;
}> = (props) => { }> = (props) => {
return ( return (
<div> <div>
@@ -42,6 +43,7 @@ export const FormFieldWithIconButton: React.FC<{
: undefined : undefined
} }
data-test={props.dataTest} data-test={props.dataTest}
placeholder={props.placeholder}
/> />
<InputButton type="button" onClick={props.right.onClick}> <InputButton type="button" onClick={props.right.onClick}>
@@ -97,7 +97,8 @@ export const ConnectModal = () => {
> >
<Modal <Modal
style={{ style={{
maxWidth: "480px", maxWidth: "450px",
maxHeight: "70vh",
}} }}
open={isWalletModalOpen} open={isWalletModalOpen}
setOpen={(value) => { setOpen={(value) => {
@@ -7,9 +7,12 @@ import {
useConnectionStatus, useConnectionStatus,
useLogin, useLogin,
useLogout, useLogout,
useNetworkMismatch,
useSwitchChain,
useThirdwebAuthContext, useThirdwebAuthContext,
useUser, useUser,
useWallet, useWallet,
useWalletContext,
} from "@thirdweb-dev/react-core"; } from "@thirdweb-dev/react-core";
import { useContext, useState } from "react"; import { useContext, useState } from "react";
import { import {
@@ -54,6 +57,17 @@ type ConnectWalletProps = {
* @default false * @default false
*/ */
hideTestnetFaucet?: boolean; 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;
}; };
const TW_CONNECT_WALLET = "tw-connect-wallet"; const TW_CONNECT_WALLET = "tw-connect-wallet";
@@ -83,6 +97,8 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
const { user } = useUser(); const { user } = useUser();
const { login } = useLogin(); const { login } = useLogin();
const { logout } = useLogout(); const { logout } = useLogout();
const isNetworkMismatch = useNetworkMismatch();
const { activeChainSetExplicitly } = useWalletContext();
const requiresSignIn = props.auth?.loginOptional const requiresSignIn = props.auth?.loginOptional
? false ? false
@@ -108,61 +124,87 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
/> />
)} )}
{/* Sign In Button */} {(() => {
{requiresSignIn && ( // wallet is not connected
<Button if (!activeWallet) {
variant="inverted" // Connect Wallet button
onClick={signIn} return (
data-theme={theme} <AnimatedButton
className={`${TW_CONNECT_WALLET}--sign-in ${props.className || ""}}`} disabled={isLoading}
style={props.style} className={`${props.className || ""} ${TW_CONNECT_WALLET}`}
> data-theme={theme}
<Flex data-is-loading={isLoading}
alignItems="center" variant="inverted"
gap="sm" type="button"
style={{ style={{
paddingRight: spacing.xs, minWidth: "140px",
borderRight: "1px solid", ...props.style,
marginRight: spacing.xs, }}
}} aria-label={
> connectionStatus === "connecting" ? "Connecting" : btnTitle
<LockIcon size={iconSize.sm} /> }
<span> Sign in </span> onClick={() => {
</Flex> setModalConfig({
<span>{shortenAddress(address || "", true)}</span> title: props.modalTitle || "Choose your wallet",
</Button> theme,
)} data: undefined,
});
setIsWalletModalOpen(true);
}}
data-test="connect-wallet-button"
>
{isLoading ? <Spinner size="sm" color="inverted" /> : btnTitle}
</AnimatedButton>
);
}
{!requiresSignIn && // switch network button
(!activeWallet ? ( if (
// connect wallet button props.switchToActiveChain &&
<AnimatedButton isNetworkMismatch &&
disabled={isLoading} activeChainSetExplicitly
className={`${props.className || ""} ${TW_CONNECT_WALLET}`} ) {
data-theme={theme} return (
data-is-loading={isLoading} <SwitchNetworkButton
variant="inverted" style={props.style}
type="button" theme={theme}
style={{ className={props.className}
minWidth: "140px", />
...props.style, );
}} }
aria-label={
connectionStatus === "connecting" ? "Connecting" : btnTitle // sign in button
} else if (requiresSignIn) {
onClick={() => { return (
setModalConfig({ <Button
title: props.modalTitle || "Choose your wallet", variant="inverted"
theme, onClick={signIn}
data: undefined, data-theme={theme}
}); className={`${TW_CONNECT_WALLET}--sign-in ${
setIsWalletModalOpen(true); props.className || ""
}} }`}
data-test="connect-wallet-button" style={props.style}
> data-test="sign-in-button"
{isLoading ? <Spinner size="sm" color="inverted" /> : btnTitle} >
</AnimatedButton> <Flex
) : ( alignItems="center"
gap="sm"
style={{
paddingRight: spacing.xs,
borderRight: "1px solid",
marginRight: spacing.xs,
}}
>
<LockIcon size={iconSize.sm} />
<span> Sign in </span>
</Flex>
<span>{shortenAddress(address || "", true)}</span>
</Button>
);
}
// wallet details button
return (
<ConnectedWalletDetails <ConnectedWalletDetails
networkSelector={props.networkSelector} networkSelector={props.networkSelector}
dropdownPosition={props.dropdownPosition} dropdownPosition={props.dropdownPosition}
@@ -178,11 +220,52 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
} }
}} }}
/> />
))} );
})()}
</ThemeProvider> </ThemeProvider>
); );
}; };
function SwitchNetworkButton(props: {
style?: React.CSSProperties;
className?: string;
theme: "dark" | "light";
}) {
const { activeChain } = useWalletContext();
const switchChain = useSwitchChain();
const [switching, setSwitching] = useState(false);
return (
<AnimatedButton
className={`${TW_CONNECT_WALLET}--switch-network ${
props.className || ""
}`}
variant="inverted"
type="button"
data-theme={props.theme}
data-is-loading={switching}
data-test="switch-network-button"
disabled={switching}
onClick={async () => {
setSwitching(true);
try {
await switchChain(activeChain.chainId);
} catch {
// ignore
}
setSwitching(false);
}}
style={{
minWidth: "140px",
...props.style,
}}
aria-label={switching ? "Switching Network" : undefined}
>
{switching ? <Spinner size="sm" color="inverted" /> : "Switch Network"}
</AnimatedButton>
);
}
const AnimatedButton = /* @__PURE__ */ styled(Button)` const AnimatedButton = /* @__PURE__ */ styled(Button)`
animation: ${fadeInAnimation} 300ms ease; animation: ${fadeInAnimation} 300ms ease;
`; `;
@@ -113,7 +113,7 @@ export const WalletSelection: React.FC<{
}); });
return ( return (
<WalletList> <WalletListContainer>
{walletConfigs.map((walletConfig) => { {walletConfigs.map((walletConfig) => {
const isInstalled = walletConfig.isInstalled const isInstalled = walletConfig.isInstalled
? walletConfig.isInstalled() ? walletConfig.isInstalled()
@@ -150,11 +150,11 @@ export const WalletSelection: React.FC<{
</li> </li>
); );
})} })}
</WalletList> </WalletListContainer>
); );
}; };
const WalletList = styled.ul` const WalletListContainer = styled.ul`
all: unset; all: unset;
list-style-type: none; list-style-type: none;
display: flex; display: flex;
@@ -1,6 +1,6 @@
import { Spacer } from "../../../components/Spacer"; import { Spacer } from "../../../components/Spacer";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { FormFooter, Label } from "../../../components/formElements"; import { Label } from "../../../components/formElements";
import { import {
ModalTitle, ModalTitle,
ModalDescription, ModalDescription,
@@ -172,7 +172,7 @@ export const ExportLocalWallet: React.FC<{
<SavedWalletAddress>{shortenAddress(savedAddress)}</SavedWalletAddress> <SavedWalletAddress>{shortenAddress(savedAddress)}</SavedWalletAddress>
<Spacer y="lg" /> <Spacer y="xl" />
{passwordIsRequired && ( {passwordIsRequired && (
<> <>
@@ -207,22 +207,21 @@ export const ExportLocalWallet: React.FC<{
error={isWrongPassword ? "Wrong Password" : ""} error={isWrongPassword ? "Wrong Password" : ""}
dataTest="current-password" dataTest="current-password"
/> />
<Spacer y="xl" /> <Spacer y="md" />
</> </>
)} )}
<FormFooter> <Button
<Button disabled={exportDisabled}
disabled={exportDisabled} variant="inverted"
variant="inverted" style={{
style={{ opacity: exportDisabled ? 0.5 : 1,
opacity: exportDisabled ? 0.5 : 1, width: "100%",
}} }}
type="submit" type="submit"
> >
Backup Backup
</Button> </Button>
</FormFooter>
</form> </form>
</> </>
); );
@@ -8,7 +8,7 @@ import {
import { EyeClosedIcon, EyeOpenIcon } from "@radix-ui/react-icons"; import { EyeClosedIcon, EyeOpenIcon } from "@radix-ui/react-icons";
import { WalletConfig, useWalletContext } from "@thirdweb-dev/react-core"; import { WalletConfig, useWalletContext } from "@thirdweb-dev/react-core";
import { useState } from "react"; import { useState } from "react";
import { FormFooter, Label } from "../../../components/formElements"; import { Label } from "../../../components/formElements";
import { spacing } from "../../../design-system"; import { spacing } from "../../../design-system";
import { Spinner } from "../../../components/Spinner"; import { Spinner } from "../../../components/Spinner";
import { shortenAddress } from "../../../evm/utils/addresses"; import { shortenAddress } from "../../../evm/utils/addresses";
@@ -131,6 +131,7 @@ export const ReconnectLocalWallet: React.FC<ReconnectLocalWalletProps> = (
meta={meta} meta={meta}
hideBack={!props.renderBackButton} hideBack={!props.renderBackButton}
/> />
<ModalTitle <ModalTitle
style={{ style={{
textAlign: "left", textAlign: "left",
@@ -138,12 +139,13 @@ export const ReconnectLocalWallet: React.FC<ReconnectLocalWalletProps> = (
> >
Guest Wallet Guest Wallet
</ModalTitle> </ModalTitle>
<Spacer y="xs" /> <Spacer y="xs" />
<ModalDescription> <ModalDescription>
Connect to saved wallet on your device Connect to saved wallet on your device
</ModalDescription> </ModalDescription>
<Spacer y="lg" /> <Spacer y="xl" />
<Label>Saved Wallet</Label> <Label>Saved Wallet</Label>
@@ -153,7 +155,7 @@ export const ReconnectLocalWallet: React.FC<ReconnectLocalWalletProps> = (
{savedAddress === "" ? "Loading..." : shortenAddress(savedAddress)} {savedAddress === "" ? "Loading..." : shortenAddress(savedAddress)}
</SecondaryText> </SecondaryText>
<Spacer y="lg" /> <Spacer y="xl" />
<form <form
onSubmit={(e) => { onSubmit={(e) => {
@@ -190,27 +192,27 @@ export const ReconnectLocalWallet: React.FC<ReconnectLocalWalletProps> = (
value={password} value={password}
error={isWrongPassword ? "Wrong Password" : ""} error={isWrongPassword ? "Wrong Password" : ""}
dataTest="current-password" dataTest="current-password"
placeholder="Enter your password"
/> />
<Spacer y="lg" /> <Spacer y="md" />
{/* Connect Button */} {/* Connect Button */}
<FormFooter> <Button
<Button variant="inverted"
variant="inverted" type="submit"
type="submit" style={{
style={{ display: "flex",
display: "flex", gap: spacing.sm,
gap: spacing.sm, width: "100%",
}} }}
> >
Connect Connect
{isConnecting && <Spinner size="sm" color="inverted" />} {isConnecting && <Spinner size="sm" color="inverted" />}
</Button> </Button>
</FormFooter>
</form> </form>
<Spacer y="xxl" /> <Spacer y="xl" />
<Button <Button
variant="link" variant="link"
@@ -18,7 +18,7 @@ export const LocalWalletModalHeader: React.FC<{
</> </>
)} )}
<Img src={props.meta.iconURL} width={iconSize.xl} height={iconSize.xl} /> <Img src={props.meta.iconURL} width={iconSize.xl} height={iconSize.xl} />
<Spacer y="sm" /> <Spacer y="md" />
</> </>
); );
}; };
+51
View File
@@ -1,5 +1,56 @@
# @thirdweb-dev/sdk # @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
- [#1488](https://github.com/thirdweb-dev/js/pull/1488) [`586e91db`](https://github.com/thirdweb-dev/js/commit/586e91dbe610588cc7b24fade59172fed6481074) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Dynamic contract detection and deployment using updated publish metadata
- [#1518](https://github.com/thirdweb-dev/js/pull/1518) [`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8) Thanks [@nkrishang](https://github.com/nkrishang)! - Update contracts package
- [#1526](https://github.com/thirdweb-dev/js/pull/1526) [`91f0245b`](https://github.com/thirdweb-dev/js/commit/91f0245be78ae523e1faea26b1032bfb283467d9) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Fix supported chains map in getChainProvider
- [#1525](https://github.com/thirdweb-dev/js/pull/1525) [`5a373a75`](https://github.com/thirdweb-dev/js/commit/5a373a75090da7e1e05724ed1a3a3a6aa9f7fd21) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Correct chain / polygon rpc for fetching published contract
- [#1523](https://github.com/thirdweb-dev/js/pull/1523) [`ae74b8ef`](https://github.com/thirdweb-dev/js/commit/ae74b8ef6200dba8affa8b52e7d834c5552350d0) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Separate ERC1155Supply extension
- [#1516](https://github.com/thirdweb-dev/js/pull/1516) [`bc003c2f`](https://github.com/thirdweb-dev/js/commit/bc003c2fef33fcf7ce5981d8634911ac4bcaa927) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Return early for claim checks when possible
- [#1288](https://github.com/thirdweb-dev/js/pull/1288) [`447d9846`](https://github.com/thirdweb-dev/js/commit/447d984653f77af6860ae907072e768b584b263d) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Airdrops
- [#1498](https://github.com/thirdweb-dev/js/pull/1498) [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Optimized fetching contract metadata, and fallback to bytecode extension detection for un-imported contracts
- Updated dependencies [[`34a3bb8a`](https://github.com/thirdweb-dev/js/commit/34a3bb8ae3c1d7a506e5568a9e79ab7e469557a8), [`f65578d6`](https://github.com/thirdweb-dev/js/commit/f65578d637decc8b87cada5b5b0c8c504064d9d5)]:
- @thirdweb-dev/contracts-js@1.3.12
- @thirdweb-dev/chains@0.1.47
- @thirdweb-dev/storage@1.2.8
## 3.10.54
### Patch Changes
- Updated dependencies [[`184c325a`](https://github.com/thirdweb-dev/js/commit/184c325ab2ef028022a050c4274f2ab12b1a3a7f), [`046c9ad6`](https://github.com/thirdweb-dev/js/commit/046c9ad604587ff79bf028c4fe7b1f9c94f4ea54), [`c12f0874`](https://github.com/thirdweb-dev/js/commit/c12f0874b4dac43c263c7edb20d0343c16381c34)]:
- @thirdweb-dev/chains@0.1.46
- @thirdweb-dev/storage@1.2.7
## 3.10.53
### Patch Changes
- Updated dependencies [[`f97ddf4c`](https://github.com/thirdweb-dev/js/commit/f97ddf4c7f14854f3b204ad9741b52ddb8dac736)]:
- @thirdweb-dev/chains@0.1.45
## 3.10.52 ## 3.10.52
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/sdk", "name": "@thirdweb-dev/sdk",
"version": "3.10.52", "version": "3.10.56",
"description": "The main thirdweb SDK.", "description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -14,13 +14,23 @@ export async function computeCloneFactoryAddress(
provider: providers.Provider, provider: providers.Provider,
storage: ThirdwebStorage, storage: ThirdwebStorage,
create2Factory?: string, create2Factory?: string,
clientId?: string,
secretKey?: string,
): Promise<string> { ): Promise<string> {
if (!create2Factory) { if (!create2Factory) {
create2Factory = await getCreate2FactoryAddress(provider); create2Factory = await getCreate2FactoryAddress(provider);
} }
return ( return (
await computeDeploymentInfo("infra", provider, storage, create2Factory, { await computeDeploymentInfo(
contractName: "TWCloneFactory", "infra",
}) provider,
storage,
create2Factory,
{
contractName: "TWCloneFactory",
},
clientId,
secretKey,
)
).transaction.predictedAddress; ).transaction.predictedAddress;
} }
@@ -15,12 +15,15 @@ export function computeDeploymentAddress(
create2FactoryAddress: string, create2FactoryAddress: string,
salt?: string, salt?: string,
): 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 // 1. create init bytecode hash with contract's bytecode and encoded args
const initBytecode = utils.solidityPack( const initBytecode = utils.solidityPack(
["bytes", "bytes"], ["bytes", "bytes"],
[bytecode, encodedArgs], [bytecodePrefixed, encodedArgs],
); );
// 2. abi-encode pack the deployer address, salt, and bytecode hash // 2. abi-encode pack the deployer address, salt, and bytecode hash
@@ -7,7 +7,10 @@ import {
ContractOptions, ContractOptions,
DeploymentPreset, DeploymentPreset,
} from "../../types/any-evm/deploy-data"; } from "../../types/any-evm/deploy-data";
import { fetchAndCachePublishedContractURI } from "./fetchAndCachePublishedContractURI"; import {
THIRDWEB_DEPLOYER,
fetchPublishedContractFromPolygon,
} from "./fetchPublishedContractFromPolygon";
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata"; import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
import { isContractDeployed } from "./isContractDeployed"; import { isContractDeployed } from "./isContractDeployed";
import { getInitBytecodeWithSalt } from "./getInitBytecodeWithSalt"; import { getInitBytecodeWithSalt } from "./getInitBytecodeWithSalt";
@@ -26,8 +29,12 @@ export async function computeDeploymentInfo(
storage: ThirdwebStorage, storage: ThirdwebStorage,
create2Factory: string, create2Factory: string,
contractOptions?: ContractOptions, contractOptions?: ContractOptions,
clientId?: string,
secretKey?: string,
): Promise<DeploymentPreset> { ): Promise<DeploymentPreset> {
const contractName = contractOptions && contractOptions.contractName; const contractName = contractOptions && contractOptions.contractName;
const version = contractOptions && contractOptions.version;
let publisherAddress = contractOptions && contractOptions.publisherAddress;
let metadata = contractOptions && contractOptions.metadata; let metadata = contractOptions && contractOptions.metadata;
invariant(contractName || metadata, "Require contract name or metadata"); invariant(contractName || metadata, "Require contract name or metadata");
@@ -57,9 +64,20 @@ export async function computeDeploymentInfo(
if (!metadata) { if (!metadata) {
invariant(contractName, "Require contract name"); invariant(contractName, "Require contract name");
const uri = await fetchAndCachePublishedContractURI(contractName); if (!publisherAddress) {
metadata = (await fetchAndCacheDeployMetadata(uri, storage)) publisherAddress = THIRDWEB_DEPLOYER;
.compilerMetadata; }
const publishedContract = await fetchPublishedContractFromPolygon(
publisherAddress,
contractName,
version,
storage,
clientId,
secretKey,
);
metadata = (
await fetchAndCacheDeployMetadata(publishedContract.metadataUri, storage)
).compilerMetadata;
} }
const encodedArgs = await encodeConstructorParamsForImplementation( const encodedArgs = await encodeConstructorParamsForImplementation(
@@ -68,6 +86,8 @@ export async function computeDeploymentInfo(
storage, storage,
create2Factory, create2Factory,
contractOptions?.constructorParams, contractOptions?.constructorParams,
clientId,
secretKey,
); );
const address = computeDeploymentAddress( const address = computeDeploymentAddress(
metadata.bytecode, metadata.bytecode,
@@ -108,6 +128,8 @@ export async function encodeConstructorParamsForImplementation(
storage: ThirdwebStorage, storage: ThirdwebStorage,
create2Factory: string, create2Factory: string,
constructorParamMap?: ConstructorParamMap, constructorParamMap?: ConstructorParamMap,
clientId?: string,
secretKey?: string,
): Promise<BytesLike> { ): Promise<BytesLike> {
const constructorParams = extractConstructorParamsFromAbi( const constructorParams = extractConstructorParamsFromAbi(
compilerMetadata.abi, compilerMetadata.abi,
@@ -147,6 +169,8 @@ export async function encodeConstructorParamsForImplementation(
{ {
contractName: "WETH9", contractName: "WETH9",
}, },
clientId,
secretKey,
); );
if (!caches.deploymentPresets["WETH9"]) { if (!caches.deploymentPresets["WETH9"]) {
caches.deploymentPresets["WETH9"] = deploymentInfo; caches.deploymentPresets["WETH9"] = deploymentInfo;
@@ -168,6 +192,8 @@ export async function encodeConstructorParamsForImplementation(
{ {
contractName: "ForwarderEOAOnly", contractName: "ForwarderEOAOnly",
}, },
clientId,
secretKey,
); );
if (!caches.deploymentPresets["ForwarderEOAOnly"]) { if (!caches.deploymentPresets["ForwarderEOAOnly"]) {
caches.deploymentPresets["ForwarderEOAOnly"] = deploymentInfo; caches.deploymentPresets["ForwarderEOAOnly"] = deploymentInfo;
@@ -183,6 +209,8 @@ export async function encodeConstructorParamsForImplementation(
{ {
contractName: "Forwarder", contractName: "Forwarder",
}, },
clientId,
secretKey,
); );
if (!caches.deploymentPresets["Forwarder"]) { if (!caches.deploymentPresets["Forwarder"]) {
caches.deploymentPresets["Forwarder"] = deploymentInfo; caches.deploymentPresets["Forwarder"] = deploymentInfo;
@@ -14,13 +14,23 @@ export async function computeEOAForwarderAddress(
provider: providers.Provider, provider: providers.Provider,
storage: ThirdwebStorage, storage: ThirdwebStorage,
create2Factory?: string, create2Factory?: string,
clientId?: string,
secretKey?: string,
): Promise<string> { ): Promise<string> {
if (!create2Factory) { if (!create2Factory || create2Factory === "") {
create2Factory = await getCreate2FactoryAddress(provider); create2Factory = await getCreate2FactoryAddress(provider);
} }
return ( return (
await computeDeploymentInfo("infra", provider, storage, create2Factory, { await computeDeploymentInfo(
contractName: "ForwarderEOAOnly", "infra",
}) provider,
storage,
create2Factory,
{
contractName: "ForwarderEOAOnly",
},
clientId,
secretKey,
)
).transaction.predictedAddress; ).transaction.predictedAddress;
} }
@@ -14,13 +14,23 @@ export async function computeForwarderAddress(
provider: providers.Provider, provider: providers.Provider,
storage: ThirdwebStorage, storage: ThirdwebStorage,
create2Factory?: string, create2Factory?: string,
clientId?: string,
secretKey?: string,
): Promise<string> { ): Promise<string> {
if (!create2Factory) { if (!create2Factory || create2Factory === "") {
create2Factory = await getCreate2FactoryAddress(provider); create2Factory = await getCreate2FactoryAddress(provider);
} }
return ( return (
await computeDeploymentInfo("infra", provider, storage, create2Factory, { await computeDeploymentInfo(
contractName: "Forwarder", "infra",
}) provider,
storage,
create2Factory,
{
contractName: "Forwarder",
},
clientId,
secretKey,
)
).transaction.predictedAddress; ).transaction.predictedAddress;
} }
@@ -14,13 +14,23 @@ export async function computeNativeTokenAddress(
provider: providers.Provider, provider: providers.Provider,
storage: ThirdwebStorage, storage: ThirdwebStorage,
create2Factory?: string, create2Factory?: string,
clientId?: string,
secretKey?: string,
): Promise<string> { ): Promise<string> {
if (!create2Factory) { if (!create2Factory || create2Factory === "") {
create2Factory = await getCreate2FactoryAddress(provider); create2Factory = await getCreate2FactoryAddress(provider);
} }
return ( return (
await computeDeploymentInfo("infra", provider, storage, create2Factory, { await computeDeploymentInfo(
contractName: "WETH9", "infra",
}) provider,
storage,
create2Factory,
{
contractName: "WETH9",
},
clientId,
secretKey,
)
).transaction.predictedAddress; ).transaction.predictedAddress;
} }
@@ -16,6 +16,7 @@ import { deployCreate2Factory } from "./deployCreate2Factory";
import { convertParamValues } from "./convertParamValues"; import { convertParamValues } from "./convertParamValues";
import { AbiInput } from "../../schema"; import { AbiInput } from "../../schema";
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress"; import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
import { fetchPublishedContractFromPolygon } from "./fetchPublishedContractFromPolygon";
/** /**
* Direct deploy a contract at a deterministic address, using Create2 method * Direct deploy a contract at a deterministic address, using Create2 method
@@ -36,7 +37,7 @@ export async function directDeployDeterministic(
constructorArgs: any[], constructorArgs: any[],
saltForCreate2?: string, saltForCreate2?: string,
gasLimit: number = 7000000, gasLimit: number = 7000000,
) { ): Promise<string> {
invariant(signer.provider, "Provider is required"); invariant(signer.provider, "Provider is required");
const bytecodePrefixed = bytecode.startsWith("0x") const bytecodePrefixed = bytecode.startsWith("0x")
@@ -97,6 +98,8 @@ export async function directDeployDeterministic(
} else { } else {
throw new Error(`Contract already deployed at ${address}`); throw new Error(`Contract already deployed at ${address}`);
} }
return address;
} }
/** /**
@@ -118,13 +121,73 @@ export async function directDeployDeterministicWithUri(
constructorArgs: any[], constructorArgs: any[],
saltForCreate2?: string, saltForCreate2?: string,
gasLimit: number = 7000000, gasLimit: number = 7000000,
) { ): Promise<string> {
const { compilerMetadata } = await fetchAndCacheDeployMetadata( const { compilerMetadata, extendedMetadata } =
publishMetadataUri, await fetchAndCacheDeployMetadata(publishMetadataUri, storage);
storage,
invariant(
extendedMetadata?.deployType === "standard",
"Must be direct deploy",
); );
await directDeployDeterministic( return await directDeployDeterministic(
compilerMetadata.bytecode,
compilerMetadata.abi,
signer,
constructorArgs,
saltForCreate2,
gasLimit,
);
}
/**
* Direct deploy a contract at a deterministic address, using Create2 method
* Address depends on the Create2 factory address and salt (if provided).
*
* @public
*
* @param contractName
* @param publisherAddress
* @param contractVersion
* @param constructorArgs
* @param signer
* @param storage
* @param clientId
* @param secretKey
* @param constructorArgs
* @param saltForCreate2
*/
export async function directDeployDeterministicPublished(
contractName: string,
publisherAddress: string,
contractVersion: string = "latest",
constructorArgs: any[],
signer: Signer,
storage: ThirdwebStorage,
clientId?: string,
secretKey?: string,
saltForCreate2?: string,
gasLimit: number = 7000000,
): Promise<string> {
const publishMetadataUri = (
await fetchPublishedContractFromPolygon(
publisherAddress,
contractName,
contractVersion,
storage,
clientId,
secretKey,
)
).metadataUri;
const { compilerMetadata, extendedMetadata } =
await fetchAndCacheDeployMetadata(publishMetadataUri, storage);
invariant(
extendedMetadata?.deployType === "standard",
"Must be direct deploy",
);
return await directDeployDeterministic(
compilerMetadata.bytecode, compilerMetadata.bytecode,
compilerMetadata.abi, compilerMetadata.abi,
signer, signer,
@@ -140,7 +203,7 @@ export async function predictAddressDeterministic(
provider: providers.Provider, provider: providers.Provider,
constructorArgs: any[], constructorArgs: any[],
saltForCreate2?: string, saltForCreate2?: string,
) { ): Promise<string> {
const bytecodePrefixed = bytecode.startsWith("0x") const bytecodePrefixed = bytecode.startsWith("0x")
? bytecode ? bytecode
: `0x${bytecode}`; : `0x${bytecode}`;
@@ -182,9 +245,50 @@ export async function predictAddressDeterministicWithUri(
constructorArgs: any[], constructorArgs: any[],
saltForCreate2?: string, saltForCreate2?: string,
): Promise<string> { ): Promise<string> {
const { compilerMetadata } = await fetchAndCacheDeployMetadata( const { compilerMetadata, extendedMetadata } =
publishMetadataUri, await fetchAndCacheDeployMetadata(publishMetadataUri, storage);
storage,
invariant(
extendedMetadata?.deployType === "standard",
"Must be direct deploy",
);
return await predictAddressDeterministic(
compilerMetadata.bytecode,
compilerMetadata.abi,
provider,
constructorArgs,
saltForCreate2,
);
}
export async function predictAddressDeterministicPublished(
contractName: string,
publisherAddress: string,
contractVersion: string = "latest",
constructorArgs: any[],
provider: providers.Provider,
storage: ThirdwebStorage,
clientId?: string,
secretKey?: string,
saltForCreate2?: string,
): Promise<string> {
const publishMetadataUri = (
await fetchPublishedContractFromPolygon(
publisherAddress,
contractName,
contractVersion,
storage,
clientId,
secretKey,
)
).metadataUri;
const { compilerMetadata, extendedMetadata } =
await fetchAndCacheDeployMetadata(publishMetadataUri, storage);
invariant(
extendedMetadata?.deployType === "standard",
"Must be direct deploy",
); );
return await predictAddressDeterministic( return await predictAddressDeterministic(
@@ -1,39 +0,0 @@
import { Contract } from "ethers";
import ContractPublisherAbi from "@thirdweb-dev/contracts-js/dist/abis/ContractPublisher.json";
import type { ContractPublisher } from "@thirdweb-dev/contracts-js";
import { getContractPublisherAddress } from "../../constants/addresses/getContractPublisherAddress";
import { getChainProvider } from "../../constants/urls";
const uriCache: Record<string, string> = {};
const THIRDWEB_DEPLOYER = "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024";
export async function fetchAndCachePublishedContractURI(
contractName: string,
): Promise<string> {
if (uriCache[contractName]) {
return uriCache[contractName];
}
const contract = new Contract(
getContractPublisherAddress(),
ContractPublisherAbi,
getChainProvider("polygon", {}),
) as ContractPublisher;
const model = await contract.getPublishedContract(
THIRDWEB_DEPLOYER,
contractName,
);
if (!model) {
throw new Error(
`No published contract found for ${contractName} at version by '${THIRDWEB_DEPLOYER}'`,
);
}
const uri = model.publishMetadataUri;
uriCache[contractName] = uri;
return uri;
}
@@ -0,0 +1,84 @@
import { Contract } from "ethers";
import ContractPublisherAbi from "@thirdweb-dev/contracts-js/dist/abis/ContractPublisher.json";
import type { ContractPublisher } from "@thirdweb-dev/contracts-js";
import { getContractPublisherAddress } from "../../constants/addresses/getContractPublisherAddress";
import { getChainProvider } from "../../constants/urls";
import { AddressOrEns, PublishedContractSchema } from "../../schema";
import { resolveAddress } from "../ens/resolveAddress";
import invariant from "tiny-invariant";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
import { getSupportedChains } from "../../constants";
import { Polygon } from "@thirdweb-dev/chains";
export const THIRDWEB_DEPLOYER = "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024";
export async function fetchPublishedContractFromPolygon(
publisherAddress: AddressOrEns,
contractName: string,
version: string = "latest",
storage: ThirdwebStorage,
clientId?: string,
secretKey?: string,
) {
const polygonChain = getSupportedChains().find((c) => c.chainId === 137);
const chain = polygonChain || Polygon;
const publisher = await resolveAddress(publisherAddress);
const contract = new Contract(
getContractPublisherAddress(),
ContractPublisherAbi,
getChainProvider(chain, { clientId, secretKey }),
) as ContractPublisher;
let publishedContract;
if (!version || version === "latest") {
const model = await contract.getPublishedContract(publisher, contractName);
publishedContract = PublishedContractSchema.parse({
id: model.contractId,
timestamp: model.publishTimestamp,
metadataUri: model.publishMetadataUri,
});
} else {
const allVersions = (
await contract.getPublishedContractVersions(publisher, contractName)
).map((c) => {
return PublishedContractSchema.parse({
id: c.contractId,
timestamp: c.publishTimestamp,
metadataUri: c.publishMetadataUri,
});
});
// get the metadata for each version
const versionMetadata = await Promise.all(
allVersions.map(async (c) => {
return {
name: c.id,
publishedTimestamp: c.timestamp,
publishedMetadata: await fetchAndCacheDeployMetadata(
c.metadataUri,
storage,
),
};
}),
);
// find the version that matches the version string
const versionMatch = versionMetadata.find(
(metadata) =>
metadata.publishedMetadata.extendedMetadata?.version === version,
);
invariant(versionMatch, "Contract version not found");
// match the version back to the contract based on the published timestamp
publishedContract = allVersions.find(
(c) => c.timestamp === versionMatch.publishedTimestamp,
);
}
if (!publishedContract) {
throw new Error(
`No published contract found for ${contractName} at version by '${THIRDWEB_DEPLOYER}'`,
);
}
return publishedContract;
}
@@ -13,9 +13,9 @@ import {
generateExtensionFunctions, generateExtensionFunctions,
generatePluginFunctions, generatePluginFunctions,
} from "../plugin/generatePluginFunctions"; } from "../plugin/generatePluginFunctions";
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins";
import { getMetadataForExtensions } from "../plugin/getMetadataForExtensions";
import { Extension } from "../../types/extensions"; import { Extension } from "../../types/extensions";
import { fetchPublishedContractFromPolygon } from "./fetchPublishedContractFromPolygon";
import invariant from "tiny-invariant";
/** /**
* *
* Returns txn data for keyless deploys as well as signer deploys. * Returns txn data for keyless deploys as well as signer deploys.
@@ -33,6 +33,8 @@ export async function getDeploymentInfo(
storage: ThirdwebStorage, storage: ThirdwebStorage,
provider: providers.Provider, provider: providers.Provider,
create2Factory?: string, create2Factory?: string,
clientId?: string,
secretKey?: string,
): Promise<DeploymentPreset[]> { ): Promise<DeploymentPreset[]> {
caches.deploymentPresets = {}; caches.deploymentPresets = {};
@@ -42,18 +44,33 @@ export async function getDeploymentInfo(
const customParams: ConstructorParamMap = {}; const customParams: ConstructorParamMap = {};
const finalDeploymentInfo: DeploymentPreset[] = []; const finalDeploymentInfo: DeploymentPreset[] = [];
const { compilerMetadata } = await fetchAndCacheDeployMetadata( const { compilerMetadata, extendedMetadata } =
metadataUri, await fetchAndCacheDeployMetadata(metadataUri, storage);
storage, const defaultExtensions = extendedMetadata?.defaultExtensions;
);
const pluginMetadata = await getMetadataForPlugins(metadataUri, storage); if (extendedMetadata?.routerType === "plugin" && defaultExtensions) {
const extensionMetadata = await getMetadataForExtensions( invariant(clientId || secretKey, "Require Client Id / Secret Key");
metadataUri, const publishedExtensions = await Promise.all(
storage, defaultExtensions.map((e) => {
); return fetchPublishedContractFromPolygon(
e.publisherAddress,
e.extensionName,
e.extensionVersion,
storage,
clientId,
secretKey,
);
}),
);
const pluginMetadata = (
await Promise.all(
publishedExtensions.map(async (c) => {
return fetchAndCacheDeployMetadata(c.metadataUri, storage);
}),
)
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
// if pluginMetadata is not empty, then it's a plugin-pattern router contract
if (pluginMetadata.length > 0) {
// get deployment info for all plugins // get deployment info for all plugins
const pluginDeploymentInfo = await Promise.all( const pluginDeploymentInfo = await Promise.all(
pluginMetadata.map(async (metadata) => { pluginMetadata.map(async (metadata) => {
@@ -63,6 +80,8 @@ export async function getDeploymentInfo(
storage, storage,
create2FactoryAddress, create2FactoryAddress,
{ metadata: metadata }, { metadata: metadata },
clientId,
secretKey,
); );
return info; return info;
}), }),
@@ -88,6 +107,8 @@ export async function getDeploymentInfo(
contractName: "PluginMap", contractName: "PluginMap",
constructorParams: { _pluginsToAdd: { value: mapInput } }, constructorParams: { _pluginsToAdd: { value: mapInput } },
}, },
clientId,
secretKey,
); );
// address of PluginMap is input for MarketplaceV3's constructor // address of PluginMap is input for MarketplaceV3's constructor
@@ -96,7 +117,29 @@ export async function getDeploymentInfo(
}; };
finalDeploymentInfo.push(...pluginDeploymentInfo, pluginMapTransaction); finalDeploymentInfo.push(...pluginDeploymentInfo, pluginMapTransaction);
} else if (extensionMetadata.length > 0) { } else if (extendedMetadata?.routerType === "dynamic" && defaultExtensions) {
invariant(clientId || secretKey, "Require Client Id / Secret Key");
const publishedExtensions = await Promise.all(
defaultExtensions.map((e) => {
return fetchPublishedContractFromPolygon(
e.publisherAddress,
e.extensionName,
e.extensionVersion,
storage,
clientId,
secretKey,
);
}),
);
const extensionMetadata = (
await Promise.all(
publishedExtensions.map(async (c) => {
return fetchAndCacheDeployMetadata(c.metadataUri, storage);
}),
)
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
// get deployment info for all extensions // get deployment info for all extensions
const extensionDeploymentInfo = await Promise.all( const extensionDeploymentInfo = await Promise.all(
extensionMetadata.map(async (metadata) => { extensionMetadata.map(async (metadata) => {
@@ -106,6 +149,8 @@ export async function getDeploymentInfo(
storage, storage,
create2FactoryAddress, create2FactoryAddress,
{ metadata: metadata }, { metadata: metadata },
clientId,
secretKey,
); );
return info; return info;
}), }),
@@ -143,6 +188,8 @@ export async function getDeploymentInfo(
metadata: compilerMetadata, metadata: compilerMetadata,
constructorParams: customParams, constructorParams: customParams,
}, },
clientId,
secretKey,
); );
// get clone factory // get clone factory
@@ -152,6 +199,8 @@ export async function getDeploymentInfo(
storage, storage,
create2FactoryAddress, create2FactoryAddress,
{ contractName: "TWCloneFactory" }, { contractName: "TWCloneFactory" },
clientId,
secretKey,
); );
finalDeploymentInfo.push(factoryInfo); finalDeploymentInfo.push(factoryInfo);
@@ -3,8 +3,10 @@ import { BytesLike } from "ethers";
import invariant from "tiny-invariant"; import invariant from "tiny-invariant";
import { getChainProvider } from "../../constants/urls"; import { getChainProvider } from "../../constants/urls";
import { ConstructorParamMap } from "../../types/any-evm/deploy-data"; import { ConstructorParamMap } from "../../types/any-evm/deploy-data";
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins"; import {
import { fetchAndCachePublishedContractURI } from "./fetchAndCachePublishedContractURI"; THIRDWEB_DEPLOYER,
fetchPublishedContractFromPolygon,
} from "./fetchPublishedContractFromPolygon";
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata"; import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress"; import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
import { encodeConstructorParamsForImplementation } from "./computeDeploymentInfo"; import { encodeConstructorParamsForImplementation } from "./computeDeploymentInfo";
@@ -21,6 +23,7 @@ export async function getEncodedConstructorParamsForThirdwebContract(
contractName: string, contractName: string,
chainId: number, chainId: number,
storage: ThirdwebStorage, storage: ThirdwebStorage,
contractVersion: string = "latest",
clientId?: string, clientId?: string,
secretKey?: string, secretKey?: string,
constructorParamMap?: ConstructorParamMap, constructorParamMap?: ConstructorParamMap,
@@ -29,22 +32,38 @@ export async function getEncodedConstructorParamsForThirdwebContract(
clientId, clientId,
secretKey, secretKey,
}); });
const publishUri = await fetchAndCachePublishedContractURI(contractName); const publishedContract = await fetchPublishedContractFromPolygon(
THIRDWEB_DEPLOYER,
contractName,
contractVersion,
storage,
clientId,
secretKey,
);
const publishUri = publishedContract.metadataUri;
const metadata = await fetchAndCacheDeployMetadata(publishUri, storage); const metadata = await fetchAndCacheDeployMetadata(publishUri, storage);
const create2Factory = await getCreate2FactoryAddress(provider); const create2Factory = await getCreate2FactoryAddress(provider);
invariant(create2Factory, "Thirdweb stack not found"); invariant(create2Factory, "Thirdweb stack not found");
const pluginMetadata = await getMetadataForPlugins(publishUri, storage); const { extendedMetadata } = await fetchAndCacheDeployMetadata(
publishUri,
storage,
);
let encodedArgs; let encodedArgs;
// if pluginMetadata is not empty, then it's a plugin-pattern router contract // if pluginMetadata is not empty, then it's a plugin-pattern router contract
if (pluginMetadata.length > 0) { if (
extendedMetadata?.routerType === "plugin" ||
extendedMetadata?.routerType === "dynamic"
) {
const deploymentInfo = await getDeploymentInfo( const deploymentInfo = await getDeploymentInfo(
publishUri, publishUri,
storage, storage,
provider, provider,
create2Factory, create2Factory,
clientId,
secretKey,
); );
encodedArgs = deploymentInfo.find( encodedArgs = deploymentInfo.find(
(contract) => contract.type === "implementation", (contract) => contract.type === "implementation",
@@ -56,6 +75,8 @@ export async function getEncodedConstructorParamsForThirdwebContract(
storage, storage,
create2Factory, create2Factory,
constructorParamMap, constructorParamMap,
clientId,
secretKey,
); );
} }
@@ -15,11 +15,14 @@ export function getInitBytecodeWithSalt(
encodedArgs: BytesLike, encodedArgs: BytesLike,
salt?: string, salt?: string,
): 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( const initBytecodeWithSalt = utils.solidityPack(
["bytes32", "bytes", "bytes"], ["bytes32", "bytes", "bytes"],
[saltHash, bytecode, encodedArgs], [saltHash, bytecodePrefixed, encodedArgs],
); );
return initBytecodeWithSalt; return initBytecodeWithSalt;
@@ -8,7 +8,10 @@ import { utils } from "ethers";
* @param bytecode: Creation bytecode of the contract to deploy * @param bytecode: Creation bytecode of the contract to deploy
*/ */
export function getSaltHash(bytecode: string): string { 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 salt = `tw.${bytecodeHash}`;
const saltHash = utils.id(salt); const saltHash = utils.id(salt);
@@ -16,6 +16,7 @@ export async function getThirdwebContractAddress(
contractName: string, contractName: string,
chainId: number, chainId: number,
storage: ThirdwebStorage, storage: ThirdwebStorage,
contractVersion: string = "latest",
clientId?: string, clientId?: string,
secretKey?: string, secretKey?: string,
): Promise<string> { ): Promise<string> {
@@ -27,6 +28,7 @@ export async function getThirdwebContractAddress(
contractName, contractName,
chainId, chainId,
storage, storage,
contractVersion,
clientId, clientId,
secretKey, secretKey,
); );
@@ -1,11 +1,14 @@
import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { ThirdwebStorage } from "@thirdweb-dev/storage";
import invariant from "tiny-invariant"; import invariant from "tiny-invariant";
import { getChainProvider } from "../../constants/urls"; import { getChainProvider } from "../../constants/urls";
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins"; import {
import { fetchAndCachePublishedContractURI } from "./fetchAndCachePublishedContractURI"; THIRDWEB_DEPLOYER,
fetchPublishedContractFromPolygon,
} from "./fetchPublishedContractFromPolygon";
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress"; import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
import { computeDeploymentInfo } from "./computeDeploymentInfo"; import { computeDeploymentInfo } from "./computeDeploymentInfo";
import { getDeploymentInfo } from "./getDeploymentInfo"; import { getDeploymentInfo } from "./getDeploymentInfo";
import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
/** /**
* *
@@ -18,6 +21,7 @@ export async function predictThirdwebContractAddress(
contractName: string, contractName: string,
chainId: number, chainId: number,
storage: ThirdwebStorage, storage: ThirdwebStorage,
contractVersion: string = "latest",
clientId?: string, clientId?: string,
secretKey?: string, secretKey?: string,
): Promise<string> { ): Promise<string> {
@@ -25,19 +29,34 @@ export async function predictThirdwebContractAddress(
clientId, clientId,
secretKey, secretKey,
}); });
const publishUri = await fetchAndCachePublishedContractURI(contractName); const publishedContract = await fetchPublishedContractFromPolygon(
THIRDWEB_DEPLOYER,
contractName,
contractVersion,
storage,
clientId,
secretKey,
);
const publishUri = publishedContract.metadataUri;
const create2Factory = await getCreate2FactoryAddress(provider); const create2Factory = await getCreate2FactoryAddress(provider);
invariant(create2Factory, "Thirdweb stack not found"); invariant(create2Factory, "Thirdweb stack not found");
const pluginMetadata = await getMetadataForPlugins(publishUri, storage); const { extendedMetadata } = await fetchAndCacheDeployMetadata(
publishUri,
storage,
);
// if pluginMetadata is not empty, then it's a plugin-pattern router contract if (
if (pluginMetadata.length > 0) { extendedMetadata?.routerType === "plugin" ||
extendedMetadata?.routerType === "dynamic"
) {
const deploymentInfo = await getDeploymentInfo( const deploymentInfo = await getDeploymentInfo(
publishUri, publishUri,
storage, storage,
provider, provider,
create2Factory, create2Factory,
clientId,
secretKey,
); );
const implementation = deploymentInfo.find( const implementation = deploymentInfo.find(
@@ -54,6 +73,8 @@ export async function predictThirdwebContractAddress(
storage, storage,
create2Factory, create2Factory,
{ contractName: contractName }, { contractName: contractName },
clientId,
secretKey,
); );
return implementation.transaction.predictedAddress; return implementation.transaction.predictedAddress;
@@ -1,7 +1,7 @@
import { ContractWrapper } from "../../core/classes/contract-wrapper";
import type { IERC20 } from "@thirdweb-dev/contracts-js"; import type { IERC20 } from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json"; 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( export async function approveErc20Allowance(
contractToApprove: ContractWrapper<any>, contractToApprove: ContractWrapper<any>,
@@ -20,8 +20,8 @@ export async function approveErc20Allowance(
contractToApprove.storage, contractToApprove.storage,
); );
const owner = await contractToApprove.getSignerAddress(); const owner = await contractToApprove.getSignerAddress();
const spender = contractToApprove.readContract.address; const spender = contractToApprove.address;
const allowance = await erc20.readContract.allowance(owner, spender); const allowance = await erc20.read("allowance", [owner, spender]);
const totalPrice = BigNumber.from(price) const totalPrice = BigNumber.from(price)
.mul(BigNumber.from(quantity)) .mul(BigNumber.from(quantity))
.div(utils.parseUnits("1", tokenDecimals)); .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 type { IERC20 } from "@thirdweb-dev/contracts-js";
import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json"; import ERC20Abi from "@thirdweb-dev/contracts-js/dist/abis/IERC20.json";
import { BigNumber } from "ethers"; import { BigNumber } from "ethers";
import { ContractWrapper } from "../../core/classes/contract-wrapper";
export async function hasERC20Allowance( export async function hasERC20Allowance(
contractToApprove: ContractWrapper<any>, contractToApprove: ContractWrapper<any>,
@@ -17,7 +17,7 @@ export async function hasERC20Allowance(
contractToApprove.storage, contractToApprove.storage,
); );
const owner = await contractToApprove.getSignerAddress(); const owner = await contractToApprove.getSignerAddress();
const spender = contractToApprove.readContract.address; const spender = contractToApprove.address;
const allowance = await erc20.readContract.allowance(owner, spender); const allowance = await erc20.read("allowance", [owner, spender]);
return allowance.gte(value); return allowance.gte(value);
} }
@@ -1,13 +1,13 @@
import { BigNumber, utils } from "ethers";
import { AmountSchema } from "../../../core/schema/shared"; import { AmountSchema } from "../../../core/schema/shared";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/contract-wrapper";
import { Amount } from "../../types/currency"; import { Amount } from "../../types/currency";
import { BaseERC20 } from "../../types/eips"; import { BaseERC20 } from "../../types/eips";
import { BigNumber, utils } from "ethers";
export async function normalizeAmount( export async function normalizeAmount(
contractWrapper: ContractWrapper<BaseERC20>, contractWrapper: ContractWrapper<BaseERC20>,
amount: Amount, amount: Amount,
): Promise<BigNumber> { ): Promise<BigNumber> {
const decimals = await contractWrapper.readContract.decimals(); const decimals = await contractWrapper.read("decimals", []);
return utils.parseUnits(AmountSchema.parse(amount), decimals); return utils.parseUnits(AmountSchema.parse(amount), decimals);
} }
@@ -2,7 +2,7 @@ import { FeatureName } from "../../constants/contract-features";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/contract-wrapper";
import { AbiSchema } from "../../schema/contracts/custom"; import { AbiSchema } from "../../schema/contracts/custom";
import { BaseContract } from "ethers"; import { BaseContract } from "ethers";
import { isFeatureEnabled } from "./isFeatureEnabled"; import { isExtensionEnabled } from "./isFeatureEnabled";
/** /**
* Type guard for contractWrappers depending on passed feature name * Type guard for contractWrappers depending on passed feature name
@@ -14,5 +14,5 @@ export function detectContractFeature<T extends BaseContract>(
contractWrapper: ContractWrapper<BaseContract>, contractWrapper: ContractWrapper<BaseContract>,
featureName: FeatureName, featureName: FeatureName,
): contractWrapper is ContractWrapper<T> { ): contractWrapper is ContractWrapper<T> {
return isFeatureEnabled(AbiSchema.parse(contractWrapper.abi), featureName); return isExtensionEnabled(AbiSchema.parse(contractWrapper.abi), featureName);
} }
@@ -4,7 +4,7 @@ import {
SUPPORTED_FEATURES, SUPPORTED_FEATURES,
} from "../../constants/contract-features"; } from "../../constants/contract-features";
import { AbiInput } from "../../schema/contracts/custom"; import { AbiInput } from "../../schema/contracts/custom";
import { hasMatchingAbi } from "./hasMatchingAbi"; import { hasMatchingAbi, matchesAbiFromBytecode } from "./hasMatchingAbi";
/** /**
* Processes ALL supported features and sets whether the passed in abi supports each individual feature * Processes ALL supported features and sets whether the passed in abi supports each individual feature
@@ -31,6 +31,24 @@ export function detectFeatures(
return results; return results;
} }
export function detectFeaturesFromBytecode(
bytecode: string,
features: Record<string, Feature> = SUPPORTED_FEATURES,
): Record<string, FeatureWithEnabled> {
const results: Record<string, FeatureWithEnabled> = {};
for (const featureKey in features) {
const feature = features[featureKey];
const enabled = matchesAbiFromBytecode(bytecode, feature.abis);
const childResults = detectFeaturesFromBytecode(bytecode, feature.features);
results[featureKey] = {
...feature,
features: childResults,
enabled,
} as FeatureWithEnabled;
}
return results;
}
/** /**
* @internal * @internal
* @param abi * @param abi
@@ -3,7 +3,8 @@ import {
FeatureWithEnabled, FeatureWithEnabled,
} from "../../constants/contract-features"; } from "../../constants/contract-features";
import { AbiInput } from "../../schema/contracts/custom"; import { AbiInput } from "../../schema/contracts/custom";
import { detectFeatures } from "./detectFeatures"; import { joinABIs } from "../plugin/joinABIs";
import { detectFeatures, detectFeaturesFromBytecode } from "./detectFeatures";
import { extractFeatures } from "./extractFeatures"; import { extractFeatures } from "./extractFeatures";
/** /**
@@ -19,6 +20,24 @@ export function getAllDetectedFeatures(abi: AbiInput): FeatureWithEnabled[] {
return features; return features;
} }
export function getAllDetectedExtensionsFromBytecode(
bytecode: string,
): FeatureWithEnabled[] {
const features: FeatureWithEnabled[] = [];
extractFeatures(detectFeaturesFromBytecode(bytecode), features);
return features;
}
export function constructAbiFromBytecode(bytecode: string): AbiInput {
let extensions = getAllDetectedExtensionsFromBytecode(bytecode);
// special deduping for ERC721 and ERC20
if (extensions.find((f) => f.name === "ERC721")) {
extensions = extensions.filter((f) => f.name !== "ERC20");
}
const abi = joinABIs(extensions.map((f) => joinABIs(f.abis as any)));
return abi;
}
/** /**
* Return all the detected extensions in the abi * Return all the detected extensions in the abi
* @param abi - parsed array of abi entries * @param abi - parsed array of abi entries
@@ -1,3 +1,4 @@
import { Interface } from "ethers/lib/utils";
import { AbiInput } from "../../schema/contracts/custom"; import { AbiInput } from "../../schema/contracts/custom";
import { extractFunctionsFromAbi } from "./extractFunctionsFromAbi"; import { extractFunctionsFromAbi } from "./extractFunctionsFromAbi";
@@ -38,3 +39,20 @@ export function hasMatchingAbi(
}); });
return intersection.length === interfaceFn.length; return intersection.length === interfaceFn.length;
} }
export function matchesAbiFromBytecode(
contractBytecode: string,
featureAbis: readonly AbiInput[],
) {
const interfaces = featureAbis.map((abi) => new Interface(abi));
const selectors = interfaces.flatMap((i) => {
return Object.values(i.functions).map((fn) =>
Number(i.getSighash(fn)).toString(16),
);
});
const uniqueSelectors = [...new Set(selectors)];
// checks that all unique selectors are found in the bytecode
return uniqueSelectors.every((selector) =>
contractBytecode.includes(selector),
);
}
@@ -11,6 +11,22 @@ export async function resolveContractUriFromAddress(
address: string, address: string,
provider: providers.Provider, provider: providers.Provider,
): Promise<string | undefined> { ): Promise<string | undefined> {
const bytecode = await resolveImplementationBytecode(address, provider);
return extractIPFSHashFromBytecode(bytecode);
}
export async function resolveContractUriAndBytecode(
address: string,
provider: providers.Provider,
): Promise<{ uri: string | undefined; bytecode: string }> {
const bytecode = await resolveImplementationBytecode(address, provider);
return { uri: extractIPFSHashFromBytecode(bytecode), bytecode };
}
export async function resolveImplementationBytecode(
address: string,
provider: providers.Provider,
): Promise<string> {
let bytecode; let bytecode;
try { try {
bytecode = await provider.getCode(address); bytecode = await provider.getCode(address);
@@ -26,10 +42,11 @@ export async function resolveContractUriFromAddress(
} }
try { try {
// TODO support other types of proxies
const implementationAddress = const implementationAddress =
extractMinimalProxyImplementationAddress(bytecode); extractMinimalProxyImplementationAddress(bytecode);
if (implementationAddress) { if (implementationAddress) {
return await resolveContractUriFromAddress( return await resolveImplementationBytecode(
implementationAddress, implementationAddress,
provider, provider,
); );
@@ -51,7 +68,7 @@ export async function resolveContractUriFromAddress(
utils.isAddress(implementationAddress) && utils.isAddress(implementationAddress) &&
implementationAddress !== constants.AddressZero implementationAddress !== constants.AddressZero
) { ) {
return await resolveContractUriFromAddress( return await resolveImplementationBytecode(
implementationAddress, implementationAddress,
provider, provider,
); );
@@ -59,6 +76,8 @@ export async function resolveContractUriFromAddress(
} catch (e) { } catch (e) {
// ignore // ignore
} }
// TODO support other types of proxies if (!bytecode) {
return await extractIPFSHashFromBytecode(bytecode); throw new Error(`Error fetching bytecode for ${address}`);
}
return bytecode;
} }
@@ -5,17 +5,21 @@ import {
} from "../schema/contracts/custom"; } from "../schema/contracts/custom";
import type { ThirdwebStorage } from "@thirdweb-dev/storage"; import type { ThirdwebStorage } from "@thirdweb-dev/storage";
const CONTRACT_METADATA_TIMEOUT_SEC = 2;
/** /**
* @internal * @internal
* @param compilerMetadataUri * @param compilerMetadataUri
* @param storage * @param storage
*/ */
export async function fetchContractMetadata( export async function fetchContractMetadata(
compilerMetadataUri: string, compilerMetadataUri: string,
storage: ThirdwebStorage, storage: ThirdwebStorage,
): Promise<PublishedMetadata> { ): Promise<PublishedMetadata> {
const metadata = await storage.downloadJSON(compilerMetadataUri); // short timeout to avoid hanging on unpinned contract metadata CIDs
const metadata = await storage.downloadJSON(compilerMetadataUri, {
timeoutInSeconds: CONTRACT_METADATA_TIMEOUT_SEC,
});
if (!metadata || !metadata.output) { if (!metadata || !metadata.output) {
throw new Error( throw new Error(
`Could not resolve metadata for contract at ${compilerMetadataUri}`, `Could not resolve metadata for contract at ${compilerMetadataUri}`,
+2 -1
View File
@@ -3,6 +3,7 @@ export * from "./snapshots";
export * from "./role"; export * from "./role";
export * from "./metadata-resolver"; export * from "./metadata-resolver";
export * from "./gas-price"; export * from "./gas-price";
export * from "./fetchContractMetadata";
// feature detection // feature detection
export * from "./feature-detection/matchesPrebuiltAbi"; export * from "./feature-detection/matchesPrebuiltAbi";
@@ -73,7 +74,7 @@ export * from "./any-evm-utils/deployWithThrowawayDeployer";
export * from "./any-evm-utils/computeDeploymentInfo"; export * from "./any-evm-utils/computeDeploymentInfo";
export * from "./any-evm-utils/convertParamValues"; export * from "./any-evm-utils/convertParamValues";
export * from "./any-evm-utils/getCreate2FactoryDeploymentInfo"; export * from "./any-evm-utils/getCreate2FactoryDeploymentInfo";
export * from "./any-evm-utils/fetchAndCachePublishedContractURI"; export * from "./any-evm-utils/fetchPublishedContractFromPolygon";
export * from "./any-evm-utils/fetchAndCacheDeployMetadata"; export * from "./any-evm-utils/fetchAndCacheDeployMetadata";
export * from "./any-evm-utils/estimateGasForDeploy"; export * from "./any-evm-utils/estimateGasForDeploy";
export * from "./any-evm-utils/createTransactionBatches"; export * from "./any-evm-utils/createTransactionBatches";
@@ -1,6 +1,6 @@
import { Abi, PublishedMetadata } from "../schema/contracts/custom"; import { Abi, PublishedMetadata } from "../schema/contracts/custom";
import { Address } from "../schema/shared/Address"; import { Address } from "../schema/shared/Address";
import { resolveContractUriFromAddress } from "./feature-detection/resolveContractUriFromAddress"; import { resolveContractUriAndBytecode } from "./feature-detection/resolveContractUriFromAddress";
import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { Contract, providers } from "ethers"; import { Contract, providers } from "ethers";
import { fetchContractMetadata } from "./fetchContractMetadata"; import { fetchContractMetadata } from "./fetchContractMetadata";
@@ -8,7 +8,9 @@ import TWRegistryABI from "@thirdweb-dev/contracts-js/dist/abis/TWMultichainRegi
import { getMultichainRegistryAddress } from "../constants/addresses/getMultichainRegistryAddress"; import { getMultichainRegistryAddress } from "../constants/addresses/getMultichainRegistryAddress";
import { getChainProvider } from "../constants/urls"; import { getChainProvider } from "../constants/urls";
import type { TWMultichainRegistryLogic } from "@thirdweb-dev/contracts-js"; import type { TWMultichainRegistryLogic } from "@thirdweb-dev/contracts-js";
import { constructAbiFromBytecode } from "./feature-detection/getAllDetectedFeatures";
import { SDKOptions } from "../schema"; import { SDKOptions } from "../schema";
import { Polygon } from "@thirdweb-dev/chains";
// Internal static cache // Internal static cache
const metadataCache: Record<string, PublishedMetadata> = {}; const metadataCache: Record<string, PublishedMetadata> = {};
@@ -41,61 +43,92 @@ export async function fetchContractMetadataFromAddress(
provider: providers.Provider, provider: providers.Provider,
storage: ThirdwebStorage, storage: ThirdwebStorage,
sdkOptions: SDKOptions = {}, sdkOptions: SDKOptions = {},
) { ): Promise<PublishedMetadata> {
const chainId = (await provider.getNetwork()).chainId; const chainId = (await provider.getNetwork()).chainId; // TODO resolve from sdk network
const cached = getFromCache(address, chainId); const cached = getFromCache(address, chainId);
if (cached) { if (cached) {
return cached; return cached;
} }
let metadata: PublishedMetadata | undefined; let metadata: PublishedMetadata | undefined;
try {
const compilerMetadataUri = await resolveContractUriFromAddress(
address,
provider,
);
if (!compilerMetadataUri) {
throw new Error(`Could not resolve metadata for contract at ${address}`);
}
metadata = await fetchContractMetadata(compilerMetadataUri, storage);
} catch (e) {
console.debug(
"Contract Metadata not found on IPFS, defaulting to onchain registry. Original error:",
(e as any)?.message,
);
try {
// try from multichain registry
if (!multichainRegistry) {
// TODO enforce always passing sdk options for clientId/secretKey
multichainRegistry = new Contract(
getMultichainRegistryAddress(),
TWRegistryABI,
getChainProvider("polygon", sdkOptions),
) as TWMultichainRegistryLogic;
}
const importedUri = await multichainRegistry.getMetadataUri( // we can't race here, because the contract URI might resolve first with a non pinned URI
chainId, const [ipfsData, registryData] = await Promise.all([
address, resolveContractUriAndBytecode(address, provider).catch(() => undefined),
getMetadataUriFromMultichainRegistry(address, chainId, sdkOptions)
.then((uri) => {
if (!uri) {
return undefined;
}
return {
uri,
bytecode: "",
};
})
.catch(() => undefined),
]);
const bytecode = ipfsData?.bytecode;
const metadataUri = registryData?.uri || ipfsData?.uri;
if (!metadataUri && !bytecode) {
throw new Error(
`Could not fetch bytecode for contract at ${address} on chain ${chainId}, double check that the address and chainId are correct.`,
);
}
try {
metadata = await fetchContractMetadata(metadataUri, storage);
} catch (e) {
// Don't warn here, its common to not have IPFS metadata for a contract, fallback to bytecode
}
if (!metadata && bytecode) {
const abi = constructAbiFromBytecode(bytecode);
if (abi && abi.length > 0) {
console.warn(
`Contract metadata could only be partially resolved, some contract functions might be unavailable. Try importing the contract by visiting: https://thirdweb.com/${chainId}/${address}`,
); );
if (!importedUri) { // return partial ABI
throw new Error( metadata = {
`Could not resolve metadata for contract at ${address}`, name: "Unimported Contract",
); abi: abi as Abi,
} metadata: {},
metadata = await fetchContractMetadata(importedUri, storage); info: {},
} catch (err) { licenses: [],
throw new Error(`Could not resolve metadata for contract at ${address}`); isPartialAbi: true,
};
// return without caching
return metadata;
} }
} }
if (!metadata) { if (!metadata) {
throw new Error( throw new Error(
`No ABI found for this contract. Try importing it by visiting: https://thirdweb.com/${chainId}/${address}`, `Could not resolve contract. Try importing it by visiting: https://thirdweb.com/${chainId}/${address}`,
); );
} }
putInCache(address, chainId, metadata); putInCache(address, chainId, metadata);
return metadata; return metadata;
} }
async function getMetadataUriFromMultichainRegistry(
address: string,
chainId: number,
sdkOptions: SDKOptions,
) {
if (!multichainRegistry) {
const polygonChain = sdkOptions?.supportedChains?.find(
(c) => c.chainId === 137,
);
const chain = polygonChain || Polygon;
multichainRegistry = new Contract(
getMultichainRegistryAddress(),
TWRegistryABI,
getChainProvider(chain, sdkOptions),
) as TWMultichainRegistryLogic;
}
const importedUri = await multichainRegistry.getMetadataUri(chainId, address);
return importedUri;
}
/** /**
* @internal * @internal
* @param address * @param address
@@ -27,7 +27,9 @@ export function generatePluginFunctions(
const pluginFunctions: Plugin[] = []; const pluginFunctions: Plugin[] = [];
// TODO - filter out common functions like _msgSender(), contractType(), etc. // TODO - filter out common functions like _msgSender(), contractType(), etc.
for (const fnFragment of Object.values(pluginInterface.functions)) { for (const fnFragment of Object.values(pluginInterface.functions)) {
const fn = pluginInterface.getFunction(fnFragment.name); const fn = pluginInterface.getFunction(
pluginInterface.getSighash(fnFragment),
);
if (fn.name.includes("_")) { if (fn.name.includes("_")) {
continue; continue;
} }
@@ -29,11 +29,11 @@ export async function getCompositePluginABI(
AbiSchema.parse(abi), AbiSchema.parse(abi),
"PluginRouter", "PluginRouter",
); );
const isExtensionRouter: boolean = isFeatureEnabled( const isbaseRouter: boolean = isFeatureEnabled(
AbiSchema.parse(abi), AbiSchema.parse(abi),
"ExtensionRouter", "DynamicContract",
); );
if (isExtensionRouter) { if (isbaseRouter) {
const contract = new ContractWrapper( const contract = new ContractWrapper(
provider, provider,
address, address,
@@ -1,74 +0,0 @@
import { getAllExtensionsAbi } from "../../constants/thirdweb-features";
import { ContractWrapper } from "../../core/classes/contract-wrapper";
import {
AbiSchema,
PreDeployMetadataFetched,
} from "../../schema/contracts/custom";
import { isFeatureEnabled } from "../feature-detection/isFeatureEnabled";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { getChainProvider } from "../../constants/urls";
import { fetchAndCachePublishedContractURI } from "../any-evm-utils/fetchAndCachePublishedContractURI";
import { fetchAndCacheDeployMetadata } from "../any-evm-utils/fetchAndCacheDeployMetadata";
import { Extension } from "../../types/extensions";
export async function getMetadataForExtensions(
publishedMetadataUri: string,
storage: ThirdwebStorage,
): Promise<PreDeployMetadataFetched[]> {
let extensionMetadata: PreDeployMetadataFetched[] = [];
const { compilerMetadata, extendedMetadata } =
await fetchAndCacheDeployMetadata(publishedMetadataUri, storage);
// check if contract is extension-pattern
const isExtensionRouter: boolean = isFeatureEnabled(
AbiSchema.parse(compilerMetadata.abi),
"ExtensionRouter",
);
if (isExtensionRouter) {
if (
extendedMetadata &&
extendedMetadata.factoryDeploymentData?.implementationAddresses
) {
const implementationsAddresses = Object.entries(
extendedMetadata.factoryDeploymentData.implementationAddresses,
);
try {
const entry = implementationsAddresses.find(
([, implementation]) => implementation !== "",
);
const [network, implementation] = entry ? entry : [];
if (network && implementation) {
const provider = getChainProvider(parseInt(network), {});
const contract = new ContractWrapper(
provider,
implementation,
getAllExtensionsAbi,
{},
storage,
);
const extensions = await contract.call("getAllExtensions");
const extensionNames: string[] = Array.from(
new Set(extensions.map((item: Extension) => item.metadata.name)),
);
const extensionUris = await Promise.all(
extensionNames.map((name) => {
return fetchAndCachePublishedContractURI(name);
}),
);
extensionMetadata = (
await Promise.all(
extensionUris.map(async (uri) => {
return fetchAndCacheDeployMetadata(uri, storage);
}),
)
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
}
} catch {}
}
}
return extensionMetadata;
}
@@ -1,91 +0,0 @@
import { getAllPluginsAbi } from "../../constants/thirdweb-features";
import { ContractWrapper } from "../../core/classes/contract-wrapper";
import {
AbiSchema,
PreDeployMetadataFetched,
} from "../../schema/contracts/custom";
import { isFeatureEnabled } from "../feature-detection/isFeatureEnabled";
import { fetchContractMetadataFromAddress } from "../metadata-resolver";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { Plugin } from "../../types/plugins";
import { getChainProvider } from "../../constants/urls";
import { fetchAndCachePublishedContractURI } from "../any-evm-utils/fetchAndCachePublishedContractURI";
import { fetchAndCacheDeployMetadata } from "../any-evm-utils/fetchAndCacheDeployMetadata";
export async function getMetadataForPlugins(
publishedMetadataUri: string,
storage: ThirdwebStorage,
): Promise<PreDeployMetadataFetched[]> {
let pluginMetadata: PreDeployMetadataFetched[] = [];
const { compilerMetadata, extendedMetadata } =
await fetchAndCacheDeployMetadata(publishedMetadataUri, storage);
// check if contract is plugin-pattern
const isPluginRouter: boolean = isFeatureEnabled(
AbiSchema.parse(compilerMetadata.abi),
"PluginRouter",
);
if (isPluginRouter) {
if (
extendedMetadata &&
extendedMetadata.factoryDeploymentData?.implementationAddresses
) {
const implementationsAddresses = Object.entries(
extendedMetadata.factoryDeploymentData.implementationAddresses,
);
try {
const entry = implementationsAddresses.find(
([, implementation]) => implementation !== "",
);
const [network, implementation] = entry ? entry : [];
if (network && implementation) {
const provider = getChainProvider(parseInt(network), {});
const contract = new ContractWrapper(
provider,
implementation,
getAllPluginsAbi,
{},
storage,
);
const pluginMap = await contract.call("getAllPlugins");
// get extension addresses
const allPlugins = pluginMap.map(
(item: Plugin) => item.pluginAddress,
);
const pluginAddresses = Array.from(new Set(allPlugins));
const pluginNames = (
await Promise.all(
pluginAddresses.map(async (address) => {
const metadata = fetchContractMetadataFromAddress(
address as string,
provider,
storage,
);
return metadata;
}),
)
).map((metadata) => metadata.name);
const pluginUris = await Promise.all(
pluginNames.map((name) => {
return fetchAndCachePublishedContractURI(name);
}),
);
pluginMetadata = (
await Promise.all(
pluginUris.map(async (uri) => {
return fetchAndCacheDeployMetadata(uri, storage);
}),
)
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
}
} catch {}
}
}
return pluginMetadata;
}
@@ -6,9 +6,9 @@ export function isRouterContract(abi: Abi) {
AbiSchema.parse(abi), AbiSchema.parse(abi),
"PluginRouter", "PluginRouter",
); );
const isExtensionRouter: boolean = isFeatureEnabled( const isBaseRouter: boolean = isFeatureEnabled(
AbiSchema.parse(abi), AbiSchema.parse(abi),
"ExtensionRouter", "DynamicContract",
); );
return isExtensionRouter || isPluginRouter; return isBaseRouter || isPluginRouter;
} }

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