Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5b89987af | ||
|
|
4bb8f5b15e | ||
|
|
914befda16 | ||
|
|
b5bbe2bd43 | ||
|
|
68288436ac | ||
|
|
d4ce855e5f | ||
|
|
47b0ed5171 |
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 4.1.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b5bbe2bd`](https://github.com/thirdweb-dev/js/commit/b5bbe2bd438179c38451bc2cfa20a54fc79e4f3a)]:
|
||||
- @thirdweb-dev/wallets@2.1.9
|
||||
|
||||
## 4.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "4.1.11",
|
||||
"version": "4.1.12",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# @thirdweb-dev/chains
|
||||
|
||||
## 0.1.59
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1967](https://github.com/thirdweb-dev/js/pull/1967) [`47b0ed51`](https://github.com/thirdweb-dev/js/commit/47b0ed5171be5608ae23c19481a1b04948443c6a) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Add Arbitrum Sepolia to defaultChains
|
||||
|
||||
- [#1990](https://github.com/thirdweb-dev/js/pull/1990) [`d4ce855e`](https://github.com/thirdweb-dev/js/commit/d4ce855e5f5e6c4206a3efa250e92e690ae87281) Thanks [@jnsdls](https://github.com/jnsdls)! - deprecate `allChains` `getChainById` and `getChainBySlug`
|
||||
|
||||
all of these would (necessarily) pull in every single chain in the package (>600kb)
|
||||
|
||||
instead these can be replaced with their async variants:
|
||||
|
||||
- `allChains` -> `await fetchChains()`
|
||||
- `getChainById(chainId)` -> `await getChainByIdAsync(chainId)`
|
||||
- `getChainBySlug(chainSlug)` -> `await getChainBySlugAsync(chainSlug)`
|
||||
|
||||
these async functions will return the same data as their sync counterparts, but without having to pull in every single chain at build-time.
|
||||
|
||||
## 0.1.58
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -39,11 +39,11 @@ export default {
|
||||
},
|
||||
"networkId": 13308,
|
||||
"rpc": [
|
||||
"https://credit-smart-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://credit-smart-chain-credit.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://13308.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc.creditsmartchain.com"
|
||||
],
|
||||
"shortName": "Credit",
|
||||
"slug": "credit-smart-chain",
|
||||
"slug": "credit-smart-chain-credit",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "BLITZ",
|
||||
"chainId": 1343,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "BLITZ Explorer",
|
||||
"url": "https://subnets-test.avax.network/blitz",
|
||||
"standard": "EIP3091"
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"features": [
|
||||
{
|
||||
"name": "EIP1559"
|
||||
}
|
||||
],
|
||||
"infoURL": "https://blitz.gg",
|
||||
"name": "Blitz Subnet",
|
||||
"nativeCurrency": {
|
||||
"name": "BLITZ GAS",
|
||||
"symbol": "BGAS",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 1343,
|
||||
"rpc": [
|
||||
"https://blitz-subnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://1343.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/blitz/testnet/rpc"
|
||||
],
|
||||
"shortName": "blitz",
|
||||
"slug": "blitz-subnet",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -33,6 +33,6 @@ export default {
|
||||
],
|
||||
"shortName": "testnet-zkEVM-mango",
|
||||
"slug": "polygon-zkevm-testnet",
|
||||
"testnet": false,
|
||||
"testnet": true,
|
||||
"title": "Polygon zkEVM Testnet"
|
||||
} as const satisfies Chain;
|
||||
@@ -41,6 +41,7 @@ export default {
|
||||
"https://faucet.holesky.ethpandaops.io",
|
||||
"https://holesky-faucet.pk910.de"
|
||||
],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmdwQDr6vmBtXmK2TmknkEuZNoaDqTasFdZdu3DRw8b2wt",
|
||||
"width": 1000,
|
||||
@@ -55,6 +56,7 @@ export default {
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 17000,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://holesky.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://17000.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
|
||||
@@ -2,13 +2,7 @@ import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Roll",
|
||||
"chainId": 1748,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "Blockscout",
|
||||
"url": "https://roll.calderaexplorer.xyz/",
|
||||
"standard": "EIP3091"
|
||||
}
|
||||
],
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
@@ -26,7 +20,11 @@ export default {
|
||||
},
|
||||
"networkId": 1748,
|
||||
"redFlags": [],
|
||||
"rpc": [],
|
||||
"rpc": [
|
||||
"https://roll-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://1748.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://roll.calderachain.xyz/http"
|
||||
],
|
||||
"shortName": "Roll",
|
||||
"slug": "roll-testnet",
|
||||
"testnet": true,
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "xgon",
|
||||
"chain": "X1",
|
||||
"chainId": 195,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "OKLink",
|
||||
"url": "https://www.oklink.com/okbc-test",
|
||||
"url": "https://www.oklink.com/x1-test",
|
||||
"standard": "EIP3091"
|
||||
}
|
||||
],
|
||||
"faucets": [
|
||||
"https://www.oklink.com/okbc-test"
|
||||
"https://www.okx.com/x1/faucet"
|
||||
],
|
||||
"features": [],
|
||||
"infoURL": "https://www.okx.com/okbc/docs/dev/quick-start/introduction/introduction-to-okbchain",
|
||||
"name": "Xgon Testnet",
|
||||
"infoURL": "https://www.okx.com/x1",
|
||||
"name": "X1 Testnet",
|
||||
"nativeCurrency": {
|
||||
"name": "Xgon Global Utility Token in testnet",
|
||||
"name": "X1 Global Utility Token in testnet",
|
||||
"symbol": "OKB",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 195,
|
||||
"rpc": [
|
||||
"https://xgon-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://x1-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://195.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://testrpc.xgon.io"
|
||||
"https://testrpc.x1.tech",
|
||||
"https://x1testrpc.okx.com"
|
||||
],
|
||||
"shortName": "tokb",
|
||||
"slug": "xgon-testnet",
|
||||
"slug": "x1-testnet",
|
||||
"status": "active",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -1,21 +1,21 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "xgon",
|
||||
"chain": "X1",
|
||||
"chainId": 196,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"infoURL": "https://www.okx.com/okbc/docs/dev/quick-start/introduction/introduction-to-okbchain",
|
||||
"name": "Xgon Mainnet",
|
||||
"infoURL": "https://www.okx.com/x1",
|
||||
"name": "X1 Mainnet",
|
||||
"nativeCurrency": {
|
||||
"name": "Xgon Global Utility Token",
|
||||
"name": "X1 Global Utility Token",
|
||||
"symbol": "OKB",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 196,
|
||||
"rpc": [],
|
||||
"shortName": "okb",
|
||||
"slug": "xgon",
|
||||
"slug": "x1",
|
||||
"status": "incubating",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 2121,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "M TEST 1103-2",
|
||||
"nativeCurrency": {
|
||||
"name": "M TEST 1103-2 Token",
|
||||
"symbol": "RJI",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 2121,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://m-test-1103-2.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://2121.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avacloud-dev.io/cb82eb40-2d0d-4188-905b-d50c4b09b40b"
|
||||
],
|
||||
"shortName": "M TEST 1103-2",
|
||||
"slug": "m-test-1103-2",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -32,7 +32,8 @@ export default {
|
||||
"rpc": [
|
||||
"https://krest-network.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://2241.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://erpc-krest.peaq.network"
|
||||
"https://erpc-krest.peaq.network",
|
||||
"https://krest.unitedbloc.com"
|
||||
],
|
||||
"shortName": "KRST",
|
||||
"slug": "krest-network",
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 23934,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "ST 11-16 v7 Regression",
|
||||
"nativeCurrency": {
|
||||
"name": "ST 11-16 v7 Regression Token",
|
||||
"symbol": "WLA",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 23934,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://st-11-16-v7-regression.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://23934.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
|
||||
],
|
||||
"shortName": "ST 11-16 v7 Regression",
|
||||
"slug": "st-11-16-v7-regression",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 30891,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "Jambon's Testnet",
|
||||
"nativeCurrency": {
|
||||
"name": "Jambon's Testnet Token",
|
||||
"symbol": "CXY",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 30891,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://jambon-s-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://30891.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avacloud-dev.io/e8b04790-d50c-4bb1-89ba-7bd140b674f3"
|
||||
],
|
||||
"shortName": "Jambon's Testnet",
|
||||
"slug": "jambon-s-testnet",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "CLOUDVERSE",
|
||||
"chainId": 33210,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "CLOUDVERSE Explorer",
|
||||
"url": "https://subnets.avax.network/cloudverse",
|
||||
"standard": "EIP3091"
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"features": [
|
||||
{
|
||||
"name": "EIP1559"
|
||||
}
|
||||
],
|
||||
"infoURL": "https://muadao.build/",
|
||||
"name": "Cloudverse Subnet",
|
||||
"nativeCurrency": {
|
||||
"name": "XCLOUD",
|
||||
"symbol": "XCLOUD",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 33210,
|
||||
"rpc": [
|
||||
"https://cloudverse-subnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://33210.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/cloudverse/mainnet/rpc"
|
||||
],
|
||||
"shortName": "cloudverse",
|
||||
"slug": "cloudverse-subnet",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 33909,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "Reg1116test",
|
||||
"nativeCurrency": {
|
||||
"name": "Reg1116test Token",
|
||||
"symbol": "JUO",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 33909,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://reg1116test.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://33909.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
|
||||
],
|
||||
"shortName": "Reg1116test",
|
||||
"slug": "reg1116test",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "ETH",
|
||||
"chainId": 34443,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "modescout",
|
||||
"url": "https://explorer.mode.network",
|
||||
"standard": "none"
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://bafkreidi5y7afj5z4xrz7uz5rkg2mcsv2p2n4ui4g7q4k4ecdz65i2agou",
|
||||
"width": 2160,
|
||||
"height": 2160,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://docs.mode.network/",
|
||||
"name": "Mode",
|
||||
"nativeCurrency": {
|
||||
"name": "Ether",
|
||||
"symbol": "ETH",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 34443,
|
||||
"rpc": [
|
||||
"https://mode.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://34443.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://mainnet.mode.network"
|
||||
],
|
||||
"shortName": "mode",
|
||||
"slug": "mode",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "DS2",
|
||||
"chainId": 363636,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"name": "Digit Soul Smart Chain 2",
|
||||
"nativeCurrency": {
|
||||
"name": "Digit Coin",
|
||||
"symbol": "DGC",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 363636,
|
||||
"rpc": [
|
||||
"https://digit-soul-smart-chain-2.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://363636.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"http://dgs-rpc.digitsoul.co.th"
|
||||
],
|
||||
"shortName": "DS2",
|
||||
"slug": "digit-soul-smart-chain-2",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -43,5 +43,5 @@ export default {
|
||||
],
|
||||
"shortName": "tftm",
|
||||
"slug": "fantom-testnet",
|
||||
"testnet": false
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -15,9 +15,7 @@ export default {
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [
|
||||
"https://coinbase.com/faucets/optimism-goerli-faucet"
|
||||
],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/optimism/512.png",
|
||||
@@ -37,8 +35,6 @@ export default {
|
||||
"rpc": [
|
||||
"https://optimism-goerli.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://420.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://optimism-goerli.infura.io/v3/${INFURA_API_KEY}",
|
||||
"https://opt-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY}",
|
||||
"https://goerli.optimism.io",
|
||||
"https://optimism-goerli.publicnode.com",
|
||||
"wss://optimism-goerli.publicnode.com",
|
||||
@@ -47,5 +43,5 @@ export default {
|
||||
],
|
||||
"shortName": "ogor",
|
||||
"slug": "optimism-goerli",
|
||||
"testnet": false
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -10,8 +10,7 @@ export default {
|
||||
}
|
||||
],
|
||||
"faucets": [
|
||||
"https://faucet.avax-test.network/",
|
||||
"https://faucet.avax.network/"
|
||||
"https://faucet.avax-test.network/"
|
||||
],
|
||||
"features": [],
|
||||
"icon": {
|
||||
@@ -32,12 +31,11 @@ export default {
|
||||
"rpc": [
|
||||
"https://avalanche-fuji.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://43113.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://avalanche-fuji.infura.io/v3/${INFURA_API_KEY}",
|
||||
"https://api.avax-test.network/ext/bc/C/rpc",
|
||||
"https://avalanche-fuji-c-chain.publicnode.com",
|
||||
"wss://avalanche-fuji-c-chain.publicnode.com"
|
||||
],
|
||||
"shortName": "Fuji",
|
||||
"slug": "avalanche-fuji",
|
||||
"testnet": false
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,49 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "CREDIT",
|
||||
"chainId": 4400,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "Creditscan",
|
||||
"url": "https://scan.creditsmartchain.com",
|
||||
"standard": "EIP3091",
|
||||
"icon": {
|
||||
"url": "ipfs://bafkreifbso3gd4wu5wxl27xyurxctmuae2jyuy37guqtzx23nga6ba4ag4",
|
||||
"width": 1000,
|
||||
"height": 1628,
|
||||
"format": "png"
|
||||
}
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"features": [
|
||||
{
|
||||
"name": "EIP155"
|
||||
},
|
||||
{
|
||||
"name": "EIP1559"
|
||||
}
|
||||
],
|
||||
"icon": {
|
||||
"url": "ipfs://bafkreifbso3gd4wu5wxl27xyurxctmuae2jyuy37guqtzx23nga6ba4ag4",
|
||||
"width": 1000,
|
||||
"height": 1628,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://creditsmartchain.com",
|
||||
"name": "Credit Smart Chain Mainnet",
|
||||
"nativeCurrency": {
|
||||
"name": "Credit",
|
||||
"symbol": "CREDIT",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 4400,
|
||||
"rpc": [
|
||||
"https://credit-smart-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://4400.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc.creditsmartchain.com"
|
||||
],
|
||||
"shortName": "CreditEdge",
|
||||
"slug": "credit-smart-chain",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -45,5 +45,5 @@ export default {
|
||||
"shortName": "synapse-sepolia",
|
||||
"slug": "synapse-chain-testnet",
|
||||
"status": "active",
|
||||
"testnet": false
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -4,8 +4,8 @@ export default {
|
||||
"chainId": 44787,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "Celoscan",
|
||||
"url": "https://alfajores.celoscan.io/",
|
||||
"name": "Alfajoresscan",
|
||||
"url": "https://alfajores.celoscan.io",
|
||||
"standard": "EIP3091"
|
||||
}
|
||||
],
|
||||
@@ -31,5 +31,5 @@ export default {
|
||||
],
|
||||
"shortName": "ALFA",
|
||||
"slug": "celo-alfajores-testnet",
|
||||
"testnet": false
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -23,7 +23,6 @@ export default {
|
||||
"https://46.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc.darwinia.network",
|
||||
"https://darwinia-rpc.darwiniacommunitydao.xyz",
|
||||
"https://darwinia2.api.onfinality.io/public-ws",
|
||||
"https://darwinia-rpc.dwellir.com"
|
||||
],
|
||||
"shortName": "darwinia",
|
||||
|
||||
@@ -35,5 +35,5 @@ export default {
|
||||
],
|
||||
"shortName": "iotex-testnet",
|
||||
"slug": "iotex-network-testnet",
|
||||
"testnet": false
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "GC",
|
||||
"chainId": 4893,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "blockscout",
|
||||
"url": "https://gcscan.io",
|
||||
"standard": "none"
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmPRHDsVNpRZ72GoQgDbpa3R4wKENmrXCRNuYJkxocFRDb",
|
||||
"width": 306,
|
||||
"height": 293,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://gcscan.io",
|
||||
"name": "Globel Chain",
|
||||
"nativeCurrency": {
|
||||
"name": "Globel Chain",
|
||||
"symbol": "GC",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 4893,
|
||||
"rpc": [
|
||||
"https://globel-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://4893.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc.gcscan.io"
|
||||
],
|
||||
"shortName": "GC",
|
||||
"slug": "globel-chain",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -26,8 +26,7 @@ export default {
|
||||
"faucets": [
|
||||
"http://fauceth.komputing.org?chain=5&address=${ADDRESS}",
|
||||
"https://goerli-faucet.slock.it?address=${ADDRESS}",
|
||||
"https://faucet.goerli.mudit.blog",
|
||||
"https://faucet.paradigm.xyz/"
|
||||
"https://faucet.goerli.mudit.blog"
|
||||
],
|
||||
"features": [],
|
||||
"icon": {
|
||||
@@ -50,7 +49,6 @@ export default {
|
||||
"https://5.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://goerli.infura.io/v3/${INFURA_API_KEY}",
|
||||
"wss://goerli.infura.io/v3/${INFURA_API_KEY}",
|
||||
"https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY}",
|
||||
"https://rpc.goerli.mudit.blog/",
|
||||
"https://ethereum-goerli.publicnode.com",
|
||||
"wss://ethereum-goerli.publicnode.com",
|
||||
@@ -59,6 +57,6 @@ export default {
|
||||
],
|
||||
"shortName": "gor",
|
||||
"slug": "goerli",
|
||||
"testnet": false,
|
||||
"testnet": true,
|
||||
"title": "Ethereum Testnet Goerli"
|
||||
} as const satisfies Chain;
|
||||
@@ -38,7 +38,9 @@ export default {
|
||||
"https://rpc1.bahamut.io",
|
||||
"https://rpc2.bahamut.io",
|
||||
"wss://ws1.sahara.bahamutchain.com",
|
||||
"wss://ws2.sahara.bahamutchain.com"
|
||||
"wss://ws2.sahara.bahamutchain.com",
|
||||
"https://bahamut.publicnode.com",
|
||||
"wss://bahamut.publicnode.com"
|
||||
],
|
||||
"shortName": "ftn",
|
||||
"slug": "bahamut",
|
||||
|
||||
@@ -44,5 +44,5 @@ export default {
|
||||
],
|
||||
"shortName": "metis-goerli",
|
||||
"slug": "metis-goerli-testnet",
|
||||
"testnet": false
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 62278,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "qi1121i1",
|
||||
"nativeCurrency": {
|
||||
"name": "qi1121i1 Token",
|
||||
"symbol": "SJOX",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 62278,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://qi1121i1.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://62278.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
|
||||
],
|
||||
"shortName": "qi1121i1",
|
||||
"slug": "qi1121i1",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 63079,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "MT 1121-2",
|
||||
"nativeCurrency": {
|
||||
"name": "MT 1121-2 Token",
|
||||
"symbol": "RCE",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 63079,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://mt-1121-2.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://63079.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avacloud-test.io/d76ea66a-e423-49f6-8ef1-4355260b47f1"
|
||||
],
|
||||
"shortName": "MT 1121-2",
|
||||
"slug": "mt-1121-2",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "DGS",
|
||||
"chainId": 6363,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"name": "Digit Soul Smart Chain",
|
||||
"nativeCurrency": {
|
||||
"name": "Digit Coin",
|
||||
"symbol": "DGC",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 6363,
|
||||
"rpc": [
|
||||
"https://digit-soul-smart-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://6363.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"http://dsc-rpc.digitsoul.co.th"
|
||||
],
|
||||
"shortName": "DGS",
|
||||
"slug": "digit-soul-smart-chain",
|
||||
"testnet": false
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "JanusNetwork",
|
||||
"chainId": 66988,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "JanusNetwork Testnet Explorer",
|
||||
"url": "https://beta.scan.janusnetwork.io",
|
||||
"standard": "none"
|
||||
}
|
||||
],
|
||||
"faucets": [],
|
||||
"icon": {
|
||||
"url": "ipfs://bafkreifc3vnwf4hj3bo6fg4u5qlqmjgajjgezyeg236qjcihl4ha42siuq",
|
||||
"width": 819,
|
||||
"height": 792,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://janus-network.gitbook.io/janus",
|
||||
"name": "Janus Testnet",
|
||||
"nativeCurrency": {
|
||||
"name": "Janus",
|
||||
"symbol": "JNS",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 66988,
|
||||
"rpc": [
|
||||
"https://janus-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://66988.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc.test.janusnetwork.io"
|
||||
],
|
||||
"shortName": "janusnetwork-testnet",
|
||||
"slug": "janus-testnet",
|
||||
"status": "active",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -14,9 +14,9 @@ export default {
|
||||
],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "ipfs://QmTS1P9sh49zg5xL5BUsRLWDz3vVoJCtCNf9yN1TTnsuQ3",
|
||||
"width": 321,
|
||||
"height": 320,
|
||||
"url": "ipfs://QmRxeKFwBwrXyDksoN4NzNRp3R35s8pVnTBfBj4AJSCq5g",
|
||||
"width": 512,
|
||||
"height": 512,
|
||||
"format": "png"
|
||||
},
|
||||
"infoURL": "https://frame.xyz",
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Jambon's Devnet",
|
||||
"chainId": 72605,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"name": "Jambon's Devnet",
|
||||
"nativeCurrency": {
|
||||
"name": "Jambon's Devnet",
|
||||
"symbol": "DOB",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 72605,
|
||||
"redFlags": [],
|
||||
"rpc": [],
|
||||
"shortName": "Jambon's Devnet",
|
||||
"slug": "jambon-s-devnet",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -31,8 +31,6 @@ export default {
|
||||
"rpc": [
|
||||
"https://mumbai.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://80001.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://polygon-mumbai.infura.io/v3/${INFURA_API_KEY}",
|
||||
"https://polygon-mumbai.g.alchemy.com/v2/${ALCHEMY_API_KEY}",
|
||||
"https://rpc-mumbai.maticvigil.com",
|
||||
"https://polygon-mumbai-bor.publicnode.com",
|
||||
"wss://polygon-mumbai-bor.publicnode.com",
|
||||
@@ -41,6 +39,6 @@ export default {
|
||||
],
|
||||
"shortName": "maticmum",
|
||||
"slug": "mumbai",
|
||||
"testnet": false,
|
||||
"testnet": true,
|
||||
"title": "Polygon Testnet Mumbai"
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "zFirst AvaCloud Subnet Thirdweb",
|
||||
"chainId": 82807,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "zFirst AvaCloud Subnet Thirdweb",
|
||||
"nativeCurrency": {
|
||||
"name": "zFirst AvaCloud Subnet Thirdweb",
|
||||
"symbol": "YOOO",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 82807,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://zfirst-avacloud-subnet-thirdweb.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://82807.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avacloud-dev.io/f2ea180d-0fda-4b06-9b2e-53a65d3fd789"
|
||||
],
|
||||
"shortName": "zFirst AvaCloud Subnet Thirdweb",
|
||||
"slug": "zfirst-avacloud-subnet-thirdweb",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -42,5 +42,5 @@ export default {
|
||||
],
|
||||
"shortName": "bnbt",
|
||||
"slug": "binance-testnet",
|
||||
"testnet": false
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"chain": "Avalanche",
|
||||
"chainId": 993535,
|
||||
"explorers": [],
|
||||
"faucets": [],
|
||||
"features": [],
|
||||
"icon": {
|
||||
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"format": ".svg"
|
||||
},
|
||||
"infoURL": "https://avacloud.io",
|
||||
"name": "qr1120y1",
|
||||
"nativeCurrency": {
|
||||
"name": "qr1120y1 Token",
|
||||
"symbol": "LMK",
|
||||
"decimals": 18
|
||||
},
|
||||
"networkId": 993535,
|
||||
"redFlags": [],
|
||||
"rpc": [
|
||||
"https://qr1120y1.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://993535.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://subnets.avax.network/qr1120y1/testnet/rpc"
|
||||
],
|
||||
"shortName": "qr1120y1",
|
||||
"slug": "qr1120y1",
|
||||
"testnet": true
|
||||
} as const satisfies Chain;
|
||||
@@ -29,6 +29,8 @@ export default {
|
||||
"https://9996.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://rpc-msc.mindchain.info/",
|
||||
"https://seednode.mindchain.info",
|
||||
"https://archive.mindchain.info/",
|
||||
"wss://archive.mindchain.info/ws",
|
||||
"wss://seednode.mindchain.info/ws"
|
||||
],
|
||||
"shortName": "MIND",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/chains",
|
||||
"version": "0.1.58",
|
||||
"version": "0.1.59",
|
||||
"main": "dist/thirdweb-dev-chains.cjs.js",
|
||||
"module": "dist/thirdweb-dev-chains.esm.js",
|
||||
"exports": {
|
||||
|
||||
@@ -95,7 +95,11 @@ export * from "./types";
|
||||
export * from "./utils";
|
||||
export * from "./async";
|
||||
export const defaultChains = [c1, c5, c8453, c84531, c137, c80001, c42161, c421613, c10, c420, c56, c97, c250, c4002, c43114, c43113, c1337];
|
||||
// @ts-expect-error - TODO: fix this later
|
||||
|
||||
\/**
|
||||
* @deprecated use \`fetchChains()\` instead
|
||||
*\/
|
||||
\/\/ @ts-expect-error - TODO: fix this later
|
||||
export const allChains: Chain[] = [${exportNames.join(", ")}];
|
||||
|
||||
type ChainsById = {
|
||||
@@ -152,6 +156,9 @@ function isValidChainSlug(slug: string): slug is ChainSlug {
|
||||
return slug in chainIdsBySlug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use \`getChainByChainIdAsync()\` instead
|
||||
*/
|
||||
export function getChainByChainId<TChainId extends ChainId>(
|
||||
chainId: TChainId | (number & {}),
|
||||
) {
|
||||
@@ -162,6 +169,9 @@ export function getChainByChainId<TChainId extends ChainId>(
|
||||
throw new Error(\`Chain with chainId "\${chainId}" not found\`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use \`getChainBySlugAsync()\` instead
|
||||
*/
|
||||
export function getChainBySlug<TSlug extends ChainSlug>(
|
||||
slug: TSlug | (string & {}),
|
||||
) {
|
||||
|
||||
@@ -4,8 +4,16 @@ type FetchChainResponse = {
|
||||
data: Chain;
|
||||
error: unknown;
|
||||
};
|
||||
|
||||
// cache of chainId -> Chain
|
||||
const chainCache: Record<number, Chain> = {};
|
||||
// cache of slug -> chainId
|
||||
const slugToChainId: Record<string, keyof typeof chainCache> = {};
|
||||
export async function fetchChain(chainIdOrSlug: number | string) {
|
||||
if (typeof chainIdOrSlug === "string" && chainIdOrSlug in slugToChainId) {
|
||||
return chainCache[slugToChainId[chainIdOrSlug]];
|
||||
} else if (typeof chainIdOrSlug === "number" && chainIdOrSlug in chainCache) {
|
||||
return chainCache[chainIdOrSlug];
|
||||
}
|
||||
const res = await fetch(
|
||||
`https://api.thirdweb.com/v1/chains/${chainIdOrSlug}`,
|
||||
);
|
||||
@@ -19,6 +27,11 @@ export async function fetchChain(chainIdOrSlug: number | string) {
|
||||
console.debug("[chains] fetchChain() error", json.error);
|
||||
return null;
|
||||
}
|
||||
const chain = json.data;
|
||||
// store the chain in chainCache
|
||||
chainCache[chain.chainId] = chain;
|
||||
// store the slug<->chainId in slugToChainId
|
||||
slugToChainId[chain.slug] = chain.chainId;
|
||||
return json.data;
|
||||
} catch (err) {
|
||||
console.debug("[chains] fetchChain() failed", err);
|
||||
@@ -31,10 +44,16 @@ type FetchChainsResponse = {
|
||||
error: unknown;
|
||||
};
|
||||
|
||||
const fetchChainsCache: Record<string, Chain[]> = {};
|
||||
export async function fetchChains(options?: {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}) {
|
||||
// cache key is based on limit and offset (options)
|
||||
const cacheKey = `l:${options?.limit ?? 0}o:${options?.offset ?? 0}`;
|
||||
if (cacheKey in fetchChainsCache) {
|
||||
return fetchChainsCache[cacheKey];
|
||||
}
|
||||
const url = new URL(`https://api.thirdweb.com/v1/chains`);
|
||||
if (options?.limit && options.limit >= 1) {
|
||||
url.searchParams.append("limit", options.limit.toString());
|
||||
@@ -53,9 +72,39 @@ export async function fetchChains(options?: {
|
||||
console.debug("[chains] fetchChain() error", json.error);
|
||||
return null;
|
||||
}
|
||||
fetchChainsCache[cacheKey] = json.data;
|
||||
return json.data;
|
||||
} catch (err) {
|
||||
console.debug("[chains] fetchChain() failed", err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param chainId - the chainId of the chain to resolve
|
||||
* @returns a Promise that resolves to the Chain object
|
||||
* @throws if the chainId is not found
|
||||
*/
|
||||
export async function getChainByChainIdAsync(chainId: number): Promise<Chain> {
|
||||
const chain = await fetchChain(chainId);
|
||||
if (!chain) {
|
||||
throw new Error(`Chain with chainId "${chainId}" not found`);
|
||||
}
|
||||
|
||||
return chain;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param slug - the slug of the chain to resolve
|
||||
* @returns a Promise that resolves to the Chain object
|
||||
* @throws if the slug is not found
|
||||
*/
|
||||
export async function getChainBySlugAsync(slug: string): Promise<Chain> {
|
||||
const chain = await fetchChain(slug);
|
||||
if (!chain) {
|
||||
throw new Error(`Chain with slug "${slug}" not found`);
|
||||
}
|
||||
return chain;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,15 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.13.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`47b0ed51`](https://github.com/thirdweb-dev/js/commit/47b0ed5171be5608ae23c19481a1b04948443c6a), [`d4ce855e`](https://github.com/thirdweb-dev/js/commit/d4ce855e5f5e6c4206a3efa250e92e690ae87281), [`b5bbe2bd`](https://github.com/thirdweb-dev/js/commit/b5bbe2bd438179c38451bc2cfa20a54fc79e4f3a)]:
|
||||
- @thirdweb-dev/chains@0.1.59
|
||||
- @thirdweb-dev/wallets@2.1.9
|
||||
- @thirdweb-dev/sdk@4.0.17
|
||||
- @thirdweb-dev/auth@4.1.12
|
||||
|
||||
## 0.13.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.13.19",
|
||||
"version": "0.13.20",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 4.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1996](https://github.com/thirdweb-dev/js/pull/1996) [`4bb8f5b1`](https://github.com/thirdweb-dev/js/commit/4bb8f5b15e58de39c5edccc7476da3e4907d7688) Thanks [@MananTank](https://github.com/MananTank)! - Revert commit fb0cb676b996fe386dcc53b5a6dab03f88e76175
|
||||
|
||||
- Updated dependencies [[`47b0ed51`](https://github.com/thirdweb-dev/js/commit/47b0ed5171be5608ae23c19481a1b04948443c6a), [`d4ce855e`](https://github.com/thirdweb-dev/js/commit/d4ce855e5f5e6c4206a3efa250e92e690ae87281), [`b5bbe2bd`](https://github.com/thirdweb-dev/js/commit/b5bbe2bd438179c38451bc2cfa20a54fc79e4f3a)]:
|
||||
- @thirdweb-dev/chains@0.1.59
|
||||
- @thirdweb-dev/wallets@2.1.9
|
||||
- @thirdweb-dev/sdk@4.0.17
|
||||
- @thirdweb-dev/auth@4.1.12
|
||||
|
||||
## 4.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "4.1.9",
|
||||
"version": "4.1.10",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -65,16 +65,6 @@ const walletInstanceToConfig: Map<
|
||||
WalletConfig<any>
|
||||
> = new Map();
|
||||
|
||||
type PersonalWalletInfo = {
|
||||
signer?: Signer;
|
||||
wallet?: WalletInstance;
|
||||
walletConfig?: WalletConfig;
|
||||
connectionStatus: ConnectionStatus;
|
||||
chainId?: number;
|
||||
disconnect: () => Promise<void>;
|
||||
switchChain: (chainId: number) => Promise<void>;
|
||||
};
|
||||
|
||||
type ThirdwebWalletContextData = {
|
||||
wallets: WalletConfig[];
|
||||
signer?: Signer;
|
||||
@@ -102,20 +92,6 @@ type ThirdwebWalletContextData = {
|
||||
getWalletConfig: (walletInstance: WalletInstance) => WalletConfig | undefined;
|
||||
activeChainSetExplicitly: boolean;
|
||||
clientId?: string;
|
||||
/**
|
||||
* flag indicating whether to treat any wallet that gets connected after setting this flag as a "personal" wallet
|
||||
* If a wallet is treated as a "personal" wallet, It's details like signer, connectionStatus, wallet, walletConfig will be saved in `personalWalletInfo` object instead of the main context
|
||||
*/
|
||||
isConnectingToPersonalWallet: boolean;
|
||||
/**
|
||||
* Set value of `isConnectingToPersonalWallet` flag
|
||||
*/
|
||||
setIsConnectingToPersonalWallet: (value: boolean) => void;
|
||||
/**
|
||||
* object containing info about the connected personal wallet
|
||||
* When `isConnectingToPersonalWallet` is set to true, and a wallet is connected after that, all the info about the connected wallet will be stored in this object
|
||||
*/
|
||||
personalWalletInfo: PersonalWalletInfo;
|
||||
};
|
||||
|
||||
const ThirdwebWalletContext = /* @__PURE__ */ createContext<
|
||||
@@ -137,31 +113,11 @@ export function ThirdwebWalletProvider(
|
||||
signerWallet?: WalletConfig<SignerWallet>;
|
||||
}>,
|
||||
) {
|
||||
const autoConnectTimeout = props.autoConnectTimeout || 15000;
|
||||
|
||||
if (!lastConnectedWalletStorage) {
|
||||
lastConnectedWalletStorage =
|
||||
props.createWalletStorage("coordinatorStorage");
|
||||
}
|
||||
|
||||
// if autoSwitch is enabled - enforce connection to activeChain
|
||||
const chainToConnect = props.autoSwitch ? props.activeChain : undefined;
|
||||
|
||||
const [isConnectingToPersonalWallet, setIsConnectingToPersonalWallet] =
|
||||
useState(false);
|
||||
|
||||
const personalWalletConnection = usePersonalWalletConnection();
|
||||
|
||||
const {
|
||||
wallet: personalWallet,
|
||||
setWallet: setPersonalWallet,
|
||||
setSigner: setPersonalWalletSigner,
|
||||
setStatus: setPersonalWalletStatus,
|
||||
setWalletConfig: setPersonalWalletConfig,
|
||||
} = personalWalletConnection;
|
||||
|
||||
const [signer, setSigner] = useState<Signer | undefined>(undefined);
|
||||
const [status, setStatus] = useState<ConnectionStatus>("unknown");
|
||||
const [connectionStatus, setConnectionStatus] =
|
||||
useState<ConnectionStatus>("unknown");
|
||||
|
||||
const autoConnectTimeout = props.autoConnectTimeout || 15000;
|
||||
|
||||
const [activeWallet, setActiveWallet] = useState<
|
||||
WalletInstance | undefined
|
||||
@@ -175,6 +131,14 @@ export function ThirdwebWalletProvider(
|
||||
WalletConfig | undefined
|
||||
>();
|
||||
|
||||
if (!lastConnectedWalletStorage) {
|
||||
lastConnectedWalletStorage =
|
||||
props.createWalletStorage("coordinatorStorage");
|
||||
}
|
||||
|
||||
// if autoSwitch is enabled - enforce connection to activeChain
|
||||
const chainToConnect = props.autoSwitch ? props.activeChain : undefined;
|
||||
|
||||
const walletParams: WalletOptions = useMemo(() => {
|
||||
return {
|
||||
chains: props.chains,
|
||||
@@ -201,25 +165,12 @@ export function ThirdwebWalletProvider(
|
||||
[walletParams],
|
||||
);
|
||||
|
||||
// if props.chains is updated, update the wallet's chains
|
||||
// if props.chains is updated, update the active wallet's chains
|
||||
useEffect(() => {
|
||||
if (activeWallet) {
|
||||
activeWallet.updateChains(props.chains);
|
||||
const _personalWallet = activeWallet.getPersonalWallet();
|
||||
if (_personalWallet instanceof AbstractClientWallet) {
|
||||
_personalWallet.updateChains(props.chains);
|
||||
}
|
||||
}
|
||||
|
||||
if (isConnectingToPersonalWallet && personalWallet) {
|
||||
personalWallet.updateChains(props.chains);
|
||||
}
|
||||
}, [
|
||||
activeWallet,
|
||||
props.chains,
|
||||
personalWallet,
|
||||
isConnectingToPersonalWallet,
|
||||
]);
|
||||
}, [activeWallet, props.chains]);
|
||||
|
||||
const setConnectedWallet = useCallback(
|
||||
async (
|
||||
@@ -227,45 +178,23 @@ export function ThirdwebWalletProvider(
|
||||
connectParams?: ConnectParams<Record<string, any>>,
|
||||
isAutoConnect = false,
|
||||
) => {
|
||||
if (isConnectingToPersonalWallet) {
|
||||
setPersonalWallet(wallet);
|
||||
} else {
|
||||
setActiveWallet(wallet);
|
||||
}
|
||||
|
||||
setActiveWallet(wallet);
|
||||
const walletConfig = walletInstanceToConfig.get(wallet);
|
||||
if (!walletConfig) {
|
||||
throw new Error(
|
||||
"Wallet config not found for given wallet instance. Do not create a wallet instance manually - use the useCreateWalletInstance() hook instead",
|
||||
);
|
||||
}
|
||||
|
||||
if (isConnectingToPersonalWallet) {
|
||||
setPersonalWalletConfig(walletConfig);
|
||||
setPersonalWalletStatus("connected");
|
||||
} else {
|
||||
setActiveWalletConfig(walletConfig);
|
||||
setStatus("connected");
|
||||
}
|
||||
|
||||
setActiveWalletConfig(walletConfig);
|
||||
setConnectionStatus("connected");
|
||||
const _signer = await wallet.getSigner();
|
||||
setSigner(_signer);
|
||||
|
||||
if (isConnectingToPersonalWallet) {
|
||||
setPersonalWalletSigner(_signer);
|
||||
} else {
|
||||
setSigner(_signer);
|
||||
}
|
||||
|
||||
// it auto-connected, then the details is already saved in storage, no need to store again
|
||||
// it autoconnected, then the details is already saved in storage, no need to store again
|
||||
if (isAutoConnect) {
|
||||
return;
|
||||
}
|
||||
|
||||
// do not save connection details for personal wallet
|
||||
if (isConnectingToPersonalWallet) {
|
||||
return;
|
||||
}
|
||||
|
||||
// save to storage
|
||||
|
||||
const walletInfo: LastConnectedWalletInfo = {
|
||||
@@ -273,18 +202,16 @@ export function ThirdwebWalletProvider(
|
||||
connectParams: connectParams || wallet.getConnectParams(),
|
||||
};
|
||||
|
||||
// if personal wallet exists, we need to replace the connectParams.personalWallet to a serializable version
|
||||
const _personalWallet =
|
||||
wallet.getPersonalWallet() as AbstractClientWallet;
|
||||
// if personal wallet exists, we need to replace the connectParams.personalWallet to a stringifiable version
|
||||
const personalWallet = wallet.getPersonalWallet() as AbstractClientWallet;
|
||||
const personalWalletConfig = walletInstanceToConfig.get(personalWallet);
|
||||
|
||||
const _personalWalletConfig = walletInstanceToConfig.get(_personalWallet);
|
||||
|
||||
if (_personalWallet && _personalWalletConfig) {
|
||||
if (personalWallet && personalWalletConfig) {
|
||||
walletInfo.connectParams = {
|
||||
...walletInfo.connectParams,
|
||||
personalWallet: {
|
||||
walletId: _personalWalletConfig.id,
|
||||
connectParams: _personalWallet.getConnectParams(),
|
||||
walletId: personalWalletConfig.id,
|
||||
connectParams: personalWallet.getConnectParams(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -293,13 +220,7 @@ export function ThirdwebWalletProvider(
|
||||
saveLastConnectedWalletInfo(walletInfo);
|
||||
}
|
||||
},
|
||||
[
|
||||
isConnectingToPersonalWallet,
|
||||
setPersonalWallet,
|
||||
setPersonalWalletConfig,
|
||||
setPersonalWalletStatus,
|
||||
setPersonalWalletSigner,
|
||||
],
|
||||
[],
|
||||
);
|
||||
|
||||
const storeLastActiveChainId = useCallback(async (chainId: number) => {
|
||||
@@ -329,35 +250,22 @@ export function ThirdwebWalletProvider(
|
||||
|
||||
const switchChain = useCallback(
|
||||
async (chainId: number) => {
|
||||
const wallet = isConnectingToPersonalWallet
|
||||
? personalWallet
|
||||
: activeWallet;
|
||||
|
||||
if (!wallet) {
|
||||
if (!activeWallet) {
|
||||
throw new Error("No active wallet");
|
||||
}
|
||||
|
||||
await wallet.switchChain(chainId);
|
||||
const _signer = await wallet.getSigner();
|
||||
await activeWallet.switchChain(chainId);
|
||||
const _signer = await activeWallet.getSigner();
|
||||
await storeLastActiveChainId(chainId);
|
||||
|
||||
if (!isConnectingToPersonalWallet) {
|
||||
await storeLastActiveChainId(chainId);
|
||||
setSigner(_signer);
|
||||
} else {
|
||||
setPersonalWalletSigner(_signer);
|
||||
}
|
||||
setSigner(_signer);
|
||||
},
|
||||
[
|
||||
isConnectingToPersonalWallet,
|
||||
personalWallet,
|
||||
activeWallet,
|
||||
storeLastActiveChainId,
|
||||
setPersonalWalletSigner,
|
||||
],
|
||||
[activeWallet, storeLastActiveChainId],
|
||||
);
|
||||
|
||||
// Auto Connect
|
||||
const autoConnectTriggered = useRef(false);
|
||||
|
||||
// Auto Connect
|
||||
useEffect(() => {
|
||||
// do not auto connect if signerWallet is given
|
||||
if (props.signerWallet) {
|
||||
@@ -370,7 +278,7 @@ export function ThirdwebWalletProvider(
|
||||
// if explicitly set to false, don't auto connect
|
||||
// by default, auto connect
|
||||
if (props.shouldAutoConnect === false) {
|
||||
setStatus("disconnected");
|
||||
setConnectionStatus("disconnected");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -379,18 +287,18 @@ export function ThirdwebWalletProvider(
|
||||
return;
|
||||
}
|
||||
|
||||
if (status !== "unknown") {
|
||||
if (connectionStatus !== "unknown") {
|
||||
// only try to auto connect if we're in the unknown state
|
||||
return;
|
||||
}
|
||||
|
||||
autoConnectTriggered.current = true;
|
||||
|
||||
async function autoConnect() {
|
||||
async function autoconnect() {
|
||||
const walletInfo = await getLastConnectedWalletInfo();
|
||||
|
||||
if (!walletInfo) {
|
||||
setStatus("disconnected");
|
||||
setConnectionStatus("disconnected");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -400,7 +308,7 @@ export function ThirdwebWalletProvider(
|
||||
|
||||
if (!walletObj) {
|
||||
// last connected wallet is no longer present in the supported wallets
|
||||
setStatus("disconnected");
|
||||
setConnectionStatus("disconnected");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -409,13 +317,12 @@ export function ThirdwebWalletProvider(
|
||||
if (personalWalletInfo) {
|
||||
const personalWallets = walletObj.personalWallets || [];
|
||||
|
||||
const personalWalletObj = personalWallets.find(
|
||||
const personalWalleObj = personalWallets.find(
|
||||
(W) => W.id === personalWalletInfo.walletId,
|
||||
);
|
||||
if (personalWalletObj) {
|
||||
if (personalWalleObj) {
|
||||
// create a personal wallet instance and auto connect it
|
||||
const personalWalletInstance =
|
||||
createWalletInstance(personalWalletObj);
|
||||
const personalWalletInstance = createWalletInstance(personalWalleObj);
|
||||
|
||||
try {
|
||||
await timeoutPromise(
|
||||
@@ -430,7 +337,7 @@ export function ThirdwebWalletProvider(
|
||||
} catch (e) {
|
||||
console.error("Failed to auto connect personal wallet");
|
||||
console.error(e);
|
||||
setStatus("disconnected");
|
||||
setConnectionStatus("disconnected");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -441,7 +348,7 @@ export function ThirdwebWalletProvider(
|
||||
};
|
||||
} else {
|
||||
// last used personal wallet is no longer present in the supported wallets
|
||||
setStatus("disconnected");
|
||||
setConnectionStatus("disconnected");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -450,7 +357,7 @@ export function ThirdwebWalletProvider(
|
||||
const wallet = createWalletInstance(walletObj);
|
||||
|
||||
try {
|
||||
setStatus("connecting");
|
||||
setConnectionStatus("connecting");
|
||||
await timeoutPromise(wallet.autoConnect(walletInfo.connectParams), {
|
||||
ms: autoConnectTimeout,
|
||||
message: autoConnectTimeoutErrorMessage,
|
||||
@@ -467,21 +374,20 @@ export function ThirdwebWalletProvider(
|
||||
LAST_CONNECTED_WALLET_STORAGE_KEY,
|
||||
);
|
||||
}
|
||||
setStatus("disconnected");
|
||||
setConnectionStatus("disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
autoConnect();
|
||||
autoconnect();
|
||||
}, [
|
||||
createWalletInstance,
|
||||
props.supportedWallets,
|
||||
setConnectedWallet,
|
||||
props.shouldAutoConnect,
|
||||
activeWallet,
|
||||
status,
|
||||
connectionStatus,
|
||||
autoConnectTimeout,
|
||||
props.signerWallet,
|
||||
setStatus,
|
||||
]);
|
||||
|
||||
const connectWallet = useCallback(
|
||||
@@ -494,12 +400,7 @@ export function ThirdwebWalletProvider(
|
||||
};
|
||||
|
||||
const wallet = createWalletInstance(WalletObj);
|
||||
if (isConnectingToPersonalWallet) {
|
||||
setPersonalWalletStatus("connecting");
|
||||
} else {
|
||||
setStatus("connecting");
|
||||
}
|
||||
|
||||
setConnectionStatus("connecting");
|
||||
try {
|
||||
// if magic is using social login - it will redirect the page - so need to save walletInfo before connecting
|
||||
// TODO: find a better way to handle this
|
||||
@@ -513,65 +414,41 @@ export function ThirdwebWalletProvider(
|
||||
setConnectedWallet(wallet, _connectedParams);
|
||||
} catch (e: any) {
|
||||
console.error(`Error connecting to wallet: ${e}`);
|
||||
if (isConnectingToPersonalWallet) {
|
||||
setPersonalWalletStatus("disconnected");
|
||||
} else {
|
||||
setStatus("disconnected");
|
||||
}
|
||||
setConnectionStatus("disconnected");
|
||||
throw e;
|
||||
}
|
||||
|
||||
return wallet;
|
||||
},
|
||||
[
|
||||
chainToConnect?.chainId,
|
||||
createWalletInstance,
|
||||
isConnectingToPersonalWallet,
|
||||
setPersonalWalletStatus,
|
||||
setConnectedWallet,
|
||||
],
|
||||
[createWalletInstance, setConnectedWallet, chainToConnect],
|
||||
);
|
||||
|
||||
const onWalletDisconnect = useCallback(async () => {
|
||||
await lastConnectedWalletStorage.removeItem(
|
||||
LAST_CONNECTED_WALLET_STORAGE_KEY,
|
||||
);
|
||||
if (isConnectingToPersonalWallet) {
|
||||
setPersonalWalletStatus("disconnected");
|
||||
setPersonalWalletSigner(undefined);
|
||||
setPersonalWallet(undefined);
|
||||
setPersonalWalletConfig(undefined);
|
||||
} else {
|
||||
setStatus("disconnected");
|
||||
setSigner(undefined);
|
||||
setActiveWallet(undefined);
|
||||
setActiveWalletConfig(undefined);
|
||||
}
|
||||
}, [
|
||||
isConnectingToPersonalWallet,
|
||||
setPersonalWallet,
|
||||
setPersonalWalletStatus,
|
||||
setPersonalWalletSigner,
|
||||
setPersonalWalletConfig,
|
||||
]);
|
||||
setConnectionStatus("disconnected");
|
||||
setSigner(undefined);
|
||||
setActiveWallet(undefined);
|
||||
setActiveWalletConfig(undefined);
|
||||
}, []);
|
||||
|
||||
const disconnectWallet = useCallback(async () => {
|
||||
const wallet = isConnectingToPersonalWallet ? personalWallet : activeWallet;
|
||||
|
||||
if (wallet) {
|
||||
const _personalWallet = wallet.getPersonalWallet();
|
||||
await wallet.disconnect();
|
||||
if (_personalWallet instanceof AbstractClientWallet) {
|
||||
await _personalWallet.disconnect();
|
||||
}
|
||||
// if disconnect is called before the wallet is connected
|
||||
if (!activeWallet) {
|
||||
onWalletDisconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
const personalWallet = activeWallet.getPersonalWallet();
|
||||
await activeWallet.disconnect();
|
||||
|
||||
if (personalWallet) {
|
||||
await (personalWallet as AbstractClientWallet)?.disconnect();
|
||||
}
|
||||
|
||||
onWalletDisconnect();
|
||||
}, [
|
||||
activeWallet,
|
||||
isConnectingToPersonalWallet,
|
||||
onWalletDisconnect,
|
||||
personalWallet,
|
||||
]);
|
||||
}, [activeWallet, onWalletDisconnect]);
|
||||
|
||||
// when wallet's network or account is changed using the extension, update UI
|
||||
useEffect(() => {
|
||||
@@ -584,20 +461,19 @@ export function ThirdwebWalletProvider(
|
||||
setSigner(_signer);
|
||||
};
|
||||
|
||||
activeWallet.addListener("change", update);
|
||||
activeWallet.addListener("disconnect", onWalletDisconnect);
|
||||
activeWallet.addListener("change", () => {
|
||||
update();
|
||||
});
|
||||
|
||||
activeWallet.addListener("disconnect", () => {
|
||||
onWalletDisconnect();
|
||||
});
|
||||
|
||||
return () => {
|
||||
activeWallet.removeListener("change", update);
|
||||
activeWallet.removeListener("disconnect", onWalletDisconnect);
|
||||
activeWallet.removeListener("change");
|
||||
activeWallet.removeListener("disconnect");
|
||||
};
|
||||
}, [
|
||||
activeWallet,
|
||||
isConnectingToPersonalWallet,
|
||||
onWalletDisconnect,
|
||||
personalWallet,
|
||||
setPersonalWalletSigner,
|
||||
setSigner,
|
||||
]);
|
||||
}, [activeWallet, onWalletDisconnect]);
|
||||
|
||||
// connect signerWallet immediately if it's passed
|
||||
// and disconnect it if it's not passed
|
||||
@@ -626,17 +502,6 @@ export function ThirdwebWalletProvider(
|
||||
disconnectWallet,
|
||||
]);
|
||||
|
||||
const setConnectionStatus = useCallback(
|
||||
(value: ConnectionStatus) => {
|
||||
if (isConnectingToPersonalWallet) {
|
||||
setPersonalWalletStatus(value);
|
||||
} else {
|
||||
setStatus(value);
|
||||
}
|
||||
},
|
||||
[isConnectingToPersonalWallet, setPersonalWalletStatus],
|
||||
);
|
||||
|
||||
return (
|
||||
<ThirdwebWalletContext.Provider
|
||||
value={{
|
||||
@@ -646,8 +511,8 @@ export function ThirdwebWalletProvider(
|
||||
signer,
|
||||
activeWallet,
|
||||
activeWalletConfig,
|
||||
connectionStatus: status,
|
||||
setConnectionStatus: setConnectionStatus,
|
||||
connectionStatus,
|
||||
setConnectionStatus,
|
||||
createWalletInstance: createWalletInstance,
|
||||
createdWalletInstance: createdWalletInstance,
|
||||
createWalletStorage: props.createWalletStorage,
|
||||
@@ -660,17 +525,6 @@ export function ThirdwebWalletProvider(
|
||||
},
|
||||
activeChainSetExplicitly: props.activeChainSetExplicitly,
|
||||
clientId: props.clientId,
|
||||
isConnectingToPersonalWallet,
|
||||
setIsConnectingToPersonalWallet,
|
||||
personalWalletInfo: {
|
||||
wallet: personalWalletConnection.wallet,
|
||||
signer: personalWalletConnection.signer,
|
||||
walletConfig: personalWalletConnection.walletConfig,
|
||||
connectionStatus: personalWalletConnection.status,
|
||||
chainId: personalWalletConnection.chainId,
|
||||
disconnect: personalWalletConnection.disconnect,
|
||||
switchChain: personalWalletConnection.switchChain,
|
||||
},
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
@@ -749,79 +603,3 @@ function timeoutPromise<T>(
|
||||
}
|
||||
|
||||
const autoConnectTimeoutErrorMessage = `Failed to Auto connect. Auto connect timed out. You can increase the timeout duration using the autoConnectTimeout prop on <ThirdwebProvider />`;
|
||||
|
||||
function usePersonalWalletConnection() {
|
||||
const [signer, setSigner] = useState<Signer | undefined>(undefined);
|
||||
const [status, setStatus] = useState<ConnectionStatus>("unknown");
|
||||
const [wallet, setWallet] = useState<WalletInstance | undefined>();
|
||||
const [walletConfig, setWalletConfig] = useState<WalletConfig | undefined>();
|
||||
const [chainId, setChainId] = useState<number | undefined>(undefined);
|
||||
|
||||
const handleDisconnect = useCallback(async () => {
|
||||
setStatus("disconnected");
|
||||
setSigner(undefined);
|
||||
setWallet(undefined);
|
||||
setWalletConfig(undefined);
|
||||
}, []);
|
||||
|
||||
const disconnect = useCallback(async () => {
|
||||
if (wallet) {
|
||||
await wallet.disconnect();
|
||||
}
|
||||
handleDisconnect();
|
||||
}, [wallet, handleDisconnect]);
|
||||
|
||||
useEffect(() => {
|
||||
if (wallet) {
|
||||
const updateChainId = () => {
|
||||
wallet?.getChainId().then((_chainId) => {
|
||||
setChainId(_chainId);
|
||||
});
|
||||
};
|
||||
|
||||
const update = async () => {
|
||||
updateChainId();
|
||||
const _signer = await wallet.getSigner();
|
||||
setSigner(_signer);
|
||||
};
|
||||
|
||||
updateChainId();
|
||||
wallet.addListener("change", update);
|
||||
wallet.addListener("disconnect", handleDisconnect);
|
||||
|
||||
return () => {
|
||||
wallet.removeListener("change", update);
|
||||
wallet.removeListener("disconnect", handleDisconnect);
|
||||
};
|
||||
} else {
|
||||
setChainId(undefined);
|
||||
}
|
||||
}, [disconnect, handleDisconnect, wallet]);
|
||||
|
||||
const switchChain = useCallback(
|
||||
async (_chainId: number) => {
|
||||
if (!wallet) {
|
||||
throw new Error("No active wallet");
|
||||
}
|
||||
|
||||
await wallet.switchChain(_chainId);
|
||||
const _signer = await wallet.getSigner();
|
||||
setSigner(_signer);
|
||||
},
|
||||
[wallet],
|
||||
);
|
||||
|
||||
return {
|
||||
signer: signer,
|
||||
setSigner: setSigner,
|
||||
wallet: wallet,
|
||||
setWallet: setWallet,
|
||||
walletConfig: walletConfig,
|
||||
setWalletConfig: setWalletConfig,
|
||||
status: status,
|
||||
setStatus: setStatus,
|
||||
chainId: chainId,
|
||||
disconnect,
|
||||
switchChain,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# @thirdweb-dev/react-native-compat
|
||||
|
||||
## 0.4.10
|
||||
|
||||
## 0.4.9
|
||||
|
||||
## 0.4.8
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native-compat",
|
||||
"description": "Shims for Thirdweb in React Native Projects",
|
||||
"version": "0.4.9",
|
||||
"version": "0.4.10",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# @thirdweb-dev/react-native
|
||||
|
||||
## 0.4.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1994](https://github.com/thirdweb-dev/js/pull/1994) [`68288436`](https://github.com/thirdweb-dev/js/commit/68288436acd62256be561395743762965888449d) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Remove `overrides` props from Web3ButtonProps
|
||||
|
||||
- Updated dependencies [[`4bb8f5b1`](https://github.com/thirdweb-dev/js/commit/4bb8f5b15e58de39c5edccc7476da3e4907d7688), [`47b0ed51`](https://github.com/thirdweb-dev/js/commit/47b0ed5171be5608ae23c19481a1b04948443c6a), [`d4ce855e`](https://github.com/thirdweb-dev/js/commit/d4ce855e5f5e6c4206a3efa250e92e690ae87281), [`b5bbe2bd`](https://github.com/thirdweb-dev/js/commit/b5bbe2bd438179c38451bc2cfa20a54fc79e4f3a)]:
|
||||
- @thirdweb-dev/react-core@4.1.10
|
||||
- @thirdweb-dev/chains@0.1.59
|
||||
- @thirdweb-dev/wallets@2.1.9
|
||||
- @thirdweb-dev/sdk@4.0.17
|
||||
|
||||
## 0.4.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native",
|
||||
"version": "0.4.9",
|
||||
"version": "0.4.10",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
useWallet,
|
||||
} from "@thirdweb-dev/react-core";
|
||||
import type { SmartContract } from "@thirdweb-dev/sdk";
|
||||
import type { CallOverrides, ContractInterface } from "ethers";
|
||||
import type { ContractInterface } from "ethers";
|
||||
import { PropsWithChildren, useEffect } from "react";
|
||||
import { ActivityIndicator, StyleSheet } from "react-native";
|
||||
import invariant from "tiny-invariant";
|
||||
@@ -26,7 +26,6 @@ interface Web3ButtonProps<TActionFn extends ActionFn> {
|
||||
contractAddress: `0x${string}` | `${string}.eth` | string;
|
||||
contractAbi?: ContractInterface;
|
||||
|
||||
overrides?: CallOverrides;
|
||||
// called with the result
|
||||
onSuccess?: (result: Awaited<ReturnType<TActionFn>>) => void;
|
||||
// called with any error that might happen
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 4.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1996](https://github.com/thirdweb-dev/js/pull/1996) [`4bb8f5b1`](https://github.com/thirdweb-dev/js/commit/4bb8f5b15e58de39c5edccc7476da3e4907d7688) Thanks [@MananTank](https://github.com/MananTank)! - Revert commit fb0cb676b996fe386dcc53b5a6dab03f88e76175
|
||||
|
||||
- [#1994](https://github.com/thirdweb-dev/js/pull/1994) [`68288436`](https://github.com/thirdweb-dev/js/commit/68288436acd62256be561395743762965888449d) Thanks [@kien-ngo](https://github.com/kien-ngo)! - Remove `overrides` props from Web3ButtonProps
|
||||
|
||||
- Updated dependencies [[`4bb8f5b1`](https://github.com/thirdweb-dev/js/commit/4bb8f5b15e58de39c5edccc7476da3e4907d7688), [`47b0ed51`](https://github.com/thirdweb-dev/js/commit/47b0ed5171be5608ae23c19481a1b04948443c6a), [`d4ce855e`](https://github.com/thirdweb-dev/js/commit/d4ce855e5f5e6c4206a3efa250e92e690ae87281), [`b5bbe2bd`](https://github.com/thirdweb-dev/js/commit/b5bbe2bd438179c38451bc2cfa20a54fc79e4f3a)]:
|
||||
- @thirdweb-dev/react-core@4.1.10
|
||||
- @thirdweb-dev/chains@0.1.59
|
||||
- @thirdweb-dev/wallets@2.1.9
|
||||
- @thirdweb-dev/sdk@4.0.17
|
||||
|
||||
## 4.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "4.1.9",
|
||||
"version": "4.1.10",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
useConnectionStatus,
|
||||
} from "@thirdweb-dev/react-core";
|
||||
import type { SmartContract } from "@thirdweb-dev/sdk";
|
||||
import type { CallOverrides, ContractInterface } from "ethers";
|
||||
import type { ContractInterface } from "ethers";
|
||||
import { PropsWithChildren, useState } from "react";
|
||||
import invariant from "tiny-invariant";
|
||||
import {
|
||||
@@ -35,7 +35,6 @@ interface Web3ButtonProps<TActionFn extends ActionFn> {
|
||||
contractAddress: `0x${string}` | `${string}.eth` | string;
|
||||
contractAbi?: ContractInterface;
|
||||
|
||||
overrides?: CallOverrides;
|
||||
// called with the result
|
||||
onSuccess?: (result: Awaited<ReturnType<TActionFn>>) => void;
|
||||
// called with any error that might happen
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
export {
|
||||
ConnectEmbed,
|
||||
type ConnectEmbedProps,
|
||||
} from "../wallet/ConnectWallet/Modal/ConnectEmbed";
|
||||
|
||||
export {
|
||||
useIsWalletModalOpen,
|
||||
useSetIsWalletModalOpen,
|
||||
@@ -15,10 +10,7 @@ export {
|
||||
ConnectWallet,
|
||||
type ConnectWalletProps,
|
||||
} from "../wallet/ConnectWallet/ConnectWallet";
|
||||
export {
|
||||
ConnectModalInline,
|
||||
type ConnectModalInlineProps,
|
||||
} from "../wallet/ConnectWallet/Modal/ConnectModalInline";
|
||||
export { ConnectModalInline } from "../wallet/ConnectWallet/Modal/ConnectModalInline";
|
||||
|
||||
export { NetworkSelector } from "../wallet/ConnectWallet/NetworkSelector";
|
||||
export type { NetworkSelectorProps } from "../wallet/ConnectWallet/NetworkSelector";
|
||||
|
||||
@@ -52,7 +52,6 @@ export function enDefault() {
|
||||
personalWallet: "Personal Wallet",
|
||||
smartWallet: "Smart Wallet",
|
||||
or: "OR",
|
||||
goBackButton: "Back",
|
||||
download: {
|
||||
chrome: "Download Chrome Extension",
|
||||
android: "Download on Google Play",
|
||||
|
||||
@@ -54,7 +54,6 @@ export function esDefault(): ThirdwebLocale {
|
||||
personalWallet: "Cartera personal",
|
||||
smartWallet: "Cartera inteligente",
|
||||
or: "O",
|
||||
goBackButton: "Atras",
|
||||
download: {
|
||||
chrome: "Descargar extensión para Chrome",
|
||||
android: "Descargar en Google Play",
|
||||
|
||||
@@ -53,7 +53,6 @@ export function jaDefault(): ThirdwebLocale {
|
||||
personalWallet: "パーソナルウォレット",
|
||||
smartWallet: "スマートウォレット",
|
||||
or: "または",
|
||||
goBackButton: "戻る", // TODO - check translation
|
||||
download: {
|
||||
chrome: "Chrome拡張をダウンロード",
|
||||
android: "Google Playでダウンロード",
|
||||
|
||||
@@ -20,7 +20,6 @@ export type ModalConfig = {
|
||||
onLogin?: (token: string) => void;
|
||||
onLogout?: () => void;
|
||||
};
|
||||
isEmbed?: boolean;
|
||||
};
|
||||
|
||||
const WalletModalOpen = /* @__PURE__ */ createContext(false);
|
||||
@@ -48,7 +47,6 @@ export const WalletUIStatesProvider = (
|
||||
termsOfServiceUrl?: string;
|
||||
privacyPolicyUrl?: string;
|
||||
welcomeScreen?: WelcomeScreen;
|
||||
isEmbed?: boolean;
|
||||
}>,
|
||||
) => {
|
||||
const [isWalletModalOpen, setIsWalletModalOpen] = useState(false);
|
||||
@@ -64,7 +62,6 @@ export const WalletUIStatesProvider = (
|
||||
privacyPolicyUrl: props.privacyPolicyUrl,
|
||||
welcomeScreen: props.welcomeScreen,
|
||||
titleIconUrl: props.titleIconUrl,
|
||||
isEmbed: props.isEmbed,
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
import {
|
||||
SetModalConfigCtx,
|
||||
WalletUIStatesProvider,
|
||||
} from "../../../evm/providers/wallet-ui-states-provider";
|
||||
import { modalMaxWidthCompact, defaultTheme } from "../constants";
|
||||
import { ConnectModalContent } from "./ConnectModal";
|
||||
import { useScreen } from "./screen";
|
||||
import { isMobile } from "../../../evm/utils/isMobile";
|
||||
import { useConnectionStatus } from "@thirdweb-dev/react-core";
|
||||
import { DynamicHeight } from "../../../components/DynamicHeight";
|
||||
import {
|
||||
CustomThemeProvider,
|
||||
useCustomTheme,
|
||||
} from "../../../design-system/CustomThemeProvider";
|
||||
import { ComponentProps, useContext, useEffect } from "react";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { StyledDiv } from "../../../design-system/elements";
|
||||
import { Theme, radius } from "../../../design-system";
|
||||
|
||||
export type ConnectEmbedProps = {
|
||||
className?: string;
|
||||
theme?: "dark" | "light" | Theme;
|
||||
|
||||
style?: React.CSSProperties;
|
||||
|
||||
/**
|
||||
* If provided, Embed will show a Terms of Service message at the bottom with below link
|
||||
*/
|
||||
termsOfServiceUrl?: string;
|
||||
|
||||
/**
|
||||
* If provided, Embed will show a Privacy Policy message at the bottom with below link
|
||||
*/
|
||||
privacyPolicyUrl?: string;
|
||||
};
|
||||
export const ConnectEmbed = (props: ConnectEmbedProps) => {
|
||||
const connectionStatus = useConnectionStatus();
|
||||
|
||||
if (connectionStatus === "connected") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <ConnectEmbedContent {...props} />;
|
||||
};
|
||||
|
||||
const ConnectEmbedContent = (props: ConnectEmbedProps) => {
|
||||
const { screen, setScreen, initialScreen } = useScreen();
|
||||
const modalSize = "compact" as const;
|
||||
|
||||
const content = (
|
||||
<ConnectModalContent
|
||||
initialScreen={initialScreen}
|
||||
screen={screen}
|
||||
setScreen={setScreen}
|
||||
setHideModal={() => {
|
||||
// no op
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const walletUIStatesProps = {
|
||||
theme: props.theme || defaultTheme,
|
||||
modalSize: modalSize,
|
||||
title: undefined,
|
||||
termsOfServiceUrl: props.termsOfServiceUrl,
|
||||
privacyPolicyUrl: props.privacyPolicyUrl,
|
||||
isEmbed: true,
|
||||
};
|
||||
|
||||
return (
|
||||
<WalletUIStatesProvider {...walletUIStatesProps}>
|
||||
<CustomThemeProvider theme={walletUIStatesProps.theme}>
|
||||
<EmbedContainer
|
||||
className={props.className}
|
||||
style={{
|
||||
height: "auto",
|
||||
maxWidth: modalMaxWidthCompact,
|
||||
...props.style,
|
||||
}}
|
||||
>
|
||||
<DynamicHeight> {content} </DynamicHeight>
|
||||
<SyncedWalletUIStates {...walletUIStatesProps} />
|
||||
</EmbedContainer>
|
||||
</CustomThemeProvider>
|
||||
</WalletUIStatesProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export function SyncedWalletUIStates(
|
||||
props: ComponentProps<typeof WalletUIStatesProvider>,
|
||||
) {
|
||||
const setModalConfig = useContext(SetModalConfigCtx);
|
||||
const locale = useTWLocale();
|
||||
|
||||
// update modalConfig on props change
|
||||
useEffect(() => {
|
||||
setModalConfig((c) => ({
|
||||
...c,
|
||||
title: props.title || locale.connectWallet.defaultModalTitle,
|
||||
theme: props.theme || "dark",
|
||||
modalSize: (isMobile() ? "compact" : props.modalSize) || "wide",
|
||||
termsOfServiceUrl: props.termsOfServiceUrl,
|
||||
privacyPolicyUrl: props.privacyPolicyUrl,
|
||||
welcomeScreen: props.welcomeScreen,
|
||||
titleIconUrl: props.titleIconUrl,
|
||||
}));
|
||||
}, [
|
||||
props.title,
|
||||
props.theme,
|
||||
props.modalSize,
|
||||
props.termsOfServiceUrl,
|
||||
props.privacyPolicyUrl,
|
||||
props.welcomeScreen,
|
||||
props.titleIconUrl,
|
||||
setModalConfig,
|
||||
locale.connectWallet.defaultModalTitle,
|
||||
]);
|
||||
|
||||
return <WalletUIStatesProvider {...props} />;
|
||||
}
|
||||
|
||||
const EmbedContainer = /* @__PURE__ */ StyledDiv(() => {
|
||||
const theme = useCustomTheme();
|
||||
return {
|
||||
color: theme.colors.primaryText,
|
||||
background: theme.colors.modalBg,
|
||||
width: "100%",
|
||||
boxSizing: "border-box",
|
||||
position: "relative",
|
||||
lineHeight: "normal",
|
||||
borderRadius: radius.xl,
|
||||
border: `1px solid ${theme.colors.borderColor}`,
|
||||
overflow: "hidden",
|
||||
fontFamily: theme.fontFamily,
|
||||
"& *::selection": {
|
||||
backgroundColor: theme.colors.primaryText,
|
||||
color: theme.colors.modalBg,
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
useThirdwebAuthContext,
|
||||
useUser,
|
||||
useWallet,
|
||||
useWalletContext,
|
||||
useWallets,
|
||||
} from "@thirdweb-dev/react-core";
|
||||
import {
|
||||
@@ -44,8 +43,6 @@ export const ConnectModalContent = (props: {
|
||||
const walletConfigs = useWallets();
|
||||
const connectionStatus = useConnectionStatus();
|
||||
const disconnect = useDisconnect();
|
||||
const { setIsConnectingToPersonalWallet, personalWalletInfo } =
|
||||
useWalletContext();
|
||||
|
||||
const isWalletModalOpen = useIsWalletModalOpen();
|
||||
const setIsWalletModalOpen = useSetIsWalletModalOpen();
|
||||
@@ -62,9 +59,6 @@ export const ConnectModalContent = (props: {
|
||||
const authConfig = useThirdwebAuthContext();
|
||||
|
||||
const closeModal = () => {
|
||||
personalWalletInfo.disconnect();
|
||||
setIsConnectingToPersonalWallet(false);
|
||||
|
||||
setIsWalletModalOpen(false);
|
||||
onModalUnmount(() => {
|
||||
setScreen(initialScreen);
|
||||
@@ -72,7 +66,6 @@ export const ConnectModalContent = (props: {
|
||||
};
|
||||
|
||||
const { setHideModal } = props;
|
||||
|
||||
const handleConnected = useCallback(() => {
|
||||
const requiresSignIn = modalConfig.auth?.loginOptional
|
||||
? false
|
||||
@@ -268,9 +261,6 @@ export const ConnectModal = () => {
|
||||
wallet,
|
||||
]);
|
||||
|
||||
const { setIsConnectingToPersonalWallet, personalWalletInfo } =
|
||||
useWalletContext();
|
||||
|
||||
return (
|
||||
<CustomThemeProvider theme={theme}>
|
||||
<Modal
|
||||
@@ -280,9 +270,6 @@ export const ConnectModal = () => {
|
||||
setOpen={(value) => {
|
||||
setIsWalletModalOpen(value);
|
||||
if (!value) {
|
||||
setIsConnectingToPersonalWallet(false);
|
||||
personalWalletInfo.disconnect();
|
||||
|
||||
const requiresSignIn = auth?.loginOptional
|
||||
? false
|
||||
: !!authConfig?.authUrl && !user?.address;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Cross2Icon } from "@radix-ui/react-icons";
|
||||
import { CrossContainer } from "../../../components/Modal";
|
||||
import { IconButton } from "../../../components/buttons";
|
||||
import { Theme, iconSize, radius, shadow } from "../../../design-system";
|
||||
import { WalletUIStatesProvider } from "../../../evm/providers/wallet-ui-states-provider";
|
||||
import { iconSize, radius, shadow } from "../../../design-system";
|
||||
import {
|
||||
SetModalConfigCtx,
|
||||
WalletUIStatesProvider,
|
||||
} from "../../../evm/providers/wallet-ui-states-provider";
|
||||
import {
|
||||
wideModalMaxHeight,
|
||||
modalMaxWidthCompact,
|
||||
@@ -17,65 +20,26 @@ import {
|
||||
CustomThemeProvider,
|
||||
useCustomTheme,
|
||||
} from "../../../design-system/CustomThemeProvider";
|
||||
import { ComponentProps, useContext, useEffect } from "react";
|
||||
import { ConnectWalletProps } from "../ConnectWallet";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { StyledDiv } from "../../../design-system/elements";
|
||||
import { SyncedWalletUIStates } from "./ConnectEmbed";
|
||||
import { WelcomeScreen } from "../screens/types";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type ConnectModalInlineProps = {
|
||||
className?: string;
|
||||
theme?: "dark" | "light" | Theme;
|
||||
|
||||
/**
|
||||
* Set a custom title for the modal
|
||||
* @defaultValue "Connect"
|
||||
*/
|
||||
modalTitle?: string;
|
||||
|
||||
/**
|
||||
* Replace the thirdweb icon next to modalTitle and set your own iconUrl
|
||||
*
|
||||
* Set to empty string to hide the icon
|
||||
*/
|
||||
modalTitleIconUrl?: string;
|
||||
|
||||
style?: React.CSSProperties;
|
||||
|
||||
/**
|
||||
* Set the size of the modal - `compact` or `wide` on desktop
|
||||
*
|
||||
* Modal size is always `compact` on mobile
|
||||
*
|
||||
* @defaultValue "wide"
|
||||
*/
|
||||
modalSize?: "compact" | "wide";
|
||||
|
||||
/**
|
||||
* If provided, Modal will show a Terms of Service message at the bottom with below link
|
||||
*/
|
||||
termsOfServiceUrl?: string;
|
||||
|
||||
/**
|
||||
* If provided, Modal will show a Privacy Policy message at the bottom with below link
|
||||
*/
|
||||
privacyPolicyUrl?: string;
|
||||
|
||||
/**
|
||||
* Customize the welcome screen
|
||||
*
|
||||
* Either provide a component to replace the default screen entirely
|
||||
*
|
||||
* or an object with title, subtitle and imgSrc to change the content of the default screen
|
||||
*/
|
||||
welcomeScreen?: WelcomeScreen;
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const ConnectModalInline = (props: ConnectModalInlineProps) => {
|
||||
export const ConnectModalInline = (
|
||||
props: Omit<
|
||||
ConnectWalletProps,
|
||||
| "detailsBtn"
|
||||
| "dropdownPosition"
|
||||
| "auth"
|
||||
| "networkSelector"
|
||||
| "hideTestnetFaucet"
|
||||
| "switchToActiveChain"
|
||||
| "supportedTokens"
|
||||
| "hideSwitchToPersonalWallet"
|
||||
> & {
|
||||
onModalHide?: () => void;
|
||||
},
|
||||
) => {
|
||||
const { screen, setScreen, initialScreen } = useScreen();
|
||||
const walletConfigs = useWallets();
|
||||
const modalSize =
|
||||
@@ -89,7 +53,9 @@ export const ConnectModalInline = (props: ConnectModalInlineProps) => {
|
||||
screen={screen}
|
||||
setScreen={setScreen}
|
||||
setHideModal={() => {
|
||||
// no op
|
||||
if (props.onModalHide) {
|
||||
props.onModalHide();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -129,10 +95,9 @@ export const ConnectModalInline = (props: ConnectModalInlineProps) => {
|
||||
modalSize === "compact"
|
||||
? modalMaxWidthCompact
|
||||
: modalMaxWidthWide,
|
||||
...props.style,
|
||||
}}
|
||||
>
|
||||
{modalSize === "compact" ? (
|
||||
{props.modalSize === "compact" ? (
|
||||
<DynamicHeight> {content} </DynamicHeight>
|
||||
) : (
|
||||
content
|
||||
@@ -144,6 +109,39 @@ export const ConnectModalInline = (props: ConnectModalInlineProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
function SyncedWalletUIStates(
|
||||
props: ComponentProps<typeof WalletUIStatesProvider>,
|
||||
) {
|
||||
const setModalConfig = useContext(SetModalConfigCtx);
|
||||
const locale = useTWLocale();
|
||||
|
||||
// update modalConfig on props change
|
||||
useEffect(() => {
|
||||
setModalConfig((c) => ({
|
||||
...c,
|
||||
title: props.title || locale.connectWallet.defaultModalTitle,
|
||||
theme: props.theme || "dark",
|
||||
modalSize: (isMobile() ? "compact" : props.modalSize) || "wide",
|
||||
termsOfServiceUrl: props.termsOfServiceUrl,
|
||||
privacyPolicyUrl: props.privacyPolicyUrl,
|
||||
welcomeScreen: props.welcomeScreen,
|
||||
titleIconUrl: props.titleIconUrl,
|
||||
}));
|
||||
}, [
|
||||
props.title,
|
||||
props.theme,
|
||||
props.modalSize,
|
||||
props.termsOfServiceUrl,
|
||||
props.privacyPolicyUrl,
|
||||
props.welcomeScreen,
|
||||
props.titleIconUrl,
|
||||
setModalConfig,
|
||||
locale.connectWallet.defaultModalTitle,
|
||||
]);
|
||||
|
||||
return <WalletUIStatesProvider {...props} />;
|
||||
}
|
||||
|
||||
const ConnectModalInlineContainer = /* @__PURE__ */ StyledDiv(() => {
|
||||
const theme = useCustomTheme();
|
||||
return {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
ScreenBottomContainer,
|
||||
Line,
|
||||
} from "../../components/basic";
|
||||
import { Button, IconButton } from "../../components/buttons";
|
||||
import { Button } from "../../components/buttons";
|
||||
import { ModalTitle } from "../../components/modalElements";
|
||||
import { iconSize, radius, spacing } from "../../design-system";
|
||||
import {
|
||||
@@ -26,7 +26,6 @@ import { Spacer } from "../../components/Spacer";
|
||||
import { TextDivider } from "../../components/TextDivider";
|
||||
import { TOS } from "./Modal/TOS";
|
||||
import { useTWLocale } from "../../evm/providers/locale-provider";
|
||||
import { ChevronLeftIcon } from "@radix-ui/react-icons";
|
||||
import { StyledButton, StyledUl } from "../../design-system/elements";
|
||||
import { useCustomTheme } from "../../design-system/CustomThemeProvider";
|
||||
|
||||
@@ -344,62 +343,28 @@ export const WalletSelector: React.FC<{
|
||||
return (
|
||||
<Container scrollY flex="column" animate="fadein" fullHeight>
|
||||
{/* Header */}
|
||||
{!modalConfig.isEmbed && (
|
||||
<Container p="lg">
|
||||
{isWalletGroupExpanded ? (
|
||||
<ModalHeader
|
||||
title={twTitle}
|
||||
onBack={() => {
|
||||
setIsWalletGroupExpanded(false);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
twTitle
|
||||
)}
|
||||
</Container>
|
||||
)}
|
||||
<Container p="lg">
|
||||
{isWalletGroupExpanded ? (
|
||||
<ModalHeader
|
||||
title={twTitle}
|
||||
onBack={() => {
|
||||
setIsWalletGroupExpanded(false);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
twTitle
|
||||
)}
|
||||
</Container>
|
||||
|
||||
{/* Body */}
|
||||
<Container
|
||||
expand
|
||||
scrollY
|
||||
px="md"
|
||||
style={
|
||||
modalConfig.isEmbed
|
||||
? {
|
||||
paddingTop: spacing.lg,
|
||||
}
|
||||
: {
|
||||
paddingTop: "2px",
|
||||
}
|
||||
}
|
||||
style={{
|
||||
paddingTop: "2px",
|
||||
}}
|
||||
>
|
||||
{modalConfig.isEmbed && isWalletGroupExpanded && (
|
||||
<Container
|
||||
flex="row"
|
||||
center="y"
|
||||
style={{
|
||||
padding: spacing.sm,
|
||||
paddingTop: 0,
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
setIsWalletGroupExpanded(false);
|
||||
}}
|
||||
style={{
|
||||
gap: spacing.xxs,
|
||||
transform: `translateX(-${spacing.xs})`,
|
||||
paddingBlock: spacing.xxs,
|
||||
paddingRight: spacing.xs,
|
||||
}}
|
||||
>
|
||||
<ChevronLeftIcon width={iconSize.sm} height={iconSize.sm} />
|
||||
{locale.goBackButton}
|
||||
</IconButton>
|
||||
</Container>
|
||||
)}
|
||||
|
||||
{topSection}
|
||||
</Container>
|
||||
|
||||
|
||||
@@ -11,10 +11,13 @@ import {
|
||||
ExclamationTriangleIcon,
|
||||
} from "@radix-ui/react-icons";
|
||||
import {
|
||||
useChain,
|
||||
useChainId,
|
||||
useConnect,
|
||||
useConnectionStatus,
|
||||
useSupportedChains,
|
||||
useWalletContext,
|
||||
useSwitchChain,
|
||||
useWallet,
|
||||
} from "@thirdweb-dev/react-core";
|
||||
import { SafeSupportedChainsSet } from "@thirdweb-dev/wallets";
|
||||
import { utils } from "ethers";
|
||||
@@ -35,24 +38,22 @@ export const SelectAccount: React.FC<{
|
||||
renderBackButton?: boolean;
|
||||
}> = (props) => {
|
||||
const locale = useTWLocale().wallets.safeWallet.accountDetailsScreen;
|
||||
const activeWallet = useWallet();
|
||||
const connect = useConnect();
|
||||
const activeChain = useChain();
|
||||
const connectedChainId = useChainId();
|
||||
|
||||
// personal wallet
|
||||
const { personalWalletInfo } = useWalletContext();
|
||||
const personalWallet = personalWalletInfo?.wallet;
|
||||
const personalWalletChainId = personalWalletInfo?.chainId;
|
||||
const switchChainPersonalWallet = personalWalletInfo?.switchChain;
|
||||
const [safeAddress, setSafeAddress] = useState("");
|
||||
const [safeChainId, setSafeChainId] = useState(-1);
|
||||
|
||||
const [safeConnectError, setSafeConnectError] = useState(false);
|
||||
const [switchError, setSwitchError] = useState(false);
|
||||
const [switchingNetwork, setSwitchingNetwork] = useState(false);
|
||||
|
||||
// safe
|
||||
const connectSafe = useConnect();
|
||||
const [safeAddress, setSafeAddress] = useState("");
|
||||
const [safeChainId, setSafeChainId] = useState(-1);
|
||||
const [safeConnectError, setSafeConnectError] = useState(false);
|
||||
const connectionStatus = useConnectionStatus();
|
||||
|
||||
const chains = useSupportedChains();
|
||||
|
||||
// put supported chains first
|
||||
const supportedChains = chains.filter((c) =>
|
||||
SafeSupportedChainsSet.has(c.chainId),
|
||||
);
|
||||
@@ -68,14 +69,15 @@ export const SelectAccount: React.FC<{
|
||||
const useOptGroup = mainnets.length > 0 && testnets.length > 0;
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!selectedSafeChain || !personalWallet) {
|
||||
if (!selectedSafeChain || !activeWallet || !activeChain) {
|
||||
return;
|
||||
}
|
||||
setSafeConnectError(false);
|
||||
|
||||
try {
|
||||
await connectSafe(props.safeWalletConfig, {
|
||||
await connect(props.safeWalletConfig, {
|
||||
chain: selectedSafeChain,
|
||||
personalWallet: personalWallet,
|
||||
personalWallet: activeWallet,
|
||||
safeAddress,
|
||||
});
|
||||
props.onConnect();
|
||||
@@ -85,11 +87,12 @@ export const SelectAccount: React.FC<{
|
||||
}
|
||||
};
|
||||
|
||||
const mismatch = safeChainId !== -1 && personalWalletChainId !== safeChainId;
|
||||
const mismatch = safeChainId !== -1 && connectedChainId !== safeChainId;
|
||||
|
||||
const isValidAddress = utils.isAddress(safeAddress);
|
||||
const disableNetworkSelection = supportedChains.length === 1;
|
||||
|
||||
const switchChain = useSwitchChain();
|
||||
const modalConfig = useContext(ModalConfigCtx);
|
||||
|
||||
return (
|
||||
@@ -323,14 +326,14 @@ export const SelectAccount: React.FC<{
|
||||
width: modalConfig.modalSize === "compact" ? "100%" : undefined,
|
||||
}}
|
||||
onClick={async () => {
|
||||
if (!personalWallet) {
|
||||
throw new Error("No personal wallet connected");
|
||||
if (!activeWallet) {
|
||||
throw new Error("No active wallet");
|
||||
}
|
||||
setSafeConnectError(false);
|
||||
setSwitchError(false);
|
||||
setSwitchingNetwork(true);
|
||||
try {
|
||||
await switchChainPersonalWallet(safeChainId);
|
||||
await switchChain(safeChainId);
|
||||
} catch (e) {
|
||||
setSwitchError(true);
|
||||
} finally {
|
||||
|
||||
@@ -3,10 +3,11 @@ import {
|
||||
WalletConfig,
|
||||
ConnectUIProps,
|
||||
WalletOptions,
|
||||
useWalletContext,
|
||||
useDisconnect,
|
||||
useWallet,
|
||||
} from "@thirdweb-dev/react-core";
|
||||
import { defaultWallets } from "../defaultWallets";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { SelectpersonalWallet } from "./SelectPersonalWallet";
|
||||
import type { SafeWalletConfigOptions, SafeWalletConfig } from "./types";
|
||||
import { SelectAccount } from "./SelectAccount";
|
||||
@@ -43,57 +44,19 @@ export const safeWallet = (
|
||||
export const SafeConnectUI = (
|
||||
props: ConnectUIProps<SafeWallet> & { personalWallets: WalletConfig[] },
|
||||
) => {
|
||||
// selected personal wallet config
|
||||
const activeWallet = useWallet();
|
||||
const [personalWalletConfig, setPersonalWalletConfig] = useState<
|
||||
WalletConfig | undefined
|
||||
>();
|
||||
const disconnect = useDisconnect();
|
||||
|
||||
const [isPersonalWalletConnected, setIsPersonalWalletConnected] =
|
||||
useState(false);
|
||||
|
||||
const { setIsConnectingToPersonalWallet, personalWalletInfo } =
|
||||
useWalletContext();
|
||||
|
||||
const goBackToMain = () => {
|
||||
personalWalletInfo.disconnect();
|
||||
setIsConnectingToPersonalWallet(false);
|
||||
props.goBack();
|
||||
};
|
||||
|
||||
const mounted = useRef(false);
|
||||
useEffect(() => {
|
||||
if (mounted.current) {
|
||||
return;
|
||||
}
|
||||
mounted.current = true;
|
||||
setIsConnectingToPersonalWallet(true);
|
||||
}, [setIsConnectingToPersonalWallet]);
|
||||
|
||||
// if personal wallet is not selected
|
||||
if (!personalWalletConfig) {
|
||||
return (
|
||||
<SelectpersonalWallet
|
||||
personalWallets={props.personalWallets}
|
||||
onBack={goBackToMain}
|
||||
safeWallet={props.walletConfig}
|
||||
selectWallet={(walletConfig) => {
|
||||
setPersonalWalletConfig(walletConfig);
|
||||
}}
|
||||
renderBackButton={props.supportedWallets.length > 1}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// if the personal wallet is selected, but not connected
|
||||
if (!isPersonalWalletConnected) {
|
||||
if (personalWalletConfig) {
|
||||
const _props: ConnectUIProps = {
|
||||
goBack: () => {
|
||||
setIsPersonalWalletConnected(false);
|
||||
setPersonalWalletConfig(undefined);
|
||||
},
|
||||
connected() {
|
||||
setIsPersonalWalletConnected(true);
|
||||
setIsConnectingToPersonalWallet(false);
|
||||
setPersonalWalletConfig(undefined);
|
||||
},
|
||||
isOpen: props.isOpen,
|
||||
hide: props.hide,
|
||||
@@ -113,11 +76,25 @@ export const SafeConnectUI = (
|
||||
return <HeadlessConnectUI {..._props} />;
|
||||
}
|
||||
|
||||
// if personal wallet is selected and connected
|
||||
if (!activeWallet) {
|
||||
return (
|
||||
<SelectpersonalWallet
|
||||
personalWallets={props.personalWallets}
|
||||
onBack={props.goBack}
|
||||
safeWallet={props.walletConfig}
|
||||
selectWallet={setPersonalWalletConfig}
|
||||
renderBackButton={props.supportedWallets.length > 1}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<SelectAccount
|
||||
renderBackButton={props.supportedWallets.length > 1}
|
||||
onBack={goBackToMain}
|
||||
onBack={() => {
|
||||
disconnect();
|
||||
props.goBack();
|
||||
}}
|
||||
onConnect={props.connected}
|
||||
safeWalletConfig={props.walletConfig}
|
||||
/>
|
||||
|
||||
@@ -4,9 +4,13 @@ import { Button } from "../../../components/buttons";
|
||||
import { iconSize, spacing, fontSize } from "../../../design-system";
|
||||
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
useChain,
|
||||
useConnect,
|
||||
useConnectionStatus,
|
||||
useNetworkMismatch,
|
||||
useWalletContext,
|
||||
useWallet,
|
||||
useSwitchChain,
|
||||
WalletConfig,
|
||||
} from "@thirdweb-dev/react-core";
|
||||
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
||||
@@ -20,32 +24,31 @@ export const SmartWalletConnecting: React.FC<{
|
||||
onBack: () => void;
|
||||
onConnect: () => void;
|
||||
smartWallet: SmartWalletConfig;
|
||||
personalWalletConfig: WalletConfig;
|
||||
personalWallet: WalletConfig;
|
||||
}> = (props) => {
|
||||
const locale = useTWLocale().wallets.smartWallet;
|
||||
const activeWallet = useWallet(); // personal wallet
|
||||
|
||||
// personal wallet
|
||||
const { personalWalletInfo } = useWalletContext();
|
||||
const personalWallet = personalWalletInfo?.wallet;
|
||||
const personalWalletChainId = personalWalletInfo?.chainId;
|
||||
const connect = useConnect();
|
||||
const connectedChain = useChain();
|
||||
const targetChain = useWalletContext().activeChain;
|
||||
|
||||
const mismatch = useNetworkMismatch();
|
||||
|
||||
const [connectError, setConnectError] = useState(false);
|
||||
const [switchError, setSwitchError] = useState(false);
|
||||
const switchPersonalWalletChain = personalWalletInfo.switchChain;
|
||||
const [switchingNetwork, setSwitchingNetwork] = useState(false);
|
||||
|
||||
// smart wallet
|
||||
const connect = useConnect();
|
||||
const targetChain = useWalletContext().activeChain;
|
||||
const mismatch = targetChain.chainId !== personalWalletChainId;
|
||||
const [connectError, setConnectError] = useState(false);
|
||||
const connectionStatus = useConnectionStatus();
|
||||
|
||||
const { onConnect } = props;
|
||||
const connectStarted = useRef(false);
|
||||
|
||||
const switchChain = useSwitchChain();
|
||||
const modalSize = useContext(ModalConfigCtx).modalSize;
|
||||
|
||||
const handleConnect = useCallback(async () => {
|
||||
if (!personalWallet || !personalWalletChainId || connectStarted.current) {
|
||||
if (!activeWallet || !connectedChain || connectStarted.current) {
|
||||
return;
|
||||
}
|
||||
setConnectError(false);
|
||||
@@ -53,26 +56,20 @@ export const SmartWalletConnecting: React.FC<{
|
||||
try {
|
||||
connectStarted.current = true;
|
||||
await connect(props.smartWallet, {
|
||||
personalWallet: personalWallet,
|
||||
personalWallet: activeWallet,
|
||||
});
|
||||
onConnect();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setConnectError(true);
|
||||
}
|
||||
}, [
|
||||
personalWallet,
|
||||
personalWalletChainId,
|
||||
connect,
|
||||
props.smartWallet,
|
||||
onConnect,
|
||||
]);
|
||||
}, [activeWallet, connectedChain, connect, props.smartWallet, onConnect]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mismatch) {
|
||||
handleConnect();
|
||||
}
|
||||
}, [mismatch, handleConnect, personalWallet, personalWalletChainId]);
|
||||
}, [mismatch, handleConnect, activeWallet, connectedChain]);
|
||||
|
||||
if (!connectError && (connectionStatus === "connecting" || !mismatch)) {
|
||||
return (
|
||||
@@ -114,8 +111,8 @@ export const SmartWalletConnecting: React.FC<{
|
||||
<Container fullHeight animate="fadein" flex="column">
|
||||
<Container p="lg">
|
||||
<ModalHeader
|
||||
title={props.personalWalletConfig.meta.name}
|
||||
imgSrc={props.personalWalletConfig.meta.iconURL}
|
||||
title={props.personalWallet.meta.name}
|
||||
imgSrc={props.personalWallet.meta.iconURL}
|
||||
onBack={props.onBack}
|
||||
/>
|
||||
</Container>
|
||||
@@ -153,14 +150,14 @@ export const SmartWalletConnecting: React.FC<{
|
||||
gap: spacing.sm,
|
||||
}}
|
||||
onClick={async () => {
|
||||
if (!personalWallet) {
|
||||
if (!activeWallet) {
|
||||
throw new Error("No active wallet");
|
||||
}
|
||||
setConnectError(false);
|
||||
setSwitchError(false);
|
||||
setSwitchingNetwork(true);
|
||||
try {
|
||||
await switchPersonalWalletChain(targetChain.chainId);
|
||||
await switchChain(targetChain.chainId);
|
||||
} catch (e) {
|
||||
setSwitchError(true);
|
||||
} finally {
|
||||
|
||||
@@ -2,15 +2,12 @@ import {
|
||||
WalletConfig,
|
||||
ConnectUIProps,
|
||||
WalletOptions,
|
||||
useWalletContext,
|
||||
useWallet,
|
||||
} from "@thirdweb-dev/react-core";
|
||||
import { SmartWallet } from "@thirdweb-dev/wallets";
|
||||
import { SmartWalletConfig, SmartWalletConfigOptions } from "./types";
|
||||
import { SmartWalletConnecting } from "./SmartWalletConnecting";
|
||||
import { HeadlessConnectUI } from "../headlessConnectUI";
|
||||
import { useRef, useEffect, useState } from "react";
|
||||
import { Container } from "../../../components/basic";
|
||||
import { Spinner } from "../../../components/Spinner";
|
||||
|
||||
export const smartWallet = (
|
||||
wallet: WalletConfig<any>,
|
||||
@@ -37,53 +34,17 @@ export const smartWallet = (
|
||||
export const SmartConnectUI = (
|
||||
props: ConnectUIProps<SmartWallet> & { personalWallet: WalletConfig },
|
||||
) => {
|
||||
const {
|
||||
setIsConnectingToPersonalWallet,
|
||||
personalWalletInfo,
|
||||
isConnectingToPersonalWallet,
|
||||
} = useWalletContext();
|
||||
const activeWallet = useWallet();
|
||||
const { walletConfig } = props;
|
||||
const [isPersonalWalletConnected, setIsPersonalWalletConnected] =
|
||||
useState(false);
|
||||
|
||||
// hide the connection of personal wallet
|
||||
const mounted = useRef(false);
|
||||
useEffect(() => {
|
||||
if (!mounted.current) {
|
||||
setIsConnectingToPersonalWallet(true);
|
||||
mounted.current = true;
|
||||
}
|
||||
}, [setIsConnectingToPersonalWallet]);
|
||||
|
||||
const PersonalWalletConfig = props.personalWallet;
|
||||
|
||||
if (!isPersonalWalletConnected) {
|
||||
// if the isConnectingToPersonalWallet is not yet updated
|
||||
if (!isConnectingToPersonalWallet) {
|
||||
return (
|
||||
<Container
|
||||
flex="row"
|
||||
center="both"
|
||||
style={{
|
||||
minHeight: "250px",
|
||||
}}
|
||||
>
|
||||
<Spinner size="xl" color="accentText" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
if (!activeWallet) {
|
||||
const _props: ConnectUIProps = {
|
||||
...props,
|
||||
walletConfig: PersonalWalletConfig,
|
||||
connected: () => {
|
||||
setIsPersonalWalletConnected(true);
|
||||
setIsConnectingToPersonalWallet(false);
|
||||
},
|
||||
goBack() {
|
||||
personalWalletInfo.disconnect();
|
||||
setIsConnectingToPersonalWallet(false);
|
||||
props.goBack();
|
||||
// override to no-op
|
||||
},
|
||||
};
|
||||
|
||||
@@ -96,14 +57,10 @@ export const SmartConnectUI = (
|
||||
|
||||
return (
|
||||
<SmartWalletConnecting
|
||||
onBack={() => {
|
||||
personalWalletInfo.disconnect();
|
||||
setIsConnectingToPersonalWallet(false);
|
||||
props.goBack();
|
||||
}}
|
||||
onBack={props.goBack}
|
||||
onConnect={props.connected}
|
||||
smartWallet={walletConfig}
|
||||
personalWalletConfig={props.personalWallet}
|
||||
personalWallet={props.personalWallet}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 4.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`47b0ed51`](https://github.com/thirdweb-dev/js/commit/47b0ed5171be5608ae23c19481a1b04948443c6a), [`d4ce855e`](https://github.com/thirdweb-dev/js/commit/d4ce855e5f5e6c4206a3efa250e92e690ae87281)]:
|
||||
- @thirdweb-dev/chains@0.1.59
|
||||
|
||||
## 4.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "4.0.16",
|
||||
"version": "4.0.17",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.2.106
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1995](https://github.com/thirdweb-dev/js/pull/1995) [`914befda`](https://github.com/thirdweb-dev/js/commit/914befda16103a9ccf66bfb474492e346f8d77e9) Thanks [@0xFirekeeper](https://github.com/0xFirekeeper)! - [Unity] Add new tx/block processing methods to match their static C# counterparts
|
||||
|
||||
- Updated dependencies [[`47b0ed51`](https://github.com/thirdweb-dev/js/commit/47b0ed5171be5608ae23c19481a1b04948443c6a), [`d4ce855e`](https://github.com/thirdweb-dev/js/commit/d4ce855e5f5e6c4206a3efa250e92e690ae87281), [`b5bbe2bd`](https://github.com/thirdweb-dev/js/commit/b5bbe2bd438179c38451bc2cfa20a54fc79e4f3a)]:
|
||||
- @thirdweb-dev/chains@0.1.59
|
||||
- @thirdweb-dev/wallets@2.1.9
|
||||
- @thirdweb-dev/sdk@4.0.17
|
||||
- @thirdweb-dev/auth@4.1.12
|
||||
|
||||
## 0.2.105
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.2.105",
|
||||
"version": "0.2.106",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -92,6 +92,10 @@ interface TWBridge {
|
||||
smartWalletAddAdmin: (admin: string) => Promise<string | undefined>;
|
||||
smartWalletRemoveAdmin: (admin: string) => Promise<string | undefined>;
|
||||
smartWalletCreateSessionKey: (options: string) => Promise<string | undefined>;
|
||||
waitForTransactionResult: (txHash: string) => Promise<string>;
|
||||
getLatestBlockNumber: () => Promise<string>;
|
||||
getBlock: (blockNumber: string) => Promise<string>;
|
||||
getBlockWithTransactions: (blockNumber: string) => Promise<string>;
|
||||
}
|
||||
|
||||
const w = window;
|
||||
@@ -693,6 +697,38 @@ class ThirdwebBridge implements TWBridge {
|
||||
return JSON.stringify({ result: result }, bigNumberReplacer);
|
||||
}
|
||||
|
||||
public async waitForTransactionResult(txHash: string) {
|
||||
if (!this.activeSDK) {
|
||||
throw new Error("SDK not initialized");
|
||||
}
|
||||
const res = await this.activeSDK.getProvider().waitForTransaction(txHash);
|
||||
return JSON.stringify({ result: res }, bigNumberReplacer);
|
||||
}
|
||||
|
||||
public async getLatestBlockNumber(){
|
||||
if (!this.activeSDK) {
|
||||
throw new Error("SDK not initialized");
|
||||
}
|
||||
const res = await this.activeSDK.getProvider().getBlockNumber();
|
||||
return JSON.stringify({ result: res }, bigNumberReplacer);
|
||||
}
|
||||
|
||||
public async getBlock(blockNumber: string){
|
||||
if (!this.activeSDK) {
|
||||
throw new Error("SDK not initialized");
|
||||
}
|
||||
const res = await this.activeSDK.getProvider().getBlock(Number(blockNumber));
|
||||
return JSON.stringify({ result: res }, bigNumberReplacer);
|
||||
}
|
||||
|
||||
public async getBlockWithTransactions(blockNumber: string){
|
||||
if (!this.activeSDK) {
|
||||
throw new Error("SDK not initialized");
|
||||
}
|
||||
const res = await this.activeSDK.getProvider().getBlockWithTransactions(Number(blockNumber));
|
||||
return JSON.stringify({ result: res }, bigNumberReplacer);
|
||||
}
|
||||
|
||||
public openPopupWindow() {
|
||||
const win = window.open("", undefined, "width=350, height=500");
|
||||
if (win) {
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/wallets
|
||||
|
||||
## 2.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1992](https://github.com/thirdweb-dev/js/pull/1992) [`b5bbe2bd`](https://github.com/thirdweb-dev/js/commit/b5bbe2bd438179c38451bc2cfa20a54fc79e4f3a) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Look at last 10 blocks for recently submitted userOp
|
||||
|
||||
- Updated dependencies [[`47b0ed51`](https://github.com/thirdweb-dev/js/commit/47b0ed5171be5608ae23c19481a1b04948443c6a), [`d4ce855e`](https://github.com/thirdweb-dev/js/commit/d4ce855e5f5e6c4206a3efa250e92e690ae87281)]:
|
||||
- @thirdweb-dev/chains@0.1.59
|
||||
- @thirdweb-dev/sdk@4.0.17
|
||||
|
||||
## 2.1.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/wallets",
|
||||
"version": "2.1.8",
|
||||
"version": "2.1.9",
|
||||
"main": "dist/thirdweb-dev-wallets.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -30,7 +30,7 @@ export class UserOperationEventListener {
|
||||
// listener takes time... first query directly:
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
setTimeout(async () => {
|
||||
const res = await this.entryPoint.queryFilter(filter, "latest");
|
||||
const res = await this.entryPoint.queryFilter(filter, -10); // look at last 10 blocks
|
||||
if (res.length > 0) {
|
||||
void this.listenerCallback(res[0]);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user