Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8258b5c15 | ||
|
|
b8086435a4 | ||
|
|
6cc4b8d28b | ||
|
|
02ab92cc5c | ||
|
|
b6b52ea56b | ||
|
|
da95dce580 | ||
|
|
44dbf283c9 | ||
|
|
d844714609 | ||
|
|
5cea8436c1 | ||
|
|
dac8fa7d98 | ||
|
|
7a6534d1a9 | ||
|
|
d5aee62bf4 | ||
|
|
0bfdedd4ba | ||
|
|
c5761b99e9 | ||
|
|
42d9ab68d9 | ||
|
|
fd0650dcac | ||
|
|
ddb3dabe69 | ||
|
|
b96a228273 | ||
|
|
781e26d896 | ||
|
|
f7392138ee | ||
|
|
5eb6fc1bf3 | ||
|
|
7dc685bbec | ||
|
|
4915ac50f8 | ||
|
|
d724ad85c5 |
@@ -131,3 +131,4 @@ jobs:
|
|||||||
run: pnpm e2e
|
run: pnpm e2e
|
||||||
env:
|
env:
|
||||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||||
|
CLI_E2E_API_KEY: ${{ secrets.CLI_E2E_API_KEY }}
|
||||||
|
|||||||
+4
-4
@@ -38,15 +38,15 @@
|
|||||||
"@changesets/get-dependents-graph": "^1.3.6",
|
"@changesets/get-dependents-graph": "^1.3.6",
|
||||||
"@changesets/get-release-plan": "^3.0.17",
|
"@changesets/get-release-plan": "^3.0.17",
|
||||||
"@changesets/parse": "^0.3.16",
|
"@changesets/parse": "^0.3.16",
|
||||||
"@manypkg/cli": "^0.20.0",
|
"@manypkg/cli": "^0.21.0",
|
||||||
"@manypkg/get-packages": "^1.1.3",
|
"@manypkg/get-packages": "^1.1.3",
|
||||||
"@playwright/test": "1.31.2",
|
"@playwright/test": "1.31.2",
|
||||||
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
||||||
"@types/node": "^18.16.18",
|
"@types/node": "^18.16.18",
|
||||||
"eslint": "^8.43.0",
|
"eslint": "^8.45.0",
|
||||||
"mocha": "^10.2.0",
|
"mocha": "^10.2.0",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^3.0.0",
|
||||||
"turbo": "^1.10.6",
|
"turbo": "^1.10.7",
|
||||||
"yalc": "1.0.0-pre.53"
|
"yalc": "1.0.0-pre.53"
|
||||||
},
|
},
|
||||||
"manypkg": {
|
"manypkg": {
|
||||||
|
|||||||
@@ -1,5 +1,26 @@
|
|||||||
# @thirdweb-dev/auth
|
# @thirdweb-dev/auth
|
||||||
|
|
||||||
|
## 3.2.18
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @thirdweb-dev/wallets@1.1.1
|
||||||
|
|
||||||
|
## 3.2.17
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b)]:
|
||||||
|
- @thirdweb-dev/wallets@1.1.0
|
||||||
|
|
||||||
|
## 3.2.16
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`c5761b99`](https://github.com/thirdweb-dev/js/commit/c5761b99e9797772481506e90cbfa5c35a05bd1d), [`b96a2282`](https://github.com/thirdweb-dev/js/commit/b96a2282730582b684cc96802649a96851af5220)]:
|
||||||
|
- @thirdweb-dev/wallets@1.0.12
|
||||||
|
|
||||||
## 3.2.15
|
## 3.2.15
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/auth",
|
"name": "@thirdweb-dev/auth",
|
||||||
"version": "3.2.15",
|
"version": "3.2.18",
|
||||||
"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": {
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
"@typescript-eslint/parser": "^5.60.1",
|
"@typescript-eslint/parser": "^5.60.1",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.6",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"eslint": "^8.43.0",
|
"eslint": "^8.45.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-config-thirdweb": "workspace:*",
|
"eslint-config-thirdweb": "workspace:*",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
"mocha": "^10.2.0",
|
"mocha": "^10.2.0",
|
||||||
"next": "^12.3.4",
|
"next": "^12.3.4",
|
||||||
"next-auth": "^4.22.1",
|
"next-auth": "^4.22.1",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^3.0.0",
|
||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
# @thirdweb-dev/chains
|
# @thirdweb-dev/chains
|
||||||
|
|
||||||
|
## 0.1.36
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1366](https://github.com/thirdweb-dev/js/pull/1366) [`02ab92cc`](https://github.com/thirdweb-dev/js/commit/02ab92cc5c97f475e3b5642e5a7bdbe63ca136ee) Thanks [@jnsdls](https://github.com/jnsdls)! - new supported chains
|
||||||
|
|
||||||
|
- [#1358](https://github.com/thirdweb-dev/js/pull/1358) [`6cc4b8d2`](https://github.com/thirdweb-dev/js/commit/6cc4b8d28b982c5be3e1cd17d2a9a947001d1608) Thanks [@DLHTX](https://github.com/DLHTX)! - feat(chain): add iotex chain icon
|
||||||
|
|
||||||
|
## 0.1.35
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1316](https://github.com/thirdweb-dev/js/pull/1316) [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b) Thanks [@iketw](https://github.com/iketw)! - Adds support for clientId / secretKey
|
||||||
|
|
||||||
## 0.1.34
|
## 0.1.34
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ export default {
|
|||||||
"rpc": [
|
"rpc": [
|
||||||
"https://gon-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
"https://gon-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
"https://node1.testnet.gaiaopen.network",
|
"https://node1.testnet.gaiaopen.network",
|
||||||
"http://database1.gaiaopen.network"
|
"https://node1.mainnet.gon.network",
|
||||||
|
"https://node2.mainnet.gon.network",
|
||||||
|
"https://node3.mainnet.gon.network",
|
||||||
|
"https://node4.mainnet.gon.network"
|
||||||
],
|
],
|
||||||
"faucets": [],
|
"faucets": [],
|
||||||
"nativeCurrency": {
|
"nativeCurrency": {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import type { Chain } from "../src/types";
|
import type { Chain } from "../src/types";
|
||||||
export default {
|
export default {
|
||||||
"name": "ChainX-EVM",
|
"name": "BEVM",
|
||||||
"chain": "ChainX",
|
"chain": "ChainX",
|
||||||
"rpc": [
|
"rpc": [
|
||||||
"https://chainx-evm.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
"https://bevm.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
"https://mainnet.chainx.org/rpc",
|
"https://mainnet.chainx.org/rpc",
|
||||||
"https://mainnet2.chainx.org/rpc"
|
"https://mainnet2.chainx.org/rpc"
|
||||||
],
|
],
|
||||||
@@ -19,11 +19,11 @@ export default {
|
|||||||
"networkId": 1501,
|
"networkId": 1501,
|
||||||
"explorers": [
|
"explorers": [
|
||||||
{
|
{
|
||||||
"name": "chainx-evm scan",
|
"name": "bevm scan",
|
||||||
"url": "https://evm.chainx.org",
|
"url": "https://evm.chainx.org",
|
||||||
"standard": "none"
|
"standard": "none"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"testnet": false,
|
"testnet": false,
|
||||||
"slug": "chainx-evm"
|
"slug": "bevm"
|
||||||
} as const satisfies Chain;
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Antofy Mainnet",
|
||||||
|
"chain": "ABN",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmdTfku81ohnG9ECU1Xswmeumt678cBhwHWuFYZ7i1Qsto",
|
||||||
|
"width": 400,
|
||||||
|
"height": 400,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://antofy.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc.antofy.io"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.antofy.io"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Antofy",
|
||||||
|
"symbol": "ABN",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://antofy.io",
|
||||||
|
"shortName": "ABNm",
|
||||||
|
"chainId": 2202,
|
||||||
|
"networkId": 2202,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Antofy Mainnet",
|
||||||
|
"url": "https://antofyscan.com",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": false,
|
||||||
|
"slug": "antofy"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -2,10 +2,10 @@ import type { Chain } from "../src/types";
|
|||||||
export default {
|
export default {
|
||||||
"name": "Kroma Sepolia",
|
"name": "Kroma Sepolia",
|
||||||
"title": "Kroma Testnet Sepolia",
|
"title": "Kroma Testnet Sepolia",
|
||||||
"chainId": 2357,
|
"chainId": 2358,
|
||||||
"shortName": "kroma-sepolia",
|
"shortName": "kroma-sepolia",
|
||||||
"chain": "ETH",
|
"chain": "ETH",
|
||||||
"networkId": 2357,
|
"networkId": 2358,
|
||||||
"nativeCurrency": {
|
"nativeCurrency": {
|
||||||
"name": "Sepolia Ether",
|
"name": "Sepolia Ether",
|
||||||
"symbol": "ETH",
|
"symbol": "ETH",
|
||||||
@@ -15,19 +15,19 @@ export default {
|
|||||||
"symbol": "NEON",
|
"symbol": "NEON",
|
||||||
"decimals": 18
|
"decimals": 18
|
||||||
},
|
},
|
||||||
"infoURL": "https://neon-labs.org",
|
"infoURL": "https://neonevm.org",
|
||||||
"shortName": "neonevm-mainnet",
|
"shortName": "neonevm-mainnet",
|
||||||
"chainId": 245022934,
|
"chainId": 245022934,
|
||||||
"networkId": 245022934,
|
"networkId": 245022934,
|
||||||
"explorers": [
|
"explorers": [
|
||||||
{
|
{
|
||||||
"name": "native",
|
"name": "neonscan",
|
||||||
"url": "https://mainnet.explorer.neon-labs.org",
|
"url": "https://neonscan.org",
|
||||||
"standard": "EIP3091"
|
"standard": "EIP3091"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "neonscan",
|
"name": "native",
|
||||||
"url": "https://mainnet.neonscan.org",
|
"url": "https://neon.blockscout.com",
|
||||||
"standard": "EIP3091"
|
"standard": "EIP3091"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "EgonCoin Mainnet",
|
||||||
|
"chain": "EGON",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmNZiMmzMQYjyGtNSghtzLg4UooYhDgMQsa677DAP5KsBg",
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://egoncoin.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc.egcscan.com"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.egcscan.com"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "EgonCoin",
|
||||||
|
"symbol": "EGON",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://egcscan.com",
|
||||||
|
"shortName": "EGONm",
|
||||||
|
"chainId": 271,
|
||||||
|
"networkId": 271,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "EgonCoin Mainnet",
|
||||||
|
"url": "https://egcscan.com",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": false,
|
||||||
|
"slug": "egoncoin"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "EgonCoin Testnet",
|
||||||
|
"chain": "EGON",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmNZiMmzMQYjyGtNSghtzLg4UooYhDgMQsa677DAP5KsBg",
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://egoncoin-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpctest.egcscan.com"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.egcscan.com"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "EgonCoin",
|
||||||
|
"symbol": "EGON",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://egcscan.com",
|
||||||
|
"shortName": "EGONt",
|
||||||
|
"chainId": 271271,
|
||||||
|
"networkId": 271271,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "EgonCoin Testnet",
|
||||||
|
"url": "https://testnet.egcscan.com",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "egoncoin-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "ProofOfPepe Testnet",
|
||||||
|
"chain": "POPTestnet",
|
||||||
|
"shortName": "POPTestnet",
|
||||||
|
"chainId": 331769,
|
||||||
|
"testnet": true,
|
||||||
|
"rpc": [
|
||||||
|
"https://proofofpepe-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://testnet01.proofofpepe.tech"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "POP",
|
||||||
|
"symbol": "POP",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "ProofOfPepe Explorer",
|
||||||
|
"url": "https://pepescan.app/",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"slug": "proofofpepe-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "SenjePowers Mainnet",
|
||||||
|
"chain": "SPC",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmcpyTj4hUyHJZ2VmSdkXFpPpRcNKRP1VxMs7Cp1anymNy",
|
||||||
|
"width": 504,
|
||||||
|
"height": 495,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://senjepowers.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc.senjepowersscan.com"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.senjepowersscan.com"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "SenjePowers",
|
||||||
|
"symbol": "SPC",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://senjepowersscan.com",
|
||||||
|
"shortName": "SPCm",
|
||||||
|
"chainId": 3699,
|
||||||
|
"networkId": 3699,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "SenjePowers",
|
||||||
|
"url": "https://senjepowersscan.com",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": false,
|
||||||
|
"slug": "senjepowers"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -23,6 +23,12 @@ export default {
|
|||||||
"standard": "EIP3091"
|
"standard": "EIP3091"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmQKHQrvtyUC5b5B76ke5GPTGXoGTVCubXS6gHgzCAswKo",
|
||||||
|
"width": 250,
|
||||||
|
"height": 250,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
"testnet": false,
|
"testnet": false,
|
||||||
"slug": "iotex-network"
|
"slug": "iotex-network"
|
||||||
} as const satisfies Chain;
|
} as const satisfies Chain;
|
||||||
@@ -25,6 +25,12 @@ export default {
|
|||||||
"standard": "EIP3091"
|
"standard": "EIP3091"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmQKHQrvtyUC5b5B76ke5GPTGXoGTVCubXS6gHgzCAswKo",
|
||||||
|
"width": 250,
|
||||||
|
"height": 250,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
"testnet": true,
|
"testnet": true,
|
||||||
"slug": "iotex-network-testnet"
|
"slug": "iotex-network-testnet"
|
||||||
} as const satisfies Chain;
|
} as const satisfies Chain;
|
||||||
@@ -2,6 +2,12 @@ import type { Chain } from "../src/types";
|
|||||||
export default {
|
export default {
|
||||||
"name": "Mantle",
|
"name": "Mantle",
|
||||||
"chain": "ETH",
|
"chain": "ETH",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmYddHh5zdceSsBU7uGfQvEHg6UUtAFbzQBBaePS4whx7o",
|
||||||
|
"width": 225,
|
||||||
|
"height": 225,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
"rpc": [
|
"rpc": [
|
||||||
"https://mantle.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
"https://mantle.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
"https://rpc.mantle.xyz"
|
"https://rpc.mantle.xyz"
|
||||||
@@ -23,6 +29,15 @@ export default {
|
|||||||
"standard": "EIP3091"
|
"standard": "EIP3091"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"parent": {
|
||||||
|
"type": "L2",
|
||||||
|
"chain": "eip155-1",
|
||||||
|
"bridges": [
|
||||||
|
{
|
||||||
|
"url": "https://bridge.mantle.xyz"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"testnet": false,
|
"testnet": false,
|
||||||
"slug": "mantle"
|
"slug": "mantle"
|
||||||
} as const satisfies Chain;
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Toronet Testnet",
|
||||||
|
"chain": "Toronet",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmciSvgLatP6jhgdazuiyD3fSrhipfAN7wC943v1qxcrpv",
|
||||||
|
"width": 846,
|
||||||
|
"height": 733,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://toronet-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"http://testnet.toronet.org/rpc"
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Toro",
|
||||||
|
"symbol": "TORO",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://toronet.org",
|
||||||
|
"shortName": "ToronetTestnet",
|
||||||
|
"chainId": 54321,
|
||||||
|
"networkId": 54321,
|
||||||
|
"ens": {
|
||||||
|
"registry": "0x059C474f26D65B0458F9da10A649a7322aB02C09"
|
||||||
|
},
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "toronet_explorer",
|
||||||
|
"url": "https://testnet.toronet.org",
|
||||||
|
"standard": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "toronet-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -10,8 +10,17 @@ export default {
|
|||||||
"symbol": "ETH",
|
"symbol": "ETH",
|
||||||
"decimals": 18
|
"decimals": 18
|
||||||
},
|
},
|
||||||
"rpc": [],
|
"rpc": [
|
||||||
|
"https://linea.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://linea-mainnet.infura.io/v3/${INFURA_API_KEY}",
|
||||||
|
"https://rpc.linea.build"
|
||||||
|
],
|
||||||
"explorers": [
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "lineascan",
|
||||||
|
"url": "https://lineascan.build",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Linea Scan",
|
"name": "Linea Scan",
|
||||||
"url": "https://lineascan.build",
|
"url": "https://lineascan.build",
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Bitrock Mainnet",
|
||||||
|
"chain": "Bitrock",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmfXZCAh3HWS2bJroUStN9TieL4QA9QArMotie3X4pwBfj",
|
||||||
|
"width": 72,
|
||||||
|
"height": 72,
|
||||||
|
"format": "svg"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://bitrock.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://connect.bit-rock.io"
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "BITROCK",
|
||||||
|
"symbol": "BROCK",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://bit-rock.io",
|
||||||
|
"shortName": "bitrock",
|
||||||
|
"chainId": 7171,
|
||||||
|
"networkId": 7171,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Bitrock Explorer",
|
||||||
|
"url": "https://scan.bit-rock.io",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": false,
|
||||||
|
"slug": "bitrock"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Bitrock Testnet",
|
||||||
|
"chain": "Bitrock",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmfXZCAh3HWS2bJroUStN9TieL4QA9QArMotie3X4pwBfj",
|
||||||
|
"width": 72,
|
||||||
|
"height": 72,
|
||||||
|
"format": "svg"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://bitrock-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://testnet.bit-rock.io"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet.bit-rock.io"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "BITROCK",
|
||||||
|
"symbol": "BROCK",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://bit-rock.io",
|
||||||
|
"shortName": "tbitrock",
|
||||||
|
"chainId": 7771,
|
||||||
|
"networkId": 7771,
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "Bitrock Testnet Explorer",
|
||||||
|
"url": "https://testnetscan.bit-rock.io",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "bitrock-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Toronet Mainnet",
|
||||||
|
"chain": "Toronet",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmciSvgLatP6jhgdazuiyD3fSrhipfAN7wC943v1qxcrpv",
|
||||||
|
"width": 846,
|
||||||
|
"height": 733,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"rpc": [
|
||||||
|
"https://toronet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"http://toronet.org/rpc"
|
||||||
|
],
|
||||||
|
"faucets": [],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Toro",
|
||||||
|
"symbol": "TORO",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://toronet.org",
|
||||||
|
"shortName": "Toronet",
|
||||||
|
"chainId": 77777,
|
||||||
|
"networkId": 77777,
|
||||||
|
"ens": {
|
||||||
|
"registry": "0x1f45a71f4aAD769E27c969c4359E0e250C67165c"
|
||||||
|
},
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "toronet_explorer",
|
||||||
|
"url": "https://toronet.org/explorer",
|
||||||
|
"standard": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": false,
|
||||||
|
"slug": "toronet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "ARDENIUM Athena",
|
||||||
|
"chain": "ATHENA",
|
||||||
|
"rpc": [
|
||||||
|
"https://ardenium-athena.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://rpc-athena.ardescan.com/"
|
||||||
|
],
|
||||||
|
"faucets": [
|
||||||
|
"https://faucet-athena.ardescan.com/"
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "ARD",
|
||||||
|
"symbol": "tARD",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"infoURL": "https://ardenium.org",
|
||||||
|
"shortName": "ard",
|
||||||
|
"chainId": 7895,
|
||||||
|
"networkId": 7895,
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmdwifhejRfF8QfyzYrNdFVhfhCR6iuzWMmppK4eL7kttG",
|
||||||
|
"width": 120,
|
||||||
|
"height": 120,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "ARDENIUM Athena Explorer",
|
||||||
|
"icon": {
|
||||||
|
"url": "ipfs://QmdwifhejRfF8QfyzYrNdFVhfhCR6iuzWMmppK4eL7kttG",
|
||||||
|
"width": 120,
|
||||||
|
"height": 120,
|
||||||
|
"format": "png"
|
||||||
|
},
|
||||||
|
"url": "https://testnet.ardscan.com",
|
||||||
|
"standard": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testnet": true,
|
||||||
|
"slug": "ardenium-athena"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import type { Chain } from "../src/types";
|
||||||
|
export default {
|
||||||
|
"name": "Mode Testnet ",
|
||||||
|
"chain": "ModeTest",
|
||||||
|
"shortName": "ModeTest",
|
||||||
|
"chainId": 919,
|
||||||
|
"testnet": true,
|
||||||
|
"rpc": [
|
||||||
|
"https://mode-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||||
|
"https://sepolia.mode.network/"
|
||||||
|
],
|
||||||
|
"explorers": [
|
||||||
|
{
|
||||||
|
"name": "mode-sepolia-vtnhnpim72",
|
||||||
|
"url": "https://sepolia.explorer.mode.network/",
|
||||||
|
"standard": "EIP3091"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nativeCurrency": {
|
||||||
|
"name": "Ether",
|
||||||
|
"symbol": "ETH",
|
||||||
|
"decimals": 18
|
||||||
|
},
|
||||||
|
"icon": {
|
||||||
|
"height": 2160,
|
||||||
|
"width": 2160,
|
||||||
|
"format": "png",
|
||||||
|
"url": "ipfs://bafkreidi5y7afj5z4xrz7uz5rkg2mcsv2p2n4ui4g7q4k4ecdz65i2agou"
|
||||||
|
},
|
||||||
|
"slug": "mode-testnet"
|
||||||
|
} as const satisfies Chain;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// @ts-check
|
||||||
|
/** @typedef { import("../../src/types").Chain } Chain */
|
||||||
|
|
||||||
|
/** @type {Omit<Chain, "slug">} */
|
||||||
|
export default {
|
||||||
|
name: "ProofOfPepe Testnet",
|
||||||
|
chain: "POPTestnet",
|
||||||
|
shortName: "POPTestnet",
|
||||||
|
chainId: 331769,
|
||||||
|
testnet: true,
|
||||||
|
rpc: ["https://testnet01.proofofpepe.tech"],
|
||||||
|
nativeCurrency: {
|
||||||
|
name: "POP",
|
||||||
|
symbol: "POP",
|
||||||
|
decimals: 18,
|
||||||
|
},
|
||||||
|
explorers: [
|
||||||
|
{
|
||||||
|
name: "ProofOfPepe Explorer",
|
||||||
|
url: "https://pepescan.app/",
|
||||||
|
standard: "EIP3091",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// @ts-check
|
||||||
|
/** @typedef { import("../../src/types").Chain } Chain */
|
||||||
|
|
||||||
|
/** @type {Omit<Chain, "slug">} */
|
||||||
|
export default {
|
||||||
|
name: "Mode Testnet ",
|
||||||
|
chain: "ModeTest",
|
||||||
|
shortName: "ModeTest",
|
||||||
|
chainId: 919,
|
||||||
|
testnet: true,
|
||||||
|
rpc: ["https://sepolia.mode.network/"],
|
||||||
|
explorers: [
|
||||||
|
{
|
||||||
|
name: "mode-sepolia-vtnhnpim72",
|
||||||
|
url: "https://sepolia.explorer.mode.network/",
|
||||||
|
standard: "EIP3091",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
nativeCurrency: {
|
||||||
|
name: "Ether",
|
||||||
|
symbol: "ETH",
|
||||||
|
decimals: 18,
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
height: 2160,
|
||||||
|
width: 2160,
|
||||||
|
format: "png",
|
||||||
|
url: "ipfs://bafkreidi5y7afj5z4xrz7uz5rkg2mcsv2p2n4ui4g7q4k4ecdz65i2agou",
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// @ts-check
|
||||||
|
/** @typedef { import("../../src/types").Chain } Chain */
|
||||||
|
|
||||||
|
/** @type {Partial<Chain>} */
|
||||||
|
export default {
|
||||||
|
icon: {
|
||||||
|
url: "ipfs://QmQKHQrvtyUC5b5B76ke5GPTGXoGTVCubXS6gHgzCAswKo",
|
||||||
|
width: 250,
|
||||||
|
height: 250,
|
||||||
|
format: "png"
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// @ts-check
|
||||||
|
/** @typedef { import("../../src/types").Chain } Chain */
|
||||||
|
|
||||||
|
/** @type {Partial<Chain>} */
|
||||||
|
export default {
|
||||||
|
icon: {
|
||||||
|
url: "ipfs://QmQKHQrvtyUC5b5B76ke5GPTGXoGTVCubXS6gHgzCAswKo",
|
||||||
|
width: 250,
|
||||||
|
height: 250,
|
||||||
|
format: "png"
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// @ts-check
|
||||||
|
/** @typedef { import("../../src/types").Chain } Chain */
|
||||||
|
|
||||||
|
/** @type {Partial<Chain>} */
|
||||||
|
export default {
|
||||||
|
chainId: 59144,
|
||||||
|
rpc: [
|
||||||
|
"https://rpc.linea.build",
|
||||||
|
"https://linea-mainnet.infura.io/v3/${INFURA_API_KEY}",
|
||||||
|
],
|
||||||
|
explorers: [
|
||||||
|
{ name: "lineascan", url: "https://lineascan.build", standard: "EIP3091" },
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/chains",
|
"name": "@thirdweb-dev/chains",
|
||||||
"version": "0.1.34",
|
"version": "0.1.36",
|
||||||
"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": {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -69,6 +69,64 @@ export function getChainRPCs(
|
|||||||
return processedRPCs;
|
return processedRPCs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the list of RPC URLs given a specific chain config. Format any RPC URLs
|
||||||
|
* with necessary clientId/secretKey and returns the first valid one.
|
||||||
|
*
|
||||||
|
* @param chain - The chain config to assemble RPC URLs from
|
||||||
|
* @param clientId - The client id to use for the RPC URL
|
||||||
|
* @param secretKey - The secret key to use for the RPC URL
|
||||||
|
* @returns The first valid RPC URL for the chain
|
||||||
|
*/
|
||||||
|
export function getValidChainRPCs(
|
||||||
|
chain: Pick<Chain, "rpc" | "chainId">,
|
||||||
|
clientId?: string,
|
||||||
|
mode: "http" | "ws" = "http",
|
||||||
|
): string[] {
|
||||||
|
const processedRPCs: string[] = [];
|
||||||
|
|
||||||
|
chain.rpc.forEach((rpc) => {
|
||||||
|
// exclude RPC if mode mismatch
|
||||||
|
if (mode === "http" && !rpc.startsWith("http")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode === "ws" && !rpc.startsWith("ws")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace API_KEY placeholder with value
|
||||||
|
if (rpc.includes("${THIRDWEB_API_KEY}")) {
|
||||||
|
if (clientId) {
|
||||||
|
processedRPCs.push(rpc.replace("${THIRDWEB_API_KEY}", clientId));
|
||||||
|
} else {
|
||||||
|
// if no client id, let it through with empty string
|
||||||
|
// if secretKey is present, it will be used in header
|
||||||
|
// if none are passed, will have reduced access
|
||||||
|
processedRPCs.push(rpc.replace("${THIRDWEB_API_KEY}", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// exclude RPCs with unknown placeholder
|
||||||
|
else if (rpc.includes("${")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add as is
|
||||||
|
else {
|
||||||
|
processedRPCs.push(rpc);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (processedRPCs.length === 0) {
|
||||||
|
throw new Error(
|
||||||
|
`No RPC available for chainId "${chain.chainId}" with mode ${mode}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return processedRPCs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the highest priority RPC URL for a specific chain
|
* Get the highest priority RPC URL for a specific chain
|
||||||
*
|
*
|
||||||
@@ -118,3 +176,18 @@ export function configureChain(
|
|||||||
// prepend additional RPCs to the chain's RPCs
|
// prepend additional RPCs to the chain's RPCs
|
||||||
return { ...chain, rpc: [...additionalRPCs, ...chain.rpc] };
|
return { ...chain, rpc: [...additionalRPCs, ...chain.rpc] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* use the clientId and return a new chain object with updated RPCs
|
||||||
|
*/
|
||||||
|
export function updateChainRPCs(chain: Chain, clientId?: string) {
|
||||||
|
try {
|
||||||
|
return {
|
||||||
|
...chain,
|
||||||
|
rpc: getValidChainRPCs(chain, clientId),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return chain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,49 @@
|
|||||||
# thirdweb
|
# thirdweb
|
||||||
|
|
||||||
|
## 0.11.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`02ab92cc`](https://github.com/thirdweb-dev/js/commit/02ab92cc5c97f475e3b5642e5a7bdbe63ca136ee), [`6cc4b8d2`](https://github.com/thirdweb-dev/js/commit/6cc4b8d28b982c5be3e1cd17d2a9a947001d1608)]:
|
||||||
|
- @thirdweb-dev/chains@0.1.36
|
||||||
|
- @thirdweb-dev/sdk@3.10.38
|
||||||
|
|
||||||
|
## 0.11.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- [#1316](https://github.com/thirdweb-dev/js/pull/1316) [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b) Thanks [@iketw](https://github.com/iketw)! - Introducing API secret key restrictions for certain commands. Get your API secret key from [here](https://thirdweb.com/dashboard/settings/api-keys).
|
||||||
|
|
||||||
|
The following commands will require you to have logged in with your API secret key:
|
||||||
|
|
||||||
|
- `thirdweb deploy`
|
||||||
|
- `thirdweb release`
|
||||||
|
- `thirdweb publish`
|
||||||
|
- `thirdweb upload`
|
||||||
|
|
||||||
|
Implemented 2 new commands for managing your session with the CLI:
|
||||||
|
|
||||||
|
- thirdweb login
|
||||||
|
- thirdweb logout
|
||||||
|
|
||||||
|
Note: If you try to call a command that requires you to be logged in, you will be prompted to login.
|
||||||
|
|
||||||
|
Updated chains.
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`44dbf283`](https://github.com/thirdweb-dev/js/commit/44dbf283c985f3e2ecbeb1cfdf09fe1d84e26298), [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b), [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b), [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b)]:
|
||||||
|
- @thirdweb-dev/storage@1.2.0
|
||||||
|
- @thirdweb-dev/sdk@3.10.37
|
||||||
|
- @thirdweb-dev/chains@0.1.35
|
||||||
|
|
||||||
|
## 0.10.37
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`dac8fa7d`](https://github.com/thirdweb-dev/js/commit/dac8fa7d98b6952acf8d13e173099889c1d47da8)]:
|
||||||
|
- @thirdweb-dev/sdk@3.10.36
|
||||||
|
|
||||||
## 0.10.36
|
## 0.10.36
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ERROR_MESSAGES } from "../constants/constants";
|
|
||||||
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
||||||
import { copyFile } from "fs/promises";
|
import { copyFile } from "fs/promises";
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
|
import { ERROR_MESSAGES } from "../constants/constants";
|
||||||
|
|
||||||
// this creates an app, can take some time that's fine
|
// this creates an app, can take some time that's fine
|
||||||
jest.setTimeout(120_000);
|
jest.setTimeout(120_000);
|
||||||
@@ -9,6 +9,14 @@ jest.setTimeout(120_000);
|
|||||||
describe("npx thirdweb deploy", () => {
|
describe("npx thirdweb deploy", () => {
|
||||||
it("should return deploy page url", async () => {
|
it("should return deploy page url", async () => {
|
||||||
const { spawn, cleanup, exists, path } = await prepareEnvironment();
|
const { spawn, cleanup, exists, path } = await prepareEnvironment();
|
||||||
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||||
|
const apiSecretKey = process.env.CLI_E2E_API_KEY as string;
|
||||||
|
|
||||||
|
if (!apiSecretKey) {
|
||||||
|
throw new Error(
|
||||||
|
"CLI_E2E_API_KEY is not set in the environment variables",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await copyFile(
|
await copyFile(
|
||||||
resolve("./e2e/files/BasicContract.sol"),
|
resolve("./e2e/files/BasicContract.sol"),
|
||||||
@@ -16,7 +24,10 @@ describe("npx thirdweb deploy", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { waitForText, waitForFinish, getExitCode, writeText, getStderr } =
|
const { waitForText, waitForFinish, getExitCode, writeText, getStderr } =
|
||||||
await spawn("node", "./dist/cli/index.js deploy --contract");
|
await spawn(
|
||||||
|
"node",
|
||||||
|
`./dist/cli/index.js deploy --contract -k ${apiSecretKey}`,
|
||||||
|
);
|
||||||
|
|
||||||
expect(await exists("BasicContract.sol")).toEqual(true);
|
expect(await exists("BasicContract.sol")).toEqual(true);
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
import { ERROR_MESSAGES } from "../constants/constants";
|
|
||||||
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
|
||||||
import { copyFile } from "fs/promises";
|
import { copyFile } from "fs/promises";
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
|
import { ERROR_MESSAGES } from "../constants/constants";
|
||||||
|
|
||||||
// this creates an app, can take some time that's fine
|
// this creates an app, can take some time that's fine
|
||||||
jest.setTimeout(120_000);
|
jest.setTimeout(120_000);
|
||||||
|
|
||||||
describe("npx thirdweb publish", () => {
|
describe("npx thirdweb publish", () => {
|
||||||
it("should return publish page url", async () => {
|
// TOOD: turn this test back on when we figure out why it's failing
|
||||||
|
it.skip("should return publish page url", async () => {
|
||||||
const { spawn, cleanup, exists, path } = await prepareEnvironment();
|
const { spawn, cleanup, exists, path } = await prepareEnvironment();
|
||||||
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||||
|
const apiSecretKey = process.env.CLI_E2E_API_KEY as string;
|
||||||
|
|
||||||
|
if (!apiSecretKey) {
|
||||||
|
throw new Error(
|
||||||
|
"CLI_E2E_API_KEY is not set in the environment variables",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await copyFile(
|
await copyFile(
|
||||||
resolve("./e2e/files/BasicContract.sol"),
|
resolve("./e2e/files/BasicContract.sol"),
|
||||||
@@ -16,7 +25,7 @@ describe("npx thirdweb publish", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { waitForText, waitForFinish, getExitCode, writeText, getStderr } =
|
const { waitForText, waitForFinish, getExitCode, writeText, getStderr } =
|
||||||
await spawn("node", "./dist/cli/index.js publish");
|
await spawn("node", `./dist/cli/index.js publish -k ${apiSecretKey}}`);
|
||||||
|
|
||||||
expect(await exists("BasicContract.sol")).toEqual(true);
|
expect(await exists("BasicContract.sol")).toEqual(true);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "thirdweb",
|
"name": "thirdweb",
|
||||||
"main": "dist/cli/index.js",
|
"main": "dist/cli/index.js",
|
||||||
"version": "0.10.36",
|
"version": "0.11.1",
|
||||||
"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",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"hardhat": "^2.16.1",
|
"hardhat": "^2.16.1",
|
||||||
"jest": "^29.4.3",
|
"jest": "^29.4.3",
|
||||||
"ora": "^6.3.1",
|
"ora": "^6.3.1",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^3.0.0",
|
||||||
"ts-jest": "^29.1.0",
|
"ts-jest": "^29.1.0",
|
||||||
"ts-node": "^10.7.0",
|
"ts-node": "^10.7.0",
|
||||||
"tsup": "^6.7.0",
|
"tsup": "^6.7.0",
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import chalk from "chalk";
|
||||||
|
import prompts from "prompts";
|
||||||
|
import Cache, { CacheEntry } from "sync-disk-cache";
|
||||||
|
import { ApiResponse } from "../lib/types";
|
||||||
|
|
||||||
|
export async function loginUser(
|
||||||
|
cache: Cache,
|
||||||
|
options?: { new: boolean },
|
||||||
|
showLogs?: boolean,
|
||||||
|
) {
|
||||||
|
const keyFound = getSession(cache);
|
||||||
|
if (keyFound && !options?.new) {
|
||||||
|
if (showLogs) {
|
||||||
|
console.log(chalk.green("You are already logged in"));
|
||||||
|
}
|
||||||
|
return keyFound;
|
||||||
|
} else {
|
||||||
|
const apiKey = await createSession(cache);
|
||||||
|
return apiKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function logoutUser(cache: Cache) {
|
||||||
|
try {
|
||||||
|
cache.remove("api-secret-key");
|
||||||
|
console.log(chalk.green("You have been logged out"));
|
||||||
|
} catch (error) {
|
||||||
|
console.log(chalk.red("Something went wrong", error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSession(cache: Cache) {
|
||||||
|
try {
|
||||||
|
const apiKey: CacheEntry = cache.get("api-secret-key");
|
||||||
|
return apiKey.value;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createSession(cache: Cache) {
|
||||||
|
try {
|
||||||
|
const response = await prompts({
|
||||||
|
type: "text",
|
||||||
|
name: "apiSecretKey",
|
||||||
|
message: `Please enter your API secret key, you can find or create it on ${chalk.blue(
|
||||||
|
"https://thirdweb.com/create-api-key",
|
||||||
|
)}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await validateKey(response.apiSecretKey);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
cache.set("api-secret-key", response.apiSecretKey);
|
||||||
|
return response.apiSecretKey;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function validateKey(apiSecretKey: string) {
|
||||||
|
const fetch = (await import("node-fetch")).default;
|
||||||
|
// TODO: CHANGE THIS TO PROD BEFORE MERGING!!!
|
||||||
|
const response = await fetch(
|
||||||
|
`https://api.thirdweb.com/v1/keys/use?scope=storage`,
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"x-secret-key": apiSecretKey,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const apiResponse = (await response.json()) as ApiResponse;
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const { error } = apiResponse;
|
||||||
|
throw new Error(chalk.red(error.message));
|
||||||
|
} else {
|
||||||
|
return apiSecretKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,30 +1,34 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { detectExtensions } from "../common/feature-detector";
|
|
||||||
import { detectProject } from "../common/project-detector";
|
|
||||||
import { processProject } from "../common/processor";
|
|
||||||
import { cliVersion, pkg } from "../constants/urls";
|
|
||||||
import { info, logger, spinner } from "../core/helpers/logger";
|
|
||||||
import { CacheEntry } from "../core/types/cache";
|
|
||||||
import { twCreate } from "../create/command";
|
|
||||||
import { deploy } from "../deploy";
|
|
||||||
import { generate } from "../generate/command";
|
|
||||||
import { findPackageInstallation } from "../helpers/detect-local-packages";
|
|
||||||
import { upload } from "../storage/command";
|
|
||||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { exec, spawn } from "child_process";
|
import { exec, spawn } from "child_process";
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import open from "open";
|
import open from "open";
|
||||||
|
import os from "os";
|
||||||
|
import path from "path";
|
||||||
import prompts from "prompts";
|
import prompts from "prompts";
|
||||||
import Cache from "sync-disk-cache";
|
import Cache, { CacheEntry } from "sync-disk-cache";
|
||||||
|
import { loginUser, logoutUser, validateKey } from "../auth";
|
||||||
|
import { detectExtensions } from "../common/feature-detector";
|
||||||
|
import { processProject } from "../common/processor";
|
||||||
|
import { detectProject } from "../common/project-detector";
|
||||||
|
import { cliVersion, pkg } from "../constants/urls";
|
||||||
|
import { info, logger, spinner } from "../core/helpers/logger";
|
||||||
|
import { twCreate } from "../create/command";
|
||||||
|
import { deploy } from "../deploy";
|
||||||
|
import { generate } from "../generate/command";
|
||||||
|
import { findPackageInstallation } from "../helpers/detect-local-packages";
|
||||||
import { install } from "../install";
|
import { install } from "../install";
|
||||||
|
import { upload } from "../storage/command";
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||||
const skipIntro = process.env.THIRDWEB_CLI_SKIP_INTRO === "true";
|
const skipIntro = process.env.THIRDWEB_CLI_SKIP_INTRO === "true";
|
||||||
|
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
const cache = new Cache("thirdweb:cli");
|
const cache = new Cache("thirdweb:cli", {
|
||||||
|
location: path.join(os.homedir(), ".thirdweb", "creds"),
|
||||||
|
});
|
||||||
|
|
||||||
// yes this has to look like this, eliminates whitespace
|
// yes this has to look like this, eliminates whitespace
|
||||||
if (!skipIntro) {
|
if (!skipIntro) {
|
||||||
@@ -205,8 +209,8 @@ const main = async () => {
|
|||||||
.option("--nightly", "Install the nightly version of packages.")
|
.option("--nightly", "Install the nightly version of packages.")
|
||||||
.option("--dev", "Install the dev version of packages")
|
.option("--dev", "Install the dev version of packages")
|
||||||
.option("-d, --debug", "show debug logs")
|
.option("-d, --debug", "show debug logs")
|
||||||
.action(async (path, options) => {
|
.action(async (_path, options) => {
|
||||||
await install(path, options);
|
await install(_path, options);
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
@@ -246,8 +250,8 @@ const main = async () => {
|
|||||||
"-c, --contract-name [name]",
|
"-c, --contract-name [name]",
|
||||||
"Name of the new smart contract to create",
|
"Name of the new smart contract to create",
|
||||||
)
|
)
|
||||||
.action(async (type, path, options) => {
|
.action(async (type, _path, options) => {
|
||||||
await twCreate(type, path, options);
|
await twCreate(type, _path, options);
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
@@ -296,8 +300,17 @@ const main = async () => {
|
|||||||
"Deploy a dynamic smart contract made up of extensions to blockchains",
|
"Deploy a dynamic smart contract made up of extensions to blockchains",
|
||||||
)
|
)
|
||||||
.option("--zksync", "Deploy on ZKSync")
|
.option("--zksync", "Deploy on ZKSync")
|
||||||
|
.option("-k, --key <key>", "API key to authorize usage")
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
const url = await deploy(options);
|
let apiSecretKey = "";
|
||||||
|
// If no key is passed in, prompt the user to login. If it is passed in, use it.
|
||||||
|
if (!options.key) {
|
||||||
|
apiSecretKey = await loginUser(cache);
|
||||||
|
} else {
|
||||||
|
await validateKey(options.key);
|
||||||
|
apiSecretKey = options.key;
|
||||||
|
}
|
||||||
|
const url = await deploy(options, apiSecretKey);
|
||||||
if (url) {
|
if (url) {
|
||||||
await open(url);
|
await open(url);
|
||||||
}
|
}
|
||||||
@@ -319,11 +332,20 @@ const main = async () => {
|
|||||||
.option("--dry-run", "dry run (skip actually publishing)")
|
.option("--dry-run", "dry run (skip actually publishing)")
|
||||||
.option("-d, --debug", "show debug logs")
|
.option("-d, --debug", "show debug logs")
|
||||||
.option("--ci", "Continuous Integration mode")
|
.option("--ci", "Continuous Integration mode")
|
||||||
|
.option("-k, --key <key>", "API key to authorize usage")
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
|
let apiSecretKey = "";
|
||||||
|
// If no key is passed in, prompt the user to login. If it is passed in, use it.
|
||||||
|
if (!options.key) {
|
||||||
|
apiSecretKey = await loginUser(cache);
|
||||||
|
} else {
|
||||||
|
await validateKey(options.key);
|
||||||
|
apiSecretKey = options.key;
|
||||||
|
}
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"'release' is deprecated and will be removed in a future update. Please use 'publish' instead.",
|
"'release' is deprecated and will be removed in a future update. Please use 'publish' instead.",
|
||||||
);
|
);
|
||||||
const url = await processProject(options, "publish");
|
const url = await processProject(options, "publish", apiSecretKey);
|
||||||
info(
|
info(
|
||||||
`Open this link to publish your contracts: ${chalk.blueBright(
|
`Open this link to publish your contracts: ${chalk.blueBright(
|
||||||
url.toString(),
|
url.toString(),
|
||||||
@@ -350,8 +372,17 @@ const main = async () => {
|
|||||||
.option("--dry-run", "dry run (skip actually publishing)")
|
.option("--dry-run", "dry run (skip actually publishing)")
|
||||||
.option("-d, --debug", "show debug logs")
|
.option("-d, --debug", "show debug logs")
|
||||||
.option("--ci", "Continuous Integration mode")
|
.option("--ci", "Continuous Integration mode")
|
||||||
|
.option("-k, --key <key>", "API key to authorize usage")
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
const url = await processProject(options, "publish");
|
let apiSecretKey = "";
|
||||||
|
// If no key is passed in, prompt the user to login. If it is passed in, use it.
|
||||||
|
if (!options.key) {
|
||||||
|
apiSecretKey = await loginUser(cache);
|
||||||
|
} else {
|
||||||
|
await validateKey(options.key);
|
||||||
|
apiSecretKey = options.key;
|
||||||
|
}
|
||||||
|
const url = await processProject(options, "publish", apiSecretKey);
|
||||||
info(
|
info(
|
||||||
`Open this link to publish your contracts: ${chalk.blueBright(
|
`Open this link to publish your contracts: ${chalk.blueBright(
|
||||||
url.toString(),
|
url.toString(),
|
||||||
@@ -364,10 +395,21 @@ const main = async () => {
|
|||||||
.command("upload")
|
.command("upload")
|
||||||
.description("Upload any file or directory to decentralized storage (IPFS)")
|
.description("Upload any file or directory to decentralized storage (IPFS)")
|
||||||
.argument("[upload]", "path to file or directory to upload")
|
.argument("[upload]", "path to file or directory to upload")
|
||||||
.action(async (path) => {
|
.option("-k, --key <key>", "API key to authorize usage")
|
||||||
const storage = new ThirdwebStorage();
|
.action(async (_path, options) => {
|
||||||
|
let apiSecretKey = "";
|
||||||
|
// If no key is passed in, prompt the user to login. If it is passed in, use it.
|
||||||
|
if (!options.key) {
|
||||||
|
apiSecretKey = await loginUser(cache);
|
||||||
|
} else {
|
||||||
|
await validateKey(options.key);
|
||||||
|
apiSecretKey = options.key;
|
||||||
|
}
|
||||||
|
const storage = new ThirdwebStorage({
|
||||||
|
secretKey: apiSecretKey,
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const uri = await upload(storage, path);
|
const uri = await upload(storage, _path);
|
||||||
info(
|
info(
|
||||||
`Files stored at the following IPFS URI: ${chalk.blueBright(
|
`Files stored at the following IPFS URI: ${chalk.blueBright(
|
||||||
uri.toString(),
|
uri.toString(),
|
||||||
@@ -414,8 +456,36 @@ const main = async () => {
|
|||||||
"Preload ABIs and generate types for your smart contract to strongly type the thirdweb SDK",
|
"Preload ABIs and generate types for your smart contract to strongly type the thirdweb SDK",
|
||||||
)
|
)
|
||||||
.option("-p, --path <project-path>", "path to project", ".")
|
.option("-p, --path <project-path>", "path to project", ".")
|
||||||
|
.option("-k, --key <key>", "API key to authorize usage")
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
await generate(options);
|
let apiSecretKey = "";
|
||||||
|
// If no key is passed in, prompt the user to login. If it is passed in, use it.
|
||||||
|
if (!options.key) {
|
||||||
|
apiSecretKey = await loginUser(cache);
|
||||||
|
} else {
|
||||||
|
await validateKey(options.key);
|
||||||
|
apiSecretKey = options.key;
|
||||||
|
}
|
||||||
|
await generate(options, apiSecretKey);
|
||||||
|
});
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("login")
|
||||||
|
.description(
|
||||||
|
"Authenticate with the thirdweb CLI using your API secret key or replace an existing API secret key",
|
||||||
|
)
|
||||||
|
.option("-n, --new", "Login with a new API secret key", false)
|
||||||
|
.action(async (options) => {
|
||||||
|
await loginUser(cache, options, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("logout")
|
||||||
|
.description(
|
||||||
|
"Logout of the thirdweb CLI, effectively removing your API secret key from your machine",
|
||||||
|
)
|
||||||
|
.action(async () => {
|
||||||
|
await logoutUser(cache);
|
||||||
});
|
});
|
||||||
|
|
||||||
await program.parseAsync();
|
await program.parseAsync();
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
|
import { detectFeatures } from "@thirdweb-dev/sdk";
|
||||||
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
|
import chalk from "chalk";
|
||||||
|
import { ethers } from "ethers";
|
||||||
|
import { readFileSync, writeFileSync } from "fs";
|
||||||
|
import ora from "ora";
|
||||||
|
import path from "path";
|
||||||
import {
|
import {
|
||||||
EXTENSION_REGISTRY_ADDRESS,
|
EXTENSION_REGISTRY_ADDRESS,
|
||||||
ROUTER_CONTRACTS,
|
|
||||||
PreDeployedRouter,
|
PreDeployedRouter,
|
||||||
TWRouterParams,
|
ROUTER_CONTRACTS,
|
||||||
RouterParams,
|
RouterParams,
|
||||||
|
TWRouterParams,
|
||||||
} from "../constants/router-contracts";
|
} from "../constants/router-contracts";
|
||||||
import { cliVersion, THIRDWEB_URL } from "../constants/urls";
|
import { THIRDWEB_URL, cliVersion } from "../constants/urls";
|
||||||
import build from "../core/builder/build";
|
import build from "../core/builder/build";
|
||||||
import detect from "../core/detection/detect";
|
import detect from "../core/detection/detect";
|
||||||
import { execute } from "../core/helpers/exec";
|
import { execute } from "../core/helpers/exec";
|
||||||
@@ -17,24 +24,20 @@ import {
|
|||||||
import { ContractPayload } from "../core/interfaces/ContractPayload";
|
import { ContractPayload } from "../core/interfaces/ContractPayload";
|
||||||
import {
|
import {
|
||||||
Extension,
|
Extension,
|
||||||
|
ExtensionDeployArgs,
|
||||||
ExtensionFunction,
|
ExtensionFunction,
|
||||||
ExtensionMetadata,
|
ExtensionMetadata,
|
||||||
ExtensionDeployArgs,
|
|
||||||
} from "../core/interfaces/Extension";
|
} from "../core/interfaces/Extension";
|
||||||
import { detectFeatures } from "@thirdweb-dev/sdk";
|
|
||||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
|
||||||
import chalk from "chalk";
|
|
||||||
import { ethers } from "ethers";
|
|
||||||
import { readFileSync, writeFileSync } from "fs";
|
|
||||||
import ora from "ora";
|
|
||||||
import path from "path";
|
|
||||||
|
|
||||||
export async function processProject(
|
export async function processProject(
|
||||||
options: any,
|
options: any,
|
||||||
command: "deploy" | "publish",
|
command: "deploy" | "publish",
|
||||||
|
apiSecretKey: string,
|
||||||
) {
|
) {
|
||||||
// TODO: allow overriding the default storage
|
// TODO: allow overriding the default storage
|
||||||
const storage = new ThirdwebStorage();
|
const storage = new ThirdwebStorage({
|
||||||
|
secretKey: apiSecretKey,
|
||||||
|
});
|
||||||
|
|
||||||
logger.setSettings({
|
logger.setSettings({
|
||||||
minLevel: options.debug ? "debug" : "info",
|
minLevel: options.debug ? "debug" : "info",
|
||||||
@@ -237,6 +240,7 @@ export async function processProject(
|
|||||||
} else {
|
} else {
|
||||||
const deployArgs: RouterParams = await formatToExtensions(
|
const deployArgs: RouterParams = await formatToExtensions(
|
||||||
selectedContracts,
|
selectedContracts,
|
||||||
|
apiSecretKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
const outputDeployArgs = JSON.stringify(deployArgs, undefined, 2);
|
const outputDeployArgs = JSON.stringify(deployArgs, undefined, 2);
|
||||||
@@ -364,11 +368,16 @@ export function getUrl(hashes: string[], command: string) {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function formatToExtensions(contracts: ContractPayload[]): Promise<{
|
async function formatToExtensions(
|
||||||
|
contracts: ContractPayload[],
|
||||||
|
apiSecretKey: string,
|
||||||
|
): Promise<{
|
||||||
extensions: Extension[];
|
extensions: Extension[];
|
||||||
extensionDeployArgs: ExtensionDeployArgs[];
|
extensionDeployArgs: ExtensionDeployArgs[];
|
||||||
}> {
|
}> {
|
||||||
const storage = new ThirdwebStorage();
|
const storage = new ThirdwebStorage({
|
||||||
|
secretKey: apiSecretKey,
|
||||||
|
});
|
||||||
const extensions: Extension[] = [];
|
const extensions: Extension[] = [];
|
||||||
const extensionDeployArgs: ExtensionDeployArgs[] = [];
|
const extensionDeployArgs: ExtensionDeployArgs[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import detectLibrary from "../core/detection/detectLibrary";
|
|||||||
import detectLanguage from "../core/detection/detectLanguage";
|
import detectLanguage from "../core/detection/detectLanguage";
|
||||||
import { logger, spinner } from "../core/helpers/logger";
|
import { logger, spinner } from "../core/helpers/logger";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { ContractLibrariesType, contractLibraries } from "../core/types/ProjectType";
|
import {
|
||||||
|
ContractLibrariesType,
|
||||||
|
contractLibraries,
|
||||||
|
} from "../core/types/ProjectType";
|
||||||
import { FeatureWithEnabled, detectFeatures } from "@thirdweb-dev/sdk";
|
import { FeatureWithEnabled, detectFeatures } from "@thirdweb-dev/sdk";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import ora from "ora";
|
import ora from "ora";
|
||||||
@@ -48,8 +51,16 @@ export async function detectProject(options: any) {
|
|||||||
options,
|
options,
|
||||||
detectedPackageManager,
|
detectedPackageManager,
|
||||||
);
|
);
|
||||||
const detectedAppType = detectedFramework !== "none" ? contractLibraries.includes(detectedFramework as ContractLibrariesType) ? "contract" : "app" : "app";
|
const detectedAppType =
|
||||||
const detectedContractLibrary = detectedAppType === "contract" ? detectedFramework as ContractLibrariesType : "none";
|
detectedFramework !== "none"
|
||||||
|
? contractLibraries.includes(detectedFramework as ContractLibrariesType)
|
||||||
|
? "contract"
|
||||||
|
: "app"
|
||||||
|
: "app";
|
||||||
|
const detectedContractLibrary =
|
||||||
|
detectedAppType === "contract"
|
||||||
|
? (detectedFramework as ContractLibrariesType)
|
||||||
|
: "none";
|
||||||
|
|
||||||
logger.info("Detected package manager: " + detectedPackageManager);
|
logger.info("Detected package manager: " + detectedPackageManager);
|
||||||
logger.info("Detected library: " + detectedLibrary);
|
logger.info("Detected library: " + detectedLibrary);
|
||||||
@@ -61,7 +72,11 @@ export async function detectProject(options: any) {
|
|||||||
let compiledResult;
|
let compiledResult;
|
||||||
const compileLoader = spinner("Compiling project...");
|
const compileLoader = spinner("Compiling project...");
|
||||||
try {
|
try {
|
||||||
compiledResult = await build(projectPath, detectedContractLibrary, options);
|
compiledResult = await build(
|
||||||
|
projectPath,
|
||||||
|
detectedContractLibrary,
|
||||||
|
options,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
compileLoader.fail("Compilation failed");
|
compileLoader.fail("Compilation failed");
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
@@ -127,7 +142,9 @@ export async function detectProject(options: any) {
|
|||||||
).stopAndPersist({ symbol: "🔎" });
|
).stopAndPersist({ symbol: "🔎" });
|
||||||
} else {
|
} else {
|
||||||
ora(
|
ora(
|
||||||
`Detected extension on ${chalk.blueBright(contractWithFeatures.name)}`,
|
`Detected extension on ${chalk.blueBright(
|
||||||
|
contractWithFeatures.name,
|
||||||
|
)}`,
|
||||||
).stopAndPersist({ symbol: "🔎" });
|
).stopAndPersist({ symbol: "🔎" });
|
||||||
contractWithFeatures.enabledFeatures.map((feature) => {
|
contractWithFeatures.enabledFeatures.map((feature) => {
|
||||||
logger.info(`✔️ ${chalk.green(feature.name)}`);
|
logger.info(`✔️ ${chalk.green(feature.name)}`);
|
||||||
|
|||||||
@@ -16,11 +16,14 @@ export class SolcBuilder extends BaseBuilder {
|
|||||||
const inputPaths: string[] = [];
|
const inputPaths: string[] = [];
|
||||||
findFiles(options.projectPath, /^.*\.sol$/, inputPaths);
|
findFiles(options.projectPath, /^.*\.sol$/, inputPaths);
|
||||||
|
|
||||||
const sources = inputPaths.reduce((acc, curr) => {
|
const sources = inputPaths.reduce(
|
||||||
const source = readFileSync(curr, "utf-8");
|
(acc, curr) => {
|
||||||
acc[basename(curr)] = { content: source };
|
const source = readFileSync(curr, "utf-8");
|
||||||
return acc;
|
acc[basename(curr)] = { content: source };
|
||||||
}, {} as Record<string, { content: string }>);
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, { content: string }>,
|
||||||
|
);
|
||||||
|
|
||||||
const input = {
|
const input = {
|
||||||
language: "Solidity",
|
language: "Solidity",
|
||||||
|
|||||||
@@ -67,7 +67,10 @@ export default async function detect(
|
|||||||
return possibleFrameworks[0];
|
return possibleFrameworks[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (possibleFrameworks.includes("expo") && possibleFrameworks.includes("react-native-cli")) {
|
if (
|
||||||
|
possibleFrameworks.includes("expo") &&
|
||||||
|
possibleFrameworks.includes("react-native-cli")
|
||||||
|
) {
|
||||||
return "expo";
|
return "expo";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ export default async function detect(
|
|||||||
return possibleLanguages[0];
|
return possibleLanguages[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (possibleLanguages.includes("typescript") && possibleLanguages.includes("javascript")) {
|
if (
|
||||||
|
possibleLanguages.includes("typescript") &&
|
||||||
|
possibleLanguages.includes("javascript")
|
||||||
|
) {
|
||||||
return "typescript";
|
return "typescript";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ export default async function detect(
|
|||||||
return possibleLibraries[0];
|
return possibleLibraries[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (possibleLibraries.includes("react-native") && possibleLibraries.includes("react")) {
|
if (
|
||||||
|
possibleLibraries.includes("react-native") &&
|
||||||
|
possibleLibraries.includes("react")
|
||||||
|
) {
|
||||||
return "react-native";
|
return "react-native";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ export default async function detect(
|
|||||||
return possiblePackageManagers[0];
|
return possiblePackageManagers[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (possiblePackageManagers.includes("brownie") && possiblePackageManagers.includes("pip")) {
|
if (
|
||||||
|
possiblePackageManagers.includes("brownie") &&
|
||||||
|
possiblePackageManagers.includes("pip")
|
||||||
|
) {
|
||||||
return "brownie";
|
return "brownie";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,13 +21,15 @@ export default class BrownieDetector implements FrameworkDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const additionalDirectoriesToCheck = ["/build", "/contracts", "/reports"];
|
const additionalDirectoriesToCheck = ["/build", "/contracts", "/reports"];
|
||||||
const additionalDirectoriesExist = additionalDirectoriesToCheck.every((dir) => {
|
const additionalDirectoriesExist = additionalDirectoriesToCheck.every(
|
||||||
return existsSync(path + dir);
|
(dir) => {
|
||||||
});
|
return existsSync(path + dir);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!!dependencies.find(dep => dep.includes("brownie")) ||
|
!!dependencies.find((dep) => dep.includes("brownie")) ||
|
||||||
!!devDependencies.find(dep => dep.includes("brownie")) ||
|
!!devDependencies.find((dep) => dep.includes("brownie")) ||
|
||||||
additionalFilesExist ||
|
additionalFilesExist ||
|
||||||
additionalDirectoriesExist ||
|
additionalDirectoriesExist ||
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export default class DjangoDetector implements FrameworkDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!!dependencies.find(dep => dep.includes("Django")) ||
|
!!dependencies.find((dep) => dep.includes("Django")) ||
|
||||||
!!devDependencies.find(dep => dep.includes("Django")) ||
|
!!devDependencies.find((dep) => dep.includes("Django")) ||
|
||||||
additionalFilesExist ||
|
additionalFilesExist ||
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export default class FastAPIDetector implements FrameworkDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!!dependencies.find(dep => dep.includes("fastapi")) ||
|
!!dependencies.find((dep) => dep.includes("fastapi")) ||
|
||||||
!!devDependencies.find(dep => dep.includes("fastapi")) ||
|
!!devDependencies.find((dep) => dep.includes("fastapi")) ||
|
||||||
additionalFilesExist ||
|
additionalFilesExist ||
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export default class FlaskDetector implements FrameworkDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!!dependencies.find(dep => dep.includes("Flask")) ||
|
!!dependencies.find((dep) => dep.includes("Flask")) ||
|
||||||
!!devDependencies.find(dep => dep.includes("Flask")) ||
|
!!devDependencies.find((dep) => dep.includes("Flask")) ||
|
||||||
additionalFilesExist ||
|
additionalFilesExist ||
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export default class PopulusDetector implements FrameworkDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!!dependencies.find(dep => dep === "populus") ||
|
!!dependencies.find((dep) => dep === "populus") ||
|
||||||
!!devDependencies.find(dep => dep === "populus") ||
|
!!devDependencies.find((dep) => dep === "populus") ||
|
||||||
additionalFilesExist ||
|
additionalFilesExist ||
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ export default class TruffleDetector implements FrameworkDetector {
|
|||||||
const packageJson = readFileSync(packageJsonPath);
|
const packageJson = readFileSync(packageJsonPath);
|
||||||
const { dependencies, devDependencies } = parsePackageJson(packageJson);
|
const { dependencies, devDependencies } = parsePackageJson(packageJson);
|
||||||
|
|
||||||
const additionalFilesToCheck = [
|
const additionalFilesToCheck = ["/truffle.config.js", "/truffle.js"];
|
||||||
"/truffle.config.js",
|
|
||||||
"/truffle.js",
|
|
||||||
];
|
|
||||||
const additionalFilesExist = additionalFilesToCheck.some((file) =>
|
const additionalFilesExist = additionalFilesToCheck.some((file) =>
|
||||||
existsSync(path + file),
|
existsSync(path + file),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ export default class Web3PyDetector implements LibraryDetector {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!!dependencies.find(dep => dep.includes("web3")) || !!devDependencies.find(dep => dep.includes("web3")) || false
|
!!dependencies.find((dep) => dep.includes("web3")) ||
|
||||||
|
!!devDependencies.find((dep) => dep.includes("web3")) ||
|
||||||
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ export default class BrownieDetector implements PackageManagerDetector {
|
|||||||
public packageManagerType: PackageManagerType = "brownie";
|
public packageManagerType: PackageManagerType = "brownie";
|
||||||
|
|
||||||
public matches(path: string): boolean {
|
public matches(path: string): boolean {
|
||||||
|
|
||||||
const additionalFilesToCheck = [
|
const additionalFilesToCheck = [
|
||||||
"/brownie-config.yaml",
|
"/brownie-config.yaml",
|
||||||
"/brownie-config.json",
|
"/brownie-config.json",
|
||||||
@@ -17,14 +16,12 @@ export default class BrownieDetector implements PackageManagerDetector {
|
|||||||
|
|
||||||
// Check that all of these exist.
|
// Check that all of these exist.
|
||||||
const additionalDirectoriesToCheck = ["/build", "/contracts", "/reports"];
|
const additionalDirectoriesToCheck = ["/build", "/contracts", "/reports"];
|
||||||
const additionalDirectoriesExist = additionalDirectoriesToCheck.every((dir) => {
|
const additionalDirectoriesExist = additionalDirectoriesToCheck.every(
|
||||||
return existsSync(path + dir);
|
(dir) => {
|
||||||
});
|
return existsSync(path + dir);
|
||||||
|
},
|
||||||
return (
|
|
||||||
additionalFilesExist ||
|
|
||||||
additionalDirectoriesExist ||
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return additionalFilesExist || additionalDirectoriesExist || false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ export type ContractLibrariesType =
|
|||||||
| "solc"
|
| "solc"
|
||||||
| "none";
|
| "none";
|
||||||
|
|
||||||
|
|
||||||
export const contractLibraries: readonly ContractLibrariesType[] = [
|
export const contractLibraries: readonly ContractLibrariesType[] = [
|
||||||
"brownie",
|
"brownie",
|
||||||
"foundry",
|
"foundry",
|
||||||
@@ -84,4 +83,4 @@ export const contractLibraries: readonly ContractLibrariesType[] = [
|
|||||||
"truffle",
|
"truffle",
|
||||||
"solc",
|
"solc",
|
||||||
"none",
|
"none",
|
||||||
] as const;
|
] as const;
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
export type CacheEntry = {
|
|
||||||
isCached: boolean;
|
|
||||||
key: string;
|
|
||||||
value: string;
|
|
||||||
};
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
declare module "sync-disk-cache";
|
|
||||||
declare module "solc";
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
declare module 'sync-disk-cache' {
|
||||||
|
export type CacheEntry = {
|
||||||
|
isCached: boolean;
|
||||||
|
key: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Cache {
|
||||||
|
constructor(key: string, options?: { location?: string; compression?: "gzip" | "deflate" | "deflateRaw"; });
|
||||||
|
clear(): void;
|
||||||
|
has(key: string): boolean;
|
||||||
|
get(key: string): CacheEntry;
|
||||||
|
set(key: string, value: string): string;
|
||||||
|
remove(key: string): boolean;
|
||||||
|
pathFor(key: string): string;
|
||||||
|
decompress(value: string): string;
|
||||||
|
compress(value: string): string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "solc"
|
||||||
@@ -321,7 +321,10 @@ export async function twCreate(
|
|||||||
const res = await prompts({
|
const res = await prompts({
|
||||||
type: "text",
|
type: "text",
|
||||||
name: "path",
|
name: "path",
|
||||||
message: projectType === "extension" ? CREATE_MESSAGES.extensionName : CREATE_MESSAGES.contractName,
|
message:
|
||||||
|
projectType === "extension"
|
||||||
|
? CREATE_MESSAGES.extensionName
|
||||||
|
: CREATE_MESSAGES.contractName,
|
||||||
initial: defaultName,
|
initial: defaultName,
|
||||||
validate: (name: string) => {
|
validate: (name: string) => {
|
||||||
const isValid = /(^[a-z0-9A-Z]+$)|(^[a-z0-9A-Z]+\.sol$)/.test(name);
|
const isValid = /(^[a-z0-9A-Z]+$)|(^[a-z0-9A-Z]+\.sol$)/.test(name);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export async function runCommand(
|
|||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
/**
|
/**
|
||||||
* Spawn the installation process.
|
* Spawn the installation process.
|
||||||
*/
|
*/
|
||||||
const child = spawn(command, args);
|
const child = spawn(command, args);
|
||||||
|
|
||||||
child.stdout?.on("data", (data) => {
|
child.stdout?.on("data", (data) => {
|
||||||
@@ -28,7 +28,7 @@ export async function runCommand(
|
|||||||
});
|
});
|
||||||
|
|
||||||
child.on("error", (err) => {
|
child.on("error", (err) => {
|
||||||
console.log("Spawn error", err)
|
console.log("Spawn error", err);
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on("close", (code) => {
|
child.on("close", (code) => {
|
||||||
@@ -39,4 +39,4 @@ export async function runCommand(
|
|||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,20 @@ import { logger } from "../core/helpers/logger";
|
|||||||
import { runCommand } from "../create/helpers/run-command";
|
import { runCommand } from "../create/helpers/run-command";
|
||||||
import { upload } from "../storage/command";
|
import { upload } from "../storage/command";
|
||||||
|
|
||||||
export async function deployApp(distPath = "dist", projectPath = ".") {
|
export async function deployApp(
|
||||||
const storage = new ThirdwebStorage();
|
distPath = "dist",
|
||||||
|
projectPath = ".",
|
||||||
|
apiSecretKey: string,
|
||||||
|
) {
|
||||||
|
const storage = new ThirdwebStorage({
|
||||||
|
secretKey: apiSecretKey,
|
||||||
|
});
|
||||||
const detectedPackageManager = await detectPackageManager(projectPath, {});
|
const detectedPackageManager = await detectPackageManager(projectPath, {});
|
||||||
const detectedFramework = await detectFramework(projectPath, {}, detectedPackageManager);
|
const detectedFramework = await detectFramework(
|
||||||
|
projectPath,
|
||||||
|
{},
|
||||||
|
detectedPackageManager,
|
||||||
|
);
|
||||||
|
|
||||||
if (detectedFramework === "none") {
|
if (detectedFramework === "none") {
|
||||||
throw new Error("No supported project detected");
|
throw new Error("No supported project detected");
|
||||||
@@ -60,7 +70,10 @@ export async function deployApp(distPath = "dist", projectPath = ".") {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const uri = await upload(storage, distPath);
|
const uri = await upload(storage, distPath);
|
||||||
return `${uri.replace("ipfs://", "https://ipfs-public.thirdwebcdn.com/ipfs/")}`;
|
return `${uri.replace(
|
||||||
|
"ipfs://",
|
||||||
|
"https://ipfs-public.thirdwebcdn.com/ipfs/",
|
||||||
|
)}`;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Can't upload project", err);
|
console.error("Can't upload project", err);
|
||||||
return Promise.reject("Can't upload project");
|
return Promise.reject("Can't upload project");
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
import chalk from "chalk";
|
||||||
import { processProject } from "../common/processor";
|
import { processProject } from "../common/processor";
|
||||||
import { info, logger } from "../core/helpers/logger";
|
import { info, logger } from "../core/helpers/logger";
|
||||||
import generateDashboardUrl from "../helpers/generate-dashboard-url";
|
import generateDashboardUrl from "../helpers/generate-dashboard-url";
|
||||||
import { deployApp } from "./app";
|
import { deployApp } from "./app";
|
||||||
import chalk from "chalk";
|
|
||||||
|
|
||||||
type DeployOptions = {
|
type DeployOptions = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -12,7 +12,7 @@ type DeployOptions = {
|
|||||||
distPath?: string;
|
distPath?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function deploy(options: DeployOptions) {
|
export async function deploy(options: DeployOptions, apiSecretKey: string) {
|
||||||
if (options.name) {
|
if (options.name) {
|
||||||
const url = generateDashboardUrl(options.name, options.contractVersion);
|
const url = generateDashboardUrl(options.name, options.contractVersion);
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ export async function deploy(options: DeployOptions) {
|
|||||||
|
|
||||||
if (options.app) {
|
if (options.app) {
|
||||||
try {
|
try {
|
||||||
let url = await deployApp(options.distPath, options.path);
|
let url = await deployApp(options.distPath, options.path, apiSecretKey);
|
||||||
info(`Here is the link to your app: ${chalk.blueBright(url.toString())}`);
|
info(`Here is the link to your app: ${chalk.blueBright(url.toString())}`);
|
||||||
return url.toString();
|
return url.toString();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -44,7 +44,7 @@ export async function deploy(options: DeployOptions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = await processProject(options, "deploy");
|
const url = await processProject(options, "deploy", apiSecretKey);
|
||||||
info(
|
info(
|
||||||
`Open this link to deploy your contracts: ${chalk.blueBright(
|
`Open this link to deploy your contracts: ${chalk.blueBright(
|
||||||
url.toString(),
|
url.toString(),
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { GENERATE_MESSAGES } from "../../constants/constants";
|
import { allChains } from "@thirdweb-dev/chains";
|
||||||
import {
|
import {
|
||||||
DeployedContract,
|
DeployedContract,
|
||||||
fetchContractMetadataFromAddress,
|
fetchContractMetadataFromAddress,
|
||||||
getChainProvider,
|
getChainProvider,
|
||||||
} from "@thirdweb-dev/sdk";
|
} from "@thirdweb-dev/sdk";
|
||||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
import { info } from "../core/helpers/logger";
|
|
||||||
import { allChains } from "@thirdweb-dev/chains";
|
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import prompts from "prompts";
|
|
||||||
import { findMatches } from "../common/file-helper";
|
|
||||||
import ora from "ora";
|
import ora from "ora";
|
||||||
|
import prompts from "prompts";
|
||||||
|
import { GENERATE_MESSAGES } from "../../constants/constants";
|
||||||
|
import { findMatches } from "../common/file-helper";
|
||||||
|
import { info } from "../core/helpers/logger";
|
||||||
import { GenerateOptions, ThirdwebConfig } from "./types";
|
import { GenerateOptions, ThirdwebConfig } from "./types";
|
||||||
import { CHAIN_OPTIONS, getContractsForAddresses } from "./utils";
|
import { CHAIN_OPTIONS, getContractsForAddresses } from "./utils";
|
||||||
|
|
||||||
export async function generate(options: GenerateOptions) {
|
export async function generate(options: GenerateOptions, apiSecretKey: string) {
|
||||||
let projectPath: string = options.path?.replace(/\/$/, "") || ".";
|
let projectPath: string = options.path?.replace(/\/$/, "") || ".";
|
||||||
let contracts: DeployedContract[] = [];
|
let contracts: DeployedContract[] = [];
|
||||||
|
|
||||||
@@ -96,7 +96,9 @@ export async function generate(options: GenerateOptions) {
|
|||||||
|
|
||||||
// Attempt to download the ABI for each contract
|
// Attempt to download the ABI for each contract
|
||||||
ora(`Downloading ABIs for contracts configured in 'thirdweb.json'`).info();
|
ora(`Downloading ABIs for contracts configured in 'thirdweb.json'`).info();
|
||||||
const storage = new ThirdwebStorage();
|
const storage = new ThirdwebStorage({
|
||||||
|
secretKey: apiSecretKey,
|
||||||
|
});
|
||||||
const metadata: {
|
const metadata: {
|
||||||
address: string;
|
address: string;
|
||||||
metadata: Awaited<ReturnType<typeof fetchContractMetadataFromAddress>>;
|
metadata: Awaited<ReturnType<typeof fetchContractMetadataFromAddress>>;
|
||||||
@@ -147,10 +149,13 @@ export async function generate(options: GenerateOptions) {
|
|||||||
|
|
||||||
const file = fs.readFileSync(filePath, "utf-8");
|
const file = fs.readFileSync(filePath, "utf-8");
|
||||||
const abiRegex = /GENERATED_ABI = \{.*\};\n\n/s;
|
const abiRegex = /GENERATED_ABI = \{.*\};\n\n/s;
|
||||||
const contractAbis = metadata.reduce((acc, contract) => {
|
const contractAbis = metadata.reduce(
|
||||||
acc[contract.address] = contract.metadata.abi;
|
(acc, contract) => {
|
||||||
return acc;
|
acc[contract.address] = contract.metadata.abi;
|
||||||
}, {} as Record<string, any>);
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, any>,
|
||||||
|
);
|
||||||
const updatedAbis = JSON.stringify(contractAbis, null, 2);
|
const updatedAbis = JSON.stringify(contractAbis, null, 2);
|
||||||
const updatedFile = file.replace(
|
const updatedFile = file.replace(
|
||||||
abiRegex,
|
abiRegex,
|
||||||
@@ -169,10 +174,13 @@ export async function generate(options: GenerateOptions) {
|
|||||||
|
|
||||||
const file = fs.readFileSync(typeFilePath, "utf-8");
|
const file = fs.readFileSync(typeFilePath, "utf-8");
|
||||||
const abiRegex = /GENERATED_ABI: \{.*\}/s;
|
const abiRegex = /GENERATED_ABI: \{.*\}/s;
|
||||||
const contractAbis = metadata.reduce((acc, contract) => {
|
const contractAbis = metadata.reduce(
|
||||||
acc[contract.address] = contract.metadata.abi;
|
(acc, contract) => {
|
||||||
return acc;
|
acc[contract.address] = contract.metadata.abi;
|
||||||
}, {} as Record<string, any>);
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, any>,
|
||||||
|
);
|
||||||
const updatedAbis = JSON.stringify(contractAbis, null, 2);
|
const updatedAbis = JSON.stringify(contractAbis, null, 2);
|
||||||
const updatedFile = file.replace(abiRegex, `GENERATED_ABI: ${updatedAbis}`);
|
const updatedFile = file.replace(abiRegex, `GENERATED_ABI: ${updatedAbis}`);
|
||||||
fs.writeFileSync(typeFilePath, updatedFile);
|
fs.writeFileSync(typeFilePath, updatedFile);
|
||||||
|
|||||||
+295
-235
@@ -1,235 +1,295 @@
|
|||||||
// Import required dependencies
|
// Import required dependencies
|
||||||
import { existsSync, readFileSync } from "fs";
|
import { existsSync, readFileSync } from "fs";
|
||||||
import ora from "ora";
|
import ora from "ora";
|
||||||
import inquirer from "inquirer";
|
import inquirer from "inquirer";
|
||||||
|
|
||||||
// Import project dependencies
|
// Import project dependencies
|
||||||
import detectFramework from "../core/detection/detectFramework";
|
import detectFramework from "../core/detection/detectFramework";
|
||||||
import detectPackageManager from "../core/detection/detectPackageManager";
|
import detectPackageManager from "../core/detection/detectPackageManager";
|
||||||
import detectLibrary from "../core/detection/detectLibrary";
|
import detectLibrary from "../core/detection/detectLibrary";
|
||||||
import { ContractLibrariesType, contractLibraries } from "../core/types/ProjectType";
|
import {
|
||||||
import { checkIfBrowniePackageIsInstalled, getDependenciesForFoundry, getDependenciesForGo, getDependenciesForPython, installOrUpdate, parsePackageJson, processAppType, processContractAppType } from "../lib/utils";
|
ContractLibrariesType,
|
||||||
import { logger } from "../core/helpers/logger";
|
contractLibraries,
|
||||||
|
} from "../core/types/ProjectType";
|
||||||
// Define excluded dependencies
|
import {
|
||||||
const EXCLUDED_DEPENDENCIES = ["@thirdweb-dev/chain-icons"];
|
checkIfBrowniePackageIsInstalled,
|
||||||
|
getDependenciesForFoundry,
|
||||||
export async function install(projectPath = ".", options: any) {
|
getDependenciesForGo,
|
||||||
const debug = options.debug || false;
|
getDependenciesForPython,
|
||||||
let installer;
|
installOrUpdate,
|
||||||
let updater;
|
parsePackageJson,
|
||||||
|
processAppType,
|
||||||
// Initialize all dependencies.
|
processContractAppType,
|
||||||
let jsDependencies: { [key: string]: string } | string[] = {};
|
} from "../lib/utils";
|
||||||
let jsDevDependencies: { [key: string]: string } | string[] = {};
|
import { logger } from "../core/helpers/logger";
|
||||||
let pythonDependencies: string[] = [];
|
|
||||||
let pythonDevDependencies: string[] = [];
|
// Define excluded dependencies
|
||||||
let peerDependencies: { [key: string]: string } = {};
|
const EXCLUDED_DEPENDENCIES = ["@thirdweb-dev/chain-icons"];
|
||||||
let goDependencies: { name: string; version: string }[] = [];
|
|
||||||
const thirdwebDepsToInstall = new Set<string>();
|
export async function install(projectPath = ".", options: any) {
|
||||||
const otherDeps = new Set<string>();
|
const debug = options.debug || false;
|
||||||
|
let installer;
|
||||||
// Initialize brownie and foundry checks
|
let updater;
|
||||||
let thirdwebExistsInBrownie = { package: "", exists: false };
|
|
||||||
let thirdwebExistsInFoundry = false;
|
// Initialize all dependencies.
|
||||||
|
let jsDependencies: { [key: string]: string } | string[] = {};
|
||||||
|
let jsDevDependencies: { [key: string]: string } | string[] = {};
|
||||||
// Detect the package manager, and framework used in the project
|
let pythonDependencies: string[] = [];
|
||||||
const detectedPackageManager = await detectPackageManager(projectPath, options);
|
let pythonDevDependencies: string[] = [];
|
||||||
const detectedFramework = await detectFramework(projectPath, options, detectedPackageManager);
|
let peerDependencies: { [key: string]: string } = {};
|
||||||
const detectedLibrary = await detectLibrary(projectPath, options, detectedPackageManager);
|
let goDependencies: { name: string; version: string }[] = [];
|
||||||
|
const thirdwebDepsToInstall = new Set<string>();
|
||||||
// Determine project type
|
const otherDeps = new Set<string>();
|
||||||
const detectedAppType = detectedFramework !== "none" ? contractLibraries.includes(detectedFramework as ContractLibrariesType) ? "contract" : "app" : "app";
|
|
||||||
|
// Initialize brownie and foundry checks
|
||||||
// Identify which specific package manager is used
|
let thirdwebExistsInBrownie = { package: "", exists: false };
|
||||||
const isBrowniePackageManager = detectedPackageManager === "brownie";
|
let thirdwebExistsInFoundry = false;
|
||||||
const isFoundryPackageManager = detectedPackageManager === "foundry";
|
|
||||||
const isGoPackageManager = detectedPackageManager === "go-modules";
|
// Detect the package manager, and framework used in the project
|
||||||
const isPythonPackageManager = ["pip", "pipenv", "poetry"].includes(detectedPackageManager);
|
const detectedPackageManager = await detectPackageManager(
|
||||||
const isJSPackageManager = ["yarn", "pnpm", "npm"].includes(detectedPackageManager);
|
projectPath,
|
||||||
|
options,
|
||||||
// Processing JS/TS dependencies
|
);
|
||||||
if (isJSPackageManager) {
|
const detectedFramework = await detectFramework(
|
||||||
let packageJson;
|
projectPath,
|
||||||
const packageJsonPath = projectPath + "/package.json";
|
options,
|
||||||
|
detectedPackageManager,
|
||||||
// Check if package.json exists
|
);
|
||||||
if (!existsSync(packageJsonPath)) {
|
const detectedLibrary = await detectLibrary(
|
||||||
console.error(
|
projectPath,
|
||||||
"No package.json file found. Please run this command in the root of your project."
|
options,
|
||||||
);
|
detectedPackageManager,
|
||||||
return;
|
);
|
||||||
}
|
|
||||||
|
// Determine project type
|
||||||
// Parse package.json
|
const detectedAppType =
|
||||||
packageJson = readFileSync(packageJsonPath);
|
detectedFramework !== "none"
|
||||||
const parsedJSDeps = parsePackageJson(packageJson);
|
? contractLibraries.includes(detectedFramework as ContractLibrariesType)
|
||||||
jsDependencies = parsedJSDeps.dependencies;
|
? "contract"
|
||||||
jsDevDependencies = parsedJSDeps.devDependencies;
|
: "app"
|
||||||
peerDependencies = parsedJSDeps.peerDependencies;
|
: "app";
|
||||||
}
|
|
||||||
|
// Identify which specific package manager is used
|
||||||
// Processing Python dependencies
|
const isBrowniePackageManager = detectedPackageManager === "brownie";
|
||||||
if (isPythonPackageManager) {
|
const isFoundryPackageManager = detectedPackageManager === "foundry";
|
||||||
const pythonDeps = getDependenciesForPython(projectPath, detectedPackageManager);
|
const isGoPackageManager = detectedPackageManager === "go-modules";
|
||||||
pythonDependencies = pythonDeps.dependencies;
|
const isPythonPackageManager = ["pip", "pipenv", "poetry"].includes(
|
||||||
pythonDevDependencies = pythonDeps.devDependencies;
|
detectedPackageManager,
|
||||||
}
|
);
|
||||||
|
const isJSPackageManager = ["yarn", "pnpm", "npm"].includes(
|
||||||
// Processing Brownie dependencies
|
detectedPackageManager,
|
||||||
if (isBrowniePackageManager) {
|
);
|
||||||
const regex = /\s*thirdweb-dev\/contracts@\d+\.\d+\.\d+/g;
|
|
||||||
const res = await checkIfBrowniePackageIsInstalled(regex);
|
// Processing JS/TS dependencies
|
||||||
thirdwebExistsInBrownie = res;
|
if (isJSPackageManager) {
|
||||||
}
|
let packageJson;
|
||||||
|
const packageJsonPath = projectPath + "/package.json";
|
||||||
// Processing Foundry dependencies
|
|
||||||
if (isFoundryPackageManager) {
|
// Check if package.json exists
|
||||||
const exists = await getDependenciesForFoundry(projectPath, "thirdweb-contracts");
|
if (!existsSync(packageJsonPath)) {
|
||||||
thirdwebExistsInFoundry = exists;
|
console.error(
|
||||||
}
|
"No package.json file found. Please run this command in the root of your project.",
|
||||||
|
);
|
||||||
// Processing Go dependencies
|
return;
|
||||||
if (isGoPackageManager) {
|
}
|
||||||
const deps = getDependenciesForGo(projectPath);
|
|
||||||
goDependencies = deps;
|
// Parse package.json
|
||||||
}
|
packageJson = readFileSync(packageJsonPath);
|
||||||
|
const parsedJSDeps = parsePackageJson(packageJson);
|
||||||
const hasEthers =
|
jsDependencies = parsedJSDeps.dependencies;
|
||||||
!!jsDependencies?.ethers ||
|
jsDevDependencies = parsedJSDeps.devDependencies;
|
||||||
!!jsDevDependencies?.ethers;
|
peerDependencies = parsedJSDeps.peerDependencies;
|
||||||
|
}
|
||||||
const version = !isJSPackageManager ? "" :
|
|
||||||
options.dev
|
// Processing Python dependencies
|
||||||
? "@dev"
|
if (isPythonPackageManager) {
|
||||||
: options.nightly
|
const pythonDeps = getDependenciesForPython(
|
||||||
? "@nightly" : "";
|
projectPath,
|
||||||
|
detectedPackageManager,
|
||||||
const thirdwebDepsToUpdate = new Set<string>(
|
);
|
||||||
[
|
pythonDependencies = pythonDeps.dependencies;
|
||||||
...Object.keys(jsDependencies).filter((dep) =>
|
pythonDevDependencies = pythonDeps.devDependencies;
|
||||||
dep.startsWith("@thirdweb-dev/"),
|
}
|
||||||
),
|
|
||||||
...Object.keys(jsDevDependencies).filter((dep) =>
|
// Processing Brownie dependencies
|
||||||
dep.startsWith("@thirdweb-dev/"),
|
if (isBrowniePackageManager) {
|
||||||
),
|
const regex = /\s*thirdweb-dev\/contracts@\d+\.\d+\.\d+/g;
|
||||||
...Object.keys(peerDependencies).filter((dep) =>
|
const res = await checkIfBrowniePackageIsInstalled(regex);
|
||||||
dep.startsWith("@thirdweb-dev/"),
|
thirdwebExistsInBrownie = res;
|
||||||
),
|
}
|
||||||
...pythonDependencies
|
|
||||||
.filter((dep) => dep.startsWith("thirdweb-sdk"))
|
// Processing Foundry dependencies
|
||||||
.map((dep) => dep.split('==')[0]),
|
if (isFoundryPackageManager) {
|
||||||
...pythonDevDependencies
|
const exists = await getDependenciesForFoundry(
|
||||||
.filter((dep) => dep.startsWith("thirdweb-sdk"))
|
projectPath,
|
||||||
.map((dep) => dep.split('==')[0]),
|
"thirdweb-contracts",
|
||||||
...goDependencies
|
);
|
||||||
.filter((dep) => {
|
thirdwebExistsInFoundry = exists;
|
||||||
console.log('dep', dep)
|
}
|
||||||
return dep.name === "github.com/thirdweb-dev/go-sdk/v2"
|
|
||||||
})
|
// Processing Go dependencies
|
||||||
.map((dep) => dep.name),
|
if (isGoPackageManager) {
|
||||||
].concat(thirdwebExistsInBrownie.exists ? [thirdwebExistsInBrownie.package] : [])
|
const deps = getDependenciesForGo(projectPath);
|
||||||
.concat(thirdwebExistsInFoundry ? ["lib/thirdweb-contracts"] : [])
|
goDependencies = deps;
|
||||||
);
|
}
|
||||||
|
|
||||||
// Figure out which dependencies to install and which to update.
|
const hasEthers = !!jsDependencies?.ethers || !!jsDevDependencies?.ethers;
|
||||||
if (detectedAppType === "contract") {
|
|
||||||
processContractAppType({ detectedPackageManager, thirdwebDepsToUpdate, thirdwebDepsToInstall, isJSPackageManager })
|
const version = !isJSPackageManager
|
||||||
} else if (detectedAppType === "app") {
|
? ""
|
||||||
processAppType({
|
: options.dev
|
||||||
detectedLibrary,
|
? "@dev"
|
||||||
detectedFramework,
|
: options.nightly
|
||||||
hasEthers,
|
? "@nightly"
|
||||||
isGoPackageManager,
|
: "";
|
||||||
isJSPackageManager,
|
|
||||||
isPythonPackageManager,
|
const thirdwebDepsToUpdate = new Set<string>(
|
||||||
otherDeps,
|
[
|
||||||
thirdwebDepsToInstall,
|
...Object.keys(jsDependencies).filter((dep) =>
|
||||||
thirdwebDepsToUpdate,
|
dep.startsWith("@thirdweb-dev/"),
|
||||||
})
|
),
|
||||||
}
|
...Object.keys(jsDevDependencies).filter((dep) =>
|
||||||
|
dep.startsWith("@thirdweb-dev/"),
|
||||||
// remove exluded dependencies
|
),
|
||||||
EXCLUDED_DEPENDENCIES.forEach((excludedDep) => {
|
...Object.keys(peerDependencies).filter((dep) =>
|
||||||
thirdwebDepsToUpdate.delete(excludedDep);
|
dep.startsWith("@thirdweb-dev/"),
|
||||||
thirdwebDepsToInstall.delete(excludedDep);
|
),
|
||||||
});
|
...pythonDependencies
|
||||||
|
.filter((dep) => dep.startsWith("thirdweb-sdk"))
|
||||||
// Ask which dependencies to install
|
.map((dep) => dep.split("==")[0]),
|
||||||
if (thirdwebDepsToInstall.size !== 0) {
|
...pythonDevDependencies
|
||||||
const answer = await inquirer.prompt({
|
.filter((dep) => dep.startsWith("thirdweb-sdk"))
|
||||||
type: "checkbox",
|
.map((dep) => dep.split("==")[0]),
|
||||||
choices: [...thirdwebDepsToInstall],
|
...goDependencies
|
||||||
message: "Which thirdweb dependencies would you like to install?",
|
.filter((dep) => {
|
||||||
name: "dependencies",
|
console.log("dep", dep);
|
||||||
default: [...thirdwebDepsToInstall],
|
return dep.name === "github.com/thirdweb-dev/go-sdk/v2";
|
||||||
});
|
})
|
||||||
|
.map((dep) => dep.name),
|
||||||
if (answer.dependencies.length !== thirdwebDepsToInstall.size) {
|
]
|
||||||
thirdwebDepsToInstall.clear();
|
.concat(
|
||||||
answer.dependencies.forEach((dep: string) => thirdwebDepsToInstall.add(dep));
|
thirdwebExistsInBrownie.exists ? [thirdwebExistsInBrownie.package] : [],
|
||||||
}
|
)
|
||||||
}
|
.concat(thirdwebExistsInFoundry ? ["lib/thirdweb-contracts"] : []),
|
||||||
|
);
|
||||||
// Ask which dependencies to update
|
|
||||||
if (thirdwebDepsToUpdate.size !== 0) {
|
// Figure out which dependencies to install and which to update.
|
||||||
const answer = await inquirer.prompt({
|
if (detectedAppType === "contract") {
|
||||||
type: "checkbox",
|
processContractAppType({
|
||||||
choices: [...thirdwebDepsToUpdate],
|
detectedPackageManager,
|
||||||
message: "Which thirdweb dependencies would you like to update?",
|
thirdwebDepsToUpdate,
|
||||||
name: "dependencies",
|
thirdwebDepsToInstall,
|
||||||
default: [...thirdwebDepsToUpdate],
|
isJSPackageManager,
|
||||||
});
|
});
|
||||||
|
} else if (detectedAppType === "app") {
|
||||||
if (answer.dependencies.length !== thirdwebDepsToUpdate.size) {
|
processAppType({
|
||||||
thirdwebDepsToUpdate.clear();
|
detectedLibrary,
|
||||||
answer.dependencies.forEach((dep: string) => thirdwebDepsToUpdate.add(dep));
|
detectedFramework,
|
||||||
}
|
hasEthers,
|
||||||
}
|
isGoPackageManager,
|
||||||
|
isJSPackageManager,
|
||||||
if (thirdwebDepsToInstall.size === 0 && thirdwebDepsToUpdate.size === 0) {
|
isPythonPackageManager,
|
||||||
console.log("No thirdweb dependencies to install or update.");
|
otherDeps,
|
||||||
return;
|
thirdwebDepsToInstall,
|
||||||
}
|
thirdwebDepsToUpdate,
|
||||||
|
});
|
||||||
if (debug) {
|
}
|
||||||
logger.info("Detected package manager: " + detectedPackageManager);
|
|
||||||
logger.info("Detected library: " + detectedLibrary);
|
// remove exluded dependencies
|
||||||
logger.info("Detected framework: " + detectedFramework);
|
EXCLUDED_DEPENDENCIES.forEach((excludedDep) => {
|
||||||
logger.info("Detected app type: " + detectedAppType);
|
thirdwebDepsToUpdate.delete(excludedDep);
|
||||||
}
|
thirdwebDepsToInstall.delete(excludedDep);
|
||||||
|
});
|
||||||
try {
|
|
||||||
const dependenciesToAdd = [
|
// Ask which dependencies to install
|
||||||
...[...thirdwebDepsToInstall].map((dep) => `${dep}${version}`),
|
if (thirdwebDepsToInstall.size !== 0) {
|
||||||
...otherDeps,
|
const answer = await inquirer.prompt({
|
||||||
];
|
type: "checkbox",
|
||||||
|
choices: [...thirdwebDepsToInstall],
|
||||||
const dependenciesToUpdate = [...thirdwebDepsToUpdate].map(
|
message: "Which thirdweb dependencies would you like to install?",
|
||||||
(dep) => `${dep}${version}`,
|
name: "dependencies",
|
||||||
)
|
default: [...thirdwebDepsToInstall],
|
||||||
|
});
|
||||||
if (thirdwebDepsToInstall.size !== 0) {
|
|
||||||
installer = ora(
|
if (answer.dependencies.length !== thirdwebDepsToInstall.size) {
|
||||||
`Installing: "${[...thirdwebDepsToInstall].join('", "')}"`,
|
thirdwebDepsToInstall.clear();
|
||||||
).start();
|
answer.dependencies.forEach((dep: string) =>
|
||||||
await installOrUpdate(detectedPackageManager, dependenciesToAdd, [], "install", { oldVersion: thirdwebExistsInBrownie.package, debug });
|
thirdwebDepsToInstall.add(dep),
|
||||||
installer?.succeed(`Installed: "${dependenciesToAdd.join('", "')}"`);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (thirdwebDepsToUpdate.size !== 0) {
|
|
||||||
updater = ora(
|
// Ask which dependencies to update
|
||||||
`Updating: "${[...thirdwebDepsToUpdate].join('", "')}"`,
|
if (thirdwebDepsToUpdate.size !== 0) {
|
||||||
).start();
|
const answer = await inquirer.prompt({
|
||||||
await installOrUpdate(detectedPackageManager, [], dependenciesToUpdate, "update", {
|
type: "checkbox",
|
||||||
debug,
|
choices: [...thirdwebDepsToUpdate],
|
||||||
});
|
message: "Which thirdweb dependencies would you like to update?",
|
||||||
updater?.succeed(`Updated: "${dependenciesToUpdate.join('", "')}"`);
|
name: "dependencies",
|
||||||
}
|
default: [...thirdwebDepsToUpdate],
|
||||||
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error("Can't install within project: ", err);
|
if (answer.dependencies.length !== thirdwebDepsToUpdate.size) {
|
||||||
return Promise.reject("Can't install within project");
|
thirdwebDepsToUpdate.clear();
|
||||||
}
|
answer.dependencies.forEach((dep: string) =>
|
||||||
}
|
thirdwebDepsToUpdate.add(dep),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thirdwebDepsToInstall.size === 0 && thirdwebDepsToUpdate.size === 0) {
|
||||||
|
console.log("No thirdweb dependencies to install or update.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
logger.info("Detected package manager: " + detectedPackageManager);
|
||||||
|
logger.info("Detected library: " + detectedLibrary);
|
||||||
|
logger.info("Detected framework: " + detectedFramework);
|
||||||
|
logger.info("Detected app type: " + detectedAppType);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const dependenciesToAdd = [
|
||||||
|
...[...thirdwebDepsToInstall].map((dep) => `${dep}${version}`),
|
||||||
|
...otherDeps,
|
||||||
|
];
|
||||||
|
|
||||||
|
const dependenciesToUpdate = [...thirdwebDepsToUpdate].map(
|
||||||
|
(dep) => `${dep}${version}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (thirdwebDepsToInstall.size !== 0) {
|
||||||
|
installer = ora(
|
||||||
|
`Installing: "${[...thirdwebDepsToInstall].join('", "')}"`,
|
||||||
|
).start();
|
||||||
|
await installOrUpdate(
|
||||||
|
detectedPackageManager,
|
||||||
|
dependenciesToAdd,
|
||||||
|
[],
|
||||||
|
"install",
|
||||||
|
{ oldVersion: thirdwebExistsInBrownie.package, debug },
|
||||||
|
);
|
||||||
|
installer?.succeed(`Installed: "${dependenciesToAdd.join('", "')}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thirdwebDepsToUpdate.size !== 0) {
|
||||||
|
updater = ora(
|
||||||
|
`Updating: "${[...thirdwebDepsToUpdate].join('", "')}"`,
|
||||||
|
).start();
|
||||||
|
await installOrUpdate(
|
||||||
|
detectedPackageManager,
|
||||||
|
[],
|
||||||
|
dependenciesToUpdate,
|
||||||
|
"update",
|
||||||
|
{
|
||||||
|
debug,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
updater?.succeed(`Updated: "${dependenciesToUpdate.join('", "')}"`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Can't install within project: ", err);
|
||||||
|
return Promise.reject("Can't install within project");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import { FrameworkType, LibraryType, PackageManagerType } from "../core/types/ProjectType";
|
import {
|
||||||
|
FrameworkType,
|
||||||
|
LibraryType,
|
||||||
|
PackageManagerType,
|
||||||
|
} from "../core/types/ProjectType";
|
||||||
|
|
||||||
export type IProcessContractAppTypeArgs = {
|
export type IProcessContractAppTypeArgs = {
|
||||||
detectedPackageManager: PackageManagerType;
|
detectedPackageManager: PackageManagerType;
|
||||||
thirdwebDepsToUpdate: Set<string>;
|
thirdwebDepsToUpdate: Set<string>;
|
||||||
thirdwebDepsToInstall: Set<string>;
|
thirdwebDepsToInstall: Set<string>;
|
||||||
isJSPackageManager: boolean;
|
isJSPackageManager: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type IProcessAppTypeArgs = {
|
export type IProcessAppTypeArgs = {
|
||||||
detectedLibrary: LibraryType;
|
detectedLibrary: LibraryType;
|
||||||
@@ -17,4 +21,26 @@ export type IProcessAppTypeArgs = {
|
|||||||
isGoPackageManager: boolean;
|
isGoPackageManager: boolean;
|
||||||
hasEthers: boolean;
|
hasEthers: boolean;
|
||||||
otherDeps: Set<string>;
|
otherDeps: Set<string>;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export type ApiKey = {
|
||||||
|
id: string;
|
||||||
|
key: string;
|
||||||
|
walletAddresses: string[];
|
||||||
|
domains: string[];
|
||||||
|
services?: [
|
||||||
|
{
|
||||||
|
name: string;
|
||||||
|
targetAddresses: string[];
|
||||||
|
},
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ApiResponse = {
|
||||||
|
data: ApiKey | null;
|
||||||
|
error: {
|
||||||
|
code: string;
|
||||||
|
statusCode: number;
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
+107
-43
@@ -7,19 +7,21 @@ import { IProcessAppTypeArgs, IProcessContractAppTypeArgs } from "./types";
|
|||||||
|
|
||||||
export function convertDependenciesToStringFormat(dependenciesObject: object) {
|
export function convertDependenciesToStringFormat(dependenciesObject: object) {
|
||||||
return Object.entries(dependenciesObject).map(([pkg, versionDetails]) => {
|
return Object.entries(dependenciesObject).map(([pkg, versionDetails]) => {
|
||||||
let version = '';
|
let version = "";
|
||||||
if (typeof versionDetails === 'string') {
|
if (typeof versionDetails === "string") {
|
||||||
version = versionDetails;
|
version = versionDetails;
|
||||||
} else if (typeof versionDetails === 'object') {
|
} else if (typeof versionDetails === "object") {
|
||||||
version = versionDetails.version;
|
version = versionDetails.version;
|
||||||
}
|
}
|
||||||
// Replace '^' with nothing as '^' is not a valid version specifier in Python
|
// Replace '^' with nothing as '^' is not a valid version specifier in Python
|
||||||
version = version.replace('^', '');
|
version = version.replace("^", "");
|
||||||
return `${pkg}==${version}`;
|
return `${pkg}==${version}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const parsePackageJson = (packageJson: Buffer): {
|
export const parsePackageJson = (
|
||||||
|
packageJson: Buffer,
|
||||||
|
): {
|
||||||
dependencies: {
|
dependencies: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
@@ -55,10 +57,9 @@ export const parsePipFile = (PipFile: string) => {
|
|||||||
|
|
||||||
export const parsePyProjectToml = (pyProjectToml: string) => {
|
export const parsePyProjectToml = (pyProjectToml: string) => {
|
||||||
const pyProjectFile = toml.parse(pyProjectToml) as any;
|
const pyProjectFile = toml.parse(pyProjectToml) as any;
|
||||||
const dependencies =
|
const dependencies = pyProjectFile["tool"]["poetry"]["dependencies"] || [];
|
||||||
(pyProjectFile["tool"]["poetry"]["dependencies"]) || [];
|
|
||||||
const devDependencies =
|
const devDependencies =
|
||||||
(pyProjectFile["tool"]["poetry"]["dev-dependencies"]) || [];
|
pyProjectFile["tool"]["poetry"]["dev-dependencies"] || [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dependencies: convertDependenciesToStringFormat(dependencies),
|
dependencies: convertDependenciesToStringFormat(dependencies),
|
||||||
@@ -150,20 +151,26 @@ export const getDependenciesForPython = (
|
|||||||
|
|
||||||
export const getLatestVersion = async (packageName: string): Promise<any> => {
|
export const getLatestVersion = async (packageName: string): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
const fetch = (await import('node-fetch')).default;
|
const fetch = (await import("node-fetch")).default;
|
||||||
const url = `https://registry.npmjs.org/${packageName}`
|
const url = `https://registry.npmjs.org/${packageName}`;
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
const data: any = await response.json();
|
const data: any = await response.json();
|
||||||
return data['dist-tags']['latest'];
|
return data["dist-tags"]["latest"];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to get latest version of ${packageName}:`, error);
|
console.error(`Failed to get latest version of ${packageName}:`, error);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
export const installOrUpdate = async (packageManager: PackageManagerType, dependenciesToAdd: string[], dependenciesToUpdate: string[], typeOfAction: "install" | "update", options?: { oldVersion?: string, debug?: boolean }) => {
|
export const installOrUpdate = async (
|
||||||
|
packageManager: PackageManagerType,
|
||||||
|
dependenciesToAdd: string[],
|
||||||
|
dependenciesToUpdate: string[],
|
||||||
|
typeOfAction: "install" | "update",
|
||||||
|
options?: { oldVersion?: string; debug?: boolean },
|
||||||
|
) => {
|
||||||
let runner: string = "";
|
let runner: string = "";
|
||||||
let installCommand: string[] = [];
|
let installCommand: string[] = [];
|
||||||
let updateCommand: string[] = [];
|
let updateCommand: string[] = [];
|
||||||
@@ -174,7 +181,7 @@ export const installOrUpdate = async (packageManager: PackageManagerType, depend
|
|||||||
case "npm":
|
case "npm":
|
||||||
runner = "npm";
|
runner = "npm";
|
||||||
installCommand = ["install"];
|
installCommand = ["install"];
|
||||||
updateCommand = ["install", "--legacy-peer-deps"]
|
updateCommand = ["install", "--legacy-peer-deps"];
|
||||||
break;
|
break;
|
||||||
case "yarn":
|
case "yarn":
|
||||||
runner = "yarn";
|
runner = "yarn";
|
||||||
@@ -208,9 +215,9 @@ export const installOrUpdate = async (packageManager: PackageManagerType, depend
|
|||||||
break;
|
break;
|
||||||
case "brownie":
|
case "brownie":
|
||||||
runner = "brownie";
|
runner = "brownie";
|
||||||
installCommand = ["pm", "install"]
|
installCommand = ["pm", "install"];
|
||||||
updateCommand = ["pm", "update"]
|
updateCommand = ["pm", "update"];
|
||||||
deleteCommand = ["pm", "delete"]
|
deleteCommand = ["pm", "delete"];
|
||||||
break;
|
break;
|
||||||
case "foundry":
|
case "foundry":
|
||||||
runner = "forge";
|
runner = "forge";
|
||||||
@@ -223,17 +230,25 @@ export const installOrUpdate = async (packageManager: PackageManagerType, depend
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeOfAction === "install") {
|
if (typeOfAction === "install") {
|
||||||
if (!dependenciesToAdd.length) { return; }
|
if (!dependenciesToAdd.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const commands = [...installCommand, ...dependenciesToAdd];
|
const commands = [...installCommand, ...dependenciesToAdd];
|
||||||
|
|
||||||
await runCommand(runner, commands, printLogs);
|
await runCommand(runner, commands, printLogs);
|
||||||
|
|
||||||
if (options?.oldVersion) {
|
if (options?.oldVersion) {
|
||||||
await runCommand(runner, [...deleteCommand, options.oldVersion], printLogs);
|
await runCommand(
|
||||||
|
runner,
|
||||||
|
[...deleteCommand, options.oldVersion],
|
||||||
|
printLogs,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeOfAction === "update") {
|
if (typeOfAction === "update") {
|
||||||
if (!dependenciesToUpdate.length) { return; }
|
if (!dependenciesToUpdate.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const commands = [...updateCommand, ...dependenciesToUpdate];
|
const commands = [...updateCommand, ...dependenciesToUpdate];
|
||||||
await runCommand(runner, commands, printLogs);
|
await runCommand(runner, commands, printLogs);
|
||||||
}
|
}
|
||||||
@@ -259,13 +274,16 @@ export const getDependenciesForBrownie = async () => {
|
|||||||
let deps = "";
|
let deps = "";
|
||||||
await runCommand("brownie", ["pm", "list"], true, (data) => {
|
await runCommand("brownie", ["pm", "list"], true, (data) => {
|
||||||
deps += data.toString();
|
deps += data.toString();
|
||||||
})
|
});
|
||||||
// strip out colors from output
|
// strip out colors from output
|
||||||
deps = deps.replace(/\u001b\[\d+(;\d+)*m/g, '');
|
deps = deps.replace(/\u001b\[\d+(;\d+)*m/g, "");
|
||||||
return deps;
|
return deps;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDependenciesForFoundry = async (filePath: string, libName: string) => {
|
export const getDependenciesForFoundry = async (
|
||||||
|
filePath: string,
|
||||||
|
libName: string,
|
||||||
|
) => {
|
||||||
const fullPath = path.join(filePath, "lib", libName);
|
const fullPath = path.join(filePath, "lib", libName);
|
||||||
return existsSync(fullPath);
|
return existsSync(fullPath);
|
||||||
};
|
};
|
||||||
@@ -275,15 +293,14 @@ type GoModule = {
|
|||||||
version: string;
|
version: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const getDependenciesForGo = (filePath: string): GoModule[] => {
|
export const getDependenciesForGo = (filePath: string): GoModule[] => {
|
||||||
const content = readFileSync(filePath + "/go.mod", "utf-8");
|
const content = readFileSync(filePath + "/go.mod", "utf-8");
|
||||||
const lines = content.split("\n");
|
const lines = content.split("\n");
|
||||||
const modules: GoModule[] = [];
|
const modules: GoModule[] = [];
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.includes('github.com/thirdweb-dev')) {
|
if (line.includes("github.com/thirdweb-dev")) {
|
||||||
const words = line.split(/\s+/); // split on any amount of whitespace
|
const words = line.split(/\s+/); // split on any amount of whitespace
|
||||||
const name = words[1].trim();
|
const name = words[1].trim();
|
||||||
const version = words[2];
|
const version = words[2];
|
||||||
modules.push({ name, version });
|
modules.push({ name, version });
|
||||||
@@ -291,10 +308,17 @@ export const getDependenciesForGo = (filePath: string): GoModule[] => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return modules;
|
return modules;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const processContractAppType = async (args: IProcessContractAppTypeArgs): Promise<void> => {
|
export const processContractAppType = async (
|
||||||
const { detectedPackageManager, thirdwebDepsToUpdate, thirdwebDepsToInstall, isJSPackageManager } = args;
|
args: IProcessContractAppTypeArgs,
|
||||||
|
): Promise<void> => {
|
||||||
|
const {
|
||||||
|
detectedPackageManager,
|
||||||
|
thirdwebDepsToUpdate,
|
||||||
|
thirdwebDepsToInstall,
|
||||||
|
isJSPackageManager,
|
||||||
|
} = args;
|
||||||
|
|
||||||
if (isJSPackageManager) {
|
if (isJSPackageManager) {
|
||||||
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/contracts`)) {
|
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/contracts`)) {
|
||||||
@@ -303,15 +327,29 @@ export const processContractAppType = async (args: IProcessContractAppTypeArgs):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (detectedPackageManager === "brownie") {
|
if (detectedPackageManager === "brownie") {
|
||||||
const latestThirdwebContractVersion = await getLatestVersion("@thirdweb-dev/contracts");
|
const latestThirdwebContractVersion = await getLatestVersion(
|
||||||
|
"@thirdweb-dev/contracts",
|
||||||
|
);
|
||||||
|
|
||||||
// Exit out early if the user already has the latest version of thirdweb installed.
|
// Exit out early if the user already has the latest version of thirdweb installed.
|
||||||
if (thirdwebDepsToUpdate.has(`thirdweb-dev/contracts@${latestThirdwebContractVersion}`)) {
|
if (
|
||||||
return Promise.reject("You already have the latest version of thirdweb-dev/contracts installed.");
|
thirdwebDepsToUpdate.has(
|
||||||
|
`thirdweb-dev/contracts@${latestThirdwebContractVersion}`,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return Promise.reject(
|
||||||
|
"You already have the latest version of thirdweb-dev/contracts installed.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thirdwebDepsToUpdate.has(`thirdweb-dev/contracts@${latestThirdwebContractVersion}`)) {
|
if (
|
||||||
thirdwebDepsToInstall.add(`thirdweb-dev/contracts@${latestThirdwebContractVersion}`);
|
!thirdwebDepsToUpdate.has(
|
||||||
|
`thirdweb-dev/contracts@${latestThirdwebContractVersion}`,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
thirdwebDepsToInstall.add(
|
||||||
|
`thirdweb-dev/contracts@${latestThirdwebContractVersion}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,8 +360,20 @@ export const processContractAppType = async (args: IProcessContractAppTypeArgs):
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const processAppType = async (args: IProcessAppTypeArgs): Promise<void> => {
|
export const processAppType = async (
|
||||||
const { detectedFramework, thirdwebDepsToUpdate, thirdwebDepsToInstall, hasEthers, isJSPackageManager, otherDeps, isPythonPackageManager, isGoPackageManager, detectedLibrary } = args;
|
args: IProcessAppTypeArgs,
|
||||||
|
): Promise<void> => {
|
||||||
|
const {
|
||||||
|
detectedFramework,
|
||||||
|
thirdwebDepsToUpdate,
|
||||||
|
thirdwebDepsToInstall,
|
||||||
|
hasEthers,
|
||||||
|
isJSPackageManager,
|
||||||
|
otherDeps,
|
||||||
|
isPythonPackageManager,
|
||||||
|
isGoPackageManager,
|
||||||
|
detectedLibrary,
|
||||||
|
} = args;
|
||||||
|
|
||||||
const reactlibs = [
|
const reactlibs = [
|
||||||
"react",
|
"react",
|
||||||
@@ -335,21 +385,35 @@ export const processAppType = async (args: IProcessAppTypeArgs): Promise<void> =
|
|||||||
"vue",
|
"vue",
|
||||||
"vite",
|
"vite",
|
||||||
"svelte",
|
"svelte",
|
||||||
]
|
];
|
||||||
const shouldInstallThirdwebReact = reactlibs.includes(detectedFramework as string);
|
const shouldInstallThirdwebReact = reactlibs.includes(
|
||||||
|
detectedFramework as string,
|
||||||
|
);
|
||||||
const shouldInstallThirdwebReactNative = detectedLibrary === "react-native";
|
const shouldInstallThirdwebReactNative = detectedLibrary === "react-native";
|
||||||
|
|
||||||
if (isJSPackageManager) {
|
if (isJSPackageManager) {
|
||||||
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/react`) && shouldInstallThirdwebReact) {
|
if (
|
||||||
|
!thirdwebDepsToUpdate.has(`@thirdweb-dev/react`) &&
|
||||||
|
shouldInstallThirdwebReact
|
||||||
|
) {
|
||||||
thirdwebDepsToInstall.add(`@thirdweb-dev/react`);
|
thirdwebDepsToInstall.add(`@thirdweb-dev/react`);
|
||||||
}
|
}
|
||||||
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/sdk`) && !shouldInstallThirdwebReactNative) {
|
if (
|
||||||
|
!thirdwebDepsToUpdate.has(`@thirdweb-dev/sdk`) &&
|
||||||
|
!shouldInstallThirdwebReactNative
|
||||||
|
) {
|
||||||
thirdwebDepsToInstall.add(`@thirdweb-dev/sdk`);
|
thirdwebDepsToInstall.add(`@thirdweb-dev/sdk`);
|
||||||
}
|
}
|
||||||
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/react-native`) && shouldInstallThirdwebReactNative) {
|
if (
|
||||||
|
!thirdwebDepsToUpdate.has(`@thirdweb-dev/react-native`) &&
|
||||||
|
shouldInstallThirdwebReactNative
|
||||||
|
) {
|
||||||
thirdwebDepsToInstall.add(`@thirdweb-dev/react-native`);
|
thirdwebDepsToInstall.add(`@thirdweb-dev/react-native`);
|
||||||
}
|
}
|
||||||
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/react-native-compat`) && shouldInstallThirdwebReactNative) {
|
if (
|
||||||
|
!thirdwebDepsToUpdate.has(`@thirdweb-dev/react-native-compat`) &&
|
||||||
|
shouldInstallThirdwebReactNative
|
||||||
|
) {
|
||||||
thirdwebDepsToInstall.add(`@thirdweb-dev/react-native-compat`);
|
thirdwebDepsToInstall.add(`@thirdweb-dev/react-native-compat`);
|
||||||
}
|
}
|
||||||
if (!hasEthers) {
|
if (!hasEthers) {
|
||||||
@@ -368,4 +432,4 @@ export const processAppType = async (args: IProcessAppTypeArgs): Promise<void> =
|
|||||||
thirdwebDepsToInstall.add("github.com/thirdweb-dev/go-sdk/v2");
|
thirdwebDepsToInstall.add("github.com/thirdweb-dev/go-sdk/v2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,9 +51,14 @@ export async function upload(
|
|||||||
const spin = spinner(
|
const spin = spinner(
|
||||||
"Uploading directory to IPFS. This may take a while depending on file sizes.",
|
"Uploading directory to IPFS. This may take a while depending on file sizes.",
|
||||||
);
|
);
|
||||||
const uris = await storage.uploadBatch(files);
|
try {
|
||||||
spin.succeed("Successfully uploaded directory to IPFS");
|
const uris = await storage.uploadBatch(files);
|
||||||
uri = uris[0].substring(0, uris[0].lastIndexOf("/"));
|
spin.succeed("Successfully uploaded directory to IPFS");
|
||||||
|
uri = uris[0].substring(0, uris[0].lastIndexOf("/"));
|
||||||
|
} catch (err) {
|
||||||
|
spin.fail("Failed to upload directory to IPFS.");
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
} else if (fileType.isFile()) {
|
} else if (fileType.isFile()) {
|
||||||
const fileName = path.parse(uploadPath).base;
|
const fileName = path.parse(uploadPath).base;
|
||||||
const fileData = fs.readFileSync(uploadPath);
|
const fileData = fs.readFileSync(uploadPath);
|
||||||
@@ -62,7 +67,12 @@ export async function upload(
|
|||||||
const spin = spinner(
|
const spin = spinner(
|
||||||
"Uploading file to IPFS. This may take a while depending on file sizes.",
|
"Uploading file to IPFS. This may take a while depending on file sizes.",
|
||||||
);
|
);
|
||||||
uri = await storage.upload(file, { uploadWithoutDirectory: true });
|
try {
|
||||||
|
uri = await storage.upload(file, { uploadWithoutDirectory: true });
|
||||||
|
} catch (err) {
|
||||||
|
spin.fail("Failed to upload file to IPFS.");
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
spin.succeed("Successfully uploaded file to IPFS.");
|
spin.succeed("Successfully uploaded file to IPFS.");
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject("Invalid path provided");
|
return Promise.reject("Invalid path provided");
|
||||||
|
|||||||
@@ -1,5 +1,42 @@
|
|||||||
# @thirdweb-dev/react-core
|
# @thirdweb-dev/react-core
|
||||||
|
|
||||||
|
## 3.14.18
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`02ab92cc`](https://github.com/thirdweb-dev/js/commit/02ab92cc5c97f475e3b5642e5a7bdbe63ca136ee), [`6cc4b8d2`](https://github.com/thirdweb-dev/js/commit/6cc4b8d28b982c5be3e1cd17d2a9a947001d1608)]:
|
||||||
|
- @thirdweb-dev/chains@0.1.36
|
||||||
|
- @thirdweb-dev/sdk@3.10.38
|
||||||
|
- @thirdweb-dev/wallets@1.1.1
|
||||||
|
|
||||||
|
## 3.14.17
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1316](https://github.com/thirdweb-dev/js/pull/1316) [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b) Thanks [@iketw](https://github.com/iketw)! - Adds new `clientId` prop to access thirdweb's services.
|
||||||
|
|
||||||
|
You can create a _free_ `clientId` [on the thirdweb Dashboard](https://thirdweb.com/dashboard)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
<ThirdwebProvider clientId="your-client-id" />
|
||||||
|
```
|
||||||
|
|
||||||
|
- Updated dependencies [[`44dbf283`](https://github.com/thirdweb-dev/js/commit/44dbf283c985f3e2ecbeb1cfdf09fe1d84e26298), [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b), [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b), [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b), [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
|
## 3.14.16
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1356](https://github.com/thirdweb-dev/js/pull/1356) [`7a6534d1`](https://github.com/thirdweb-dev/js/commit/7a6534d1a98cab1eb47cf88d13e2b7ec04037e42) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix useOwnedNFT enabled state
|
||||||
|
|
||||||
|
- Updated dependencies [[`dac8fa7d`](https://github.com/thirdweb-dev/js/commit/dac8fa7d98b6952acf8d13e173099889c1d47da8), [`c5761b99`](https://github.com/thirdweb-dev/js/commit/c5761b99e9797772481506e90cbfa5c35a05bd1d), [`b96a2282`](https://github.com/thirdweb-dev/js/commit/b96a2282730582b684cc96802649a96851af5220)]:
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
- @thirdweb-dev/[email protected]
|
||||||
|
|
||||||
## 3.14.15
|
## 3.14.15
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thirdweb-dev/react-core",
|
"name": "@thirdweb-dev/react-core",
|
||||||
"version": "3.14.15",
|
"version": "3.14.18",
|
||||||
"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",
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
"@types/react": "^18.2.14",
|
"@types/react": "^18.2.14",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
||||||
"@typescript-eslint/parser": "^5.60.1",
|
"@typescript-eslint/parser": "^5.60.1",
|
||||||
"eslint": "^8.43.0",
|
"eslint": "^8.45.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-config-thirdweb": "workspace:*",
|
"eslint-config-thirdweb": "workspace:*",
|
||||||
"eslint-plugin-better-tree-shaking": "0.0.3",
|
"eslint-plugin-better-tree-shaking": "0.0.3",
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"eslint-plugin-tsdoc": "^0.2.16",
|
"eslint-plugin-tsdoc": "^0.2.16",
|
||||||
"ethers": "^5.7.2",
|
"ethers": "^5.7.2",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^3.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"typescript": "^5.1.6"
|
"typescript": "^5.1.6"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export const AUTH_TOKEN_STORAGE_KEY = "auth_token_storage_key";
|
export const AUTH_TOKEN_STORAGE_KEY = "auth_token_storage_key";
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
export const DEFAULT_API_KEY =
|
|
||||||
"fb52f0ca630bdd02f0d5210d9e8e3568272ac765dd0709272918eefb29d3ac9e";
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ThirdwebAuthProvider } from "../../evm/contexts/ThirdwebAuthProvider";
|
import { ThirdwebAuthProvider } from "../../evm/contexts/ThirdwebAuthProvider";
|
||||||
import { useUpdateChainsWithApiKeys } from "../../evm/hooks/chain-hooks";
|
import { useUpdateChainsWithClientId } from "../../evm/hooks/chain-hooks";
|
||||||
import { ThirdwebSDKProvider } from "../../evm/providers/thirdweb-sdk-provider";
|
import { ThirdwebSDKProvider } from "../../evm/providers/thirdweb-sdk-provider";
|
||||||
import { ThirdwebSDKProviderProps } from "../../evm/providers/types";
|
import { ThirdwebSDKProviderProps } from "../../evm/providers/types";
|
||||||
import { WalletConfig } from "../types/wallet";
|
import { WalletConfig } from "../types/wallet";
|
||||||
@@ -106,12 +106,10 @@ export const ThirdwebProviderCore = <TChains extends Chain[]>({
|
|||||||
}, [props.supportedChains, activeChain]);
|
}, [props.supportedChains, activeChain]);
|
||||||
|
|
||||||
const [supportedChainsWithKey, activeChainIdOrObjWithKey] =
|
const [supportedChainsWithKey, activeChainIdOrObjWithKey] =
|
||||||
useUpdateChainsWithApiKeys(
|
useUpdateChainsWithClientId(
|
||||||
supportedChainsNonNull,
|
supportedChainsNonNull,
|
||||||
props.activeChain || supportedChainsNonNull[0],
|
props.activeChain || supportedChainsNonNull[0],
|
||||||
props.thirdwebApiKey,
|
props.clientId,
|
||||||
props.alchemyApiKey,
|
|
||||||
props.infuraApiKey,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const activeChainWithKey = useMemo(() => {
|
const activeChainWithKey = useMemo(() => {
|
||||||
@@ -155,6 +153,7 @@ export const ThirdwebProviderCore = <TChains extends Chain[]>({
|
|||||||
activeChain={activeChainWithKey}
|
activeChain={activeChainWithKey}
|
||||||
autoSwitch={props.autoSwitch}
|
autoSwitch={props.autoSwitch}
|
||||||
autoConnectTimeout={props.autoConnectTimeout}
|
autoConnectTimeout={props.autoConnectTimeout}
|
||||||
|
clientId={props.clientId}
|
||||||
>
|
>
|
||||||
<ThirdwebSDKProviderWrapper
|
<ThirdwebSDKProviderWrapper
|
||||||
queryClient={props.queryClient}
|
queryClient={props.queryClient}
|
||||||
@@ -163,9 +162,7 @@ export const ThirdwebProviderCore = <TChains extends Chain[]>({
|
|||||||
activeChain={activeChainWithKey}
|
activeChain={activeChainWithKey}
|
||||||
storageInterface={props.storageInterface}
|
storageInterface={props.storageInterface}
|
||||||
authConfig={props.authConfig}
|
authConfig={props.authConfig}
|
||||||
thirdwebApiKey={props.thirdwebApiKey}
|
clientId={props.clientId}
|
||||||
alchemyApiKey={props.alchemyApiKey}
|
|
||||||
infuraApiKey={props.infuraApiKey}
|
|
||||||
>
|
>
|
||||||
<ThirdwebAuthProvider value={props.authConfig}>
|
<ThirdwebAuthProvider value={props.authConfig}>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { DAppMetaData } from "../types/dAppMeta";
|
import { DAppMetaData } from "../types/dAppMeta";
|
||||||
import type { WalletConfig, WalletInstance } from "../types/wallet";
|
import type {
|
||||||
import { ThirdwebThemeContext } from "./theme-context";
|
WalletConfig,
|
||||||
|
WalletInstance,
|
||||||
|
WalletOptions,
|
||||||
|
} from "../types/wallet";
|
||||||
import { Chain } from "@thirdweb-dev/chains";
|
import { Chain } from "@thirdweb-dev/chains";
|
||||||
import {
|
import {
|
||||||
AbstractClientWallet,
|
AbstractClientWallet,
|
||||||
@@ -102,6 +105,7 @@ export function ThirdwebWalletProvider(
|
|||||||
chains: Chain[];
|
chains: Chain[];
|
||||||
autoSwitch?: boolean;
|
autoSwitch?: boolean;
|
||||||
autoConnectTimeout?: number;
|
autoConnectTimeout?: number;
|
||||||
|
clientId?: string;
|
||||||
}>,
|
}>,
|
||||||
) {
|
) {
|
||||||
const [signer, setSigner] = useState<Signer | undefined>(undefined);
|
const [signer, setSigner] = useState<Signer | undefined>(undefined);
|
||||||
@@ -130,21 +134,14 @@ export function ThirdwebWalletProvider(
|
|||||||
// if autoSwitch is enabled - enforce connection to activeChain
|
// if autoSwitch is enabled - enforce connection to activeChain
|
||||||
const chainToConnect = props.autoSwitch ? props.activeChain : undefined;
|
const chainToConnect = props.autoSwitch ? props.activeChain : undefined;
|
||||||
|
|
||||||
const theme = useContext(ThirdwebThemeContext);
|
const walletParams: WalletOptions = useMemo(() => {
|
||||||
|
|
||||||
const walletParams = useMemo(() => {
|
|
||||||
const walletChains = props.chains;
|
|
||||||
const walletOptions = {
|
|
||||||
chains: walletChains,
|
|
||||||
dappMetadata: props.dAppMeta,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...walletOptions,
|
chains: props.chains,
|
||||||
|
dappMetadata: props.dAppMeta,
|
||||||
chain: props.activeChain || props.chains[0],
|
chain: props.activeChain || props.chains[0],
|
||||||
theme: theme || "dark",
|
clientId: props.clientId,
|
||||||
};
|
};
|
||||||
}, [props.chains, props.dAppMeta, props.activeChain, theme]);
|
}, [props.chains, props.dAppMeta, props.activeChain, props.clientId]);
|
||||||
|
|
||||||
const createWalletInstance = useCallback(
|
const createWalletInstance = useCallback(
|
||||||
<I extends WalletInstance>(walletConfig: WalletConfig<I>): I => {
|
<I extends WalletInstance>(walletConfig: WalletConfig<I>): I => {
|
||||||
@@ -494,7 +491,14 @@ async function getLastConnectedWalletInfo() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.parse(str) as LastConnectedWalletInfo;
|
try {
|
||||||
|
return JSON.parse(str) as LastConnectedWalletInfo;
|
||||||
|
} catch {
|
||||||
|
await lastConnectedWalletStorage.removeItem(
|
||||||
|
LAST_CONNECTED_WALLET_STORAGE_KEY,
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveLastConnectedWalletInfo(
|
async function saveLastConnectedWalletInfo(
|
||||||
|
|||||||
@@ -1,19 +1,12 @@
|
|||||||
import type {
|
import type { AbstractClientWallet, Chain } from "@thirdweb-dev/wallets";
|
||||||
AbstractClientWallet,
|
import { WalletOptions as WalletOptions_ } from "@thirdweb-dev/wallets";
|
||||||
Chain,
|
|
||||||
DAppMetaData,
|
|
||||||
} from "@thirdweb-dev/wallets";
|
|
||||||
|
|
||||||
// these are extra options provided by the react-core package
|
// these are extra options provided by the react-core package
|
||||||
export type ExtraCoreWalletOptions = {
|
export type ExtraCoreWalletOptions = {
|
||||||
chain: Chain;
|
chain: Chain;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WalletOptions = {
|
export type WalletOptions = WalletOptions_<ExtraCoreWalletOptions>;
|
||||||
chains: Chain[];
|
|
||||||
walletId?: string;
|
|
||||||
dappMetadata?: DAppMetaData;
|
|
||||||
} & ExtraCoreWalletOptions;
|
|
||||||
|
|
||||||
export type WalletInstance = AbstractClientWallet;
|
export type WalletInstance = AbstractClientWallet;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import { getChainRPCs, ChainRPCOptions, Chain } from "@thirdweb-dev/chains";
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* use the keys and return a new chain object with updated RPCs
|
|
||||||
*/
|
|
||||||
export const updateChainRPCs = (chain: Chain, options: ChainRPCOptions) => {
|
|
||||||
try {
|
|
||||||
return {
|
|
||||||
...chain,
|
|
||||||
rpc: getChainRPCs(chain, options),
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
return chain;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -3,9 +3,7 @@ import React, { createContext, PropsWithChildren, useContext } from "react";
|
|||||||
|
|
||||||
interface ThirdwebConfigContext {
|
interface ThirdwebConfigContext {
|
||||||
chains: Chain[];
|
chains: Chain[];
|
||||||
thirdwebApiKey?: string;
|
clientId?: string;
|
||||||
alchemyApiKey?: string;
|
|
||||||
infuraApiKey?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ThirdwebConfigContext =
|
const ThirdwebConfigContext =
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
|
||||||
|
import { createContext } from "react";
|
||||||
|
|
||||||
|
export interface TWSDKContext {
|
||||||
|
sdk?: ThirdwebSDK;
|
||||||
|
_inProvider?: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ThirdwebSDKContext = /* @__PURE__ */ createContext<TWSDKContext>(
|
||||||
|
{},
|
||||||
|
);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { __DEV__ } from "../../core/constants/runtime";
|
import { __DEV__ } from "../../core/constants/runtime";
|
||||||
import { useThirdwebConfigContext } from "./thirdweb-config";
|
import { useThirdwebConfigContext } from "./thirdweb-config";
|
||||||
import { getChainRPC } from "@thirdweb-dev/chains";
|
import { getValidChainRPCs } from "@thirdweb-dev/chains";
|
||||||
import { UserWallet } from "@thirdweb-dev/sdk";
|
import { UserWallet } from "@thirdweb-dev/sdk";
|
||||||
import { Signer } from "ethers";
|
import { Signer } from "ethers";
|
||||||
import React, {
|
import React, {
|
||||||
@@ -10,6 +10,7 @@ import React, {
|
|||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
|
import { useSDK } from "../hooks/useSDK";
|
||||||
|
|
||||||
interface ThirdwebConnectedWalletContext {
|
interface ThirdwebConnectedWalletContext {
|
||||||
wallet: UserWallet | undefined;
|
wallet: UserWallet | undefined;
|
||||||
@@ -33,8 +34,8 @@ const ThirdwebConnectedWalletContext =
|
|||||||
export const ThirdwebConnectedWalletProvider: React.FC<
|
export const ThirdwebConnectedWalletProvider: React.FC<
|
||||||
PropsWithChildren<{ signer?: Signer }>
|
PropsWithChildren<{ signer?: Signer }>
|
||||||
> = ({ signer, children }) => {
|
> = ({ signer, children }) => {
|
||||||
const { chains, thirdwebApiKey, alchemyApiKey, infuraApiKey } =
|
const { chains, clientId } = useThirdwebConfigContext();
|
||||||
useThirdwebConfigContext();
|
const storage = useSDK()?.storage;
|
||||||
|
|
||||||
const [contextValue, setContextValue] =
|
const [contextValue, setContextValue] =
|
||||||
useState<ThirdwebConnectedWalletContext>({
|
useState<ThirdwebConnectedWalletContext>({
|
||||||
@@ -50,6 +51,10 @@ export const ThirdwebConnectedWalletProvider: React.FC<
|
|||||||
}, [signer]);
|
}, [signer]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!storage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let s = signer;
|
let s = signer;
|
||||||
if (signer) {
|
if (signer) {
|
||||||
// just get both of these up front and keep them around with the context
|
// just get both of these up front and keep them around with the context
|
||||||
@@ -59,11 +64,7 @@ export const ThirdwebConnectedWalletProvider: React.FC<
|
|||||||
let rpcUrl = undefined;
|
let rpcUrl = undefined;
|
||||||
if (chain) {
|
if (chain) {
|
||||||
try {
|
try {
|
||||||
rpcUrl = getChainRPC(chain, {
|
rpcUrl = getValidChainRPCs(chain, clientId)[0];
|
||||||
thirdwebApiKey,
|
|
||||||
alchemyApiKey,
|
|
||||||
infuraApiKey,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// failed to get a viable rpc url, nothing we can do
|
// failed to get a viable rpc url, nothing we can do
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -72,14 +73,18 @@ export const ThirdwebConnectedWalletProvider: React.FC<
|
|||||||
|
|
||||||
// only if the signer is still the same!
|
// only if the signer is still the same!
|
||||||
if (signer === s) {
|
if (signer === s) {
|
||||||
const wallet = new UserWallet(signer, {
|
const wallet = new UserWallet(
|
||||||
readonlySettings: rpcUrl
|
signer,
|
||||||
? {
|
{
|
||||||
rpcUrl,
|
readonlySettings: rpcUrl
|
||||||
chainId,
|
? {
|
||||||
}
|
rpcUrl,
|
||||||
: undefined,
|
chainId,
|
||||||
});
|
}
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
|
storage,
|
||||||
|
);
|
||||||
setContextValue({ wallet, address, chainId, signer });
|
setContextValue({ wallet, address, chainId, signer });
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -100,7 +105,7 @@ export const ThirdwebConnectedWalletProvider: React.FC<
|
|||||||
s = undefined;
|
s = undefined;
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [signer, thirdwebApiKey, alchemyApiKey, infuraApiKey]);
|
}, [signer, clientId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThirdwebConnectedWalletContext.Provider value={contextValue}>
|
<ThirdwebConnectedWalletContext.Provider value={contextValue}>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
RequiredParam,
|
RequiredParam,
|
||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import { WalletAddress } from "../../types";
|
import { WalletAddress } from "../../types";
|
||||||
import {
|
import {
|
||||||
cacheKeys,
|
cacheKeys,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
RequiredParam,
|
RequiredParam,
|
||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import {
|
import {
|
||||||
cacheKeys,
|
cacheKeys,
|
||||||
invalidateContractAndBalances,
|
invalidateContractAndBalances,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
RequiredParam,
|
RequiredParam,
|
||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import {
|
import {
|
||||||
cacheKeys,
|
cacheKeys,
|
||||||
invalidateContractAndBalances,
|
invalidateContractAndBalances,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
RequiredParam,
|
RequiredParam,
|
||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDK, useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDK, useSDKChainId } from "../useSDK";
|
||||||
import { getErcs, DropContract, WalletAddress } from "../../types";
|
import { getErcs, DropContract, WalletAddress } from "../../types";
|
||||||
import {
|
import {
|
||||||
cacheKeys,
|
cacheKeys,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
RequiredParam,
|
RequiredParam,
|
||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import { WalletAddress } from "../../types";
|
import { WalletAddress } from "../../types";
|
||||||
import {
|
import {
|
||||||
cacheKeys,
|
cacheKeys,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
RequiredParam,
|
RequiredParam,
|
||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDK, useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDK, useSDKChainId } from "../useSDK";
|
||||||
import { ContractAddress } from "../../types";
|
import { ContractAddress } from "../../types";
|
||||||
import {
|
import {
|
||||||
cacheKeys,
|
cacheKeys,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
RequiredParam,
|
RequiredParam,
|
||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import {
|
import {
|
||||||
ClaimNFTParams,
|
ClaimNFTParams,
|
||||||
ClaimNFTReturnType,
|
ClaimNFTReturnType,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
RequiredParam,
|
RequiredParam,
|
||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import {
|
import {
|
||||||
AcceptDirectOffer,
|
AcceptDirectOffer,
|
||||||
BuyFromListingParams,
|
BuyFromListingParams,
|
||||||
@@ -596,7 +596,10 @@ export function useBidBuffer(
|
|||||||
) {
|
) {
|
||||||
const contractAddress = contract?.getAddress();
|
const contractAddress = contract?.getAddress();
|
||||||
return useQueryWithNetwork(
|
return useQueryWithNetwork(
|
||||||
cacheKeys.contract.marketplace.auction.getBidBufferBps(contractAddress, listingId),
|
cacheKeys.contract.marketplace.auction.getBidBufferBps(
|
||||||
|
contractAddress,
|
||||||
|
listingId,
|
||||||
|
),
|
||||||
() => {
|
() => {
|
||||||
requiredParamInvariant(contract, "No Contract instance provided");
|
requiredParamInvariant(contract, "No Contract instance provided");
|
||||||
|
|
||||||
@@ -1426,13 +1429,13 @@ export function useBuyDirectListing(contract: RequiredParam<MarketplaceV3>) {
|
|||||||
requiredParamInvariant(contract, "No Contract instance provided");
|
requiredParamInvariant(contract, "No Contract instance provided");
|
||||||
invariant(
|
invariant(
|
||||||
contract.directListings.buyFromListing,
|
contract.directListings.buyFromListing,
|
||||||
"contract does not support directListings.buyFromListing"
|
"contract does not support directListings.buyFromListing",
|
||||||
);
|
);
|
||||||
|
|
||||||
return await contract.directListings.buyFromListing(
|
return await contract.directListings.buyFromListing(
|
||||||
data.listingId,
|
data.listingId,
|
||||||
data.quantity,
|
data.quantity,
|
||||||
data.buyer
|
data.buyer,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
RequiredParam,
|
RequiredParam,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import {
|
import {
|
||||||
AirdropNFTParams,
|
AirdropNFTParams,
|
||||||
BurnNFTParams,
|
BurnNFTParams,
|
||||||
@@ -256,7 +256,7 @@ export function useOwnedNFTs<TContract extends NFTContract>(
|
|||||||
invariant(false, "Unknown NFT type");
|
invariant(false, "Unknown NFT type");
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: !!erc721 || (!!erc1155 && !!ownerWalletAddress),
|
enabled: (!!erc721 || !!erc1155) && !!ownerWalletAddress,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
RequiredParam,
|
RequiredParam,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import { WalletAddress } from "../../types";
|
import { WalletAddress } from "../../types";
|
||||||
import {
|
import {
|
||||||
cacheKeys,
|
cacheKeys,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
requiredParamInvariant,
|
requiredParamInvariant,
|
||||||
RequiredParam,
|
RequiredParam,
|
||||||
} from "../../../core/query-utils/required-param";
|
} from "../../../core/query-utils/required-param";
|
||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import {
|
import {
|
||||||
ClaimTokenParams,
|
ClaimTokenParams,
|
||||||
getErc20,
|
getErc20,
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { updateChainRPCs } from "../../core/utils/updateChainRpcs";
|
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import type { Chain } from "@thirdweb-dev/chains";
|
import { updateChainRPCs, type Chain } from "@thirdweb-dev/chains";
|
||||||
|
|
||||||
export function useUpdateChainsWithApiKeys<
|
export function useUpdateChainsWithClientId<
|
||||||
TChains extends Chain[],
|
TChains extends Chain[],
|
||||||
TActiveChain extends
|
TActiveChain extends
|
||||||
| Chain
|
| Chain
|
||||||
@@ -11,22 +10,11 @@ export function useUpdateChainsWithApiKeys<
|
|||||||
>(
|
>(
|
||||||
supportedChains: NonNullable<TChains>,
|
supportedChains: NonNullable<TChains>,
|
||||||
activeChain: TActiveChain,
|
activeChain: TActiveChain,
|
||||||
thirdwebApiKey?: string,
|
clientId?: string,
|
||||||
alchemyApiKey?: string,
|
|
||||||
infuraApiKey?: string,
|
|
||||||
) {
|
) {
|
||||||
const keys = useMemo(
|
|
||||||
() => ({
|
|
||||||
thirdwebApiKey: thirdwebApiKey,
|
|
||||||
alchemyApiKey: alchemyApiKey,
|
|
||||||
infuraApiKey: infuraApiKey,
|
|
||||||
}),
|
|
||||||
[thirdwebApiKey, alchemyApiKey, infuraApiKey],
|
|
||||||
);
|
|
||||||
|
|
||||||
const supportedChainsWithKey = useMemo(() => {
|
const supportedChainsWithKey = useMemo(() => {
|
||||||
return supportedChains.map((chain) => updateChainRPCs(chain, keys));
|
return supportedChains.map((chain) => updateChainRPCs(chain, clientId));
|
||||||
}, [supportedChains, keys]);
|
}, [supportedChains, clientId]);
|
||||||
|
|
||||||
const activeChainIdOrObjWithKey = useMemo(() => {
|
const activeChainIdOrObjWithKey = useMemo(() => {
|
||||||
if (
|
if (
|
||||||
@@ -37,8 +25,8 @@ export function useUpdateChainsWithApiKeys<
|
|||||||
return activeChain;
|
return activeChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateChainRPCs(activeChain, keys);
|
return updateChainRPCs(activeChain, clientId);
|
||||||
}, [activeChain, keys]);
|
}, [activeChain, clientId]);
|
||||||
|
|
||||||
return [supportedChainsWithKey, activeChainIdOrObjWithKey] as const;
|
return [supportedChainsWithKey, activeChainIdOrObjWithKey] as const;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useSDKChainId } from "../../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "../useSDK";
|
||||||
import { createCacheKeyWithNetwork } from "../../utils/cache-keys";
|
import { createCacheKeyWithNetwork } from "../../utils/cache-keys";
|
||||||
import {
|
import {
|
||||||
QueryFunction,
|
QueryFunction,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useSDK } from "../../providers/thirdweb-sdk-provider";
|
import { useSDK } from "../useSDK";
|
||||||
|
|
||||||
export { useStorageUpload } from "./useStorageUpload";
|
export { useStorageUpload } from "./useStorageUpload";
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useSDK } from "../../providers/thirdweb-sdk-provider";
|
import { useSDK } from "../useSDK";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { IpfsUploadBatchOptions, UploadOptions } from "@thirdweb-dev/storage";
|
import { IpfsUploadBatchOptions, UploadOptions } from "@thirdweb-dev/storage";
|
||||||
import invariant from "tiny-invariant";
|
import invariant from "tiny-invariant";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useSDKChainId } from "../providers/thirdweb-sdk-provider";
|
import { useSDKChainId } from "./useSDK";
|
||||||
import { useChainId } from "./wallet";
|
import { useChainId } from "./wallet";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
|
||||||
|
import { useContext } from "react";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
import { TWSDKContext, ThirdwebSDKContext } from "../contexts/thirdweb-sdk";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export function useSDKContext(): TWSDKContext {
|
||||||
|
const ctx = useContext(ThirdwebSDKContext);
|
||||||
|
invariant(
|
||||||
|
ctx._inProvider,
|
||||||
|
"useSDK must be called from within a ThirdwebProvider, did you forget to wrap your app in a <ThirdwebProvider />?",
|
||||||
|
);
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {@link ThirdwebSDK}
|
||||||
|
* Access the instance of the thirdweb SDK created by the ThirdwebProvider
|
||||||
|
* to call methods using the connected wallet on the desiredChainId.
|
||||||
|
* @example
|
||||||
|
* ```javascript
|
||||||
|
* const sdk = useSDK();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export function useSDK(): ThirdwebSDK | undefined {
|
||||||
|
const { sdk } = useSDKContext();
|
||||||
|
return sdk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export function useSDKChainId(): number | undefined {
|
||||||
|
const sdk = useSDK();
|
||||||
|
return (sdk as any)?._chainId;
|
||||||
|
}
|
||||||
@@ -242,11 +242,8 @@ export { useSupportedWallet } from "./hooks/useSupportedWallet";
|
|||||||
export { useAppURI, useSetAppURI } from "./hooks/async/app";
|
export { useAppURI, useSetAppURI } from "./hooks/async/app";
|
||||||
|
|
||||||
// sdk provider
|
// sdk provider
|
||||||
export {
|
export { ThirdwebSDKProvider } from "./providers/thirdweb-sdk-provider";
|
||||||
ThirdwebSDKProvider,
|
export { useSDK, useSDKChainId } from "./hooks/useSDK";
|
||||||
useSDK,
|
|
||||||
useSDKChainId,
|
|
||||||
} from "./providers/thirdweb-sdk-provider";
|
|
||||||
export type { ThirdwebSDKProviderProps } from "./providers/types";
|
export type { ThirdwebSDKProviderProps } from "./providers/types";
|
||||||
|
|
||||||
// types
|
// types
|
||||||
|
|||||||
@@ -1,20 +1,13 @@
|
|||||||
import { DEFAULT_API_KEY } from "../../core/constants/rpc";
|
import { useMemo, useEffect } from "react";
|
||||||
import { QueryClientProviderWithDefault } from "../../core/providers/query-client";
|
import { QueryClientProviderWithDefault } from "../../core/providers/query-client";
|
||||||
import { ThirdwebConfigProvider } from "../contexts/thirdweb-config";
|
import { ThirdwebConfigProvider } from "../contexts/thirdweb-config";
|
||||||
|
import { ThirdwebSDKContext } from "../contexts/thirdweb-sdk";
|
||||||
import { ThirdwebConnectedWalletProvider } from "../contexts/thirdweb-wallet";
|
import { ThirdwebConnectedWalletProvider } from "../contexts/thirdweb-wallet";
|
||||||
import { useUpdateChainsWithApiKeys } from "../hooks/chain-hooks";
|
import { useUpdateChainsWithClientId } from "../hooks/chain-hooks";
|
||||||
import { ThirdwebSDKProviderProps } from "./types";
|
import { ThirdwebSDKProviderProps } from "./types";
|
||||||
import { Chain, defaultChains, getChainRPC } from "@thirdweb-dev/chains";
|
import { Chain, defaultChains, getValidChainRPCs } from "@thirdweb-dev/chains";
|
||||||
import { SDKOptionsOutput, ThirdwebSDK } from "@thirdweb-dev/sdk/evm";
|
import { SDKOptionsOutput, ThirdwebSDK } from "@thirdweb-dev/sdk/evm";
|
||||||
import { createContext, useContext, useEffect, useMemo } from "react";
|
import { checkClientIdOrSecretKey } from "@thirdweb-dev/sdk";
|
||||||
import invariant from "tiny-invariant";
|
|
||||||
|
|
||||||
interface TWSDKContext {
|
|
||||||
sdk?: ThirdwebSDK;
|
|
||||||
_inProvider?: true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ThirdwebSDKContext = /* @__PURE__ */ createContext<TWSDKContext>({});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -27,9 +20,7 @@ const WrappedThirdwebSDKProvider = <TChains extends Chain[]>({
|
|||||||
activeChain,
|
activeChain,
|
||||||
signer,
|
signer,
|
||||||
children,
|
children,
|
||||||
thirdwebApiKey,
|
clientId,
|
||||||
infuraApiKey,
|
|
||||||
alchemyApiKey,
|
|
||||||
}: React.PropsWithChildren<
|
}: React.PropsWithChildren<
|
||||||
{ supportedChains: Readonly<TChains> } & Omit<
|
{ supportedChains: Readonly<TChains> } & Omit<
|
||||||
ThirdwebSDKProviderProps<TChains>,
|
ThirdwebSDKProviderProps<TChains>,
|
||||||
@@ -70,11 +61,7 @@ const WrappedThirdwebSDKProvider = <TChains extends Chain[]>({
|
|||||||
|
|
||||||
if (supportedChain && supportedChain.rpc.length > 0) {
|
if (supportedChain && supportedChain.rpc.length > 0) {
|
||||||
try {
|
try {
|
||||||
const rpcUrl = getChainRPC(supportedChain, {
|
const rpcUrl = getValidChainRPCs(supportedChain, clientId)[0];
|
||||||
thirdwebApiKey,
|
|
||||||
infuraApiKey,
|
|
||||||
alchemyApiKey,
|
|
||||||
});
|
|
||||||
|
|
||||||
readonlySettings = {
|
readonlySettings = {
|
||||||
chainId: supportedChain.chainId,
|
chainId: supportedChain.chainId,
|
||||||
@@ -105,7 +92,7 @@ const WrappedThirdwebSDKProvider = <TChains extends Chain[]>({
|
|||||||
// sdk from chainId
|
// sdk from chainId
|
||||||
sdk_ = new ThirdwebSDK(
|
sdk_ = new ThirdwebSDK(
|
||||||
chainId,
|
chainId,
|
||||||
{ ...mergedOptions, infuraApiKey, alchemyApiKey, thirdwebApiKey },
|
{ ...mergedOptions, clientId },
|
||||||
storageInterface,
|
storageInterface,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -126,15 +113,7 @@ const WrappedThirdwebSDKProvider = <TChains extends Chain[]>({
|
|||||||
(sdk_ as any)._chainId = chainId;
|
(sdk_ as any)._chainId = chainId;
|
||||||
|
|
||||||
return sdk_;
|
return sdk_;
|
||||||
}, [
|
}, [activeChainId, supportedChains, sdkOptions, storageInterface, clientId]);
|
||||||
activeChainId,
|
|
||||||
alchemyApiKey,
|
|
||||||
infuraApiKey,
|
|
||||||
supportedChains,
|
|
||||||
sdkOptions,
|
|
||||||
storageInterface,
|
|
||||||
thirdwebApiKey,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// if we have an sdk and a signer update the signer
|
// if we have an sdk and a signer update the signer
|
||||||
@@ -179,21 +158,24 @@ export const ThirdwebSDKProvider = <TChains extends Chain[]>({
|
|||||||
queryClient,
|
queryClient,
|
||||||
supportedChains,
|
supportedChains,
|
||||||
activeChain,
|
activeChain,
|
||||||
thirdwebApiKey = DEFAULT_API_KEY,
|
clientId,
|
||||||
alchemyApiKey,
|
|
||||||
infuraApiKey,
|
|
||||||
...restProps
|
...restProps
|
||||||
}: React.PropsWithChildren<ThirdwebSDKProviderProps<TChains>>) => {
|
}: React.PropsWithChildren<ThirdwebSDKProviderProps<TChains>>) => {
|
||||||
|
if (!clientId) {
|
||||||
|
checkClientIdOrSecretKey(
|
||||||
|
"No clientId provided in ThirdwebSDK. You will have limited access to thirdweb's services for storage, RPC, and account abstraction. You can get a clientId from https://thirdweb.com/create-api-key",
|
||||||
|
clientId,
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
}
|
||||||
const supportedChainsNonNull = useMemo(() => {
|
const supportedChainsNonNull = useMemo(() => {
|
||||||
return supportedChains || (defaultChains as any as TChains);
|
return supportedChains || (defaultChains as any as TChains);
|
||||||
}, [supportedChains]);
|
}, [supportedChains]);
|
||||||
const [supportedChainsWithKey, activeChainIdOrObjWithKey] =
|
const [supportedChainsWithKey, activeChainIdOrObjWithKey] =
|
||||||
useUpdateChainsWithApiKeys(
|
useUpdateChainsWithClientId(
|
||||||
supportedChainsNonNull,
|
supportedChainsNonNull,
|
||||||
activeChain || supportedChainsNonNull[0],
|
activeChain || supportedChainsNonNull[0],
|
||||||
thirdwebApiKey,
|
clientId,
|
||||||
alchemyApiKey,
|
|
||||||
infuraApiKey,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const mergedChains = useMemo(() => {
|
const mergedChains = useMemo(() => {
|
||||||
@@ -222,61 +204,22 @@ export const ThirdwebSDKProvider = <TChains extends Chain[]>({
|
|||||||
<ThirdwebConfigProvider
|
<ThirdwebConfigProvider
|
||||||
value={{
|
value={{
|
||||||
chains: mergedChains as Chain[],
|
chains: mergedChains as Chain[],
|
||||||
thirdwebApiKey,
|
clientId,
|
||||||
alchemyApiKey,
|
|
||||||
infuraApiKey,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ThirdwebConnectedWalletProvider signer={signer}>
|
<QueryClientProviderWithDefault queryClient={queryClient}>
|
||||||
<QueryClientProviderWithDefault queryClient={queryClient}>
|
<WrappedThirdwebSDKProvider
|
||||||
<WrappedThirdwebSDKProvider
|
signer={signer}
|
||||||
signer={signer}
|
supportedChains={mergedChains}
|
||||||
supportedChains={mergedChains}
|
clientId={clientId}
|
||||||
thirdwebApiKey={thirdwebApiKey}
|
activeChain={activeChainIdOrObjWithKey}
|
||||||
alchemyApiKey={alchemyApiKey}
|
{...restProps}
|
||||||
infuraApiKey={infuraApiKey}
|
>
|
||||||
activeChain={activeChainIdOrObjWithKey}
|
<ThirdwebConnectedWalletProvider signer={signer}>
|
||||||
{...restProps}
|
|
||||||
>
|
|
||||||
{children}
|
{children}
|
||||||
</WrappedThirdwebSDKProvider>
|
</ThirdwebConnectedWalletProvider>
|
||||||
</QueryClientProviderWithDefault>
|
</WrappedThirdwebSDKProvider>
|
||||||
</ThirdwebConnectedWalletProvider>
|
</QueryClientProviderWithDefault>
|
||||||
</ThirdwebConfigProvider>
|
</ThirdwebConfigProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
function useSDKContext(): TWSDKContext {
|
|
||||||
const ctx = useContext(ThirdwebSDKContext);
|
|
||||||
invariant(
|
|
||||||
ctx._inProvider,
|
|
||||||
"useSDK must be called from within a ThirdwebProvider, did you forget to wrap your app in a <ThirdwebProvider />?",
|
|
||||||
);
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns {@link ThirdwebSDK}
|
|
||||||
* Access the instance of the thirdweb SDK created by the ThirdwebProvider
|
|
||||||
* to call methods using the connected wallet on the desiredChainId.
|
|
||||||
* @example
|
|
||||||
* ```javascript
|
|
||||||
* const sdk = useSDK();
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function useSDK(): ThirdwebSDK | undefined {
|
|
||||||
const { sdk } = useSDKContext();
|
|
||||||
return sdk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export function useSDKChainId(): number | undefined {
|
|
||||||
const sdk = useSDK();
|
|
||||||
return (sdk as any)?._chainId;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { QueryClientProviderProps } from "../../core/providers/query-client
|
|||||||
import type { ThirdwebAuthConfig } from "../contexts/thirdweb-auth";
|
import type { ThirdwebAuthConfig } from "../contexts/thirdweb-auth";
|
||||||
import type { Chain } from "@thirdweb-dev/chains";
|
import type { Chain } from "@thirdweb-dev/chains";
|
||||||
import type { SDKOptions } from "@thirdweb-dev/sdk";
|
import type { SDKOptions } from "@thirdweb-dev/sdk";
|
||||||
import type { ThirdwebStorage } from "@thirdweb-dev/storage";
|
import type { IThirdwebStorage } from "@thirdweb-dev/storage";
|
||||||
import type { Signer } from "ethers";
|
import type { Signer } from "ethers";
|
||||||
|
|
||||||
export interface ThirdwebSDKProviderProps<TChains extends Chain[]>
|
export interface ThirdwebSDKProviderProps<TChains extends Chain[]>
|
||||||
@@ -22,7 +22,7 @@ export interface ThirdwebSDKProviderProps<TChains extends Chain[]>
|
|||||||
/**
|
/**
|
||||||
* The storage interface to use with the sdk.
|
* The storage interface to use with the sdk.
|
||||||
*/
|
*/
|
||||||
storageInterface?: ThirdwebStorage;
|
storageInterface?: IThirdwebStorage;
|
||||||
/**
|
/**
|
||||||
* The configuration used for thirdweb auth usage. Enables users to login
|
* The configuration used for thirdweb auth usage. Enables users to login
|
||||||
* to backends with their wallet.
|
* to backends with their wallet.
|
||||||
@@ -41,8 +41,6 @@ export interface ThirdwebSDKProviderProps<TChains extends Chain[]>
|
|||||||
| (string & {})
|
| (string & {})
|
||||||
| Chain;
|
| Chain;
|
||||||
|
|
||||||
// api keys that can be passed
|
// client Id for thirdweb services
|
||||||
thirdwebApiKey?: string;
|
clientId?: string;
|
||||||
alchemyApiKey?: string;
|
|
||||||
infuraApiKey?: string;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export const ThirdwebSDKProvider: ComponentWithChildren<
|
|||||||
sdk,
|
sdk,
|
||||||
desiredNetwork: network || "unknown",
|
desiredNetwork: network || "unknown",
|
||||||
_inProvider: true,
|
_inProvider: true,
|
||||||
} as const),
|
}) as const,
|
||||||
[sdk, network],
|
[sdk, network],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# @thirdweb-dev/react-native-compat
|
# @thirdweb-dev/react-native-compat
|
||||||
|
|
||||||
|
## 0.2.37
|
||||||
|
|
||||||
|
## 0.2.36
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#1316](https://github.com/thirdweb-dev/js/pull/1316) [`d8447146`](https://github.com/thirdweb-dev/js/commit/d8447146092c1962f410155ab2047225453aaa2b) Thanks [@iketw](https://github.com/iketw)! - Adds support for clientId / secretKey
|
||||||
|
|
||||||
|
## 0.2.35
|
||||||
|
|
||||||
## 0.2.34
|
## 0.2.34
|
||||||
|
|
||||||
## 0.2.33
|
## 0.2.33
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
presets: ['module:metro-react-native-babel-preset'],
|
presets: ["module:metro-react-native-babel-preset"],
|
||||||
|
plugins: [
|
||||||
|
[
|
||||||
|
"module-resolver",
|
||||||
|
{
|
||||||
|
alias: {
|
||||||
|
crypto: "react-native-crypto",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user